BossHP: fix bosses that are initialized before some of the other triggers exist
This commit is contained in:
parent
9b5dca9ba4
commit
f0d4f65bf7
@ -21,6 +21,7 @@ ConVar g_hCvar_DebugMode;
|
|||||||
|
|
||||||
char g_sHUDText[256];
|
char g_sHUDText[256];
|
||||||
|
|
||||||
|
bool g_bProcessNewEntities = false;
|
||||||
char g_aHurtEntityToBossIdx[2048] = {0xFF, ...};
|
char g_aHurtEntityToBossIdx[2048] = {0xFF, ...};
|
||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
@ -392,6 +393,8 @@ public void OnEntitySpawned(int entity, const char[] classname)
|
|||||||
if(!g_aConfig)
|
if(!g_aConfig)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
g_bProcessNewEntities = true;
|
||||||
|
|
||||||
char sTargetname[64];
|
char sTargetname[64];
|
||||||
GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
|
GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
|
||||||
|
|
||||||
@ -804,13 +807,18 @@ public void OnGameFrame()
|
|||||||
|
|
||||||
if(!Boss.bActive)
|
if(!Boss.bActive)
|
||||||
{
|
{
|
||||||
|
bool bProcess = g_bProcessNewEntities;
|
||||||
if(Boss.fWaitUntil)
|
if(Boss.fWaitUntil)
|
||||||
{
|
{
|
||||||
if(Boss.fWaitUntil > GetGameTime())
|
if(Boss.fWaitUntil > GetGameTime())
|
||||||
continue;
|
continue;
|
||||||
Boss.fWaitUntil = 0.0;
|
Boss.fWaitUntil = 0.0;
|
||||||
|
bProcess = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!bProcess)
|
||||||
|
continue;
|
||||||
|
|
||||||
if(!BossInit(i, Boss))
|
if(!BossInit(i, Boss))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -869,6 +877,8 @@ public void OnGameFrame()
|
|||||||
s_bLastHudPrinted = false;
|
s_bLastHudPrinted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_bProcessNewEntities = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BossInit(int iBoss, CBoss _Boss)
|
bool BossInit(int iBoss, CBoss _Boss)
|
||||||
@ -1110,8 +1120,6 @@ bool BossInit(int iBoss, CBoss _Boss)
|
|||||||
Config.bCounterReverse = iCounterOnHitMaxCount > iCounterOnHitMinCount;
|
Config.bCounterReverse = iCounterOnHitMaxCount > iCounterOnHitMinCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
_Boss.bActive = true;
|
|
||||||
|
|
||||||
char sShowTrigger[64];
|
char sShowTrigger[64];
|
||||||
_Config.GetShowTrigger(sShowTrigger, sizeof(sShowTrigger));
|
_Config.GetShowTrigger(sShowTrigger, sizeof(sShowTrigger));
|
||||||
|
|
||||||
@ -1146,6 +1154,7 @@ bool BossInit(int iBoss, CBoss _Boss)
|
|||||||
char sShowOutput[64];
|
char sShowOutput[64];
|
||||||
_Config.GetShowOutput(sShowOutput, sizeof(sShowOutput));
|
_Config.GetShowOutput(sShowOutput, sizeof(sShowOutput));
|
||||||
|
|
||||||
|
bool bHooked = false;
|
||||||
int entity = INVALID_ENT_REFERENCE;
|
int entity = INVALID_ENT_REFERENCE;
|
||||||
while((entity = FindEntityByTargetname(entity, sShowTrigger)) != 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);
|
HookSingleEntityOutput(entity, sShowOutput, OnEntityOutputShow, Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bHooked = true;
|
||||||
LogDebugMessage("Hooked showtrigger %s:%s", sShowTrigger, sShowOutput);
|
LogDebugMessage("Hooked showtrigger %s:%s", sShowTrigger, sShowOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!bHooked)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sKillTrigger[0])
|
if(sKillTrigger[0])
|
||||||
@ -1168,6 +1181,7 @@ bool BossInit(int iBoss, CBoss _Boss)
|
|||||||
char sKillOutput[64];
|
char sKillOutput[64];
|
||||||
_Config.GetKillOutput(sKillOutput, sizeof(sKillOutput));
|
_Config.GetKillOutput(sKillOutput, sizeof(sKillOutput));
|
||||||
|
|
||||||
|
bool bHooked = false;
|
||||||
int entity = INVALID_ENT_REFERENCE;
|
int entity = INVALID_ENT_REFERENCE;
|
||||||
while((entity = FindEntityByTargetname(entity, sKillTrigger)) != 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);
|
HookSingleEntityOutput(entity, sKillOutput, OnEntityOutputKill, Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bHooked = true;
|
||||||
LogDebugMessage("Hooked killtrigger %s:%s", sKillTrigger, sKillOutput);
|
LogDebugMessage("Hooked killtrigger %s:%s", sKillTrigger, sKillOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!bHooked)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sHurtTrigger[0])
|
if(sHurtTrigger[0])
|
||||||
@ -1190,6 +1208,7 @@ bool BossInit(int iBoss, CBoss _Boss)
|
|||||||
char sHurtOutput[64];
|
char sHurtOutput[64];
|
||||||
_Config.GetHurtOutput(sHurtOutput, sizeof(sHurtOutput));
|
_Config.GetHurtOutput(sHurtOutput, sizeof(sHurtOutput));
|
||||||
|
|
||||||
|
bool bHooked = false;
|
||||||
int entity = INVALID_ENT_REFERENCE;
|
int entity = INVALID_ENT_REFERENCE;
|
||||||
while((entity = FindEntityByTargetname(entity, sHurtTrigger)) != 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);
|
HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bHooked = true;
|
||||||
LogDebugMessage("Hooked hurttrigger %s:%s", sHurtTrigger, sHurtOutput);
|
LogDebugMessage("Hooked hurttrigger %s:%s", sHurtTrigger, sHurtOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!bHooked)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_Boss.bActive = true;
|
||||||
|
|
||||||
char sBoss[64];
|
char sBoss[64];
|
||||||
_Config.GetName(sBoss, sizeof(sBoss));
|
_Config.GetName(sBoss, sizeof(sBoss));
|
||||||
LogDebugMessage("Initialized boss %s (template = %d)", sBoss, iTemplateNum);
|
LogDebugMessage("Initialized boss %s (template = %d)", sBoss, iTemplateNum);
|
||||||
|
Loading…
Reference in New Issue
Block a user