[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

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);

View File

@ -15,6 +15,7 @@ methodmap CBoss < Basic
myclass.SetBool("bShow", true);
myclass.SetInt("iTemplateNum", -1);
myclass.SetInt("iHealth", 0);
myclass.SetInt("iMaxHealth", 0);
myclass.SetInt("iLastChange", 0);
myclass.SetFloat("fWaitUntil", 0.0);
myclass.SetFloat("fShowAt", 0.0);
@ -95,6 +96,18 @@ methodmap CBoss < Basic
}
}
property int iMaxHealth
{
public get()
{
return this.GetInt("iMaxHealth");
}
public set(int value)
{
this.SetInt("iMaxHealth", value);
}
}
property int iLastChange
{
public get()