Jump to content

Fix handling of SPELL_AURA_ADD_TARGET_TRIGGER auras


Auntie Mangos

Recommended Posts

* What bug does the patch fix? What features does the patch add?

Fix handling of SPELL_AURA_ADD_TARGET_TRIGGER auras.

e.g. fix Shadow Weaving proccing from Mind Flay. Periodic trigger from Mind Flay in casted by target with original caster guid.

* For which repository revision was the patch created?

11956

* Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.

don't know

http://getmangos.eu/community/topic/13391/2x-bug-mind-sear-priest/

* Who has been writing this patch? Please include either forum user names or email addresses.

me

http://paste2.org/p/1978871

src/game/Spell.cpp |   54 ++++++++++++++++++++++++++++-----------------------
1 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index ab9f141..099c1dd 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -3547,30 +3547,36 @@ void Spell::finish(bool ok)
    if (!ok)
        return;

-    // handle SPELL_AURA_ADD_TARGET_TRIGGER auras
-    Unit::AuraList const& targetTriggers = m_caster->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER);
-    for(Unit::AuraList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i)
-    {
-        if (!(*i)->isAffectedOnSpell(m_spellInfo))
-            continue;
-        for(TargetList::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
-        {
-            if (ihit->missCondition == SPELL_MISS_NONE)
-            {
-                // check m_caster->GetGUID() let load auras at login and speedup most often case
-                Unit *unit = m_caster->GetObjectGuid() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
-                if (unit && unit->isAlive())
-                {
-                    SpellEntry const *auraSpellInfo = (*i)->GetSpellProto();
-                    SpellEffectIndex auraSpellIdx = (*i)->GetEffIndex();
-                    // Calculate chance at that moment (can be depend for example from combo points)
-                    int32 auraBasePoints = (*i)->GetBasePoints();
-                    int32 chance = m_caster->CalculateSpellDamage(unit, auraSpellInfo, auraSpellIdx, &auraBasePoints);
-                    if(roll_chance_i(chance))
-                        m_caster->CastSpell(unit, auraSpellInfo->EffectTriggerSpell[auraSpellIdx], true, NULL, (*i));
-                }
-            }
-        }
+    if (Unit* caster = GetAffectiveCaster())
+    {
+        Unit::AuraList const& targetTriggers = caster->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER);
+        for (Unit::AuraList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i)
+        {
+            if (!(*i)->isAffectedOnSpell(m_spellInfo))
+                continue;
+
+            for (TargetList::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
+            {
+                if (ihit->deleted)
+                    continue;
+
+                if (ihit->missCondition == SPELL_MISS_NONE)
+                {
+                    // check caster->GetGUID() let load auras at login and speedup most often case
+                    Unit* unit = caster->GetObjectGuid() == ihit->targetGUID ? caster : ObjectAccessor::GetUnit(*caster, ihit->targetGUID);
+                    if (unit && unit->isAlive())
+                    {
+                        SpellEntry const * auraSpellInfo = (*i)->GetSpellProto();
+                        SpellEffectIndex auraSpellIdx = (*i)->GetEffIndex();
+                        // Calculate chance at that moment (can be depend for example from combo points)
+                        int32 auraBasePoints = (*i)->GetBasePoints();
+                        int32 chance = caster->CalculateSpellDamage(unit, auraSpellInfo, auraSpellIdx, &auraBasePoints);
+                        if (roll_chance_i(chance))
+                            caster->CastSpell(unit, auraSpellInfo->EffectTriggerSpell[auraSpellIdx], true, NULL, (*i));
+                    }
+                }
+            }
+        }
    }

    // Heal caster for all health leech from all targets

Link to comment
Share on other sites

  • 42 years later...
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use