Skip to content

Commit

Permalink
Merge branch 'master' into fix-nade-counts
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-wa authored Oct 13, 2023
2 parents 39822b1 + bb47007 commit 44bcacf
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/demoinfocs/common/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func (p *Player) Health() int {
// Armor returns the player's armor points, normally 0-100.
func (p *Player) Armor() int {
if p.demoInfoProvider.IsSource2() {
return getInt(p.Entity, "m_iPawnArmor")
return getInt(p.PlayerPawnEntity(), "m_ArmorValue")
}

return getInt(p.Entity, "m_ArmorValue")
Expand Down
19 changes: 19 additions & 0 deletions pkg/demoinfocs/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,25 @@ func (ru RankUpdate) SteamID64() uint64 {
return common.ConvertSteamID32To64(uint32(ru.SteamID32))
}

// OtherDeath signals that there has occurred a death of something that is not a player.
// For example chickens.
type OtherDeath struct {
Killer *common.Player // May be nil
Weapon *common.Equipment
PenetratedObjects int
NoScope bool
KillerBlind bool
ThroughSmoke bool

OtherType string
OtherID int32
OtherPosition r3.Vector
}

func (od OtherDeath) IsWallBang() bool {
return od.PenetratedObjects > 0
}

// ItemEquip signals an item was equipped.
// This event is not available in all demos.
type ItemEquip struct {
Expand Down
24 changes: 23 additions & 1 deletion pkg/demoinfocs/game_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func newGameEventHandler(parser *parser, ignoreBombsiteIndexNotFound bool) gameE
"item_pickup_slerp": nil, // Not sure, only in locally recorded (POV) demos
"item_remove": geh.itemRemove, // Dropped?
"jointeam_failed": nil, // Dunno, only in locally recorded (POV) demos
"other_death": nil, // Dunno
"other_death": geh.otherDeath, // Other deaths, like chickens.
"player_blind": delay(geh.playerBlind), // Player got blinded by a flash. Delayed because Player.FlashDuration hasn't been updated yet
"player_changename": nil, // Name change
"player_connect": geh.playerConnect, // Bot connected or player reconnected, players normally come in via string tables & data tables
Expand Down Expand Up @@ -839,6 +839,28 @@ func (geh gameEventHandler) itemRemove(data map[string]*msg.CSVCMsg_GameEventKey
})
}

func (geh gameEventHandler) otherDeath(data map[string]*msg.CSVCMsg_GameEventKeyT) {
killer := geh.playerByUserID32(data["attacker"].GetValShort())
otherType := data["othertype"].GetValString()
otherID := data["otherid"].GetValShort()
otherPosition := geh.gameState().entities[int(otherID)].Position()
wepType := common.MapEquipment(data["weapon"].GetValString())
weapon := getPlayerWeapon(killer, wepType)

geh.dispatch(events.OtherDeath{
Killer: killer,
Weapon: weapon,
PenetratedObjects: int(data["penetrated"].GetValShort()),
NoScope: data["noscope"].GetValBool(),
ThroughSmoke: data["thrusmoke"].GetValBool(),
KillerBlind: data["attackerblind"].GetValBool(),

OtherType: otherType,
OtherID: otherID,
OtherPosition: otherPosition,
})
}

func (geh gameEventHandler) itemEvent(data map[string]*msg.CSVCMsg_GameEventKeyT) (*common.Player, *common.Equipment) {
player := geh.playerByUserID32(data["userid"].GetValShort())

Expand Down
2 changes: 1 addition & 1 deletion pkg/demoinfocs/sendtables2/field_decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func runeTimeDecoder(r *reader) interface{} {
}

func simulationTimeDecoder(r *reader) interface{} {
return float32(r.readVarUint32()) * (1.0 / 30)
return float32(r.readVarUint32()) * (1.0 / 64)
}

func readBitCoordPres(r *reader) float32 {
Expand Down

0 comments on commit 44bcacf

Please sign in to comment.