summaryrefslogtreecommitdiff
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
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"
-rw-r--r--src/game/g_active.c26
-rw-r--r--src/game/g_buildable.c44
-rw-r--r--src/game/g_client.c5
-rw-r--r--src/game/g_cmds.c6
-rw-r--r--src/game/g_combat.c4
5 files changed, 49 insertions, 36 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c
index 0ebb30ec..49c23a43 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -676,6 +676,7 @@ void ClientTimerActions( gentity_t *ent, int msec )
{
ent->client->medKitHealthToRestore--;
ent->health++;
+ ent->client->ps.stats[ STAT_HEALTH ] = ent->health;
}
else
ent->client->ps.stats[ STAT_STATE ] &= ~SS_HEALING_2X;
@@ -691,6 +692,7 @@ void ClientTimerActions( gentity_t *ent, int msec )
{
ent->client->medKitHealthToRestore--;
ent->health++;
+ ent->client->ps.stats[ STAT_HEALTH ] = ent->health;
client->medKitIncrementTime = level.time +
( remainingStartupTime / MEDKIT_STARTUP_SPEED );
@@ -1462,16 +1464,20 @@ void ClientThink_real( gentity_t *ent )
interval = 1000 / ( regenRate * modifier );
// if recovery interval is less than frametime, compensate
count = 1 + ( level.time - ent->nextRegenTime ) / interval;
-
- ent->health += count;
ent->nextRegenTime += count * interval;
- // if at max health, clear damage counters
- if( ent->health >= client->ps.stats[ STAT_MAX_HEALTH ] )
+ if( ent->health < client->ps.stats[ STAT_MAX_HEALTH ] )
{
- ent->health = client->ps.stats[ STAT_MAX_HEALTH ];
- for( i = 0; i < MAX_CLIENTS; i++ )
- ent->credits[ i ] = 0;
+ ent->health += count;
+ client->ps.stats[ STAT_HEALTH ] = ent->health;
+
+ // if at max health, clear damage counters
+ if( ent->health >= client->ps.stats[ STAT_MAX_HEALTH ] )
+ {
+ ent->health = client->ps.stats[ STAT_HEALTH ] = client->ps.stats[ STAT_MAX_HEALTH ];
+ for( i = 0; i < MAX_CLIENTS; i++ )
+ ent->credits[ i ] = 0;
+ }
}
}
}
@@ -1845,12 +1851,6 @@ void ClientEndFrame( gentity_t *ent )
else
ent->s.eFlags &= ~EF_CONNECTION;
- if( ent->client->ps.stats[ STAT_HEALTH ] != ent->health )
- {
- ent->client->ps.stats[ STAT_HEALTH ] = ent->health; // FIXME: get rid of ent->health...
- ent->client->pers.infoChangeTime = level.time;
- }
-
// respawn if dead
if( ent->client->ps.stats[ STAT_HEALTH ] <= 0 && level.time >= ent->client->respawnTime )
respawn( ent );
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 )
diff --git a/src/game/g_client.c b/src/game/g_client.c
index 5c355652..31e3037a 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -525,8 +525,7 @@ static void SpawnCorpse( gentity_t *ent )
body->takedamage = qfalse;
- body->health = ent->health = ent->client->ps.stats[ STAT_HEALTH ];
- ent->health = 0;
+ body->health = ent->health;
//change body dimensions
BG_ClassBoundingBox( ent->client->ps.stats[ STAT_CLASS ], mins, NULL, NULL, body->r.mins, body->r.maxs );
@@ -1383,7 +1382,7 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles
if( ent == spawn )
{
ent->health *= ent->client->pers.evolveHealthFraction;
- client->ps.stats[ STAT_HEALTH ] *= ent->client->pers.evolveHealthFraction;
+ client->ps.stats[ STAT_HEALTH ] = ent->health;
}
//clear the credits array
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 69cc677c..9246a644 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -436,7 +436,11 @@ void Cmd_Give_f( gentity_t *ent )
if( give_all || Q_stricmp( name, "health" ) == 0 )
{
- ent->health = ent->client->ps.stats[ STAT_MAX_HEALTH ];
+ if( ent->health < ent->client->ps.stats[ STAT_MAX_HEALTH ] )
+ {
+ ent->health = ent->client->ps.stats[ STAT_MAX_HEALTH ];
+ ent->client->ps.stats[ STAT_HEALTH ] = ent->health;
+ }
BG_AddUpgradeToInventory( UP_MEDKIT, ent->client->ps.stats );
}
diff --git a/src/game/g_combat.c b/src/game/g_combat.c
index 29a1af3d..d7f15806 100644
--- a/src/game/g_combat.c
+++ b/src/game/g_combat.c
@@ -1160,7 +1160,11 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
targ->flags |= FL_NO_KNOCKBACK;
if( targ->health < -999 )
+ {
targ->health = -999;
+ if( targ->client )
+ targ->client->ps.stats[ STAT_HEALTH ] = -999;
+ }
targ->enemy = attacker;
targ->die( targ, inflictor, attacker, take, mod );