refactor(Scripts/EasternKingdoms): spell scripts use registry macros (#20399)

This commit is contained in:
Jelle Meeus
2024-11-01 20:54:41 +01:00
committed by GitHub
parent bbbcaac77c
commit 7410175a08
9 changed files with 308 additions and 433 deletions

View File

@@ -227,71 +227,54 @@ public:
}
};
class spell_temple_of_atal_hakkar_hex_of_jammal_an : public SpellScriptLoader
class spell_temple_of_atal_hakkar_hex_of_jammal_an_aura : public AuraScript
{
public:
spell_temple_of_atal_hakkar_hex_of_jammal_an() : SpellScriptLoader("spell_temple_of_atal_hakkar_hex_of_jammal_an") { }
PrepareAuraScript(spell_temple_of_atal_hakkar_hex_of_jammal_an_aura);
class spell_temple_of_atal_hakkar_hex_of_jammal_an_AuraScript : public AuraScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
PrepareAuraScript(spell_temple_of_atal_hakkar_hex_of_jammal_an_AuraScript);
return ValidateSpellInfo({ HEX_OF_JAMMAL_AN, HEX_OF_JAMMAL_AN_CHARM });
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* caster = GetCaster())
if (caster->IsAlive() && caster->IsInCombat())
{
caster->CastSpell(GetTarget(), HEX_OF_JAMMAL_AN, true);
caster->CastSpell(GetTarget(), HEX_OF_JAMMAL_AN_CHARM, true);
}
}
void Register() override
{
OnEffectRemove += AuraEffectRemoveFn(spell_temple_of_atal_hakkar_hex_of_jammal_an_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
return new spell_temple_of_atal_hakkar_hex_of_jammal_an_AuraScript();
if (Unit* caster = GetCaster())
if (caster->IsAlive() && caster->IsInCombat())
{
caster->CastSpell(GetTarget(), HEX_OF_JAMMAL_AN, true);
caster->CastSpell(GetTarget(), HEX_OF_JAMMAL_AN_CHARM, true);
}
}
void Register() override
{
OnEffectRemove += AuraEffectRemoveFn(spell_temple_of_atal_hakkar_hex_of_jammal_an_aura::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
class spell_temple_of_atal_hakkar_awaken_the_soulflayer : public SpellScriptLoader
class spell_temple_of_atal_hakkar_awaken_the_soulflayer : public SpellScript
{
public:
spell_temple_of_atal_hakkar_awaken_the_soulflayer() : SpellScriptLoader("spell_temple_of_atal_hakkar_awaken_the_soulflayer") { }
PrepareSpellScript(spell_temple_of_atal_hakkar_awaken_the_soulflayer);
class spell_temple_of_atal_hakkar_awaken_the_soulflayer_SpellScript : public SpellScript
void HandleSendEvent(SpellEffIndex effIndex)
{
PrepareSpellScript(spell_temple_of_atal_hakkar_awaken_the_soulflayer_SpellScript);
PreventHitDefaultEffect(effIndex);
InstanceScript* instanceScript = GetCaster()->GetInstanceScript();
Map* map = GetCaster()->FindMap();
if (!map || !instanceScript || instanceScript->GetData(TYPE_HAKKAR_EVENT) != NOT_STARTED)
return;
void HandleSendEvent(SpellEffIndex effIndex)
Position pos = {-466.795f, 272.863f, -90.447f, 1.57f};
if (TempSummon* summon = map->SummonCreature(NPC_SHADE_OF_HAKKAR, pos))
{
PreventHitDefaultEffect(effIndex);
InstanceScript* instanceScript = GetCaster()->GetInstanceScript();
Map* map = GetCaster()->FindMap();
if (!map || !instanceScript || instanceScript->GetData(TYPE_HAKKAR_EVENT) != NOT_STARTED)
return;
Position pos = {-466.795f, 272.863f, -90.447f, 1.57f};
if (TempSummon* summon = map->SummonCreature(NPC_SHADE_OF_HAKKAR, pos))
{
summon->SetTempSummonType(TEMPSUMMON_MANUAL_DESPAWN);
instanceScript->SetData(TYPE_HAKKAR_EVENT, IN_PROGRESS);
}
summon->SetTempSummonType(TEMPSUMMON_MANUAL_DESPAWN);
instanceScript->SetData(TYPE_HAKKAR_EVENT, IN_PROGRESS);
}
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_temple_of_atal_hakkar_awaken_the_soulflayer_SpellScript::HandleSendEvent, EFFECT_0, SPELL_EFFECT_SEND_EVENT);
}
};
SpellScript* GetSpellScript() const override
void Register() override
{
return new spell_temple_of_atal_hakkar_awaken_the_soulflayer_SpellScript();
OnEffectHit += SpellEffectFn(spell_temple_of_atal_hakkar_awaken_the_soulflayer::HandleSendEvent, EFFECT_0, SPELL_EFFECT_SEND_EVENT);
}
};
@@ -299,6 +282,6 @@ void AddSC_instance_sunken_temple()
{
new instance_sunken_temple();
new at_malfurion_stormrage();
new spell_temple_of_atal_hakkar_hex_of_jammal_an();
new spell_temple_of_atal_hakkar_awaken_the_soulflayer();
RegisterSpellScript(spell_temple_of_atal_hakkar_hex_of_jammal_an_aura);
RegisterSpellScript(spell_temple_of_atal_hakkar_awaken_the_soulflayer);
}