From bafb1aab878f21057cf82e62557ae27642102db0 Mon Sep 17 00:00:00 2001 From: Shtrecker Date: Tue, 4 Mar 2025 15:29:59 +0300 Subject: [PATCH] Add kick sounds Co-authored-by: Drombeys --- src/xrGame/WeaponKnife.cpp | 40 ++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/xrGame/WeaponKnife.cpp b/src/xrGame/WeaponKnife.cpp index b5f2c9cf24..5710472cf1 100644 --- a/src/xrGame/WeaponKnife.cpp +++ b/src/xrGame/WeaponKnife.cpp @@ -50,8 +50,16 @@ void CWeaponKnife::Load (LPCSTR section) fWallmarkSize = pSettings->r_float(section,"wm_size"); - m_sounds.LoadSound(section,"snd_shoot", "sndShot", false, SOUND_TYPE_WEAPON_SHOOTING); - + if (pSettings->line_exist(section, "snd_kick_1") && pSettings->line_exist(section, "snd_kick_2")) + { + m_sounds.LoadSound(section, "snd_kick_1", "sndKick1", false, SOUND_TYPE_WEAPON_SHOOTING); + m_sounds.LoadSound(section, "snd_kick_2", "sndKick2", false, SOUND_TYPE_WEAPON_SHOOTING); + } + else + { + m_sounds.LoadSound(section, "snd_shoot", "sndShot", false, SOUND_TYPE_WEAPON_SHOOTING); + } + if (pSettings->line_exist(section, "snd_draw")) m_sounds.LoadSound(section, "snd_draw", "SndShow", false, ESoundTypes(SOUND_TYPE_ITEM_TAKING)); @@ -204,7 +212,10 @@ void CWeaponKnife::MakeShot(Fvector const & pos, Fvector const & dir, float cons iAmmoElapsed = (u32)m_magazine.size(); bool SendHit = SendHitAllowed(H_Parent()); - PlaySound ("sndShot",pos); + if (m_sounds.FindSoundItem("sndShot", false)) + { + PlaySound("sndShot", pos); + } CActor* actor = smart_cast(H_Parent()); if (actor->active_cam() != eacFirstEye) { @@ -275,12 +286,25 @@ void CWeaponKnife::state_Attacking (float) void CWeaponKnife::switch2_Attacking (u32 state) { - if(IsPending()) return; + if(IsPending()) + return; - if(state==eFire) - PlayHUDMotion("anm_attack", FALSE, this, state); - else //eFire2 - PlayHUDMotion("anm_attack2", FALSE, this, state); + if (state == eFire) + { + PlayHUDMotion("anm_attack", FALSE, this, state); + if (m_sounds.FindSoundItem("sndKick1", false)) + { + PlaySound("sndKick1", Position()); + } + } + else + {//eFire2 + PlayHUDMotion("anm_attack2", FALSE, this, state); + if (m_sounds.FindSoundItem("sndKick2", false)) + { + PlaySound("sndKick2", Position()); + } + } SetPending (TRUE); }