diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2015-04-11 21:17:39 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2015-04-11 21:17:39 +0200 |
commit | 397f8c6f86aa68eeef6a94cc33473c0ffd69372d (patch) | |
tree | 75c44e5265f1d94607b9fd3e573b418ba3b2fc63 /src/game/g_active.c | |
parent | 22bfcab00937a147a91073796d71538dadbee491 (diff) |
Revert the removal of stamina and sprinting.
Diffstat (limited to 'src/game/g_active.c')
-rw-r--r-- | src/game/g_active.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c index 2bf6400..0c84f57 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -631,6 +631,7 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) client->ps.pm_flags |= PMF_QUEUED; client->ps.speed = client->pers.flySpeed; + client->ps.stats[ STAT_STAMINA ] = 0; client->ps.stats[ STAT_MISC ] = 0; client->ps.stats[ STAT_BUILDABLE ] = BA_NONE; client->ps.stats[ STAT_CLASS ] = PCL_NONE; @@ -806,10 +807,26 @@ void ClientTimerActions( gentity_t *ent, int msec ) client->ps.stats[ STAT_STATE ] &= ~SS_INVI; } - // Regenerate health if we have got a Biokit + // Restore or subtract stamina + if( stopped || client->ps.pm_type == PM_JETPACK ) + client->ps.stats[ STAT_STAMINA ] += STAMINA_STOP_RESTORE; + else if( ( client->ps.stats[ STAT_STATE ] & SS_SPEEDBOOST ) && + !( client->buttons & BUTTON_WALKING ) ) // walk overrides sprint + client->ps.stats[ STAT_STAMINA ] -= STAMINA_SPRINT_TAKE; + else if( walking || crouched ) + client->ps.stats[ STAT_STAMINA ] += STAMINA_WALK_RESTORE; + + // Check stamina limits + if( client->ps.stats[ STAT_STAMINA ] > STAMINA_MAX ) + client->ps.stats[ STAT_STAMINA ] = STAMINA_MAX; + else if( client->ps.stats[ STAT_STAMINA ] < -STAMINA_MAX ) + client->ps.stats[ STAT_STAMINA ] = -STAMINA_MAX; + + // Regenerate health and stamina if we have got a Biokit if( BG_InventoryContainsUpgrade( UP_BIOKIT, client->ps.stats ) ) { int rate_health = BIOKIT_HEALTH_RATE; + int rate_stamina = BIOKIT_STAMINA_RATE; if( ent->nextRegenTime < level.time && ent->health > 0 && rate_health > 0 && ent->health < client->ps.stats[ STAT_MAX_HEALTH ] ) @@ -823,6 +840,9 @@ void ClientTimerActions( gentity_t *ent, int msec ) ent->nextRegenTime = level.time + 5000/rate_health; ent->client->alreadyRegenerated = qtrue; } + + if( client->ps.stats[ STAT_STAMINA ] + rate_stamina <= STAMINA_MAX ) + client->ps.stats[ STAT_STAMINA ] += rate_stamina; } if( weapon == WP_ABUILD || |