From 82b933d0581646ab85554a527737d827267352cb Mon Sep 17 00:00:00 2001 From: Sabian Roberts <31491602+sabianroberts@users.noreply.github.com> Date: Wed, 23 Oct 2024 20:56:40 +0100 Subject: [PATCH] Gauss seconday spin up sound --- cl_dll/ev_hldm.cpp | 35 +++++++++++++++++++++++++++++++++++ dlls/gauss.cpp | 1 + 2 files changed, 36 insertions(+) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index ecfeee24..d73a5fbe 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -57,6 +57,8 @@ #include "op4_weapons/CDisplacer.h" #include "op4_weapons/CM249.h" #include "op4_weapons/CPenguin.h" +#include +#include extern engine_studio_api_t IEngineStudio; @@ -98,6 +100,7 @@ void EV_FireMP5( struct event_args_s *args ); void EV_FireMP52( struct event_args_s *args ); void EV_FirePython( struct event_args_s *args ); void EV_FireGauss( struct event_args_s *args ); +void EV_GaussSuccess(struct event_args_s* args); void EV_SpinGauss( struct event_args_s *args ); void EV_Crowbar( struct event_args_s *args ); void EV_FireCrossbow( struct event_args_s *args ); @@ -1206,6 +1209,35 @@ void EV_FirePython( event_args_t *args ) // GAUSS START //====================== #define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch +bool g_bSoundPlayed = false; + +void EV_GaussSuccess(event_args_t* args) +{ + int idx; + + vec3_t origin; + vec3_t angles; + vec3_t velocity; + + idx = args->entindex; + + gEngfuncs.pEventAPI->EV_PlaySound(idx, origin, CHAN_WEP4, "buttons/button6.wav", 1.0, ATTN_NORM, 0, PITCH_NORM); +} + +void DelayedSound(event_args_t* args) +{ + if (!g_bSoundPlayed) + { + std::this_thread::sleep_for(std::chrono::milliseconds(1200)); + EV_GaussSuccess(args); + g_bSoundPlayed = true; + } +} + +void StopButtonSound() +{ + g_bSoundPlayed = false; +} void EV_SpinGauss( event_args_t *args ) { @@ -1226,6 +1258,8 @@ void EV_SpinGauss( event_args_t *args ) iSoundState = args->bparam1 ? SND_CHANGE_PITCH : 0; + std::thread(DelayedSound, args).detach(); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "ambience/pulsemachine.wav", 1.0, ATTN_NORM, iSoundState, pitch ); } @@ -1334,6 +1368,7 @@ void EV_FireGauss( event_args_t *args ) } + StopButtonSound(); gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/gauss2.wav", 0.5 + flDamage * (1.0 / 400.0), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) ); while (flDamage > 10 && nMaxHits > 0) diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 213ae5dd..1232fc8a 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -86,6 +86,7 @@ void CGauss::Precache( void ) PRECACHE_SOUND("weapons/electro5.wav"); PRECACHE_SOUND("weapons/electro6.wav"); PRECACHE_SOUND("ambience/pulsemachine.wav"); + PRECACHE_SOUND("buttons/button6.wav"); m_iGlow = PRECACHE_MODEL( "sprites/hotglow.spr" ); m_iBalls = PRECACHE_MODEL( "sprites/hotglow.spr" );