Add missing func_vehicle sound client side event

Fixes https://github.com/ValveSoftware/halflife/issues/3746
This commit is contained in:
Joël Troch 2024-09-21 21:15:55 +02:00
parent 3b1d963f28
commit af9952e3da
5 changed files with 64 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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);

View file

@ -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);