[Attack target] Fix

This commit is contained in:
Yunfan Li
2024-06-04 22:42:48 +08:00
parent 5f40c39e5e
commit be3b2c82f8

View File

@@ -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<Player*>(attacker));
}