diff options
author | offl <11556157+offl@users.noreply.github.com> | 2021-07-11 14:57:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-11 14:57:37 +0300 |
commit | 0ddcfbf8a0d574a22bd4724d4df699b850d02d06 (patch) | |
tree | 176a559ccd1d0dac003b713653b15a9cb4d656a1 | |
parent | 160d4778112f92b19bfbe1f4d5730e3044feb678 (diff) |
Scripts/Spells: Update Winter Veil holiday scripts to new register model (#26668)
-rw-r--r-- | src/server/scripts/Spells/spell_holiday.cpp | 110 |
1 files changed, 44 insertions, 66 deletions
diff --git a/src/server/scripts/Spells/spell_holiday.cpp b/src/server/scripts/Spells/spell_holiday.cpp index b0e6d2658d3..fa00722a71b 100644 --- a/src/server/scripts/Spells/spell_holiday.cpp +++ b/src/server/scripts/Spells/spell_holiday.cpp @@ -973,44 +973,33 @@ enum Mistletoe }; // 26218 - Mistletoe -class spell_winter_veil_mistletoe : public SpellScriptLoader +class spell_winter_veil_mistletoe : public SpellScript { - public: - spell_winter_veil_mistletoe() : SpellScriptLoader("spell_winter_veil_mistletoe") { } + PrepareSpellScript(spell_winter_veil_mistletoe); - class spell_winter_veil_mistletoe_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo( { - PrepareSpellScript(spell_winter_veil_mistletoe_SpellScript); - - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo( - { - SPELL_CREATE_MISTLETOE, - SPELL_CREATE_HOLLY, - SPELL_CREATE_SNOWFLAKES - }); - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Player* target = GetHitPlayer()) - { - uint32 spellId = RAND(SPELL_CREATE_HOLLY, SPELL_CREATE_MISTLETOE, SPELL_CREATE_SNOWFLAKES); - GetCaster()->CastSpell(target, spellId, true); - } - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_winter_veil_mistletoe_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + SPELL_CREATE_MISTLETOE, + SPELL_CREATE_HOLLY, + SPELL_CREATE_SNOWFLAKES + }); + } - SpellScript* GetSpellScript() const override + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Player* target = GetHitPlayer()) { - return new spell_winter_veil_mistletoe_SpellScript(); + uint32 spellId = RAND(SPELL_CREATE_HOLLY, SPELL_CREATE_MISTLETOE, SPELL_CREATE_SNOWFLAKES); + GetCaster()->CastSpell(target, spellId, true); } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_winter_veil_mistletoe::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } }; // 26275 - PX-238 Winter Wondervolt TRAP @@ -1031,44 +1020,33 @@ uint32 const WonderboltTransformSpells[] = }; // 26275 - PX-238 Winter Wondervolt TRAP -class spell_winter_veil_px_238_winter_wondervolt : public SpellScriptLoader +class spell_winter_veil_px_238_winter_wondervolt : public SpellScript { - public: - spell_winter_veil_px_238_winter_wondervolt() : SpellScriptLoader("spell_winter_veil_px_238_winter_wondervolt") { } - - class spell_winter_veil_px_238_winter_wondervolt_SpellScript : public SpellScript - { - PrepareSpellScript(spell_winter_veil_px_238_winter_wondervolt_SpellScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo(WonderboltTransformSpells); - } - - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - - if (Unit* target = GetHitUnit()) - { - for (uint32 spell : WonderboltTransformSpells) - if (target->HasAura(spell)) - return; + PrepareSpellScript(spell_winter_veil_px_238_winter_wondervolt); - target->CastSpell(target, Trinity::Containers::SelectRandomContainerElement(WonderboltTransformSpells), true); - } - } + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo(WonderboltTransformSpells); + } - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_winter_veil_px_238_winter_wondervolt_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + void HandleScript(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); - SpellScript* GetSpellScript() const override + if (Unit* target = GetHitUnit()) { - return new spell_winter_veil_px_238_winter_wondervolt_SpellScript(); + for (uint32 spell : WonderboltTransformSpells) + if (target->HasAura(spell)) + return; + + target->CastSpell(target, Trinity::Containers::SelectRandomContainerElement(WonderboltTransformSpells), true); } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_winter_veil_px_238_winter_wondervolt::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } }; enum RamBlaBla @@ -1959,8 +1937,8 @@ void AddSC_holiday_spell_scripts() new spell_pilgrims_bounty_a_serving_of("spell_pilgrims_bounty_a_serving_of_potatoes", SPELL_A_SERVING_OF_SWEET_POTATOES_PLATE); new spell_pilgrims_bounty_a_serving_of("spell_pilgrims_bounty_a_serving_of_pie", SPELL_A_SERVING_OF_PIE_PLATE); // Winter Veil - new spell_winter_veil_mistletoe(); - new spell_winter_veil_px_238_winter_wondervolt(); + RegisterSpellScript(spell_winter_veil_mistletoe); + RegisterSpellScript(spell_winter_veil_px_238_winter_wondervolt); // Brewfest new spell_brewfest_giddyup(); new spell_brewfest_ram(); |