diff --git a/src/client/game_event.qc b/src/client/game_event.qc index fea3f18..250798a 100644 --- a/src/client/game_event.qc +++ b/src/client/game_event.qc @@ -198,6 +198,9 @@ ClientGame_EventParse(float fHeader) //printfline("EVENT_TS::TEST HAPPENED"); //clearscene(); break; + case EVENT_TS::SOUNDPITCHED: + SoundPitched_Receive(); + break; /* //can this even happen ...? case EVENT_TS::DROP_WEAPON: diff --git a/src/shared/event_enum.h b/src/shared/event_enum.h index cd1c820..3760769 100644 --- a/src/shared/event_enum.h +++ b/src/shared/event_enum.h @@ -14,6 +14,7 @@ enum EVENT_TS{ //TAGGG - NEW. Like EV_IMPACT but to paint a decal only. EV_PLACEDECAL, EV_IMPACT_MELEE, + SOUNDPITCHED, TEST, }; diff --git a/src/shared/include.src b/src/shared/include.src index 2b613b4..d8bc0cd 100644 --- a/src/shared/include.src +++ b/src/shared/include.src @@ -62,6 +62,7 @@ effects.qc //TAGGG - NEW util.qc precache.qc +sound_pitched.qc //fx_impact.h //pmove.c //animations.c diff --git a/src/shared/sound_pitched.qc b/src/shared/sound_pitched.qc new file mode 100644 index 0000000..923669a --- /dev/null +++ b/src/shared/sound_pitched.qc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016-2021 Marco Hladik + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +typedef enum +{ + SNDP_AK47, + SNDP_AKIMBOCOLTS, + SNDP_BARRETTM82, + SNDP_M3_FIRE, + SNDP_BERETTA, + SNDP_BERETTA_SIL, +} sfx_pitched_t; + + +void +SoundPitched_Send(entity ent, int id) +{ +#ifdef SERVER + WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET); + WriteByte(MSG_MULTICAST, EVENT_TS::SOUNDPITCHED); + WriteEntity(MSG_MULTICAST, ent); + WriteByte(MSG_MULTICAST, id); + + msg_entity = ent; + multicast(ent.origin, MULTICAST_PHS); +#endif +} + +#ifdef CLIENT +/* TODO: add the rest */ +const string sfx_pitched_s[] = +{ + "weapons/ak47/fire.wav", + "weapons/gold/gold-fire.wav", + "weapons/barrett/fire.wav", + "weapons/m3/m3-fire.wav", + "weapons/beretta/fire.wav", + "weapons/beretta/fire-sil.wav" +}; + +void +SoundPitched_Receive(void) +{ + entity ent = findfloat(world, entnum, readentitynum()); + int id = readbyte(); + + if (ent) + sound(ent, CHAN_WEAPON, sfx_pitched_s[id], 1.0f, ATTN_NORM, 400, SOUNDFLAG_FOLLOW); +} +#endif diff --git a/src/shared/weapons/weapon_ak47.qc b/src/shared/weapons/weapon_ak47.qc index d9871cd..f87344c 100644 --- a/src/shared/weapons/weapon_ak47.qc +++ b/src/shared/weapons/weapon_ak47.qc @@ -180,8 +180,8 @@ w_ak47_primary(void) PLAY_CLICK_SOUND return; } - - TS_Weapons_PlaySoundDirect(pl, "weapons/ak47/fire.wav"); + + SoundPitched_Send(pl, SNDP_AK47); /* get around protocol limits */ if(!arg_thisWeapon.iIronSight){ TS_Weapons_ViewAnimation(weaponseq_ak47::shoot, 31.0f/30.0f); diff --git a/src/shared/weapons/weapon_akimbocolts.qc b/src/shared/weapons/weapon_akimbocolts.qc index 3385d69..df357cc 100644 --- a/src/shared/weapons/weapon_akimbocolts.qc +++ b/src/shared/weapons/weapon_akimbocolts.qc @@ -216,13 +216,16 @@ BOOLEAN weapon_AkimboColts_akimbo_attack(player localPlayer, weapondynamic_t arg weapon_base_onAttack(localPlayer, ary_weaponData[WEAPON_ID::AkimboColts], arg_thisWeapon, effectiveAkimboChoice); - +#if 0 if(effectiveAkimboChoice & BITS_AKIMBOCHOICE_LEFT){ TS_Weapons_PlaySoundDirect(pl, "weapons/gold/gold-fire.wav"); } if(effectiveAkimboChoice & BITS_AKIMBOCHOICE_RIGHT){ TS_Weapons_PlaySoundDirect(pl, "weapons/gold/gold-fire.wav"); } +#else + SoundPitched_Send(pl, SNDP_AKIMBOCOLTS); +#endif if(pl.akimboTest == 0 && !(finalAkimboChoice == BITS_AKIMBOCHOICE_BOTH)){ diff --git a/src/shared/weapons/weapon_barrett_m82.qc b/src/shared/weapons/weapon_barrett_m82.qc index 68fc480..606aee0 100644 --- a/src/shared/weapons/weapon_barrett_m82.qc +++ b/src/shared/weapons/weapon_barrett_m82.qc @@ -167,9 +167,9 @@ w_barrett_m82_primary(void) PLAY_CLICK_SOUND return; } - - TS_Weapons_PlaySoundDirect(pl, "weapons/barrett/fire.wav"); - + + SoundPitched_Send(pl, SNDP_BARRETTM82); + if(randomChoice < 0.5){ TS_Weapons_ViewAnimation(weaponseq_barrett_m82::shoot, 31.0f/30.0f); }else{ diff --git a/src/shared/weapons/weapon_benellim3.qc b/src/shared/weapons/weapon_benellim3.qc index f34bc26..5e213ba 100644 --- a/src/shared/weapons/weapon_benellim3.qc +++ b/src/shared/weapons/weapon_benellim3.qc @@ -193,7 +193,7 @@ w_benellim3_primary(void) // pump instead! pl.shotgunWaitingForPump = FALSE; - TS_Weapons_PlaySoundChannelDirect(pl, "weapons/m3/m3-pump.wav", CHAN_AUTO); + TS_Weapons_PlaySoundChannelDirect(pl, "weapons/m3/m3-pump.wav", CHAN_AUTO); // these pumps eject shells #ifdef CLIENT @@ -220,7 +220,8 @@ w_benellim3_primary(void) return; } - TS_Weapons_PlaySoundDirect(pl, "weapons/m3/m3-fire.wav"); +// TS_Weapons_PlaySoundDirect(pl, "weapons/m3/m3-fire.wav"); + SoundPitched_Send(pl, SNDP_M3_FIRE); if(arg_thisWeapon.iFireMode == BITS_FIREMODE_PUMP){ TS_Weapons_ViewAnimation(weaponseq_benellim3::shootpump, (31.0f/35.0f) ); diff --git a/src/shared/weapons/weapon_beretta.qc b/src/shared/weapons/weapon_beretta.qc index bda8e47..92ea130 100644 --- a/src/shared/weapons/weapon_beretta.qc +++ b/src/shared/weapons/weapon_beretta.qc @@ -183,9 +183,9 @@ w_beretta_primary(void) if(!(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SILENCER) ){ - TS_Weapons_PlaySoundDirect(pl, "weapons/beretta/fire.wav"); + SoundPitched_Send(pl, SNDP_BERETTA); } else { - TS_Weapons_PlaySoundDirect(pl, "weapons/beretta/fire-sil.wav"); + SoundPitched_Send(pl, SNDP_BERETTA_SIL); } diff --git a/src/shared/weapons/weapon_beretta_akimbo.qc b/src/shared/weapons/weapon_beretta_akimbo.qc index e433082..1577090 100644 --- a/src/shared/weapons/weapon_beretta_akimbo.qc +++ b/src/shared/weapons/weapon_beretta_akimbo.qc @@ -242,16 +242,16 @@ BOOLEAN weapon_Beretta_akimbo_attack(player localPlayer, weapondynamic_t arg_thi if(effectiveAkimboChoice & BITS_AKIMBOCHOICE_LEFT){ if(!(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SILENCER) ){ - TS_Weapons_PlaySoundDirect(pl, "weapons/beretta/fire.wav"); + SoundPitched_Send(pl, SNDP_BERETTA); } else { - TS_Weapons_PlaySoundDirect(pl, "weapons/beretta/fire-sil.wav"); + SoundPitched_Send(pl, SNDP_BERETTA_SIL); } } if(effectiveAkimboChoice & BITS_AKIMBOCHOICE_RIGHT){ if(!(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SILENCER) ){ - TS_Weapons_PlaySoundDirect(pl, "weapons/beretta/fire.wav"); + SoundPitched_Send(pl, SNDP_BERETTA); } else { - TS_Weapons_PlaySoundDirect(pl, "weapons/beretta/fire-sil.wav"); + SoundPitched_Send(pl, SNDP_BERETTA_SIL); } }