diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2018-11-12 22:24:03 +0100 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2018-11-16 00:08:22 +0100 |
commit | 76e008b69d12c699bf86598d43e4d8cae0c8df27 (patch) | |
tree | 1b6c5f2882122f4a5bc833d25fbad02eafa10ab7 | |
parent | eb2a2d20e17bae90333d2b8a66f45711789104d5 (diff) |
Redo total score calculation.
-rw-r--r-- | src/game/g_main.c | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/src/game/g_main.c b/src/game/g_main.c index a403a4e..c0dd33f 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -2689,27 +2689,48 @@ AntistackHandicap ================= */ -static qboolean AntistackHandicap(void) +static void AntistackHandicap(void) { + int i, alienKills = 0, humanKills = 0; qboolean human_bias; float bias, handicap; - if (level.alienKills < g_antistackKillThreshold.integer && - level.humanKills < g_antistackKillThreshold.integer) - return qfalse; + for (i = 0; i < level.maxclients; i++) { + gclient_t *client = level.clients + i; + int kills; - if (level.humanKills > level.alienKills) { + if (client->pers.connected != CON_CONNECTED) + continue; + + if (client->ps.stats[STAT_PTEAM] == PTE_NONE) + continue; + + kills = client->ps.persistant[PERS_SCORE]; + if (kills < 0) + kills = 0; + + if (client->ps.stats[STAT_PTEAM] == PTE_ALIENS) + alienKills += kills; + else + humanKills += kills; + } + + if (alienKills < g_antistackKillThreshold.integer && + humanKills < g_antistackKillThreshold.integer) + goto no_handicap; + + if (humanKills > alienKills) { human_bias = qtrue; - bias = (float)level.humanKills / level.alienKills; + bias = (float)humanKills / alienKills; } else { human_bias = qfalse; - bias = (float)level.alienKills / level.humanKills; + bias = (float)alienKills / humanKills; } bias *= g_antistackBias.value; if (bias < g_antistackBiasThreshold.value) - return qfalse; + goto no_handicap; handicap = g_antistackHandicapMultiplier.value / (bias - 1.0f + 0.2f); @@ -2721,7 +2742,7 @@ static qboolean AntistackHandicap(void) level.humanHandicap = 1.0f; } - G_LogPrintf("Antistack: %d %d %f %s %f", level.alienKills, level.humanKills, + G_LogPrintf("Antistack: %d %d %f %s %f", alienKills, humanKills, bias, (human_bias ? "human" : "alien"), handicap); if (g_antistack.integer > 0) trap_SendServerCommand(-1, va("print \"^1Teams are uneven. %s income is decreased by %.0f percent.\n\"", @@ -2729,7 +2750,19 @@ static qboolean AntistackHandicap(void) (1.0f - handicap) * 100.0f)); level.antistackWasHandicapping = qtrue; - return qtrue; + return; + +no_handicap: + level.alienHandicap = 1.0f; + level.humanHandicap = 1.0f; + + G_LogPrintf("Antistack: %d %d n/a\n", + alienKills, humanKills); + + if (level.antistackWasHandicapping && g_antistack.integer > 0) + trap_SendServerCommand(-1, "print \"^1Teams are no longer uneven.\n\""); + + level.antistackWasHandicapping = qfalse; } /* @@ -2745,18 +2778,7 @@ static void CheckAntistack(void) if (level.time < level.antistackNextCheck) return; - if (!AntistackHandicap()) { - level.alienHandicap = 1.0f; - level.humanHandicap = 1.0f; - - G_LogPrintf("Antistack: %d %d n/a\n", - level.alienKills, level.humanKills); - - if (level.antistackWasHandicapping && g_antistack.integer > 0) - trap_SendServerCommand(-1, "print \"^1Teams are no longer uneven.\n\""); - - level.antistackWasHandicapping = qfalse; - } + AntistackHandicap(); // Negative g_antistack values cause a dry run and are for debugging. if (g_antistack.integer < 0) { |