From b79a2d6c9ffb0b41f85064ed44b7e4de8472cd9e Mon Sep 17 00:00:00 2001 From: Sabian Roberts <31491602+sabianroberts@users.noreply.github.com> Date: Sat, 14 Sep 2024 21:10:31 +0100 Subject: [PATCH] Move shield empty sound to SE --- binary/dlls/player.cpp | 18 ++++++++++++++++++ binary/dlls/player.h | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/binary/dlls/player.cpp b/binary/dlls/player.cpp index bdcc3b95..0db438bd 100644 --- a/binary/dlls/player.cpp +++ b/binary/dlls/player.cpp @@ -4663,6 +4663,24 @@ void CBasePlayer :: UpdateClientData( void ) float currentTime = gpGlobals->time; + if (pev->armorvalue <= 0) + { + if (!isShieldEmpty && (currentTime - lastShieldSoundTime > 1.0f)) + { + EMIT_SOUND(ENT(pev), CHAN_AUTO, "player/shield_empty.wav", 0.85, ATTN_NORM); + isShieldEmpty = true; + lastShieldSoundTime = currentTime; + } + } + else + { + if (isShieldEmpty) + { + STOP_SOUND(ENT(pev), CHAN_AUTO, "player/shield_empty.wav"); + isShieldEmpty = false; + } + } + if (pev->armorvalue < 10) { if (!isShieldLow && (currentTime - lastShieldSoundTime > 1.0f)) // 1 second delay diff --git a/binary/dlls/player.h b/binary/dlls/player.h index 5974bced..29207531 100644 --- a/binary/dlls/player.h +++ b/binary/dlls/player.h @@ -516,9 +516,10 @@ class CBasePlayer : public CBaseMonster float m_flDisplacerSndRoomtype; bool isShieldLow; + bool isShieldEmpty; float lastShieldSoundTime; - CBasePlayer () : isShieldLow(false), lastShieldSoundTime(0.0f) {} + CBasePlayer () : isShieldLow(false), isShieldEmpty(false), lastShieldSoundTime(0.0f) {} void UpdateClientData();