BossHP: fix everything?
This commit is contained in:
parent
d8d5eb3128
commit
31f8571e8d
@ -21,7 +21,6 @@ ConVar g_hCvar_DebugMode;
|
||||
|
||||
char g_sHUDText[256];
|
||||
|
||||
bool g_bProcessNewEntities = false;
|
||||
char g_aHurtEntityToBossIdx[2048] = {0xFF, ...};
|
||||
|
||||
public Plugin myinfo =
|
||||
@ -393,8 +392,6 @@ 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));
|
||||
|
||||
@ -470,6 +467,7 @@ public void OnEntitySpawned(int entity, const char[] classname)
|
||||
char sHurtOutput[64];
|
||||
Config.GetHurtOutput(sHurtOutput, sizeof(sHurtOutput));
|
||||
|
||||
int iBoss = -1;
|
||||
for(int j = 0; j < g_aBoss.Length; j++)
|
||||
{
|
||||
CBoss Boss = g_aBoss.Get(j);
|
||||
@ -477,18 +475,20 @@ public void OnEntitySpawned(int entity, const char[] classname)
|
||||
if(Boss.dConfig != Config)
|
||||
continue;
|
||||
|
||||
g_aHurtEntityToBossIdx[entity] = j;
|
||||
iBoss = j;
|
||||
break;
|
||||
}
|
||||
|
||||
if(g_aHurtEntityToBossIdx[entity] == 0xFF)
|
||||
if(iBoss == -1)
|
||||
{
|
||||
char sBoss[64];
|
||||
Config.GetName(sBoss, sizeof(sBoss));
|
||||
LogError("ERROR Hooking hurttrigger %s:%s!!! Boss = %s", sHurtTrigger, sHurtOutput, sBoss);
|
||||
return;
|
||||
LogDebugMessage("Couldn't find boss \"%s\" for hurttrigger %s:%s", sBoss, sHurtTrigger, sHurtOutput);
|
||||
continue;
|
||||
}
|
||||
|
||||
g_aHurtEntityToBossIdx[entity] = iBoss;
|
||||
|
||||
if(StrEqual(sHurtOutput, "OnTakeDamage"))
|
||||
{
|
||||
SDKHook(entity, SDKHook_OnTakeDamagePost, OnTakeDamagePostHurt);
|
||||
@ -498,7 +498,7 @@ public void OnEntitySpawned(int entity, const char[] classname)
|
||||
HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt);
|
||||
}
|
||||
|
||||
LogDebugMessage("Hooked hurttrigger %s:%s (iBoss %d)", sHurtTrigger, sHurtOutput, g_aHurtEntityToBossIdx[entity]);
|
||||
LogDebugMessage("Hooked hurttrigger %s:%s (iBoss %d)", sHurtTrigger, sHurtOutput, iBoss);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -879,18 +879,13 @@ 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;
|
||||
}
|
||||
@ -949,8 +944,6 @@ public void OnGameFrame()
|
||||
s_bLastHudPrinted = false;
|
||||
}
|
||||
}
|
||||
|
||||
g_bProcessNewEntities = false;
|
||||
}
|
||||
|
||||
bool BossInit(int iBoss, CBoss _Boss)
|
||||
@ -1208,74 +1201,85 @@ bool BossInit(int iBoss, CBoss _Boss)
|
||||
if(sShowTrigger[0])
|
||||
{
|
||||
Format(sShowTrigger, sizeof(sShowTrigger), "%s&%04d", sShowTrigger, iTemplateNum);
|
||||
|
||||
char sShowOutput[64];
|
||||
_Config.GetShowOutput(sShowOutput, sizeof(sShowOutput));
|
||||
|
||||
int entity = INVALID_ENT_REFERENCE;
|
||||
while((entity = FindEntityByTargetname(entity, sShowTrigger)) != INVALID_ENT_REFERENCE)
|
||||
{
|
||||
if(StrEqual(sShowOutput, "OnTakeDamage"))
|
||||
{
|
||||
SDKHook(entity, SDKHook_OnTakeDamagePost, OnTakeDamagePostShow);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool Once = !_Config.bMultiTrigger;
|
||||
HookSingleEntityOutput(entity, sShowOutput, OnEntityOutputShow, Once);
|
||||
}
|
||||
|
||||
LogDebugMessage("Hooked showtrigger %s:%s", sShowTrigger, sShowOutput);
|
||||
}
|
||||
}
|
||||
|
||||
if(sKillTrigger[0])
|
||||
{
|
||||
Format(sKillTrigger, sizeof(sKillTrigger), "%s&%04d", sKillTrigger, iTemplateNum);
|
||||
|
||||
char sKillOutput[64];
|
||||
_Config.GetKillOutput(sKillOutput, sizeof(sKillOutput));
|
||||
|
||||
int entity = INVALID_ENT_REFERENCE;
|
||||
while((entity = FindEntityByTargetname(entity, sKillTrigger)) != INVALID_ENT_REFERENCE)
|
||||
{
|
||||
if(StrEqual(sKillOutput, "OnTakeDamage"))
|
||||
{
|
||||
SDKHook(entity, SDKHook_OnTakeDamagePost, OnTakeDamagePostKill);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool Once = !_Config.bMultiTrigger;
|
||||
HookSingleEntityOutput(entity, sKillOutput, OnEntityOutputKill, Once);
|
||||
}
|
||||
|
||||
LogDebugMessage("Hooked killtrigger %s:%s", sKillTrigger, sKillOutput);
|
||||
}
|
||||
}
|
||||
|
||||
if(sHurtTrigger[0])
|
||||
{
|
||||
Format(sHurtTrigger, sizeof(sHurtTrigger), "%s&%04d", sHurtTrigger, iTemplateNum);
|
||||
}
|
||||
}
|
||||
|
||||
char sHurtOutput[64];
|
||||
_Config.GetHurtOutput(sHurtOutput, sizeof(sHurtOutput));
|
||||
if(sShowTrigger[0])
|
||||
{
|
||||
char sShowOutput[64];
|
||||
_Config.GetShowOutput(sShowOutput, sizeof(sShowOutput));
|
||||
|
||||
int entity = INVALID_ENT_REFERENCE;
|
||||
while((entity = FindEntityByTargetname(entity, sHurtTrigger)) != INVALID_ENT_REFERENCE)
|
||||
int entity = INVALID_ENT_REFERENCE;
|
||||
while((entity = FindEntityByTargetname(entity, sShowTrigger)) != INVALID_ENT_REFERENCE)
|
||||
{
|
||||
if(StrEqual(sShowOutput, "OnTakeDamage"))
|
||||
{
|
||||
g_aHurtEntityToBossIdx[entity] = iBoss;
|
||||
|
||||
if(StrEqual(sHurtOutput, "OnTakeDamage"))
|
||||
{
|
||||
SDKHook(entity, SDKHook_OnTakeDamagePost, OnTakeDamagePostHurt);
|
||||
}
|
||||
else
|
||||
{
|
||||
HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt);
|
||||
}
|
||||
|
||||
LogDebugMessage("Hooked hurttrigger %s:%s", sHurtTrigger, sHurtOutput);
|
||||
SDKHook(entity, SDKHook_OnTakeDamagePost, OnTakeDamagePostShow);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool Once = !_Config.bMultiTrigger;
|
||||
HookSingleEntityOutput(entity, sShowOutput, OnEntityOutputShow, Once);
|
||||
}
|
||||
|
||||
LogDebugMessage("Hooked showtrigger %s:%s", sShowTrigger, sShowOutput);
|
||||
}
|
||||
}
|
||||
|
||||
if(sKillTrigger[0])
|
||||
{
|
||||
char sKillOutput[64];
|
||||
_Config.GetKillOutput(sKillOutput, sizeof(sKillOutput));
|
||||
|
||||
int entity = INVALID_ENT_REFERENCE;
|
||||
while((entity = FindEntityByTargetname(entity, sKillTrigger)) != INVALID_ENT_REFERENCE)
|
||||
{
|
||||
if(StrEqual(sKillOutput, "OnTakeDamage"))
|
||||
{
|
||||
SDKHook(entity, SDKHook_OnTakeDamagePost, OnTakeDamagePostKill);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool Once = !_Config.bMultiTrigger;
|
||||
HookSingleEntityOutput(entity, sKillOutput, OnEntityOutputKill, Once);
|
||||
}
|
||||
|
||||
LogDebugMessage("Hooked killtrigger %s:%s", sKillTrigger, sKillOutput);
|
||||
}
|
||||
}
|
||||
|
||||
if(sHurtTrigger[0])
|
||||
{
|
||||
Format(sHurtTrigger, sizeof(sHurtTrigger), "%s&%04d", sHurtTrigger, iTemplateNum);
|
||||
|
||||
char sHurtOutput[64];
|
||||
_Config.GetHurtOutput(sHurtOutput, sizeof(sHurtOutput));
|
||||
|
||||
int entity = INVALID_ENT_REFERENCE;
|
||||
while((entity = FindEntityByTargetname(entity, sHurtTrigger)) != INVALID_ENT_REFERENCE)
|
||||
{
|
||||
g_aHurtEntityToBossIdx[entity] = iBoss;
|
||||
|
||||
if(StrEqual(sHurtOutput, "OnTakeDamage"))
|
||||
{
|
||||
SDKHook(entity, SDKHook_OnTakeDamagePost, OnTakeDamagePostHurt);
|
||||
}
|
||||
else
|
||||
{
|
||||
HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt);
|
||||
}
|
||||
|
||||
LogDebugMessage("Hooked hurttrigger %s:%s", sHurtTrigger, sHurtOutput);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user