All pastes #1171404 Raw Edit

Miscellany

public text v1 · immutable
#1171404 ·published 2008-08-14 12:52 UTC
rendered paste body
Index: game/Spell.cpp
===================================================================
--- game/Spell.cpp	(revision 6458)
+++ game/Spell.cpp	(working copy)
@@ -4898,18 +4898,46 @@
 {
     Unit* target = m_targets.getUnitTarget();
 
-    if(target && target->HasAuraType(SPELL_AURA_SPELL_MAGNET) && !(m_spellInfo->Attributes & 0x10))
-    {
-        Unit::AuraList const& magnetAuras = target->GetAurasByType(SPELL_AURA_SPELL_MAGNET);
-        for(Unit::AuraList::const_iterator itr = magnetAuras.begin(); itr != magnetAuras.end(); ++itr)
+    if(target)
+	{
+        if (m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC)
+		{
+			if (target->HasAuraType(SPELL_AURA_SPELL_MAGNET) && !(m_spellInfo->Attributes & 0x10))
+            {
+                Unit::AuraList const& magnetAuars = target->GetAurasByType(SPELL_AURA_SPELL_MAGNET);
+                for(Unit::AuraList::const_iterator itr = magnetAuars.begin(); itr != magnetAuars.end(); ++itr)
+                {
+                    if(Unit* magnet = (*itr)->GetCaster())
+                    {
+                        if(magnet->IsWithinLOSInMap(m_caster))
+                        {
+                            target = magnet;
+                            m_targets.setUnitTarget(target);
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+		else if ( m_spellInfo->DmgClass != SPELL_DAMAGE_CLASS_NONE )
         {
-            if(Unit* magnet = (*itr)->GetCaster())
+			if (target->HasAuraType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER) && !(m_spellInfo->Attributes & 0x10))
             {
-                if(magnet->IsWithinLOSInMap(m_caster))
+                Unit::AuraList const& magnetAuars = target->GetAurasByType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER);
+                for(Unit::AuraList::const_iterator itr = magnetAuars.begin(); itr != magnetAuars.end(); ++itr)
                 {
-                    target = magnet;
-                    m_targets.setUnitTarget(target);
-                    break;
+				    float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry((*itr)->GetSpellProto()->EffectRadiusIndex[(*itr)->GetEffIndex()]));
+                    
+                    Unit* magnet = (*itr)->GetCaster();
+                    if(magnet && magnet->IsWithinDistInMap(target,radius))
+                    {
+                        if(magnet->IsWithinLOSInMap(m_caster))
+                        {
+                            target = magnet;
+                            m_targets.setUnitTarget(target);
+                            break;
+                        }
+                    }
                 }
             }
         }
Index: game/Unit.cpp
===================================================================
--- game/Unit.cpp	(revision 6458)
+++ game/Unit.cpp	(working copy)
@@ -2167,6 +2167,24 @@
         return;
     }
 
+    // redirection
+    if (pVictim->HasAuraType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER))
+    {
+        AuraList const& magnetAuars = pVictim->GetAurasByType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER);
+        for(AuraList::const_iterator itr = magnetAuars.begin(); itr != magnetAuars.end(); ++itr)
+        {
+            if(Unit* magnet = (*itr)->GetCaster())
+            {
+				float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry((*itr)->GetSpellProto()->EffectRadiusIndex[(*itr)->GetEffIndex()]));
+                if(magnet->IsWithinDistInMap(pVictim,radius) && IsWithinLOSInMap(magnet) && magnet->isAlive())
+                {
+                    pVictim = magnet;
+                    break;
+                }
+            }
+        }
+    }
+
     VictimState victimState = VICTIMSTATE_NORMAL;
 
     CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );