From be3b2c82f8ef7fce15fc4e44fdd78ccf75917c30 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Tue, 4 Jun 2024 22:42:48 +0800 Subject: [PATCH] [Attack target] Fix --- src/strategy/values/AttackersValue.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/strategy/values/AttackersValue.cpp b/src/strategy/values/AttackersValue.cpp index ec82655b..fcfd1d9a 100644 --- a/src/strategy/values/AttackersValue.cpp +++ b/src/strategy/values/AttackersValue.cpp @@ -23,24 +23,25 @@ GuidVector AttackersValue::Calculate() if (Group* group = bot->GetGroup()) AddAttackersOf(group, targets); + + RemoveNonThreating(targets); + // prioritized target GuidVector prioritizedTargets = AI_VALUE(GuidVector, "prioritized targets"); for (ObjectGuid target : prioritizedTargets) { Unit* unit = botAI->GetUnit(target); - if (unit) { + if (unit && IsValidTarget(unit, bot)) { targets.insert(unit); } } if (Group* group = bot->GetGroup()) { ObjectGuid skullGuid = group->GetTargetIcon(4); Unit* skullTarget = botAI->GetUnit(skullGuid); - if (skullTarget) { + if (skullTarget && IsValidTarget(skullTarget, bot)) { targets.insert(skullTarget); } } - RemoveNonThreating(targets); - for (Unit* unit : targets) result.push_back(unit->GetGUID()); @@ -130,7 +131,7 @@ bool AttackersValue::hasRealThreat(Unit *attacker) attacker->IsAlive() && !attacker->IsPolymorphed() && // !attacker->isInRoots() && - !attacker->IsFriendlyTo(bot) && + !attacker->IsFriendlyTo(bot); (attacker->GetThreatMgr().getCurrentVictim() || dynamic_cast(attacker)); }