mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[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:
parent
39b2844210
commit
a8a22db09d
2 changed files with 29 additions and 39 deletions
|
|
@ -1963,6 +1963,14 @@ void Spell::EffectForceCast(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];
|
||||
|
||||
// special cases
|
||||
|
|
@ -1971,21 +1979,21 @@ void Spell::EffectTriggerSpell(uint32 i)
|
|||
// Vanish (not exist)
|
||||
case 18461:
|
||||
{
|
||||
m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT);
|
||||
m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED);
|
||||
m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED);
|
||||
unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT);
|
||||
unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED);
|
||||
unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED);
|
||||
|
||||
// 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;
|
||||
|
||||
// get highest rank of the Stealth spell
|
||||
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)
|
||||
{
|
||||
// only highest rank is shown in spell book, so simply check if shown in spell book
|
||||
if(!itr->second->active || itr->second->disabled || itr->second->state == PLAYERSPELL_REMOVED)
|
||||
if (!itr->second->active || itr->second->disabled || itr->second->state == PLAYERSPELL_REMOVED)
|
||||
continue;
|
||||
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
|
||||
|
|
@ -2004,10 +2012,10 @@ void Spell::EffectTriggerSpell(uint32 i)
|
|||
return;
|
||||
|
||||
// reset cooldown on it if needed
|
||||
if(((Player*)m_caster)->HasSpellCooldown(spellId))
|
||||
((Player*)m_caster)->RemoveSpellCooldown(spellId);
|
||||
if (((Player*)unitTarget)->HasSpellCooldown(spellId))
|
||||
((Player*)unitTarget)->RemoveSpellCooldown(spellId);
|
||||
|
||||
m_caster->CastSpell(m_caster, spellId, true);
|
||||
m_caster->CastSpell(unitTarget, spellId, true);
|
||||
return;
|
||||
}
|
||||
// just skip
|
||||
|
|
@ -2047,7 +2055,7 @@ void Spell::EffectTriggerSpell(uint32 i)
|
|||
// Cloak of Shadows
|
||||
case 35729:
|
||||
{
|
||||
Unit::AuraMap& Auras = m_caster->GetAuras();
|
||||
Unit::AuraMap& Auras = unitTarget->GetAuras();
|
||||
for(Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end(); ++iter)
|
||||
{
|
||||
// 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
|
||||
case 41967:
|
||||
{
|
||||
if (Unit *pet = m_caster->GetPet())
|
||||
if (Unit *pet = unitTarget->GetPet())
|
||||
pet->CastSpell(pet, 28305, true);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2073,63 +2081,45 @@ void Spell::EffectTriggerSpell(uint32 i)
|
|||
|
||||
// normal case
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
// some triggered spells require specific equipment
|
||||
if(spellInfo->EquippedItemClass >=0 && m_caster->GetTypeId()==TYPEID_PLAYER)
|
||||
if (spellInfo->EquippedItemClass >=0 && m_caster->GetTypeId()==TYPEID_PLAYER)
|
||||
{
|
||||
// main hand weapon required
|
||||
if(spellInfo->AttributesEx3 & SPELL_ATTR_EX3_MAIN_HAND)
|
||||
if (spellInfo->AttributesEx3 & SPELL_ATTR_EX3_MAIN_HAND)
|
||||
{
|
||||
Item* item = ((Player*)m_caster)->GetWeaponForAttack(BASE_ATTACK);
|
||||
|
||||
// skip spell if no weapon in slot or broken
|
||||
if(!item || item->IsBroken() )
|
||||
if (!item || item->IsBroken() )
|
||||
return;
|
||||
|
||||
// skip spell if weapon not fit to triggered spell
|
||||
if(!item->IsFitToSpellRequirements(spellInfo))
|
||||
if (!item->IsFitToSpellRequirements(spellInfo))
|
||||
return;
|
||||
}
|
||||
|
||||
// offhand hand weapon required
|
||||
if(spellInfo->AttributesEx3 & SPELL_ATTR_EX3_REQ_OFFHAND)
|
||||
if (spellInfo->AttributesEx3 & SPELL_ATTR_EX3_REQ_OFFHAND)
|
||||
{
|
||||
Item* item = ((Player*)m_caster)->GetWeaponForAttack(OFF_ATTACK);
|
||||
|
||||
// skip spell if no weapon in slot or broken
|
||||
if(!item || item->IsBroken() )
|
||||
if (!item || item->IsBroken() )
|
||||
return;
|
||||
|
||||
// skip spell if weapon not fit to triggered spell
|
||||
if(!item->IsFitToSpellRequirements(spellInfo))
|
||||
if (!item->IsFitToSpellRequirements(spellInfo))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// some triggered spells must be casted instantly (for example, if next effect case instant kill caster)
|
||||
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);
|
||||
unitTarget->CastSpell(unitTarget,spellInfo,true,NULL,NULL,m_originalCasterGUID);
|
||||
}
|
||||
|
||||
void Spell::EffectTriggerMissileSpell(uint32 effect_idx)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8359"
|
||||
#define REVISION_NR "8360"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue