Skip to content

Commit

Permalink
Add missing func_vehicle sound client side event
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelTroch committed Sep 21, 2024
1 parent 3b1d963 commit d609aa2
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
60 changes: 60 additions & 0 deletions cl_dll/ev_hldm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,66 @@ void EV_TrainPitchAdjust(event_args_t* args)
}
}

void EV_VehiclePitchAdjust(event_args_t* args)
{
int idx;
Vector origin;

unsigned short us_params;
int noise;
float m_flVolume;
int pitch;
bool stop;

char sz[256];

idx = args->entindex;

VectorCopy(args->origin, origin);

us_params = (unsigned short)args->iparam1;
stop = 0 != args->bparam1;

m_flVolume = (float)(us_params & 0x003f) / 40.0;
noise = (int)(((us_params) >> 12) & 0x0007);
pitch = (int)(10.0 * (float)((us_params >> 6) & 0x003f));

switch (noise)
{
case 1:
strcpy(sz, "plats/vehicle1.wav");
break;
case 2:
strcpy(sz, "plats/vehicle2.wav");
break;
case 3:
strcpy(sz, "plats/vehicle3.wav");
break;
case 4:
strcpy(sz, "plats/vehicle4.wav");
break;
case 5:
strcpy(sz, "plats/vehicle6.wav");
break;
case 6:
strcpy(sz, "plats/vehicle7.wav");
break;
default:
// no sound
strcpy(sz, "");
return;
}

if (stop)
{
gEngfuncs.pEventAPI->EV_StopSound(idx, CHAN_STATIC, sz);
}
else
{
gEngfuncs.pEventAPI->EV_PlaySound(idx, origin, CHAN_STATIC, sz, m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, pitch);
}
}

bool EV_TFC_IsAllyTeam(int iTeam1, int iTeam2)
{
return false;
Expand Down
1 change: 1 addition & 0 deletions cl_dll/ev_hldm.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ void EV_SnarkFire(event_args_t* args);


void EV_TrainPitchAdjust(event_args_t* args);
void EV_VehiclePitchAdjust(event_args_t* args);
1 change: 1 addition & 0 deletions cl_dll/hl/hl_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void Game_HookEvents()
gEngfuncs.pfnHookEvent("events/gauss.sc", EV_FireGauss);
gEngfuncs.pfnHookEvent("events/gaussspin.sc", EV_SpinGauss);
gEngfuncs.pfnHookEvent("events/train.sc", EV_TrainPitchAdjust);
gEngfuncs.pfnHookEvent("events/vehicle.sc", EV_VehiclePitchAdjust);
gEngfuncs.pfnHookEvent("events/crowbar.sc", EV_Crowbar);
gEngfuncs.pfnHookEvent("events/crossbow1.sc", EV_FireCrossbow);
gEngfuncs.pfnHookEvent("events/crossbow2.sc", EV_FireCrossbow2);
Expand Down

0 comments on commit d609aa2

Please sign in to comment.