[Attack target] Crash fix

This commit is contained in:
Yunfan Li
2024-06-02 23:22:20 +08:00
parent d5d1bb3904
commit 05236fddec
2 changed files with 26 additions and 24 deletions

View File

@@ -23,7 +23,7 @@ GuidVector AttackersValue::Calculate()
if (Group* group = bot->GetGroup())
AddAttackersOf(group, targets);
// prioritize target
// prioritized target
GuidVector prioritizedTargets = AI_VALUE(GuidVector, "prioritized targets");
for (ObjectGuid target : prioritizedTargets) {
Unit* unit = botAI->GetUnit(target);
@@ -31,10 +31,12 @@ GuidVector AttackersValue::Calculate()
targets.insert(unit);
}
}
ObjectGuid skullGuid = bot->GetGroup()->GetTargetIcon(4);
Unit* skullTarget = botAI->GetUnit(skullGuid);
if (skullTarget) {
targets.insert(skullTarget);
if (Group* group = bot->GetGroup()) {
ObjectGuid skullGuid = group->GetTargetIcon(4);
Unit* skullTarget = botAI->GetUnit(skullGuid);
if (skullTarget) {
targets.insert(skullTarget);
}
}
RemoveNonThreating(targets);