diff --git a/BossHP/scripting/BossHP.sp b/BossHP/scripting/BossHP.sp index 4f5922fb..7f5d5005 100644 --- a/BossHP/scripting/BossHP.sp +++ b/BossHP/scripting/BossHP.sp @@ -21,6 +21,7 @@ ConVar g_hCvar_DebugMode; char g_sHUDText[256]; +bool g_bProcessNewEntities = false; char g_aHurtEntityToBossIdx[2048] = {0xFF, ...}; public Plugin myinfo = @@ -392,6 +393,8 @@ public void OnEntitySpawned(int entity, const char[] classname) if(!g_aConfig) return; + g_bProcessNewEntities = true; + char sTargetname[64]; GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname)); @@ -804,13 +807,18 @@ public void OnGameFrame() if(!Boss.bActive) { + bool bProcess = g_bProcessNewEntities; if(Boss.fWaitUntil) { if(Boss.fWaitUntil > GetGameTime()) continue; Boss.fWaitUntil = 0.0; + bProcess = true; } + if(!bProcess) + continue; + if(!BossInit(i, Boss)) continue; } @@ -869,6 +877,8 @@ public void OnGameFrame() s_bLastHudPrinted = false; } } + + g_bProcessNewEntities = false; } bool BossInit(int iBoss, CBoss _Boss) @@ -1110,8 +1120,6 @@ bool BossInit(int iBoss, CBoss _Boss) Config.bCounterReverse = iCounterOnHitMaxCount > iCounterOnHitMinCount; } - _Boss.bActive = true; - char sShowTrigger[64]; _Config.GetShowTrigger(sShowTrigger, sizeof(sShowTrigger)); @@ -1146,6 +1154,7 @@ bool BossInit(int iBoss, CBoss _Boss) char sShowOutput[64]; _Config.GetShowOutput(sShowOutput, sizeof(sShowOutput)); + bool bHooked = false; int entity = INVALID_ENT_REFERENCE; while((entity = FindEntityByTargetname(entity, sShowTrigger)) != INVALID_ENT_REFERENCE) { @@ -1159,8 +1168,12 @@ bool BossInit(int iBoss, CBoss _Boss) HookSingleEntityOutput(entity, sShowOutput, OnEntityOutputShow, Once); } + bHooked = true; LogDebugMessage("Hooked showtrigger %s:%s", sShowTrigger, sShowOutput); } + + if(!bHooked) + return false; } if(sKillTrigger[0]) @@ -1168,6 +1181,7 @@ bool BossInit(int iBoss, CBoss _Boss) char sKillOutput[64]; _Config.GetKillOutput(sKillOutput, sizeof(sKillOutput)); + bool bHooked = false; int entity = INVALID_ENT_REFERENCE; while((entity = FindEntityByTargetname(entity, sKillTrigger)) != INVALID_ENT_REFERENCE) { @@ -1181,8 +1195,12 @@ bool BossInit(int iBoss, CBoss _Boss) HookSingleEntityOutput(entity, sKillOutput, OnEntityOutputKill, Once); } + bHooked = true; LogDebugMessage("Hooked killtrigger %s:%s", sKillTrigger, sKillOutput); } + + if(!bHooked) + return false; } if(sHurtTrigger[0]) @@ -1190,6 +1208,7 @@ bool BossInit(int iBoss, CBoss _Boss) char sHurtOutput[64]; _Config.GetHurtOutput(sHurtOutput, sizeof(sHurtOutput)); + bool bHooked = false; int entity = INVALID_ENT_REFERENCE; while((entity = FindEntityByTargetname(entity, sHurtTrigger)) != INVALID_ENT_REFERENCE) { @@ -1204,10 +1223,16 @@ bool BossInit(int iBoss, CBoss _Boss) HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt); } + bHooked = true; LogDebugMessage("Hooked hurttrigger %s:%s", sHurtTrigger, sHurtOutput); } + + if(!bHooked) + return false; } + _Boss.bActive = true; + char sBoss[64]; _Config.GetName(sBoss, sizeof(sBoss)); LogDebugMessage("Initialized boss %s (template = %d)", sBoss, iTemplateNum);