From 4cb8ff7f26d1e26e0840153d8f4fddbb616346a5 Mon Sep 17 00:00:00 2001 From: megamage Date: Sat, 14 Mar 2009 21:30:03 -0600 Subject: *Fix the case that trap spell is casted on target self. --HG-- branch : trunk --- src/game/GameObject.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/game/GameObject.cpp') diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 583bcab36c4..95a83ce6819 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -1364,8 +1364,28 @@ void GameObject::Use(Unit* user) spell->prepare(&targets); } -void GameObject::CastSpell(Unit* target, uint32 spell) +void GameObject::CastSpell(Unit* target, uint32 spellId) { + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); + if(!spellInfo) + return; + + bool self = false; + for(int i = 0; i < 3; ++i) + { + if(spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_CASTER) + { + self = true; + break; + } + } + + if(self) + { + target->CastSpell(target, spellInfo, true); + return; + } + //summon world trigger Creature *trigger = SummonTrigger(GetPositionX(), GetPositionY(), GetPositionZ(), 0, 1); if(!trigger) return; @@ -1374,12 +1394,12 @@ void GameObject::CastSpell(Unit* target, uint32 spell) if(Unit *owner = GetOwner()) { trigger->setFaction(owner->getFaction()); - trigger->CastSpell(target, spell, true, 0, 0, owner->GetGUID()); + trigger->CastSpell(target, spellInfo, true, 0, 0, owner->GetGUID()); } else { trigger->setFaction(14); - trigger->CastSpell(target, spell, true, 0, 0, target->GetGUID()); + trigger->CastSpell(target, spellInfo, true, 0, 0, target->GetGUID()); } //trigger->setDeathState(JUST_DIED); //trigger->RemoveCorpse(); -- cgit v1.2.3