[Avoid aoe] Fix avoid unit

This commit is contained in:
Yunfan Li
2024-04-20 00:30:11 +08:00
parent a4f9783997
commit 98ff69473c

View File

@@ -1613,26 +1613,29 @@ bool AvoidAoeAction::AvoidUnitWithDamageAura()
if (!unit->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE)) { if (!unit->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE)) {
return false; return false;
} }
Unit::AuraEffectList const& auras = unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL); Unit::AuraEffectList const& aurasPeriodicTriggerSpell = unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL);
for (auto i = auras.begin(); i != auras.end(); ++i) Unit::AuraEffectList const& aurasPeriodicTriggerWithValueSpell = unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE);
{ for (const Unit::AuraEffectList& list : {aurasPeriodicTriggerSpell, aurasPeriodicTriggerWithValueSpell}) {
AuraEffect* aurEff = *i; for (auto i = list.begin(); i != list.end(); ++i)
const SpellInfo* spellInfo = aurEff->GetSpellInfo(); {
if (!spellInfo) AuraEffect* aurEff = *i;
continue; const SpellInfo* spellInfo = aurEff->GetSpellInfo();
const SpellInfo* triggerSpellInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[aurEff->GetEffIndex()].TriggerSpell); if (!spellInfo)
if (!triggerSpellInfo) continue;
continue; const SpellInfo* triggerSpellInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[aurEff->GetEffIndex()].TriggerSpell);
for (int j = 0; j < MAX_SPELL_EFFECTS; j++) { if (!triggerSpellInfo)
if (triggerSpellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) { continue;
float radius = triggerSpellInfo->Effects[j].CalcRadius(); for (int j = 0; j < MAX_SPELL_EFFECTS; j++) {
if (bot->GetDistance(unit) > radius) { if (triggerSpellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) {
break; float radius = triggerSpellInfo->Effects[j].CalcRadius();
} if (bot->GetDistance(unit) > radius) {
std::ostringstream name; break;
name << "[" << triggerSpellInfo->SpellName[0] << "] (unit)"; }
if (FleePostion(unit->GetPosition(), radius, name.str())) { std::ostringstream name;
return true; name << "[" << triggerSpellInfo->SpellName[0] << "] (unit)";
if (FleePostion(unit->GetPosition(), radius, name.str())) {
return true;
}
} }
} }
} }