fix(Core/Spells): Sleep aura from Magic Dust should be removed if tar… (#12020)

* fix(Core/Spells): Sleep aura from Magic Dust should be removed if target is too high level.

Fixes #11947

* Update.
This commit is contained in:
UltraNix
2022-06-22 19:52:29 +02:00
committed by GitHub
parent fe3b3b6132
commit a70762910a

View File

@@ -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 (Unit* target = GetHitUnit())
if (target->getLevel() >= 30)
{ {
uint8 chance = 100 - std::min<uint8>(100, target->getLevel() - 30 * urand(3, 10)); if (target->getLevel() >= 30)
if (!roll_chance_i(chance)) {
PreventDefaultAction(); uint8 chance = 100 - std::min<uint8>(100, target->getLevel() - 30 * urand(3, 10));
if (!roll_chance_i(chance))
{
PreventHitAura();
}
}
} }
} }
void Register() override 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);
} }
}; };