Skip to content

Commit 450db65

Browse files
bozimmermanbilly1arm
authored andcommitted
Notice and respect conf changes to min/max bots (#218)
1 parent a39def7 commit 450db65

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,23 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed)
5454
return;
5555
}
5656

57+
sLog.outBasic("Processing random bots...");
58+
59+
uint32 cachedMin = GetEventValue(0, "config_min");
60+
uint32 cachedMax = GetEventValue(0, "config_max");
61+
62+
if (cachedMin != sPlayerbotAIConfig.minRandomBots ||
63+
cachedMax != sPlayerbotAIConfig.maxRandomBots)
64+
{
65+
sLog.outString("Bot count range changed from %d-%d to %d-%d, regenerating target...",
66+
cachedMin, cachedMax,
67+
sPlayerbotAIConfig.minRandomBots, sPlayerbotAIConfig.maxRandomBots);
68+
69+
SetEventValue(0, "bot_count", 0, 0); // Invalidate
70+
SetEventValue(0, "config_min", sPlayerbotAIConfig.minRandomBots, 999999);
71+
SetEventValue(0, "config_max", sPlayerbotAIConfig.maxRandomBots, 999999);
72+
}
73+
5774
int maxAllowedBotCount = GetEventValue(0, "bot_count");
5875
if (!maxAllowedBotCount)
5976
{
@@ -286,6 +303,21 @@ bool RandomPlayerbotMgr::ProcessBot(Player* player)
286303
return true;
287304
}
288305

306+
// Check if bot level is outside configured min/max range
307+
uint32 botLevel = player->getLevel();
308+
uint32 maxLevel = sPlayerbotAIConfig.randomBotMaxLevel;
309+
if (maxLevel > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
310+
{
311+
maxLevel = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL);
312+
}
313+
if (botLevel < sPlayerbotAIConfig.randomBotMinLevel || botLevel > maxLevel)
314+
{
315+
sLog.outDetail("Bot %d level %d is outside valid range (%d-%d), scheduling immediate re-randomization",
316+
bot, botLevel, sPlayerbotAIConfig.randomBotMinLevel, maxLevel);
317+
ScheduleRandomize(bot, 0);
318+
return true;
319+
}
320+
289321
uint32 teleport = GetEventValue(bot, "teleport");
290322
if (!teleport)
291323
{

0 commit comments

Comments
 (0)