refactor(Scripts/TempestKeep): Spell Scripts use registry macros (#19123)

* init sql

* instance_the_eye aura:spell_the_eye_countercharge_aura

* instance_the_botanica aura:spell_botanica_call_of_the_falcon_aura

* instance_the_botanica aura:spell_botanica_shift_form_aura

* arcatraz aura:spell_arcatraz_soul_steal_aura
This commit is contained in:
Jelle Meeus
2024-06-22 10:19:43 +02:00
committed by GitHub
parent e83e343aec
commit f65283c35a
4 changed files with 122 additions and 156 deletions
@@ -0,0 +1,5 @@
--
UPDATE `spell_script_names` SET `ScriptName`='spell_the_eye_countercharge_aura' WHERE `spell_id`=35035;
UPDATE `spell_script_names` SET `ScriptName`='spell_botanica_call_of_the_falcon_aura' WHERE `spell_id`=34852;
UPDATE `spell_script_names` SET `ScriptName`='spell_botanica_shift_form_aura' WHERE `spell_id`=34201;
UPDATE `spell_script_names` SET `ScriptName`='spell_arcatraz_soul_steal_aura' WHERE `spell_id`=36778;
@@ -145,37 +145,26 @@ public:
} }
}; };
class spell_the_eye_countercharge : public SpellScriptLoader class spell_the_eye_countercharge_aura : public AuraScript
{ {
public: PrepareAuraScript(spell_the_eye_countercharge_aura);
spell_the_eye_countercharge() : SpellScriptLoader("spell_the_eye_countercharge") { }
class spell_the_eye_counterchargeScript : public AuraScript bool PrepareProc(ProcEventInfo& /*eventInfo*/)
{ {
PrepareAuraScript(spell_the_eye_counterchargeScript); // xinef: prevent charge drop
PreventDefaultAction();
return true;
}
bool PrepareProc(ProcEventInfo& /*eventInfo*/) void Register() override
{
// xinef: prevent charge drop
PreventDefaultAction();
return true;
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_the_eye_counterchargeScript::PrepareProc);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_the_eye_counterchargeScript(); DoCheckProc += AuraCheckProcFn(spell_the_eye_countercharge_aura::PrepareProc);
} }
}; };
void AddSC_instance_the_eye() void AddSC_instance_the_eye()
{ {
new instance_the_eye(); new instance_the_eye();
new spell_the_eye_countercharge(); RegisterSpellScript(spell_the_eye_countercharge_aura);
} }
@@ -585,37 +585,31 @@ public:
} }
}; };
class spell_arcatraz_soul_steal : public SpellScriptLoader class spell_arcatraz_soul_steal_aura : public AuraScript
{ {
public: PrepareAuraScript(spell_arcatraz_soul_steal_aura);
spell_arcatraz_soul_steal() : SpellScriptLoader("spell_arcatraz_soul_steal") { }
class spell_arcatraz_soul_steal_AuraScript : public AuraScript bool Validate(SpellInfo const* /*spellInfo*/) override
{ {
PrepareAuraScript(spell_arcatraz_soul_steal_AuraScript) return ValidateSpellInfo({ SPELL_SOUL_STEAL });
}
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* caster = GetCaster())
caster->CastSpell(caster, SPELL_SOUL_STEAL, true);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* caster = GetCaster())
caster->RemoveAurasDueToSpell(SPELL_SOUL_STEAL);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_arcatraz_soul_steal_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_arcatraz_soul_steal_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_arcatraz_soul_steal_AuraScript(); if (Unit* caster = GetCaster())
caster->CastSpell(caster, SPELL_SOUL_STEAL, true);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* caster = GetCaster())
caster->RemoveAurasDueToSpell(SPELL_SOUL_STEAL);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_arcatraz_soul_steal_aura::HandleEffectApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_arcatraz_soul_steal_aura::HandleEffectRemove, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL);
} }
}; };
@@ -624,6 +618,6 @@ void AddSC_arcatraz()
new npc_millhouse_manastorm(); new npc_millhouse_manastorm();
new npc_warden_mellichar(); new npc_warden_mellichar();
new spell_arcatraz_soul_steal(); RegisterSpellScript(spell_arcatraz_soul_steal_aura);
} }
@@ -42,136 +42,114 @@ public:
} }
}; };
class spell_botanica_call_of_the_falcon : public SpellScriptLoader class spell_botanica_call_of_the_falcon_aura : public AuraScript
{ {
public: PrepareAuraScript(spell_botanica_call_of_the_falcon_aura);
spell_botanica_call_of_the_falcon() : SpellScriptLoader("spell_botanica_call_of_the_falcon") { }
class spell_botanica_call_of_the_falcon_AuraScript : public AuraScript bool Load() override
{ {
PrepareAuraScript(spell_botanica_call_of_the_falcon_AuraScript) _falconSet.clear();
return true;
bool Load() override
{
_falconSet.clear();
return true;
}
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
std::list<Creature*> creatureList;
GetUnitOwner()->GetCreaturesWithEntryInRange(creatureList, 80.0f, NPC_BLOODFALCON);
for (std::list<Creature*>::const_iterator itr = creatureList.begin(); itr != creatureList.end(); ++itr)
{
(*itr)->TauntApply(GetUnitOwner());
(*itr)->AddThreat(GetUnitOwner(), 10000000.0f);
_falconSet.insert((*itr)->GetGUID());
}
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
for (ObjectGuid const& guid : _falconSet)
if (Creature* falcon = ObjectAccessor::GetCreature(*GetUnitOwner(), guid))
{
falcon->TauntFadeOut(GetUnitOwner());
falcon->AddThreat(GetUnitOwner(), -10000000.0f);
}
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_botanica_call_of_the_falcon_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_botanica_call_of_the_falcon_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
private:
GuidSet _falconSet;
};
AuraScript* GetAuraScript() const override
{
return new spell_botanica_call_of_the_falcon_AuraScript();
} }
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
std::list<Creature*> creatureList;
GetUnitOwner()->GetCreaturesWithEntryInRange(creatureList, 80.0f, NPC_BLOODFALCON);
for (std::list<Creature*>::const_iterator itr = creatureList.begin(); itr != creatureList.end(); ++itr)
{
(*itr)->TauntApply(GetUnitOwner());
(*itr)->AddThreat(GetUnitOwner(), 10000000.0f);
_falconSet.insert((*itr)->GetGUID());
}
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
for (ObjectGuid const& guid : _falconSet)
if (Creature* falcon = ObjectAccessor::GetCreature(*GetUnitOwner(), guid))
{
falcon->TauntFadeOut(GetUnitOwner());
falcon->AddThreat(GetUnitOwner(), -10000000.0f);
}
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_botanica_call_of_the_falcon_aura::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_botanica_call_of_the_falcon_aura::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
private:
GuidSet _falconSet;
}; };
class spell_botanica_shift_form : public SpellScriptLoader class spell_botanica_shift_form_aura : public AuraScript
{ {
public: PrepareAuraScript(spell_botanica_shift_form_aura);
spell_botanica_shift_form() : SpellScriptLoader("spell_botanica_shift_form") { }
class spell_botanica_shift_form_AuraScript : public AuraScript bool Load() override
{ {
PrepareAuraScript(spell_botanica_shift_form_AuraScript); _lastSchool = 0;
_lastForm = 0;
_swapTime = 0;
return true;
}
bool Load() override bool CheckProc(ProcEventInfo& eventInfo)
{
if (SpellInfo const* spellInfo = eventInfo.GetSpellInfo())
{ {
_lastSchool = 0; if ((spellInfo->GetSchoolMask() & _lastSchool) && _swapTime > GameTime::GetGameTime().count())
_lastForm = 0; return false;
_swapTime = 0;
return true;
}
bool CheckProc(ProcEventInfo& eventInfo) uint32 form = 0;
{ switch (GetFirstSchoolInMask(spellInfo->GetSchoolMask()))
if (SpellInfo const* spellInfo = eventInfo.GetSpellInfo())
{ {
if ((spellInfo->GetSchoolMask() & _lastSchool) && _swapTime > GameTime::GetGameTime().count()) case SPELL_SCHOOL_FIRE:
return false; form = SPELL_FIRE_FORM;
break;
uint32 form = 0; case SPELL_SCHOOL_FROST:
switch (GetFirstSchoolInMask(spellInfo->GetSchoolMask())) form = SPELL_FROST_FORM;
{ break;
case SPELL_SCHOOL_FIRE: case SPELL_SCHOOL_ARCANE:
form = SPELL_FIRE_FORM; form = SPELL_ARCANE_FORM;
break; break;
case SPELL_SCHOOL_FROST: case SPELL_SCHOOL_SHADOW:
form = SPELL_FROST_FORM; form = SPELL_SHADOW_FORM;
break; break;
case SPELL_SCHOOL_ARCANE: default:
form = SPELL_ARCANE_FORM; break;
break;
case SPELL_SCHOOL_SHADOW:
form = SPELL_SHADOW_FORM;
break;
default:
break;
}
if (form)
{
_swapTime = GameTime::GetGameTime().count() + 6;
_lastSchool = spellInfo->GetSchoolMask();
GetUnitOwner()->RemoveAurasDueToSpell(_lastForm);
_lastForm = form;
GetUnitOwner()->CastSpell(GetUnitOwner(), _lastForm, true);
}
} }
return false; if (form)
{
_swapTime = GameTime::GetGameTime().count() + 6;
_lastSchool = spellInfo->GetSchoolMask();
GetUnitOwner()->RemoveAurasDueToSpell(_lastForm);
_lastForm = form;
GetUnitOwner()->CastSpell(GetUnitOwner(), _lastForm, true);
}
} }
void Register() override return false;
{
DoCheckProc += AuraCheckProcFn(spell_botanica_shift_form_AuraScript::CheckProc);
}
private:
uint32 _lastSchool;
uint32 _lastForm;
uint32 _swapTime;
};
AuraScript* GetAuraScript() const override
{
return new spell_botanica_shift_form_AuraScript();
} }
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_botanica_shift_form_aura::CheckProc);
}
private:
uint32 _lastSchool;
uint32 _lastForm;
uint32 _swapTime;
}; };
void AddSC_instance_the_botanica() void AddSC_instance_the_botanica()
{ {
new instance_the_botanica(); new instance_the_botanica();
new spell_botanica_call_of_the_falcon(); RegisterSpellScript(spell_botanica_call_of_the_falcon_aura);
new spell_botanica_shift_form(); RegisterSpellScript(spell_botanica_shift_form_aura);
} }