mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[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:
parent
49b201e22b
commit
9c91796443
4 changed files with 50 additions and 19 deletions
|
|
@ -1238,12 +1238,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
|
||||||
unit->IncrDiminishing(m_diminishGroup);
|
unit->IncrDiminishing(m_diminishGroup);
|
||||||
|
|
||||||
// Apply additional spell effects to target
|
// Apply additional spell effects to target
|
||||||
while (!m_preCastSpells.empty())
|
CastPreCastSpells(unit);
|
||||||
{
|
|
||||||
uint32 spellId = *m_preCastSpells.begin();
|
|
||||||
m_caster->CastSpell(unit, spellId, true, m_CastItem);
|
|
||||||
m_preCastSpells.erase(m_preCastSpells.begin());
|
|
||||||
}
|
|
||||||
|
|
||||||
for(uint32 effectNumber = 0; effectNumber < 3; ++effectNumber)
|
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)
|
switch(m_spellInfo->SpellFamilyName)
|
||||||
{
|
{
|
||||||
case SPELLFAMILY_GENERIC:
|
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)
|
// call triggered spell only at successful cast (after clear combo points -> for add some if need)
|
||||||
if(!m_TriggerSpells.empty())
|
if(!m_TriggerSpells.empty())
|
||||||
TriggerSpell();
|
CastTriggerSpells();
|
||||||
|
|
||||||
// Stop Attack for some spells
|
// Stop Attack for some spells
|
||||||
if( m_spellInfo->Attributes & SPELL_ATTR_STOP_ATTACK_TARGET )
|
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* spell = new Spell(m_caster, (*si), true, m_originalCasterGUID, m_selfContainer);
|
||||||
spell->prepare(&m_targets); // use original spell original targets
|
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)
|
SpellCastResult Spell::CheckCast(bool strict)
|
||||||
{
|
{
|
||||||
// check cooldowns to prevent cheating
|
// check cooldowns to prevent cheating
|
||||||
|
|
@ -5802,4 +5831,4 @@ void Spell::FillRaidOrPartyHealthPriorityTargets( UnitList &TagUnitMap, Unit* ta
|
||||||
TagUnitMap.push_back(healthQueue.top().getUnit());
|
TagUnitMap.push_back(healthQueue.top().getUnit());
|
||||||
healthQueue.pop();
|
healthQueue.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -333,7 +333,6 @@ class Spell
|
||||||
void TakeRunePower();
|
void TakeRunePower();
|
||||||
void TakeReagents();
|
void TakeReagents();
|
||||||
void TakeCastItem();
|
void TakeCastItem();
|
||||||
void TriggerSpell();
|
|
||||||
|
|
||||||
SpellCastResult CheckCast(bool strict);
|
SpellCastResult CheckCast(bool strict);
|
||||||
SpellCastResult CheckPetCast(Unit* target);
|
SpellCastResult CheckPetCast(Unit* target);
|
||||||
|
|
@ -438,8 +437,12 @@ class Spell
|
||||||
|
|
||||||
bool CheckTargetCreatureType(Unit* target) const;
|
bool CheckTargetCreatureType(Unit* target) const;
|
||||||
|
|
||||||
void AddTriggeredSpell(SpellEntry const* spell) { m_TriggerSpells.push_back(spell); }
|
void AddTriggeredSpell(SpellEntry const* spellInfo) { m_TriggerSpells.push_back(spellInfo); }
|
||||||
void AddPrecastSpell(uint32 spellId) { m_preCastSpells.push_back(spellId); }
|
void AddPrecastSpell(SpellEntry const* spellInfo) { m_preCastSpells.push_back(spellInfo); }
|
||||||
|
void AddTriggeredSpell(uint32 spellId);
|
||||||
|
void AddPrecastSpell(uint32 spellId);
|
||||||
|
void CastPreCastSpells(Unit* target);
|
||||||
|
void CastTriggerSpells();
|
||||||
|
|
||||||
void CleanupTargetList();
|
void CleanupTargetList();
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -558,10 +561,9 @@ class Spell
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
|
|
||||||
//List For Triggered Spells
|
//List For Triggered Spells
|
||||||
typedef std::list<SpellEntry const*> TriggerSpells;
|
typedef std::list<SpellEntry const*> SpellInfoList;
|
||||||
typedef std::list<uint32> SpellPrecasts;
|
SpellInfoList m_TriggerSpells; // casted by caster to same targets settings in m_targets at success finish of current spell
|
||||||
TriggerSpells m_TriggerSpells;
|
SpellInfoList m_preCastSpells; // casted by caster to each target at spell hit before spell effects apply
|
||||||
SpellPrecasts m_preCastSpells;
|
|
||||||
|
|
||||||
uint32 m_spellState;
|
uint32 m_spellState;
|
||||||
uint32 m_timer;
|
uint32 m_timer;
|
||||||
|
|
|
||||||
|
|
@ -2034,7 +2034,7 @@ void Spell::EffectTriggerSpell(uint32 i)
|
||||||
m_caster->CastSpell(unitTarget,spellInfo,true,m_CastItem,NULL,m_originalCasterGUID);
|
m_caster->CastSpell(unitTarget,spellInfo,true,m_CastItem,NULL,m_originalCasterGUID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_TriggerSpells.push_back(spellInfo);
|
AddTriggeredSpell(spellInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spell::EffectTriggerMissileSpell(uint32 effect_idx)
|
void Spell::EffectTriggerMissileSpell(uint32 effect_idx)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8196"
|
#define REVISION_NR "8197"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue