From 7abb78c54e75dfcc92c5c78e99cd6dffe6fda0bc Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 16 Nov 2025 18:49:12 +0000 Subject: [PATCH 1/2] Fix combo point tracking - use name-based tracking as fallback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent macro conditional evaluations from overwriting good CP data: Problem: Macros like "[combo:>0 nodebuff]Rip /cast [combo:>0]Rip" evaluate multiple times, calling TrackComboPointCast repeatedly: 1. Check [combo:>0 nodebuff] → TrackComboPointCast(0 CP) 2. Claw lands → player gains 1 CP 3. Check [combo:>0] → TrackComboPointCast(1 CP) 4. Spell casts → pfUI AddEffect fires → uses tracking data If the 0 CP call happens after the 1 CP call, pfUI gets wrong data. Solution: Only update tracking if: - No existing data exists, OR - Existing data is stale (>0.5s), OR - New CP value >= existing CP value This ensures we keep the highest (best) combo point count during rapid macro evaluations, so pfUI always gets the correct duration. Debug: Shows "Ignoring X with Y CP (have Z CP)" when preventing overwrites of better data. --- ComboPointTracker.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/ComboPointTracker.lua b/ComboPointTracker.lua index 445850c..754ad97 100644 --- a/ComboPointTracker.lua +++ b/ComboPointTracker.lua @@ -182,12 +182,30 @@ function CleveRoids.TrackComboPointCast(spellName) local comboPoints = CleveRoids.GetComboPoints() local duration = CleveRoids.CalculateComboScaledDuration(spellName, comboPoints) + local currentTime = GetTime() + + -- Only update if this is a better (higher CP) value than existing, or if existing is stale + local existing = CleveRoids.ComboPointTracking[spellName] + if existing then + local age = currentTime - existing.cast_time + -- Keep existing if it's fresh (<0.5s) and has more combo points + if age < 0.5 and existing.combo_points > comboPoints then + -- Don't overwrite better data with worse data + if CleveRoids.debug then + DEFAULT_CHAT_FRAME:AddMessage( + string.format("|cff888888CleveRoids:|r ComboTrack: Ignoring %s with %d CP (have %d CP)", + spellName, comboPoints, existing.combo_points) + ) + end + return + end + end -- Store the tracking data CleveRoids.ComboPointTracking[spellName] = { combo_points = comboPoints, duration = duration, - cast_time = GetTime(), + cast_time = currentTime, target = UnitName("target") or "Unknown" } @@ -198,7 +216,7 @@ function CleveRoids.TrackComboPointCast(spellName) CleveRoids.spell_tracking[spellName].last_combo_points = comboPoints CleveRoids.spell_tracking[spellName].last_duration = duration - CleveRoids.spell_tracking[spellName].last_cast_time = GetTime() + CleveRoids.spell_tracking[spellName].last_cast_time = currentTime -- Debug output if CleveRoids.debug then From aedb2684b5f7f8e7fbcc840f9f14290fb06130d2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 16 Nov 2025 18:51:57 +0000 Subject: [PATCH 2/2] Add confirmation system to prevent pfUI from using evaluation-only tracking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Macro conditional evaluations create tracking entries, but pfUI's AddEffect can fire during these evaluations (before actual cast), causing it to use incorrect combo point data. Flow before fix: 1. Macro evaluates [combo:>0] → TrackComboPointCast(0 CP, confirmed=false) 2. Macro evaluates again → TrackComboPointCast(1 CP, confirmed=false) 3. pfUI AddEffect fires → uses tracking (wrong timing!) ✗ 4. SPELLCAST_START fires (actual cast) Flow after fix: 1. Macro evaluates [combo:>0] → TrackComboPointCast(0 CP, confirmed=false) 2. Macro evaluates again → TrackComboPointCast(1 CP, confirmed=false) 3. SPELLCAST_START fires → sets confirmed=true ✓ 4. pfUI AddEffect fires → only uses tracking if confirmed=true ✓ Changes: - Added 'confirmed' field to tracking (default: false) - SPELLCAST_START sets confirmed=true when spell actually casts - pfUI AddEffect hook only uses tracking if confirmed=true - Clear confirmed flag after use to prevent reuse - Clear on failed/interrupted casts Debug shows: "Ignoring X tracking (not confirmed - evaluation only)" when preventing use of evaluation-only data. --- ComboPointTracker.lua | 11 +++++++++-- Compatibility/pfUI.lua | 12 ++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ComboPointTracker.lua b/ComboPointTracker.lua index 754ad97..c96afc5 100644 --- a/ComboPointTracker.lua +++ b/ComboPointTracker.lua @@ -206,7 +206,8 @@ function CleveRoids.TrackComboPointCast(spellName) combo_points = comboPoints, duration = duration, cast_time = currentTime, - target = UnitName("target") or "Unknown" + target = UnitName("target") or "Unknown", + confirmed = false -- Will be set to true by SPELLCAST_START } -- Also store in spell_tracking for integration with existing system @@ -414,6 +415,11 @@ function Extension.OnSpellcastStart() local spellName = arg1 if spellName and CleveRoids.IsComboScalingSpell(spellName) then CleveRoids.TrackComboPointCast(spellName) + + -- Mark this tracking as confirmed (actual cast, not just evaluation) + if CleveRoids.ComboPointTracking[spellName] then + CleveRoids.ComboPointTracking[spellName].confirmed = true + end end end @@ -436,7 +442,8 @@ function Extension.OnSpellcastFailed() if spellName and CleveRoids.ComboPointTracking[spellName] then local tracking = CleveRoids.ComboPointTracking[spellName] if tracking and (GetTime() - tracking.cast_time) < 1 then - -- Recent cast failed, clear it + -- Recent cast failed, clear confirmed flag and the tracking + tracking.confirmed = false CleveRoids.ComboPointTracking[spellName] = nil end end diff --git a/Compatibility/pfUI.lua b/Compatibility/pfUI.lua index 0b1fbb2..ef26928 100644 --- a/Compatibility/pfUI.lua +++ b/Compatibility/pfUI.lua @@ -155,14 +155,22 @@ function Extension.HookPfUILibdebuff() -- Use name-based tracking which is populated BEFORE pfUI's AddEffect if CleveRoids.ComboPointTracking and CleveRoids.ComboPointTracking[effect] then local tracking = CleveRoids.ComboPointTracking[effect] - if tracking.duration and (GetTime() - tracking.cast_time) < 0.5 then + -- Only use tracking if it's confirmed (actual cast, not just evaluation) + if tracking.duration and tracking.confirmed and (GetTime() - tracking.cast_time) < 0.5 then duration = tracking.duration + -- Clear confirmed flag after use to prevent reuse + tracking.confirmed = false if CleveRoids.debug then DEFAULT_CHAT_FRAME:AddMessage( - string.format("|cff00ff00[pfUI AddEffect Hook]|r Overriding %s duration to %ds (from name tracking)", + string.format("|cff00ff00[pfUI AddEffect Hook]|r Overriding %s duration to %ds (from confirmed tracking)", effect, duration) ) end + elseif CleveRoids.debug and tracking.duration and not tracking.confirmed then + DEFAULT_CHAT_FRAME:AddMessage( + string.format("|cffaaaa00[pfUI AddEffect Hook]|r Ignoring %s tracking (not confirmed - evaluation only)", + effect) + ) end end end