diff --git a/main.go b/main.go index 92585f1..03f1bb1 100644 --- a/main.go +++ b/main.go @@ -180,37 +180,44 @@ func main() { }) p.RegisterEventHandler(func(e events.Kill) { - if e.Killer != nil && e.Killer.SteamID64 != e.Victim.SteamID64 { - stat := getOrCreate(*e.Killer) - stat.Kills++ - if e.IsHeadshot { - stat.Headshots++ - } - if e.NoScope { - stat.NoScopes++ - } - if e.AttackerBlind { - stat.BlindKills++ - } - if e.ThroughSmoke { - stat.SmokeKills++ - } - if e.IsWallBang() { - stat.WallbangKills++ - } - if e.Weapon != nil { - switch e.Weapon.Type { - case common.EqKnife: - stat.KnifeKills++ - case common.EqZeus: - stat.ZeusKills++ + if e.Killer != nil && e.Victim != nil && e.Killer.SteamID64 != e.Victim.SteamID64 { + killerTeam := e.Killer.Team + victimTeam := e.Victim.Team + + if killerTeam != victimTeam && killerTeam != common.TeamSpectators { + stat := getOrCreate(*e.Killer) + stat.Kills++ + if e.IsHeadshot { + stat.Headshots++ + } + if e.NoScope { + stat.NoScopes++ + } + if e.AttackerBlind { + stat.BlindKills++ + } + if e.ThroughSmoke { + stat.SmokeKills++ + } + if e.IsWallBang() { + stat.WallbangKills++ + } + if e.Weapon != nil { + switch e.Weapon.Type { + case common.EqKnife: + stat.KnifeKills++ + case common.EqZeus: + stat.ZeusKills++ + } } } } + if e.Victim != nil { stat := getOrCreate(*e.Victim) stat.Deaths++ } + if e.Assister != nil { stat := getOrCreate(*e.Assister) stat.Assists++ @@ -227,7 +234,6 @@ func main() { p.RegisterEventHandler(func(e events.PlayerHurt) { if e.Attacker != nil && e.Attacker != e.Player { stat := getOrCreate(*e.Attacker) - stat.TotalDamage += e.HealthDamage if e.Weapon != nil { switch e.Weapon.Type { case common.EqHE, common.EqMolotov, common.EqIncendiary: @@ -301,8 +307,29 @@ func main() { for _, stat := range playerStats { sid, _ := parseSteamID(stat.SteamID) - if team, ok := teamHistory[1][sid]; ok { - stat.Team = team + lastTeam := "" + lastRound := 0 + + for roundNum, roundTeams := range teamHistory { + if team, ok := roundTeams[sid]; ok && roundNum > lastRound { + lastTeam = team + lastRound = roundNum + } + } + + stat.Team = lastTeam + } + + for _, player := range p.GameState().Participants().All() { + sid := player.SteamID64 + stat, ok := playerStats[sid] + if !ok || player.Entity == nil { + continue + } + + val, ok := player.Entity.PropertyValue("m_pActionTrackingServices.m_iDamage") + if ok { + stat.TotalDamage = val.Int() } } diff --git a/parser_cs2-linux b/parser_cs2-linux index 7842c8b..5fdc809 100644 Binary files a/parser_cs2-linux and b/parser_cs2-linux differ diff --git a/parser_cs2-win.exe b/parser_cs2-win.exe index 45f0d7b..a080fad 100644 Binary files a/parser_cs2-win.exe and b/parser_cs2-win.exe differ