From e399b1eda7cb8713ef0dc93f2135cbbbf1eb686b Mon Sep 17 00:00:00 2001 From: BotoX Date: Mon, 11 Nov 2019 18:22:31 +0100 Subject: [PATCH] BossHP: fix bugs --- BossHP/scripting/BossHP.sp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/BossHP/scripting/BossHP.sp b/BossHP/scripting/BossHP.sp index 22be5d1e..1d29e379 100644 --- a/BossHP/scripting/BossHP.sp +++ b/BossHP/scripting/BossHP.sp @@ -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; + } +}