From a70762910a4d0fa9c271f9f152e44c96ec4e193b Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Wed, 22 Jun 2022 19:52:29 +0200 Subject: [PATCH] =?UTF-8?q?fix(Core/Spells):=20Sleep=20aura=20from=20Magic?= =?UTF-8?q?=20Dust=20should=20be=20removed=20if=20tar=E2=80=A6=20(#12020)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(Core/Spells): Sleep aura from Magic Dust should be removed if target is too high level. Fixes #11947 * Update. --- src/server/scripts/Spells/spell_item.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 969e04e7e..3c2984212 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -273,24 +273,28 @@ class spell_item_with_mount_speed : public AuraScript } }; -class spell_item_magic_dust : public AuraScript +class spell_item_magic_dust : public SpellScript { - PrepareAuraScript(spell_item_magic_dust); + PrepareSpellScript(spell_item_magic_dust); - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + void HandlePreventAura(SpellEffIndex /*effIndex*/) { - Unit* target = GetTarget(); - if (target->getLevel() >= 30) + if (Unit* target = GetHitUnit()) { - uint8 chance = 100 - std::min(100, target->getLevel() - 30 * urand(3, 10)); - if (!roll_chance_i(chance)) - PreventDefaultAction(); + if (target->getLevel() >= 30) + { + uint8 chance = 100 - std::min(100, target->getLevel() - 30 * urand(3, 10)); + if (!roll_chance_i(chance)) + { + PreventHitAura(); + } + } } } void Register() override { - OnEffectApply += AuraEffectApplyFn(spell_item_magic_dust::OnApply, EFFECT_0, SPELL_AURA_MOD_STUN, AURA_EFFECT_HANDLE_REAL); + OnEffectHitTarget += SpellEffectFn(spell_item_magic_dust::HandlePreventAura, EFFECT_0, SPELL_EFFECT_APPLY_AURA); } };