From 397f8c6f86aa68eeef6a94cc33473c0ffd69372d Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sat, 11 Apr 2015 21:17:39 +0200 Subject: Revert the removal of stamina and sprinting. --- src/cgame/cg_draw.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++-- src/cgame/cg_tutorial.c | 11 ++++++++ src/cgame/cg_view.c | 12 ++++++++ 3 files changed, 94 insertions(+), 2 deletions(-) (limited to 'src/cgame') diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 570276b..0af9839 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -375,10 +375,34 @@ static void CG_DrawPlayerStamina( int ownerDraw, rectDef_t *rect, vec4_t backColor, vec4_t foreColor, qhandle_t shader ) { + playerState_t *ps = &cg.snap->ps; + float stamina = ps->stats[ STAT_STAMINA ]; + float maxStaminaBy3 = (float)STAMINA_MAX / 3.0f; float progress; vec4_t color; - progress = 0.0f; + switch( ownerDraw ) + { + case CG_PLAYER_STAMINA_1: + progress = ( stamina - 2 * (int)maxStaminaBy3 ) / maxStaminaBy3; + break; + case CG_PLAYER_STAMINA_2: + progress = ( stamina - (int)maxStaminaBy3 ) / maxStaminaBy3; + break; + case CG_PLAYER_STAMINA_3: + progress = stamina / maxStaminaBy3; + break; + case CG_PLAYER_STAMINA_4: + progress = ( stamina + STAMINA_MAX ) / STAMINA_MAX; + break; + default: + return; + } + + if( progress > 1.0f ) + progress = 1.0f; + else if( progress < 0.0f ) + progress = 0.0f; Vector4Lerp( progress, backColor, foreColor, color ); @@ -395,9 +419,25 @@ CG_DrawPlayerStaminaBolt static void CG_DrawPlayerStaminaBolt( rectDef_t *rect, vec4_t backColor, vec4_t foreColor, qhandle_t shader ) { + float stamina = cg.snap->ps.stats[ STAT_STAMINA ]; vec4_t color; - Vector4Copy( backColor, 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 + { + 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 ); @@ -3420,6 +3460,31 @@ void CG_RunMenuScript( char **args ) } //END TA UI + +/* +================ +CG_DrawLighting + +================ +*/ +static void CG_DrawLighting( void ) +{ + // centity_t *cent; + + // cent = &cg_entities[ cg.snap->ps.clientNum ]; + + //fade to black if stamina is low + if( ( cg.snap->ps.stats[ STAT_STAMINA ] < STAMINA_BLACKOUT_LEVEL ) && + ( cg.snap->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) ) + { + vec4_t black = { 0, 0, 0, 0 }; + black[ 3 ] = 1.0 - ( (float)( cg.snap->ps.stats[ STAT_STAMINA ] + 1000 ) / 200.0f ); + trap_R_SetColor( black ); + CG_DrawPic( 0, 0, 640, 480, cgs.media.whiteShader ); + trap_R_SetColor( NULL ); + } +} + /* =============================================================================== @@ -4097,6 +4162,10 @@ static void CG_Draw2D( void ) if( cg.levelShot ) return; + // fading to black if stamina runs out + // (only 2D that can't be disabled) + CG_DrawLighting( ); + if( cg_draw2D.integer == 0 ) return; diff --git a/src/cgame/cg_tutorial.c b/src/cgame/cg_tutorial.c index d2f01b3..d36ecac 100644 --- a/src/cgame/cg_tutorial.c +++ b/src/cgame/cg_tutorial.c @@ -514,6 +514,17 @@ static void CG_HumanText( char *text, playerState_t *ps ) BG_Upgrade( UP_MEDKIT )->humanName ) ); } + if( ps->stats[ STAT_STAMINA ] <= STAMINA_BLACKOUT_LEVEL ) + { + Q_strcat( text, MAX_TUTORIAL_TEXT, + "You are blacking out. Stop sprinting to recover stamina\n" ); + } + else if( ps->stats[ STAT_STAMINA ] <= STAMINA_SLOW_LEVEL ) + { + Q_strcat( text, MAX_TUTORIAL_TEXT, + "Your stamina is low. Stop sprinting to recover\n" ); + } + switch( cg.nearUsableBuildable ) { case BA_H_ARMOURY: diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c index 333e421..1221fe9 100644 --- a/src/cgame/cg_view.c +++ b/src/cgame/cg_view.c @@ -809,6 +809,18 @@ void CG_OffsetFirstPersonView( void ) cg.predictedPlayerState.pm_type == PM_JETPACK ) ) { angles[PITCH] += cg.bobfracsin * bob2 * 0.5; + + // heavy breathing effects //FIXME: sound + if( cg.predictedPlayerState.stats[ STAT_STAMINA ] < STAMINA_BREATHING_LEVEL ) + { + float deltaBreath = ( cg.predictedPlayerState.stats[ STAT_STAMINA ] - + STAMINA_BREATHING_LEVEL ) / -250.0; + float deltaAngle = cos( (float)cg.time/150.0 ) * deltaBreath; + + deltaAngle += ( deltaAngle < 0 ? -deltaAngle : deltaAngle ) * 0.5; + + angles[ PITCH ] -= deltaAngle; + } } //=================================== -- cgit