BossHP: Finish second version of damage callback.

Now with extra forwards.
This commit is contained in:
zaCade 2018-10-13 14:21:51 +02:00
parent eb94163ef8
commit 7160defcaa
2 changed files with 35 additions and 19 deletions

View File

@ -5,6 +5,7 @@
#include <sdkhooks>
#include <sdktools>
#include <outputinfo>
#include <BossHP>
#include <basic>
#include "CConfig.inc"
@ -16,6 +17,8 @@ ArrayList g_aConfig;
ArrayList g_aBoss;
StringMap g_aHadOnce;
Handle g_hFwd_OnBossDamaged;
char g_sHUDText[256];
public Plugin myinfo =
@ -29,6 +32,8 @@ public Plugin myinfo =
public void OnPluginStart()
{
g_hFwd_OnBossDamaged = CreateGlobalForward("OnBossDamaged", ET_Ignore, Param_Any, Param_Cell, Param_Cell);
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
HookEntityOutput("env_entity_maker", "OnEntitySpawned", OnEnvEntityMakerEntitySpawned);
}
@ -471,8 +476,7 @@ public void OnEntitySpawned(int entity)
}
else
{
bool Once = !Config.bMultiTrigger;
HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt, Once);
HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt);
}
LogMessage("Hooked hurttrigger %s:%s", sHurtTrigger, sHurtOutput);
@ -726,7 +730,7 @@ void OnKillTrigger(int entity, const char[] output, SDKHookType HookType = view_
}
}
void OnHurtTrigger(int activator, int entity, const char[] output, SDKHookType HookType = view_as<SDKHookType>(-1))
void OnHurtTrigger(int entity, const char[] output, int activator)
{
char sTargetname[64];
GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
@ -768,21 +772,27 @@ void OnHurtTrigger(int activator, int entity, const char[] output, SDKHookType H
if(!StrEqual(output, sHurtOutput))
continue;
if(iHurtTriggerHammerID == -1)
LogMessage("Triggered hurt boss %s(%d) from output %s", sTargetname, entity, output);
else
LogMessage("Triggered hurt boss #%d(%d) from output %s", iHurtTriggerHammerID, entity, output);
// if(iHurtTriggerHammerID == -1)
// LogMessage("Triggered hurt boss %s(%d) from output %s", sTargetname, entity, output);
// else
// LogMessage("Triggered hurt boss #%d(%d) from output %s", iHurtTriggerHammerID, entity, output);
if(HookType != view_as<SDKHookType>(-1) && !Config.bMultiTrigger)
for(int j = 0; j < g_aBoss.Length; j++)
{
if(HookType == SDKHook_OnTakeDamagePost)
SDKUnhook(entity, SDKHook_OnTakeDamagePost, OnTakeDamagePostHurt);
CBoss Boss = g_aBoss.Get(j);
if(Boss.dConfig != Config)
continue;
if(Boss.iTemplateNum != iTemplateNum)
continue;
Call_StartForward(g_hFwd_OnBossDamaged);
Call_PushCell(Boss);
Call_PushCell(entity);
Call_PushCell(activator);
Call_Finish();
}
}
}
@ -830,7 +840,7 @@ public void OnEntityOutputKill(const char[] output, int caller, int activator, f
public void OnEntityOutputHurt(const char[] output, int caller, int activator, float delay)
{
OnHurtTrigger(activator, caller, output);
OnHurtTrigger(caller, output, activator);
}
public void OnTakeDamagePost(int victim, int attacker, int inflictor, float damage, int damagetype)
@ -850,7 +860,7 @@ public void OnTakeDamagePostKill(int victim, int attacker, int inflictor, float
public void OnTakeDamagePostHurt(int victim, int attacker, int inflictor, float damage, int damagetype)
{
OnHurtTrigger(attacker, victim, "OnTakeDamage", SDKHook_OnTakeDamagePost);
OnHurtTrigger(victim, "OnTakeDamage", attacker);
}
public void OnGameFrame()
@ -1219,8 +1229,7 @@ bool BossInit(CBoss _Boss)
}
else
{
bool Once = !_Config.bMultiTrigger;
HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt, Once);
HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt);
}
LogMessage("Hooked hurttrigger %s:%s", sHurtTrigger, sHurtOutput);

View File

@ -0,0 +1,7 @@
#if defined BossHP_included
#endinput
#endif
#define BossHP_included
forward void OnBossDamaged(any Boss, int entity, int activator);