Skip to content

Commit

Permalink
Fix spectators getting karma bonus (redsunservers#60)
Browse files Browse the repository at this point in the history
Remove penalty scaling by victim karma
+5 karma loss for friendlyfire kills
  • Loading branch information
ficool2 authored Apr 21, 2022
1 parent 498093d commit fad4cb5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/scp_sf/classes.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 12 additions & 7 deletions addons/sourcemod/scripting/scp_sf/sdkhooks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
{
Expand All @@ -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;

Expand Down

0 comments on commit fad4cb5

Please sign in to comment.