[8197] Use more similar code for triggered and precast spells.

Also better error reporting at not existed spells.
Clear use in comments for this 2 dependent cast ways.
This commit is contained in:
VladimirMangos 2009-07-18 21:20:33 +04:00
parent 49b201e22b
commit 9c91796443
4 changed files with 50 additions and 19 deletions

View file

@ -1238,12 +1238,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
unit->IncrDiminishing(m_diminishGroup);
// Apply additional spell effects to target
while (!m_preCastSpells.empty())
{
uint32 spellId = *m_preCastSpells.begin();
m_caster->CastSpell(unit, spellId, true, m_CastItem);
m_preCastSpells.erase(m_preCastSpells.begin());
}
CastPreCastSpells(unit);
for(uint32 effectNumber = 0; effectNumber < 3; ++effectNumber)
{
@ -2283,6 +2278,7 @@ void Spell::cast(bool skipCheck)
}
}
// different triggred (for caster) and precast (casted before apply effect to target) cases
switch(m_spellInfo->SpellFamilyName)
{
case SPELLFAMILY_GENERIC:
@ -2765,7 +2761,7 @@ void Spell::finish(bool ok)
// call triggered spell only at successful cast (after clear combo points -> for add some if need)
if(!m_TriggerSpells.empty())
TriggerSpell();
CastTriggerSpells();
// Stop Attack for some spells
if( m_spellInfo->Attributes & SPELL_ATTR_STOP_ATTACK_TARGET )
@ -3604,15 +3600,48 @@ void Spell::HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTar
*/
}
void Spell::TriggerSpell()
void Spell::AddTriggeredSpell( uint32 spellId )
{
for(TriggerSpells::const_iterator si=m_TriggerSpells.begin(); si!=m_TriggerSpells.end(); ++si)
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId );
if(!spellInfo)
{
sLog.outError("Spell::AddTriggeredSpell: unknown spell id %u used as triggred spell for spell %u)", spellId, m_spellInfo->Id);
return;
}
m_TriggerSpells.push_back(spellInfo);
}
void Spell::AddPrecastSpell( uint32 spellId )
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId );
if(!spellInfo)
{
sLog.outError("Spell::AddPrecastSpell: unknown spell id %u used as pre-cast spell for spell %u)", spellId, m_spellInfo->Id);
return;
}
m_preCastSpells.push_back(spellInfo);
}
void Spell::CastTriggerSpells()
{
for(SpellInfoList::const_iterator si=m_TriggerSpells.begin(); si!=m_TriggerSpells.end(); ++si)
{
Spell* spell = new Spell(m_caster, (*si), true, m_originalCasterGUID, m_selfContainer);
spell->prepare(&m_targets); // use original spell original targets
}
}
void Spell::CastPreCastSpells(Unit* target)
{
for(SpellInfoList::const_iterator si=m_preCastSpells.begin(); si!=m_preCastSpells.end(); ++si)
m_caster->CastSpell(target, (*si), true, m_CastItem);
}
SpellCastResult Spell::CheckCast(bool strict)
{
// check cooldowns to prevent cheating
@ -5802,4 +5831,4 @@ void Spell::FillRaidOrPartyHealthPriorityTargets( UnitList &TagUnitMap, Unit* ta
TagUnitMap.push_back(healthQueue.top().getUnit());
healthQueue.pop();
}
}
}