summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorenneract <trem.redman@gmail.com>2014-12-12 20:45:09 +0100
committerenneract <trem.redman@gmail.com>2014-12-12 20:45:09 +0100
commit964371805c751877c99ed2faeb8214355c2b3d6b (patch)
tree60cce1719928b9d8a376e0040841748e99cf3b84 /src
parent9d1b014b113ae04fe2d15ea12bf2e21b74f7df60 (diff)
Flash BP display when MOD_NOBP kills a building.
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_draw.c53
-rw-r--r--src/cgame/cg_local.h9
-rw-r--r--src/cgame/cg_main.c2
-rw-r--r--src/game/g_local.h5
-rw-r--r--src/game/g_main.c26
5 files changed, 87 insertions, 8 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index a8331b1..e1ee2b7 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -1790,7 +1790,7 @@ static void CG_DrawBuildPoolReport( rectDef_t *rect, float text_x, float text_y,
char out[ 20 ];
float tx, ty;
- Com_sprintf( out, sizeof( out ), "%s", Info_ValueForKey( CG_ConfigString( CS_BUILD_POOLS ), ( humans ? "h" : "a" ) ) );
+ Com_sprintf( out, sizeof( out ), "%d", ( humans ? cgs.humanBuildPool : cgs.alienBuildPool ) );
CG_AlignText( rect, out, scale, 0.0f, 0.0f, textalign, textvalign, &tx, &ty );
UI_Text_Paint( text_x + tx, text_y + ty, scale, color, out, 0, 0, textStyle );
@@ -1803,14 +1803,11 @@ CG_DrawBuildPoolBars
*/
static void CG_DrawBuildPoolBars( rectDef_t *rect, vec4_t color )
{
- const char *cs;
float abp, hbp, f;
float x, y, w, h;
- cs = CG_ConfigString( CS_BUILD_POOLS );
-
- abp = atof( Info_ValueForKey( cs, "a" ) ) / atof( Info_ValueForKey( cs, "ad" ) );
- hbp = atof( Info_ValueForKey( cs, "h" ) ) / atof( Info_ValueForKey( cs, "hd" ) );
+ abp = (float)cgs.alienBuildPool / (float)cgs.alienBuildPoolMax;
+ hbp = (float)cgs.humanBuildPool / (float)cgs.humanBuildPoolMax;
if( fabs( abp + hbp ) < 1e-3 )
f = 0.5f;
@@ -1841,6 +1838,35 @@ static void CG_DrawBuildPoolBars( rectDef_t *rect, vec4_t color )
/*
==================
+CG_DrawNoBPFlash
+==================
+*/
+#define NOBP_FLASH_TIME 3000
+static void CG_DrawNoBPFlash( rectDef_t *rect, vec4_t color, qboolean humans )
+{
+ vec4_t mcolor;
+ int flashTime;
+
+ Vector4Copy( color, mcolor );
+ flashTime = ( humans ? cgs.humanNoBPFlashTime : cgs.alienNoBPFlashTime );
+
+ if( flashTime == -1 )
+ return;
+
+ mcolor[ 3 ] *= 1.0f - ( (float)( cg.time - flashTime ) / NOBP_FLASH_TIME );
+
+ if( mcolor[ 3 ] <= 0 )
+ return;
+
+ trap_R_SetColor( mcolor );
+ CG_DrawPic( rect->x, rect->y, rect->w, rect->h,
+ ( humans ? cgs.media.humanNoBPFlash :
+ cgs.media.alienNoBPFlash ) );
+ trap_R_SetColor( NULL );
+}
+
+/*
+==================
CG_DrawFPS
==================
*/
@@ -3209,6 +3235,12 @@ void CG_OwnerDraw( float x, float y, float w, float h, float text_x,
case CG_BUILD_POOL_BARS:
CG_DrawBuildPoolBars( &rect, foreColor );
break;
+ case CG_ALIEN_NOBP_FLASH:
+ CG_DrawNoBPFlash( &rect, foreColor, qfalse );
+ break;
+ case CG_HUMAN_NOBP_FLASH:
+ CG_DrawNoBPFlash( &rect, foreColor, qtrue );
+ break;
case CG_ALIENS_SCORE_LABEL:
CG_DrawTeamLabel( &rect, TEAM_ALIENS, text_x, text_y, foreColor, scale, textalign, textvalign, textStyle );
break;
@@ -3831,6 +3863,15 @@ static void CG_Draw2D( void )
if( cg_draw2D.integer == 0 )
return;
+ // this has to be here, CG_ConfigStringModified isn't reliable
+ sscanf( CG_ConfigString( CS_BUILD_POOLS ), "%d %d %d %d %d %d",
+ &cgs.alienBuildPool,
+ &cgs.alienBuildPoolMax,
+ &cgs.alienNoBPFlashTime,
+ &cgs.humanBuildPool,
+ &cgs.humanBuildPoolMax,
+ &cgs.humanNoBPFlashTime );
+
if( cg.snap->ps.pm_type == PM_INTERMISSION )
{
CG_DrawIntermission( );
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 097da54..10e89fd 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1339,6 +1339,8 @@ typedef struct
qhandle_t alienBuildPoolBar;
qhandle_t humanBuildPoolBar;
+ qhandle_t alienNoBPFlash;
+ qhandle_t humanNoBPFlash;
} cgMedia_t;
typedef struct
@@ -1443,6 +1445,13 @@ typedef struct
voice_t *voices;
clientList_t ignoreList;
+
+ int alienBuildPool;
+ int alienBuildPoolMax;
+ int alienNoBPFlashTime;
+ int humanBuildPool;
+ int humanBuildPoolMax;
+ int humanNoBPFlashTime;
} cgs_t;
typedef struct
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 8f3ceb7..3985834 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -824,6 +824,8 @@ static void CG_RegisterGraphics( void )
cgs.media.alienBuildPoolBar = trap_R_RegisterShader( "ui/assets/alien/build_pool_bar.tga" );
cgs.media.humanBuildPoolBar = trap_R_RegisterShader( "ui/assets/human/build_pool_bar.tga" );
+ cgs.media.alienNoBPFlash = trap_R_RegisterShader( "ui/assets/alien/nobp_flash.tga" );
+ cgs.media.humanNoBPFlash = trap_R_RegisterShader( "ui/assets/human/nobp_flash.tga" );
cgs.media.disconnectPS = CG_RegisterParticleSystem( "disconnectPS" );
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 32b6075..eb5f37e 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -713,6 +713,11 @@ typedef struct
buildLog_t buildLog[ MAX_BUILDLOG ];
int buildId;
int numBuildLogs;
+
+ qboolean alienNoBPFlash;
+ qboolean humanNoBPFlash;
+ int alienNoBPFlashTime;
+ int humanNoBPFlashTime;
} level_locals_t;
#define CMD_CHEAT 0x0001
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 62df632..57b4af4 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -653,6 +653,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart )
level.humanStage2Time = level.humanStage3Time = level.humanStage4Time = level.humanStage5Time = level.startTime;
level.snd_fry = G_SoundIndex( "sound/misc/fry.wav" ); // FIXME standing in lava / slime
level.humanRewardKills = level.alienRewardKills = 0.0f;
+ level.alienNoBPFlashTime = level.humanNoBPFlashTime = -1;
trap_Cvar_Set( "g_version", G_MOD_VERSION );
trap_Cvar_Set( "edge_version", EDGE_MOD_VERSION );
if( g_logFile.string[ 0 ] )
@@ -1405,11 +1406,25 @@ void G_CalculateBuildPoints( void )
level.alienBuildPoints += level.alienExtraBuildPoints;
}
- trap_SetConfigstring( CS_BUILD_POOLS, va( "a\\%d\\ad\\%d\\h\\%d\\hd\\%d",
+ if( level.alienNoBPFlash )
+ {
+ level.alienNoBPFlash = qfalse;
+ level.alienNoBPFlashTime = level.time;
+ }
+
+ if( level.humanNoBPFlash )
+ {
+ level.humanNoBPFlash = qfalse;
+ level.humanNoBPFlashTime = level.time;
+ }
+
+ trap_SetConfigstring( CS_BUILD_POOLS, va( "%d %d %d %d %d %d",
g_alienBuildPoints.integer + level.alienExtraBuildPoints,
g_alienBuildPoints.integer,
+ level.alienNoBPFlashTime,
g_humanBuildPoints.integer + level.humanExtraBuildPoints,
- g_humanBuildPoints.integer ) );
+ g_humanBuildPoints.integer,
+ level.humanNoBPFlashTime ) );
//zero bp not allowed
// if( level.humanBuildPoints < 0 )
@@ -1481,7 +1496,14 @@ void G_CheckForNegativeBuildPoints( void )
{
surviveprobcur = pow( surviveprob1min, thinkduration / 60000.0f );
if( surviveprobcur * RAND_MAX < rand( ) )
+ {
G_Suicide( ent, MOD_NOBP );
+
+ if( ent->buildableTeam == TEAM_ALIENS )
+ level.alienNoBPFlash = qtrue;
+ else
+ level.humanNoBPFlash = qtrue;
+ }
}
}
}