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); } };