From bb6b8a0d5bee50ac19222ee9a66ab892c4b6511b Mon Sep 17 00:00:00 2001 From: Jrc13245 Date: Fri, 6 Mar 2026 20:04:58 -0500 Subject: [PATCH] make stopattack faster --- Console.lua | 21 ++++++++++----------- Core.lua | 14 +++++--------- 2 files changed, 15 insertions(+), 20 deletions(-) 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