diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2015-04-04 19:19:17 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2015-04-04 19:19:17 +0200 |
commit | d6fa5c74ba80688a3e14d2e099bfb6077323d079 (patch) | |
tree | 8e690b045833c644c8830c848f1dc31bbfba6072 | |
parent | 8c6ad4c73c816dbe412e6fac0ad1c0d2837492cc (diff) |
Initial implementation of hit sounds.
-rw-r--r-- | assets/sound/feedback/hit_building.wav | bin | 0 -> 4454 bytes | |||
-rw-r--r-- | assets/sound/feedback/hit_building_splash.wav | bin | 0 -> 4454 bytes | |||
-rw-r--r-- | assets/sound/feedback/hit_enemy.wav | bin | 0 -> 4454 bytes | |||
-rw-r--r-- | assets/sound/feedback/hit_friendly.wav | bin | 0 -> 4454 bytes | |||
-rw-r--r-- | assets/sound/feedback/hit_splash.wav | bin | 0 -> 4454 bytes | |||
-rw-r--r-- | src/cgame/cg_draw.c | 14 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 4 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 18 | ||||
-rw-r--r-- | src/game/bg_public.h | 6 |
9 files changed, 37 insertions, 5 deletions
diff --git a/assets/sound/feedback/hit_building.wav b/assets/sound/feedback/hit_building.wav Binary files differnew file mode 100644 index 0000000..d3f3d82 --- /dev/null +++ b/assets/sound/feedback/hit_building.wav diff --git a/assets/sound/feedback/hit_building_splash.wav b/assets/sound/feedback/hit_building_splash.wav Binary files differnew file mode 100644 index 0000000..0987138 --- /dev/null +++ b/assets/sound/feedback/hit_building_splash.wav diff --git a/assets/sound/feedback/hit_enemy.wav b/assets/sound/feedback/hit_enemy.wav Binary files differnew file mode 100644 index 0000000..51d6b9b --- /dev/null +++ b/assets/sound/feedback/hit_enemy.wav diff --git a/assets/sound/feedback/hit_friendly.wav b/assets/sound/feedback/hit_friendly.wav Binary files differnew file mode 100644 index 0000000..c3fd444 --- /dev/null +++ b/assets/sound/feedback/hit_friendly.wav diff --git a/assets/sound/feedback/hit_splash.wav b/assets/sound/feedback/hit_splash.wav Binary files differnew file mode 100644 index 0000000..459b5fc --- /dev/null +++ b/assets/sound/feedback/hit_splash.wav diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 8007bfe..2c9c400 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -3879,6 +3879,20 @@ found_blob: blob->flags = flags; VectorCopy( origin, blob->origin ); VectorSet( blob->velocity, crandom( ) * 20, crandom( ) * 20, 100 ); + + if( cg_hitSounds.integer > 1 || + ( cg_hitSounds.integer == 1 && + ( flags & DAMAGE_BLOB_FRIENDLY ) ) ) + { + int index; + + if( flags & DAMAGE_BLOB_FRIENDLY ) + index = 4; + else + index = ( flags & ( DAMAGE_BLOB_SPLASH | DAMAGE_BLOB_BUILDABLE ) ); + + trap_S_StartLocalSound( cgs.media.hitSounds[ index ], CHAN_LOCAL_SOUND ); + } } static void CG_DrawNumber( float x, float y, float h, char *str ) diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 2d2598c..6c3325a 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1349,6 +1349,8 @@ typedef struct qhandle_t lightningBeam; qhandle_t lightningImpactPS; + + sfxHandle_t hitSounds[ 5 ]; } cgMedia_t; typedef struct @@ -1613,6 +1615,8 @@ extern vmCvar_t cg_damageBlobAlpha; extern vmCvar_t cg_healthBarSize; extern vmCvar_t cg_healthBarAlpha; +extern vmCvar_t cg_hitSounds; + // // cg_main.c // diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 9e51258..06fd2a3 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -238,6 +238,8 @@ vmCvar_t cg_damageBlobAlpha; vmCvar_t cg_healthBarSize; vmCvar_t cg_healthBarAlpha; +vmCvar_t cg_hitSounds; + typedef struct { vmCvar_t *vmCvar; @@ -391,7 +393,9 @@ static cvarTable_t cvarTable[ ] = { &cg_damageBlobAlpha, "cg_damageBlobAlpha", "0.8", CVAR_ARCHIVE }, { &cg_healthBarSize, "cg_healthBarSize", "2000", CVAR_ARCHIVE }, - { &cg_healthBarAlpha, "cg_healthBarAlpha", "0.5", CVAR_ARCHIVE } + { &cg_healthBarAlpha, "cg_healthBarAlpha", "0.5", CVAR_ARCHIVE }, + + { &cg_hitSounds, "cg_hitSounds", "1", CVAR_ARCHIVE } }; static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] ); @@ -647,7 +651,14 @@ static void CG_RegisterSounds( void ) int i; char name[ MAX_QPATH ]; const char *soundName; - + const char *hit_sounds[ 5 ] = + { + "sound/feedback/hit_enemy.wav", + "sound/feedback/hit_splash.wav", + "sound/feedback/hit_building.wav", + "sound/feedback/hit_building_splash.wav", + "sound/feedback/hit_friendly.wav", + }; cgs.media.alienStageTransition = trap_S_RegisterSound( "sound/announcements/overmindevolved.wav", qtrue ); @@ -751,6 +762,9 @@ static void CG_RegisterSounds( void ) cgs.media.FlamerWarningSound = trap_S_RegisterSound( "models/weapons/flamer/warning.wav", qfalse ); cgs.media.FlamerWarningSound2 = trap_S_RegisterSound( "models/weapons/flamer/warning2.wav", qfalse ); + + for( i = 0; i < 5; i++ ) + cgs.media.hitSounds[ i ] = trap_S_RegisterSound( hit_sounds[ i ], qfalse ); } diff --git a/src/game/bg_public.h b/src/game/bg_public.h index fa93839..a04d053 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -1245,6 +1245,6 @@ typedef struct int cmdcmp( const void *a, const void *b ); // damage blob flags -#define DAMAGE_BLOB_FRIENDLY 1 -#define DAMAGE_BLOB_BUILDABLE 2 -#define DAMAGE_BLOB_SPLASH 4 +#define DAMAGE_BLOB_SPLASH 1 // has to be 1 +#define DAMAGE_BLOB_BUILDABLE 2 // has to be 2 +#define DAMAGE_BLOB_FRIENDLY 4 |