From 48b4d221f00f7bfaf9ff28eb743c019e843c1194 Mon Sep 17 00:00:00 2001 From: Jrc13245 Date: Sun, 25 Jan 2026 10:53:29 -0500 Subject: [PATCH] fix tracking all players buff casts and timers for comparison --- Conditionals.lua | 39 ++++++++++++++---------- Core.lua | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 16 deletions(-) diff --git a/Conditionals.lua b/Conditionals.lua index afba41b..8bdfc94 100644 --- a/Conditionals.lua +++ b/Conditionals.lua @@ -950,6 +950,15 @@ local function OnAuraCastOther(spellId, casterGuid, targetGuid, effect, effectAu duration = durationMs / 1000, -- Convert ms to seconds casterGuid = casterGuid, } + + -- Debug output when enabled + if CleveRoids.debug then + local spellName = SpellInfo(spellId) or "Unknown" + DEFAULT_CHAT_FRAME:AddMessage(string.format( + "|cff00ffff[AuraTrack]|r %s (ID:%d) on %s, dur=%.1fs", + spellName, spellId, string.sub(tostring(targetGuid), 1, 16), durationMs / 1000 + )) + end end -- Store cap status for this target GUID (if available) @@ -2924,22 +2933,9 @@ function CleveRoids.ValidateAura(unit, args, isbuff) -- For non-player units with time comparisons, try to get time from tracking systems local nonPlayerAuraTimeRemaining = nil if not isPlayer and args.name then - -- First try: libdebuff (player-cast auras with accurate timing) - local lib = type(CleveRoids.libdebuff) == "table" and CleveRoids.libdebuff or nil - if lib and lib.UnitBuff and isbuff then - -- Search through buff slots using libdebuff to find the matching buff with time remaining - for idx = 1, 32 do - local effect, _, _, effectStacks, _, duration, timeleft, effectCaster = lib:UnitBuff(unit, idx, nil) - if not effect then break end - -- Strip rank from effect name for comparison - local effectBase = effect and _string_gsub(effect, _RANK_PATTERN, "") - if effectBase and _string_lower(effectBase) == searchName then - nonPlayerAuraTimeRemaining = (timeleft and timeleft >= 0) and timeleft or 0 - stacks = effectStacks or stacks - break - end - end - end + -- NOTE: libdebuff's UnitBuff has a bug where timeleft returns incorrect values + -- (showing ~1000s instead of actual remaining time). Skip it for buff time checks + -- and rely on all-caster tracking from AURA_CAST events instead. -- Second try: All-caster tracking from AURA_CAST events (works for any caster) -- Only use if libdebuff didn't find it (libdebuff has more accurate timing for player casts) @@ -2947,6 +2943,17 @@ function CleveRoids.ValidateAura(unit, args, isbuff) local _, targetGuid = UnitExists(unit) if targetGuid then local remaining, casterGuid = CleveRoids.FindAllCasterAuraByName(targetGuid, args.name) + + -- Debug output when enabled + if CleveRoids.debug then + local hasData = CleveRoids.AllCasterAuraTracking[targetGuid] ~= nil + DEFAULT_CHAT_FRAME:AddMessage(string.format( + "|cffff9900[AuraLookup]|r %s on GUID %s: hasData=%s, remaining=%s", + tostring(args.name), string.sub(tostring(targetGuid), 1, 16), + tostring(hasData), tostring(remaining) + )) + end + if remaining then nonPlayerAuraTimeRemaining = remaining end diff --git a/Core.lua b/Core.lua index 6a96136..dc2e52a 100644 --- a/Core.lua +++ b/Core.lua @@ -5314,6 +5314,8 @@ SlashCmdList["CLEVEROID"] = function(msg) DEFAULT_CHAT_FRAME:AddMessage('/cleveroid debuffdebug [spell] - Debug debuff tracking on target') DEFAULT_CHAT_FRAME:AddMessage("|cffffaa00pfUI Tank Integration:|r") DEFAULT_CHAT_FRAME:AddMessage('/cleveroid tankdebug - Debug tank targeting conditionals') + DEFAULT_CHAT_FRAME:AddMessage("|cffffaa00All-Caster Aura Tracking:|r") + DEFAULT_CHAT_FRAME:AddMessage('/cleveroid auradebug - Debug buff/debuff time tracking from all casters') return end @@ -5973,6 +5975,82 @@ SlashCmdList["CLEVEROID"] = function(msg) return end + -- auradebug (debug all-caster aura tracking) + if cmd == "auradebug" or cmd == "bufftracking" then + CleveRoids.Print("=== All-Caster Aura Tracking Debug ===") + + -- Check CVar status + local auraCastEnabled = GetCVar("NP_EnableAuraCastEvents") + if auraCastEnabled == "1" then + CleveRoids.Print("|cff00ff00NP_EnableAuraCastEvents = 1 (ENABLED)|r") + else + CleveRoids.Print("|cffff0000NP_EnableAuraCastEvents = " .. tostring(auraCastEnabled) .. " (DISABLED)|r") + CleveRoids.Print(" Enable with: |cff00ffff/run SetCVar(\"NP_EnableAuraCastEvents\", \"1\")|r") + CleveRoids.Print(" Then /reload") + end + + -- Check Nampower version + local API = CleveRoids.NampowerAPI + if API and API.features then + CleveRoids.Print("Nampower hasAuraCastEvents: " .. tostring(API.features.hasAuraCastEvents)) + else + CleveRoids.Print("|cffff0000Nampower API not available|r") + end + + -- Show tracking data for current target/mouseover + CleveRoids.Print(" ") + CleveRoids.Print("|cffffaa00Tracked Auras:|r") + local trackingCount = 0 + local now = GetTime() + for targetGuid, spells in pairs(CleveRoids.AllCasterAuraTracking or {}) do + local unitName = nil + -- Try to find unit name for this GUID (use pcall to handle invalid units like "focus") + for _, testUnit in ipairs({"target", "mouseover", "party1", "party2", "party3", "party4"}) do + local ok, exists, testGuid = pcall(function() return UnitExists(testUnit) end) + if ok and exists then + _, testGuid = UnitExists(testUnit) + if testGuid == targetGuid then + unitName = UnitName(testUnit) + break + end + end + end + + for spellId, auraData in pairs(spells) do + if auraData.start and auraData.duration then + local remaining = auraData.duration + auraData.start - now + if remaining > 0 then + local spellName = SpellInfo(spellId) or ("ID:" .. spellId) + local display = unitName or (string.sub(targetGuid, 1, 16) .. "...") + CleveRoids.Print(string.format(" %s on %s: %.1fs left", spellName, display, remaining)) + trackingCount = trackingCount + 1 + end + end + end + end + if trackingCount == 0 then + CleveRoids.Print(" (no auras currently tracked)") + end + + -- Check specific target + if UnitExists("target") then + CleveRoids.Print(" ") + CleveRoids.Print("|cffffaa00Target Buff Check:|r") + local _, targetGuid = UnitExists("target") + CleveRoids.Print(" Target GUID: " .. tostring(targetGuid)) + local targetData = CleveRoids.AllCasterAuraTracking[targetGuid] + if targetData then + local count = 0 + for _ in pairs(targetData) do count = count + 1 end + CleveRoids.Print(" Tracked spells on target: " .. count) + else + CleveRoids.Print(" |cffff9900No tracking data for this target|r") + end + end + + return + end + -- Unknown command fallback CleveRoids.Print("Usage:") DEFAULT_CHAT_FRAME:AddMessage("/cleveroid - Show current settings")