From f990fbb7abc6efbde3b4c2fe2a7f548466fc8d20 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Fri, 6 Dec 2019 16:40:41 +0100 Subject: [PATCH] Core/Spells: updated Master of Elements script to new model and simplified code --- .../custom/custom_2019_12_06_00_world.sql | 1 + src/server/scripts/Spells/spell_mage.cpp | 60 ++++++++----------- 2 files changed, 26 insertions(+), 35 deletions(-) create mode 100644 sql/updates/world/custom/custom_2019_12_06_00_world.sql diff --git a/sql/updates/world/custom/custom_2019_12_06_00_world.sql b/sql/updates/world/custom/custom_2019_12_06_00_world.sql new file mode 100644 index 00000000000..0990153f0b7 --- /dev/null +++ b/sql/updates/world/custom/custom_2019_12_06_00_world.sql @@ -0,0 +1 @@ +UPDATE `spell_proc` SET `SchoolMask`= 0, `SpellTypeMask`= 1 WHERE `SpellId`= -29074; diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp index 12c46779e2b..a46e6d394a0 100644 --- a/src/server/scripts/Spells/spell_mage.cpp +++ b/src/server/scripts/Spells/spell_mage.cpp @@ -1001,47 +1001,37 @@ class spell_mage_mana_shield : public SpellScriptLoader }; // -29074 - Master of Elements -class spell_mage_master_of_elements : public SpellScriptLoader +class spell_mage_master_of_elements : public AuraScript { - public: - spell_mage_master_of_elements() : SpellScriptLoader("spell_mage_master_of_elements") { } + PrepareAuraScript(spell_mage_master_of_elements); - class spell_mage_master_of_elements_AuraScript : public AuraScript - { - PrepareAuraScript(spell_mage_master_of_elements_AuraScript); + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_MAGE_MASTER_OF_ELEMENTS_ENERGIZE }); + } - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_MAGE_MASTER_OF_ELEMENTS_ENERGIZE }); - } + bool CheckProc(ProcEventInfo& eventInfo) + { + return eventInfo.GetDamageInfo()->GetSpellInfo() != nullptr; + } - bool CheckProc(ProcEventInfo& eventInfo) - { - return eventInfo.GetDamageInfo()->GetSpellInfo() != nullptr; - } + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); - void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); + SpellInfo const* spell = eventInfo.GetSpellInfo(); + int32 mana = int32(spell->CalcPowerCost(GetTarget(), spell->GetSchoolMask())); + mana = CalculatePct(mana, aurEff->GetAmount()); - int32 mana = int32(eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo()->GetSchoolMask())); - mana = CalculatePct(mana, aurEff->GetAmount()); + if (mana) + GetTarget()->CastCustomSpell(SPELL_MAGE_MASTER_OF_ELEMENTS_ENERGIZE, SPELLVALUE_BASE_POINT0, mana, GetTarget(), true, nullptr, aurEff); + } - if (mana > 0) - GetTarget()->CastCustomSpell(SPELL_MAGE_MASTER_OF_ELEMENTS_ENERGIZE, SPELLVALUE_BASE_POINT0, mana, GetTarget(), true, nullptr, aurEff); - } - - void Register() override - { - DoCheckProc += AuraCheckProcFn(spell_mage_master_of_elements_AuraScript::CheckProc); - OnEffectProc += AuraEffectProcFn(spell_mage_master_of_elements_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_mage_master_of_elements_AuraScript(); - } + void Register() override + { + DoCheckProc += AuraCheckProcFn(spell_mage_master_of_elements::CheckProc); + OnEffectProc += AuraEffectProcFn(spell_mage_master_of_elements::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); + } }; // -86181 - Nether Vortex @@ -2346,7 +2336,7 @@ void AddSC_mage_spell_scripts() RegisterAuraScript(spell_mage_living_bomb); new spell_mage_mage_ward(); new spell_mage_mana_shield(); - new spell_mage_master_of_elements(); + RegisterAuraScript(spell_mage_master_of_elements); RegisterSpellAndAuraScriptPair(spell_mage_mirror_image, spell_mage_mirror_image_AurasScript); RegisterAuraScript(spell_mage_nether_vortex); RegisterAuraScript(spell_mage_offensive_state_dnd);