diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 414b4b22..4292a48b 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -367,11 +367,19 @@ void PlayerbotAI::UpdateAIGroupAndMaster() { if (!bot) return; + + PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); + if (!botAI) + return; + Group* group = bot->GetGroup(); + + bool IsRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot); + // If bot is not in group verify that for is RandomBot before clearing master and resetting. if (!group) { - if (master && sRandomPlayerbotMgr->IsRandomBot(bot)) + if (master && IsRandomBot) { SetMaster(nullptr); Reset(true); @@ -380,12 +388,10 @@ void PlayerbotAI::UpdateAIGroupAndMaster() return; } - if (bot->InBattleground() && bot->GetBattleground()->GetBgTypeID() != BATTLEGROUND_AV) - return; - - PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - if (!botAI) - return; + // Bot in BG, but master no longer part of a group: release master + // Exclude alt and addclass bots as they rely on current (real player) master, security-wise. + if (bot->InBattleground() && IsRandomBot && master && !master->GetGroup()) + SetMaster(nullptr); PlayerbotAI* masterBotAI = nullptr; if (master)