BossHP_Ranking: show difference between hit- and dmg-based bosses

This commit is contained in:
neon
2018-12-29 16:06:15 +01:00
parent 41d902c0af
commit ba11285aa0
26 changed files with 122 additions and 95 deletions
+4 -3
View File
@@ -37,7 +37,7 @@ public Plugin myinfo =
public void OnPluginStart()
{
g_hFwd_OnBossInitialized = CreateGlobalForward("OnBossInitialized", ET_Ignore, Param_Any, Param_Any);
g_hFwd_OnBossDamaged = CreateGlobalForward("OnBossDamaged", ET_Ignore, Param_Any, Param_Any, Param_Cell);
g_hFwd_OnBossDamaged = CreateGlobalForward("OnBossDamaged", ET_Ignore, Param_Any, Param_Any, Param_Cell, Param_Float);
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);
@@ -763,7 +763,7 @@ void OnKillTrigger(int entity, const char[] output, SDKHookType HookType = view_
}
}
void OnHurtTrigger(int entity, const char[] output, int activator)
void OnHurtTrigger(int entity, const char[] output, int activator, float damage = 1.0)
{
char sTargetname[64];
GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
@@ -824,6 +824,7 @@ void OnHurtTrigger(int entity, const char[] output, int activator)
Call_PushCell(Boss);
Call_PushCell(Boss.dConfig);
Call_PushCell(activator);
Call_PushFloat(damage);
Call_Finish();
}
}
@@ -893,7 +894,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(victim, "OnTakeDamage", attacker);
OnHurtTrigger(victim, "OnTakeDamage", attacker, damage);
}
public void OnGameFrame()
+29 -11
View File
@@ -84,18 +84,23 @@ public void OnClientDisconnect(int client)
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnBossDamaged(any Boss, any Config, int client)
public void OnBossDamaged(any Boss, any Config, int client, float damage)
{
if (!IsValidClient(client))
return;
//int iCurrentCash = GetEntProp(client, Prop_Send, "m_iAccount");
//if (iCurrentCash < 16000)
// SetEntProp(client, Prop_Send, "m_iAccount", iCurrentCash + 1);
SetEntProp(client, Prop_Send, "m_iAccount", GetEntProp(client, Prop_Send, "m_iAccount") + 1);
bool bBreakable;
CConfig _Config = view_as<CConfig>(Config);
if (_Config.IsBreakable)
bBreakable = true;
else
bBreakable = false;
delete _Config;
for (int index = 0; index < g_hStats[client].Length; index++)
{
any BossDamage[2];
@@ -103,7 +108,10 @@ public void OnBossDamaged(any Boss, any Config, int client)
if (BossDamage[0] == Boss)
{
BossDamage[1] += 1;
if (bBreakable)
BossDamage[1] += RoundToNearest(damage);
else
BossDamage[1] += 1;
g_hStats[client].SetArray(index, BossDamage, sizeof(BossDamage));
return;
@@ -112,7 +120,11 @@ public void OnBossDamaged(any Boss, any Config, int client)
any BossDamage[2];
BossDamage[0] = Boss;
BossDamage[1] = 1;
if (bBreakable)
BossDamage[1] = RoundToNearest(damage);
else
BossDamage[1] = 1;
g_hStats[client].PushArray(BossDamage, sizeof(BossDamage));
}
@@ -178,6 +190,12 @@ public void OnBossKilled(any Boss, any Config, int reason)
char sBossName[64];
_Config.GetName(sBossName, sizeof(sBossName));
char sType[16];
if (_Config.IsBreakable)
sType = "damage"
else
sType = "hits"
delete _Config;
char sBuffer[512];
@@ -186,19 +204,19 @@ public void OnBossKilled(any Boss, any Config, int reason)
if (iSortedList[0][0])
{
Format(sBuffer, sizeof(sBuffer), "%s\n1. %N - %d hits", sBuffer, iSortedList[0][0], iSortedList[0][1]);
Format(sBuffer, sizeof(sBuffer), "%s\n1. %N - %d %s", sBuffer, iSortedList[0][0], iSortedList[0][1], sType);
LogPlayerEvent(iSortedList[0][0], "triggered", "ze_boss_damage_first");
}
if (iSortedList[1][0])
{
Format(sBuffer, sizeof(sBuffer), "%s\n2. %N - %d hits", sBuffer, iSortedList[1][0], iSortedList[1][1]);
Format(sBuffer, sizeof(sBuffer), "%s\n2. %N - %d %s", sBuffer, iSortedList[1][0], iSortedList[1][1], sType);
LogPlayerEvent(iSortedList[1][0], "triggered", "ze_boss_damage_second");
}
if (iSortedList[2][0])
{
Format(sBuffer, sizeof(sBuffer), "%s\n3. %N - %d hits", sBuffer, iSortedList[2][0], iSortedList[2][1]);
Format(sBuffer, sizeof(sBuffer), "%s\n3. %N - %d %s", sBuffer, iSortedList[2][0], iSortedList[2][1], sType);
LogPlayerEvent(iSortedList[2][0], "triggered", "ze_boss_damage_third");
}
+2 -2
View File
@@ -6,6 +6,6 @@
forward void OnBossIntialized(any Boss, any Config);
forward void OnBossDamaged(any Boss, any Config, int activator);
forward void OnBossDamaged(any Boss, any Config, int activator, float damage);
forward void OnBossKilled(any Boss, any Config, 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.