* Converted hunter spell scripts to the new format (mostly for example purposes for the rest of the team).

--HG--
branch : trunk
This commit is contained in:
XTZGZoReX
2010-08-06 19:46:02 +02:00
parent 255158f535
commit 7f6fe6394c
9 changed files with 208 additions and 178 deletions
+198 -169
View File
@@ -34,198 +34,227 @@ enum HunterSpells
HUNTER_PET_SPELL_CARRION_FEEDER_TRIGGERED = 54045, HUNTER_PET_SPELL_CARRION_FEEDER_TRIGGERED = 54045,
}; };
class spell_hun_last_stand_pet_SpellScript : public SpellScript class spell_hun_last_stand_pet : public SpellHandlerScript
{ {
bool Validate(SpellEntry const * spellEntry) public:
{
if (!sSpellStore.LookupEntry(HUNTER_PET_SPELL_LAST_STAND_TRIGGERED))
return false;
return true;
}
void HandleDummy(SpellEffIndex effIndex) spell_hun_last_stand_pet()
{ : SpellHandlerScript("spell_hun_last_stand_pet")
Unit *caster = GetCaster();
int32 healthModSpellBasePoints0 = int32(caster->GetMaxHealth()*0.3);
caster->CastCustomSpell(caster, HUNTER_PET_SPELL_LAST_STAND_TRIGGERED, &healthModSpellBasePoints0, NULL, NULL, true, NULL);
}
void Register()
{
// add dummy effect spell handler to pet's Last Stand
EffectHandlers += EffectHandlerFn(spell_hun_last_stand_pet_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript * GetSpellScript_spell_hun_last_stand_pet()
{
return new spell_hun_last_stand_pet_SpellScript();
}
class spell_hun_masters_call_SpellScript : public SpellScript
{
void HandleDummy(SpellEffIndex effIndex)
{
Unit *caster = GetCaster();
Unit *unitTarget = GetHitUnit();
if (caster->GetTypeId() != TYPEID_PLAYER || !unitTarget)
return;
if (Pet *pet = caster->ToPlayer()->GetPet())
if (pet->isAlive())
pet->CastSpell(unitTarget, SpellMgr::CalculateSpellEffectAmount(GetSpellInfo(), effIndex), true);
}
void Register()
{
// add dummy effect spell handler to Master's Call
EffectHandlers += EffectHandlerFn(spell_hun_masters_call_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript * GetSpellScript_spell_hun_masters_call()
{
return new spell_hun_masters_call_SpellScript();
}
class spell_hun_readiness_SpellScript : public SpellScript
{
void HandleDummy(SpellEffIndex effIndex)
{
Unit *caster = GetCaster();
if (caster->GetTypeId() != TYPEID_PLAYER)
return;
// immediately finishes the cooldown on your other Hunter abilities except Bestial Wrath
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_HUNTER &&
spellInfo->Id != HUNTER_SPELL_READINESS &&
spellInfo->Id != HUNTER_SPELL_BESTIAL_WRATH &&
GetSpellRecoveryTime(spellInfo) > 0)
caster->ToPlayer()->RemoveSpellCooldown((itr++)->first,true);
else
++itr;
} }
}
void Register() class spell_hun_last_stand_pet_SpellScript : public SpellScript
{ {
// add dummy effect spell handler to Readiness bool Validate(SpellEntry const * spellEntry)
EffectHandlers += EffectHandlerFn(spell_hun_readiness_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); {
} if (!sSpellStore.LookupEntry(HUNTER_PET_SPELL_LAST_STAND_TRIGGERED))
return false;
return true;
}
void HandleDummy(SpellEffIndex effIndex)
{
Unit *caster = GetCaster();
int32 healthModSpellBasePoints0 = int32(caster->GetMaxHealth()*0.3);
caster->CastCustomSpell(caster, HUNTER_PET_SPELL_LAST_STAND_TRIGGERED, &healthModSpellBasePoints0, NULL, NULL, true, NULL);
}
void Register()
{
// add dummy effect spell handler to pet's Last Stand
EffectHandlers += EffectHandlerFn(spell_hun_last_stand_pet_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const
{
return new spell_hun_last_stand_pet_SpellScript();
}
}; };
SpellScript * GetSpellScript_spell_hun_readiness() class spell_hun_masters_call : public SpellHandlerScript
{ {
return new spell_hun_readiness_SpellScript(); public:
}
class spell_hun_pet_heart_of_the_phoenix : public SpellScript spell_hun_masters_call()
{ : SpellHandlerScript("spell_hun_masters_call")
bool Validate(SpellEntry const * spellEntry) {
{ }
if (!sSpellStore.LookupEntry(HUNTER_PET_HEART_OF_THE_PHOENIX_TRIGGERED))
return false;
if (!sSpellStore.LookupEntry(HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF))
return false;
return true;
}
void HandleScript(SpellEffIndex effIndex) class spell_hun_masters_call_SpellScript : public SpellScript
{ {
Unit *caster = GetCaster(); void HandleDummy(SpellEffIndex effIndex)
if (caster->HasAura(HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF)) {
return; Unit *caster = GetCaster();
caster->CastCustomSpell(HUNTER_PET_HEART_OF_THE_PHOENIX_TRIGGERED, SPELLVALUE_BASE_POINT0, 100, caster, true); Unit *unitTarget = GetHitUnit();
caster->CastSpell(caster, HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF, true);
}
void Register() if (caster->GetTypeId() != TYPEID_PLAYER || !unitTarget)
{ return;
// add dummy effect spell handler to pet's Last Stand
EffectHandlers += EffectHandlerFn(spell_hun_pet_heart_of_the_phoenix::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
bool Load() if (Pet *pet = caster->ToPlayer()->GetPet())
{ if (pet->isAlive())
if (!GetCaster()->isPet()) pet->CastSpell(unitTarget, SpellMgr::CalculateSpellEffectAmount(GetSpellInfo(), effIndex), true);
return false; }
return true;
} void Register()
{
// add dummy effect spell handler to Master's Call
EffectHandlers += EffectHandlerFn(spell_hun_masters_call_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const
{
return new spell_hun_masters_call_SpellScript();
}
}; };
SpellScript * GetSpellScript_spell_hun_pet_heart_of_the_phoenix() class spell_hun_readiness : public SpellHandlerScript
{ {
return new spell_hun_pet_heart_of_the_phoenix(); public:
}
class spell_hun_pet_carrion_feeder : public SpellScript spell_hun_readiness()
{ : SpellHandlerScript("spell_hun_readiness")
bool Validate(SpellEntry const * spellEntry) {
{ }
if (!sSpellStore.LookupEntry(HUNTER_PET_SPELL_CARRION_FEEDER_TRIGGERED))
return false;
return true;
}
void HandleDummy(SpellEffIndex effIndex) class spell_hun_readiness_SpellScript : public SpellScript
{ {
if (!GetHitUnit()) void HandleDummy(SpellEffIndex effIndex)
return; {
Unit *caster = GetCaster(); Unit *caster = GetCaster();
caster->CastSpell(caster, HUNTER_PET_SPELL_CARRION_FEEDER_TRIGGERED, false); if (caster->GetTypeId() != TYPEID_PLAYER)
} return;
void Register() // immediately finishes the cooldown on your other Hunter abilities except Bestial Wrath
{ const SpellCooldowns& cm = caster->ToPlayer()->GetSpellCooldownMap();
// add dummy effect spell handler to pet's Last Stand for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();)
EffectHandlers += EffectHandlerFn(spell_hun_pet_carrion_feeder::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); {
} SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
bool Load() if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER &&
{ spellInfo->Id != HUNTER_SPELL_READINESS &&
if (!GetCaster()->isPet()) spellInfo->Id != HUNTER_SPELL_BESTIAL_WRATH &&
return false; GetSpellRecoveryTime(spellInfo) > 0)
return true; caster->ToPlayer()->RemoveSpellCooldown((itr++)->first,true);
} else
++itr;
}
}
void Register()
{
// add dummy effect spell handler to Readiness
EffectHandlers += EffectHandlerFn(spell_hun_readiness_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const
{
return new spell_hun_readiness_SpellScript();
}
}; };
SpellScript * GetSpellScript_spell_hun_pet_carrion_feeder() class spell_hun_pet_heart_of_the_phoenix : public SpellHandlerScript
{ {
return new spell_hun_pet_carrion_feeder(); public:
}
spell_hun_pet_heart_of_the_phoenix()
: SpellHandlerScript("spell_hun_pet_heart_of_the_phoenix")
{
}
class spell_hun_pet_heart_of_the_phoenix_SpellScript : public SpellScript
{
bool Validate(SpellEntry const * spellEntry)
{
if (!sSpellStore.LookupEntry(HUNTER_PET_HEART_OF_THE_PHOENIX_TRIGGERED))
return false;
if (!sSpellStore.LookupEntry(HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF))
return false;
return true;
}
void HandleScript(SpellEffIndex effIndex)
{
Unit *caster = GetCaster();
if (caster->HasAura(HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF))
return;
caster->CastCustomSpell(HUNTER_PET_HEART_OF_THE_PHOENIX_TRIGGERED, SPELLVALUE_BASE_POINT0, 100, caster, true);
caster->CastSpell(caster, HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF, true);
}
void Register()
{
// add dummy effect spell handler to pet's Last Stand
EffectHandlers += EffectHandlerFn(spell_hun_pet_heart_of_the_phoenix_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
bool Load()
{
if (!GetCaster()->isPet())
return false;
return true;
}
};
SpellScript* GetSpellScript() const
{
return new spell_hun_pet_heart_of_the_phoenix_SpellScript();
}
};
class spell_hun_pet_carrion_feeder : public SpellHandlerScript
{
public:
spell_hun_pet_carrion_feeder()
: SpellHandlerScript("spell_hun_pet_carrion_feeder")
{
}
class spell_hun_pet_carrion_feeder_SpellScript : public SpellScript
{
bool Validate(SpellEntry const * spellEntry)
{
if (!sSpellStore.LookupEntry(HUNTER_PET_SPELL_CARRION_FEEDER_TRIGGERED))
return false;
return true;
}
void HandleDummy(SpellEffIndex effIndex)
{
if (!GetHitUnit())
return;
Unit *caster = GetCaster();
caster->CastSpell(caster, HUNTER_PET_SPELL_CARRION_FEEDER_TRIGGERED, false);
}
void Register()
{
// add dummy effect spell handler to pet's Last Stand
EffectHandlers += EffectHandlerFn(spell_hun_pet_carrion_feeder_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
bool Load()
{
if (!GetCaster()->isPet())
return false;
return true;
}
};
SpellScript* GetSpellScript() const
{
return new spell_hun_pet_carrion_feeder_SpellScript();
}
};
void AddSC_hunter_spell_scripts() void AddSC_hunter_spell_scripts()
{ {
Script *newscript; new spell_hun_last_stand_pet();
new spell_hun_masters_call();
newscript = new Script; new spell_hun_readiness();
newscript->Name = "spell_hun_last_stand_pet"; new spell_hun_pet_heart_of_the_phoenix();
newscript->GetSpellScript = &GetSpellScript_spell_hun_last_stand_pet; new spell_hun_pet_carrion_feeder();
newscript->RegisterSelf();
newscript = new Script;
newscript->Name = "spell_hun_masters_call";
newscript->GetSpellScript = &GetSpellScript_spell_hun_masters_call;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name = "spell_hun_readiness";
newscript->GetSpellScript = &GetSpellScript_spell_hun_readiness;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name = "spell_hun_pet_heart_of_the_phoenix";
newscript->GetSpellScript = &GetSpellScript_spell_hun_pet_heart_of_the_phoenix;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name = "spell_hun_pet_carrion_feeder";
newscript->GetSpellScript = &GetSpellScript_spell_hun_pet_carrion_feeder;
newscript->RegisterSelf();
} }
+2 -1
View File
@@ -102,7 +102,8 @@ class spell_mage_polymorph_cast_visual_SpellScript : public SpellScript
} }
}; };
const uint32 spell_mage_polymorph_cast_visual_SpellScript::spell_list[6] = { const uint32 spell_mage_polymorph_cast_visual_SpellScript::spell_list[6] =
{
SPELL_MAGE_SQUIRREL_FORM, SPELL_MAGE_SQUIRREL_FORM,
SPELL_MAGE_GIRAFFE_FORM, SPELL_MAGE_GIRAFFE_FORM,
SPELL_MAGE_SERPENT_FORM, SPELL_MAGE_SERPENT_FORM,