From 833251690ab43392528a1a4c9cb01682460f6d9a Mon Sep 17 00:00:00 2001 From: bo Date: Wed, 10 Dec 2025 19:00:16 -0600 Subject: [PATCH] Notice and respect conf changes to min/max bots --- .../Bots/playerbot/RandomPlayerbotMgr.cpp | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) mode change 100644 => 100755 src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp diff --git a/src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp b/src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp old mode 100644 new mode 100755 index 6c9b497ad..39345d8fe --- a/src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp +++ b/src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp @@ -39,6 +39,21 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed) sLog.outBasic("Processing random bots..."); + uint32 cachedMin = GetEventValue(0, "config_min"); + uint32 cachedMax = GetEventValue(0, "config_max"); + + if (cachedMin != sPlayerbotAIConfig.minRandomBots || + cachedMax != sPlayerbotAIConfig.maxRandomBots) + { + sLog.outString("Bot count range changed from %d-%d to %d-%d, regenerating target...", + cachedMin, cachedMax, + sPlayerbotAIConfig.minRandomBots, sPlayerbotAIConfig.maxRandomBots); + + SetEventValue(0, "bot_count", 0, 0); // Invalidate + SetEventValue(0, "config_min", sPlayerbotAIConfig.minRandomBots, 999999); + SetEventValue(0, "config_max", sPlayerbotAIConfig.maxRandomBots, 999999); + } + int maxAllowedBotCount = GetEventValue(0, "bot_count"); if (!maxAllowedBotCount) { @@ -228,6 +243,19 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot) return true; } + // Check if bot level is outside configured min/max range + uint32 botLevel = player->getLevel(); + uint32 maxLevel = sPlayerbotAIConfig.randomBotMaxLevel; + if (maxLevel > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) + maxLevel = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); + if (botLevel < sPlayerbotAIConfig.randomBotMinLevel || botLevel > maxLevel) + { + sLog.outDetail("Bot %d level %d is outside valid range (%d-%d), scheduling immediate re-randomization", + bot, botLevel, sPlayerbotAIConfig.randomBotMinLevel, maxLevel); + ScheduleRandomize(bot, 0); + return true; + } + uint32 teleport = GetEventValue(bot, "teleport"); if (!teleport) { @@ -555,7 +583,6 @@ list RandomPlayerbotMgr::GetBots() vector RandomPlayerbotMgr::GetFreeBots(bool alliance) { set bots; - QueryResult* results = CharacterDatabase.PQuery( "SELECT `bot` FROM `ai_playerbot_random_bots` WHERE `event` = 'add'" ); @@ -599,7 +626,6 @@ vector RandomPlayerbotMgr::GetFreeBots(bool alliance) delete result; } - return guids; }