BossHP: improve last commits, untested
This commit is contained in:
parent
127f434faf
commit
52ca028b59
@ -398,6 +398,10 @@ public void OnEntitySpawned(int entity, const char[] classname)
|
|||||||
char sTargetname[64];
|
char sTargetname[64];
|
||||||
GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
|
GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
|
||||||
|
|
||||||
|
int iTemplateLoc = FindCharInString(sTargetname, '&', true);
|
||||||
|
if(iTemplateLoc != -1)
|
||||||
|
return;
|
||||||
|
|
||||||
int iHammerID = GetEntProp(entity, Prop_Data, "m_iHammerID");
|
int iHammerID = GetEntProp(entity, Prop_Data, "m_iHammerID");
|
||||||
|
|
||||||
for(int i = 0; i < g_aConfig.Length; i++)
|
for(int i = 0; i < g_aConfig.Length; i++)
|
||||||
@ -428,6 +432,74 @@ public void OnEntitySpawned(int entity, const char[] classname)
|
|||||||
|
|
||||||
LogDebugMessage("Hooked trigger %s:%s", sTrigger, sOutput);
|
LogDebugMessage("Hooked trigger %s:%s", sTrigger, sOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char sKillTrigger[64];
|
||||||
|
Config.GetKillTrigger(sKillTrigger, sizeof(sKillTrigger));
|
||||||
|
|
||||||
|
int iKillTriggerHammerID = -1;
|
||||||
|
if(sKillTrigger[0] == '#')
|
||||||
|
iKillTriggerHammerID = StringToInt(sKillTrigger[1]);
|
||||||
|
|
||||||
|
if((iKillTriggerHammerID == -1 && sKillTrigger[0] && StrEqual(sTargetname, sKillTrigger)) || iKillTriggerHammerID == iHammerID)
|
||||||
|
{
|
||||||
|
char sKillOutput[64];
|
||||||
|
Config.GetKillOutput(sKillOutput, sizeof(sKillOutput));
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
char sHurtTrigger[64];
|
||||||
|
Config.GetHurtTrigger(sHurtTrigger, sizeof(sHurtTrigger));
|
||||||
|
|
||||||
|
int iHurtTriggerHammerID = -1;
|
||||||
|
if(sHurtTrigger[0] == '#')
|
||||||
|
iHurtTriggerHammerID = StringToInt(sHurtTrigger[1]);
|
||||||
|
|
||||||
|
if((iHurtTriggerHammerID == -1 && sHurtTrigger[0] && StrEqual(sTargetname, sHurtTrigger)) || iHurtTriggerHammerID == iHammerID)
|
||||||
|
{
|
||||||
|
char sHurtOutput[64];
|
||||||
|
Config.GetHurtOutput(sHurtOutput, sizeof(sHurtOutput));
|
||||||
|
|
||||||
|
for(int j = 0; j < g_aBoss.Length; j++)
|
||||||
|
{
|
||||||
|
CBoss Boss = g_aBoss.Get(j);
|
||||||
|
|
||||||
|
if(Boss.dConfig != Config)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
g_aHurtEntityToBossIdx[entity] = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(g_aHurtEntityToBossIdx[entity] == 0xFF)
|
||||||
|
{
|
||||||
|
char sBoss[64];
|
||||||
|
Config.GetName(sBoss, sizeof(sBoss));
|
||||||
|
LogError("ERROR Hooking hurttrigger %s:%s!!! Boss = %s", sHurtTrigger, sHurtOutput, sBoss);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StrEqual(sHurtOutput, "OnTakeDamage"))
|
||||||
|
{
|
||||||
|
SDKHook(entity, SDKHook_OnTakeDamagePost, OnTakeDamagePostHurt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt);
|
||||||
|
}
|
||||||
|
|
||||||
|
LogDebugMessage("Hooked hurttrigger %s:%s (iBoss %d)", sHurtTrigger, sHurtOutput, g_aHurtEntityToBossIdx[entity]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1136,101 +1208,77 @@ bool BossInit(int iBoss, CBoss _Boss)
|
|||||||
if(sShowTrigger[0])
|
if(sShowTrigger[0])
|
||||||
{
|
{
|
||||||
Format(sShowTrigger, sizeof(sShowTrigger), "%s&%04d", sShowTrigger, iTemplateNum);
|
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])
|
if(sKillTrigger[0])
|
||||||
{
|
{
|
||||||
Format(sKillTrigger, sizeof(sKillTrigger), "%s&%04d", sKillTrigger, iTemplateNum);
|
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])
|
if(sHurtTrigger[0])
|
||||||
{
|
{
|
||||||
Format(sHurtTrigger, sizeof(sHurtTrigger), "%s&%04d", sHurtTrigger, iTemplateNum);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sShowTrigger[0])
|
|
||||||
{
|
|
||||||
char sShowOutput[64];
|
|
||||||
_Config.GetShowOutput(sShowOutput, sizeof(sShowOutput));
|
|
||||||
|
|
||||||
bool bHooked = false;
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
bHooked = true;
|
|
||||||
LogDebugMessage("Hooked showtrigger %s:%s", sShowTrigger, sShowOutput);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!bHooked)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sKillTrigger[0])
|
|
||||||
{
|
|
||||||
char sKillOutput[64];
|
|
||||||
_Config.GetKillOutput(sKillOutput, sizeof(sKillOutput));
|
|
||||||
|
|
||||||
bool bHooked = false;
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
bHooked = true;
|
|
||||||
LogDebugMessage("Hooked killtrigger %s:%s", sKillTrigger, sKillOutput);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!bHooked)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sHurtTrigger[0])
|
|
||||||
{
|
|
||||||
char sHurtOutput[64];
|
|
||||||
_Config.GetHurtOutput(sHurtOutput, sizeof(sHurtOutput));
|
|
||||||
|
|
||||||
bool bHooked = false;
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
bHooked = true;
|
|
||||||
LogDebugMessage("Hooked hurttrigger %s:%s", sHurtTrigger, sHurtOutput);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!bHooked)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_Boss.bActive = true;
|
_Boss.bActive = true;
|
||||||
|
|
||||||
char sBoss[64];
|
char sBoss[64];
|
||||||
|
Loading…
Reference in New Issue
Block a user