summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikko Tiusanen <ams@daug.net>2015-05-31 16:36:18 +0300
committerMikko Tiusanen <ams@daug.net>2015-05-31 16:36:18 +0300
commit41d562ee8d956b6a44293c2a8bc53a2038274a56 (patch)
tree7cd3c8e926d419e5b62e4c82ff8e2519c6a3e4fe
parent528aaa3c017e812638cb7388b378a1a172426265 (diff)
parent711345101d6bd021dc1088e36757ba19ecc2dd5a (diff)
Merge branch 'master' of https://github.com/mtiusane/new-edge
-rw-r--r--src/cgame/cg_draw.c118
-rw-r--r--src/cgame/cg_local.h1
-rw-r--r--src/cgame/cg_main.c4
3 files changed, 115 insertions, 8 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index 0af9839..91cea14 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -3853,6 +3853,25 @@ typedef struct
#define MAX_DAMAGE_INDICATORS 50
cg_damageIndicator_t cg_damageIndicators[ MAX_DAMAGE_INDICATORS ];
+typedef struct
+{
+ int time;
+ int value;
+} cg_damageStat;
+
+enum
+{
+ DS_DIRECT,
+ DS_INDIRECT,
+ DS_DIRECT_BUILDABLE,
+ DS_INDIRECT_BUILDABLE,
+ DS_PERSISTENT,
+ DS_FRIENDLY,
+ DS_MAX
+};
+
+cg_damageStat cg_damageStats[ DS_MAX ];
+
/*
=================
CG_SpawnDamageIndicator
@@ -3862,8 +3881,9 @@ Creates a new local damage indicator
*/
void CG_SpawnDamageIndicator( vec3_t origin, int value, int flags )
{
- int i;
+ int i, dsx;
cg_damageIndicator_t *di, *oldest = NULL;
+ cg_damageStat *ds;
for( i = 0; i < MAX_DAMAGE_INDICATORS; i++ )
{
@@ -3902,6 +3922,24 @@ found:
trap_S_StartLocalSound( cgs.media.hitSounds[ index ], CHAN_LOCAL_SOUND );
}
+
+ if( flags & DIF_FRIENDLY )
+ dsx = DS_FRIENDLY;
+ else if( flags & DIF_PERSISTENT )
+ dsx = DS_PERSISTENT;
+ else if( flags & DIF_BUILDABLE )
+ dsx = ( flags & DIF_INDIRECT ) ? DS_INDIRECT_BUILDABLE : DS_DIRECT_BUILDABLE;
+ else
+ dsx = ( flags & DIF_INDIRECT ) ? DS_INDIRECT : DS_DIRECT;
+
+ ds = cg_damageStats + dsx;
+
+ if( cg.time - ds->time > 1000 )
+ ds->value = value;
+ else
+ ds->value += value;
+
+ ds->time = cg.time;
}
/*
@@ -3912,17 +3950,19 @@ Draws a centered (horizontally and vertically) number using the
cgs.media.numbersAlt charset. Used by damage indicators and health bars.
=================
*/
-static void CG_DrawAltNumber( float x, float y, float h, char *str )
+static void CG_DrawAltNumber( float x, float y, float h, char *str,
+ qboolean center )
{
- int index, len;
+ int index;
float w;
char *p;
- len = strlen( str );
w = h * cgDC.aspectScale * 0.75f;
y -= h / 2;
- x -= len * w / 2;
+
+ if( center )
+ x -= strlen( str ) * w / 2;
for( p = str; *p; p++ )
{
@@ -4006,7 +4046,7 @@ static void CG_DrawDamageIndicators( void )
color[ 3 ] = cg_damageIndicatorAlpha.value * fade;
trap_R_SetColor( color );
- CG_DrawAltNumber( x, y, scale, str );
+ CG_DrawAltNumber( x, y, scale, str, qtrue );
VectorMA( di->origin, dt, di->velocity, di->origin );
di->velocity[ 2 ] -= 300 * dt;
@@ -4017,6 +4057,69 @@ static void CG_DrawDamageIndicators( void )
/*
=================
+CG_DrawDamageStats
+=================
+*/
+static void CG_DrawDamageStats( void )
+{
+ int i;
+ float x, y, h, f;
+ char str[ 30 ];
+ vec4_t color;
+
+ x = 360;
+ h = 10;
+ y = 240 - 0.5 * h * DS_MAX;
+
+ for( i = 0; i < DS_MAX; i++, y += h )
+ {
+ const cg_damageStat *ds = cg_damageStats + i;
+
+ f = ( cg.time - ds->time ) / 1000.0f;
+
+ if( !ds->value || f > 1 )
+ continue;
+
+ Com_sprintf( str, sizeof( str ), "%d", ds->value );
+
+ switch( i )
+ {
+ case DS_FRIENDLY:
+ VectorSet( color, 1, 0, 0 );
+ break;
+
+ case DS_PERSISTENT:
+ VectorSet( color, 0, 1, 0 );
+ break;
+
+ case DS_INDIRECT_BUILDABLE:
+ VectorSet( color, 1, 0.5, 0 );
+ break;
+
+ case DS_DIRECT_BUILDABLE:
+ VectorSet( color, 0.7, 0.7, 0.7 );
+ break;
+
+ case DS_INDIRECT:
+ VectorSet( color, 1, 1, 0 );
+ break;
+
+ case DS_DIRECT:
+ VectorSet( color, 1, 1, 1 );
+ break;
+ }
+
+ color[ 3 ] = 1.0 - f;
+ trap_R_SetColor( color );
+
+ CG_DrawAltNumber( x, y, h, str, qfalse );
+ }
+
+ trap_R_SetColor( NULL );
+}
+
+/*
+=================
Health bars
=================
*/
@@ -4139,7 +4242,7 @@ static void CG_DrawHealthBars( void )
VectorSet( color, 1, 1, 1 );
trap_R_SetColor( color );
- CG_DrawAltNumber( x, y, h, buffer );
+ CG_DrawAltNumber( x, y, h, buffer, qtrue );
}
}
@@ -4196,6 +4299,7 @@ static void CG_Draw2D( void )
CG_DrawHealthBars( );
CG_DrawDamageIndicators( );
+ CG_DrawDamageStats( );
if( !menu )
{
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index dc289b9..9f8de96 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1617,6 +1617,7 @@ extern vmCvar_t cg_healthBarSize;
extern vmCvar_t cg_healthBarAlpha;
extern vmCvar_t cg_hitSounds;
+extern vmCvar_t cg_hitStats;
//
// cg_main.c
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 7ac160e..2f78110 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -239,6 +239,7 @@ vmCvar_t cg_healthBarSize;
vmCvar_t cg_healthBarAlpha;
vmCvar_t cg_hitSounds;
+vmCvar_t cg_hitStats;
typedef struct
{
@@ -395,7 +396,8 @@ static cvarTable_t cvarTable[ ] =
{ &cg_healthBarSize, "cg_healthBarSize", "2000", CVAR_ARCHIVE },
{ &cg_healthBarAlpha, "cg_healthBarAlpha", "0.5", CVAR_ARCHIVE },
- { &cg_hitSounds, "cg_hitSounds", "1", CVAR_ARCHIVE }
+ { &cg_hitSounds, "cg_hitSounds", "1", CVAR_ARCHIVE },
+ { &cg_hitStats, "cg_hitStats", "0", CVAR_ARCHIVE }
};
static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] );