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 af9952e
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
### Bug fixes

* Added missing client side event for `func_vehicle` sounds
* Link Linux binaries with `-Wl` and `--no-undefined` flags to avoid situations where something was referenced but wasn't added in the build (Thanks a1batross)

## Changes in V1.1.0
Expand Down
1 change: 1 addition & 0 deletions FULL_UPDATED_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ Fixes for bugs introduced in beta builds are not included in this list.
* Prevent breakables from spawning multiple items when destroyed by gunfire and explosives at the same time (Thanks Oxofemple.)
* Added cvar `sv_allowbunnyhopping` to control whether the bunny hopping limiter is enabled (halflife issue [#11](https://github.com/ValveSoftware/halflife/issues/11))
* Added `sv_load_all_maps` & `sv_stop_loading_all_maps` to help automate node graph generation
* Added missing client side event for `func_vehicle` sounds

## Code cleanup

Expand Down
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 af9952e

Please sign in to comment.