[Combat formation] Compatible with naxx and avoid aoe

This commit is contained in:
Yunfan Li
2024-09-26 20:01:10 +08:00
parent d1a744fca3
commit 8d524cdaf0
5 changed files with 66 additions and 20 deletions

View File

@@ -2090,6 +2090,25 @@ bool PlayerbotAI::IsMainTank(Player* player)
return false; return false;
} }
uint32 PlayerbotAI::GetGroupTankNum(Player* player)
{
Group* group = player->GetGroup();
if (!group)
{
return 0;
}
uint32 result = 0;
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
{
Player* member = ref->GetSource();
if (IsTank(member) && member->IsAlive())
{
result++;
}
}
return result;
}
bool PlayerbotAI::IsAssistTank(Player* player) { return IsTank(player) && !IsMainTank(player); } bool PlayerbotAI::IsAssistTank(Player* player) { return IsTank(player) && !IsMainTank(player); }
bool PlayerbotAI::IsAssistTankOfIndex(Player* player, int index) bool PlayerbotAI::IsAssistTankOfIndex(Player* player, int index)

View File

@@ -410,6 +410,7 @@ public:
static bool IsCombo(Player* player, bool bySpec = false); static bool IsCombo(Player* player, bool bySpec = false);
static bool IsRangedDps(Player* player, bool bySpec = false); static bool IsRangedDps(Player* player, bool bySpec = false);
static bool IsMainTank(Player* player); static bool IsMainTank(Player* player);
static uint32 GetGroupTankNum(Player* player);
bool IsAssistTank(Player* player); bool IsAssistTank(Player* player);
bool IsAssistTankOfIndex(Player* player, int index); bool IsAssistTankOfIndex(Player* player, int index);
bool IsHealAssistantOfIndex(Player* player, int index); bool IsHealAssistantOfIndex(Player* player, int index);

View File

@@ -525,7 +525,10 @@ void PlayerbotHolder::OnBotLogin(Player* const bot)
sGroupMgr->AddGroup(newGroup); sGroupMgr->AddGroup(newGroup);
newGroup->AddMember(bot); newGroup->AddMember(bot);
} }
// if (master)
// {
// // bot->TeleportTo(master);
// }
uint32 accountId = bot->GetSession()->GetAccountId(); uint32 accountId = bot->GetSession()->GetAccountId();
bool isRandomAccount = sPlayerbotAIConfig->IsInRandomAccountList(accountId); bool isRandomAccount = sPlayerbotAIConfig->IsInRandomAccountList(accountId);

View File

@@ -1883,16 +1883,7 @@ bool AvoidAoeAction::AvoidGameObjectWithDamage()
float radius = (float)goInfo->trap.diameter / 2 + go->GetCombatReach(); float radius = (float)goInfo->trap.diameter / 2 + go->GetCombatReach();
if (!radius || radius > sPlayerbotAIConfig->maxAoeAvoidRadius) if (!radius || radius > sPlayerbotAIConfig->maxAoeAvoidRadius)
continue; continue;
// for (int i = 0; i < MAX_SPELL_EFFECTS; i++) {
// if (spellInfo->Effects[i].Effect == SPELL_EFFECT_APPLY_AURA) {
// if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE) {
// radius = spellInfo->Effects[i].CalcRadius();
// break;
// }
// } else if (spellInfo->Effects[i].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) {
// break;
// }
// }
if (bot->GetDistance(go) > radius) if (bot->GetDistance(go) > radius)
{ {
continue; continue;
@@ -2352,13 +2343,27 @@ bool TankFaceAction::Execute(Event event)
target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle1); target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle1);
if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(),
x, y, z)) x, y, z))
{
/// @todo: movement control now is a mess, prepare to rewrite
std::list<FleeInfo>& infoList = AI_VALUE(std::list<FleeInfo>&, "recently flee info");
Position pos(x, y, z);
float angle = bot->GetAngle(&pos);
if (CheckLastFlee(angle, infoList))
{ {
availablePos.push_back(Position(x, y, z)); availablePos.push_back(Position(x, y, z));
} }
}
target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle2); target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle2);
if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(),
x, y, z)) x, y, z))
{ {
std::list<FleeInfo>& infoList = AI_VALUE(std::list<FleeInfo>&, "recently flee info");
Position pos(x, y, z);
float angle = bot->GetAngle(&pos);
if (CheckLastFlee(angle, infoList))
{
availablePos.push_back(Position(x, y, z));
}
availablePos.push_back(Position(x, y, z)); availablePos.push_back(Position(x, y, z));
} }
if (availablePos.empty()) if (availablePos.empty())
@@ -2531,12 +2536,27 @@ bool SetBehindTargetAction::Execute(Event event)
if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(),
x, y, z)) x, y, z))
{ {
/// @todo: movement control now is a mess, prepare to rewrite
std::list<FleeInfo>& infoList = AI_VALUE(std::list<FleeInfo>&, "recently flee info");
Position pos(x, y, z);
float angle = bot->GetAngle(&pos);
if (CheckLastFlee(angle, infoList))
{
availablePos.push_back(Position(x, y, z));
}
availablePos.push_back(Position(x, y, z)); availablePos.push_back(Position(x, y, z));
} }
target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle2); target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle2);
if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(),
x, y, z)) x, y, z))
{ {
std::list<FleeInfo>& infoList = AI_VALUE(std::list<FleeInfo>&, "recently flee info");
Position pos(x, y, z);
float angle = bot->GetAngle(&pos);
if (CheckLastFlee(angle, infoList))
{
availablePos.push_back(Position(x, y, z));
}
availablePos.push_back(Position(x, y, z)); availablePos.push_back(Position(x, y, z));
} }
if (availablePos.empty()) if (availablePos.empty())

View File

@@ -27,7 +27,7 @@ float GrobbulusMultiplier::GetValue(Action* action)
{ {
return 1.0f; return 1.0f;
} }
if (dynamic_cast<AvoidAoeAction*>(action)) if (dynamic_cast<AvoidAoeAction*>(action) || dynamic_cast<CombatFormationMoveAction*>(action))
{ {
return 0.0f; return 0.0f;
} }
@@ -48,7 +48,7 @@ float HeiganDanceMultiplier::GetValue(Action* action)
uint32 curr_dance = eventMap->GetNextEventTime(4); uint32 curr_dance = eventMap->GetNextEventTime(4);
uint32 curr_timer = eventMap->GetTimer(); uint32 curr_timer = eventMap->GetTimer();
uint32 curr_erupt = eventMap->GetNextEventTime(3); uint32 curr_erupt = eventMap->GetNextEventTime(3);
if (dynamic_cast<SetBehindTargetAction*>(action)) if (dynamic_cast<CombatFormationMoveAction*>(action))
{ {
return 0.0f; return 0.0f;
} }
@@ -87,7 +87,8 @@ float LoathebGenericMultiplier::GetValue(Action* action)
context->GetValue<bool>("neglect threat")->Set(true); context->GetValue<bool>("neglect threat")->Set(true);
if (botAI->GetState() == BOT_STATE_COMBAT && if (botAI->GetState() == BOT_STATE_COMBAT &&
(dynamic_cast<DpsAssistAction*>(action) || dynamic_cast<TankAssistAction*>(action) || (dynamic_cast<DpsAssistAction*>(action) || dynamic_cast<TankAssistAction*>(action) ||
dynamic_cast<CastDebuffSpellOnAttackerAction*>(action) || dynamic_cast<FleeAction*>(action))) dynamic_cast<CastDebuffSpellOnAttackerAction*>(action) || dynamic_cast<FleeAction*>(action) ||
dynamic_cast<CombatFormationMoveAction*>(action)))
{ {
return 0.0f; return 0.0f;
} }
@@ -113,7 +114,8 @@ float ThaddiusGenericMultiplier::GetValue(Action* action)
if (helper.IsPhasePet() && if (helper.IsPhasePet() &&
(dynamic_cast<DpsAssistAction*>(action) || dynamic_cast<TankAssistAction*>(action) || (dynamic_cast<DpsAssistAction*>(action) || dynamic_cast<TankAssistAction*>(action) ||
dynamic_cast<CastDebuffSpellOnAttackerAction*>(action) || dynamic_cast<CastDebuffSpellOnAttackerAction*>(action) ||
dynamic_cast<ReachPartyMemberToHealAction*>(action) || dynamic_cast<BuffOnMainTankAction*>(action))) dynamic_cast<ReachPartyMemberToHealAction*>(action) || dynamic_cast<BuffOnMainTankAction*>(action) ||
dynamic_cast<CombatFormationMoveAction*>(action)))
{ {
return 0.0f; return 0.0f;
} }
@@ -151,7 +153,8 @@ float SapphironGenericMultiplier::GetValue(Action* action)
{ {
return 1.0f; return 1.0f;
} }
if (dynamic_cast<FollowAction*>(action) || dynamic_cast<CastDeathGripAction*>(action)) if (dynamic_cast<FollowAction*>(action) || dynamic_cast<CastDeathGripAction*>(action) ||
dynamic_cast<CombatFormationMoveAction*>(action))
{ {
return 0.0f; return 0.0f;
} }