[BossHP] Add boss health percentage display

This commit is contained in:
zaCade
2025-03-02 10:25:42 +01:00
parent d2a812153b
commit ba1da9afa2
2 changed files with 29 additions and 0 deletions
+16
View File
@@ -1314,6 +1314,7 @@ bool BossProcess(CBoss _Boss)
bool bInvalid = false;
int iHealth = 0;
int iLastHealth = _Boss.iHealth;
int iMaxHealth = _Boss.iMaxHealth;
int iLastChange = _Boss.iLastChange;
if(_Boss.IsBreakable)
@@ -1396,6 +1397,12 @@ bool BossProcess(CBoss _Boss)
if(iHealth < 0)
iHealth = 0;
if(iMaxHealth < iHealth)
{
iMaxHealth = iHealth;
_Boss.iMaxHealth = iHealth;
}
if(iHealth != iLastHealth)
{
iLastChange = GetTime();
@@ -1440,6 +1447,15 @@ bool BossProcess(CBoss _Boss)
sFormat[FormatLen++] = ' ';
FormatLen += IntToString(iHealth, sFormat[FormatLen], sizeof(sFormat) - FormatLen);
sFormat[FormatLen++] = ' ';
sFormat[FormatLen++] = '[';
FormatLen += IntToString(RoundToNearest(float(iHealth) / float(iMaxHealth) * 100), sFormat[FormatLen], sizeof(sFormat) - FormatLen);
FormatLen += StrCat(sFormat[FormatLen], sizeof(sFormat) - FormatLen, "%%%%"); // No idea why this needs 4 percents, but it works.
sFormat[FormatLen++] = ']';
sFormat[FormatLen] = 0;
StrCat(g_sHUDText, sizeof(g_sHUDText), sFormat);