From d3d0fff2064d2c958ef61d14de69f13e42fed26a Mon Sep 17 00:00:00 2001 From: Jrc13245 Date: Mon, 26 Jan 2026 13:01:36 -0500 Subject: [PATCH] fix moving and nomoving for non monkeyspeed users --- Conditionals.lua | 30 +++++++++++++----------------- Core.lua | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/Conditionals.lua b/Conditionals.lua index 8bdfc94..a58faa5 100644 --- a/Conditionals.lua +++ b/Conditionals.lua @@ -2171,25 +2171,21 @@ function CleveRoids.IsPlayerMoving() return (MonkeySpeed.m_fSpeed or 0) > 0 end - -- Fallback: use SuperWoW's UnitPosition for basic moving detection - -- We store last position and compare - if UnitPosition then - local x, y = UnitPosition("player") - if x and y then - if CleveRoids._lastPlayerPos then - local dx = x - CleveRoids._lastPlayerPos.x - local dy = y - CleveRoids._lastPlayerPos.y - local dist = math.sqrt(dx * dx + dy * dy) - CleveRoids._lastPlayerPos = { x = x, y = y, time = GetTime() } - -- Moving if distance > small threshold (account for floating point) - return dist > 0.001 - else - CleveRoids._lastPlayerPos = { x = x, y = y, time = GetTime() } - return false -- Can't determine on first call - end - end + -- Fallback: use continuously tracked position data from OnUpdate + -- Core.lua tracks position at ~10 Hz, storing _currentPlayerPos and _previousPlayerPos + -- This is more accurate than the old method which only updated on macro execution + local current = CleveRoids._currentPlayerPos + local previous = CleveRoids._previousPlayerPos + + if current and previous then + local dx = current.x - previous.x + local dy = current.y - previous.y + local dist = math.sqrt(dx * dx + dy * dy) + -- Moving if distance > small threshold (account for floating point) + return dist > 0.001 end + -- Not enough data yet (first 0.2s after login) - assume not moving return false end diff --git a/Core.lua b/Core.lua index dc2e52a..965528a 100644 --- a/Core.lua +++ b/Core.lua @@ -3573,6 +3573,28 @@ function CleveRoids.OnUpdate(self) return end + -- ========================================================================= + -- CONTINUOUS POSITION TRACKING (for [moving] fallback without MonkeySpeed) + -- ========================================================================= + -- Track player position at ~10 Hz for accurate movement detection. + -- This runs every frame but only updates storage at the tracking interval. + -- Without this, [moving] only updates when macros execute (stale data). + local posTrackInterval = 0.1 -- 100ms between position samples + local lastPosTime = CleveRoids._positionTrackTime or 0 + + if (time - lastPosTime) >= posTrackInterval then + CleveRoids._positionTrackTime = time + + if UnitPosition then + local x, y = UnitPosition("player") + if x and y then + -- Shift current to previous, store new current + CleveRoids._previousPlayerPos = CleveRoids._currentPlayerPos + CleveRoids._currentPlayerPos = { x = x, y = y, time = time } + end + end + end + -- PERFORMANCE: Delayed WDB warmup after login (ensures GetItemInfo works after WDB clear) if CleveRoids.wdbWarmupTime and time >= CleveRoids.wdbWarmupTime then CleveRoids.wdbWarmupTime = nil