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

@@ -157,31 +157,30 @@ private:
EventMap _events;
};
class spell_q12641_death_comes_from_on_high_summon_ghouls : public SpellScriptLoader
enum DeathComesFromOnHigh
{
public:
spell_q12641_death_comes_from_on_high_summon_ghouls() : SpellScriptLoader("spell_q12641_death_comes_from_on_high_summon_ghouls") { }
SUMMON_GHOULS_ON_SCARLET_CRUSADE = 54522
};
class spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript : public SpellScript
class spell_q12641_death_comes_from_on_high_summon_ghouls : public SpellScript
{
PrepareSpellScript(spell_q12641_death_comes_from_on_high_summon_ghouls);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
PrepareSpellScript(spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript);
return ValidateSpellInfo({ SUMMON_GHOULS_ON_SCARLET_CRUSADE });
}
void HandleScriptEffect(SpellEffIndex effIndex)
{
PreventHitEffect(effIndex);
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 54522, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
void HandleScriptEffect(SpellEffIndex effIndex)
{
return new spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript();
PreventHitEffect(effIndex);
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), SUMMON_GHOULS_ON_SCARLET_CRUSADE, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_q12641_death_comes_from_on_high_summon_ghouls::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
@@ -406,64 +405,47 @@ enum GiftOfTheHarvester
SAY_GOTHIK_PIT = 0
};
class spell_item_gift_of_the_harvester : public SpellScriptLoader
class spell_item_gift_of_the_harvester : public SpellScript
{
public:
spell_item_gift_of_the_harvester() : SpellScriptLoader("spell_item_gift_of_the_harvester") { }
PrepareSpellScript(spell_item_gift_of_the_harvester);
class spell_item_gift_of_the_harvester_SpellScript : public SpellScript
SpellCastResult CheckRequirement()
{
PrepareSpellScript(spell_item_gift_of_the_harvester_SpellScript);
SpellCastResult CheckRequirement()
std::list<Creature*> ghouls;
GetCaster()->GetAllMinionsByEntry(ghouls, NPC_GHOUL);
if (ghouls.size() >= MAX_GHOULS)
{
std::list<Creature*> ghouls;
GetCaster()->GetAllMinionsByEntry(ghouls, NPC_GHOUL);
if (ghouls.size() >= MAX_GHOULS)
{
SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_TOO_MANY_GHOULS);
return SPELL_FAILED_CUSTOM_ERROR;
}
return SPELL_CAST_OK;
SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_TOO_MANY_GHOULS);
return SPELL_FAILED_CUSTOM_ERROR;
}
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_item_gift_of_the_harvester_SpellScript::CheckRequirement);
}
};
return SPELL_CAST_OK;
}
SpellScript* GetSpellScript() const override
void Register() override
{
return new spell_item_gift_of_the_harvester_SpellScript();
OnCheckCast += SpellCheckCastFn(spell_item_gift_of_the_harvester::CheckRequirement);
}
};
class spell_q12698_the_gift_that_keeps_on_giving : public SpellScriptLoader
class spell_q12698_the_gift_that_keeps_on_giving : public SpellScript
{
public:
spell_q12698_the_gift_that_keeps_on_giving() : SpellScriptLoader("spell_q12698_the_gift_that_keeps_on_giving") { }
PrepareSpellScript(spell_q12698_the_gift_that_keeps_on_giving);
class spell_q12698_the_gift_that_keeps_on_giving_SpellScript : public SpellScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
PrepareSpellScript(spell_q12698_the_gift_that_keeps_on_giving_SpellScript);
return ValidateSpellInfo({ SPELL_SUMMON_SCARLET_GHOST });
}
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
{
if (GetOriginalCaster() && GetHitUnit())
GetOriginalCaster()->CastSpell(GetHitUnit(), urand(0, 1) ? GetEffectValue() : SPELL_SUMMON_SCARLET_GHOST, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_q12698_the_gift_that_keeps_on_giving_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
{
return new spell_q12698_the_gift_that_keeps_on_giving_SpellScript();
if (GetOriginalCaster() && GetHitUnit())
GetOriginalCaster()->CastSpell(GetHitUnit(), urand(0, 1) ? GetEffectValue() : SPELL_SUMMON_SCARLET_GHOST, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_q12698_the_gift_that_keeps_on_giving::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
@@ -1237,10 +1219,10 @@ void AddSC_the_scarlet_enclave_c1()
{
// Ours
RegisterCreatureAI(npc_eye_of_acherus);
new spell_q12641_death_comes_from_on_high_summon_ghouls();
RegisterSpellScript(spell_q12641_death_comes_from_on_high_summon_ghouls);
new npc_death_knight_initiate();
new spell_item_gift_of_the_harvester();
new spell_q12698_the_gift_that_keeps_on_giving();
RegisterSpellScript(spell_item_gift_of_the_harvester);
RegisterSpellScript(spell_q12698_the_gift_that_keeps_on_giving);
new npc_scarlet_ghoul();
new npc_dkc1_gothik();
new npc_scarlet_cannon();

View File

@@ -1177,75 +1177,53 @@ public:
};
};
class spell_chapter5_light_of_dawn_aura : public SpellScriptLoader
class spell_chapter5_light_of_dawn_aura : public AuraScript
{
public:
spell_chapter5_light_of_dawn_aura() : SpellScriptLoader("spell_chapter5_light_of_dawn_aura") { }
PrepareAuraScript(spell_chapter5_light_of_dawn_aura);
class spell_chapter5_light_of_dawn_aura_AuraScript : public AuraScript
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
PrepareAuraScript(spell_chapter5_light_of_dawn_aura_AuraScript);
GetUnitOwner()->Dismount();
GetUnitOwner()->SetCanFly(true);
GetUnitOwner()->SetDisableGravity(true);
GetUnitOwner()->AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
}
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetUnitOwner()->Dismount();
GetUnitOwner()->SetCanFly(true);
GetUnitOwner()->SetDisableGravity(true);
GetUnitOwner()->AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetUnitOwner()->SetCanFly(false);
GetUnitOwner()->SetDisableGravity(false);
GetUnitOwner()->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING);
GetUnitOwner()->GetMotionMaster()->MoveFall();
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_chapter5_light_of_dawn_aura_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_chapter5_light_of_dawn_aura_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_chapter5_light_of_dawn_aura_AuraScript();
GetUnitOwner()->SetCanFly(false);
GetUnitOwner()->SetDisableGravity(false);
GetUnitOwner()->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING);
GetUnitOwner()->GetMotionMaster()->MoveFall();
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_chapter5_light_of_dawn_aura::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_chapter5_light_of_dawn_aura::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
class spell_chapter5_rebuke : public SpellScriptLoader
class spell_chapter5_rebuke : public SpellScript
{
public:
spell_chapter5_rebuke() : SpellScriptLoader("spell_chapter5_rebuke") { }
PrepareSpellScript(spell_chapter5_rebuke);
class spell_chapter5_rebuke_SpellScript : public SpellScript
void HandleLeapBack(SpellEffIndex effIndex)
{
PrepareSpellScript(spell_chapter5_rebuke_SpellScript);
PreventHitEffect(effIndex);
if (Unit* unitTarget = GetHitUnit())
unitTarget->KnockbackFrom(2282.86f, -5263.45f, 40.0f, 8.0f);
}
void HandleLeapBack(SpellEffIndex effIndex)
{
PreventHitEffect(effIndex);
if (Unit* unitTarget = GetHitUnit())
unitTarget->KnockbackFrom(2282.86f, -5263.45f, 40.0f, 8.0f);
}
void Register() override
{
OnEffectLaunchTarget += SpellEffectFn(spell_chapter5_rebuke_SpellScript::HandleLeapBack, EFFECT_0, SPELL_EFFECT_LEAP_BACK);
}
};
SpellScript* GetSpellScript() const override
void Register() override
{
return new spell_chapter5_rebuke_SpellScript();
OnEffectLaunchTarget += SpellEffectFn(spell_chapter5_rebuke::HandleLeapBack, EFFECT_0, SPELL_EFFECT_LEAP_BACK);
}
};
void AddSC_the_scarlet_enclave_c5()
{
new npc_highlord_darion_mograine();
new spell_chapter5_light_of_dawn_aura();
new spell_chapter5_rebuke();
RegisterSpellScript(spell_chapter5_light_of_dawn_aura);
RegisterSpellScript(spell_chapter5_rebuke);
}