@@ -72,14 +72,27 @@ func (p *Parser) bindEntities() {
7272func (p * Parser ) bindBomb () {
7373 bomb := & p .gameState .bomb
7474
75- // Track bomb when it is not held by a player
76- scDroppedC4 := p .stParser .ServerClasses ().FindByName ("CC4" )
77- scDroppedC4 .OnEntityCreated (func (bomb * st.Entity ) {
78- bomb .OnPositionUpdate (func (pos r3.Vector ) {
75+ // Track bomb when it is dropped on the ground or being held by a player
76+ scC4 := p .stParser .ServerClasses ().FindByName ("CC4" )
77+ scC4 .OnEntityCreated (func (bombEntity * st.Entity ) {
78+ bombEntity .OnPositionUpdate (func (pos r3.Vector ) {
7979 // Bomb only has a position when not held by a player
80- p . gameState . bomb .Carrier = nil
80+ bomb .Carrier = nil
8181
82- p .gameState .bomb .LastOnGroundPosition = pos
82+ bomb .LastOnGroundPosition = pos
83+ })
84+
85+ bombEntity .FindPropertyI ("m_hOwner" ).OnUpdate (func (val st.PropertyValue ) {
86+ bomb .Carrier = p .gameState .Participants ().FindByHandle (val .IntVal )
87+ })
88+
89+ bombEntity .FindPropertyI ("m_bStartedArming" ).OnUpdate (func (val st.PropertyValue ) {
90+ if val .IntVal != 0 {
91+ p .gameState .currentPlanter = bomb .Carrier
92+ } else if p .gameState .currentPlanter != nil {
93+ p .gameState .currentPlanter .IsPlanting = false
94+ p .eventDispatcher .Dispatch (events.BombPlantAborted {Player : p .gameState .currentPlanter })
95+ }
8396 })
8497 })
8598
@@ -91,14 +104,6 @@ func (p *Parser) bindBomb() {
91104
92105 bomb .LastOnGroundPosition = bombEntity .Position ()
93106 })
94-
95- // Track bomb when it is being held by a player
96- scPlayerC4 := p .stParser .ServerClasses ().FindByName ("CC4" )
97- scPlayerC4 .OnEntityCreated (func (bombEntity * st.Entity ) {
98- bombEntity .FindPropertyI ("m_hOwner" ).OnUpdate (func (val st.PropertyValue ) {
99- bomb .Carrier = p .gameState .Participants ().FindByHandle (val .IntVal )
100- })
101- })
102107}
103108
104109func (p * Parser ) bindTeamStates () {
@@ -299,6 +304,7 @@ func (p *Parser) bindNewPlayer(playerEntity st.IEntity) {
299304
300305 // Active weapon
301306 playerEntity .FindPropertyI ("m_hActiveWeapon" ).OnUpdate (func (val st.PropertyValue ) {
307+ pl .IsReloading = false
302308 pl .ActiveWeaponID = val .IntVal & entityHandleIndexMask
303309 })
304310
@@ -426,6 +432,10 @@ func (p *Parser) bindWeapon(entity *st.Entity, wepType common.EquipmentElement)
426432
427433 entity .FindPropertyI ("m_iClip1" ).OnUpdate (func (val st.PropertyValue ) {
428434 eq .AmmoInMagazine = val .IntVal - 1
435+
436+ if eq .Owner != nil {
437+ eq .Owner .IsReloading = false
438+ }
429439 })
430440 // Some weapons in some demos might be missing this property
431441 if reserveAmmoProp := entity .FindPropertyI ("m_iPrimaryReserveAmmoCount" ); reserveAmmoProp != nil {
0 commit comments