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 +++++++++++++++++++++++++++++ src/game/bg_public.h | 1 + src/game/g_active.c | 10 ++++++++++ 5 files changed, 46 insertions(+) (limited to 'src') 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" ); diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 462bf95..69967a1 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -280,6 +280,7 @@ typedef enum #define EF_TELEPORT_BIT 0x00000002 // toggled every time the origin abruptly changes #define EF_PLAYER_EVENT 0x00000004 #define EF_BOUNCE 0x00000008 // for missiles +#define EF_ZOOM 0x00000008 #define EF_BOUNCE_HALF 0x00000010 // for missiles #define EF_NO_BOUNCE_SOUND 0x00000020 // for missiles #define EF_WALLCLIMB 0x00000040 // TA: wall walking diff --git a/src/game/g_active.c b/src/game/g_active.c index b9ab899..fcb888a 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -587,6 +587,16 @@ void ClientTimerActions( gentity_t *ent, int msec ) client->time1000 += msec; client->time10000 += msec; + // zoom detection + if( BG_InventoryContainsWeapon( WP_MASS_DRIVER, ent->client->ps.stats ) + || BG_InventoryContainsWeapon( WP_LAS_GUN, ent->client->ps.stats ) ) + { + if( ( ucmd->buttons & BUTTON_ATTACK2 ) && !( ent->client->ps.eFlags & EF_ZOOM ) ) + client->ps.eFlags |= EF_ZOOM; + else if( !( ucmd->buttons & BUTTON_ATTACK2 ) && ( ent->client->ps.eFlags & EF_ZOOM ) ) + client->ps.eFlags &= ~EF_ZOOM; + } + if( aForward == 0 && aRight == 0 ) stopped = qtrue; else if( aForward <= 64 && aRight <= 64 ) -- cgit