Skip to content

Conversation

@SimoSbara
Copy link
Contributor

@SimoSbara SimoSbara commented Dec 21, 2025

This PR refers to #1158.

Status:

  • NPC_SetPos may remove bot from vehicle (solved in 6cac7da)
  • NPC doesn't call vehicle events like death or respawn (it deserves another PR)
  • NPC_EnableInfiniteAmmo has no effect if NPC_SetAmmo wasn't used (done)

@SimoSbara
Copy link
Contributor Author

After some debugging of the vehicle death event I observed that:
If a vehicle's health were set at value <= 250 and it has never been occupied by a player in his lifetime (common if you use it with a NPC), the Vehicle::setDead() will never be called, and consequently OnVehicleDeath() will also be missed! This happens because the clients won't send the VehicleDeath's packet (id 136) at the vehicle explosion, because they never entered the vehicle in the first place!

There is another way that the client can inform the vehicle's death to the player: vehicle.cpp:304 where the client can sync vehicles while onfoot. However, after multiple testing, it seems that the condition if (health <= 0.f) is never encoutered because after the explosion (health = 0), the client doesn't send anymore PlayerUnoccupiedSync's packet (id 209).

Side note: unoccupiedSync.SeatID != 0 could be removed because it seems like SeatID is always 0 when the player is on foot. (maybe it is used in some particular cases?)

Can anyone confirm/reject these observations?

@SimoSbara
Copy link
Contributor Author

@AmyrAhmady, I think it's better that I transform this PR for the infinite ammo improvement for NPC only. The vehicle death it's a separate question (from the observation that I had), and for the "NPC_SetPos issue" I saw that you already commit a fix.

What do you think?

@NexiusTailer
Copy link
Contributor

NexiusTailer commented Dec 28, 2025

Thanks for your work and attention to my issue. I think the first item in the list can also be completely solved by adding NPC_SetVehiclePos (instead of any changes into NPC_SetPos), so there will be no differences with player manipulation natives.

@SimoSbara
Copy link
Contributor Author

I edited the PR, now it addresses the infinite ammo behaviour issue.

I think the first item in the list can also be completely solved by adding NPC_SetVehiclePos

I think it's better to separate it with another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants