Skip to content

Commit

Permalink
Suicide stat was not being used at all
Browse files Browse the repository at this point in the history
Refactor suicide logic again
  • Loading branch information
nickdnk committed Jul 25, 2022
1 parent c8fe43d commit b9e4b87
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions scripting/get5/stats.sp
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ public Action Stats_PlayerDeathEvent(Event event, const char[] name, bool dontBr
// c4 is attacker 0, weapon id 0, weapon planted_c4
// with those in mind, we can determine suicide from this:
bool killedByBomb = StrEqual("planted_c4", weapon, true);
bool isSuicide = attacker == victim || (view_as<int>(weaponId) == 0 && !killedByBomb);
bool isSuicide = !killedByBomb && (attacker == victim || view_as<int>(weaponId) == 0);

IncrementPlayerStat(victim, STAT_DEATHS);
// used for calculating round KAST
Expand All @@ -724,8 +724,12 @@ public Action Stats_PlayerDeathEvent(Event event, const char[] name, bool dontBr
(victimTeam == CS_TEAM_CT) ? STAT_FIRSTDEATH_CT : STAT_FIRSTDEATH_T);
}

if (!isSuicide) {
if (attackerTeam != victimTeam) {
if (isSuicide) {
IncrementPlayerStat(victim, STAT_SUICIDES);
} else if (!killedByBomb) {
if (attackerTeam == victimTeam) {
IncrementPlayerStat(attacker, STAT_TEAMKILLS);
} else {
if (!g_TeamFirstKillDone[attackerTeam]) {
g_TeamFirstKillDone[attackerTeam] = true;
IncrementPlayerStat(attacker,
Expand Down Expand Up @@ -753,8 +757,6 @@ public Action Stats_PlayerDeathEvent(Event event, const char[] name, bool dontBr
weaponId > CSWeapon_MAX_WEAPONS_NO_KNIFES) {
IncrementPlayerStat(attacker, STAT_KNIFE_KILLS);
}
} else {
IncrementPlayerStat(attacker, STAT_TEAMKILLS);
}
}

Expand Down

0 comments on commit b9e4b87

Please sign in to comment.