forked from UNLOZE/sm-plugins
[BossHP] Add boss health percentage display
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user