From b5f7399d30bd6011ff6040f16d8d1b17038c4a87 Mon Sep 17 00:00:00 2001 From: Jrc13245 Date: Thu, 11 Dec 2025 16:57:31 -0500 Subject: [PATCH] fix nampower queuing issues and debuff duration issues --- Core.lua | 7 ++++++ NampowerAPI.lua | 14 +++++++++++ Utility.lua | 62 ++++++++++++++++++++++++++++++------------------- 3 files changed, 59 insertions(+), 24 deletions(-) diff --git a/Core.lua b/Core.lua index 134dae5..ff95666 100644 --- a/Core.lua +++ b/Core.lua @@ -2095,6 +2095,13 @@ function CleveRoids.DoCast(msg) end if CleveRoids.DoWithConditionals(v, CleveRoids.Hooks.CAST_SlashCmd, CleveRoids.FixEmptyTarget, not CleveRoids.hasSuperwow, CastSpellByName) then + -- Set stopmacro so subsequent lines in multi-line macros don't execute + -- This prevents spell queue replacement issues where Line 2 queues a spell + -- and Line 3 immediately replaces it before it can fire + -- Only enable this behavior if Nampower queuing is active for at least one spell type + if CleveRoids.NampowerAPI and CleveRoids.NampowerAPI.IsAnyQueueingEnabled() then + CleveRoids.stopmacro = true + end return true end end diff --git a/NampowerAPI.lua b/NampowerAPI.lua index 8f68306..bde8259 100644 --- a/NampowerAPI.lua +++ b/NampowerAPI.lua @@ -190,6 +190,20 @@ function API.IsQueueingEnabled(spellType) return API.GetSettingBool("NP_QueueCastTimeSpells") end +-- Check if ANY spell queuing is enabled +-- Used to determine if stopmacro behavior is needed for multi-line macros +function API.IsAnyQueueingEnabled() + if not API.features.hasNampower then + return false + end + + -- Check all spell type queuing settings + return API.GetSettingBool("NP_QueueCastTimeSpells") + or API.GetSettingBool("NP_QueueInstantSpells") + or API.GetSettingBool("NP_QueueChannelingSpells") + or API.GetSettingBool("NP_QueueOnSwingSpells") +end + -- Get the queue window for a given spell type (in seconds) function API.GetQueueWindow(spellType) local ms = 500 -- default diff --git a/Utility.lua b/Utility.lua index 237943b..3c9b0e4 100644 --- a/Utility.lua +++ b/Utility.lua @@ -1559,15 +1559,25 @@ local function SeedUnit(unit) else local duration = lib:GetDuration(spellID) if duration > 0 then - -- SHARED DEBUFFS: Always update to refresh stacks and duration - -- Check if already exists - if so, preserve caster info - local existingCaster = nil - if lib.objects[guid] and lib.objects[guid][spellID] then - existingCaster = lib.objects[guid][spellID].caster - end + -- SHARED DEBUFFS: Only seed if not already tracked + -- If already tracked via UNIT_CASTEVENT, just update stacks (preserve timer) + local existing = lib.objects[guid] and lib.objects[guid][spellID] - if not (lib.objects[guid] and lib.objects[guid][spellID]) then - -- First time seeing this debuff - check for combo spell duration + if existing and existing.start and existing.duration then + -- Already tracked - only update stacks if different (don't reset timer!) + if existing.stacks ~= stacks then + existing.stacks = stacks + if CleveRoids.debug then + local spellName = SpellInfo(spellID) or "Unknown" + DEFAULT_CHAT_FRAME:AddMessage( + string.format("|cffaaff00[DEBUG SeedUnit Debuff]|r %s (ID:%d) updated stacks to %d (timer preserved)", + spellName, spellID, stacks or 0) + ) + end + end + else + -- First time seeing this debuff - add with full duration + -- Check for combo spell duration if CleveRoids.IsComboScalingSpellID and CleveRoids.IsComboScalingSpellID(spellID) and CleveRoids_ComboDurations and CleveRoids_ComboDurations[spellID] then -- Use the longest learned duration (assume 5 CP) @@ -1585,11 +1595,8 @@ local function SeedUnit(unit) end end end - duration = duration or lib:GetDuration(spellID) + lib:AddEffect(guid, unitName, spellID, duration, stacks, nil) end - - -- Always update shared debuffs to keep stacks current - lib:AddEffect(guid, unitName, spellID, duration, stacks, existingCaster) end end end @@ -1607,15 +1614,25 @@ local function SeedUnit(unit) else local duration = lib:GetDuration(spellID) if duration > 0 then - -- SHARED DEBUFFS: Always update to refresh stacks and duration - -- Check if already exists - if so, preserve caster info - local existingCaster = nil - if lib.objects[guid] and lib.objects[guid][spellID] then - existingCaster = lib.objects[guid][spellID].caster - end + -- SHARED DEBUFFS: Only seed if not already tracked + -- If already tracked via UNIT_CASTEVENT, just update stacks (preserve timer) + local existing = lib.objects[guid] and lib.objects[guid][spellID] - if not (lib.objects[guid] and lib.objects[guid][spellID]) then - -- First time seeing this debuff - check for combo spell duration + if existing and existing.start and existing.duration then + -- Already tracked - only update stacks if different (don't reset timer!) + if existing.stacks ~= stacks then + existing.stacks = stacks + if CleveRoids.debug then + local spellName = SpellInfo(spellID) or "Unknown" + DEFAULT_CHAT_FRAME:AddMessage( + string.format("|cffaaff00[DEBUG SeedUnit Buff]|r %s (ID:%d) updated stacks to %d (timer preserved)", + spellName, spellID, stacks or 0) + ) + end + end + else + -- First time seeing this debuff - add with full duration + -- Check for combo spell duration if CleveRoids.IsComboScalingSpellID and CleveRoids.IsComboScalingSpellID(spellID) and CleveRoids_ComboDurations and CleveRoids_ComboDurations[spellID] then -- Use the longest learned duration (assume 5 CP) @@ -1633,11 +1650,8 @@ local function SeedUnit(unit) end end end - duration = duration or lib:GetDuration(spellID) + lib:AddEffect(guid, unitName, spellID, duration, stacks, nil) end - - -- Always update shared debuffs to keep stacks current - lib:AddEffect(guid, unitName, spellID, duration, stacks, existingCaster) end end end