All pastes #914938 Raw Edit

Unnamed

public text v1 · immutable
#914938 ·published 2008-02-23 10:33 UTC
rendered paste body
Index: game/Spell.cpp
===================================================================
--- game/Spell.cpp	(revision 5279)
+++ game/Spell.cpp	(working copy)
@@ -325,7 +325,7 @@
     // determine reflection
     m_canReflect = false;
 
-    if(m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && (m_spellInfo->AttributesEx2 & 0x4)==0)
+    if(m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && (m_spellInfo->AttributesEx & 0x80)==0)
     {
         for(int j=0;j<3;j++)
         {
Index: game/Unit.cpp
===================================================================
--- game/Unit.cpp	(revision 5279)
+++ game/Unit.cpp	(working copy)
@@ -2777,10 +2778,46 @@
     if (CanReflect)
     {
         int32 reflectchance = pVictim->GetTotalAuraModifier(SPELL_AURA_REFLECT_SPELLS);
+        // Drop charges for SPELL_AURA_REFLECT_SPELLS
+        Unit::AuraList const& mReflectSpells = pVictim->GetAurasByType(SPELL_AURA_REFLECT_SPELLS_SCHOOL);
+        for(AuraList::const_iterator i = mReflectSpells.begin(); i != mReflectSpells.end(); ++i)
+        {
+            if((*i)->m_procCharges > 0)
+                (*i)->m_procCharges -= 1;
+        }
+        // Get school based reflect and drop their charges
         Unit::AuraList const& mReflectSpellsSchool = pVictim->GetAurasByType(SPELL_AURA_REFLECT_SPELLS_SCHOOL);
         for(Unit::AuraList::const_iterator i = mReflectSpellsSchool.begin(); i != mReflectSpellsSchool.end(); ++i)
+        {
             if((*i)->GetModifier()->m_miscvalue & int32(1 << spell->School))
+            {
                 reflectchance += (*i)->GetModifier()->m_amount;
+                if((*i)->m_procCharges > 0)
+                    (*i)->m_procCharges -= 1;
+            }
+        }
+        // Remove Auras with no charges
+        // School based
+        for(AuraList::const_iterator i = mReflectSpellsSchool.begin(), next; i != mReflectSpellsSchool.end(); i = next)
+        {
+            next = i; ++next;
+            if((*i)->m_procCharges == 0)
+            {
+                RemoveAurasDueToSpell((*i)->GetId());
+                next = mReflectSpellsSchool.begin();
+            }
+        }
+        // General
+        for(AuraList::const_iterator i = mReflectSpells.begin(), next; i != mReflectSpells.end(); i = next)
+        {
+            next = i; ++next;
+            if((*i)->m_procCharges == 0)
+            {
+                RemoveAurasDueToSpell((*i)->GetId());
+                next = mReflectSpells.begin();
+            }
+        }
+        // Try to reflect now
         if (reflectchance > 0 && roll_chance_i(reflectchance))
             return SPELL_MISS_REFLECT;
     }