From 5fd1aef563c8921055bccfcc5d3984588024e1ee Mon Sep 17 00:00:00 2001 From: BotoX Date: Thu, 14 Nov 2019 20:26:53 +0100 Subject: [PATCH] BossHP: never say never --- BossHP/scripting/BossHP.sp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/BossHP/scripting/BossHP.sp b/BossHP/scripting/BossHP.sp index 5522c4bd..da0db88b 100644 --- a/BossHP/scripting/BossHP.sp +++ b/BossHP/scripting/BossHP.sp @@ -21,7 +21,7 @@ ConVar g_hCvar_DebugMode; char g_sHUDText[256]; -Handle g_aHurtEntityToBoss[2048] = {INVALID_HANDLE, ...}; +Handle g_aHurtEntityToBoss[4096] = {INVALID_HANDLE, ...}; public Plugin myinfo = { @@ -497,7 +497,7 @@ public void OnEntitySpawned(int entity, const char[] classname) continue; } - g_aHurtEntityToBoss[entity] = Boss; + g_aHurtEntityToBoss[EntRefToEntIndex(entity)] = Boss; if(StrEqual(sHurtOutput, "OnTakeDamage")) { @@ -518,6 +518,8 @@ public void OnEntityDestroyed(int entity) if(!g_aConfig) return; + entity = EntRefToEntIndex(entity); + if(entity >= 0 && entity < sizeof(g_aHurtEntityToBoss)) g_aHurtEntityToBoss[entity] = INVALID_HANDLE; } @@ -776,6 +778,10 @@ void OnKillTrigger(int entity, const char[] output, SDKHookType HookType = view_ void OnHurtTrigger(int entity, int activator, float damage = 1.0) { + entity = EntRefToEntIndex(entity); + if(entity <= 0 || entity >= sizeof(g_aHurtEntityToBoss)) + return; + if(g_aHurtEntityToBoss[entity] == INVALID_HANDLE) return; @@ -1272,7 +1278,7 @@ bool BossInit(CBoss _Boss) int entity = INVALID_ENT_REFERENCE; while((entity = FindEntityByTargetname(entity, sHurtTrigger)) != INVALID_ENT_REFERENCE) { - g_aHurtEntityToBoss[entity] = _Boss; + g_aHurtEntityToBoss[EntRefToEntIndex(entity)] = _Boss; if(StrEqual(sHurtOutput, "OnTakeDamage")) {