Skip to content

Commit

Permalink
Gauss seconday spin up sound
Browse files Browse the repository at this point in the history
  • Loading branch information
sabianroberts committed Oct 23, 2024
1 parent e159afd commit 82b933d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cl_dll/ev_hldm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
#include "op4_weapons/CDisplacer.h"
#include "op4_weapons/CM249.h"
#include "op4_weapons/CPenguin.h"
#include <thread>
#include <chrono>

extern engine_studio_api_t IEngineStudio;

Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 )
{
Expand All @@ -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 );
}

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions dlls/gauss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down

0 comments on commit 82b933d

Please sign in to comment.