Skip to content

Commit

Permalink
Add armour HUD flashing on zero @deanamx
Browse files Browse the repository at this point in the history
  • Loading branch information
sabianroberts committed Jun 20, 2024
1 parent fffe9cd commit 146372b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 22 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
Aura Client
======================
[![CI](https://github.com/phoenixprojectsoftware/Aura-CL/actions/workflows/CI.yml/badge.svg?branch=master&event=push)](https://github.com/phoenixprojectsoftware/Aura-CL/actions/workflows/CI.yml)
[![Build Status](https://travis-ci.com/phoenixprojectsoftware/Aura-CL.svg?branch=master)](https://travis-ci.com/phoenixprojectsoftware/Aura-CL)

**Aura** is the all new multiplayer game engine from The Phoenix Project Software, and a modification of Adrenaline Gamer, built specifically for *Half-Life: Zombies Ate My Neighbours.*

Expand Down
58 changes: 38 additions & 20 deletions cl_dll/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf )

int CHudBattery::Draw(float flTime)
{
if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
if (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH)
return 1;

int r, g, b, x, y, a;
Expand All @@ -94,40 +94,58 @@ int CHudBattery::Draw(float flTime)

#if defined( _TFC )
float fScale = 0.0;
if ( m_iBatMax > 0 )

if (m_iBatMax > 0)
fScale = 1.0 / (float)m_iBatMax;

rc.top += m_iHeight * ((float)(m_iBatMax-(min(m_iBatMax,m_iBat))) * fScale); // battery can go from 0 to m_iBatMax so * fScale goes from 0 to 1
rc.top += m_iHeight * ((float)(m_iBatMax - (min(m_iBatMax, m_iBat))) * fScale); // battery can go from 0 to m_iBatMax so * fScale goes from 0 to 1
#else
rc.top += m_iHeight * ((float)(100-(min(100,m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
rc.top += m_iHeight * ((float)(100 - (min(100, m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
#endif

UnpackRGB(r,g,b, gHUD.m_iDefaultHUDColor);
cvar_t* sv_aura_regeneration = gEngfuncs.pfnGetCvarPointer("sv_aura_regeneration");

if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
return 1;

// Has health changed? Flash the health #
if (m_fFade)
// DeanAMX: Flash the armour HUD on zero.

UnpackRGB(r, g, b, RGB_DEFAULT);
if (sv_aura_regeneration->value == 1)
{
if (m_fFade > FADE_TIME)
m_fFade = FADE_TIME;

m_fFade -= (gHUD.m_flTimeDelta * 20);
if (m_fFade <= 0)
if (m_iBat <= 0)
{
if (!Blinking)
{
a = 128;
m_fFade = 0;
PlaySound("player/shield_empty.wav", 1);
Blinking = true;
}

// Fade the health number back to dim
a = (int)(fabs(sin(flTime * 10)) * 256.0);
}
else
{
Blinking = false;

if (0 != m_fFade) // Has health changed? Flash the health #
{
if (m_fFade > FADE_TIME)
m_fFade = FADE_TIME;

m_fFade -= (gHUD.m_flTimeDelta * 20);
if (m_fFade <= 0)
{
a = 128;
m_fFade = 0;
}

a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
// Fade the health number back to dim

a = MIN_ALPHA + (m_fFade / FADE_TIME) * 128;
}
else
a = MIN_ALPHA;
}
}
else
a = MIN_ALPHA;

ScaleColors(r, g, b, a );

Expand Down
1 change: 1 addition & 0 deletions cl_dll/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ class CHudBattery: public CHudBase
int VidInit( void );
int Draw(float flTime);
int MsgFunc_Battery(const char *pszName, int iSize, void *pbuf );
bool Blinking;

private:
HSPRITE m_hSprite1;
Expand Down

0 comments on commit 146372b

Please sign in to comment.