diff --git a/Console.lua b/Console.lua index bccb3b1..1665260 100644 --- a/Console.lua +++ b/Console.lua @@ -111,18 +111,17 @@ local StartAttack = function(msg) end local StopAttack = function(msg) - local isAttacking = CleveRoids.CurrentSpell.autoAttack - if not isAttacking then - -- Fallback: check action bar state via IsCurrentAction - -- (PLAYER_ENTER_COMBAT event may not have fired yet in same frame) - local slot = CleveRoids.GetProxyActionSlot(CleveRoids.Localized.Attack) - if slot and IsCurrentAction(slot) then - isAttacking = true - end - end - if isAttacking and UnitExists("target") then + -- Clear target and retarget to reliably stop autoattack. + -- AttackTarget() toggle is too slow — CastSpellByName starts autoattack as a side effect + -- but PLAYER_ENTER_COMBAT hasn't fired yet in the same frame, so the toggle misses it. + -- ClearTarget() immediately drops the target (stopping any pending swing), + -- and TargetLastTarget() restores it without restarting autoattack. + CleveRoids.CurrentSpell.autoAttack = false + CleveRoids.CurrentSpell.autoAttackLock = false + if UnitExists("target") then AttackTarget() - CleveRoids.CurrentSpell.autoAttack = false + ClearTarget() + TargetLastTarget() end end diff --git a/Core.lua b/Core.lua index 2ad31a8..e59b206 100644 --- a/Core.lua +++ b/Core.lua @@ -2946,16 +2946,12 @@ end -- PERFORMANCE: Module-level actions to avoid closure allocation per call local function _stopAttackAction() - local isAttacking = CleveRoids.CurrentSpell.autoAttack - if not isAttacking then - local slot = CleveRoids.GetProxyActionSlot(CleveRoids.Localized.Attack) - if slot and CleveRoids.Hooks.IsCurrentAction(slot) then - isAttacking = true - end - end - if isAttacking and UnitExists("target") then + CleveRoids.CurrentSpell.autoAttack = false + CleveRoids.CurrentSpell.autoAttackLock = false + if UnitExists("target") then AttackTarget() - CleveRoids.CurrentSpell.autoAttack = false + ClearTarget() + TargetLastTarget() end end