From fdcfecb4ff6ab0ccf4329e121a267ff41faa091a Mon Sep 17 00:00:00 2001 From: LightCat Date: Thu, 21 Mar 2019 18:24:55 +0100 Subject: [PATCH] Catbot and NavBot improvements --- data/menu/nullifiedcat/movement.xml | 4 ++-- src/hacks/CatBot.cpp | 18 ++++++++++-------- src/hacks/NavBot.cpp | 14 +++++++++++--- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/data/menu/nullifiedcat/movement.xml b/data/menu/nullifiedcat/movement.xml index 332a4997..22ebb466 100755 --- a/data/menu/nullifiedcat/movement.xml +++ b/data/menu/nullifiedcat/movement.xml @@ -29,9 +29,9 @@ - + + diff --git a/src/hacks/CatBot.cpp b/src/hacks/CatBot.cpp index c4ebbaa0..e3a9e0df 100644 --- a/src/hacks/CatBot.cpp +++ b/src/hacks/CatBot.cpp @@ -108,7 +108,7 @@ void do_random_votekick() return; hack::ExecuteCommand("callvote kick \"" + std::to_string(target) + " cheating\""); } - +static const std::string catbot_names[] = { "K4T-B0T", "cat-bot", "btarrant", "cat-scout", "just disable vac tf", "raul.garcia", "zCat", "lagger bot" }; void update_catbot_list() { for (int i = 1; i < g_GlobalVars->maxClients; ++i) @@ -118,14 +118,16 @@ void update_catbot_list() continue; info.name[31] = 0; - if (strcasestr(info.name, "cat-bot") || strcasestr(info.name, "just disable vac tf") || strcasestr(info.name, "raul.garcia") || strcasestr(info.name, "zCat") || strcasestr(info.name, "lagger bot") || strcasestr(info.name, "zLag-bot") || strcasestr(info.name, "crash-bot") || strcasestr(info.name, "reichstagbot")) - { - if (human_detecting_map.find(info.friendsID) == human_detecting_map.end()) + std::string pl_name(info.name); + for (auto name : catbot_names) + if (pl_name.find(name) != pl_name.npos) { - logging::Info("Found bot %s [U:1:%u]", info.name, info.friendsID); - human_detecting_map.insert(std::make_pair(info.friendsID, catbot_user_state{ 0 })); + if (human_detecting_map.find(info.friendsID) == human_detecting_map.end()) + { + logging::Info("Found bot %s [U:1:%u]", info.name, info.friendsID); + human_detecting_map.insert(std::make_pair(info.friendsID, catbot_user_state{ 0 })); + } } - } } } @@ -333,7 +335,7 @@ static void cm() // static const int classes[3]{ tf_spy, tf_sniper, tf_pyro }; - if (*auto_disguise && g_pPlayerResource->GetClass(LOCAL_E) == tf_spy && !HasCondition(LOCAL_E) && disguise.test_and_set(3000)) + if (*auto_disguise && g_pPlayerResource->GetClass(LOCAL_E) == tf_spy && !IsPlayerDisguised(LOCAL_E) && disguise.test_and_set(3000)) { int teamtodisguise = (LOCAL_E->m_iTeam() == TEAM_RED) ? TEAM_RED - 1 : TEAM_BLU - 1; int classtojoin = classes[rand() % 3]; diff --git a/src/hacks/NavBot.cpp b/src/hacks/NavBot.cpp index 16790b61..f0fc06c3 100644 --- a/src/hacks/NavBot.cpp +++ b/src/hacks/NavBot.cpp @@ -11,6 +11,7 @@ namespace hacks::tf2::NavBot static settings::Bool enabled("navbot.enabled", "false"); static settings::Bool stay_near("navbot.stay-near", "true"); static settings::Bool heavy_mode("navbot.other-mode", "false"); +static settings::Bool spy_mode("navbot.spy-mode", "false"); static settings::Bool get_health("navbot.get-health-and-ammo", "true"); static settings::Float jump_distance("navbot.autojump.trigger-distance", "300"); static settings::Bool autojump("navbot.autojump.enabled", "false"); @@ -34,6 +35,7 @@ namespace task { task current_task; } +constexpr bot_class_config DIST_SPY{ 300.0f, 500.0f, 1000.0f }; constexpr bot_class_config DIST_OTHER{ 100.0f, 200.0f, 300.0f }; constexpr bot_class_config DIST_SNIPER{ 1000.0f, 1500.0f, 3000.0f }; @@ -57,13 +59,13 @@ static void CreateMove() if (getHealthAndAmmo()) return; // Try to stay near enemies to increase efficiency - if ((stay_near || heavy_mode) && current_task != task::followbot) + if ((stay_near || heavy_mode || spy_mode) && current_task != task::followbot) if (stayNear()) return; // We don't have anything else to do. Just nav to sniper spots. if (navToSniperSpot()) return; - // Uhh... Just stand arround I guess? + // Uhh... Just stand around I guess? } bool init(bool first_cm) @@ -236,7 +238,11 @@ static bool stayNear() // What distances do we have to use? const bot_class_config *config; - if (heavy_mode) + if (spy_mode) + { + config = &DIST_SPY; + } + else if (heavy_mode) { config = &DIST_OTHER; } @@ -425,6 +431,8 @@ static int GetBestSlot() return primary; case tf_medic: return secondary; + case tf_spy: + return primary; default: { float nearest_dist = getNearestPlayerDistance().second;