|
@@ -7,7 +7,6 @@
|
|
|
#include <sourcemod>
|
|
|
|
|
|
#include <tf2_stocks>
|
|
|
-#include <tf2idb>
|
|
|
|
|
|
#pragma newdecls required
|
|
|
|
|
@@ -15,8 +14,9 @@
|
|
|
#include <sdktools>
|
|
|
|
|
|
#include <stocksoup/tf/econ>
|
|
|
+#include <tf_econ_data>
|
|
|
|
|
|
-#define PLUGIN_VERSION "1.0.1"
|
|
|
+#define PLUGIN_VERSION "1.1.0"
|
|
|
public Plugin myinfo = {
|
|
|
name = "[CSRD] Bot Taunt Randomizer",
|
|
|
author = "nosoop",
|
|
@@ -27,8 +27,6 @@ public Plugin myinfo = {
|
|
|
|
|
|
Handle g_SDKFindPartnerTauntInitiator;
|
|
|
|
|
|
-ArrayList g_TauntEntries[TFClassType];
|
|
|
-
|
|
|
public void OnPluginStart() {
|
|
|
Handle hGameConf = LoadGameConfigFile("csrd.bot_taunt_randomizer");
|
|
|
if (!hGameConf) {
|
|
@@ -50,33 +48,6 @@ public void OnPluginStart() {
|
|
|
DHookEnableDetour(dt_HandleTauntCommand, false, OnHandleTauntCommand);
|
|
|
|
|
|
delete hGameConf;
|
|
|
-
|
|
|
- for (TFClassType i = TFClass_Unknown; i < TFClassType; i++) {
|
|
|
- g_TauntEntries[i] = new ArrayList();
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Build lists of taunts sorted by class via TF2IDB.
|
|
|
- */
|
|
|
-public void OnAllPluginsLoaded() {
|
|
|
- ArrayList args = new ArrayList();
|
|
|
- DBResultSet results = view_as<DBResultSet>(TF2IDB_CustomQuery(
|
|
|
- "SELECT id, class FROM tf2idb_class WHERE slot = 'taunt'", args, 4));
|
|
|
-
|
|
|
- if (!results) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- while (results.FetchRow()) {
|
|
|
- char className[16];
|
|
|
-
|
|
|
- int id = results.FetchInt(0);
|
|
|
- results.FetchString(1, className, sizeof(className));
|
|
|
-
|
|
|
- g_TauntEntries[TF2_GetClass(className)].Push(id);
|
|
|
- }
|
|
|
- delete results;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -163,19 +134,19 @@ int TF2_FindPartnerTauntInitiator(int client) {
|
|
|
* Returns a random class-specific or all-class taunt index.
|
|
|
*/
|
|
|
int TF2_GetRandomTauntForClass(TFClassType playerClass) {
|
|
|
- int nTauntsAllClass = g_TauntEntries[0].Length;
|
|
|
- int nTauntsPlayerClass = g_TauntEntries[playerClass].Length;
|
|
|
+ int returnValue = DEFINDEX_UNDEFINED;
|
|
|
|
|
|
- if (nTauntsAllClass + nTauntsPlayerClass == 0) {
|
|
|
- return DEFINDEX_UNDEFINED;
|
|
|
+ ArrayList tauntList = TF2Econ_GetItemList(FilterClassTaunts, playerClass);
|
|
|
+ if (tauntList.Length) {
|
|
|
+ returnValue = tauntList.Get(GetRandomInt(0, tauntList.Length - 1));
|
|
|
}
|
|
|
+ delete tauntList;
|
|
|
|
|
|
- int index = GetRandomInt(0, nTauntsAllClass + nTauntsPlayerClass - 1);
|
|
|
-
|
|
|
- if (index < nTauntsAllClass) {
|
|
|
- return g_TauntEntries[0].Get(index);
|
|
|
- }
|
|
|
- return g_TauntEntries[playerClass].Get(index - nTauntsAllClass);
|
|
|
+ return returnValue;
|
|
|
+}
|
|
|
+
|
|
|
+public bool FilterClassTaunts(int defindex, TFClassType playerClass) {
|
|
|
+ return TF2Econ_GetItemSlot(defindex, playerClass) == 11;
|
|
|
}
|
|
|
|
|
|
/**
|