summaryrefslogtreecommitdiff
path: root/src/game/g_combat.c
diff options
context:
space:
mode:
authorRoman Tetelman <kevlarman@gmail.com>2009-10-03 11:54:49 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:30 +0000
commit7f16b7c59b8c84120eac6dfef4b78cea297b9e67 (patch)
tree9c180f1ed21c84ec3448d1e0e91469fe374f06df /src/game/g_combat.c
parent45b4d03e66058565129e4de53a719433a50cf4e6 (diff)
* players dying to structures no longer give full credit towards stages
* credit for damage done is reset when a player/structure heals to full
Diffstat (limited to 'src/game/g_combat.c')
-rw-r--r--src/game/g_combat.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/game/g_combat.c b/src/game/g_combat.c
index 3d2bcb21..cc2cb07a 100644
--- a/src/game/g_combat.c
+++ b/src/game/g_combat.c
@@ -138,7 +138,7 @@ Returns the total damage dealt.
float G_RewardAttackers( gentity_t *self )
{
float value, totalDamage = 0;
- int team, i;
+ int team, i, maxHealth = 0;
// Total up all the damage done by every client
for( i = 0; i < MAX_CLIENTS; i++ )
@@ -152,6 +152,7 @@ float G_RewardAttackers( gentity_t *self )
{
value = BG_GetValueOfPlayer( &self->client->ps );
team = self->client->pers.teamSelection;
+ maxHealth = self->client->ps.stats[ STAT_MAX_HEALTH ];
}
else if( self->s.eType == ET_BUILDABLE )
{
@@ -165,6 +166,7 @@ float G_RewardAttackers( gentity_t *self )
}
team = self->buildableTeam;
+ maxHealth = BG_Buildable( self->s.modelindex )->health;
}
else
return totalDamage;
@@ -174,6 +176,9 @@ float G_RewardAttackers( gentity_t *self )
{
gentity_t *player = g_entities + i;
short num = value * self->credits[ i ] / totalDamage;
+ int stageValue = num;
+ if( totalDamage < maxHealth )
+ stageValue *= totalDamage / maxHealth;
if( !player->client || !self->credits[ i ] ||
player->client->ps.stats[ STAT_TEAM ] == team )
@@ -182,9 +187,9 @@ float G_RewardAttackers( gentity_t *self )
// add to stage counters
if( player->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS )
- trap_Cvar_Set( "g_alienCredits", va( "%d", g_alienCredits.integer + num ) );
+ trap_Cvar_Set( "g_alienCredits", va( "%d", g_alienCredits.integer + stageValue ) );
else if( player->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS )
- trap_Cvar_Set( "g_humanCredits", va( "%d", g_humanCredits.integer + num ) );
+ trap_Cvar_Set( "g_humanCredits", va( "%d", g_humanCredits.integer + stageValue ) );
self->credits[ i ] = 0;
}