forked from SirPlease/L4D2-Competitive-Rework
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1744b8
commit 34c2bf8
Showing
6 changed files
with
1,395 additions
and
258 deletions.
There are no files selected for viewing
Binary file modified
BIN
+10.2 KB
(190%)
addons/sourcemod/plugins/optional/l4d_tank_damage_announce.smx
Binary file not shown.
86 changes: 86 additions & 0 deletions
86
addons/sourcemod/scripting/include/l4d_tank_damage_announce.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#if defined _l4d_tank_damage_announce_included | ||
#endinput | ||
#endif | ||
#define _l4d_tank_damage_announce_included | ||
|
||
/** | ||
* @brief Retrieves total punches landed by a Tank during his lifetime. | ||
* | ||
* @param client Client id of the Tank | ||
* | ||
* @return Number of punches. | ||
*/ | ||
native int TFA_Punches(int client); | ||
|
||
/** | ||
* @brief Retrieves total rocks landed by a Tank during his lifetime. | ||
* | ||
* @param client Client id of the Tank | ||
* | ||
* @return Number of rocks. | ||
*/ | ||
native int TFA_Rocks(int client); | ||
|
||
/** | ||
* @brief Retrieves total hittables landed by a Tank during his lifetime. | ||
* | ||
* @param client Client id of the Tank | ||
* | ||
* @return Number of hittables. | ||
*/ | ||
native int TFA_Hittables(int client); | ||
|
||
/** | ||
* @brief Retrieves total damage done by a Tank during his lifetime. | ||
* | ||
* @param client Client id of the Tank | ||
* | ||
* @return Number of total damage. | ||
*/ | ||
native int TFA_TotalDmg(int client); | ||
|
||
/** | ||
* @brief Retrieves life time of an alive Tank. | ||
* | ||
* @param client Client id of the Tank | ||
* | ||
* @return Elasped time in seconds, -1 if non-exist or dead. | ||
*/ | ||
native int TFA_UpTime(int client); | ||
|
||
/** | ||
* @brief Called when a Tank's damage info should be announced. | ||
* | ||
* @param tank Client id of the Tank | ||
* @param remaining_health Remaining health of the Tank | ||
* @param max_health Total health of the Tank | ||
* @param survivors Array of survivor client id | ||
* @param damages Array of survivor damages | ||
* @param arraySize Size of array | ||
* | ||
* @noreturn | ||
*/ | ||
forward void OnTankDamageAnnounce(int tank, int remaining_health, int max_health, const int[] survivors, const int[] damages, int arraySize); | ||
|
||
|
||
public SharedPlugin __pl_l4d_tank_damage_announce = | ||
{ | ||
name = "l4d_tank_damage_announce", | ||
file = "l4d_tank_damage_announce.smx", | ||
#if defined REQUIRE_PLUGIN | ||
required = 1, | ||
#else | ||
required = 0, | ||
#endif | ||
}; | ||
|
||
#if !defined REQUIRE_PLUGIN | ||
public void __pl_l4d_tank_damage_announce_SetNTVOptional() | ||
{ | ||
MarkNativeAsOptional("TFA_Punches"); | ||
MarkNativeAsOptional("TFA_Rocks"); | ||
MarkNativeAsOptional("TFA_Hittables"); | ||
MarkNativeAsOptional("TFA_TotalDmg"); | ||
MarkNativeAsOptional("TFA_UpTime"); | ||
} | ||
#endif |
142 changes: 142 additions & 0 deletions
142
addons/sourcemod/scripting/include/logic/uservector.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
#if defined _l4d_tank_damage_announce_uservector_included | ||
#endinput | ||
#endif | ||
#define _l4d_tank_damage_announce_uservector_included | ||
|
||
/** | ||
* Entity-Relationship: UserVector(Userid, ...) | ||
*/ | ||
typeset UserVectorIterate | ||
{ | ||
function bool (int userid); | ||
function bool (int userid, any data); | ||
} | ||
methodmap UserVector < ArrayList | ||
{ | ||
public UserVector(int blocksize = 1) { | ||
return view_as<UserVector>(new ArrayList(blocksize, 0)); | ||
} | ||
property ArrayList Super { | ||
public get() { return view_as<ArrayList>(this); } | ||
} | ||
public int FindOrCreate(int userid, bool create = false) { | ||
int index = this.FindValue(userid, 0); | ||
if (index == -1 && create) { | ||
any[] o = new any[this.BlockSize]; | ||
o[0] = userid; | ||
for (int i = 1; i < this.BlockSize; ++i) { o[i] = 0; } | ||
index = this.PushArray(o); | ||
} | ||
return index; | ||
} | ||
public int At(int index) { | ||
return this.Super.Get(index, 0); | ||
} | ||
public bool Get(int userid, any &value, int block = 0) { | ||
int index = this.FindOrCreate(userid); | ||
if (index != -1) value = this.Super.Get(index, block); | ||
return index != -1; | ||
} | ||
public bool Set(int userid, any value, int block = 0) { | ||
int index = this.FindOrCreate(userid); | ||
if (index != -1) value = this.Super.Set(index, value, block); | ||
return index != -1; | ||
} | ||
public bool Erase(int userid) { | ||
int index = this.FindOrCreate(userid); | ||
if (index != -1) this.Super.Erase(index); | ||
return index != -1; | ||
} | ||
public bool GetArray(int userid, any[] value) { | ||
int index = this.FindOrCreate(userid); | ||
if (index != -1) this.Super.GetArray(index, value); | ||
return index != -1; | ||
} | ||
public bool Add(int userid, any value, int block = 0) { | ||
any temp; | ||
return this.Get(userid, temp, block) && this.Set(userid, temp + value, block); | ||
} | ||
public any Sum(int block) { | ||
int size = this.Length; | ||
any result = 0; | ||
for (int i = 0; i < size; ++i) { result += this.Super.Get(i, block); } | ||
return result; | ||
} | ||
public bool ForEach(UserVectorIterate callback, any data = 0) { | ||
int size = this.Length; | ||
bool result = false; | ||
for (int i = 0; i < size; ++i) { | ||
Call_StartFunction(INVALID_HANDLE, callback); | ||
Call_PushCell(this.At(i)); | ||
Call_PushCell(data); | ||
Call_Finish(result); | ||
if (!result) return false; | ||
} | ||
return true; | ||
} | ||
} | ||
|
||
// pawn doesn't implement methodmap VTable-like, so I have to copy paste the whole thing here :( | ||
methodmap AutoUserVector < ArrayList { | ||
public AutoUserVector(int blocksize = 1) { | ||
return view_as<AutoUserVector>(new ArrayList(blocksize)); | ||
} | ||
property ArrayList Super { | ||
public get() { return view_as<ArrayList>(this); } | ||
} | ||
public int FindOrCreate(int userid) { | ||
int index = this.FindValue(userid, 0); | ||
if (index == -1) { | ||
any[] o = new any[this.BlockSize]; | ||
o[0] = userid; | ||
for (int i = 1; i < this.BlockSize; ++i) { o[i] = 0; } | ||
index = this.PushArray(o); | ||
} | ||
return index; | ||
} | ||
public int At(int index) { | ||
return this.Super.Get(index, 0); | ||
} | ||
public bool Get(int userid, any &value, int block = 0) { | ||
int index = this.FindOrCreate(userid); | ||
if (index != -1) value = this.Super.Get(index, block); | ||
return index != -1; | ||
} | ||
public bool Set(int userid, any value, int block = 0) { | ||
int index = this.FindOrCreate(userid); | ||
if (index != -1) value = this.Super.Set(index, value, block); | ||
return index != -1; | ||
} | ||
public bool Erase(int userid) { | ||
int index = this.FindOrCreate(userid); | ||
if (index != -1) this.Super.Erase(index); | ||
return index != -1; | ||
} | ||
public bool GetArray(int userid, any[] value) { | ||
int index = this.FindOrCreate(userid); | ||
if (index != -1) this.Super.GetArray(index, value); | ||
return index != -1; | ||
} | ||
public bool Add(int userid, any value, int block = 0) { | ||
any temp; | ||
return this.Get(userid, temp, block) && this.Set(userid, temp + value, block); | ||
} | ||
public any Sum(int block) { | ||
int size = this.Length; | ||
any result = 0; | ||
for (int i = 0; i < size; ++i) { result += this.Super.Get(i, block); } | ||
return result; | ||
} | ||
public bool ForEach(UserVectorIterate callback, any data = 0) { | ||
int size = this.Length; | ||
bool result = false; | ||
for (int i = 0; i < size; ++i) { | ||
Call_StartFunction(INVALID_HANDLE, callback); | ||
Call_PushCell(this.At(i)); | ||
Call_PushCell(data); | ||
Call_Finish(result); | ||
if (!result) return false; | ||
} | ||
return true; | ||
} | ||
} |
Oops, something went wrong.