diff options
-rw-r--r-- | src/cgame/cg_draw.c | 141 | ||||
-rw-r--r-- | src/cgame/cg_scanner.c | 40 | ||||
-rw-r--r-- | src/game/bg_public.h | 3 | ||||
-rw-r--r-- | src/game/g_active.c | 12 | ||||
-rw-r--r-- | src/game/g_cmds.c | 2 | ||||
-rw-r--r-- | ui/menudef.h | 3 |
6 files changed, 143 insertions, 58 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 2a802d52..18971f76 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -250,8 +250,73 @@ void CG_SetPrintString( int type, const char *p ) } } -static void CG_DrawPlayerAmmoValue( rectDef_t *rect, float scale, vec4_t color, - qhandle_t shader, int textStyle ) +static void CG_DrawPlayerCreditsValue( rectDef_t *rect, float scale, vec4_t color, int textStyle ) +{ + char num[ 16 ]; + int value; + centity_t *cent; + playerState_t *ps; + + cent = &cg_entities[ cg.snap->ps.clientNum ]; + ps = &cg.snap->ps; + + value = ps->stats[ STAT_CREDIT ]; + if( value > -1 ) + { + Com_sprintf( num, sizeof( num ), "%d", value ); + value = CG_Text_Width( num, scale, 0 ); + CG_Text_Paint( rect->x + ( rect->w - value ) / 2, rect->y + rect->h, + scale, color, num, 0, 0, textStyle ); + } +} + +static void CG_DrawPlayerBankValue( rectDef_t *rect, float scale, vec4_t color, int textStyle ) +{ + char num[ 16 ]; + int value; + centity_t *cent; + playerState_t *ps; + + cent = &cg_entities[ cg.snap->ps.clientNum ]; + ps = &cg.snap->ps; + + value = ps->stats[ STAT_BANK ]; + if( value > -1 ) + { + Com_sprintf( num, sizeof( num ), "%d", value ); + value = CG_Text_Width( num, scale, 0 ); + CG_Text_Paint( rect->x + ( rect->w - value ) / 2, rect->y + rect->h, + scale, color, num, 0, 0, textStyle ); + } +} + +static void CG_DrawPlayerStamina( rectDef_t *rect ) +{ + playerState_t *ps = &cg.snap->ps; + int stamina = ps->stats[ STAT_STAMINA ]; + int height = (int)( (float)stamina / ( MAX_STAMINA / ( rect->h / 2 ) ) ); + vec4_t bcolor = { 0.5f, 0.5f, 0.5f, 0.5f }; + vec4_t pos = { 0.0f, 0.5f, 0.0f, 0.5f }; + vec4_t neg = { 0.5f, 0.0f, 0.0f, 0.5f }; + + trap_R_SetColor( bcolor ); // white + CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.whiteShader ); + + if( stamina > 0 ) + { + trap_R_SetColor( pos ); // green + CG_DrawPic( rect->x, rect->y + ( rect->h / 2 - height ), + rect->w, height, cgs.media.whiteShader ); + } + + if( stamina < 0 ) + { + trap_R_SetColor( neg ); // red + CG_DrawPic( rect->x, rect->y + rect->h / 2, rect->w, -height, cgs.media.whiteShader ); + } +} + +static void CG_DrawPlayerAmmoValue( rectDef_t *rect, float scale, vec4_t color, int textStyle ) { char num[ 16 ]; int value; @@ -266,25 +331,15 @@ static void CG_DrawPlayerAmmoValue( rectDef_t *rect, float scale, vec4_t color, BG_unpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, &value, NULL, NULL ); if( value > -1 ) { - if( shader ) - { - trap_R_SetColor( color ); - CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); - trap_R_SetColor( NULL ); - } - else - { - Com_sprintf( num, sizeof( num ), "%d", value ); - value = CG_Text_Width( num, scale, 0 ); - CG_Text_Paint( rect->x + ( rect->w - value ) / 2, rect->y + rect->h, - scale, color, num, 0, 0, textStyle ); - } + Com_sprintf( num, sizeof( num ), "%d", value ); + value = CG_Text_Width( num, scale, 0 ); + CG_Text_Paint( rect->x + ( rect->w - value ) / 2, rect->y + rect->h, + scale, color, num, 0, 0, textStyle ); } } } -static void CG_DrawPlayerClipsValue( rectDef_t *rect, float scale, vec4_t color, - qhandle_t shader, int textStyle ) +static void CG_DrawPlayerClipsValue( rectDef_t *rect, float scale, vec4_t color, int textStyle ) { char num[ 16 ]; int value; @@ -299,25 +354,15 @@ static void CG_DrawPlayerClipsValue( rectDef_t *rect, float scale, vec4_t color, BG_unpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, NULL, &value, NULL ); if( value > -1 ) { - if( shader ) - { - trap_R_SetColor( color ); - CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); - trap_R_SetColor( NULL ); - } - else - { - Com_sprintf( num, sizeof( num ), "%d", value ); - value = CG_Text_Width( num, scale, 0 ); - CG_Text_Paint( rect->x + ( rect->w - value ) / 2, rect->y + rect->h, - scale, color, num, 0, 0, textStyle ); - } + Com_sprintf( num, sizeof( num ), "%d", value ); + value = CG_Text_Width( num, scale, 0 ); + CG_Text_Paint( rect->x + ( rect->w - value ) / 2, rect->y + rect->h, + scale, color, num, 0, 0, textStyle ); } } } -static void CG_DrawPlayerHealth( rectDef_t *rect, float scale, vec4_t color, - qhandle_t shader, int textStyle ) +static void CG_DrawPlayerHealth( rectDef_t *rect, float scale, vec4_t color, int textStyle ) { playerState_t *ps; int value; @@ -327,19 +372,10 @@ static void CG_DrawPlayerHealth( rectDef_t *rect, float scale, vec4_t color, value = ps->stats[ STAT_HEALTH ]; - if( shader ) - { - trap_R_SetColor( color ); - CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); - trap_R_SetColor( NULL ); - } - else - { - Com_sprintf( num, sizeof( num ), "%d", value ); - value = CG_Text_Width( num, scale, 0 ); - CG_Text_Paint( rect->x + ( rect->w - value ) / 2, rect->y + rect->h, - scale, color, num, 0, 0, textStyle ); - } + Com_sprintf( num, sizeof( num ), "%d", value ); + value = CG_Text_Width( num, scale, 0 ); + CG_Text_Paint( rect->x + ( rect->w - value ) / 2, rect->y + rect->h, + scale, color, num, 0, 0, textStyle ); } float CG_GetValue( int ownerDraw ) @@ -514,14 +550,23 @@ void CG_OwnerDraw( float x, float y, float w, float h, float text_x, switch( ownerDraw ) { + case CG_PLAYER_CREDITS_VALUE: + CG_DrawPlayerCreditsValue( &rect, scale, color, textStyle ); + break; + case CG_PLAYER_BANK_VALUE: + CG_DrawPlayerBankValue( &rect, scale, color, textStyle ); + break; + case CG_PLAYER_STAMINA: + CG_DrawPlayerStamina( &rect ); + break; case CG_PLAYER_AMMO_VALUE: - CG_DrawPlayerAmmoValue( &rect, scale, color, shader, textStyle ); + CG_DrawPlayerAmmoValue( &rect, scale, color, textStyle ); break; case CG_PLAYER_CLIPS_VALUE: - CG_DrawPlayerClipsValue( &rect, scale, color, shader, textStyle ); + CG_DrawPlayerClipsValue( &rect, scale, color, textStyle ); break; case CG_PLAYER_HEALTH: - CG_DrawPlayerHealth( &rect, scale, color, shader, textStyle ); + CG_DrawPlayerHealth( &rect, scale, color, textStyle ); break; case CG_AREA_SYSTEMCHAT: CG_DrawAreaSystemChat( &rect, scale, color, shader ); diff --git a/src/cgame/cg_scanner.c b/src/cgame/cg_scanner.c index b3c37fbe..e0966ff4 100644 --- a/src/cgame/cg_scanner.c +++ b/src/cgame/cg_scanner.c @@ -64,11 +64,43 @@ static void CG_DrawBlips( vec3_t origin, vec4_t colour ) static void CG_DrawDir( vec3_t origin, vec4_t colour ) { vec3_t drawOrigin; - vec3_t up = { 0.0f, 0.0f, 1.0f }; + vec3_t noZOrigin; + vec3_t normal, antinormal, normalDiff; + vec3_t view, noZview; + vec3_t up = { 0.0f, 0.0f, 1.0f }; + vec3_t top = { 0.0f, -1.0f, 0.0f }; + float angle; + playerState_t *ps = &cg.snap->ps; + + if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) + { + if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) + VectorSet( normal, 0.0f, 0.0f, -1.0f ); + else + VectorCopy( ps->grapplePoint, normal ); + } + else + VectorSet( normal, 0.0f, 0.0f, 1.0f ); - RotatePointAroundVector( drawOrigin, up, origin, -cg.refdefViewAngles[ 1 ] - 90 ); - drawOrigin[ 2 ] = 0.0f; - VectorNormalize( drawOrigin ); + AngleVectors( cg.refdefViewAngles, view, NULL, NULL ); + + ProjectPointOnPlane( noZOrigin, origin, normal ); + ProjectPointOnPlane( noZview, view, normal ); + VectorNormalize( noZOrigin ); + VectorNormalize( noZview ); + + angle = RAD2DEG( acos( DotProduct( noZOrigin, noZview ) ) ); + CrossProduct( noZOrigin, noZview, antinormal ); + VectorNormalize( antinormal ); + + VectorSubtract( normal, antinormal, normalDiff ); + + if( VectorLength( normalDiff ) < 1.0f ) + angle = 360.0f - angle; + + CG_Printf( "%f\n", angle ); + + RotatePointAroundVector( drawOrigin, up, top, angle ); trap_R_SetColor( colour ); CG_DrawPic( XPOS2 + ( WIDTH2 / 2 ) - ( BLIPX2 / 2 ) - drawOrigin[ 0 ] * ( WIDTH2 / 2 ), diff --git a/src/game/bg_public.h b/src/game/bg_public.h index da8d65fa..9238fca1 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -224,6 +224,7 @@ typedef enum { STAT_STAMINA, //TA: stamina (human only) STAT_STATE, //TA: client states e.g. wall climbing STAT_CREDIT, //TA: human credit + STAT_BANK, //TA: human credit in the bank STAT_MISC, //TA: for uh...misc stuff STAT_BUILDABLE //TA: which ghost model to display for building } statIndex_t; @@ -249,6 +250,8 @@ typedef enum { #define SB_VALID_TOGGLEBIT 16384 +#define MAX_STAMINA 1000 + // player_state->persistant[] indexes // these fields are the only part of player_state that isn't // cleared on respawn diff --git a/src/game/g_active.c b/src/game/g_active.c index 8d281f1b..d78e0f1c 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -442,8 +442,8 @@ void ClientTimerActions( gentity_t *ent, int msec ) else client->ps.stats[ STAT_STAMINA ] -= STAMINA_SPRINT_TAKE; - if( client->ps.stats[ STAT_STAMINA ] < -1000 ) - client->ps.stats[ STAT_STAMINA ] = -1000; + if( client->ps.stats[ STAT_STAMINA ] < -MAX_STAMINA ) + client->ps.stats[ STAT_STAMINA ] = -MAX_STAMINA; } if( ( aForward <= 64 && aForward > 5 ) || ( aRight <= 64 && aRight > 5 ) ) @@ -451,16 +451,16 @@ void ClientTimerActions( gentity_t *ent, int msec ) //restore stamina client->ps.stats[ STAT_STAMINA ] += STAMINA_WALK_RESTORE; - if( client->ps.stats[ STAT_STAMINA ] > 1000 ) - client->ps.stats[ STAT_STAMINA ] = 1000; + if( client->ps.stats[ STAT_STAMINA ] > MAX_STAMINA ) + client->ps.stats[ STAT_STAMINA ] = MAX_STAMINA; } else if( aForward <= 5 && aRight <= 5 ) { //restore stamina faster client->ps.stats[ STAT_STAMINA ] += STAMINA_STOP_RESTORE; - if( client->ps.stats[ STAT_STAMINA ] > 1000 ) - client->ps.stats[ STAT_STAMINA ] = 1000; + if( client->ps.stats[ STAT_STAMINA ] > MAX_STAMINA ) + client->ps.stats[ STAT_STAMINA ] = MAX_STAMINA; } //client is poisoned diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 92ed0311..c69e6da4 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -2098,6 +2098,7 @@ void Cmd_Deposit_f( gentity_t *ent ) if( amount <= ent->client->ps.stats[ STAT_CREDIT ] ) { ent->client->ps.stats[ STAT_CREDIT ] -= amount; + ent->client->ps.stats[ STAT_BANK ] += amount; level.bankCredits[ ent->client->ps.clientNum ] += amount; } else @@ -2153,6 +2154,7 @@ void Cmd_Withdraw_f( gentity_t *ent ) if( amount <= level.bankCredits[ ent->client->ps.clientNum ] ) { ent->client->ps.stats[ STAT_CREDIT ] += amount; + ent->client->ps.stats[ STAT_BANK ] -= amount; level.bankCredits[ ent->client->ps.clientNum ] -= amount; } else diff --git a/ui/menudef.h b/ui/menudef.h index 3049250f..95c84c1f 100644 --- a/ui/menudef.h +++ b/ui/menudef.h @@ -131,6 +131,9 @@ #define CG_PLAYER_AMMO_ICON 5 #define CG_PLAYER_AMMO_VALUE 6 #define CG_PLAYER_CLIPS_VALUE 70 +#define CG_PLAYER_CREDITS_VALUE 71 +#define CG_PLAYER_BANK_VALUE 72 +#define CG_PLAYER_STAMINA 73 #define CG_SELECTEDPLAYER_HEAD 7 #define CG_SELECTEDPLAYER_NAME 8 #define CG_SELECTEDPLAYER_LOCATION 9 |