summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheriaca <reichmeister@protonmail.com>2019-01-26 18:36:30 +0100
committerPaweł Redman <pawel.redman@gmail.com>2019-02-10 14:47:47 +0100
commit50e64c25d1ed0334711987175b5cc1ce73e8477c (patch)
treeda45f7757627e0a65454aac2248f4edda98d37e0
parent128acaff79c423102e83adf8ad87d883af607640 (diff)
fix PERS_CREDIT clusterfuck; nuke retribution code; and more
- move ClientGradualFunds() call before death check - use pers.funds in game code, sync PERS_CREDIT only when necessary
-rw-r--r--src/game/g_active.c9
-rw-r--r--src/game/g_cmds.c9
-rw-r--r--src/game/g_combat.c128
-rw-r--r--src/game/g_local.h1
-rw-r--r--src/game/g_main.c2
5 files changed, 10 insertions, 139 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c
index 5cdf985..0a484ee 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -1923,6 +1923,11 @@ void ClientThink_real( gentity_t *ent )
if( ent->client->ps.eventSequence != oldEventSequence )
ent->eventTime = level.time;
+ // Give clients some credit periodically
+ ClientGradualFunds( ent );
+
+ client->ps.persistant[ PERS_CREDIT ] = client->pers.funds;
+
// Don't think anymore if dead
if( client->ps.stats[ STAT_HEALTH ] <= 0 )
return;
@@ -2025,9 +2030,6 @@ void ClientThink_real( gentity_t *ent )
client->retriggerArmouryMenu = 0;
}
- // Give clients some credit periodically
- ClientGradualFunds( ent );
-
// perform once-a-second actions
ClientTimerActions( ent, msec );
@@ -2164,7 +2166,6 @@ void ClientEndFrame( gentity_t *ent )
// save a copy of certain playerState values in case of SPECTATOR_FOLLOW
pers->score = ent->client->ps.persistant[ PERS_SCORE ];
- pers->funds = ent->client->ps.persistant[ PERS_CREDIT ];
//
// If the end of unit layout is displayed, don't give
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index d6126c8..470376d 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -708,6 +708,7 @@ void G_ChangeTeam( gentity_t *ent, pTeam_t newTeam )
ent->client->pers.score = 0;
}
+ ent->client->ps.persistant[ PERS_CREDIT ] = ent->client->pers.funds;
ent->client->ps.persistant[ PERS_KILLED ] = 0;
ent->client->pers.statscounters.kills = 0;
ent->client->pers.statscounters.structskilled = 0;
@@ -3266,7 +3267,7 @@ void Cmd_Class_f( gentity_t *ent )
numLevels = BG_ClassCanEvolveFromTo( currentClass,
newClass,
- (short)ent->client->ps.persistant[ PERS_CREDIT ], 0 );
+ floorf( ent->client->pers.funds ), 0 );
if( G_RoomForClassChange( ent, newClass, infestOrigin ) )
{
@@ -3925,7 +3926,7 @@ void Cmd_Buy_f( gentity_t *ent )
}
//can afford this?
- if( BG_FindPriceForWeapon( weapon ) > (short)ent->client->ps.persistant[ PERS_CREDIT ] )
+ if( BG_FindPriceForWeapon( weapon ) > ent->client->pers.funds )
{
G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS );
return;
@@ -3996,7 +3997,7 @@ void Cmd_Buy_f( gentity_t *ent )
}
//can afford this?
- if( BG_FindPriceForUpgrade( upgrade ) > (short)ent->client->ps.persistant[ PERS_CREDIT ] )
+ if( BG_FindPriceForUpgrade( upgrade ) > ent->client->pers.funds )
{
G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS );
return;
@@ -5029,7 +5030,7 @@ void Cmd_PTRCRestore_f( gentity_t *ent )
G_ChangeTeam( ent, connection->clientTeam );
// set the correct credit etc.
- ent->client->ps.persistant[ PERS_CREDIT ] = 0;
+ ent->client->pers.funds = 0;
G_AddFundsToClient( ent->client, connection->clientCredit, qtrue );
ent->client->pers.score = connection->clientScore;
ent->client->pers.enterTime = connection->clientEnterTime;
diff --git a/src/game/g_combat.c b/src/game/g_combat.c
index d834fcd..29ab80f 100644
--- a/src/game/g_combat.c
+++ b/src/game/g_combat.c
@@ -274,15 +274,6 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
if( attacker == self || OnSameTeam( self, attacker ) )
{
AddScore( attacker, -1 );
-
- // Normal teamkill penalty
- if( !g_retribution.integer )
- {
- if( attacker->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
- G_AddFundsToClient( attacker->client, -FREEKILL_ALIEN, qtrue );
- else if( attacker->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
- G_AddFundsToClient( attacker->client, -FREEKILL_HUMAN, qtrue );
- }
}
else
{
@@ -341,125 +332,6 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
totalDamage += (float)self->credits[ i ];
totalTK += (float)self->client->tkcredits[ i ];
}
- // punish players for damaging teammates
- if ( g_retribution.integer && totalTK )
- {
- int totalPrice;
- int max = HUMAN_MAX_CREDITS;
-
- if ( self->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
- {
- totalPrice = BG_ClassCanEvolveFromTo( PCL_ALIEN_LEVEL0, self->client->ps.stats[ STAT_PCLASS ], ALIEN_MAX_KILLS, 0 );
- max = ALIEN_MAX_KILLS;
- }
- else
- {
- totalPrice = BG_GetValueOfEquipment( &self->client->ps );
- }
-
- if ( self->client->ps.persistant[ PERS_CREDIT ] + totalPrice > max )
- totalPrice = max - self->client->ps.persistant[ PERS_CREDIT ];
-
- if ( totalPrice > 0 )
- {
- totalTK += totalDamage;
- if( totalTK < self->client->ps.stats[ STAT_MAX_HEALTH ] )
- totalTK = self->client->ps.stats[ STAT_MAX_HEALTH ];
-
- if ( self->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
- {
- for ( i = 0; i < MAX_CLIENTS; i++ )
- {
- int price;
- // no retribution if self damage or enemy damage or building damage or no damage from this client
- if ( i == self - g_entities || !g_entities[ i ].client ||
- !OnSameTeam( &g_entities[ i ], self ) ||
- !self->client->tkcredits[ i ] )
- continue;
-
- // calculate retribution price (rounded up)
- price = ( totalPrice * self->client->tkcredits[ i ] ) / totalTK + 0.5f;
- self->client->tkcredits[ i ] = 0;
-
- // check for enough credits
- if ( g_entities[ i ].client->ps.persistant[ PERS_CREDIT ] < price )
- price = g_entities[ i ].client->ps.persistant[ PERS_CREDIT ];
- if ( price )
- {
- G_AddFundsToClient( self->client, price, qtrue );
- G_AddFundsToClient( g_entities[ i ].client, -price, qtrue );
-
- trap_SendServerCommand( self->client->ps.clientNum,
- va( "print \"Received ^3%d credits ^7from %s ^7in retribution.\n\"",
- price, g_entities[ i ].client->pers.netname ) );
- trap_SendServerCommand( g_entities[ i ].client->ps.clientNum,
- va( "print \"Transfered ^3%d credits ^7to %s ^7in retribution.\n\"",
- price, self->client->pers.netname ) );
- }
- }
- }
- else
- {
- int toPay[ MAX_CLIENTS ] = { 0 };
- int frags = totalPrice;
- int damageForEvo = totalTK / totalPrice;
- for ( i = 0; i < MAX_CLIENTS; i++ )
- {
- // no retribution if self damage or enemy damage or building damage or no damage from this client
- if ( i == self - g_entities || !g_entities[ i ].client ||
- !OnSameTeam( &g_entities[ i ], self ) ||
- !self->client->tkcredits[ i ] )
- continue;
-
- // find out how many full evos this client needs to pay
- toPay[ i ] = ( totalPrice * self->client->tkcredits[ i ] ) / totalTK;
- if ( toPay[ i ] > g_entities[ i ].client->ps.persistant[ PERS_CREDIT ] )
- toPay[ i ] = g_entities[ i ].client->ps.persistant[ PERS_CREDIT ];
- frags -= toPay[ i ];
- self->client->tkcredits[ i ] -= damageForEvo * toPay[ i ];
- }
-
- // if we have not met the evo count, continue stealing evos
- while ( 1 )
- {
- int maximum = 0;
- int topClient = 0;
- for ( i = 0; i < MAX_CLIENTS; i++ )
- {
- if ( self->client->tkcredits[ i ] > maximum && g_entities[ i ].client->ps.persistant[ PERS_CREDIT ] )
- {
- maximum = self->client->tkcredits[ i ];
- topClient = i;
- }
- }
- if ( !maximum )
- break;
- toPay[ topClient ]++;
- self->client->tkcredits[ topClient ] = 0;
- frags--;
- if ( !frags )
- break;
- }
-
- // now move the evos around
- for ( i = 0; i < MAX_CLIENTS; i++ )
- {
- if ( !toPay[ i ] )
- continue;
-
- G_AddFundsToClient( self->client, toPay[ i ], qtrue );
- G_AddFundsToClient( g_entities[ i ].client, -toPay[ i ], qtrue );
-
- trap_SendServerCommand( self->client->ps.clientNum,
- va( "print \"Received ^3%d ^7evos from %s ^7in retribution.\n\"",
- toPay[ i ], g_entities[ i ].client->pers.netname ) );
- trap_SendServerCommand( g_entities[ i ].client->ps.clientNum,
- va( "print \"Transfered ^3%d ^7evos to %s ^7in retribution.\n\"",
- toPay[ i ], self->client->pers.netname ) );
- }
- }
- }
- }
// if players did more than DAMAGE_FRACTION_FOR_KILL increment the stage counters
if( !OnSameTeam( self, attacker ) && totalDamage >= ( self->client->ps.stats[ STAT_MAX_HEALTH ] * DAMAGE_FRACTION_FOR_KILL ) )
diff --git a/src/game/g_local.h b/src/game/g_local.h
index c701da2..51ab249 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -1367,7 +1367,6 @@ extern vmCvar_t g_vampireDeathInfo;
extern vmCvar_t g_friendlyFire;
extern vmCvar_t g_friendlyFireHumans;
extern vmCvar_t g_friendlyFireAliens;
-extern vmCvar_t g_retribution;
extern vmCvar_t g_friendlyFireMovementAttacks;
extern vmCvar_t g_friendlyBuildableFire;
extern vmCvar_t g_password;
diff --git a/src/game/g_main.c b/src/game/g_main.c
index dfa45ab..4fe3f7c 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -52,7 +52,6 @@ vmCvar_t g_friendlyFire;
vmCvar_t g_friendlyFireAliens;
vmCvar_t g_friendlyFireHumans;
vmCvar_t g_friendlyFireMovementAttacks;
-vmCvar_t g_retribution;
vmCvar_t g_friendlyBuildableFire;
vmCvar_t g_password;
vmCvar_t g_needpass;
@@ -331,7 +330,6 @@ static cvarTable_t gameCvarTable[ ] =
{ &g_friendlyFire, "g_friendlyFire", "0", CVAR_ARCHIVE | CVAR_SERVERINFO, 0, qtrue },
{ &g_friendlyFireAliens, "g_friendlyFireAliens", "0", CVAR_ARCHIVE, 0, qtrue },
{ &g_friendlyFireHumans, "g_friendlyFireHumans", "0", CVAR_ARCHIVE, 0, qtrue },
- { &g_retribution, "g_retribution", "0", CVAR_ARCHIVE, 0, qtrue },
{ &g_friendlyBuildableFire, "g_friendlyBuildableFire", "0", CVAR_ARCHIVE | CVAR_SERVERINFO, 0, qtrue },
{ &g_friendlyFireMovementAttacks, "g_friendlyFireMovementAttacks", "1", CVAR_ARCHIVE, 0, qtrue },
{ &g_devmapNoGod, "g_devmapNoGod", "0", CVAR_ARCHIVE, 0, qtrue },