From c2dc0b62ce4bfd34f0678bc9c9e4c4ae7eb99e4b Mon Sep 17 00:00:00 2001 From: Neo2003 Date: Sun, 5 Oct 2008 15:17:41 -0500 Subject: [svn] * Make Grounding totem disappear after any spell redirection Patch provided by Albrecht de Endrau --HG-- branch : trunk --- src/game/Spell.cpp | 18 ++++++++++++++++-- src/game/Spell.h | 1 + src/game/SpellAuras.h | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index d97cc2c6f0d..7cefcc1de8f 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -267,6 +267,8 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi m_caster = Caster; m_selfContainer = NULL; m_triggeringContainer = triggeringContainer; + m_magnetPair.first = false; + m_magnetPair.second = NULL; m_deletable = true; m_delayAtDamageCount = 0; @@ -947,6 +949,14 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) if(!unit || !effectMask) return; + // remove spell_magnet aura after first spell redirect and destroy target if its totem + if(m_magnetPair.first && m_magnetPair.second && m_magnetPair.second == unit) + { + if(unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->isTotem()) + unit->DealDamage(unit,unit->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + return; + } + // Recheck immune (only for delayed spells) if( m_spellInfo->speed && ( unit->IsImmunedToDamage(GetSpellSchoolMask(m_spellInfo),true) || @@ -4837,7 +4847,7 @@ CurrentSpellTypes Spell::GetCurrentContainer() bool Spell::CheckTarget( Unit* target, uint32 eff, bool hitPhase ) { // Check targets for creature type mask and remove not appropriate (skip explicit self target case, maybe need other explicit targets) - if(m_spellInfo->EffectImplicitTargetA[eff]!=TARGET_SELF ) + if(m_spellInfo->EffectImplicitTargetA[eff]!=TARGET_SELF && !m_magnetPair.first) { if (!CheckTargetCreatureType(target)) return false; @@ -4918,8 +4928,12 @@ Unit* Spell::SelectMagnetTarget() { if(Unit* magnet = (*itr)->GetCaster()) { - if(magnet->IsWithinLOSInMap(m_caster)) + if((*itr)->m_procCharges>0 && magnet->IsWithinLOSInMap(m_caster)) { + (*itr)->SetAuraProcCharges((*itr)->m_procCharges-1); + m_magnetPair.first = true; + m_magnetPair.second = magnet; + target = magnet; m_targets.setUnitTarget(target); break; diff --git a/src/game/Spell.h b/src/game/Spell.h index d606fd71f34..62e5fdb40b2 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -335,6 +335,7 @@ class Spell void SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap); Unit* SelectMagnetTarget(); + std::pair m_magnetPair; bool CheckTarget( Unit* target, uint32 eff, bool hitPhase ); void SendCastResult(uint8 result); diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index 24b94202978..54beccf9dbf 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -283,6 +283,7 @@ class MANGOS_DLL_SPEC Aura void SetRemoveMode(AuraRemoveMode mode) { m_removeMode = mode; } int32 m_procCharges; + void SetAuraProcCharges(int32 charges) { m_procCharges = charges; } virtual Unit* GetTriggerTarget() const { return m_target; } -- cgit v1.2.3