From 67f8ec608c09b039f96dd321f83a18da31f453af Mon Sep 17 00:00:00 2001 From: QAston Date: Sun, 5 Jul 2009 16:58:42 +0200 Subject: *Allow dest target spells to proc spellcast. *Allow source target spells to be triggered during spellproc if no unit target avalible. --HG-- branch : trunk --- src/game/Spell.cpp | 33 +++++++++++++++++++++++++++++++++ src/game/SpellMgr.cpp | 11 +++++++++++ src/game/SpellMgr.h | 2 ++ src/game/Unit.cpp | 10 +++++----- 4 files changed, 51 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 00c47a5cc4e..a0cd094a27b 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -3076,6 +3076,7 @@ void Spell::_handle_immediate_phase() if(!m_originalCaster) return; + uint8 oldEffMask = m_effectMask; // process ground for(uint32 j = 0; j < 3; ++j) { @@ -3092,6 +3093,38 @@ void Spell::_handle_immediate_phase() m_effectMask |= (1<Id, i)) + { + positive = false; + break; + } + switch(m_spellInfo->DmgClass) + { + case SPELL_DAMAGE_CLASS_MAGIC: + if (positive) + procAttacker |= PROC_FLAG_SUCCESSFUL_POSITIVE_MAGIC_SPELL; + else + procAttacker |= PROC_FLAG_SUCCESSFUL_NEGATIVE_MAGIC_SPELL; + break; + case SPELL_DAMAGE_CLASS_NONE: + if (positive) + procAttacker |= PROC_FLAG_SUCCESSFUL_POSITIVE_SPELL_HIT; + else + procAttacker |= PROC_FLAG_SUCCESSFUL_NEGATIVE_SPELL_HIT; + break; + } + } + // Proc damage for spells which have only dest targets (2484 should proc 51486 for example) + m_originalCaster->ProcDamageAndSpell(0, procAttacker, 0, m_procEx | PROC_EX_NORMAL_HIT, 0, BASE_ATTACK, m_spellInfo, m_triggeredByAuraSpell); + } } void Spell::_handle_finish_phase() diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index b99997dd526..32759951f84 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -236,6 +236,7 @@ SpellMgr::SpellMgr() } } + SpellMgr::~SpellMgr() { } @@ -246,6 +247,16 @@ SpellMgr& SpellMgr::Instance() return spellMgr; } +bool SpellMgr::IsSrcTargetSpell(SpellEntry const *spellInfo) const +{ + for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i) + { + if(SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_AREA_SRC || SpellTargetType[spellInfo->EffectImplicitTargetB[i]] == TARGET_TYPE_AREA_SRC) + return true; + } + return false; +} + int32 GetSpellDuration(SpellEntry const *spellInfo) { if(!spellInfo) diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 38c64e9cb92..6c192f5b309 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -1042,6 +1042,8 @@ class SpellMgr return SpellAreaForAreaMapBounds(mSpellAreaForAreaMap.lower_bound(area_id),mSpellAreaForAreaMap.upper_bound(area_id)); } + bool SpellMgr::IsSrcTargetSpell(SpellEntry const *spellInfo) const; + // Modifiers public: static SpellMgr& Instance(); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 70afcf91803..f0ac89d849e 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -4829,7 +4829,7 @@ bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger } // default case - if(!target || target!=this && !target->isAlive()) + if((!target && !spellmgr.IsSrcTargetSpell(triggerEntry)) || (target && target!=this && !target->isAlive())) return false; if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) @@ -6944,7 +6944,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger } // default case - if(!target || target!=this && !target->isAlive()) + if((!target && !spellmgr.IsSrcTargetSpell(triggerEntry)) || (target && target!=this && !target->isAlive())) return false; if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) @@ -7002,7 +7002,7 @@ bool Unit::HandleObsModEnergyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* } // default case - if(!target || target!=this && !target->isAlive()) + if((!target && !spellmgr.IsSrcTargetSpell(triggerEntry)) || (target && target!=this && !target->isAlive())) return false; if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) @@ -7059,7 +7059,7 @@ bool Unit::HandleModDamagePctTakenAuraProc(Unit *pVictim, uint32 damage, AuraEff } // default case - if(!target || target!=this && !target->isAlive()) + if((!target && !spellmgr.IsSrcTargetSpell(triggerEntry)) || (target && target!=this && !target->isAlive())) return false; if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) @@ -7870,7 +7870,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig target = !(procFlags & (PROC_FLAG_SUCCESSFUL_POSITIVE_MAGIC_SPELL | PROC_FLAG_SUCCESSFUL_POSITIVE_SPELL_HIT)) && IsPositiveSpell(trigger_spell_id) ? this : pVictim; // default case - if(!target || target!=this && !target->isAlive()) + if((!target && !spellmgr.IsSrcTargetSpell(triggerEntry)) || (target && target!=this && !target->isAlive())) return false; if(basepoints0) -- cgit v1.2.3