diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2015-04-04 12:47:05 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2015-04-04 12:47:05 +0200 |
commit | e71cf2b9d657c112eb3674969a3185957f816d04 (patch) | |
tree | cf06d8de6e721722b87e562599e61c25f2570fcc /src | |
parent | 72f038ae632b0f9af485129747f5fca45898b52e (diff) | |
parent | 752d1bbed1f59eb45b3c89cbddc1430d817b1102 (diff) |
Merge branch 'damage-feedback'
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_draw.c | 56 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 2 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 5 | ||||
-rw-r--r-- | src/game/g_combat.c | 47 |
4 files changed, 52 insertions, 58 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index f57e44a..09777b6 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -3888,7 +3888,7 @@ static void CG_DrawNumber( float x, float y, float h, char *str ) char *p; len = strlen( str ); - w = h * cgDC.aspectScale * 0.5f; + w = h * cgDC.aspectScale * 0.75f; y -= h / 2; x -= len * w / 2; @@ -3897,10 +3897,14 @@ static void CG_DrawNumber( float x, float y, float h, char *str ) { if( *p >= '0' && *p <= '9' ) index = *p - '0'; - else + else if( *p == '.' ) index = 10; - - CG_DrawPic( x, y, w, h, cgs.media.numberShadersAlt[ index ] ); + else + index = 11; + + if( *p != ' ' ) + CG_DrawPic( x, y, w, h, cgs.media.numberShadersAlt[ index ] ); + x += w; } } @@ -3932,7 +3936,7 @@ static void CG_DrawDamageBlobs( void ) fade = 1.0f - (float)( cg.time - blob->spawnTime ) / DAMAGE_BLOB_TIME; - scale = cg_damageBlobSize.value / + scale = 0.75f * cg_damageBlobSize.value / pow( Distance( blob->origin, cg.refdef.vieworg ), 0.5f ); Com_sprintf( str, sizeof( str ), "%d", blob->value ); @@ -3984,7 +3988,7 @@ typedef struct static int CompareHealthBars( const healthBar_t *a, const healthBar_t *b ) { - return a->dist < b->dist; + return ( a->dist < b->dist ? 1 : -1 ); } static void CG_DrawHealthBars( void ) @@ -4047,44 +4051,50 @@ static void CG_DrawHealthBars( void ) qsort( bars, bare - bars, sizeof( healthBar_t ), (int(*)(const void*,const void*))CompareHealthBars ); -/* - TODO: figure out why qsort fails for more than 5 bars - - for( i = 0; i < bare - bars - 1; i++ ) - if( CompareHealthBars( bars + i, bars + i + 1 ) ) - { - Com_Printf( "qsort is retarded\n" ); - break; - } -*/ - for( bar = bars; bar < bare; bar++ ) { - float x, y, w, h, hf; + float x, y, w, h, hf, cf; char buffer[ 64 ]; vec4_t color; + if( bar->value >= bar->max ) + continue; + if( !CG_WorldToScreen( bar->origin, &x, &y ) ) continue; hf = (float)bar->value / bar->max; h = cg_healthBarSize.value / bar->dist; - w = 4 * h * cgDC.aspectScale; + w = 6 * h * cgDC.aspectScale; - Com_sprintf( buffer, sizeof( buffer ), "%d", bar->value ); + Com_sprintf( buffer, sizeof( buffer ), "%d/%d", bar->value, bar->max ); color[ 3 ] = cg_healthBarAlpha.value; - VectorSet( color, 0.1, 0.7, 0.1 ); + if( hf <= 1.0f && hf > 0.5f ) + { + cf = ( hf - 0.5f ) / 0.5f; + VectorSet( color, 1 - cf, 1.0f, 0.0f ); + } + else + { + cf = hf / 0.5f; + VectorSet( color, 1.0f, cf, 0.0f ); + } + + VectorScale( color, 0.5f, color ); + trap_R_SetColor( color ); CG_DrawPic( x - w/2, y - h/2, w * hf, h, cgs.media.whiteShader ); - VectorSet( color, 0.7, 0.1, 0.1 ); + + + VectorSet( color, 0.1, 0.1, 0.1 ); trap_R_SetColor( color ); CG_DrawPic( x - w/2 + w * hf, y - h/2, w * ( 1 - hf ), h, cgs.media.whiteShader ); - VectorSet( color, 0, 0, 0 ); + VectorSet( color, 1, 1, 1 ); trap_R_SetColor( color ); CG_DrawNumber( x, y, h, buffer ); } diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 83cac63..2d2598c 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1198,7 +1198,7 @@ typedef struct qhandle_t teamOverlayShader; qhandle_t numberShaders[ 11 ]; - qhandle_t numberShadersAlt[ 11 ]; + qhandle_t numberShadersAlt[ 12 ]; qhandle_t shadowMarkShader; qhandle_t wakeMarkShader; diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 0fdb028..9e51258 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -781,7 +781,7 @@ static void CG_RegisterGraphics( void ) "gfx/2d/numbers/nine_32b", "gfx/2d/numbers/minus_32b", }; - static char *sb_nums_alt[ 11 ] = + static char *sb_nums_alt[ 12 ] = { "gfx/2d/numbers_alt/0", "gfx/2d/numbers_alt/1", @@ -794,6 +794,7 @@ static void CG_RegisterGraphics( void ) "gfx/2d/numbers_alt/8", "gfx/2d/numbers_alt/9", "gfx/2d/numbers_alt/minus", + "gfx/2d/numbers_alt/slash", }; static char *buildWeaponTimerPieShaders[ 8 ] = { @@ -817,7 +818,7 @@ static void CG_RegisterGraphics( void ) for( i = 0; i < 11; i++ ) cgs.media.numberShaders[ i ] = trap_R_RegisterShader( sb_nums[ i ] ); - for( i = 0; i < 11; i++ ) + for( i = 0; i < 12; i++ ) cgs.media.numberShadersAlt[ i ] = trap_R_RegisterShader( sb_nums_alt[ i ] ); cgs.media.viewBloodShader = trap_R_RegisterShader( "gfx/damage/fullscreen_painblend" ); diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 1a54981..0c6086d 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -1447,52 +1447,35 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, G_CombatStats_HitMOD( attacker, targ, mod, take ); - if( attacker && attacker->client && take && attacker != targ ) + if( attacker && attacker->client && take && attacker != targ && + attacker->client->bufferedBlobCount < MAX_BUFFERED_BLOBS ) { g_damageBlob_t *blob; - int flags = 0; - if( attacker->client->bufferedBlobCount == MAX_BUFFERED_BLOBS ) - return; + blob = attacker->client->blobBuffer + + ( attacker->client->bufferedBlobCount++ ); + + blob->flags = 0; + blob->value = take; if( OnSameTeam( attacker, targ ) || ( targ->s.eType == ET_BUILDABLE && attacker->client->pers.teamSelection == targ->buildableTeam ) ) - flags |= DAMAGE_BLOB_FRIENDLY; + blob->flags |= DAMAGE_BLOB_FRIENDLY; if( targ->s.eType == ET_BUILDABLE ) - flags |= DAMAGE_BLOB_BUILDABLE; + blob->flags |= DAMAGE_BLOB_BUILDABLE; if( dflags & DAMAGE_RADIUS ) { - vec3_t mins = {0}, maxs = {0}; - - flags |= DAMAGE_BLOB_SPLASH; - - switch( targ->s.eType ) - { - case ET_BUILDABLE: - BG_BuildableBoundingBox( targ->s.modelindex, mins, maxs ); - break; - - case ET_PLAYER: - BG_ClassBoundingBox( targ->client->ps.stats[ STAT_CLASS ], mins, maxs, NULL, NULL, NULL ); - break; - } - - VectorAdd( mins, maxs, point ); - VectorScale( point, 0.5f, point ); - VectorAdd( point, targ->s.origin, point ); + blob->flags |= DAMAGE_BLOB_SPLASH; + VectorAdd( targ->r.absmin, targ->r.absmax, blob->origin ); + VectorScale( blob->origin, 0.5f, blob->origin ); } else if( inflictor->s.eType == ET_MISSILE ) - VectorCopy( inflictor->r.currentOrigin, point ); - - blob = attacker->client->blobBuffer + - ( attacker->client->bufferedBlobCount++ ); - - VectorCopy( point, blob->origin ); - blob->value = take; - blob->flags = flags; + VectorCopy( inflictor->r.currentOrigin, blob->origin ); + else + VectorCopy( point, blob->origin ); } if( targ->health <= 0 ) |