diff options
| author | IronClawTrem <louie.nutman@gmail.com> | 2019-08-27 01:15:15 +0100 | 
|---|---|---|
| committer | IronClawTrem <louie.nutman@gmail.com> | 2019-08-27 01:19:50 +0100 | 
| commit | 1c970daca1c62539325df935b7afce0ecc08823b (patch) | |
| tree | 3dd1bed6ba84a98d5280f67e50fb405385c45749 /src/game | |
| parent | def759fd4110b4f58ea54f3024fec5bf9112b4c2 (diff) | |
Implement g_gradualFreeFunds to improve time funds mechanic
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/g_active.c | 47 | ||||
| -rw-r--r-- | src/game/g_client.c | 3 | ||||
| -rw-r--r-- | src/game/g_cmds.c | 4 | ||||
| -rw-r--r-- | src/game/g_combat.c | 3 | ||||
| -rw-r--r-- | src/game/g_local.h | 4 | ||||
| -rw-r--r-- | src/game/g_main.c | 4 | 
6 files changed, 49 insertions, 16 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c index f171617..b5df273 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -1407,6 +1407,42 @@ static void G_UnlaggedDetectCollisions( gentity_t *ent )  /*  ============== +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  This will be called once for each client frame, which will @@ -1852,16 +1888,7 @@ void ClientThink_real( gentity_t *ent )    }    // Give clients some credit periodically -  if( ent->client->lastKillTime + FREEKILL_PERIOD < level.time ) -  { -    if( !g_suddenDeath.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->lastKillTime = level.time; -  } +  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 7a27f64..cc3d40e 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -1920,7 +1920,8 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles    client->ps.pm_time = 100;    client->respawnTime = level.time; -  client->lastKillTime = level.time; +  if( g_gradualFreeFunds.integer < 2 ) +    client->pers.lastFreekillTime = level.time;    client->inactivityTime = level.time + g_inactivity.integer * 1000;    client->latched_buttons = 0; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 09f8597..e4f6ad7 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -656,13 +656,15 @@ void G_ChangeTeam( gentity_t *ent, pTeam_t newTeam )  {    pTeam_t oldTeam = ent->client->pers.teamSelection;    qboolean isFixingImbalance=qfalse; -  +    if( oldTeam == newTeam )      return;    G_LeaveTeam( ent );    ent->client->pers.teamSelection = newTeam; +  ent->client->pers.lastFreekillTime = level.time; +    // G_LeaveTeam() calls G_StopFollowing() which sets spec mode to free.     // Undo that in this case, or else people can freespec while in the spawn queue on their new team    if( newTeam != PTE_NONE ) diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 569a613..091040e 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -275,7 +275,8 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int      {        AddScore( attacker, 1 ); -      attacker->client->lastKillTime = level.time; +      if( g_gradualFreeFunds.integer < 2 ) +        attacker->client->pers.lastFreekillTime = level.time;        attacker->client->pers.statscounters.kills++;        if( attacker->client->pers.teamSelection == PTE_ALIENS )         { diff --git a/src/game/g_local.h b/src/game/g_local.h index 5a41a78..c6352cd 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -422,6 +422,7 @@ typedef struct    int                 ping;    int                 lastTeamStatus; +  int                 lastFreekillTime;    int                 lastFloodTime;         // level.time of last flood-limited command    int                 floodDemerits;         // number of flood demerits accumulated @@ -508,8 +509,6 @@ struct gclient_s    int                 airOutTime; -  int                 lastKillTime;     // for multiple kill rewards -    qboolean            fireHeld;         // used for hook    qboolean            fire2Held;        // used for alt fire    gentity_t           *hook;            // grapple hook if out @@ -1486,6 +1485,7 @@ extern  vmCvar_t  g_aimbotAdvertBanReason;  extern  vmCvar_t  g_Bubbles;  extern  vmCvar_t  g_scrimMode; +extern  vmCvar_t  g_gradualFreeFunds;  void      trap_Printf( const char *fmt );  void      trap_Error( const char *fmt ); diff --git a/src/game/g_main.c b/src/game/g_main.c index 4ae31bb..19d98ad 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -237,6 +237,7 @@ vmCvar_t  g_aimbotAdvertBanReason;  vmCvar_t  g_Bubbles;  vmCvar_t  g_scrimMode; +vmCvar_t  g_gradualFreeFunds;  static cvarTable_t   gameCvarTable[ ] =  { @@ -451,7 +452,8 @@ static cvarTable_t   gameCvarTable[ ] =    { &g_aimbotAdvertBanReason, "g_aimbotAdvertBanReason", "AUTOBAN: AIMBOT", CVAR_ARCHIVE, 0, qfalse  },    { &g_Bubbles, "g_Bubbles", "1", CVAR_ARCHIVE, 0, qfalse  }, -  { &g_scrimMode, "g_scrimMode", "0", CVAR_ARCHIVE, 0, qfalse } +  { &g_scrimMode, "g_scrimMode", "0", CVAR_ARCHIVE, 0, qfalse }, +  { &g_gradualFreeFunds, "g_gradualFreeFunds", "2", CVAR_ARCHIVE, 0, qtrue  }  };  static int gameCvarTableSize = sizeof( gameCvarTable ) / sizeof( gameCvarTable[ 0 ] );  | 
