From 3e1e8961bf3bfad660b15a30472b9c572c8b75a5 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Tue, 30 Jul 2019 20:08:50 +0300 Subject: [PATCH] Stop gauss pulse sound on overcharge --- cl_dll/ev_hldm.cpp | 2 ++ dlls/gauss.cpp | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 9b100439..53c6cbcf 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -815,6 +815,7 @@ void EV_FirePython( event_args_t *args ) //====================== // GAUSS START //====================== +#define SND_STOP (1 << 5) #define SND_CHANGE_PITCH (1 << 7) // duplicated in protocol.h change sound pitch void EV_SpinGauss( event_args_t *args ) @@ -835,6 +836,7 @@ void EV_SpinGauss( event_args_t *args ) pitch = args->iparam1; iSoundState = args->bparam1 ? SND_CHANGE_PITCH : 0; + iSoundState = args->bparam2 ? SND_STOP : iSoundState; gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "ambience/pulsemachine.wav", 1.0, ATTN_NORM, iSoundState, pitch ); } diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 8bff79a1..96345ad2 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -278,19 +278,27 @@ void CGauss::SecondaryAttack() // ALERT( at_console, "%d %d %d\n", m_fInAttack, m_iSoundState, pitch ); + const bool overcharge = m_pPlayer->m_flStartCharge < gpGlobals->time - 10.0f; + if( m_iSoundState == 0 ) ALERT( at_console, "sound state %d\n", m_iSoundState ); - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, pitch, 0, ( m_iSoundState == SND_CHANGE_PITCH ) ? 1 : 0, 0 ); +#ifdef GAUSS_OVERCHARGE_FIX + if (!overcharge) +#endif + PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, pitch, 0, ( m_iSoundState == SND_CHANGE_PITCH ) ? 1 : 0, 0 ); m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME; // m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1f; - if( m_pPlayer->m_flStartCharge < gpGlobals->time - 10.0f ) + if( overcharge ) { // Player charged up too long. Zap him. +#ifdef GAUSS_OVERCHARGE_FIX + PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, g_vecZero, g_vecZero, 0.0, 0.0, pitch, 0, 0, 1 ); +#endif EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", 1.0f, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) ); EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/electro6.wav", 1.0f, ATTN_NORM, 0, 75 + RANDOM_LONG( 0, 0x3f ) );