|
12 | 12 | #include <stocksoup/convars>
|
13 | 13 | #include <stocksoup/memory>
|
14 | 14 |
|
15 |
| -#define PLUGIN_VERSION "1.0.0" |
| 15 | +#define PLUGIN_VERSION "1.1.0" |
16 | 16 | public Plugin myinfo = {
|
17 | 17 | name = "TF2 Utils",
|
18 | 18 | author = "nosoop",
|
@@ -67,6 +67,9 @@ int sizeof_TFCondInfo;
|
67 | 67 |
|
68 | 68 | int g_nConditions;
|
69 | 69 |
|
| 70 | +#define MAX_DOT_DAMAGE_TYPES 16 |
| 71 | +int g_nDOTDamageTypes, g_DOTDamageTypes[MAX_DOT_DAMAGE_TYPES]; |
| 72 | + |
70 | 73 | public APLRes AskPluginLoad2(Handle self, bool late, char[] error, int maxlen) {
|
71 | 74 | RegPluginLibrary("nosoop_tf2utils");
|
72 | 75 |
|
@@ -114,6 +117,8 @@ public APLRes AskPluginLoad2(Handle self, bool late, char[] error, int maxlen) {
|
114 | 117 |
|
115 | 118 | CreateNative("TF2Util_IsPointInRespawnRoom", Native_IsPointInRespawnRoom);
|
116 | 119 |
|
| 120 | + CreateNative("TF2Util_IsCustomDamageTypeDOT", Native_IsCustomDamageTypeDOT); |
| 121 | + |
117 | 122 | CreateNative("TF2Util_GetPlayerFromSharedAddress", Native_GetPlayerFromSharedAddress);
|
118 | 123 |
|
119 | 124 | // deprecated name for backcompat
|
@@ -364,6 +369,26 @@ public void OnPluginStart() {
|
364 | 369 | offs_CTFPlayer_flLastDamageTime = GameConfGetAddressOffset(hGameConf,
|
365 | 370 | "CTFPlayer::m_flLastDamageTime");
|
366 | 371 |
|
| 372 | + // allocate 5 chars for each value + delimiter |
| 373 | + char damageTypes[MAX_DOT_DAMAGE_TYPES * 5]; |
| 374 | + if (!GameConfGetKeyValue(hGameConf, "DOTDamageTypes", damageTypes, sizeof(damageTypes))) { |
| 375 | + SetFailState("Could not retrieve DOTDamageTypes values"); |
| 376 | + } else for (int c, i, res; (i = StringToIntEx(damageTypes[c], res, 0x10)); c += i) { |
| 377 | + /** |
| 378 | + * Parse numeric values from the list. |
| 379 | + * I don't expect the game to ever have as many DOT damage types as the hardcoded |
| 380 | + * limit of 16 I've initally assigned here, but if it does, don't silently fail. |
| 381 | + */ |
| 382 | + if (g_nDOTDamageTypes == MAX_DOT_DAMAGE_TYPES) { |
| 383 | + SetFailState("Not enough space allocated to parse damage types (limit %d) - " |
| 384 | + ... "update MAX_DOT_DAMAGE_TYPES and recompile", MAX_DOT_DAMAGE_TYPES); |
| 385 | + } else if (res == 0) { |
| 386 | + continue; |
| 387 | + } |
| 388 | + |
| 389 | + g_DOTDamageTypes[g_nDOTDamageTypes++] = res; |
| 390 | + } |
| 391 | + |
367 | 392 | delete hGameConf;
|
368 | 393 |
|
369 | 394 | CreateVersionConVar("tf2utils_version", "TF2 Utils version.");
|
@@ -865,6 +890,17 @@ any Native_SetPlayerRespawnTimeOverride(Handle plugin, int numParams) {
|
865 | 890 | return;
|
866 | 891 | }
|
867 | 892 |
|
| 893 | +// bool(int damagecustom); |
| 894 | +any Native_IsCustomDamageTypeDOT(Handle plugin, int numParams) { |
| 895 | + int damagecustom = GetNativeCell(1); |
| 896 | + for (int i; i < g_nDOTDamageTypes; i++) { |
| 897 | + if (g_DOTDamageTypes[i] == damagecustom) { |
| 898 | + return true; |
| 899 | + } |
| 900 | + } |
| 901 | + return false; |
| 902 | +} |
| 903 | + |
868 | 904 | // int(Address pShared);
|
869 | 905 | any Native_GetPlayerFromSharedAddress(Handle plugin, int numParams) {
|
870 | 906 | Address pShared = GetNativeCell(1);
|
|
0 commit comments