diff --git a/Conditionals.lua b/Conditionals.lua index 5ad84f2..bf8ec57 100644 --- a/Conditionals.lua +++ b/Conditionals.lua @@ -2569,11 +2569,16 @@ end --- Falls back to basic position checking if MonkeySpeed isn't available --- @return boolean True if player is moving function CleveRoids.IsPlayerMoving() - -- If MonkeySpeed is available, use it for accurate detection + -- If MonkeySpeed is available, use it for accurate speed-based detection if CleveRoids.HasMonkeySpeed() then return (MonkeySpeed.m_fSpeed or 0) > 0 end + -- Nampower 2.36+ provides direct movement flag query (catches jumping, falling, pitching) + if CleveRoids.NampowerAPI.features.hasPlayerIsMoving then + return PlayerIsMoving() == 1 + end + -- Fallback: use continuously tracked position history from OnUpdate -- Core.lua tracks position at ~100 Hz with 4-sample circular buffer (matches MonkeySpeed's 0.01s). -- Movement is detected if ANY consecutive pair of samples shows movement. @@ -4541,6 +4546,7 @@ CleveRoids.CCTypesLossOfControl = { [1] = true, -- charm [2] = true, -- disoriented [5] = true, -- fear + [7] = true, -- root (Entangling Roots, Frost Nova, etc.) [10] = true, -- sleep [12] = true, -- stun (Cheap Shot, Kidney Shot, etc.) [13] = true, -- freeze @@ -6413,16 +6419,29 @@ CleveRoids.Keywords = { end, conditionals, "nopet") end, - -- TODO: swimming/noswimming disabled - IsSpellUsable doesn't check environmental - -- requirements (swimming state is server-side only). Revisit when DLL mods expose - -- movement flags or IsSwimming() API. - -- swimming = function(conditionals) - -- return CleveRoids.IsReactiveUsable("Aquatic Form") - -- end, - -- - -- noswimming = function(conditionals) - -- return not CleveRoids.IsReactiveUsable("Aquatic Form") - -- end, + -- [swimming] - Player is currently swimming (Nampower v2.36+) + swimming = function(conditionals) + if not CleveRoids.NampowerAPI.features.hasPlayerIsSwimming then + if not CleveRoids._swimmingErrorShown then + DEFAULT_CHAT_FRAME:AddMessage("|cffff0000[SuperCleveRoidMacros]|r The [swimming] conditional requires Nampower v2.36.0 or newer.", 1, 0.5, 0.5) + CleveRoids._swimmingErrorShown = true + end + return false + end + return PlayerIsSwimming() == 1 + end, + + -- [noswimming] - Player is NOT swimming (Nampower v2.36+) + noswimming = function(conditionals) + if not CleveRoids.NampowerAPI.features.hasPlayerIsSwimming then + if not CleveRoids._swimmingErrorShown then + DEFAULT_CHAT_FRAME:AddMessage("|cffff0000[SuperCleveRoidMacros]|r The [swimming] conditional requires Nampower v2.36.0 or newer.", 1, 0.5, 0.5) + CleveRoids._swimmingErrorShown = true + end + return false + end + return PlayerIsSwimming() ~= 1 + end, distance = function(conditionals) if not CleveRoids.hasUnitXP then return false end @@ -7706,7 +7725,7 @@ CleveRoids.STATIC_CONDITIONALS = { form = true, noform = true, stance = true, nostance = true, equipped = true, noequipped = true, mod = true, nomod = true, - -- swimming = true, noswimming = true, -- disabled: no client-side swimming detection + swimming = true, noswimming = true, resting = true, noresting = true, } diff --git a/NampowerAPI.lua b/NampowerAPI.lua index 90d24d4..d993693 100644 --- a/NampowerAPI.lua +++ b/NampowerAPI.lua @@ -97,7 +97,12 @@ (e.g., "0x0600000012345678") instead of raw numbers to avoid Lua 64-bit precision loss - LearnTalentRank(talentPage, talentIndex, rank) - Learn a specific talent rank directly - Current version: v2.35.0 + Player State Functions (v2.36+): + - PlayerIsMoving() - Returns 1 if player is moving, nil if stationary + - PlayerIsRooted() - Returns 1 if player is rooted, nil if not + - PlayerIsSwimming() - Returns 1 if player is swimming, nil if not + + Current version: v2.36.0 ]] local _G = _G or getfenv(0) @@ -262,6 +267,11 @@ API.VERSION_REQUIREMENTS = { -- v2.35+ - GUID string fix and talent helper ["GuidStringFormat"] = { 2, 35, 0 }, -- GetUnitData/GetUnitField return GUID fields as hex strings ["LearnTalentRank"] = { 2, 35, 0, "LearnTalentRank" }, + + -- v2.36+ - Player state functions + ["PlayerIsMoving"] = { 2, 36, 0, "PlayerIsMoving" }, + ["PlayerIsRooted"] = { 2, 36, 0, "PlayerIsRooted" }, + ["PlayerIsSwimming"] = { 2, 36, 0, "PlayerIsSwimming" }, } -- Check if a specific feature is available @@ -410,6 +420,11 @@ local function InitializeFeatures() f.hasGuidStringFormat = API.HasFeature("GuidStringFormat") f.hasLearnTalentRank = API.HasFeature("LearnTalentRank") + -- v2.36+ Player state functions + f.hasPlayerIsMoving = API.HasFeature("PlayerIsMoving") + f.hasPlayerIsRooted = API.HasFeature("PlayerIsRooted") + f.hasPlayerIsSwimming = API.HasFeature("PlayerIsSwimming") + -- Runtime detection for enhanced spell functions (verify by testing) if f.hasEnhancedSpellFunctions and GetSpellTexture then local success, result = pcall(function()