From b43c5c9bf33b5c224b76e6b6c0b9054813582d56 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Tue, 2 Feb 2021 16:08:52 +0100 Subject: [PATCH] fix(Core/Spell): Instant Statue (#4319) * fix(Core/Spell): Instant Statue * make sure GetCaster() is not null * values * unit not player * scriptName * Update spell_item.cpp * feat(Core/Spell): Implement ValidateSpellInfo * Cherry-pick from https://github.com/TrinityCore/TrinityCore/commit/2b5d7eef3a091e67c27e853d43ac0bebbfa67531 & https://github.com/TrinityCore/TrinityCore/commit/a0a158b5b851db7e2c16819ec89e913d914a3aba * Revert "feat(Core/Spell): Implement ValidateSpellInfo" This reverts commit 7690f02b49c82c65de3e92307063211a2e9941f5. * Revert "Revert "feat(Core/Spell): Implement ValidateSpellInfo"" This reverts commit 8ffbb46fafe1f2d1597b4295b9e5fcec822d1181. * Update spell_item.cpp * dependant on https://github.com/azerothcore/azerothcore-wotlk/pull/4323 * untargetable --- .../rev_1611180684314340400.sql | 11 +++++ src/server/scripts/Spells/spell_item.cpp | 47 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 data/sql/updates/pending_db_world/rev_1611180684314340400.sql diff --git a/data/sql/updates/pending_db_world/rev_1611180684314340400.sql b/data/sql/updates/pending_db_world/rev_1611180684314340400.sql new file mode 100644 index 000000000..ca984158c --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1611180684314340400.sql @@ -0,0 +1,11 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1611180684314340400'); + +DELETE FROM `spell_script_names` WHERE `spell_id` = 75731; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(75731, 'spell_item_instant_statue'); +UPDATE `creature_template` SET `unit_flags`=`unit_flags`|33554432, `AIName` = '' WHERE `entry` = 40246; +DELETE FROM `spell_linked_spell` WHERE `spell_trigger` IN (74890, -75731); +INSERT INTO `spell_linked_spell` (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES +(74890, 75055, 0, 'Instant Statue'), +(-75731, -74890, 0, 'Instant Statue'), +(-75731, -75055, 0, 'Instant Statue'); diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index b1087923c..7445ef165 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -1550,6 +1550,52 @@ public: } }; +enum InstantStatue +{ + CREATURE_INSTANT_STATUE_PEDESTAL = 40246, + SPELL_INSTANT_STATUE = 75731 +}; + +class spell_item_instant_statue : public SpellScriptLoader +{ +public: + spell_item_instant_statue() : SpellScriptLoader("spell_item_instant_statue") { } + + class spell_item_instant_stature_AuraScript : public AuraScript + { + PrepareAuraScript(spell_item_instant_stature_AuraScript); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_INSTANT_STATUE }); + } + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* caster = GetCaster(); + if (!caster) + { + return; + } + + if (Creature* creature = caster->FindNearestCreature(CREATURE_INSTANT_STATUE_PEDESTAL, 0.0f, true)) + { + creature->RemoveAurasDueToSpell(SPELL_INSTANT_STATUE); + } + } + + void Register() override + { + OnEffectRemove += AuraEffectRemoveFn(spell_item_instant_stature_AuraScript::OnRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_item_instant_stature_AuraScript(); + } +}; + // Theirs // Generic script for handling item dummy effects which trigger another spell. class spell_item_trigger_spell : public SpellScriptLoader @@ -4241,6 +4287,7 @@ void AddSC_item_spell_scripts() new spell_item_direbrew_remote(); new spell_item_eye_of_gruul_healing_discount(); new spell_item_summon_argent_knight(); + new spell_item_instant_statue(); // Theirs // 23074 Arcanite Dragonling