garrysmod-issues icon indicating copy to clipboard operation
garrysmod-issues copied to clipboard

GetNextPrimary/SecondaryFire doesn't update for npcs

Open Ramalayha opened this issue 3 years ago • 3 comments

It gets set to CurTime() when they spawn but doesn't change when they shoot.

To reproduce:

  • Spawn an npc with a weapon.
  • Look at it and type "lua_run print(Entity(1):GetEyeTrace().Entity:GetActiveWeapon():GetNextPrimaryFire())" in console before and after it shoots and see that it doesn't change.

Ramalayha avatar Feb 07 '22 12:02 Ramalayha

It's not a bug, NPCs use an internal "shot regulator" that dictates when they can shoot and how often.

For SWEPs it can be controlled via the GetNPC callbacks, such as: https://wiki.facepunch.com/gmod/WEAPON:GetNPCBulletSpread https://wiki.facepunch.com/gmod/WEAPON:GetNPCBurstSettings https://wiki.facepunch.com/gmod/WEAPON:GetNPCRestTimes

robotboy655 avatar Feb 07 '22 14:02 robotboy655

I see

Ramalayha avatar Feb 07 '22 16:02 Ramalayha

The function could be made to be an alias for the lastshot time + lowest rest time for NPCs.

Kefta avatar Feb 07 '22 20:02 Kefta