From 97a01b430dd3f2b0ba4d6c63bb5c0d7c4f5c5cab Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Sat, 7 Jan 2023 23:08:19 +0100 Subject: [PATCH] fix(Script/Item): Elixir of Shadows for pets (#14514) * closes https://github.com/azerothcore/azerothcore-wotlk/issues/13067 --- .../rev_1672970116654820600.sql | 4 ++++ src/server/scripts/Spells/spell_item.cpp | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 data/sql/updates/pending_db_world/rev_1672970116654820600.sql diff --git a/data/sql/updates/pending_db_world/rev_1672970116654820600.sql b/data/sql/updates/pending_db_world/rev_1672970116654820600.sql new file mode 100644 index 000000000..3e56b2b54 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1672970116654820600.sql @@ -0,0 +1,4 @@ +-- +DELETE FROM `spell_script_names` WHERE `spell_id`=37678 AND `ScriptName`='spell_item_elixir_of_shadows'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(37678, 'spell_item_elixir_of_shadows'); diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 9d527e6fe..973c38622 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -25,6 +25,7 @@ #include "GameTime.h" #include "ObjectMgr.h" #include "Player.h" +#include "Pet.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SkillDiscovery.h" @@ -3758,6 +3759,26 @@ class spell_item_green_whelp_armor : public AuraScript } }; +// 37678 - elixir of shadows +/// @todo Temporary fix until pet restrictions vs player restrictions are investigated +class spell_item_elixir_of_shadows : public SpellScript +{ + PrepareSpellScript(spell_item_elixir_of_shadows); + + void HandleEffect(SpellEffIndex /*effIndex*/) + { + if (Player* player = GetCaster()->ToPlayer()) + if (Pet* pet = player->GetPet()) + pet->AddAura(37678 /*Elixir of Shadows*/, pet); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_item_elixir_of_shadows::HandleEffect, EFFECT_0, SPELL_EFFECT_APPLY_AURA); + OnEffectHitTarget += SpellEffectFn(spell_item_elixir_of_shadows::HandleEffect, EFFECT_1, SPELL_EFFECT_APPLY_AURA); + } +}; + enum TrollDice { TEXT_WORN_TROLL_DICE = 26152 @@ -3914,5 +3935,6 @@ void AddSC_item_spell_scripts() RegisterSpellScript(spell_item_snowman); RegisterSpellScript(spell_item_freeze_rookery_egg); RegisterSpellScript(spell_item_green_whelp_armor); + RegisterSpellScript(spell_item_elixir_of_shadows); RegisterSpellScript(spell_item_worn_troll_dice); }