Skip to content

Commit 9c8ba42

Browse files
authored
FIX: Battlegrounds - Unset bot's master when current master left BG (mod-playerbots#1819)
Adds a check for if current master left the BG and group, if so release set master and carry on in BG. This prevents multiple bots in (potentially multiple different) BG's to still consider you as their master when you yourself have left. - Applies when you join BGs with a party of bots.
1 parent e5bc495 commit 9c8ba42

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

src/PlayerbotAI.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,19 @@ void PlayerbotAI::UpdateAIGroupAndMaster()
367367
{
368368
if (!bot)
369369
return;
370+
371+
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
372+
if (!botAI)
373+
return;
374+
370375
Group* group = bot->GetGroup();
376+
377+
bool IsRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot);
378+
371379
// If bot is not in group verify that for is RandomBot before clearing master and resetting.
372380
if (!group)
373381
{
374-
if (master && sRandomPlayerbotMgr->IsRandomBot(bot))
382+
if (master && IsRandomBot)
375383
{
376384
SetMaster(nullptr);
377385
Reset(true);
@@ -380,12 +388,10 @@ void PlayerbotAI::UpdateAIGroupAndMaster()
380388
return;
381389
}
382390

383-
if (bot->InBattleground() && bot->GetBattleground()->GetBgTypeID() != BATTLEGROUND_AV)
384-
return;
385-
386-
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
387-
if (!botAI)
388-
return;
391+
// Bot in BG, but master no longer part of a group: release master
392+
// Exclude alt and addclass bots as they rely on current (real player) master, security-wise.
393+
if (bot->InBattleground() && IsRandomBot && master && !master->GetGroup())
394+
SetMaster(nullptr);
389395

390396
PlayerbotAI* masterBotAI = nullptr;
391397
if (master)

0 commit comments

Comments
 (0)