Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -555,7 +583,6 @@ list<uint32> RandomPlayerbotMgr::GetBots()
vector<uint32> RandomPlayerbotMgr::GetFreeBots(bool alliance)
{
set<uint32> bots;

QueryResult* results = CharacterDatabase.PQuery(
"SELECT `bot` FROM `ai_playerbot_random_bots` WHERE `event` = 'add'"
);
Expand Down Expand Up @@ -599,7 +626,6 @@ vector<uint32> RandomPlayerbotMgr::GetFreeBots(bool alliance)
delete result;
}


return guids;
}

Expand Down