2121#include " game_object_space.h"
2222#include " script_callback_ex.h"
2323#include " script_game_object.h"
24+ #include " HudSound.h"
25+
26+ #include " Common/Config.hpp"
2427
2528ENGINE_API bool g_dedicated_server;
2629
@@ -42,6 +45,7 @@ CWeaponMagazined::CWeaponMagazined(ESoundTypes eSoundType) : CWeapon()
4245 m_eSoundShot = ESoundTypes (SOUND_TYPE_WEAPON_SHOOTING | eSoundType);
4346 m_eSoundEmptyClick = ESoundTypes (SOUND_TYPE_WEAPON_EMPTY_CLICKING | eSoundType);
4447 m_eSoundReload = ESoundTypes (SOUND_TYPE_WEAPON_RECHARGING | eSoundType);
48+ m_eSoundReloadEmpty = ESoundTypes (SOUND_TYPE_WEAPON_RECHARGING | eSoundType);
4549 m_sounds_enabled = true ;
4650
4751 m_sSndShotCurrent = NULL ;
@@ -60,6 +64,20 @@ CWeaponMagazined::~CWeaponMagazined()
6064}
6165
6266void CWeaponMagazined::net_Destroy () { inherited::net_Destroy (); }
67+
68+ // AVO: for custom added sounds check if sound exists
69+ bool CWeaponMagazined::WeaponSoundExist (LPCSTR section, LPCSTR sound_name)
70+ {
71+ pcstr str;
72+ bool sec_exist = process_if_exists_set (section, sound_name, &CInifile::r_string, str, true );
73+ if (sec_exist)
74+ return true ;
75+ Msg (" ~ [WARNING] ------ Sound [%s] does not exist in [%s]" , sound_name, section);
76+ return false ;
77+ }
78+
79+ // -AVO
80+
6381void CWeaponMagazined::Load (LPCSTR section)
6482{
6583 inherited::Load (section);
@@ -71,6 +89,11 @@ void CWeaponMagazined::Load(LPCSTR section)
7189 m_sounds.LoadSound (section, " snd_empty" , " sndEmptyClick" , false , m_eSoundEmptyClick);
7290 m_sounds.LoadSound (section, " snd_reload" , " sndReload" , true , m_eSoundReload);
7391
92+ #ifdef NEW_SOUNDS // AVO: custom sounds go here
93+ if (WeaponSoundExist (section, " snd_reload_empty" ))
94+ m_sounds.LoadSound (section, " snd_reload_empty" , " sndReloadEmpty" , true , m_eSoundReloadEmpty);
95+ #endif // -NEW_SOUNDS
96+
7497 m_sSndShotCurrent = " sndShot" ;
7598
7699 // звуки и партиклы глушителя, еслит такой есть
@@ -457,6 +480,12 @@ void CWeaponMagazined::UpdateSounds()
457480 m_sounds.SetPosition (" sndHide" , P);
458481 // . nah m_sounds.SetPosition("sndShot", P);
459482 m_sounds.SetPosition (" sndReload" , P);
483+
484+ #ifdef NEW_SOUNDS // AVO: custom sounds go here
485+ if (m_sounds.FindSoundItem (" sndReloadEmpty" , false ))
486+ m_sounds.SetPosition (" sndReloadEmpty" , P);
487+ #endif // -NEW_SOUNDS
488+
460489 // . nah m_sounds.SetPosition("sndEmptyClick", P);
461490}
462491
@@ -688,7 +717,17 @@ void CWeaponMagazined::switch2_Empty()
688717void CWeaponMagazined::PlayReloadSound ()
689718{
690719 if (m_sounds_enabled)
691- PlaySound (" sndReload" , get_LastFP ());
720+ if (iAmmoElapsed == 0 )
721+ {
722+ #ifdef NEW_SOUNDS // AVO: custom reload sound
723+ if (m_sounds.FindSoundItem (" sndReloadEmpty" , false ))
724+ PlaySound (" sndReloadEmpty" , get_LastFP ());
725+ else
726+ #endif // -NEW_SOUNDS
727+ PlaySound (" sndReload" , get_LastFP ());
728+ }
729+ else
730+ PlaySound (" sndReload" , get_LastFP ());
692731}
693732
694733void CWeaponMagazined::switch2_Reload ()
@@ -1053,7 +1092,17 @@ void CWeaponMagazined::PlayAnimShow()
10531092void CWeaponMagazined::PlayAnimHide ()
10541093{
10551094 VERIFY (GetState () == eHiding);
1056- PlayHUDMotion (" anm_hide" , TRUE , this , GetState ());
1095+ if (iAmmoElapsed == 0 )
1096+ {
1097+ #ifdef NEW_ANIMS // AVO: new reload animation
1098+ if (isHUDAnimationExist (" anm_reload_empty" ))
1099+ PlayHUDMotion (" anm_reload_empty" , true , this , GetState ());
1100+ else
1101+ #endif // -NEW_ANIMS
1102+ PlayHUDMotion (" anm_reload" , true , this , GetState ());
1103+ }
1104+ else
1105+ PlayHUDMotion (" anm_reload" , true , this , GetState ());
10571106}
10581107
10591108void CWeaponMagazined::PlayAnimReload ()
@@ -1348,6 +1397,15 @@ bool CWeaponMagazined::install_upgrade_impl(LPCSTR section, bool test)
13481397 }
13491398 result |= result2;
13501399
1400+ #ifdef NEW_SOUNDS // AVO: custom sounds go here
1401+ result2 = process_if_exists_set (section, " snd_reload_empty" , &CInifile::r_string, str, test);
1402+ if (result2 && !test)
1403+ {
1404+ m_sounds.LoadSound (section, " snd_reload_empty" , " sndReloadEmpty" , true , m_eSoundReloadEmpty);
1405+ }
1406+ result |= result2;
1407+ #endif // -NEW_SOUNDS
1408+
13511409 // snd_shoot1 = weapons\ak74u_shot_1 ??
13521410 // snd_shoot2 = weapons\ak74u_shot_2 ??
13531411 // snd_shoot3 = weapons\ak74u_shot_3 ??
0 commit comments