This commit is contained in:
Linrador 2025-07-31 17:42:19 +02:00
parent aa208a14d4
commit e41bb63fbd
3 changed files with 54 additions and 27 deletions

81
main.go
View File

@ -180,37 +180,44 @@ func main() {
}) })
p.RegisterEventHandler(func(e events.Kill) { p.RegisterEventHandler(func(e events.Kill) {
if e.Killer != nil && e.Killer.SteamID64 != e.Victim.SteamID64 { if e.Killer != nil && e.Victim != nil && e.Killer.SteamID64 != e.Victim.SteamID64 {
stat := getOrCreate(*e.Killer) killerTeam := e.Killer.Team
stat.Kills++ victimTeam := e.Victim.Team
if e.IsHeadshot {
stat.Headshots++ if killerTeam != victimTeam && killerTeam != common.TeamSpectators {
} stat := getOrCreate(*e.Killer)
if e.NoScope { stat.Kills++
stat.NoScopes++ if e.IsHeadshot {
} stat.Headshots++
if e.AttackerBlind { }
stat.BlindKills++ if e.NoScope {
} stat.NoScopes++
if e.ThroughSmoke { }
stat.SmokeKills++ if e.AttackerBlind {
} stat.BlindKills++
if e.IsWallBang() { }
stat.WallbangKills++ if e.ThroughSmoke {
} stat.SmokeKills++
if e.Weapon != nil { }
switch e.Weapon.Type { if e.IsWallBang() {
case common.EqKnife: stat.WallbangKills++
stat.KnifeKills++ }
case common.EqZeus: if e.Weapon != nil {
stat.ZeusKills++ switch e.Weapon.Type {
case common.EqKnife:
stat.KnifeKills++
case common.EqZeus:
stat.ZeusKills++
}
} }
} }
} }
if e.Victim != nil { if e.Victim != nil {
stat := getOrCreate(*e.Victim) stat := getOrCreate(*e.Victim)
stat.Deaths++ stat.Deaths++
} }
if e.Assister != nil { if e.Assister != nil {
stat := getOrCreate(*e.Assister) stat := getOrCreate(*e.Assister)
stat.Assists++ stat.Assists++
@ -227,7 +234,6 @@ func main() {
p.RegisterEventHandler(func(e events.PlayerHurt) { p.RegisterEventHandler(func(e events.PlayerHurt) {
if e.Attacker != nil && e.Attacker != e.Player { if e.Attacker != nil && e.Attacker != e.Player {
stat := getOrCreate(*e.Attacker) stat := getOrCreate(*e.Attacker)
stat.TotalDamage += e.HealthDamage
if e.Weapon != nil { if e.Weapon != nil {
switch e.Weapon.Type { switch e.Weapon.Type {
case common.EqHE, common.EqMolotov, common.EqIncendiary: case common.EqHE, common.EqMolotov, common.EqIncendiary:
@ -301,8 +307,29 @@ func main() {
for _, stat := range playerStats { for _, stat := range playerStats {
sid, _ := parseSteamID(stat.SteamID) sid, _ := parseSteamID(stat.SteamID)
if team, ok := teamHistory[1][sid]; ok { lastTeam := ""
stat.Team = team 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()
} }
} }

Binary file not shown.

Binary file not shown.