Index: game/Spell.cpp =================================================================== --- game/Spell.cpp (revision 5282) +++ 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 5282) +++ game/Unit.cpp (working copy) @@ -2774,15 +2775,59 @@ return SPELL_MISS_IMMUNE; // Try victim reflect spell - if (CanReflect) + if (CanReflect) { int32 reflectchance = pVictim->GetTotalAuraModifier(SPELL_AURA_REFLECT_SPELLS); 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; + } + // Try to reflect now if (reflectchance > 0 && roll_chance_i(reflectchance)) - return SPELL_MISS_REFLECT; + { + // Drop charges for: + // SPELL_AURA_REFLECT_SPELLS + Unit::AuraList const& mReflectSpells = pVictim->GetAurasByType(SPELL_AURA_REFLECT_SPELLS); + for(Unit::AuraList::const_iterator i = mReflectSpells.begin(); i != mReflectSpells.end(); ++i) + { + if((*i)->m_procCharges > 0) + (*i)->m_procCharges -= 1; + } + // 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)) + { + if((*i)->m_procCharges > 0) + (*i)->m_procCharges -= 1; + } + } + // Remove Auras with no charges: + // SPELL_AURA_REFLECT_SPELLS_SCHOOL + for(Unit::AuraList::const_iterator i = mReflectSpellsSchool.begin(), next; i != mReflectSpellsSchool.end(); i = next) + { + next = i; ++next; + if((*i)->m_procCharges == 0) + { + pVictim->RemoveAurasDueToSpell((*i)->GetId()); + next = mReflectSpellsSchool.begin(); + } + } + // SPELL_AURA_REFLECT_SPELLS + for(Unit::AuraList::const_iterator i = mReflectSpells.begin(), next; i != mReflectSpells.end(); i = next) + { + next = i; ++next; + if((*i)->m_procCharges == 0) + { + pVictim->RemoveAurasDueToSpell((*i)->GetId()); + next = mReflectSpells.begin(); + } + } + + return SPELL_MISS_REFLECT; + } } // TODO need add here hit result calculation for spells