mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Merge branch 'liyunfan1223:master' into razorscale_final
This commit is contained in:
@@ -25,8 +25,4 @@ bool PartyMemberNeedCureTrigger::IsActive()
|
|||||||
return target && target->IsInWorld();
|
return target && target->IsInWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NeedWorldBuffTrigger::IsActive()
|
bool NeedWorldBuffTrigger::IsActive() { return !WorldBuffAction::NeedWorldBuffs(bot).empty(); }
|
||||||
{
|
|
||||||
std::any_of(WorldBuffAction::NeedWorldBuffs(bot).begin(), WorldBuffAction::NeedWorldBuffs(bot).end(),
|
|
||||||
[](const auto& wb) { return true; });
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -413,79 +413,83 @@ float Formation::GetFollowAngle()
|
|||||||
Group* group = bot->GetGroup();
|
Group* group = bot->GetGroup();
|
||||||
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
|
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
|
||||||
|
|
||||||
|
// If there's no master and no group
|
||||||
|
if (!master && !group)
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
uint32 index = 1;
|
uint32 index = 1;
|
||||||
uint32 total = 1;
|
uint32 total = 1;
|
||||||
|
|
||||||
PlayerbotMgr* masterBotMgr = nullptr;
|
std::vector<Player*> roster;
|
||||||
if (master)
|
|
||||||
masterBotMgr = GET_PLAYERBOT_MGR(master);
|
|
||||||
if (!group && master && !GET_PLAYERBOT_AI(master) && masterBotMgr)
|
|
||||||
{
|
|
||||||
for (PlayerBotMap::const_iterator i = masterBotMgr->GetPlayerBotsBegin(); i != masterBotMgr->GetPlayerBotsEnd();
|
|
||||||
++i)
|
|
||||||
{
|
|
||||||
if (i->second == bot)
|
|
||||||
index = total;
|
|
||||||
|
|
||||||
++total;
|
if (group)
|
||||||
|
{
|
||||||
|
bool left = true; // Used for alternating tanks' positions
|
||||||
|
|
||||||
|
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
|
||||||
|
{
|
||||||
|
Player* member = ref->GetSource();
|
||||||
|
|
||||||
|
// Skip invalid, dead, or out-of-map members
|
||||||
|
if (!member || !member->IsAlive() || bot->GetMapId() != member->GetMapId())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Skip the master
|
||||||
|
if (member == master)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Put DPS in the middle
|
||||||
|
if (!botAI->IsTank(member) && !botAI->IsHeal(member))
|
||||||
|
{
|
||||||
|
roster.insert(roster.begin() + roster.size() / 2, member);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Put Healers in the middle
|
||||||
|
else if (botAI->IsHeal(member))
|
||||||
|
{
|
||||||
|
roster.insert(roster.begin() + roster.size() / 2, member);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle tanks (alternate between front and back)
|
||||||
|
else if (botAI->IsTank(member))
|
||||||
|
{
|
||||||
|
if (left)
|
||||||
|
roster.push_back(member); // Place tank at the back
|
||||||
|
else
|
||||||
|
roster.insert(roster.begin(), member); // Place tank at the front
|
||||||
|
|
||||||
|
left = !left; // Alternate for the next tank
|
||||||
|
}
|
||||||
|
|
||||||
|
total++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (group)
|
else if (master)
|
||||||
{
|
{
|
||||||
std::vector<Player*> roster;
|
// If the bot is following a master, look up the bot's position in the master's list
|
||||||
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
|
PlayerbotMgr* masterBotMgr = GET_PLAYERBOT_MGR(master);
|
||||||
|
if (masterBotMgr && !GET_PLAYERBOT_AI(master))
|
||||||
{
|
{
|
||||||
if (Player* member = ref->GetSource())
|
for (auto it = masterBotMgr->GetPlayerBotsBegin(); it != masterBotMgr->GetPlayerBotsEnd(); ++it)
|
||||||
{
|
{
|
||||||
if (!member || member == bot || !member->IsAlive() || bot->GetMapId() != member->GetMapId()) continue;
|
if (it->second == bot)
|
||||||
if (member != master && !botAI->IsTank(member) && !botAI->IsHeal(member))
|
|
||||||
{
|
{
|
||||||
roster.insert(roster.begin() + roster.size() / 2, member);
|
index = total; // Found bot in master's list, set the index
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
++total;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
|
|
||||||
{
|
|
||||||
if (Player* member = ref->GetSource())
|
|
||||||
{
|
|
||||||
if (!member || member == bot || !member->IsAlive() || bot->GetMapId() != member->GetMapId()) continue;
|
|
||||||
if (member != master && botAI->IsHeal(member))
|
|
||||||
{
|
|
||||||
roster.insert(roster.begin() + roster.size() / 2, member);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool left = true;
|
|
||||||
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
|
|
||||||
{
|
|
||||||
if (Player* member = ref->GetSource())
|
|
||||||
{
|
|
||||||
if (!member || member == bot || !member->IsAlive() || bot->GetMapId() != member->GetMapId()) continue;
|
|
||||||
if (member != master && botAI->IsTank(member))
|
|
||||||
{
|
|
||||||
if (left)
|
|
||||||
roster.push_back(member);
|
|
||||||
else
|
|
||||||
roster.insert(roster.begin(), member);
|
|
||||||
|
|
||||||
left = !left;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player* playerRoster : roster)
|
|
||||||
{
|
|
||||||
if (playerRoster == bot)
|
|
||||||
break;
|
|
||||||
|
|
||||||
++index;
|
|
||||||
}
|
|
||||||
|
|
||||||
total = roster.size() + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find the bot's position in the roster
|
||||||
|
auto it = std::find(roster.begin(), roster.end(), bot);
|
||||||
|
if (it != roster.end())
|
||||||
|
{
|
||||||
|
index = std::distance(roster.begin(), it) + 1; // Find bot's index in the roster
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return
|
||||||
float start = (master ? master->GetOrientation() : 0.0f);
|
float start = (master ? master->GetOrientation() : 0.0f);
|
||||||
return start + (0.125f + 1.75f * index / total + (total == 2 ? 0.125f : 0.0f)) * M_PI;
|
return start + (0.125f + 1.75f * index / total + (total == 2 ? 0.125f : 0.0f)) * M_PI;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user