From 6fcf641ebb9b68216904352b33e1c8a1831d3ae4 Mon Sep 17 00:00:00 2001 From: AkiVer Date: Tue, 10 Oct 2023 01:17:35 +0200 Subject: [PATCH 1/8] fix: simulation time decoder tickrate --- pkg/demoinfocs/sendtables2/field_decoder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/demoinfocs/sendtables2/field_decoder.go b/pkg/demoinfocs/sendtables2/field_decoder.go index fc7cb997..8254358f 100644 --- a/pkg/demoinfocs/sendtables2/field_decoder.go +++ b/pkg/demoinfocs/sendtables2/field_decoder.go @@ -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 { From 86881d2cf0da1c793a290390aa24459797addaa7 Mon Sep 17 00:00:00 2001 From: Esben Glavind Clausen Date: Wed, 11 Oct 2023 08:57:08 +0200 Subject: [PATCH 2/8] Source 2: Fixed Player.Armor() sometimes being a few ticks outdated. Experiments show that m_iPawnArmor on the Player entity tends to be updated a few ticks later than m_ArmorValue of the Pawn entity. --- pkg/demoinfocs/common/player.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/demoinfocs/common/player.go b/pkg/demoinfocs/common/player.go index e8a0a1e5..6f581857 100644 --- a/pkg/demoinfocs/common/player.go +++ b/pkg/demoinfocs/common/player.go @@ -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") From 7ca1fd40ed769f60c00e20534a3b875bd688da91 Mon Sep 17 00:00:00 2001 From: Frederik Date: Fri, 13 Oct 2023 11:50:24 +0200 Subject: [PATCH 3/8] added otherdeath to geh --- pkg/demoinfocs/game_events.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/demoinfocs/game_events.go b/pkg/demoinfocs/game_events.go index 671430c6..bf58a1ff 100644 --- a/pkg/demoinfocs/game_events.go +++ b/pkg/demoinfocs/game_events.go @@ -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, // Dunno "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 @@ -839,6 +839,20 @@ 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() + + geh.dispatch(events.OtherDeath{ + Killer: killer, + 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()) From a45718d0abf2d2d292a8558a26759c00c07fa986 Mon Sep 17 00:00:00 2001 From: Frederik Date: Fri, 13 Oct 2023 11:50:39 +0200 Subject: [PATCH 4/8] added otherdeath struct to events --- pkg/demoinfocs/events/events.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/demoinfocs/events/events.go b/pkg/demoinfocs/events/events.go index bca46458..abd76f50 100644 --- a/pkg/demoinfocs/events/events.go +++ b/pkg/demoinfocs/events/events.go @@ -504,6 +504,15 @@ type RankUpdate struct { Player *common.Player // may be nil if the player has already disconnected } +// OtherDeath signals that there has occured a death of something that is not a player. +// For example chickens. +type OtherDeath struct { + Killer *common.Player // May be nil + OtherType string + OtherID int32 + OtherPosition r3.Vector +} + // SteamID64 converts SteamID32 to the 64-bit SteamID variant and returns the result. // See https://developer.valvesoftware.com/wiki/SteamID func (ru RankUpdate) SteamID64() uint64 { From c065873b356fcbf8769359154073a330b452a988 Mon Sep 17 00:00:00 2001 From: Frederik Date: Fri, 13 Oct 2023 11:57:54 +0200 Subject: [PATCH 5/8] update comment --- pkg/demoinfocs/game_events.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/demoinfocs/game_events.go b/pkg/demoinfocs/game_events.go index bf58a1ff..d30f0893 100644 --- a/pkg/demoinfocs/game_events.go +++ b/pkg/demoinfocs/game_events.go @@ -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": geh.otherDeath, // 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 From 3dfd962eb803b2d40b1b8651a874fa7d7e519632 Mon Sep 17 00:00:00 2001 From: Frederik Lind <61952615+Falderebet@users.noreply.github.com> Date: Fri, 13 Oct 2023 12:11:08 +0200 Subject: [PATCH 6/8] Misspelling fix --- pkg/demoinfocs/events/events.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/demoinfocs/events/events.go b/pkg/demoinfocs/events/events.go index abd76f50..910eaeef 100644 --- a/pkg/demoinfocs/events/events.go +++ b/pkg/demoinfocs/events/events.go @@ -504,7 +504,7 @@ type RankUpdate struct { Player *common.Player // may be nil if the player has already disconnected } -// OtherDeath signals that there has occured a death of something that is not a player. +// 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 From 7083ef6e7347199dc3142f0146a43ed44812a2ce Mon Sep 17 00:00:00 2001 From: Frederik Date: Fri, 13 Oct 2023 12:45:17 +0200 Subject: [PATCH 7/8] Added extra data fields for Otherdeath struct --- pkg/demoinfocs/events/events.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pkg/demoinfocs/events/events.go b/pkg/demoinfocs/events/events.go index abd76f50..fdfbad07 100644 --- a/pkg/demoinfocs/events/events.go +++ b/pkg/demoinfocs/events/events.go @@ -504,19 +504,29 @@ type RankUpdate struct { Player *common.Player // may be nil if the player has already disconnected } +// SteamID64 converts SteamID32 to the 64-bit SteamID variant and returns the result. +// See https://developer.valvesoftware.com/wiki/SteamID +func (ru RankUpdate) SteamID64() uint64 { + return common.ConvertSteamID32To64(uint32(ru.SteamID32)) +} + // OtherDeath signals that there has occured a death of something that is not a player. // For example chickens. type OtherDeath struct { - Killer *common.Player // May be nil + Killer *common.Player // May be nil + Weapon *common.Equipment + PenetratedObjects int + NoScope bool + KillerBlind bool + ThroughSmoke bool + OtherType string OtherID int32 OtherPosition r3.Vector } -// SteamID64 converts SteamID32 to the 64-bit SteamID variant and returns the result. -// See https://developer.valvesoftware.com/wiki/SteamID -func (ru RankUpdate) SteamID64() uint64 { - return common.ConvertSteamID32To64(uint32(ru.SteamID32)) +func (od OtherDeath) IsWallBang() bool { + return od.PenetratedObjects > 0 } // ItemEquip signals an item was equipped. From 08d6bb723461949093b9def62fbf5174caca7143 Mon Sep 17 00:00:00 2001 From: Frederik Date: Fri, 13 Oct 2023 12:45:49 +0200 Subject: [PATCH 8/8] Binding event data to otherdeath struct event --- pkg/demoinfocs/game_events.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/demoinfocs/game_events.go b/pkg/demoinfocs/game_events.go index d30f0893..3c6253ef 100644 --- a/pkg/demoinfocs/game_events.go +++ b/pkg/demoinfocs/game_events.go @@ -844,9 +844,17 @@ func (geh gameEventHandler) otherDeath(data map[string]*msg.CSVCMsg_GameEventKey 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, + 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,