Add more methods to SpellScript.

Spells cleanup: move spells from the core to scripts.

* Shaman spells: 39610 Mana Tide Totem, 1535 Fire Nova (and ranks)
* Death Knight spells: 55090 Scourge Strike (and ranks), 49158 Corpse Explosion (and ranks), 50524 Runic Power Feed
* Druid spells: 54846 Glyph of Starfire
* Warlock spells: 6201 Create Healthstone (and ranks), 47422 Everlasting Affliction, 47193 Demonic Empowerment, 63521 Guarded by The Light
* Hunter spells: 37506 Scatter Shot, 53412 Invigoration, 53209 Chimera Shot
* Quest spells: 45449 Arcane Prisoner Rescue (quest 11587), 46023 The Ultrasonic Screwdriver (quest 11730). Closes issue #3068

Clean old code for hunter's Heart of the Phoenix, move script effect of hunter's Master's Call to corresponding script.
Move DK's Hungering Cold to spell_scripts table (needs DB support)

--HG--
branch : trunk
This commit is contained in:
azazel committed 2010-08-18 00:20:23 +06:00
1 parent 0284ed4cfe
commit 66fcd52106
12 files changed
+1127 -520

No files matched your search

+335 -169
View File
@@ -22,6 +22,7 @@
*/
#include "ScriptPCH.h"
#include "SpellAuraEffects.h"
enum HunterSpells
{
@@ -32,229 +33,394 @@ enum HunterSpells
HUNTER_PET_HEART_OF_THE_PHOENIX_TRIGGERED = 54114,
HUNTER_PET_HEART_OF_THE_PHOENIX_DEBUFF = 55711,
HUNTER_PET_SPELL_CARRION_FEEDER_TRIGGERED = 54045,
HUNTER_SPELL_INVIGORATION_TRIGGERED = 53398,
HUNTER_SPELL_MASTERS_CALL_TRIGGERED = 62305,
HUNTER_SPELL_CHIMERA_SHOT_SERPENT = 53353,
HUNTER_SPELL_CHIMERA_SHOT_VIPER = 53358,
HUNTER_SPELL_CHIMERA_SHOT_SCORPID = 53359,
};
// 53209 Chimera Shot
class spell_hun_chimera_shot : public SpellHandlerScript
{
public:
spell_hun_chimera_shot() : SpellHandlerScript("spell_hun_chimera_shot") { }
class spell_hun_chimera_shot_SpellScript : public SpellScript
{
bool Validate(SpellEntry const * spellEntry)
{
if (!sSpellStore.LookupEntry(HUNTER_SPELL_CHIMERA_SHOT_SERPENT))
return false;
if (!sSpellStore.LookupEntry(HUNTER_SPELL_CHIMERA_SHOT_VIPER))
return false;
if (!sSpellStore.LookupEntry(HUNTER_SPELL_CHIMERA_SHOT_SCORPID))
return false;
return true;
}
void HandleScriptEffect(SpellEffIndex effIndex)
{
Unit* caster = GetCaster();
Unit* unitTarget = GetHitUnit();
if (!unitTarget)
return;
uint32 spellId = 0;
int32 basePoint = 0;
Unit::AuraApplicationMap& Auras = unitTarget->GetAppliedAuras();
for (Unit::AuraApplicationMap::iterator i = Auras.begin(); i != Auras.end(); ++i)
{
Aura* aura = i->second->GetBase();
if (aura->GetCasterGUID() != caster->GetGUID())
continue;
// Search only Serpent Sting, Viper Sting, Scorpid Sting auras
flag96 familyFlag = aura->GetSpellProto()->SpellFamilyFlags;
if (!(familyFlag[1] & 0x00000080 || familyFlag[0] & 0x0000C000))
continue;
if (AuraEffect const * aurEff = aura->GetEffect(0))
{
// Serpent Sting - Instantly deals 40% of the damage done by your Serpent Sting.
if (familyFlag[0] & 0x4000)
{
int32 TickCount = aurEff->GetTotalTicks();
spellId = HUNTER_SPELL_CHIMERA_SHOT_SERPENT;
basePoint = aurEff->GetAmount() * TickCount * 40 / 100;
}
// Viper Sting - Instantly restores mana to you equal to 60% of the total amount drained by your Viper Sting.
else if (familyFlag[1] & 0x00000080)
{
int32 TickCount = aura->GetEffect(0)->GetTotalTicks();
spellId = HUNTER_SPELL_CHIMERA_SHOT_VIPER;
// Amount of one aura tick
basePoint = aurEff->GetAmount() * unitTarget->GetMaxPower(POWER_MANA) / 100 ;
int32 casterBasePoint = aurEff->GetAmount() * unitTarget->GetMaxPower(POWER_MANA) / 50 ;
if (basePoint > casterBasePoint)
basePoint = casterBasePoint;
basePoint = basePoint * TickCount * 60 / 100;
}
// Scorpid Sting - Attempts to Disarm the target for 10 sec. This effect cannot occur more than once per 1 minute.
else if (familyFlag[0] & 0x00008000)
spellId = HUNTER_SPELL_CHIMERA_SHOT_SCORPID;
// ?? nothing say in spell desc (possibly need addition check)
//if (familyFlag & 0x0000010000000000LL || // dot
// familyFlag & 0x0000100000000000LL) // stun
//{
// spellId = 53366; // 53366 Chimera Shot - Wyvern
//}
// Refresh aura duration
aura->RefreshDuration();
}
break;
}
if (spellId)
caster->CastCustomSpell(unitTarget, spellId, &basePoint, 0, 0, false);
}
void Register()
{
EffectHandlers += EffectHandlerFn(spell_hun_chimera_shot_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const
{
return new spell_hun_chimera_shot_SpellScript();
}
};
// 53412 Invigoration
class spell_hun_invigoration : public SpellHandlerScript
{
public:
spell_hun_invigoration() : SpellHandlerScript("spell_hun_invigoration") { }
class spell_hun_invigoration_SpellScript : public SpellScript
{
bool Validate(SpellEntry const * spellEntry)
{
if (!sSpellStore.LookupEntry(HUNTER_SPELL_INVIGORATION_TRIGGERED))
return false;
return true;
}
void HandleScriptEffect(SpellEffIndex effIndex)
{
if (Unit* unitTarget = GetHitUnit())
if (AuraEffect* aurEff = unitTarget->GetDummyAuraEffect(SPELLFAMILY_HUNTER, 3487, 0))
if (roll_chance_i(aurEff->GetAmount()))
unitTarget->CastSpell(unitTarget, HUNTER_SPELL_INVIGORATION_TRIGGERED, true);
}
void Register()
{
EffectHandlers += EffectHandlerFn(spell_hun_invigoration_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const
{
return new spell_hun_invigoration_SpellScript();
}
};
class spell_hun_last_stand_pet : public SpellHandlerScript
{
public:
public:
spell_hun_last_stand_pet() : SpellHandlerScript("spell_hun_last_stand_pet") { }
spell_hun_last_stand_pet()
: SpellHandlerScript("spell_hun_last_stand_pet")
class spell_hun_last_stand_pet_SpellScript : public SpellScript
{
bool Validate(SpellEntry const * spellEntry)
{
if (!sSpellStore.LookupEntry(HUNTER_PET_SPELL_LAST_STAND_TRIGGERED))
return false;
return true;
}
class spell_hun_last_stand_pet_SpellScript : public SpellScript
void HandleDummy(SpellEffIndex effIndex)
{
bool Validate(SpellEntry const * spellEntry)
{
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();
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();
}
};
class spell_hun_masters_call : public SpellHandlerScript
{
public:
public:
spell_hun_masters_call() : SpellHandlerScript("spell_hun_masters_call") { }
spell_hun_masters_call()
: SpellHandlerScript("spell_hun_masters_call")
class spell_hun_masters_call_SpellScript : public SpellScript
{
bool Validate(SpellEntry const * spellEntry)
{
if (!sSpellStore.LookupEntry(HUNTER_SPELL_MASTERS_CALL_TRIGGERED))
return false;
return true;
}
class spell_hun_masters_call_SpellScript : public SpellScript
void HandleDummy(SpellEffIndex effIndex)
{
void HandleDummy(SpellEffIndex effIndex)
{
Unit *caster = GetCaster();
Unit *unitTarget = GetHitUnit();
Unit *caster = GetCaster();
Unit *unitTarget = GetHitUnit();
if (caster->GetTypeId() != TYPEID_PLAYER || !unitTarget)
return;
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() const
{
return new spell_hun_masters_call_SpellScript();
if (Pet *pet = caster->ToPlayer()->GetPet())
if (pet->isAlive())
pet->CastSpell(unitTarget, SpellMgr::CalculateSpellEffectAmount(GetSpellInfo(), effIndex), true);
}
void HandleScriptEffect(SpellEffIndex effIndex)
{
Unit* caster = GetCaster();
if (caster->GetTypeId() != TYPEID_PLAYER)
return;
if (Pet *pet = caster->ToPlayer()->GetPet())
if (pet->isAlive())
caster->CastSpell(pet, HUNTER_SPELL_MASTERS_CALL_TRIGGERED, true);
}
void Register()
{
EffectHandlers += EffectHandlerFn(spell_hun_masters_call_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
EffectHandlers += EffectHandlerFn(spell_hun_masters_call_SpellScript::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const
{
return new spell_hun_masters_call_SpellScript();
}
};
class spell_hun_readiness : public SpellHandlerScript
{
public:
public:
spell_hun_readiness() : SpellHandlerScript("spell_hun_readiness") { }
spell_hun_readiness()
: SpellHandlerScript("spell_hun_readiness")
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;
}
}
class spell_hun_readiness_SpellScript : public SpellScript
void Register()
{
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()
{
// 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();
// 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();
}
};
// 37506 Scatter Shot
class spell_hun_scatter_shot : public SpellHandlerScript
{
public:
spell_hun_scatter_shot() : SpellHandlerScript("spell_hun_scatter_shot") { }
class spell_hun_scatter_shot_SpellScript : public SpellScript
{
void HandleDummy(SpellEffIndex effIndex)
{
Unit* caster = GetCaster();
if (caster->GetTypeId() != TYPEID_PLAYER)
return;
// break Auto Shot and autohit
caster->InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
caster->AttackStop();
caster->ToPlayer()->SendAttackSwingCancelAttack();
}
void Register()
{
EffectHandlers += EffectHandlerFn(spell_hun_scatter_shot_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const
{
return new spell_hun_scatter_shot_SpellScript();
}
};
class spell_hun_pet_heart_of_the_phoenix : public SpellHandlerScript
{
public:
public:
spell_hun_pet_heart_of_the_phoenix() : SpellHandlerScript("spell_hun_pet_heart_of_the_phoenix") { }
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;
}
class spell_hun_pet_heart_of_the_phoenix_SpellScript : public SpellScript
void HandleScript(SpellEffIndex effIndex)
{
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();
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:
public:
spell_hun_pet_carrion_feeder() : SpellHandlerScript("spell_hun_pet_carrion_feeder") { }
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;
}
class spell_hun_pet_carrion_feeder_SpellScript : public SpellScript
void HandleDummy(SpellEffIndex effIndex)
{
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();
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()
{
new spell_hun_last_stand_pet;
new spell_hun_masters_call;
new spell_hun_readiness;
new spell_hun_pet_heart_of_the_phoenix;
new spell_hun_pet_carrion_feeder;
new spell_hun_chimera_shot();
new spell_hun_invigoration();
new spell_hun_last_stand_pet();
new spell_hun_masters_call();
new spell_hun_readiness();
new spell_hun_scatter_shot();
new spell_hun_pet_heart_of_the_phoenix();
new spell_hun_pet_carrion_feeder();
}