From 5d943336c53a84b9d0e7a451ea57b8abac1b5039 Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 2 Feb 2009 16:04:17 -0600 Subject: *Fix the bug that some instant cast spells do not remove auras with cast interrupte flag. --HG-- branch : trunk --- src/game/Spell.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/game/Spell.cpp') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 417afad7c41..c4db2454724 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2083,8 +2083,7 @@ void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) // set timer base at cast time ReSetTimer(); - //item: first cast may destroy item and second cast causes crash - if(m_IsTriggeredSpell || !m_casttime && !m_spellInfo->StartRecoveryTime && !m_castItemGUID && GetCurrentContainer() == CURRENT_GENERIC_SPELL) + if(m_IsTriggeredSpell) cast(true); else { @@ -2093,9 +2092,16 @@ void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) if(isSpellBreakStealth(m_spellInfo) ) m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CAST); - m_caster->SetCurrentCastedSpell( this ); - m_selfContainer = &(m_caster->m_currentSpells[GetCurrentContainer()]); - SendSpellStart(); + if(!m_casttime && !m_spellInfo->StartRecoveryTime + && !m_castItemGUID //item: first cast may destroy item and second cast causes crash + && GetCurrentContainer() == CURRENT_GENERIC_SPELL) + cast(true); + else + { + m_caster->SetCurrentCastedSpell( this ); + m_selfContainer = &(m_caster->m_currentSpells[GetCurrentContainer()]); + SendSpellStart(); + } } } -- cgit v1.2.3 From 8b8d7225237b017be97a6aabd0febebdf4200689 Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 2 Feb 2009 17:06:57 -0600 Subject: *handle SPELL_AURA_ADD_TARGET_TRIGGER auras when spell is casted rather than when hit. This fixes the trigger chance of spells such as Relentless Strikes. --HG-- branch : trunk --- src/game/Spell.cpp | 55 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) (limited to 'src/game/Spell.cpp') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index c4db2454724..201f7048a6c 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2252,6 +2252,34 @@ void Spell::cast(bool skipCheck) handle_immediate(); } + //handle SPELL_AURA_ADD_TARGET_TRIGGER auras + //are there any spells need to be triggered after hit? + Unit::AuraList const& targetTriggers = m_caster->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER); + for(Unit::AuraList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i) + { + SpellEntry const *auraSpellInfo = (*i)->GetSpellProto(); + uint32 auraSpellIdx = (*i)->GetEffIndex(); + if (IsAffectedBy(auraSpellInfo, auraSpellIdx)) + { + for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + if( ihit->effectMask & (1<GetGUID() let load auras at login and speedup most often case + Unit *unit = m_caster->GetGUID()== ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); + if (unit && unit->isAlive()) + { + // Calculate chance at that moment (can be depend for example from combo points) + int32 chance = m_caster->CalculateSpellDamage(auraSpellInfo, auraSpellIdx, (*i)->GetBasePoints(),unit); + + if(roll_chance_i(chance)) + for (int j=0; j != (*i)->GetStackAmount(); ++j) + m_caster->CastSpell(unit, auraSpellInfo->EffectTriggerSpell[auraSpellIdx], true, NULL, (*i)); + } + } + } + } + + // combo points should not be taken before SPELL_AURA_ADD_TARGET_TRIGGER auras are handled if(!m_IsTriggeredSpell) { TakePower(); @@ -2638,32 +2666,6 @@ void Spell::finish(bool ok) if (m_caster->GetTypeId() == TYPEID_PLAYER) ((Player*)m_caster)->RemoveSpellMods(this); - //handle SPELL_AURA_ADD_TARGET_TRIGGER auras - Unit::AuraList const& targetTriggers = m_caster->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER); - for(Unit::AuraList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i) - { - SpellEntry const *auraSpellInfo = (*i)->GetSpellProto(); - uint32 auraSpellIdx = (*i)->GetEffIndex(); - if (IsAffectedBy(auraSpellInfo, auraSpellIdx)) - { - for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - if( ihit->effectMask & (1<GetGUID() let load auras at login and speedup most often case - Unit *unit = m_caster->GetGUID()== ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); - if (unit && unit->isAlive()) - { - // Calculate chance at that moment (can be depend for example from combo points) - int32 chance = m_caster->CalculateSpellDamage(auraSpellInfo, auraSpellIdx, (*i)->GetBasePoints(),unit); - - if(roll_chance_i(chance)) - for (int j=0; j != (*i)->GetStackAmount(); ++j) - m_caster->CastSpell(unit, auraSpellInfo->EffectTriggerSpell[auraSpellIdx], true, NULL, (*i)); - } - } - } - } - // Heal caster for all health leech from all targets if (m_healthLeech) { @@ -2681,6 +2683,7 @@ void Spell::finish(bool ok) } // call triggered spell only at successful cast (after clear combo points -> for add some if need) + // I assume what he means is that some triggered spells may add combo points if(!m_TriggerSpells.empty()) TriggerSpell(); -- cgit v1.2.3 From 8dfe8cd64a29dfb57e392733929e86abaa749e6b Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 2 Feb 2009 17:20:30 -0600 Subject: *Fix some broken charge spells. --HG-- branch : trunk --- src/game/Spell.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/game/Spell.cpp') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 201f7048a6c..648d73a8f6f 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2206,9 +2206,6 @@ void Spell::cast(bool skipCheck) FillTargetMap(); - if(m_customAttr & SPELL_ATTR_CU_DIRECT_DAMAGE) - CalculateDamageDoneForAllTargets(); - // traded items have trade slot instead of guid in m_itemTargetGUID // set to real guid to be sent later to the client m_targets.updateTradeSlotItem(); @@ -2231,12 +2228,15 @@ void Spell::cast(bool skipCheck) SendCastResult(castResult); SendSpellGo(); // we must send smsg_spell_go packet before m_castItem delete in TakeCastItem()... + if(m_customAttr & SPELL_ATTR_CU_DIRECT_DAMAGE) + CalculateDamageDoneForAllTargets(); + + if(m_customAttr & SPELL_ATTR_CU_CHARGE) + EffectCharge(0); + // Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells if (m_spellInfo->speed > 0.0f && !IsChanneledSpell(m_spellInfo)) { - if(m_customAttr & SPELL_ATTR_CU_CHARGE) - EffectCharge(0); - // Remove used for cast item if need (it can be already NULL after TakeReagents call // in case delayed spell remove item at cast delay start TakeCastItem(); -- cgit v1.2.3