summaryrefslogtreecommitdiff
path: root/src/game/g_combat.c
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 /src/game/g_combat.c
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
Diffstat (limited to 'src/game/g_combat.c')
-rw-r--r--src/game/g_combat.c128
1 files changed, 0 insertions, 128 deletions
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 ) )