Merge pull request #845 from liyunfan1223/lfg_leave

Remove from group when no real player in lfg group
This commit is contained in:
Yunfan Li
2025-01-04 18:36:49 +08:00
committed by GitHub

View File

@@ -406,6 +406,27 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal)
}
}
if (bot->GetGroup() && bot->GetGroup()->isLFGGroup())
{
bool hasRealPlayer = false;
for (GroupReference* ref = bot->GetGroup()->GetFirstMember(); ref; ref = ref->next())
{
Player* member = ref->GetSource();
if (!member)
continue;
PlayerbotAI* memberAI = GET_PLAYERBOT_AI(member);
if (memberAI && !memberAI->IsRealPlayer())
continue;
hasRealPlayer = true;
break;
}
if (!hasRealPlayer)
{
bot->RemoveFromGroup();
ResetStrategies();
}
}
bool min = minimal;
UpdateAIInternal(elapsed, min);
YieldThread(GetReactDelay());