Skip to content

Commit

Permalink
Improved damage report to include kills, assists and flash assists. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdnk authored Dec 26, 2021
1 parent 6005843 commit 3cf1f7d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
7 changes: 5 additions & 2 deletions scripting/get5.sp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ int g_PlayerKilledBy[MAXPLAYERS + 1];
float g_PlayerKilledByTime[MAXPLAYERS + 1];
int g_DamageDone[MAXPLAYERS + 1][MAXPLAYERS + 1];
int g_DamageDoneHits[MAXPLAYERS + 1][MAXPLAYERS + 1];
bool g_DamageDoneKill[MAXPLAYERS + 1][MAXPLAYERS + 1];
bool g_DamageDoneAssist[MAXPLAYERS + 1][MAXPLAYERS + 1];
bool g_DamageDoneFlashAssist[MAXPLAYERS + 1][MAXPLAYERS + 1];
bool g_PlayerRoundKillOrAssistOrTradedDeath[MAXPLAYERS + 1];
bool g_PlayerSurvived[MAXPLAYERS + 1];
KeyValues g_StatsKv;
Expand Down Expand Up @@ -270,8 +273,8 @@ public void OnPluginStart() {
CreateConVar("get5_print_damage", "0", "Whether damage reports are printed on round end.");
g_DamagePrintFormat = CreateConVar(
"get5_damageprint_format",
"--> ({DMG_TO} dmg / {HITS_TO} hits) to ({DMG_FROM} dmg / {HITS_FROM} hits) from {NAME} ({HEALTH} HP)",
"Format of the damage output string. Avaliable tags are in the default, color tags such as {LIGHT_RED} and {GREEN} also work.");
"- [{KILL_TO}] ({DMG_TO} in {HITS_TO}) to [{KILL_FROM}] ({DMG_FROM} in {HITS_FROM}) from {NAME} ({HEALTH} HP)",
"Format of the damage output string. Available tags are in the default, color tags such as {LIGHT_RED} and {GREEN} also work. {KILL_TO} and {KILL_FROM} indicate kills, assists and flash assists as booleans, all of which are mutually exclusive.");
g_CheckAuthsCvar =
CreateConVar("get5_check_auths", "1",
"If set to 0, get5 will not force players to the correct team based on steamid");
Expand Down
34 changes: 30 additions & 4 deletions scripting/get5/stats.sp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public void Stats_ResetClientRoundValues(int client) {
for (int i = 1; i <= MaxClients; i++) {
g_DamageDone[client][i] = 0;
g_DamageDoneHits[client][i] = 0;
g_DamageDoneKill[client][i] = false;
g_DamageDoneAssist[client][i] = false;
g_DamageDoneFlashAssist[client][i] = false;
}
}

Expand Down Expand Up @@ -226,6 +229,7 @@ public Action Stats_PlayerDeathEvent(Event event, const char[] name, bool dontBr

g_PlayerKilledBy[victim] = attacker;
g_PlayerKilledByTime[victim] = GetGameTime();
g_DamageDoneKill[attacker][victim] = true;
UpdateTradeStat(attacker, victim);

IncrementPlayerStat(attacker, STAT_KILLS);
Expand Down Expand Up @@ -253,9 +257,11 @@ public Action Stats_PlayerDeathEvent(Event event, const char[] name, bool dontBr
// You cannot flash-assist and regular-assist for the same kill.
if (assistedFlash) {
IncrementPlayerStat(assister, STAT_FLASHBANG_ASSISTS);
g_DamageDoneFlashAssist[assister][victim] = true;
} else {
IncrementPlayerStat(assister, STAT_ASSISTS);
g_PlayerRoundKillOrAssistOrTradedDeath[assister] = true;
g_DamageDoneAssist[assister][victim] = true;
}

} else {
Expand Down Expand Up @@ -618,11 +624,31 @@ static void PrintDamageInfo(int client) {

g_DamagePrintFormat.GetString(message, sizeof(message));
ReplaceStringWithInt(message, sizeof(message), "{DMG_TO}", g_DamageDone[client][i], false);
ReplaceStringWithInt(message, sizeof(message), "{HITS_TO}", g_DamageDoneHits[client][i],
false);
ReplaceStringWithInt(message, sizeof(message), "{HITS_TO}", g_DamageDoneHits[client][i], false);

if (g_DamageDoneKill[client][i]) {
ReplaceString(message, sizeof(message), "{KILL_TO}", "{GREEN}X{NORMAL}", false);
} else if (g_DamageDoneAssist[client][i]) {
ReplaceString(message, sizeof(message), "{KILL_TO}", "{YELLOW}A{NORMAL}", false);
} else if (g_DamageDoneFlashAssist[client][i]) {
ReplaceString(message, sizeof(message), "{KILL_TO}", "{YELLOW}F{NORMAL}", false);
} else {
ReplaceString(message, sizeof(message), "{KILL_TO}", "", false);
}

ReplaceStringWithInt(message, sizeof(message), "{DMG_FROM}", g_DamageDone[i][client], false);
ReplaceStringWithInt(message, sizeof(message), "{HITS_FROM}", g_DamageDoneHits[i][client],
false);
ReplaceStringWithInt(message, sizeof(message), "{HITS_FROM}", g_DamageDoneHits[i][client], false);

if (g_DamageDoneKill[i][client]) {
ReplaceString(message, sizeof(message), "{KILL_FROM}", "{DARK_RED}X{NORMAL}", false);
} else if (g_DamageDoneAssist[i][client]) {
ReplaceString(message, sizeof(message), "{KILL_FROM}", "{YELLOW}A{NORMAL}", false);
} else if (g_DamageDoneFlashAssist[i][client]) {
ReplaceString(message, sizeof(message), "{KILL_FROM}", "{YELLOW}F{NORMAL}", false);
} else {
ReplaceString(message, sizeof(message), "{KILL_FROM}", "", false);
}

ReplaceString(message, sizeof(message), "{NAME}", name, false);
ReplaceStringWithInt(message, sizeof(message), "{HEALTH}", health, false);

Expand Down

0 comments on commit 3cf1f7d

Please sign in to comment.