From 98ff69473c753d7406eb99a216b09dc2e5b11a85 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sat, 20 Apr 2024 00:30:11 +0800 Subject: [PATCH] [Avoid aoe] Fix avoid unit --- src/strategy/actions/MovementActions.cpp | 43 +++++++++++++----------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index 8fe7d750..66c4f7af 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -1613,26 +1613,29 @@ bool AvoidAoeAction::AvoidUnitWithDamageAura() if (!unit->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE)) { return false; } - Unit::AuraEffectList const& auras = unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL); - for (auto i = auras.begin(); i != auras.end(); ++i) - { - AuraEffect* aurEff = *i; - const SpellInfo* spellInfo = aurEff->GetSpellInfo(); - if (!spellInfo) - continue; - const SpellInfo* triggerSpellInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[aurEff->GetEffIndex()].TriggerSpell); - if (!triggerSpellInfo) - continue; - for (int j = 0; j < MAX_SPELL_EFFECTS; j++) { - if (triggerSpellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) { - float radius = triggerSpellInfo->Effects[j].CalcRadius(); - if (bot->GetDistance(unit) > radius) { - break; - } - std::ostringstream name; - name << "[" << triggerSpellInfo->SpellName[0] << "] (unit)"; - if (FleePostion(unit->GetPosition(), radius, name.str())) { - return true; + Unit::AuraEffectList const& aurasPeriodicTriggerSpell = unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL); + Unit::AuraEffectList const& aurasPeriodicTriggerWithValueSpell = unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE); + for (const Unit::AuraEffectList& list : {aurasPeriodicTriggerSpell, aurasPeriodicTriggerWithValueSpell}) { + for (auto i = list.begin(); i != list.end(); ++i) + { + AuraEffect* aurEff = *i; + const SpellInfo* spellInfo = aurEff->GetSpellInfo(); + if (!spellInfo) + continue; + const SpellInfo* triggerSpellInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[aurEff->GetEffIndex()].TriggerSpell); + if (!triggerSpellInfo) + continue; + for (int j = 0; j < MAX_SPELL_EFFECTS; j++) { + if (triggerSpellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) { + float radius = triggerSpellInfo->Effects[j].CalcRadius(); + if (bot->GetDistance(unit) > radius) { + break; + } + std::ostringstream name; + name << "[" << triggerSpellInfo->SpellName[0] << "] (unit)"; + if (FleePostion(unit->GetPosition(), radius, name.str())) { + return true; + } } } }