Skip to content

Commit bb47007

Browse files
authored
Merge pull request #440 from Falderebet/add-otherdeath-event
Add otherdeath event handling
2 parents 5c02316 + 372ffb1 commit bb47007

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

pkg/demoinfocs/events/events.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,25 @@ func (ru RankUpdate) SteamID64() uint64 {
510510
return common.ConvertSteamID32To64(uint32(ru.SteamID32))
511511
}
512512

513+
// OtherDeath signals that there has occurred a death of something that is not a player.
514+
// For example chickens.
515+
type OtherDeath struct {
516+
Killer *common.Player // May be nil
517+
Weapon *common.Equipment
518+
PenetratedObjects int
519+
NoScope bool
520+
KillerBlind bool
521+
ThroughSmoke bool
522+
523+
OtherType string
524+
OtherID int32
525+
OtherPosition r3.Vector
526+
}
527+
528+
func (od OtherDeath) IsWallBang() bool {
529+
return od.PenetratedObjects > 0
530+
}
531+
513532
// ItemEquip signals an item was equipped.
514533
// This event is not available in all demos.
515534
type ItemEquip struct {

pkg/demoinfocs/game_events.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func newGameEventHandler(parser *parser, ignoreBombsiteIndexNotFound bool) gameE
210210
"item_pickup_slerp": nil, // Not sure, only in locally recorded (POV) demos
211211
"item_remove": geh.itemRemove, // Dropped?
212212
"jointeam_failed": nil, // Dunno, only in locally recorded (POV) demos
213-
"other_death": nil, // Dunno
213+
"other_death": geh.otherDeath, // Other deaths, like chickens.
214214
"player_blind": delay(geh.playerBlind), // Player got blinded by a flash. Delayed because Player.FlashDuration hasn't been updated yet
215215
"player_changename": nil, // Name change
216216
"player_connect": geh.playerConnect, // Bot connected or player reconnected, players normally come in via string tables & data tables
@@ -839,6 +839,28 @@ func (geh gameEventHandler) itemRemove(data map[string]*msg.CSVCMsg_GameEventKey
839839
})
840840
}
841841

842+
func (geh gameEventHandler) otherDeath(data map[string]*msg.CSVCMsg_GameEventKeyT) {
843+
killer := geh.playerByUserID32(data["attacker"].GetValShort())
844+
otherType := data["othertype"].GetValString()
845+
otherID := data["otherid"].GetValShort()
846+
otherPosition := geh.gameState().entities[int(otherID)].Position()
847+
wepType := common.MapEquipment(data["weapon"].GetValString())
848+
weapon := getPlayerWeapon(killer, wepType)
849+
850+
geh.dispatch(events.OtherDeath{
851+
Killer: killer,
852+
Weapon: weapon,
853+
PenetratedObjects: int(data["penetrated"].GetValShort()),
854+
NoScope: data["noscope"].GetValBool(),
855+
ThroughSmoke: data["thrusmoke"].GetValBool(),
856+
KillerBlind: data["attackerblind"].GetValBool(),
857+
858+
OtherType: otherType,
859+
OtherID: otherID,
860+
OtherPosition: otherPosition,
861+
})
862+
}
863+
842864
func (geh gameEventHandler) itemEvent(data map[string]*msg.CSVCMsg_GameEventKeyT) (*common.Player, *common.Equipment) {
843865
player := geh.playerByUserID32(data["userid"].GetValShort())
844866

0 commit comments

Comments
 (0)