Skip to content

Commit

Permalink
Add a sound for when the shield is low
Browse files Browse the repository at this point in the history
  • Loading branch information
sabianroberts committed Sep 7, 2024
1 parent 731b8b6 commit ec1d638
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions binary/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
29 changes: 29 additions & 0 deletions binary/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion binary/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ec1d638

Please sign in to comment.