BossHP: General Kenobi cleans house.
This commit is contained in:
parent
17dfe2f334
commit
2d3c9e1966
@ -21,6 +21,8 @@ Handle g_hFwd_OnBossInitialized;
|
|||||||
Handle g_hFwd_OnBossDamaged;
|
Handle g_hFwd_OnBossDamaged;
|
||||||
Handle g_hFwd_OnBossKilled;
|
Handle g_hFwd_OnBossKilled;
|
||||||
|
|
||||||
|
ConVar g_hCvar_DebugMode;
|
||||||
|
|
||||||
char g_sHUDText[256];
|
char g_sHUDText[256];
|
||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
@ -34,14 +36,27 @@ public Plugin myinfo =
|
|||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
g_hFwd_OnBossInitialized = CreateGlobalForward("OnBossInitialized", ET_Ignore, Param_Any);
|
g_hFwd_OnBossInitialized = CreateGlobalForward("OnBossInitialized", ET_Ignore, Param_Any, Param_Any);
|
||||||
g_hFwd_OnBossDamaged = CreateGlobalForward("OnBossDamaged", ET_Ignore, Param_Any, Param_Cell, Param_Cell);
|
g_hFwd_OnBossDamaged = CreateGlobalForward("OnBossDamaged", ET_Ignore, Param_Any, Param_Any, Param_Cell);
|
||||||
g_hFwd_OnBossKilled = CreateGlobalForward("OnBossKilled", ET_Ignore, Param_Any, Param_Cell);
|
g_hFwd_OnBossKilled = CreateGlobalForward("OnBossKilled", ET_Ignore, Param_Any, Param_Any, Param_Cell);
|
||||||
|
|
||||||
|
g_hCvar_DebugMode = CreateConVar("bosshp_debug", "0", _, _, true, 0.0, true, 1.0);
|
||||||
|
|
||||||
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
|
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
|
||||||
HookEntityOutput("env_entity_maker", "OnEntitySpawned", OnEnvEntityMakerEntitySpawned);
|
HookEntityOutput("env_entity_maker", "OnEntitySpawned", OnEnvEntityMakerEntitySpawned);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogDebugMessage(const char[] message, any ...)
|
||||||
|
{
|
||||||
|
if(g_hCvar_DebugMode.BoolValue)
|
||||||
|
{
|
||||||
|
char buffer[1024];
|
||||||
|
VFormat(buffer, sizeof(buffer), message, 2);
|
||||||
|
|
||||||
|
LogMessage(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void OnPluginEnd()
|
public void OnPluginEnd()
|
||||||
{
|
{
|
||||||
Cleanup();
|
Cleanup();
|
||||||
@ -49,16 +64,6 @@ public void OnPluginEnd()
|
|||||||
|
|
||||||
void Cleanup()
|
void Cleanup()
|
||||||
{
|
{
|
||||||
if(g_aConfig)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < g_aConfig.Length; i++)
|
|
||||||
{
|
|
||||||
CConfig Config = g_aConfig.Get(i);
|
|
||||||
delete Config;
|
|
||||||
}
|
|
||||||
delete g_aConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(g_aBoss)
|
if(g_aBoss)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < g_aBoss.Length; i++)
|
for(int i = 0; i < g_aBoss.Length; i++)
|
||||||
@ -67,6 +72,7 @@ void Cleanup()
|
|||||||
|
|
||||||
Call_StartForward(g_hFwd_OnBossKilled);
|
Call_StartForward(g_hFwd_OnBossKilled);
|
||||||
Call_PushCell(Boss);
|
Call_PushCell(Boss);
|
||||||
|
Call_PushCell(Boss.dConfig);
|
||||||
Call_PushCell(0);
|
Call_PushCell(0);
|
||||||
Call_Finish();
|
Call_Finish();
|
||||||
|
|
||||||
@ -74,6 +80,16 @@ void Cleanup()
|
|||||||
}
|
}
|
||||||
delete g_aBoss;
|
delete g_aBoss;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(g_aConfig)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < g_aConfig.Length; i++)
|
||||||
|
{
|
||||||
|
CConfig Config = g_aConfig.Get(i);
|
||||||
|
delete Config;
|
||||||
|
}
|
||||||
|
delete g_aConfig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnMapEnd()
|
public void OnMapEnd()
|
||||||
@ -415,7 +431,7 @@ public void OnEntitySpawned(int entity)
|
|||||||
HookSingleEntityOutput(entity, sOutput, OnEntityOutput, Once);
|
HookSingleEntityOutput(entity, sOutput, OnEntityOutput, Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("Hooked trigger %s:%s", sTrigger, sOutput);
|
LogDebugMessage("Hooked trigger %s:%s", sTrigger, sOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
char sShowTrigger[64];
|
char sShowTrigger[64];
|
||||||
@ -440,7 +456,7 @@ public void OnEntitySpawned(int entity)
|
|||||||
HookSingleEntityOutput(entity, sShowOutput, OnEntityOutputShow, Once);
|
HookSingleEntityOutput(entity, sShowOutput, OnEntityOutputShow, Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("Hooked showtrigger %s:%s", sShowTrigger, sShowOutput);
|
LogDebugMessage("Hooked showtrigger %s:%s", sShowTrigger, sShowOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
char sKillTrigger[64];
|
char sKillTrigger[64];
|
||||||
@ -465,7 +481,7 @@ public void OnEntitySpawned(int entity)
|
|||||||
HookSingleEntityOutput(entity, sKillOutput, OnEntityOutputKill, Once);
|
HookSingleEntityOutput(entity, sKillOutput, OnEntityOutputKill, Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("Hooked killtrigger %s:%s", sKillTrigger, sKillOutput);
|
LogDebugMessage("Hooked killtrigger %s:%s", sKillTrigger, sKillOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
char sHurtTrigger[64];
|
char sHurtTrigger[64];
|
||||||
@ -489,7 +505,7 @@ public void OnEntitySpawned(int entity)
|
|||||||
HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt);
|
HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("Hooked hurttrigger %s:%s", sHurtTrigger, sHurtOutput);
|
LogDebugMessage("Hooked hurttrigger %s:%s", sHurtTrigger, sHurtOutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -573,9 +589,9 @@ void OnTrigger(int entity, const char[] output, SDKHookType HookType = view_as<S
|
|||||||
g_aHadOnce.SetValue(sTemp, true);
|
g_aHadOnce.SetValue(sTemp, true);
|
||||||
|
|
||||||
if(iTriggerHammerID == -1)
|
if(iTriggerHammerID == -1)
|
||||||
LogMessage("Triggered boss %s(%d) from output %s", sTargetname, entity, output);
|
LogDebugMessage("Triggered boss %s(%d) from output %s", sTargetname, entity, output);
|
||||||
else
|
else
|
||||||
LogMessage("Triggered boss #%d(%d) from output %s", iTriggerHammerID, entity, output);
|
LogDebugMessage("Triggered boss #%d(%d) from output %s", iTriggerHammerID, entity, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -623,9 +639,9 @@ void OnShowTrigger(int entity, const char[] output, SDKHookType HookType = view_
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(iShowTriggerHammerID == -1)
|
if(iShowTriggerHammerID == -1)
|
||||||
LogMessage("Triggered show boss %s(%d) from output %s", sTargetname, entity, output);
|
LogDebugMessage("Triggered show boss %s(%d) from output %s", sTargetname, entity, output);
|
||||||
else
|
else
|
||||||
LogMessage("Triggered show boss #%d(%d) from output %s", iShowTriggerHammerID, entity, output);
|
LogDebugMessage("Triggered show boss #%d(%d) from output %s", iShowTriggerHammerID, entity, output);
|
||||||
|
|
||||||
if(HookType != view_as<SDKHookType>(-1) && !Config.bMultiTrigger)
|
if(HookType != view_as<SDKHookType>(-1) && !Config.bMultiTrigger)
|
||||||
{
|
{
|
||||||
@ -648,12 +664,12 @@ void OnShowTrigger(int entity, const char[] output, SDKHookType HookType = view_
|
|||||||
if(fShowTriggerDelay > 0)
|
if(fShowTriggerDelay > 0)
|
||||||
{
|
{
|
||||||
Boss.fShowAt = GetGameTime() + fShowTriggerDelay;
|
Boss.fShowAt = GetGameTime() + fShowTriggerDelay;
|
||||||
LogMessage("Scheduled show(%f) boss %d", fShowTriggerDelay, j);
|
LogDebugMessage("Scheduled show(%f) boss %d", fShowTriggerDelay, j);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Boss.bShow = true;
|
Boss.bShow = true;
|
||||||
LogMessage("Showing boss %d", j);
|
LogDebugMessage("Showing boss %d", j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -702,9 +718,9 @@ void OnKillTrigger(int entity, const char[] output, SDKHookType HookType = view_
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(iKillTriggerHammerID == -1)
|
if(iKillTriggerHammerID == -1)
|
||||||
LogMessage("Triggered kill boss %s(%d) from output %s", sTargetname, entity, output);
|
LogDebugMessage("Triggered kill boss %s(%d) from output %s", sTargetname, entity, output);
|
||||||
else
|
else
|
||||||
LogMessage("Triggered kill boss #%d(%d) from output %s", iKillTriggerHammerID, entity, output);
|
LogDebugMessage("Triggered kill boss #%d(%d) from output %s", iKillTriggerHammerID, entity, output);
|
||||||
|
|
||||||
if(HookType != view_as<SDKHookType>(-1) && !Config.bMultiTrigger)
|
if(HookType != view_as<SDKHookType>(-1) && !Config.bMultiTrigger)
|
||||||
{
|
{
|
||||||
@ -727,14 +743,15 @@ void OnKillTrigger(int entity, const char[] output, SDKHookType HookType = view_
|
|||||||
if(fKillTriggerDelay > 0)
|
if(fKillTriggerDelay > 0)
|
||||||
{
|
{
|
||||||
Boss.fKillAt = GetGameTime() + fKillTriggerDelay;
|
Boss.fKillAt = GetGameTime() + fKillTriggerDelay;
|
||||||
LogMessage("Scheduled kill(%f) boss %d", fKillTriggerDelay, j);
|
LogDebugMessage("Scheduled kill(%f) boss %d", fKillTriggerDelay, j);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogMessage("Killed boss %d", j);
|
LogDebugMessage("Killed boss %d", j);
|
||||||
|
|
||||||
Call_StartForward(g_hFwd_OnBossKilled);
|
Call_StartForward(g_hFwd_OnBossKilled);
|
||||||
Call_PushCell(Boss);
|
Call_PushCell(Boss);
|
||||||
|
Call_PushCell(Boss.dConfig);
|
||||||
Call_PushCell(1);
|
Call_PushCell(1);
|
||||||
Call_Finish();
|
Call_Finish();
|
||||||
|
|
||||||
@ -788,10 +805,10 @@ void OnHurtTrigger(int entity, const char[] output, int activator)
|
|||||||
if(!StrEqual(output, sHurtOutput))
|
if(!StrEqual(output, sHurtOutput))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// if(iHurtTriggerHammerID == -1)
|
if(iHurtTriggerHammerID == -1)
|
||||||
// LogMessage("Triggered hurt boss %s(%d) from output %s", sTargetname, entity, output);
|
LogDebugMessage("Triggered hurt boss %s(%d) from output %s", sTargetname, entity, output);
|
||||||
// else
|
else
|
||||||
// LogMessage("Triggered hurt boss #%d(%d) from output %s", iHurtTriggerHammerID, entity, output);
|
LogDebugMessage("Triggered hurt boss #%d(%d) from output %s", iHurtTriggerHammerID, entity, output);
|
||||||
|
|
||||||
for(int j = 0; j < g_aBoss.Length; j++)
|
for(int j = 0; j < g_aBoss.Length; j++)
|
||||||
{
|
{
|
||||||
@ -805,6 +822,7 @@ void OnHurtTrigger(int entity, const char[] output, int activator)
|
|||||||
|
|
||||||
Call_StartForward(g_hFwd_OnBossDamaged);
|
Call_StartForward(g_hFwd_OnBossDamaged);
|
||||||
Call_PushCell(Boss);
|
Call_PushCell(Boss);
|
||||||
|
Call_PushCell(Boss.dConfig);
|
||||||
Call_PushCell(activator);
|
Call_PushCell(activator);
|
||||||
Call_Finish();
|
Call_Finish();
|
||||||
}
|
}
|
||||||
@ -892,10 +910,11 @@ public void OnGameFrame()
|
|||||||
|
|
||||||
if(Boss.fKillAt && Boss.fKillAt < GetGameTime())
|
if(Boss.fKillAt && Boss.fKillAt < GetGameTime())
|
||||||
{ // Delete Boss
|
{ // Delete Boss
|
||||||
LogMessage("Deleting boss %d (KillAt)", i);
|
LogDebugMessage("Deleting boss %d (KillAt)", i);
|
||||||
|
|
||||||
Call_StartForward(g_hFwd_OnBossKilled);
|
Call_StartForward(g_hFwd_OnBossKilled);
|
||||||
Call_PushCell(Boss);
|
Call_PushCell(Boss);
|
||||||
|
Call_PushCell(Boss.dConfig);
|
||||||
Call_PushCell(1);
|
Call_PushCell(1);
|
||||||
Call_Finish();
|
Call_Finish();
|
||||||
|
|
||||||
@ -921,10 +940,11 @@ public void OnGameFrame()
|
|||||||
|
|
||||||
if(!BossProcess(Boss))
|
if(!BossProcess(Boss))
|
||||||
{ // Delete Boss
|
{ // Delete Boss
|
||||||
LogMessage("Deleting boss %d (dead)", i);
|
LogDebugMessage("Deleting boss %d (dead)", i);
|
||||||
|
|
||||||
Call_StartForward(g_hFwd_OnBossKilled);
|
Call_StartForward(g_hFwd_OnBossKilled);
|
||||||
Call_PushCell(Boss);
|
Call_PushCell(Boss);
|
||||||
|
Call_PushCell(Boss.dConfig);
|
||||||
Call_PushCell(2);
|
Call_PushCell(2);
|
||||||
Call_Finish();
|
Call_Finish();
|
||||||
|
|
||||||
@ -1207,7 +1227,7 @@ bool BossInit(CBoss _Boss)
|
|||||||
HookSingleEntityOutput(entity, sShowOutput, OnEntityOutputShow, Once);
|
HookSingleEntityOutput(entity, sShowOutput, OnEntityOutputShow, Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("Hooked showtrigger %s:%s", sShowTrigger, sShowOutput);
|
LogDebugMessage("Hooked showtrigger %s:%s", sShowTrigger, sShowOutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1234,7 +1254,7 @@ bool BossInit(CBoss _Boss)
|
|||||||
HookSingleEntityOutput(entity, sKillOutput, OnEntityOutputKill, Once);
|
HookSingleEntityOutput(entity, sKillOutput, OnEntityOutputKill, Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("Hooked killtrigger %s:%s", sKillTrigger, sKillOutput);
|
LogDebugMessage("Hooked killtrigger %s:%s", sKillTrigger, sKillOutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1260,17 +1280,18 @@ bool BossInit(CBoss _Boss)
|
|||||||
HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt);
|
HookSingleEntityOutput(entity, sHurtOutput, OnEntityOutputHurt);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("Hooked hurttrigger %s:%s", sHurtTrigger, sHurtOutput);
|
LogDebugMessage("Hooked hurttrigger %s:%s", sHurtTrigger, sHurtOutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char sBoss[64];
|
char sBoss[64];
|
||||||
_Config.GetName(sBoss, sizeof(sBoss));
|
_Config.GetName(sBoss, sizeof(sBoss));
|
||||||
LogMessage("Initialized boss %s (template = %d)", sBoss, iTemplateNum);
|
LogDebugMessage("Initialized boss %s (template = %d)", sBoss, iTemplateNum);
|
||||||
|
|
||||||
Call_StartForward(g_hFwd_OnBossInitialized);
|
Call_StartForward(g_hFwd_OnBossInitialized);
|
||||||
Call_PushCell(_Boss);
|
Call_PushCell(_Boss);
|
||||||
|
Call_PushCell(_Boss.dConfig);
|
||||||
Call_Finish();
|
Call_Finish();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -7,9 +7,6 @@
|
|||||||
|
|
||||||
ArrayList g_hStats[MAXPLAYERS+1];
|
ArrayList g_hStats[MAXPLAYERS+1];
|
||||||
|
|
||||||
|
|
||||||
bool g_bLoadedLate;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
@ -21,30 +18,17 @@ public Plugin myinfo =
|
|||||||
version = "1.0.0",
|
version = "1.0.0",
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
|
||||||
// Purpose:
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
|
||||||
public APLRes AskPluginLoad2(Handle hThis, bool bLate, char[] err, int iErrLen)
|
|
||||||
{
|
|
||||||
g_bLoadedLate = bLate;
|
|
||||||
|
|
||||||
return APLRes_Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
if (g_bLoadedLate)
|
for (int client = 1; client <= MaxClients; client++)
|
||||||
{
|
{
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
if (!IsClientInGame(client))
|
||||||
{
|
continue;
|
||||||
if (!IsClientInGame(i) || IsFakeClient(i))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
OnClientPutInServer(i);
|
OnClientPutInServer(client);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +51,7 @@ public void OnClientDisconnect(int client)
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void OnBossDamaged(any Boss, int client)
|
public void OnBossDamaged(any Boss, any Config, int client)
|
||||||
{
|
{
|
||||||
if (!IsValidClient(client))
|
if (!IsValidClient(client))
|
||||||
return;
|
return;
|
||||||
@ -96,7 +80,7 @@ public void OnBossDamaged(any Boss, int client)
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void OnBossKilled(any Boss, int reason)
|
public void OnBossKilled(any Boss, any Config, int reason)
|
||||||
{
|
{
|
||||||
if (reason != 2)
|
if (reason != 2)
|
||||||
{
|
{
|
||||||
@ -149,11 +133,12 @@ public void OnBossKilled(any Boss, int reason)
|
|||||||
|
|
||||||
if (iSortedCount)
|
if (iSortedCount)
|
||||||
{
|
{
|
||||||
|
CConfig _Config = view_as<CConfig>(Config);
|
||||||
|
|
||||||
char sBossName[64];
|
char sBossName[64];
|
||||||
CBoss _Boss = view_as<CBoss>(Boss);
|
_Config.GetName(sBossName, sizeof(sBossName));
|
||||||
CConfig Config = _Boss.dConfig;
|
|
||||||
Config.GetName(sBossName, sizeof(sBossName))
|
delete _Config;
|
||||||
delete Config;
|
|
||||||
|
|
||||||
char sBuffer[512];
|
char sBuffer[512];
|
||||||
Format(sBuffer, sizeof(sBuffer), "BOSS DAMAGE [%s]:", sBossName);
|
Format(sBuffer, sizeof(sBuffer), "BOSS DAMAGE [%s]:", sBossName);
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#define BossHP_included
|
#define BossHP_included
|
||||||
|
|
||||||
forward void OnBossIntialized(any Boss);
|
forward void OnBossIntialized(any Boss, any Config);
|
||||||
|
|
||||||
forward void OnBossDamaged(any Boss, int activator);
|
forward void OnBossDamaged(any Boss, any Config, int activator);
|
||||||
|
|
||||||
forward void OnBossKilled(any Boss, int reason); //reason: 0 = RoundEnd/MapEnd, 1 = KillTrigger, 2 = Death.
|
forward void OnBossKilled(any Boss, any Config, int reason); //reason: 0 = RoundEnd/MapEnd, 1 = KillTrigger, 2 = Death.
|
||||||
|
Loading…
Reference in New Issue
Block a user