From bc737ecc68dfe7b46694f18d3a2c682c79536f5e Mon Sep 17 00:00:00 2001 From: kadeshar Date: Tue, 26 Aug 2025 18:28:42 +0200 Subject: [PATCH] - Changed standalone config on cheat (#1585) - Changed drink condition --- conf/playerbots.conf.dist | 7 ++----- src/PlayerbotAIConfig.cpp | 5 +++-- src/PlayerbotAIConfig.h | 4 ++-- src/factory/PlayerbotFactory.cpp | 2 +- src/strategy/actions/GiveItemAction.cpp | 4 ++-- src/strategy/actions/NonCombatActions.cpp | 10 +++++----- src/strategy/generic/UseFoodStrategy.cpp | 11 ++++++----- src/strategy/triggers/GenericTriggers.cpp | 4 ++-- 8 files changed, 23 insertions(+), 24 deletions(-) diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index b7694173..4d9e89d9 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -174,10 +174,6 @@ AiPlayerbot.SummonWhenGroup = 1 # Selfbot permission level (0 = disabled, 1 = GM only (default), 2 = all players, 3 = activate on login) AiPlayerbot.SelfBotLevel = 1 -# Give free food to bots -# Default: 1 (enabled) -AiPlayerbot.FreeFood = 1 - # Non-GM player can only use init=auto to initialize bots based on their own level and gearscore # Default: 0 (non-GM player can use any intialization commands) AiPlayerbot.AutoInitOnly = 0 @@ -496,6 +492,7 @@ AiPlayerbot.AutoGearQualityLimit = 3 AiPlayerbot.AutoGearScoreLimit = 0 # Enable/Disable cheats for bots +# "food" (bots use cheat when eat or drink) # "gold" (bots have infinite gold) # "health" (bots have infinite health) # "mana" (bots have infinite mana) @@ -504,7 +501,7 @@ AiPlayerbot.AutoGearScoreLimit = 0 # "raid" (bots use cheats implemented into raid strategies) # To use multiple cheats, separate them by commas below (e.g., to enable all, use "gold,health,mana,power,raid,taxi") # Default: taxi and raid are enabled -AiPlayerbot.BotCheats = "taxi,raid" +AiPlayerbot.BotCheats = "food,taxi,raid" # # diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index 5ee4a115..f69cbf19 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -462,11 +462,13 @@ bool PlayerbotAIConfig::Initialize() } botCheats.clear(); - LoadListString>(sConfigMgr->GetOption("AiPlayerbot.BotCheats", "taxi,raid"), + LoadListString>(sConfigMgr->GetOption("AiPlayerbot.BotCheats", "food,taxi,raid"), botCheats); botCheatMask = 0; + if (std::find(botCheats.begin(), botCheats.end(), "food") != botCheats.end()) + botCheatMask |= (uint32)BotCheatMask::food; if (std::find(botCheats.begin(), botCheats.end(), "taxi") != botCheats.end()) botCheatMask |= (uint32)BotCheatMask::taxi; if (std::find(botCheats.begin(), botCheats.end(), "gold") != botCheats.end()) @@ -598,7 +600,6 @@ bool PlayerbotAIConfig::Initialize() RpgStatusProbWeight[RPG_REST] = sConfigMgr->GetOption("AiPlayerbot.RpgStatusProbWeight.Rest", 5); syncLevelWithPlayers = sConfigMgr->GetOption("AiPlayerbot.SyncLevelWithPlayers", false); - freeFood = sConfigMgr->GetOption("AiPlayerbot.FreeFood", true); randomBotGroupNearby = sConfigMgr->GetOption("AiPlayerbot.RandomBotGroupNearby", true); // arena diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index a9a12fba..36faa98b 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -23,7 +23,8 @@ enum class BotCheatMask : uint32 mana = 8, power = 16, raid = 32, - maxMask = 64 + food = 64, + maxMask = 128 }; enum class HealingManaEfficiency : uint8 @@ -340,7 +341,6 @@ public: bool enableNewRpgStrategy; std::unordered_map RpgStatusProbWeight; bool syncLevelWithPlayers; - bool freeFood; bool autoLearnQuestSpells; bool autoTeleportForLevel; bool randomBotGroupNearby; diff --git a/src/factory/PlayerbotFactory.cpp b/src/factory/PlayerbotFactory.cpp index e239d449..b3ca0e9b 100644 --- a/src/factory/PlayerbotFactory.cpp +++ b/src/factory/PlayerbotFactory.cpp @@ -3244,7 +3244,7 @@ std::vector PlayerbotFactory::GetCurrentGemsCount() void PlayerbotFactory::InitFood() { - if (sPlayerbotAIConfig->freeFood) + if (!botAI->HasCheat(BotCheatMask::food)) { return; } diff --git a/src/strategy/actions/GiveItemAction.cpp b/src/strategy/actions/GiveItemAction.cpp index a68482c0..afdf19be 100644 --- a/src/strategy/actions/GiveItemAction.cpp +++ b/src/strategy/actions/GiveItemAction.cpp @@ -76,7 +76,7 @@ bool GiveFoodAction::isUseful() bool isRandomBot = GetTarget()->IsPlayer() && sRandomPlayerbotMgr->IsRandomBot((Player*)GetTarget()); - return !isRandomBot || (isRandomBot && !sPlayerbotAIConfig->freeFood); + return !isRandomBot || (isRandomBot && !botAI->HasCheat(BotCheatMask::food)); } Unit* GiveWaterAction::GetTarget() { return AI_VALUE(Unit*, "party member without water"); } @@ -88,5 +88,5 @@ bool GiveWaterAction::isUseful() bool isRandomBot = GetTarget()->IsPlayer() && sRandomPlayerbotMgr->IsRandomBot((Player*)GetTarget()); - return !isRandomBot || (isRandomBot && !sPlayerbotAIConfig->freeFood); + return !isRandomBot || (isRandomBot && !botAI->HasCheat(BotCheatMask::food)); } diff --git a/src/strategy/actions/NonCombatActions.cpp b/src/strategy/actions/NonCombatActions.cpp index 128e44ab..d3c49dec 100644 --- a/src/strategy/actions/NonCombatActions.cpp +++ b/src/strategy/actions/NonCombatActions.cpp @@ -17,7 +17,7 @@ bool DrinkAction::Execute(Event event) if (!hasMana) return false; - if (sPlayerbotAIConfig->freeFood) + if (botAI->HasCheat(BotCheatMask::food)) { // if (bot->IsNonMeleeSpellCast(true)) // return false; @@ -54,11 +54,11 @@ bool DrinkAction::Execute(Event event) return UseItemAction::Execute(event); } -bool DrinkAction::isUseful() { return UseItemAction::isUseful() && AI_VALUE2(uint8, "mana", "self target") < 85; } +bool DrinkAction::isUseful() { return UseItemAction::isUseful() && AI_VALUE2(uint8, "mana", "self target") < 100; } bool DrinkAction::isPossible() { - return !bot->IsInCombat() && (sPlayerbotAIConfig->freeFood || UseItemAction::isPossible()); + return !bot->IsInCombat() && (botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible()); } bool EatAction::Execute(Event event) @@ -66,7 +66,7 @@ bool EatAction::Execute(Event event) if (bot->IsInCombat()) return false; - if (sPlayerbotAIConfig->freeFood) + if (botAI->HasCheat(BotCheatMask::food)) { // if (bot->IsNonMeleeSpellCast(true)) // return false; @@ -107,5 +107,5 @@ bool EatAction::isUseful() { return UseItemAction::isUseful() && AI_VALUE2(uint8 bool EatAction::isPossible() { - return !bot->IsInCombat() && (sPlayerbotAIConfig->freeFood || UseItemAction::isPossible()); + return !bot->IsInCombat() && (botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible()); } diff --git a/src/strategy/generic/UseFoodStrategy.cpp b/src/strategy/generic/UseFoodStrategy.cpp index 04841e4a..e7f2049d 100644 --- a/src/strategy/generic/UseFoodStrategy.cpp +++ b/src/strategy/generic/UseFoodStrategy.cpp @@ -11,13 +11,14 @@ void UseFoodStrategy::InitTriggers(std::vector& triggers) { Strategy::InitTriggers(triggers); - if (sPlayerbotAIConfig->freeFood) + if (botAI->HasCheat(BotCheatMask::food)) + { triggers.push_back(new TriggerNode("medium health", NextAction::array(0, new NextAction("food", 3.0f), nullptr))); - else - triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("food", 3.0f), nullptr))); - - if (sPlayerbotAIConfig->freeFood) triggers.push_back(new TriggerNode("high mana", NextAction::array(0, new NextAction("drink", 3.0f), nullptr))); + } else + { + triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("food", 3.0f), nullptr))); triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("drink", 3.0f), nullptr))); + } } diff --git a/src/strategy/triggers/GenericTriggers.cpp b/src/strategy/triggers/GenericTriggers.cpp index 5f1935a9..2e0043c5 100644 --- a/src/strategy/triggers/GenericTriggers.cpp +++ b/src/strategy/triggers/GenericTriggers.cpp @@ -249,7 +249,7 @@ bool AoeTrigger::IsActive() bool NoFoodTrigger::IsActive() { bool isRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot); - if (isRandomBot && sPlayerbotAIConfig->freeFood) + if (isRandomBot && botAI->HasCheat(BotCheatMask::food)) return false; return AI_VALUE2(std::vector, "inventory items", "conjured food").empty(); @@ -258,7 +258,7 @@ bool NoFoodTrigger::IsActive() bool NoDrinkTrigger::IsActive() { bool isRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot); - if (isRandomBot && sPlayerbotAIConfig->freeFood) + if (isRandomBot && botAI->HasCheat(BotCheatMask::food)) return false; return AI_VALUE2(std::vector, "inventory items", "conjured water").empty();