demoinfocs-golang
demoinfocs-golang copied to clipboard
Ability to tell if a player can fire his weapon (e.g. after reloading)
Originally requested on Gitter by @skilaren
Hi, I have question, is it possible to retrieve somehow info about moment when player switched weapons and cant shoot yet simply? Or I should figure out it within active weapon and enitites' updates info?
...
would like to see some property of player which is related to this switch animation. didn't found any solution so far except counting ticks after active weapon was changed
Higher goal Be able to tell if a player had the ability to react to being shot. For instance if a player is getting shot while reloading or planting the bomb he has a limited ability to react.
Describe the solution you'd like
Player.IsAbleToFireWeapon()
Describe alternatives you've considered
Player.IsReloadAnimationComplete()
Additional context So far we haven't found any property on the player entity giving us this information, any help would be very much appreciated.
Maybe these values in the weapon table would be it? https://github.com/saul/demofile/blob/1849dba325574b221adac92e8f7f650dbb968a0c/src/sendtabletypes.ts#L2319-L2320 Rather than being attached to the player, it might be attached to the weapon, which makes sense to me I guess.
Though there are a few reasons why someone might not be able to shoot their gun, if you want this to be comprehensive:
- They are in the process of reloading (ammo in clip not refreshed)
- They are in the process of reloading (ammo in clip is refreshed)
- Clip is out of ammo
- Weapon completely out of ammo
- The player just shot and needs to wait to shoot again (based on the weapon's fire rate)
- The player just switched to the weapon and is in the process of pulling the weapon out
- It is freezetime, end of half, end of the match, or another game state where players can't shoot
I can't think of any more :)
EDIT:
- taking on/off a silencer
- toggling burst mode?
cheers @billfreeman44 :pray: those props from demofile might come in handy. I guess it's just really hard to know at what point all scenarios are covered :thinking:
Might just start off with better out-of-the-box support for some of those props and take it from there :smile:
m_flNextPrimaryAttack
should cover:
- deploying weapon
- reloading weapon
- just shot (next shot allowed dependent on fire rate)
- attaching/removing silencer
- burst mode
But won't cover being out of ammo/freeze time.
thanks @saul - great input!