Skip to content

Commit

Permalink
Move shield empty sound to SE
Browse files Browse the repository at this point in the history
  • Loading branch information
sabianroberts committed Sep 14, 2024
1 parent 6ab1b36 commit b79a2d6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions binary/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion binary/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit b79a2d6

Please sign in to comment.