BossHP: fix bugs

This commit is contained in:
BotoX 2019-11-11 18:22:31 +01:00
parent 2a0a3d39ee
commit e399b1eda7

View File

@ -62,6 +62,11 @@ public void OnPluginEnd()
void Cleanup()
{
for(int entity = 0; entity < sizeof(g_aHurtEntityToBossIdx); entity++)
{
g_aHurtEntityToBossIdx[entity] = 0xFF;
}
if(g_aBoss)
{
for(int i = 0; i < g_aBoss.Length; i++)
@ -369,6 +374,11 @@ public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
if(!g_aConfig)
return;
for(int entity = 0; entity < sizeof(g_aHurtEntityToBossIdx); entity++)
{
g_aHurtEntityToBossIdx[entity] = 0xFF;
}
if(g_aBoss)
{
for(int i = 0; i < g_aBoss.Length; i++)
@ -759,6 +769,7 @@ void OnKillTrigger(int entity, const char[] output, SDKHookType HookType = view_
delete Boss;
g_aBoss.Erase(j);
OnBossDeleted(j);
j--;
}
}
@ -872,6 +883,7 @@ public void OnGameFrame()
delete Boss;
g_aBoss.Erase(i);
OnBossDeleted(i);
i--;
continue;
@ -907,15 +919,9 @@ public void OnGameFrame()
delete Boss;
g_aBoss.Erase(i);
OnBossDeleted(i);
i--;
// TODO: Unhook instead of this
for(int entity = 0; entity < sizeof(g_aHurtEntityToBossIdx); entity++)
{
if(g_aHurtEntityToBossIdx[entity] == i)
g_aHurtEntityToBossIdx[entity] = 0xFF;
}
continue;
}
@ -1267,8 +1273,6 @@ bool BossInit(int iBoss, CBoss _Boss)
if(sHurtTrigger[0])
{
Format(sHurtTrigger, sizeof(sHurtTrigger), "%s&%04d", sHurtTrigger, iTemplateNum);
char sHurtOutput[64];
_Config.GetHurtOutput(sHurtOutput, sizeof(sHurtOutput));
@ -1479,3 +1483,12 @@ int FindEntityByTargetname(int entity, const char[] sTargetname, const char[] sC
return INVALID_ENT_REFERENCE;
}
void OnBossDeleted(int iBoss)
{
for(int entity = 0; entity < sizeof(g_aHurtEntityToBossIdx); entity++)
{
if(g_aHurtEntityToBossIdx[entity] == iBoss)
g_aHurtEntityToBossIdx[entity] = 0xFF;
}
}