diff options
author | Christopher Schwarz <lakitu7@gmail.com> | 2009-10-24 07:46:20 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:17:03 +0000 |
commit | 6717b6d4f7882081012550719dd4373650fdd033 (patch) | |
tree | 25c36abd50a03055e084850db384a976c7384f1b /src | |
parent | 3c596928698f25af8e0fe45403a5770eac3866d1 (diff) |
* Stamina changes/fixes (kevlarman)
- Restore blacking out when you run out of stamina
- Add cg_sprintToggle, allowing the sprint button to act as a toggle between always-sprinting or not
- Walk overrides sprint, by popular demand
- Modify the stamina "bolt" to better differentiate between states
- Allow one to begin a sprint when stamina is negative (even though it is generally a bad idea for them, at least their button presses do something!)
* When avilable, use predictedplayerstate for cg_drawSpeed to reduce latency (kevlarman)
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_draw.c | 32 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 2 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 4 | ||||
-rw-r--r-- | src/game/bg_pmove.c | 30 | ||||
-rw-r--r-- | src/game/bg_public.h | 35 | ||||
-rw-r--r-- | src/game/g_active.c | 5 | ||||
-rw-r--r-- | src/game/g_client.c | 6 | ||||
-rw-r--r-- | src/qcommon/msg.c | 2 |
8 files changed, 76 insertions, 40 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index da5d9101..6cc78738 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -423,13 +423,22 @@ static void CG_DrawPlayerStaminaBolt( rectDef_t *rect, vec4_t backColor, float stamina = cg.snap->ps.stats[ STAT_STAMINA ]; vec4_t color; - if( stamina < 0 ) - Vector4Copy( backColor, color ); - else if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_SPEEDBOOST ) - Vector4Lerp( ( sin( cg.time / 150.0f ) + 1 ) / 2, - backColor, foreColor, color ); + if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_SPEEDBOOST ) + { + if( stamina >= 0 ) + Vector4Lerp( ( sin( cg.time / 150.0f ) + 1 ) / 2, + backColor, foreColor, color ); + else + Vector4Lerp( ( sin( cg.time / 2000.0f ) + 1 ) / 2, + backColor, foreColor, color ); + } else - Vector4Copy( foreColor, color ); + { + if( stamina < 0 ) + Vector4Copy( backColor, color ); + else + Vector4Copy( foreColor, color ); + } trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); @@ -2220,8 +2229,15 @@ static void CG_DrawSpeedText( rectDef_t *rect, float text_x, float text_y, VectorCopy( foreColor, color ); color[ 3 ] = 1; - - if( oldestSpeedSample == 0 ) + if( cg.predictedPlayerState.clientNum == cg.clientNum ) + { + vec3_t vel; + VectorCopy( cg.predictedPlayerState.velocity, vel ); + if( cg_drawSpeed.integer & SPEEDOMETER_IGNORE_Z ) + vel[ 2 ] = 0; + val = VectorLength( vel ); + } + else if( oldestSpeedSample == 0 ) val = speedSamples[ SPEEDOMETER_NUM_SAMPLES - 1 ]; else val = speedSamples[ oldestSpeedSample - 1 ]; diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 477bd384..6b146653 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1517,7 +1517,7 @@ extern vmCvar_t cg_painBlendScale; extern vmCvar_t cg_painBlendZoom; extern vmCvar_t cg_stickySpec; -extern vmCvar_t cg_alwaysSprint; +extern vmCvar_t cg_sprintToggle; extern vmCvar_t cg_unlagged; extern vmCvar_t cg_debugVoices; diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index feb16cae..61888f92 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -195,7 +195,7 @@ vmCvar_t cg_painBlendScale; vmCvar_t cg_painBlendZoom; vmCvar_t cg_stickySpec; -vmCvar_t cg_alwaysSprint; +vmCvar_t cg_sprintToggle; vmCvar_t cg_unlagged; vmCvar_t cg_debugVoices; @@ -287,7 +287,7 @@ static cvarTable_t cvarTable[ ] = { NULL, "cg_wwToggle", "1", CVAR_ARCHIVE|CVAR_USERINFO }, { NULL, "cg_disableBlueprintErrors", "0", CVAR_ARCHIVE|CVAR_USERINFO }, { &cg_stickySpec, "cg_stickySpec", "1", CVAR_ARCHIVE|CVAR_USERINFO }, - { &cg_alwaysSprint, "cg_alwaysSprint", "0", CVAR_ARCHIVE|CVAR_USERINFO }, + { &cg_sprintToggle, "cg_sprintToggle", "0", CVAR_ARCHIVE|CVAR_USERINFO }, { &cg_unlagged, "cg_unlagged", "1", CVAR_ARCHIVE|CVAR_USERINFO }, { NULL, "cg_flySpeed", "600", CVAR_ARCHIVE|CVAR_USERINFO }, { &cg_depthSortParticles, "cg_depthSortParticles", "1", CVAR_ARCHIVE }, diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index 005cf46a..684e020a 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -383,16 +383,34 @@ static float PM_CmdScale( usercmd_t *cmd ) if( pm->ps->stats[ STAT_TEAM ] == TEAM_HUMANS && pm->ps->pm_type == PM_NORMAL ) { - if( pm->ps->stats[ STAT_STAMINA ] > 0 && cmd->buttons & BUTTON_SPRINT ) + qboolean wasSprinting; + qboolean sprint; + wasSprinting = sprint = pm->ps->stats[ STAT_STATE ] & SS_SPEEDBOOST; + + if( pm->ps->persistant[ PERS_STATE ] & PS_SPRINTTOGGLE ) { - modifier *= HUMAN_SPRINT_MODIFIER; - pm->ps->stats[ STAT_STATE ] |= SS_SPEEDBOOST; + 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 - { - modifier *= HUMAN_JOG_MODIFIER; + 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; - } + + if( sprint ) + modifier *= HUMAN_SPRINT_MODIFIER; + else + modifier *= HUMAN_JOG_MODIFIER; if( cmd->forwardmove < 0 ) { diff --git a/src/game/bg_public.h b/src/game/bg_public.h index fa6d24b7..0e687ea4 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -128,22 +128,23 @@ typedef enum } weaponstate_t; // pmove->pm_flags -#define PMF_DUCKED 0x0001 -#define PMF_JUMP_HELD 0x0002 -#define PMF_CROUCH_HELD 0x0004 -#define PMF_BACKWARDS_JUMP 0x0008 // go into backwards land -#define PMF_BACKWARDS_RUN 0x0010 // coast down to backwards run -#define PMF_TIME_LAND 0x0020 // pm_time is time before rejump -#define PMF_TIME_KNOCKBACK 0x0040 // pm_time is an air-accelerate only time -#define PMF_TIME_WATERJUMP 0x0080 // pm_time is waterjump -#define PMF_RESPAWNED 0x0100 // clear after attack and jump buttons come up -#define PMF_USE_ITEM_HELD 0x0200 -#define PMF_WEAPON_RELOAD 0x0400 // force a weapon switch -#define PMF_FOLLOW 0x0800 // spectate following another player -#define PMF_QUEUED 0x1000 // player is queued -#define PMF_TIME_WALLJUMP 0x2000 // for limiting wall jumping -#define PMF_CHARGE 0x4000 // keep track of pouncing -#define PMF_WEAPON_SWITCH 0x8000 // force a weapon switch +#define PMF_DUCKED 0x000001 +#define PMF_JUMP_HELD 0x000002 +#define PMF_CROUCH_HELD 0x000004 +#define PMF_BACKWARDS_JUMP 0x000008 // go into backwards land +#define PMF_BACKWARDS_RUN 0x000010 // coast down to backwards run +#define PMF_TIME_LAND 0x000020 // pm_time is time before rejump +#define PMF_TIME_KNOCKBACK 0x000040 // pm_time is an air-accelerate only time +#define PMF_TIME_WATERJUMP 0x000080 // pm_time is waterjump +#define PMF_RESPAWNED 0x000100 // clear after attack and jump buttons come up +#define PMF_USE_ITEM_HELD 0x000200 +#define PMF_WEAPON_RELOAD 0x000400 // force a weapon switch +#define PMF_FOLLOW 0x000800 // spectate following another player +#define PMF_QUEUED 0x001000 // player is queued +#define PMF_TIME_WALLJUMP 0x002000 // for limiting wall jumping +#define PMF_CHARGE 0x004000 // keep track of pouncing +#define PMF_WEAPON_SWITCH 0x008000 // force a weapon switch +#define PMF_SPRINTHELD 0x010000 #define PMF_ALL_TIMES (PMF_TIME_WATERJUMP|PMF_TIME_LAND|PMF_TIME_KNOCKBACK|PMF_TIME_WALLJUMP) @@ -271,7 +272,7 @@ typedef enum #define PS_WALLCLIMBINGFOLLOW 0x00000001 #define PS_WALLCLIMBINGTOGGLE 0x00000002 #define PS_NONSEGMODEL 0x00000004 -#define PS_ALWAYSSPRINT 0x00000008 +#define PS_SPRINTTOGGLE 0x00000008 // entityState_t->eFlags #define EF_DEAD 0x00000001 // don't draw a foe marker over players with EF_DEAD diff --git a/src/game/g_active.c b/src/game/g_active.c index 236bc708..4bd1c30e 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -596,8 +596,9 @@ void ClientTimerActions( gentity_t *ent, int msec ) // 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->ps.stats[ STAT_STAMINA ] -= STAMINA_SPRINT_TAKE; + 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; diff --git a/src/game/g_client.c b/src/game/g_client.c index 03a63147..aafb30fa 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -1122,12 +1122,12 @@ void ClientUserinfoChanged( int clientNum ) client->ps.persistant[ PERS_STATE ] &= ~PS_WALLCLIMBINGTOGGLE; // always sprint - s = Info_ValueForKey( userinfo, "cg_alwaysSprint" ); + s = Info_ValueForKey( userinfo, "cg_sprintToggle" ); if( atoi( s ) ) - client->ps.persistant[ PERS_STATE ] |= PS_ALWAYSSPRINT; + client->ps.persistant[ PERS_STATE ] |= PS_SPRINTTOGGLE; else - client->ps.persistant[ PERS_STATE ] &= ~PS_ALWAYSSPRINT; + client->ps.persistant[ PERS_STATE ] &= ~PS_SPRINTTOGGLE; // fly speed s = Info_ValueForKey( userinfo, "cg_flySpeed" ); diff --git a/src/qcommon/msg.c b/src/qcommon/msg.c index 5108937e..dc1d1e9e 100644 --- a/src/qcommon/msg.c +++ b/src/qcommon/msg.c @@ -1139,7 +1139,7 @@ netField_t playerStateFields[] = { PSF(events[0]), 8 }, { PSF(legsAnim), 8 }, { PSF(events[1]), 8 }, -{ PSF(pm_flags), 16 }, +{ PSF(pm_flags), 24 }, { PSF(groundEntityNum), GENTITYNUM_BITS }, { PSF(weaponstate), 4 }, { PSF(eFlags), 16 }, |