From 0c097c244fc8c57fa33524c8c351195826519343 Mon Sep 17 00:00:00 2001 From: IronClawTrem Date: Fri, 21 Feb 2020 13:55:46 +0000 Subject: sounds for zooming in / out with mass driver --- src/cgame/cg_local.h | 3 +++ src/cgame/cg_main.c | 3 +++ src/cgame/cg_weapons.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) (limited to 'src/cgame') diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index ea1694b..83c3162 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -666,6 +666,7 @@ typedef struct centity_s qboolean valid; qboolean oldValid; + qboolean zoomed; } centity_t; @@ -1185,6 +1186,8 @@ typedef struct // sounds sfxHandle_t tracerSound; + sfxHandle_t weaponZoomIn; + sfxHandle_t weaponZoomOut; sfxHandle_t selectSound; sfxHandle_t footsteps[ FOOTSTEP_TOTAL ][ 4 ]; sfxHandle_t talkSound; diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index eb19dcb..a5496cd 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -883,6 +883,9 @@ static void CG_RegisterSounds( void ) cgs.media.tracerSound = trap_S_RegisterSound( "sound/weapons/tracer.wav", qfalse ); cgs.media.selectSound = trap_S_RegisterSound( "sound/weapons/change.wav", qfalse ); + cgs.media.weaponZoomIn = trap_S_RegisterSound( "sound/weapons/zoom_in.wav", qfalse ); + cgs.media.weaponZoomOut = trap_S_RegisterSound( "sound/weapons/zoom_out.wav", qfalse ); + cgs.media.talkSound = trap_S_RegisterSound( "sound/misc/talk.wav", qfalse ); cgs.media.alienTalkSound = trap_S_RegisterSound( "sound/misc/alien_talk.wav", qfalse ); cgs.media.humanTalkSound = trap_S_RegisterSound( "sound/misc/human_talk.wav", qfalse ); diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index 9aa9f9d..ca0115f 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -858,6 +858,35 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->readySound ); } + //Zoom in / out sound + if( ( weaponNum == WP_LAS_GUN || weaponNum == WP_MASS_DRIVER ) && + ( cent->currentState.eFlags & EF_ZOOM ) && !cent->zoomed ) + { + trap_S_StartSound( cent->lerpOrigin, cent->currentState.number, + CHAN_AUTO, cgs.media.weaponZoomIn ); + cent->zoomed = qtrue; + + if( cg.snap->ps.pm_flags & PMF_FOLLOW ) + { + cg.zoomed = qtrue; + cg.zoomTime = MIN( cg.time, + cg.time + cg.time - cg.zoomTime - ZOOM_TIME ); + } + } + else if ( ( weaponNum == WP_LAS_GUN || weaponNum == WP_MASS_DRIVER ) && + !( cent->currentState.eFlags & EF_ZOOM ) && cent->zoomed ) + { + trap_S_StartSound( cent->lerpOrigin, cent->currentState.number, + CHAN_AUTO, cgs.media.weaponZoomOut ); + cent->zoomed = qfalse; + if( cg.snap->ps.pm_flags & PMF_FOLLOW ) + { + cg.zoomed = qfalse; + cg.zoomTime = MIN( cg.time, + cg.time + cg.time - cg.zoomTime - ZOOM_TIME ); + } + } + if( !noGunModel ) { CG_PositionEntityOnTag( &gun, parent, parent->hModel, "tag_weapon" ); -- cgit