Implemented precast spell store as dynamicaly allocated list of precasts.

Signed-off-by: ApoC <apoc@nymfe.net>
This commit is contained in:
ApoC 2009-07-07 01:39:56 +02:00
parent 0f6d312e59
commit 6002d7ea2c
2 changed files with 27 additions and 13 deletions

View file

@ -405,7 +405,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi
focusObject = NULL;
m_cast_count = 0;
m_glyphIndex = 0;
m_preCastSpell = 0;
m_preCastSpells = NULL;
m_triggeredByAuraSpell = NULL;
//Auto Shot & Shoot (wand)
@ -445,6 +445,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi
Spell::~Spell()
{
delete m_preCastSpells;
}
template<typename T>
@ -1238,8 +1239,13 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
unit->IncrDiminishing(m_diminishGroup);
// Apply additional spell effects to target
if (m_preCastSpell)
m_caster->CastSpell(unit, m_preCastSpell, true, m_CastItem);
if (m_preCastSpells)
{
for (SpellPrecasts::const_iterator i = m_preCastSpells->begin(); i != m_preCastSpells->end(); ++i)
m_caster->CastSpell(unit, *i, true, m_CastItem);
delete m_preCastSpells;
m_preCastSpells = NULL;
}
for(uint32 effectNumber = 0; effectNumber < 3; ++effectNumber)
{
@ -2288,17 +2294,17 @@ void Spell::cast(bool skipCheck)
case SPELLFAMILY_GENERIC:
{
if (m_spellInfo->Mechanic == MECHANIC_BANDAGE) // Bandages
m_preCastSpell = 11196; // Recently Bandaged
AddPrecastSpell(11196); // Recently Bandaged
else if(m_spellInfo->SpellIconID == 1662 && m_spellInfo->AttributesEx & 0x20)
// Blood Fury (Racial)
m_preCastSpell = 23230; // Blood Fury - Healing Reduction
AddPrecastSpell(23230); // Blood Fury - Healing Reduction
break;
}
case SPELLFAMILY_MAGE:
{
// Ice Block
if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000008000000000))
m_preCastSpell = 41425; // Hypothermia
AddPrecastSpell(41425); // Hypothermia
break;
}
case SPELLFAMILY_PRIEST:
@ -2306,27 +2312,27 @@ void Spell::cast(bool skipCheck)
// Power Word: Shield
if (m_spellInfo->Mechanic == MECHANIC_SHIELD &&
(m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000000001)))
m_preCastSpell = 6788; // Weakened Soul
AddPrecastSpell(6788); // Weakened Soul
// Dispersion (transform)
if (m_spellInfo->Id == 47585)
m_preCastSpell = 60069; // Dispersion (mana regen)
AddPrecastSpell(60069); // Dispersion (mana regen)
break;
}
case SPELLFAMILY_PALADIN:
{
// Divine Shield, Divine Protection or Hand of Protection
if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000400080))
m_preCastSpell = 25771; // Forbearance
AddPrecastSpell(25771); // Forbearance
break;
}
case SPELLFAMILY_SHAMAN:
{
// Bloodlust
if (m_spellInfo->Id == 2825)
m_preCastSpell = 57724; // Sated
AddPrecastSpell(57724); // Sated
// Heroism
else if (m_spellInfo->Id == 32182)
m_preCastSpell = 57723; // Exhaustion
AddPrecastSpell(57723); // Exhaustion
break;
}
default:

View file

@ -204,6 +204,7 @@ enum SpellTargets
#define SPELL_SPELL_CHANNEL_UPDATE_INTERVAL (1*IN_MILISECONDS)
typedef std::multimap<uint64, uint64> SpellTargetTimeMap;
typedef std::list<uint32> SpellPrecasts;
class Spell
{
@ -335,6 +336,13 @@ class Spell
void TakeCastItem();
void TriggerSpell();
void AddPrecastSpell(uint32 spellId)
{
if (!m_preCastSpells)
m_preCastSpells = new SpellPrecasts();
m_preCastSpells->push_back(spellId);
}
SpellCastResult CheckCast(bool strict);
SpellCastResult CheckPetCast(Unit* target);
@ -399,7 +407,7 @@ class Spell
Item* m_CastItem;
uint8 m_cast_count;
uint32 m_glyphIndex;
uint32 m_preCastSpell;
SpellPrecasts *m_preCastSpells;
SpellCastTargets m_targets;
int32 GetCastTime() const { return m_casttime; }