diff --git a/binary/dlls/client.cpp b/binary/dlls/client.cpp index 4ab01371..87949ae5 100644 --- a/binary/dlls/client.cpp +++ b/binary/dlls/client.cpp @@ -889,6 +889,7 @@ void ClientPrecache( void ) // BlueNightHawk : Suit Energy Regeneration PRECACHE_SOUND("debris/beamstart15.wav"); + PRECACHE_SOUND("player/shield_low.wav"); PRECACHE_SOUND("player/shield_empty.wav"); PRECACHE_SOUND("player/shield_charge.wav"); PRECACHE_SOUND("items/suitchargeno1.wav"); diff --git a/binary/dlls/player.cpp b/binary/dlls/player.cpp index 2ed0ec2b..fc55ce58 100644 --- a/binary/dlls/player.cpp +++ b/binary/dlls/player.cpp @@ -4658,6 +4658,35 @@ void CBasePlayer :: UpdateClientData( void ) m_iClientHideHUD = m_iHideHUD; } + float currentTime = gpGlobals->time; + + if (pev->armorvalue < 10) + { + if (!isShieldLow && (currentTime - lastShieldSoundTime > 1.0f)) // 1 second delay + { + EMIT_SOUND(ENT(pev), CHAN_AUTO, "player/shield_low.wav", 0.85, ATTN_NORM); + isShieldLow = true; + lastShieldSoundTime = currentTime; + } + } + else + { + if (isShieldLow) + { + STOP_SOUND(ENT(pev), CHAN_AUTO, "player/shield_low.wav"); + isShieldLow = false; + } + } + + if (pev->armorvalue == 0) + { + STOP_SOUND(ENT(pev), CHAN_AUTO, "player/shield_low.wav"); + } + else if (pev->armorvalue > 10) + { + STOP_SOUND(ENT(pev), CHAN_AUTO, "player/shield_low.wav"); + } + // BlueNightHawk : Suit Energy Regeneration #define MSG_STOP_SOUND 100 if (sv_aura_regeneration.value != 0 && pev->armorvalue < MAX_NORMAL_BATTERY diff --git a/binary/dlls/player.h b/binary/dlls/player.h index 18b3dd95..5974bced 100644 --- a/binary/dlls/player.h +++ b/binary/dlls/player.h @@ -255,7 +255,7 @@ class CBasePlayer : public CBaseMonster BOOL SwitchWeapon( CBasePlayerItem *pWeapon ); // JOHN: sends custom messages if player HUD data has changed (eg health, ammo) - virtual void UpdateClientData( void ); + //virtual void UpdateClientData( void ); static TYPEDESCRIPTION m_playerSaveData[]; @@ -515,6 +515,13 @@ class CBasePlayer : public CBaseMonster Vector m_DisplacerReturn; float m_flDisplacerSndRoomtype; + bool isShieldLow; + float lastShieldSoundTime; + + CBasePlayer () : isShieldLow(false), lastShieldSoundTime(0.0f) {} + + void UpdateClientData(); + private: CRope* m_pRope; float m_flLastClimbTime = 0;