summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
authorMichael Levin <risujin@fastmail.fm>2009-10-03 11:29:22 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:02 +0000
commit685e9535db65b8117a93afd68b93ce1521a6ec28 (patch)
tree379a6571720a38230181bc082caaabc921d31772 /src/cgame
parent7fed4f2d94817bb4c6d0a3bff665a5cae0ce8ff3 (diff)
* Lucifer cannon projectile a little bigger with charge
* Sitting on a booster won't make it blink the warning bolt (SS_BOOSTEDWARNING), also made the warning fade * Lucifer Cannon repeat rates fixed * G_Damage() wont deal damage to dead entities * Maybe fixed the buildable killed with shotgun won't show dying anim bug * Attacked hives won't attack back when the OM is dead * The monstrous hive bounding boxes shrunk to something reasonable * Tesla Generator muzzle offset to the ball part, now fires over turrets * HUDs can make vertical charge bars * Human charge bar no longer overlaps scanner * "There are no spawns remaining" Changes to trample attack: * No longer deals locational damage (wtf?) * Charge "holding" restored * Hit repeat rate limited to 50 ms Changes to health cross icons: * Inspired by Techhead, made new icons (sorry, yours didn't look so good in game :-\ ) * Icons fade from one to another * Switched SS_HEALING_2X and SS_HEALING_ACTIVE meaning for Humans -- glows when on medi station, special icon for medkit * Poisoned icon for humans (Techhead's idea)
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_draw.c167
-rw-r--r--src/cgame/cg_local.h8
-rw-r--r--src/cgame/cg_main.c8
-rw-r--r--src/cgame/cg_playerstate.c7
-rw-r--r--src/cgame/cg_view.c6
5 files changed, 132 insertions, 64 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index e99d48d1..24121df5 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -488,7 +488,8 @@ static void CG_DrawPlayerStaminaBolt( rectDef_t *rect, vec4_t color, qhandle_t s
if( stamina < 0 )
color[ 3 ] = HH_MIN_ALPHA;
else if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_SPEEDBOOST )
- color[ 3 ] = 1.0f;
+ color[ 3 ] = HH_MIN_ALPHA + HH_MAX_ALPHA *
+ ( 0.5f + sin( cg.time / 200.0f ) / 2 );
else
color[ 3 ] = HH_MAX_ALPHA;
@@ -573,7 +574,7 @@ CG_DrawPlayerBoosted
*/
static void CG_DrawPlayerBoosted( rectDef_t *rect, vec4_t color, qhandle_t shader )
{
- if( cg.boostedTime >= 0 )
+ if( cg.snap->ps.stats[ STAT_STATE ] & SS_BOOSTED )
color[ 3 ] = AH_MAX_ALPHA;
else
color[ 3 ] = AH_MIN_ALPHA;
@@ -596,9 +597,9 @@ static void CG_DrawPlayerBoosterBolt( rectDef_t *rect, vec4_t color, qhandle_t s
// Flash bolts when the boost is almost out
if( ( cg.snap->ps.stats[ STAT_STATE ] & SS_BOOSTED ) &&
- cg.boostedTime > 0 && cg.time - cg.boostedTime > BOOST_TIME - 5000 &&
- cg.time & 256 )
- localColor[ 3 ] = 1.0f;
+ ( cg.snap->ps.stats[ STAT_STATE ] & SS_BOOSTEDWARNING ) )
+ localColor[ 3 ] += ( 1.0f - localColor[ 3 ] ) *
+ ( 0.5f + sin( cg.time / 100.0f ) / 2 );
trap_R_SetColor( localColor );
CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );
@@ -857,44 +858,67 @@ static void CG_DrawPlayerHealthValue( rectDef_t *rect, vec4_t color )
CG_DrawPlayerHealthCross
==============
*/
-static void CG_DrawPlayerHealthCross( rectDef_t *rect, vec4_t color, qhandle_t shader )
+static void CG_DrawPlayerHealthCross( rectDef_t *rect, vec4_t ref_color )
{
- if( ( cg.snap->ps.stats[ STAT_STATE ] & SS_HEALING_2X ) ||
- ( cg.snap->ps.stats[ STAT_STATE ] & SS_HEALING_3X ) )
- return;
+ qhandle_t shader;
+ vec4_t color;
+ float ref_alpha;
+
+ // Pick the current icon
+ shader = cgs.media.healthCross;
+ if( cg.snap->ps.stats[ STAT_STATE ] & SS_HEALING_3X )
+ shader = cgs.media.healthCross3X;
+ else if( cg.snap->ps.stats[ STAT_STATE ] & SS_HEALING_2X )
+ {
+ if( cg.snap->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
+ shader = cgs.media.healthCross2X;
+ else
+ shader = cgs.media.healthCrossMedkit;
+ }
+ else if( cg.snap->ps.stats[ STAT_STATE ] & SS_POISONED )
+ shader = cgs.media.healthCrossPoisoned;
+
+ // Pick the alpha value
+ Vector4Copy( ref_color, color );
if( cg.snap->ps.stats[ STAT_PTEAM ] == PTE_HUMANS &&
cg.snap->ps.stats[ STAT_HEALTH ] < 10 )
{
color[ 0 ] = 1.0f;
color[ 1 ] = color[ 2 ] = 0.0f;
}
+ ref_alpha = ref_color[ 3 ];
if( cg.snap->ps.stats[ STAT_STATE ] & SS_HEALING_ACTIVE )
- color[ 3 ] = 1.0f;
-
- trap_R_SetColor( color );
- CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );
- trap_R_SetColor( NULL );
-}
-
-static void CG_DrawPlayerHealthCross2( rectDef_t *rect, vec4_t color, qhandle_t shader )
-{
- if( !( cg.snap->ps.stats[ STAT_STATE ] & SS_HEALING_2X ) )
- return;
- if( cg.snap->ps.stats[ STAT_STATE ] & SS_HEALING_ACTIVE )
- color[ 3 ] = 1.0f;
+ ref_alpha = 1.0f;
+
+ // Don't fade from nothing
+ if( !cg.lastHealthCross )
+ cg.lastHealthCross = shader;
- trap_R_SetColor( color );
- CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );
- trap_R_SetColor( NULL );
-}
+ // Fade the icon during transition
+ if( cg.lastHealthCross != shader )
+ {
+ cg.healthCrossFade += cg.frametime / 500.f;
+ if( cg.healthCrossFade > 1.f )
+ {
+ cg.healthCrossFade = 0.f;
+ cg.lastHealthCross = shader;
+ }
+ else
+ {
+ // Fading between two icons
+ color[ 3 ] = ref_alpha * cg.healthCrossFade;
+ trap_R_SetColor( color );
+ CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );
+ color[ 3 ] = ref_alpha * ( 1.f - cg.healthCrossFade );
+ trap_R_SetColor( color );
+ CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cg.lastHealthCross );
+ trap_R_SetColor( NULL );
+ return;
+ }
+ }
-static void CG_DrawPlayerHealthCross3( rectDef_t *rect, vec4_t color, qhandle_t shader )
-{
- if( !( cg.snap->ps.stats[ STAT_STATE ] & SS_HEALING_3X ) )
- return;
- if( cg.snap->ps.stats[ STAT_STATE ] & SS_HEALING_ACTIVE )
- color[ 3 ] = 1.0f;
-
+ // Not fading, draw a single icon
+ color[ 3 ] = ref_alpha;
trap_R_SetColor( color );
CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );
trap_R_SetColor( NULL );
@@ -917,8 +941,16 @@ static float CG_ChargeProgress( void )
}
else if( cg.snap->ps.weapon == WP_ALEVEL4 )
{
- min = LEVEL4_TRAMPLE_CHARGE_MIN;
- max = LEVEL4_TRAMPLE_CHARGE_MAX;
+ if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_CHARGING )
+ {
+ min = 0;
+ max = LEVEL4_TRAMPLE_DURATION;
+ }
+ else
+ {
+ min = LEVEL4_TRAMPLE_CHARGE_MIN;
+ max = LEVEL4_TRAMPLE_CHARGE_MAX;
+ }
}
else if( cg.snap->ps.weapon == WP_LUCIFER_CANNON )
{
@@ -962,11 +994,14 @@ static void CG_DrawPlayerChargeBarBG( rectDef_t *rect, vec4_t ref_color,
trap_R_SetColor( NULL );
}
+// FIXME: This should come from the element info
+#define CHARGE_BAR_CAP_SIZE 3
+
static void CG_DrawPlayerChargeBar( rectDef_t *rect, vec4_t ref_color,
qhandle_t shader )
{
vec4_t color;
- float x, y, width, height, cap_width, progress;
+ float x, y, width, height, cap_size, progress;
if( !cg_drawChargeBar.integer )
return;
@@ -1005,21 +1040,45 @@ static void CG_DrawPlayerChargeBar( rectDef_t *rect, vec4_t ref_color,
color[ 2 ] = 0.0f;
}
- // Calculate bar coords
x = rect->x;
y = rect->y;
- width = ( rect->w - 6 ) * cg.chargeMeterValue;
- height = rect->h;
- CG_AdjustFrom640( &x, &y, &width, &height );
- cap_width = 3 * cgs.screenXScale;
- // Draw the meter
- trap_R_SetColor( color );
- trap_R_DrawStretchPic( x, y, cap_width, height, 0, 0, 1, 1, shader );
- trap_R_DrawStretchPic( x + width + cap_width, y, cap_width, height,
- 1, 0, 0, 1, shader );
- trap_R_DrawStretchPic( x + cap_width, y, width, height, 1, 0, 1, 1, shader );
- trap_R_SetColor( NULL );
+ // Horizontal charge bar
+ if( rect->w >= rect->h )
+ {
+ width = ( rect->w - CHARGE_BAR_CAP_SIZE * 2 ) * cg.chargeMeterValue;
+ height = rect->h;
+ CG_AdjustFrom640( &x, &y, &width, &height );
+ cap_size = CHARGE_BAR_CAP_SIZE * cgs.screenXScale;
+
+ // Draw the meter
+ trap_R_SetColor( color );
+ trap_R_DrawStretchPic( x, y, cap_size, height, 0, 0, 1, 1, shader );
+ trap_R_DrawStretchPic( x + width + cap_size, y, cap_size, height,
+ 1, 0, 0, 1, shader );
+ trap_R_DrawStretchPic( x + cap_size, y, width, height, 1, 0, 1, 1, shader );
+ trap_R_SetColor( NULL );
+ }
+
+ // Vertical charge bar
+ else
+ {
+ y += rect->h;
+ width = rect->w;
+ height = ( rect->h - CHARGE_BAR_CAP_SIZE * 2 ) * cg.chargeMeterValue;
+ CG_AdjustFrom640( &x, &y, &width, &height );
+ cap_size = CHARGE_BAR_CAP_SIZE * cgs.screenYScale;
+
+ // Draw the meter
+ trap_R_SetColor( color );
+ trap_R_DrawStretchPic( x, y - cap_size, width, cap_size,
+ 0, 1, 1, 0, shader );
+ trap_R_DrawStretchPic( x, y - height - cap_size * 2, width,
+ cap_size, 0, 0, 1, 1, shader );
+ trap_R_DrawStretchPic( x, y - height - cap_size, width, height,
+ 0, 1, 1, 1, shader );
+ trap_R_SetColor( NULL );
+ }
}
static void CG_DrawProgressLabel( rectDef_t *rect, float text_x, float text_y, vec4_t color,
@@ -2261,13 +2320,7 @@ void CG_OwnerDraw( float x, float y, float w, float h, float text_x,
CG_DrawPlayerHealthValue( &rect, color );
break;
case CG_PLAYER_HEALTH_CROSS:
- CG_DrawPlayerHealthCross( &rect, color, shader );
- break;
- case CG_PLAYER_HEALTH_CROSS2:
- CG_DrawPlayerHealthCross2( &rect, color, shader );
- break;
- case CG_PLAYER_HEALTH_CROSS3:
- CG_DrawPlayerHealthCross3( &rect, color, shader );
+ CG_DrawPlayerHealthCross( &rect, color );
break;
case CG_PLAYER_CHARGE_BAR_BG:
CG_DrawPlayerChargeBarBG( &rect, color, shader );
@@ -2870,7 +2923,9 @@ static qboolean CG_DrawQueue( void )
w = UI_Text_Width( buffer, 0.7f, 0 );
UI_Text_Paint( 320 - w / 2, 360, 0.7f, color, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
- if( cg.snap->ps.persistant[ PERS_SPAWNS ] == 1 )
+ if( cg.snap->ps.persistant[ PERS_SPAWNS ] == 0 )
+ Com_sprintf( buffer, MAX_STRING_CHARS, "There are no spawns remaining" );
+ else if( cg.snap->ps.persistant[ PERS_SPAWNS ] == 1 )
Com_sprintf( buffer, MAX_STRING_CHARS, "There is 1 spawn remaining" );
else
Com_sprintf( buffer, MAX_STRING_CHARS, "There are %d spawns remaining",
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 3f4a0d80..2c04f4e6 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1101,7 +1101,6 @@ typedef struct
qboolean weapon2Firing;
qboolean weapon3Firing;
- int boostedTime;
int poisonedTime;
vec3_t lastNormal; // view smoothage
@@ -1139,6 +1138,8 @@ typedef struct
float chargeMeterAlpha;
float chargeMeterValue;
+ qhandle_t lastHealthCross;
+ float healthCrossFade;
int nextWeaponClickTime;
} cg_t;
@@ -1277,6 +1278,11 @@ typedef struct
qhandle_t buildWeaponTimerPie[ 8 ];
qhandle_t upgradeClassIconShader;
+ qhandle_t healthCross;
+ qhandle_t healthCross2X;
+ qhandle_t healthCross3X;
+ qhandle_t healthCrossMedkit;
+ qhandle_t healthCrossPoisoned;
} cgMedia_t;
typedef struct
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index f07df10f..67db0a61 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -846,6 +846,13 @@ static void CG_RegisterGraphics( void )
for( i = 0; i < 8; i++ )
cgs.media.buildWeaponTimerPie[ i ] = trap_R_RegisterShader( buildWeaponTimerPieShaders[ i ] );
+ // player health cross shaders
+ cgs.media.healthCross = trap_R_RegisterShader( "ui/assets/neutral/cross.tga" );
+ cgs.media.healthCross2X = trap_R_RegisterShader( "ui/assets/neutral/cross2.tga" );
+ cgs.media.healthCross3X = trap_R_RegisterShader( "ui/assets/neutral/cross3.tga" );
+ cgs.media.healthCrossMedkit = trap_R_RegisterShader( "ui/assets/neutral/cross_medkit.tga" );
+ cgs.media.healthCrossPoisoned = trap_R_RegisterShader( "ui/assets/neutral/cross_poison.tga" );
+
cgs.media.upgradeClassIconShader = trap_R_RegisterShader( "icons/icona_upgrade.tga" );
cgs.media.balloonShader = trap_R_RegisterShader( "gfx/sprites/chatballoon" );
@@ -1812,7 +1819,6 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum )
CG_LoadHudMenu( );
cg.weaponSelect = WP_NONE;
- cg.boostedTime = -1;
// old servers
diff --git a/src/cgame/cg_playerstate.c b/src/cgame/cg_playerstate.c
index e1bcb091..6999e773 100644
--- a/src/cgame/cg_playerstate.c
+++ b/src/cgame/cg_playerstate.c
@@ -313,5 +313,12 @@ void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops )
cg.duckChange = ps->viewheight - ops->viewheight;
cg.duckTime = cg.time;
}
+
+ // changed team
+ if( ps->persistant[ PERS_TEAM ] != ops->persistant[ PERS_TEAM ] )
+ {
+ cg.lastHealthCross = 0;
+ cg.chargeMeterAlpha = 0.0f;
+ }
}
diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c
index 94e7187c..f18773c0 100644
--- a/src/cgame/cg_view.c
+++ b/src/cgame/cg_view.c
@@ -1234,12 +1234,6 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
// decide on third person view
cg.renderingThirdPerson = cg_thirdPerson.integer || ( cg.snap->ps.stats[ STAT_HEALTH ] <= 0 );
- // Infer when we first became boosted
- if( ( cg.snap->ps.stats[ STAT_STATE ] & SS_BOOSTED ) && cg.boostedTime < 0 )
- cg.boostedTime = cg.time;
- else if( !( cg.snap->ps.stats[ STAT_STATE ] & SS_BOOSTED ) && cg.boostedTime >= 0 )
- cg.boostedTime = -1;
-
// build cg.refdef
inwater = CG_CalcViewValues( );