Skip to content

Instantly share code, notes, and snippets.

@tobmaps
Created May 31, 2011 20:59
Show Gist options
  • Save tobmaps/1001277 to your computer and use it in GitHub Desktop.
Save tobmaps/1001277 to your computer and use it in GitHub Desktop.
Dispel
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index c602a07..bd21a58 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -5006,6 +5006,48 @@ SpellCastResult Spell::CheckCast(bool strict)
break;
}
+ case SPELL_EFFECT_DISPEL:
+ {
+ Unit* target = m_targets.GetUnitTarget();
+ if (!target || i != 0 || m_spellInfo->DmgClass != SPELL_DAMAGE_CLASS_MAGIC)
+ break;
+
+ bool dispelAura = false;
+
+ // Create dispel mask by dispel type
+ uint32 dispelMask;
+ for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
+ if (m_spellInfo->Effects[j].Effect == SPELL_EFFECT_DISPEL)
+ dispelMask |= SpellInfo::GetDispelMask(DispelType(m_spellInfo->Effects[j].MiscValue));
+ // we should not be able to dispel diseases if the target is affected by unholy blight
+ if (dispelMask & (1 << DISPEL_DISEASE) && target->HasAura(50536))
+ dispelMask &= ~(1 << DISPEL_DISEASE);
+
+ Unit::AuraMap const& auras = target->GetOwnedAuras();
+ for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
+ {
+ Aura* aura = itr->second;
+
+ // don't try to remove passive auras
+ if (aura->IsPassive())
+ continue;
+
+ if (aura->GetSpellInfo()->GetDispelMask() & dispelMask)
+ {
+ // do not remove positive auras if friendly target
+ // negative auras if non-friendly target
+ if (aura->GetSpellInfo()->IsPositive() == target->IsFriendlyTo(m_caster))
+ continue;
+
+ dispelAura = true;
+ break;
+ }
+ }
+
+ if (!dispelAura)
+ return SPELL_FAILED_NOTHING_TO_DISPEL;
+ break;
+ }
case SPELL_EFFECT_POWER_BURN:
case SPELL_EFFECT_POWER_DRAIN:
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment