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/bg_pmove.c | |
parent | 22bfcab00937a147a91073796d71538dadbee491 (diff) |
Revert the removal of stamina and sprinting.
Diffstat (limited to 'src/game/bg_pmove.c')
-rw-r--r-- | src/game/bg_pmove.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index 63b67fa..ecdaccf 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -406,6 +406,57 @@ static float PM_CmdScale( usercmd_t *cmd ) if( pm->ps->stats[ STAT_TEAM ] == TEAM_HUMANS && pm->ps->pm_type == PM_NORMAL ) { + qboolean wasSprinting; + qboolean sprint; + wasSprinting = sprint = pm->ps->stats[ STAT_STATE ] & SS_SPEEDBOOST; + + if( pm->ps->persistant[ PERS_STATE ] & PS_SPRINTTOGGLE ) + { + if( cmd->buttons & BUTTON_SPRINT && + !( pm->ps->pm_flags & PMF_SPRINTHELD ) ) + { + sprint = !sprint; + pm->ps->pm_flags |= PMF_SPRINTHELD; + } + else if( pm->ps->pm_flags & PMF_SPRINTHELD && + !( cmd->buttons & BUTTON_SPRINT ) ) + pm->ps->pm_flags &= ~PMF_SPRINTHELD; + } + else + sprint = cmd->buttons & BUTTON_SPRINT; + + if( sprint ) + pm->ps->stats[ STAT_STATE ] |= SS_SPEEDBOOST; + else if( wasSprinting && !sprint ) + pm->ps->stats[ STAT_STATE ] &= ~SS_SPEEDBOOST; + + // Walk overrides sprint. We keep the state that we want to be sprinting + // (above), but don't apply the modifier, and in g_active we skip taking + // the stamina too. + if( sprint && !( cmd->buttons & BUTTON_WALKING ) ) + modifier *= HUMAN_SPRINT_MODIFIER; + else + modifier *= HUMAN_JOG_MODIFIER; + + if( cmd->forwardmove < 0 ) + { + //can't run backwards + modifier *= HUMAN_BACK_MODIFIER; + } + else if( cmd->rightmove ) + { + //can't move that fast sideways + modifier *= HUMAN_SIDE_MODIFIER; + } + + //must have have stamina to jump + if( pm->ps->stats[ STAT_STAMINA ] < STAMINA_SLOW_LEVEL + STAMINA_JUMP_TAKE ) + cmd->upmove = 0; + + //slow down once stamina depletes + if( pm->ps->stats[ STAT_STAMINA ] <= STAMINA_SLOW_LEVEL ) + modifier *= (float)( pm->ps->stats[ STAT_STAMINA ] + STAMINA_MAX ) / (float)(STAMINA_SLOW_LEVEL + STAMINA_MAX); + if( pm->ps->stats[ STAT_STATE ] & SS_CREEPSLOWED ) { if( BG_InventoryContainsUpgrade( UP_LIGHTARMOUR, pm->ps->stats ) || @@ -906,6 +957,10 @@ static qboolean PM_CheckJump( void ) pm->ps->stats[ STAT_MISC ] > 0 ) return qfalse; + if( ( pm->ps->stats[ STAT_TEAM ] == TEAM_HUMANS ) && + ( pm->ps->stats[ STAT_STAMINA ] < STAMINA_SLOW_LEVEL + STAMINA_JUMP_TAKE ) ) + return qfalse; + //no bunny hopping off a dodge if( pm->ps->stats[ STAT_TEAM ] == TEAM_HUMANS && pm->ps->pm_time ) @@ -944,6 +999,10 @@ static qboolean PM_CheckJump( void ) pml.walking = qfalse; pm->ps->pm_flags |= PMF_JUMP_HELD; + // take some stamina off + if( pm->ps->stats[ STAT_TEAM ] == TEAM_HUMANS ) + pm->ps->stats[ STAT_STAMINA ] -= STAMINA_JUMP_TAKE; + pm->ps->groundEntityNum = ENTITYNUM_NONE; // jump away from wall @@ -2748,6 +2807,9 @@ static void PM_Footsteps( void ) bobmove *= BG_Class( pm->ps->stats[ STAT_CLASS ] )->bobCycle; + if( pm->ps->stats[ STAT_STATE ] & SS_SPEEDBOOST ) + bobmove *= HUMAN_SPRINT_MODIFIER; + // check for footstep / splash sounds old = pm->ps->bobCycle; pm->ps->bobCycle = (int)( old + bobmove * pml.msec ) & 255; |