[8360] Simplify and partly rewrite SPELL_EFFECT_TRIGGER_SPELL work.

* Always use explicit spell cast from effect code
* Always use for normal case unitTraget self cast
  that fix thriggered spell apply to area targets.
This commit is contained in:
VladimirMangos 2009-08-12 23:27:53 +04:00
parent 39b2844210
commit a8a22db09d
2 changed files with 29 additions and 39 deletions

View file

@ -1963,6 +1963,14 @@ void Spell::EffectForceCast(uint32 i)
void Spell::EffectTriggerSpell(uint32 i) void Spell::EffectTriggerSpell(uint32 i)
{ {
// only unit case known
if (!unitTarget)
{
if(gameObjTarget || itemTarget)
sLog.outError("Spell::EffectTriggerSpell (Spell: %u): Unsupported non-unit case!",m_spellInfo->Id);
return;
}
uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[i]; uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[i];
// special cases // special cases
@ -1971,17 +1979,17 @@ void Spell::EffectTriggerSpell(uint32 i)
// Vanish (not exist) // Vanish (not exist)
case 18461: case 18461:
{ {
m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT);
m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED); unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED);
m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED); unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED);
// if this spell is given to NPC it must handle rest by it's own AI // if this spell is given to NPC it must handle rest by it's own AI
if ( m_caster->GetTypeId() != TYPEID_PLAYER ) if (unitTarget->GetTypeId() != TYPEID_PLAYER)
return; return;
// get highest rank of the Stealth spell // get highest rank of the Stealth spell
uint32 spellId = 0; uint32 spellId = 0;
const PlayerSpellMap& sp_list = ((Player*)m_caster)->GetSpellMap(); const PlayerSpellMap& sp_list = ((Player*)unitTarget)->GetSpellMap();
for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
{ {
// only highest rank is shown in spell book, so simply check if shown in spell book // only highest rank is shown in spell book, so simply check if shown in spell book
@ -2004,10 +2012,10 @@ void Spell::EffectTriggerSpell(uint32 i)
return; return;
// reset cooldown on it if needed // reset cooldown on it if needed
if(((Player*)m_caster)->HasSpellCooldown(spellId)) if (((Player*)unitTarget)->HasSpellCooldown(spellId))
((Player*)m_caster)->RemoveSpellCooldown(spellId); ((Player*)unitTarget)->RemoveSpellCooldown(spellId);
m_caster->CastSpell(m_caster, spellId, true); m_caster->CastSpell(unitTarget, spellId, true);
return; return;
} }
// just skip // just skip
@ -2047,7 +2055,7 @@ void Spell::EffectTriggerSpell(uint32 i)
// Cloak of Shadows // Cloak of Shadows
case 35729: case 35729:
{ {
Unit::AuraMap& Auras = m_caster->GetAuras(); Unit::AuraMap& Auras = unitTarget->GetAuras();
for(Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end(); ++iter) for(Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end(); ++iter)
{ {
// remove all harmful spells on you... // remove all harmful spells on you...
@ -2065,7 +2073,7 @@ void Spell::EffectTriggerSpell(uint32 i)
// Priest Shadowfiend (34433) need apply mana gain trigger aura on pet // Priest Shadowfiend (34433) need apply mana gain trigger aura on pet
case 41967: case 41967:
{ {
if (Unit *pet = m_caster->GetPet()) if (Unit *pet = unitTarget->GetPet())
pet->CastSpell(pet, 28305, true); pet->CastSpell(pet, 28305, true);
return; return;
} }
@ -2073,7 +2081,6 @@ void Spell::EffectTriggerSpell(uint32 i)
// normal case // normal case
SpellEntry const *spellInfo = sSpellStore.LookupEntry( triggered_spell_id ); SpellEntry const *spellInfo = sSpellStore.LookupEntry( triggered_spell_id );
if (!spellInfo) if (!spellInfo)
{ {
sLog.outError("EffectTriggerSpell of spell %u: triggering unknown spell id %i", m_spellInfo->Id,triggered_spell_id); sLog.outError("EffectTriggerSpell of spell %u: triggering unknown spell id %i", m_spellInfo->Id,triggered_spell_id);
@ -2112,24 +2119,7 @@ void Spell::EffectTriggerSpell(uint32 i)
} }
} }
// some triggered spells must be casted instantly (for example, if next effect case instant kill caster) unitTarget->CastSpell(unitTarget,spellInfo,true,NULL,NULL,m_originalCasterGUID);
bool instant = false;
for(uint32 j = i+1; j < 3; ++j)
{
if(m_spellInfo->Effect[j]==SPELL_EFFECT_INSTAKILL && m_spellInfo->EffectImplicitTargetA[j]==TARGET_SELF)
{
instant = true;
break;
}
}
if(instant)
{
if (unitTarget)
m_caster->CastSpell(unitTarget,spellInfo,true,m_CastItem,NULL,m_originalCasterGUID);
}
else
AddTriggeredSpell(spellInfo);
} }
void Spell::EffectTriggerMissileSpell(uint32 effect_idx) void Spell::EffectTriggerMissileSpell(uint32 effect_idx)

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8359" #define REVISION_NR "8360"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__