Cleanup Required

This commit is contained in:
zaCade
2019-03-03 12:40:16 +01:00
parent 997d1ec0e6
commit 57e860f5cb
179 changed files with 20 additions and 20 deletions
File diff suppressed because it is too large Load Diff
-343
View File
@@ -1,343 +0,0 @@
#include <sourcemod>
#include <BossHP>
#include <zombiereloaded>
#include "loghelper.inc"
#include <basic>
#include "CConfig.inc"
#include "CBoss.inc"
ArrayList g_hStats[MAXPLAYERS+1];
bool g_bZRLoaded;
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = "BossHP - Ranking",
author = "Neon & zaCade",
description = "",
version = "1.0.0",
};
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart()
{
HookEvent("player_death", EventHook_PlayerDeath, EventHookMode_Pre);
for (int client = 1; client <= MaxClients; client++)
{
if (!IsClientInGame(client))
continue;
OnClientPutInServer(client);
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnAllPluginsLoaded()
{
g_bZRLoaded = LibraryExists("zombiereloaded");
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnLibraryAdded(const char[] sName)
{
if (strcmp(sName, "zombiereloaded", false) == 0)
g_bZRLoaded = true;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnLibraryRemoved(const char[] sName)
{
if (strcmp(sName, "zombiereloaded", false) == 0)
g_bZRLoaded = false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientPutInServer(int client)
{
g_hStats[client] = new ArrayList(64);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientDisconnect(int client)
{
delete g_hStats[client];
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnBossDamaged(any Boss, any Config, int client, float damage)
{
if (!IsValidClient(client))
return;
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];
g_hStats[client].GetArray(index, BossDamage, sizeof(BossDamage));
if (BossDamage[0] == Boss)
{
if (bBreakable)
BossDamage[1] += RoundToNearest(damage);
else
BossDamage[1] += 1;
g_hStats[client].SetArray(index, BossDamage, sizeof(BossDamage));
return;
}
}
any BossDamage[2];
BossDamage[0] = Boss;
if (bBreakable)
BossDamage[1] = RoundToNearest(damage);
else
BossDamage[1] = 1;
g_hStats[client].PushArray(BossDamage, sizeof(BossDamage));
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnBossKilled(any Boss, any Config, int reason)
{
if (reason == 0)
{
for (int client = 1; client <= MaxClients; client++)
{
if (!IsClientInGame(client))
continue;
for (int index = 0; index < g_hStats[client].Length; index++)
{
any BossDamage[2];
g_hStats[client].GetArray(index, BossDamage, sizeof(BossDamage));
if (BossDamage[0] == Boss)
{
g_hStats[client].Erase(index);
break;
}
}
}
}
else
{
int iSortedList[MAXPLAYERS+1][2];
int iSortedCount;
for (int client = 1; client <= MaxClients; client++)
{
if (!IsClientInGame(client))
continue;
for (int index = 0; index < g_hStats[client].Length; index++)
{
any BossDamage[2];
g_hStats[client].GetArray(index, BossDamage, sizeof(BossDamage));
if (BossDamage[0] == Boss)
{
iSortedList[iSortedCount][0] = client;
iSortedList[iSortedCount][1] = BossDamage[1];
iSortedCount++;
g_hStats[client].Erase(index);
break;
}
}
}
SortCustom2D(iSortedList, iSortedCount, SortBossHitsList);
if (iSortedCount)
{
CConfig _Config = view_as<CConfig>(Config);
char sBossName[64];
_Config.GetName(sBossName, sizeof(sBossName));
char sBuffer[512];
char sType[16];
if (_Config.IsBreakable)
{
sType = "damage"
Format(sBuffer, sizeof(sBuffer), "BOSS DAMAGE [%s]:", sBossName);
}
else
{
sType = "hits"
Format(sBuffer, sizeof(sBuffer), "BOSS HITS [%s]:", sBossName);
}
delete _Config;
Format(sBuffer, sizeof(sBuffer), "%s\n*************************", sBuffer);
if (iSortedList[0][0])
{
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 %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 %s", sBuffer, iSortedList[2][0], iSortedList[2][1], sType);
LogPlayerEvent(iSortedList[2][0], "triggered", "ze_boss_damage_third");
}
Format(sBuffer, sizeof(sBuffer), "%s\n*************************", sBuffer);
Handle hMessage = StartMessageAll("HudMsg");
if (hMessage)
{
if (GetUserMessageType() == UM_Protobuf)
{
PbSetInt(hMessage, "channel", 50);
PbSetInt(hMessage, "effect", 0);
PbSetColor(hMessage, "clr1", {255, 255, 255, 255});
PbSetColor(hMessage, "clr2", {255, 255, 255, 255});
PbSetVector2D(hMessage, "pos", Float:{0.02, 0.45});
PbSetFloat(hMessage, "fade_in_time", 0.1);
PbSetFloat(hMessage, "fade_out_time", 0.1);
PbSetFloat(hMessage, "hold_time", 7.0);
PbSetFloat(hMessage, "fx_time", 0.0);
PbSetString(hMessage, "text", sBuffer);
EndMessage();
}
else
{
BfWriteByte(hMessage, 50);
BfWriteFloat(hMessage, 0.02);
BfWriteFloat(hMessage, 0.25);
BfWriteByte(hMessage, 255);
BfWriteByte(hMessage, 255);
BfWriteByte(hMessage, 0);
BfWriteByte(hMessage, 255);
BfWriteByte(hMessage, 255);
BfWriteByte(hMessage, 255);
BfWriteByte(hMessage, 255);
BfWriteByte(hMessage, 255);
BfWriteByte(hMessage, 0);
BfWriteFloat(hMessage, 0.1);
BfWriteFloat(hMessage, 0.1);
BfWriteFloat(hMessage, 7.0);
BfWriteFloat(hMessage, 0.0);
BfWriteString(hMessage, sBuffer);
EndMessage();
}
}
if(GetEngineVersion() == Engine_CSGO)
{
int iSplits
char sSplits[16][512];
if((iSplits = ExplodeString(sBuffer, "\n", sSplits, sizeof(sSplits), sizeof(sSplits[]))) != 0)
{
for (int iSplit; iSplit < iSplits; iSplit++)
{
PrintToChatAll(sSplits[iSplit]);
}
}
}
else
PrintToChatAll(sBuffer);
}
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action EventHook_PlayerDeath(Event hEvent, const char[] sEventName, bool bDontBroadcast)
{
if (!g_bZRLoaded)
return Plugin_Continue;
int iClient = GetClientOfUserId(hEvent.GetInt("userid"));
if (!IsValidClient(iClient))
return Plugin_Continue;
if (IsPlayerAlive(iClient) && !ZR_IsClientHuman(iClient))
return Plugin_Continue;
int iPacked = (iClient<<16) | (GetEntProp(iClient, Prop_Send, "m_iAccount")&0xFFFF);
RequestFrame(RequestFrame_Callback, iPacked);
return Plugin_Continue;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
void RequestFrame_Callback(int iPacked)
{
int iOldCash = iPacked&0xFFFF;
int iClient = iPacked>>16;
SetEntProp(iClient, Prop_Send, "m_iAccount", iOldCash);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public int SortBossHitsList(int[] elem1, int[] elem2, const int[][] array, Handle hndl)
{
if (elem1[1] > elem2[1]) return -1;
if (elem1[1] < elem2[1]) return 1;
return 0;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock int IsValidClient(int client, bool nobots = true)
{
if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
return false;
return IsClientInGame(client);
}
-271
View File
@@ -1,271 +0,0 @@
#if defined _class_cboss_
#endinput
#endif
#define _class_cboss_
methodmap CBoss < Basic
{
public CBoss()
{
Basic myclass = new Basic();
myclass.SetHandle("dConfig", INVALID_HANDLE);
myclass.SetBool("bActive", false);
myclass.SetBool("bShow", true);
myclass.SetInt("iTemplateNum", -1);
myclass.SetInt("iHealth", 0);
myclass.SetInt("iLastChange", 0);
myclass.SetFloat("fWaitUntil", 0.0);
myclass.SetFloat("fShowAt", 0.0);
myclass.SetFloat("fKillAt", 0.0);
return view_as<CBoss>(myclass);
}
property CConfig dConfig
{
public get()
{
return view_as<CConfig>(this.GetHandle("dConfig"));
}
public set(CConfig value)
{
this.SetHandle("dConfig", value);
}
}
property bool bActive
{
public get()
{
return this.GetBool("bActive");
}
public set(bool value)
{
this.SetBool("bActive", value);
}
}
property bool bShow
{
public get()
{
return this.GetBool("bShow");
}
public set(bool value)
{
this.SetBool("bShow", value);
}
}
property int iTemplateNum
{
public get()
{
return this.GetInt("iTemplateNum");
}
public set(int value)
{
this.SetInt("iTemplateNum", value);
}
}
property int iHealth
{
public get()
{
return this.GetInt("iHealth");
}
public set(int value)
{
this.SetInt("iHealth", value);
}
}
property int iLastChange
{
public get()
{
return this.GetInt("iLastChange");
}
public set(int value)
{
this.SetInt("iLastChange", value);
}
}
property float fWaitUntil
{
public get()
{
return this.GetFloat("fWaitUntil");
}
public set(float value)
{
this.SetFloat("fWaitUntil", value);
}
}
property float fShowAt
{
public get()
{
return this.GetFloat("fShowAt");
}
public set(float value)
{
this.SetFloat("fShowAt", value);
}
}
property float fKillAt
{
public get()
{
return this.GetFloat("fKillAt");
}
public set(float value)
{
this.SetFloat("fKillAt", value);
}
}
property bool IsBreakable {
public get() {
return this.dConfig.IsBreakable;
}
}
property bool IsCounter {
public get() {
return this.dConfig.IsCounter;
}
}
property bool IsHPBar {
public get() {
return this.dConfig.IsHPBar;
}
}
}
methodmap CBossBreakable < CBoss
{
public CBossBreakable()
{
CBoss myclass = new CBoss();
myclass.SetInt("iBreakableEnt", INVALID_ENT_REFERENCE);
return view_as<CBossBreakable>(myclass);
}
property int iBreakableEnt
{
public get()
{
return this.GetInt("iBreakableEnt");
}
public set(int value)
{
this.SetInt("iBreakableEnt", value);
}
}
property CConfigBreakable Config
{
public get()
{
return view_as<CConfigBreakable>(this.dConfig);
}
public set(CConfigBreakable value)
{
this.dConfig = value;
}
}
}
methodmap CBossCounter < CBoss
{
public CBossCounter()
{
CBoss myclass = new CBoss();
myclass.SetInt("iCounterEnt", INVALID_ENT_REFERENCE);
return view_as<CBossCounter>(myclass);
}
property int iCounterEnt
{
public get()
{
return this.GetInt("iCounterEnt");
}
public set(int value)
{
this.SetInt("iCounterEnt", value);
}
}
property CConfigCounter Config
{
public get()
{
return view_as<CConfigCounter>(this.dConfig);
}
public set(CConfigCounter value)
{
this.dConfig = value;
}
}
}
methodmap CBossHPBar < CBossCounter
{
public CBossHPBar()
{
CBoss myclass = new CBossCounter();
myclass.SetInt("iIteratorEnt", INVALID_ENT_REFERENCE);
myclass.SetInt("iBackupEnt", INVALID_ENT_REFERENCE);
return view_as<CBossHPBar>(myclass);
}
property int iIteratorEnt
{
public get()
{
return this.GetInt("iIteratorEnt");
}
public set(int value)
{
this.SetInt("iIteratorEnt", value);
}
}
property int iBackupEnt
{
public get()
{
return this.GetInt("iBackupEnt");
}
public set(int value)
{
this.SetInt("iBackupEnt", value);
}
}
property CConfigHPBar Config
{
public get()
{
return view_as<CConfigHPBar>(this.dConfig);
}
public set(CConfigHPBar value)
{
this.dConfig = value;
}
}
}
-340
View File
@@ -1,340 +0,0 @@
#if defined _class_cconfig_
#endinput
#endif
#define _class_cconfig_
enum eConfigMethod
{
eConfigMethod_Invalid = 0,
eConfigMethod_Breakable = 1,
eConfigMethod_Counter = 2,
eConfigMethod_HPBar = 3
}
methodmap CConfig < Basic
{
public CConfig()
{
Basic myclass = new Basic();
myclass.SetString("sName", "");
myclass.SetInt("iMethod", eConfigMethod_Invalid);
myclass.SetString("sTrigger", "");
myclass.SetString("sOutput", "");
myclass.SetFloat("fTriggerDelay", 0.0);
myclass.SetString("sShowTrigger", "");
myclass.SetString("sShowOutput", "");
myclass.SetFloat("fShowTriggerDelay", 0.0);
myclass.SetString("sKillTrigger", "");
myclass.SetString("sKillOutput", "");
myclass.SetFloat("fKillTriggerDelay", 0.0);
myclass.SetString("sHurtTrigger", "");
myclass.SetString("sHurtOutput", "");
myclass.SetBool("bMultiTrigger", false);
myclass.SetBool("bNameFixup", false);
myclass.SetInt("iTimeout", -1);
return view_as<CConfig>(myclass);
}
public bool GetName(char[] buffer, int length)
{
return this.GetString("sName", buffer, length);
}
public void SetName(const char[] buffer)
{
this.SetString("sName", buffer);
}
property eConfigMethod iMethod
{
public get()
{
return view_as<eConfigMethod>(this.GetInt("iMethod"));
}
public set(eConfigMethod value)
{
this.SetInt("iMethod", view_as<int>(value));
}
}
public bool GetTrigger(char[] buffer, int length)
{
return this.GetString("sTrigger", buffer, length);
}
public void SetTrigger(const char[] buffer)
{
this.SetString("sTrigger", buffer);
}
public bool GetOutput(char[] buffer, int length)
{
return this.GetString("sOutput", buffer, length);
}
public void SetOutput(const char[] buffer)
{
this.SetString("sOutput", buffer);
}
property float fTriggerDelay
{
public get()
{
return this.GetFloat("fTriggerDelay");
}
public set(float value)
{
this.SetFloat("fTriggerDelay", value);
}
}
public bool GetShowTrigger(char[] buffer, int length)
{
return this.GetString("sShowTrigger", buffer, length);
}
public void SetShowTrigger(const char[] buffer)
{
this.SetString("sShowTrigger", buffer);
}
public bool GetShowOutput(char[] buffer, int length)
{
return this.GetString("sShowOutput", buffer, length);
}
public void SetShowOutput(const char[] buffer)
{
this.SetString("sShowOutput", buffer);
}
property float fShowTriggerDelay
{
public get()
{
return this.GetFloat("fShowTriggerDelay");
}
public set(float value)
{
this.SetFloat("fShowTriggerDelay", value);
}
}
public bool GetKillTrigger(char[] buffer, int length)
{
return this.GetString("sKillTrigger", buffer, length);
}
public void SetKillTrigger(const char[] buffer)
{
this.SetString("sKillTrigger", buffer);
}
public bool GetKillOutput(char[] buffer, int length)
{
return this.GetString("sKillOutput", buffer, length);
}
public void SetKillOutput(const char[] buffer)
{
this.SetString("sKillOutput", buffer);
}
property float fKillTriggerDelay
{
public get()
{
return this.GetFloat("fKillTriggerDelay");
}
public set(float value)
{
this.SetFloat("fKillTriggerDelay", value);
}
}
public bool GetHurtTrigger(char[] buffer, int length)
{
return this.GetString("sHurtTrigger", buffer, length);
}
public void SetHurtTrigger(const char[] buffer)
{
this.SetString("sHurtTrigger", buffer);
}
public bool GetHurtOutput(char[] buffer, int length)
{
return this.GetString("sHurtOutput", buffer, length);
}
public void SetHurtOutput(const char[] buffer)
{
this.SetString("sHurtOutput", buffer);
}
property bool bMultiTrigger
{
public get()
{
return this.GetBool("bMultiTrigger");
}
public set(bool value)
{
this.SetBool("bMultiTrigger", value);
}
}
property bool bNameFixup
{
public get()
{
return this.GetBool("bNameFixup");
}
public set(bool value)
{
this.SetBool("bNameFixup", value);
}
}
property int iTimeout
{
public get()
{
return this.GetInt("iTimeout");
}
public set(int value)
{
this.SetInt("iTimeout", value);
}
}
property bool IsBreakable {
public get() {
return (this.iMethod == eConfigMethod_Breakable);
}
}
property bool IsCounter {
public get() {
return (this.iMethod == eConfigMethod_Counter);
}
}
property bool IsHPBar {
public get() {
return (this.iMethod == eConfigMethod_HPBar);
}
}
}
methodmap CConfigBreakable < CConfig
{
public CConfigBreakable()
{
CConfig myclass = new CConfig();
myclass.SetString("sBreakable", "");
myclass.iMethod = eConfigMethod_Breakable;
return view_as<CConfigBreakable>(myclass);
}
public bool GetBreakable(char[] buffer, int length)
{
return this.GetString("sBreakable", buffer, length);
}
public void SetBreakable(const char[] buffer)
{
this.SetString("sBreakable", buffer);
}
}
methodmap CConfigCounter < CConfig
{
public CConfigCounter()
{
CConfig myclass = new CConfig();
myclass.SetString("sCounter", "");
myclass.SetBool("bCounterReverse", false);
myclass.iMethod = eConfigMethod_Counter;
return view_as<CConfigCounter>(myclass);
}
public bool GetCounter(char[] buffer, int length)
{
return this.GetString("sCounter", buffer, length);
}
public void SetCounter(const char[] buffer)
{
this.SetString("sCounter", buffer);
}
property bool bCounterReverse
{
public get()
{
return this.GetBool("bCounterReverse");
}
public set(bool value)
{
this.SetBool("bCounterReverse", value);
}
}
}
methodmap CConfigHPBar < CConfigCounter
{
public CConfigHPBar()
{
CConfigCounter myclass = new CConfigCounter();
myclass.SetString("sIterator", "");
myclass.SetString("sBackup", "");
myclass.SetBool("bIteratorReverse", false);
myclass.iMethod = eConfigMethod_HPBar;
return view_as<CConfigHPBar>(myclass);
}
public bool GetIterator(char[] buffer, int length)
{
return this.GetString("sIterator", buffer, length);
}
public void SetIterator(const char[] buffer)
{
this.SetString("sIterator", buffer);
}
public bool GetBackup(char[] buffer, int length)
{
return this.GetString("sBackup", buffer, length);
}
public void SetBackup(const char[] buffer)
{
this.SetString("sBackup", buffer);
}
property bool bIteratorReverse
{
public get()
{
return this.GetBool("bIteratorReverse");
}
public set(bool value)
{
this.SetBool("bIteratorReverse", value);
}
}
}
-11
View File
@@ -1,11 +0,0 @@
#if defined BossHP_included
#endinput
#endif
#define BossHP_included
forward void OnBossIntialized(any Boss, any Config);
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.