Convert spell scripts to new system.

--HG--
branch : trunk
This commit is contained in:
silinoron committed 2010-08-06 11:35:39 -07:00
1 parent 5a345eeade
commit 14459bc467
10 files changed
+523 -528

No files matched your search

+125 -120
View File
@@ -37,139 +37,144 @@ enum MageSpells
SPELL_MAGE_SUMMON_WATER_ELEMENTAL_TEMPORARY = 70907,
};
class spell_mage_cold_snap_SpellScript : public SpellScript
class spell_mage_cold_snap : public SpellHandlerScript
{
void HandleDummy(SpellEffIndex effIndex)
{
Unit *caster = GetCaster();
public:
spell_mage_cold_snap() : SpellHandlerScript("spell_mage_cold_snap") { }
if (caster->GetTypeId() != TYPEID_PLAYER)
return;
// immediately finishes the cooldown on Frost spells
const SpellCooldowns& cm = caster->ToPlayer()->GetSpellCooldownMap();
for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();)
class spell_mage_cold_snap_SpellScript : public SpellScript
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
if (spellInfo->SpellFamilyName == SPELLFAMILY_MAGE &&
(GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_FROST) &&
spellInfo->Id != SPELL_MAGE_COLD_SNAP && GetSpellRecoveryTime(spellInfo) > 0)
void HandleDummy(SpellEffIndex effIndex)
{
caster->ToPlayer()->RemoveSpellCooldown((itr++)->first, true);
Unit *caster = GetCaster();
if (caster->GetTypeId() != TYPEID_PLAYER)
return;
// immediately finishes the cooldown on Frost spells
const SpellCooldowns& cm = caster->ToPlayer()->GetSpellCooldownMap();
for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();)
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
if (spellInfo->SpellFamilyName == SPELLFAMILY_MAGE &&
(GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_FROST) &&
spellInfo->Id != SPELL_MAGE_COLD_SNAP && GetSpellRecoveryTime(spellInfo) > 0)
{
caster->ToPlayer()->RemoveSpellCooldown((itr++)->first, true);
}
else
++itr;
}
}
else
++itr;
}
}
void Register()
{
// add dummy effect spell handler to Cold Snap
EffectHandlers += EffectHandlerFn(spell_mage_cold_snap_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
void Register()
{
// add dummy effect spell handler to Cold Snap
EffectHandlers += EffectHandlerFn(spell_mage_cold_snap_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript * GetSpellScript_spell_mage_cold_snap()
{
return new spell_mage_cold_snap_SpellScript();
}
class spell_mage_polymorph_cast_visual_SpellScript : public SpellScript
{
static const uint32 spell_list[6];
bool Validate(SpellEntry const * spellEntry)
{
// check if spell ids exist in dbc
for (int i = 0; i < 6; i++)
if (!sSpellStore.LookupEntry(spell_list[i]))
return false;
return true;
}
void HandleDummy(SpellEffIndex effIndex)
{
if (Unit *unitTarget = GetHitUnit())
if (unitTarget->GetTypeId() == TYPEID_UNIT)
unitTarget->CastSpell(unitTarget, spell_list[urand(0, 5)], true);
}
void Register()
{
// add dummy effect spell handler to Polymorph visual
EffectHandlers += EffectHandlerFn(spell_mage_polymorph_cast_visual_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
const uint32 spell_mage_polymorph_cast_visual_SpellScript::spell_list[6] =
{
SPELL_MAGE_SQUIRREL_FORM,
SPELL_MAGE_GIRAFFE_FORM,
SPELL_MAGE_SERPENT_FORM,
SPELL_MAGE_DRAGONHAWK_FORM,
SPELL_MAGE_WORGEN_FORM,
SPELL_MAGE_SHEEP_FORM
};
SpellScript * GetSpellScript_spell_mage_polymorph_visual()
{
return new spell_mage_polymorph_cast_visual_SpellScript();
}
class spell_mage_summon_water_elemental_SpellScript : public SpellScript
{
bool Validate(SpellEntry const * spellEntry)
{
if (!sSpellStore.LookupEntry(SPELL_MAGE_GLYPH_OF_ETERNAL_WATER))
return false;
if (!sSpellStore.LookupEntry(SPELL_MAGE_SUMMON_WATER_ELEMENTAL_TEMPORARY))
return false;
if (!sSpellStore.LookupEntry(SPELL_MAGE_SUMMON_WATER_ELEMENTAL_PERMANENT))
return false;
return true;
}
void HandleDummy(SpellEffIndex effIndex)
{
if (Unit *unitTarget = GetHitUnit())
SpellScript* GetSpellScript() const
{
// Glyph of Eternal Water
if (unitTarget->HasAura(SPELL_MAGE_GLYPH_OF_ETERNAL_WATER))
unitTarget->CastSpell(unitTarget, SPELL_MAGE_SUMMON_WATER_ELEMENTAL_PERMANENT, true);
else
unitTarget->CastSpell(unitTarget, SPELL_MAGE_SUMMON_WATER_ELEMENTAL_TEMPORARY, true);
return new spell_mage_cold_snap_SpellScript();
}
}
void Register()
{
// add dummy effect spell handler to Summon Water Elemental
EffectHandlers += EffectHandlerFn(spell_mage_summon_water_elemental_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript * GetSpellScript_spell_mage_summon_water_elemental()
class spell_mage_polymorph_cast_visual : public SpellHandlerScript
{
return new spell_mage_summon_water_elemental_SpellScript();
}
public:
spell_mage_polymorph_cast_visual() : SpellHandlerScript("spell_mage_polymorph_visual") { }
class spell_mage_polymorph_cast_visual_SpellScript : public SpellScript
{
static const uint32 spell_list[6];
bool Validate(SpellEntry const * spellEntry)
{
// check if spell ids exist in dbc
for (int i = 0; i < 6; i++)
if (!sSpellStore.LookupEntry(spell_list[i]))
return false;
return true;
}
void HandleDummy(SpellEffIndex effIndex)
{
if (Unit *unitTarget = GetHitUnit())
if (unitTarget->GetTypeId() == TYPEID_UNIT)
unitTarget->CastSpell(unitTarget, spell_list[urand(0, 5)], true);
}
void Register()
{
// add dummy effect spell handler to Polymorph visual
EffectHandlers += EffectHandlerFn(spell_mage_polymorph_cast_visual_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
const uint32 spell_mage_polymorph_cast_visual_SpellScript::spell_list[6] =
{
SPELL_MAGE_SQUIRREL_FORM,
SPELL_MAGE_GIRAFFE_FORM,
SPELL_MAGE_SERPENT_FORM,
SPELL_MAGE_DRAGONHAWK_FORM,
SPELL_MAGE_WORGEN_FORM,
SPELL_MAGE_SHEEP_FORM
};
SpellScript* GetSpellScript() const
{
return new spell_mage_polymorph_cast_visual_SpellScript();
}
};
class spell_mage_summon_water_elemental : public SpellHandlerScript
{
public:
spell_mage_summon_water_elemental() : SpellHandlerScript("spell_mage_summon_water_elemental") { }
class spell_mage_summon_water_elemental_SpellScript : public SpellScript
{
bool Validate(SpellEntry const * spellEntry)
{
if (!sSpellStore.LookupEntry(SPELL_MAGE_GLYPH_OF_ETERNAL_WATER))
return false;
if (!sSpellStore.LookupEntry(SPELL_MAGE_SUMMON_WATER_ELEMENTAL_TEMPORARY))
return false;
if (!sSpellStore.LookupEntry(SPELL_MAGE_SUMMON_WATER_ELEMENTAL_PERMANENT))
return false;
return true;
}
void HandleDummy(SpellEffIndex effIndex)
{
if (Unit *unitTarget = GetHitUnit())
{
// Glyph of Eternal Water
if (unitTarget->HasAura(SPELL_MAGE_GLYPH_OF_ETERNAL_WATER))
unitTarget->CastSpell(unitTarget, SPELL_MAGE_SUMMON_WATER_ELEMENTAL_PERMANENT, true);
else
unitTarget->CastSpell(unitTarget, SPELL_MAGE_SUMMON_WATER_ELEMENTAL_TEMPORARY, true);
}
}
void Register()
{
// add dummy effect spell handler to Summon Water Elemental
EffectHandlers += EffectHandlerFn(spell_mage_summon_water_elemental_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript * GetSpellScript() const
{
return new spell_mage_summon_water_elemental_SpellScript();
}
};
void AddSC_mage_spell_scripts()
{
Script *newscript;
newscript = new Script;
newscript->Name = "spell_mage_cold_snap";
newscript->GetSpellScript = &GetSpellScript_spell_mage_cold_snap;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name = "spell_mage_polymorph_visual";
newscript->GetSpellScript = &GetSpellScript_spell_mage_polymorph_visual;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name = "spell_mage_summon_water_elemental";
newscript->GetSpellScript = &GetSpellScript_spell_mage_summon_water_elemental;
newscript->RegisterSelf();
new spell_mage_cold_snap;
new spell_mage_polymorph_cast_visual;
new spell_mage_summon_water_elemental;
}