From fad4cb5af9eefaf25b9fea8acf9ef66df131c75d Mon Sep 17 00:00:00 2001 From: ficool2 <34815548+ficool2@users.noreply.github.com> Date: Thu, 21 Apr 2022 18:10:17 +0100 Subject: [PATCH] Fix spectators getting karma bonus (#60) Remove penalty scaling by victim karma +5 karma loss for friendlyfire kills --- addons/sourcemod/scripting/scp_sf/classes.sp | 4 ++-- addons/sourcemod/scripting/scp_sf/sdkhooks.sp | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/addons/sourcemod/scripting/scp_sf/classes.sp b/addons/sourcemod/scripting/scp_sf/classes.sp index a4548676..f140963d 100644 --- a/addons/sourcemod/scripting/scp_sf/classes.sp +++ b/addons/sourcemod/scripting/scp_sf/classes.sp @@ -1113,8 +1113,8 @@ public void Classes_EscapeEscortBonus(int client) if (!IsValidClient(i)) continue; - - if (!IsPlayerAlive(i)) + + if (IsSpec(i)) continue; // the disarmer gets a different bonus diff --git a/addons/sourcemod/scripting/scp_sf/sdkhooks.sp b/addons/sourcemod/scripting/scp_sf/sdkhooks.sp index 80c9445e..aeb4e21d 100644 --- a/addons/sourcemod/scripting/scp_sf/sdkhooks.sp +++ b/addons/sourcemod/scripting/scp_sf/sdkhooks.sp @@ -575,13 +575,14 @@ public void OnTakeDamageAlivePost(int victim, int attacker, int inflictor, float // compensate for the other player's karma // don't apply this for friendlyfire damage though + // removed: this makes karma too lenient float victimkarmaratio = 1.0; - if (!IsFriendly(Client[victim].Class, DamageSavedClass)) - { - float victimkarma = Classes_GetKarma(victim); - victimkarmaratio = (victimkarma * 0.01); - penaltyamount = RoundFloat(float(penaltyamount) * victimkarmaratio); - } + //if (!IsFriendly(Client[victim].Class, DamageSavedClass)) + //{ + // float victimkarma = Classes_GetKarma(victim); + // victimkarmaratio = (victimkarma * 0.01); + // penaltyamount = RoundFloat(float(penaltyamount) * victimkarmaratio); + //} if ((checked == 2) || ((checked == 0) && IsBadKill(victim, attacker, DamageSavedClass))) { @@ -600,10 +601,14 @@ public void OnTakeDamageAlivePost(int victim, int attacker, int inflictor, float float karmaMin = CvarKarmaMin.FloatValue; float prevkarma = karma; + // lose 5 more karma for friendlyfire kills + if (IsFriendly(Client[victim].Class, DamageSavedClass)) + karmaPoints += 5.0; + // hack: this compensates for miniscule precision errors if (karmaPoints > 0.01) { - karma -= Client[attacker].KarmaPoints[victim] * victimkarmaratio; + karma -= karmaPoints * victimkarmaratio; if (karma < karmaMin) karma = karmaMin;