diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index dad5a4198..de6d99e83 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1613,6 +1613,7 @@ public: void ClearInCombat(); void ClearInPetCombat(); [[nodiscard]] uint32 GetCombatTimer() const { return m_CombatTimer; } + void SetCombatTimer(uint32 timer) { m_CombatTimer = timer; } [[nodiscard]] bool HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint32 familyFlags) const; [[nodiscard]] bool virtual HasSpell(uint32 /*spellID*/) const { return false; } diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index 78fd2df69..944221d64 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -808,29 +808,39 @@ class spell_pri_vampiric_touch : public AuraScript }; // 605 - Mind Control -class spell_pri_mind_control : public SpellScript +class spell_pri_mind_control : public AuraScript { - PrepareSpellScript(spell_pri_mind_control); + PrepareAuraScript(spell_pri_mind_control); - void OnHit() + void HandleApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - if (Aura const* aura = GetHitAura()) + if (Unit* caster = GetCaster()) { - if (Unit* caster = GetCaster()) + if (Unit* target = GetTarget()) { - if (Unit* target = GetHitUnit()) - { - uint32 duration = static_cast(aura->GetMaxDuration()); - caster->SetInCombatWith(target, duration); - target->SetInCombatWith(caster, duration); - } + uint32 duration = static_cast(GetDuration()); + caster->SetInCombatWith(target, duration); + target->SetInCombatWith(caster, duration); + } + } + } + + void HandleRemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Unit* caster = GetCaster()) + { + if (Unit* target = GetTarget()) + { + caster->SetCombatTimer(0); + target->SetCombatTimer(0); } } } void Register() override { - AfterHit += SpellHitFn(spell_pri_mind_control::OnHit); + AfterEffectApply += AuraEffectApplyFn(spell_pri_mind_control::HandleApplyEffect, EFFECT_0, SPELL_AURA_MOD_POSSESS, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_pri_mind_control::HandleRemoveEffect, EFFECT_0, SPELL_AURA_MOD_POSSESS, AURA_EFFECT_HANDLE_REAL); } };