-
Notifications
You must be signed in to change notification settings - Fork 115
Description
Describe the bug
Occasionally (about 10% from my testitng) grenades will have WeaponInstance.Entity as nil when retrieved inside event handler functions for events like WeaponFire or GrenadeProjectileThrown.
In WeaponFire events, this only happens to grenade weapons.
To Reproduce
Demos from any of the following, but not limited to matches:
https://www.hltv.org/matches/2378899/vitality-vs-faze-iem-katowice-2025
https://www.hltv.org/matches/2378897/eternal-fire-vs-virtuspro-iem-katowice-2025
https://www.hltv.org/matches/2378898/falcons-vs-g2-iem-katowice-2025
Code:
func main() { // ... p.RegisterEventHandler(func(e events.GrenadeProjectileThrow) { if e.Projectile.WeaponInstance.Entity == nil { fmt.Println("Missing Entity") } }) // ... }
Expected behavior
Every nade should have a corresponding WeaponInstance.Entity.
Library version
v4.3.3
Additional context
I have also observed, that for all of the nades in these demos, where WeaponInstance.Entity is missing, WeaponInstance.Owner is also missing.
I have also tested with the code below to confirm that the cause of this issue is not that those entities are destroyed when a grenade is thrown.
func main() { // ... lastNonNilWeaponEntities := make(map[ulid.ULID]st.Entity) p.RegisterEventHandler(func(e events.FrameDone) { for _, player := range p.GameState().Participants().Playing() { for _, weapon := range player.Weapons() { ent := weapon.Entity if ent == nil { continue } lastNonNilWeaponEntities[weapon.UniqueID2()] = weapon.Entity } } }) p.RegisterEventHandler(func(e events.GrenadeProjectileThrow) { projectileWeaponInstanceId := e.Projectile.WeaponInstance.UniqueID2() projectileWeaponInstanceEntity := lastNonNilWeaponEntities[projectileWeaponInstanceId] if projectileWeaponInstanceEntity == nil { fmt.Println("Missing Entity") return } }) // ... }