summaryrefslogtreecommitdiff
path: root/src/game/g_buildable.c
diff options
context:
space:
mode:
author/dev/humancontroller <devhc@example.com>2014-07-14 15:58:13 +0200
committer/dev/humancontroller <devhc@example.com>2017-03-09 13:51:16 +0100
commit66606bb27c471802722cd1294924e450dae00043 (patch)
tree05472afc5b73479338505ac5276013d8dcb232c9 /src/game/g_buildable.c
parentf8a0a02075de58dd8c269d9eef80a84c6bea0f15 (diff)
synchronize ent->health with ent->client->ps.stats[STAT_HEALTH]
when healing, keep the health untouched if the health is already above the "maximum"
Diffstat (limited to 'src/game/g_buildable.c')
-rw-r--r--src/game/g_buildable.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index c221af13..a335e04e 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -2129,12 +2129,15 @@ void HMedistat_Think( gentity_t *self )
if( self->enemy->client->ps.stats[ STAT_STAMINA ] > STAMINA_MAX )
self->enemy->client->ps.stats[ STAT_STAMINA ] = STAMINA_MAX;
- self->enemy->health++;
+ if( self->enemy->health < self->enemy->client->ps.stats[ STAT_MAX_HEALTH ] )
+ {
+ self->enemy->health++;
+ self->enemy->client->ps.stats[ STAT_HEALTH ] = self->enemy->health;
+ }
//if they're completely healed, give them a medkit
if( self->enemy->health >= self->enemy->client->ps.stats[ STAT_MAX_HEALTH ] )
{
- self->enemy->health = self->enemy->client->ps.stats[ STAT_MAX_HEALTH ];
if( !BG_InventoryContainsUpgrade( UP_MEDKIT, self->enemy->client->ps.stats ) )
BG_AddUpgradeToInventory( UP_MEDKIT, self->enemy->client->ps.stats );
}
@@ -2713,29 +2716,32 @@ void G_BuildableThink( gentity_t *ent, int msec )
{
ent->time1000 -= 1000;
- if( !ent->spawned && ent->health > 0 )
- ent->health += (int)( ceil( (float)maxHealth / (float)( buildTime * 0.001f ) ) );
- else if( ent->health > 0 && ent->health < maxHealth )
+ if( ent->health > 0 && ent->health < maxHealth )
{
- if( ent->buildableTeam == TEAM_ALIENS && regenRate &&
- ( ent->lastDamageTime + ALIEN_REGEN_DAMAGE_TIME ) < level.time )
+ if( !ent->spawned )
+ ent->health += (int)( ceil( (float)maxHealth / (float)( buildTime * 0.001f ) ) );
+ else
{
- ent->health += regenRate;
+ if( ent->buildableTeam == TEAM_ALIENS && regenRate &&
+ ( ent->lastDamageTime + ALIEN_REGEN_DAMAGE_TIME ) < level.time )
+ {
+ ent->health += regenRate;
+ }
+ else if( ent->buildableTeam == TEAM_HUMANS && ent->dcc &&
+ ( ent->lastDamageTime + HUMAN_REGEN_DAMAGE_TIME ) < level.time )
+ {
+ ent->health += DC_HEALRATE * ent->dcc;
+ }
}
- else if( ent->buildableTeam == TEAM_HUMANS && ent->dcc &&
- ( ent->lastDamageTime + HUMAN_REGEN_DAMAGE_TIME ) < level.time )
+
+ if( ent->health >= maxHealth )
{
- ent->health += DC_HEALRATE * ent->dcc;
+ int i;
+ ent->health = maxHealth;
+ for( i = 0; i < MAX_CLIENTS; i++ )
+ ent->credits[ i ] = 0;
}
}
-
- if( ent->health >= maxHealth )
- {
- int i;
- ent->health = maxHealth;
- for( i = 0; i < MAX_CLIENTS; i++ )
- ent->credits[ i ] = 0;
- }
}
if( ent->clientSpawnTime > 0 )