From 90094e0e71e05b155a6a1edb1835607e1202a8bc Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Thu, 13 Apr 2017 11:30:00 +0000 Subject: Improve g_gradualFreeFunds. g_gradualFreeFunds values: 0 - disabled 1 - vanilla behavior 2 - 1 and counters don't reset on death or evolution 3 - 2 and funds are given even during SD --- src/game/g_active.c | 47 +++++++++++++++++++++++++++++++++++++---------- src/game/g_client.c | 2 +- src/game/g_combat.c | 2 +- src/game/g_main.c | 2 +- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/game/g_active.c b/src/game/g_active.c index e909ca6..ec92c97 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -1532,6 +1532,42 @@ static void G_UnlaggedDetectCollisions( gentity_t *ent ) G_UnlaggedOff( ); } +/* +============== +ClientGradualFunds + +g_gradualFreeFunds values: +0 - disabled +1 - vanilla behavior +2 - 1 and counters don't reset on death or evolution +3 - 2 and funds are given even during SD +============== +*/ +static void ClientGradualFunds( gentity_t *ent ) +{ + if( !g_gradualFreeFunds.integer ) + return; + + if( ent->client->pers.lastFreekillTime + FREEKILL_PERIOD >= level.time ) + return; + + if( g_suddenDeath.integer && g_gradualFreeFunds.integer < 3 ) + return; + + switch ( ent->client->ps.stats[ STAT_PTEAM ] ) + { + case PTE_ALIENS: + G_AddCreditToClient( ent->client, FREEKILL_ALIEN, qtrue ); + break; + + case PTE_HUMANS: + G_AddCreditToClient( ent->client, FREEKILL_HUMAN, qtrue ); + break; + } + + ent->client->pers.lastFreekillTime += FREEKILL_PERIOD; +} + /* ============== ClientThink @@ -1989,16 +2025,7 @@ void ClientThink_real( gentity_t *ent ) } // Give clients some credit periodically - if( ent->client->pers.lastFreekillTime + FREEKILL_PERIOD < level.time ) - { - if( !g_suddenDeath.integer || g_gradualFreeFunds.integer ) { - if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) - G_AddCreditToClient( ent->client, FREEKILL_ALIEN, qtrue ); - if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) - G_AddCreditToClient( ent->client, FREEKILL_HUMAN, qtrue ); - } - ent->client->pers.lastFreekillTime += FREEKILL_PERIOD; - } + ClientGradualFunds( ent ); // perform once-a-second actions ClientTimerActions( ent, msec ); diff --git a/src/game/g_client.c b/src/game/g_client.c index 54c05df..d36b237 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -1950,7 +1950,7 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles client->ps.pm_time = 100; client->respawnTime = level.time; - if( !g_gradualFreeFunds.integer ) + if( g_gradualFreeFunds.integer < 2 ) client->pers.lastFreekillTime = level.time; client->inactivityTime = level.time + g_inactivity.integer * 1000; diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 4cf2722..c781959 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -288,7 +288,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int { AddScore( attacker, 1 ); - if( !g_gradualFreeFunds.integer ) + if( g_gradualFreeFunds.integer < 2 ) attacker->client->pers.lastFreekillTime = level.time; attacker->client->pers.statscounters.kills++; attacker->client->pers.karma += 50; diff --git a/src/game/g_main.c b/src/game/g_main.c index 5f6bed8..814224d 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -425,7 +425,7 @@ static cvarTable_t gameCvarTable[ ] = { &g_buildPointsRecoverRate, "g_buildPointsRecoverRate", "0", CVAR_ARCHIVE, 0, qfalse }, { &g_dynamicBuildPoints, "g_dynamicBuildPoints", "0", CVAR_ARCHIVE, 0, qfalse }, { &g_instantBuild, "g_instantBuild", "0", CVAR_ARCHIVE, 0, qfalse }, - { &g_gradualFreeFunds, "g_gradualFreeFunds", "1", CVAR_ARCHIVE, 0, qtrue }, + { &g_gradualFreeFunds, "g_gradualFreeFunds", "2", CVAR_ARCHIVE, 0, qtrue }, { &g_chatTeamPrefix, "g_chatTeamPrefix", "1", CVAR_ARCHIVE }, { &g_sayAreaRange, "g_sayAreaRange", "1000", CVAR_ARCHIVE, 0, qtrue }, -- cgit