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

+114 -109
View File
@@ -35,135 +35,140 @@ enum PaladinSpells
SPELL_BLESSING_OF_LOWER_CITY_SHAMAN = 37881,
};
class spell_pal_blessing_of_faith_SpellScript : public SpellScript
class spell_pal_blessing_of_faith : public SpellHandlerScript
{
bool Validate(SpellEntry const *spellEntry)
{
if (!sSpellStore.LookupEntry(SPELL_BLESSING_OF_LOWER_CITY_DRUID))
return false;
if (!sSpellStore.LookupEntry(SPELL_BLESSING_OF_LOWER_CITY_PALADIN))
return false;
if (!sSpellStore.LookupEntry(SPELL_BLESSING_OF_LOWER_CITY_PRIEST))
return false;
if (!sSpellStore.LookupEntry(SPELL_BLESSING_OF_LOWER_CITY_SHAMAN))
return false;
return true;
}
public:
spell_pal_blessing_of_faith() : SpellHandlerScript("spell_pal_blessing_of_faith") { }
void HandleDummy(SpellEffIndex effIndex)
{
if (Unit *unitTarget = GetHitUnit())
class spell_pal_blessing_of_faith_SpellScript : public SpellScript
{
uint32 spell_id = 0;
switch(unitTarget->getClass())
bool Validate(SpellEntry const *spellEntry)
{
case CLASS_DRUID: spell_id = SPELL_BLESSING_OF_LOWER_CITY_DRUID; break;
case CLASS_PALADIN: spell_id = SPELL_BLESSING_OF_LOWER_CITY_PALADIN; break;
case CLASS_PRIEST: spell_id = SPELL_BLESSING_OF_LOWER_CITY_PRIEST; break;
case CLASS_SHAMAN: spell_id = SPELL_BLESSING_OF_LOWER_CITY_SHAMAN; break;
default: return; // ignore for non-healing classes
if (!sSpellStore.LookupEntry(SPELL_BLESSING_OF_LOWER_CITY_DRUID))
return false;
if (!sSpellStore.LookupEntry(SPELL_BLESSING_OF_LOWER_CITY_PALADIN))
return false;
if (!sSpellStore.LookupEntry(SPELL_BLESSING_OF_LOWER_CITY_PRIEST))
return false;
if (!sSpellStore.LookupEntry(SPELL_BLESSING_OF_LOWER_CITY_SHAMAN))
return false;
return true;
}
GetCaster()->CastSpell(GetCaster(), spell_id, true);
}
}
void HandleDummy(SpellEffIndex effIndex)
{
if (Unit *unitTarget = GetHitUnit())
{
uint32 spell_id = 0;
switch(unitTarget->getClass())
{
case CLASS_DRUID: spell_id = SPELL_BLESSING_OF_LOWER_CITY_DRUID; break;
case CLASS_PALADIN: spell_id = SPELL_BLESSING_OF_LOWER_CITY_PALADIN; break;
case CLASS_PRIEST: spell_id = SPELL_BLESSING_OF_LOWER_CITY_PRIEST; break;
case CLASS_SHAMAN: spell_id = SPELL_BLESSING_OF_LOWER_CITY_SHAMAN; break;
default: return; // ignore for non-healing classes
}
void Register()
{
// add dummy effect spell handler to Blessing of Faith
EffectHandlers += EffectHandlerFn(spell_pal_blessing_of_faith_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
GetCaster()->CastSpell(GetCaster(), spell_id, true);
}
}
SpellScript * GetSpellScript_spell_pal_blessing_of_faith()
{
return new spell_pal_blessing_of_faith_SpellScript();
}
void Register()
{
// add dummy effect spell handler to Blessing of Faith
EffectHandlers += EffectHandlerFn(spell_pal_blessing_of_faith_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
class spell_pal_holy_shock_SpellScript : public SpellScript
{
bool Validate(SpellEntry const *spellEntry)
{
if (!sSpellStore.LookupEntry(PALADIN_SPELL_HOLY_SHOCK_R1))
return false;
// can't use other spell than holy shock due to spell_ranks dependency
if (spellmgr.GetFirstSpellInChain(PALADIN_SPELL_HOLY_SHOCK_R1) != spellmgr.GetFirstSpellInChain(spellEntry->Id))
return false;
uint8 rank = spellmgr.GetSpellRank(spellEntry->Id);
if (!spellmgr.GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_DAMAGE, rank, true))
return false;
if (!spellmgr.GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_HEALING, rank, true))
return false;
return true;
}
void HandleDummy(SpellEffIndex effIndex)
{
if (Unit *unitTarget = GetHitUnit())
SpellScript *GetSpellScript() const
{
Unit *caster = GetCaster();
uint8 rank = spellmgr.GetSpellRank(GetSpellInfo()->Id);
if (caster->IsFriendlyTo(unitTarget))
caster->CastSpell(unitTarget, spellmgr.GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_HEALING, rank), true, 0);
else
caster->CastSpell(unitTarget, spellmgr.GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_DAMAGE, rank), true, 0);
return new spell_pal_blessing_of_faith_SpellScript();
}
}
void Register()
{
// add dummy effect spell handler to Holy Shock
EffectHandlers += EffectHandlerFn(spell_pal_holy_shock_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript * GetSpellScript_spell_pal_holy_shock()
class spell_pal_holy_shock : public SpellHandlerScript
{
return new spell_pal_holy_shock_SpellScript();
}
public:
spell_pal_holy_shock() : SpellHandlerScript("spell_pal_holy_shock") { }
class spell_pal_judgement_of_command_SpellScript : public SpellScript
{
void HandleDummy(SpellEffIndex effIndex)
{
if (Unit *unitTarget = GetHitUnit())
if (SpellEntry const* spell_proto = sSpellStore.LookupEntry(GetEffectValue()))
GetCaster()->CastSpell(unitTarget, spell_proto, true, NULL);
}
class spell_pal_holy_shock_SpellScript : public SpellScript
{
bool Validate(SpellEntry const *spellEntry)
{
if (!sSpellStore.LookupEntry(PALADIN_SPELL_HOLY_SHOCK_R1))
return false;
void Register()
{
// add dummy effect spell handler to Judgement of Command
EffectHandlers += EffectHandlerFn(spell_pal_judgement_of_command_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
// can't use other spell than holy shock due to spell_ranks dependency
if (spellmgr.GetFirstSpellInChain(PALADIN_SPELL_HOLY_SHOCK_R1) != spellmgr.GetFirstSpellInChain(spellEntry->Id))
return false;
uint8 rank = spellmgr.GetSpellRank(spellEntry->Id);
if (!spellmgr.GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_DAMAGE, rank, true))
return false;
if (!spellmgr.GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_HEALING, rank, true))
return false;
return true;
}
void HandleDummy(SpellEffIndex effIndex)
{
if (Unit *unitTarget = GetHitUnit())
{
Unit *caster = GetCaster();
uint8 rank = spellmgr.GetSpellRank(GetSpellInfo()->Id);
if (caster->IsFriendlyTo(unitTarget))
caster->CastSpell(unitTarget, spellmgr.GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_HEALING, rank), true, 0);
else
caster->CastSpell(unitTarget, spellmgr.GetSpellWithRank(PALADIN_SPELL_HOLY_SHOCK_R1_DAMAGE, rank), true, 0);
}
}
void Register()
{
// add dummy effect spell handler to Holy Shock
EffectHandlers += EffectHandlerFn(spell_pal_holy_shock_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript *GetSpellScript() const
{
return new spell_pal_holy_shock_SpellScript();
}
};
SpellScript * GetSpellScript_spell_pal_judgement_of_command()
class spell_pal_judgement_of_command : public SpellHandlerScript
{
return new spell_pal_judgement_of_command_SpellScript();
}
public:
spell_pal_judgement_of_command() : SpellHandlerScript("spell_pal_judgement_of_command") { }
class spell_pal_judgement_of_command_SpellScript : public SpellScript
{
void HandleDummy(SpellEffIndex effIndex)
{
if (Unit *unitTarget = GetHitUnit())
if (SpellEntry const* spell_proto = sSpellStore.LookupEntry(GetEffectValue()))
GetCaster()->CastSpell(unitTarget, spell_proto, true, NULL);
}
void Register()
{
// add dummy effect spell handler to Judgement of Command
EffectHandlers += EffectHandlerFn(spell_pal_judgement_of_command_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript *GetSpellScript() const
{
return new spell_pal_judgement_of_command_SpellScript();
}
};
void AddSC_paladin_spell_scripts()
{
Script *newscript;
newscript = new Script;
newscript->Name = "spell_pal_blessing_of_faith";
newscript->GetSpellScript = &GetSpellScript_spell_pal_blessing_of_faith;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name = "spell_pal_holy_shock";
newscript->GetSpellScript = &GetSpellScript_spell_pal_holy_shock;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name = "spell_pal_judgement_of_command";
newscript->GetSpellScript = &GetSpellScript_spell_pal_judgement_of_command;
newscript->RegisterSelf();
new spell_pal_blessing_of_faith;
new spell_pal_holy_shock;
new spell_pal_judgement_of_command;
}