From 7165be56360fbc722b90d0fb1cfe86178d5c1e31 Mon Sep 17 00:00:00 2001 From: Meow <30401521+me0wg4ming@users.noreply.github.com> Date: Wed, 18 Feb 2026 13:37:40 +0100 Subject: [PATCH] fix for nameplates sometimes not showing casttimes of mobs fix for nameplates sometimes not showing casttimes of mobs --- libs/libcast.lua | 62 ++++++++++++++++++++++++++++++++++++++++-- modules/nameplates.lua | 14 ++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/libs/libcast.lua b/libs/libcast.lua index d8fc6c0d..51a1ba96 100644 --- a/libs/libcast.lua +++ b/libs/libcast.lua @@ -60,6 +60,13 @@ UnitChannelInfo = function(unit) -- convert to name if unitstring was given local unitName = pfValidUnits[unit] and UnitName(unit) or unit + -- Get GUID if Nampower is available AND unit is a valid unit token + local guid = nil + if pfValidUnits[unit] and UnitExists then + local _, unitGuid = UnitExists(unit) + guid = unitGuid + end + -- For player: ALWAYS use libcast.db because it handles channel updates correctly local isPlayer = unit == "player" or unitName == player @@ -93,9 +100,31 @@ UnitChannelInfo = function(unit) return SuperWoW_UnitChannelInfo(unit) end + -- Try GUID-based lookup first (from libdebuff's SPELL_START tracking) + local db = nil + if guid and pfUI.libdebuff_casts and pfUI.libdebuff_casts[guid] then + -- Use libdebuff's cast tracking (from SPELL_START_OTHER events) + local castData = pfUI.libdebuff_casts[guid] + if castData.event == "START" and castData.endTime and castData.endTime > GetTime() then + -- Convert libdebuff format to libcast format + db = { + cast = castData.spellName, + rank = nil, + start = castData.startTime, + casttime = castData.duration * 1000, -- Convert back to ms + icon = castData.icon, + channel = nil -- TODO: libdebuff should distinguish channel vs cast + } + end + end + + -- Fallback to name-based lookup (CHAT_MSG castbars) + if not db and libcast.db[unitName] then + db = libcast.db[unitName] + end + -- Fallback to libcast.db for non-player units local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill - local db = libcast.db[unitName] if db and db.cast and db.start + db.casttime / 1000 > GetTime() then if not db.channel then return end @@ -125,6 +154,13 @@ UnitCastingInfo = function(unit) -- convert to name if unitstring was given local unitName = pfValidUnits[unit] and UnitName(unit) or unit + -- Get GUID if Nampower is available AND unit is a valid unit token + local guid = nil + if pfValidUnits[unit] and UnitExists then + local _, unitGuid = UnitExists(unit) + guid = unitGuid + end + -- For player: ALWAYS use libcast.db because it handles pushback correctly -- SuperWoW's UnitCastingInfo doesn't track SPELLCAST_DELAYED events local isPlayer = unit == "player" or unitName == player @@ -159,9 +195,31 @@ UnitCastingInfo = function(unit) return SuperWoW_UnitCastingInfo(unit) end + -- Try GUID-based lookup first (from libdebuff's SPELL_START tracking) + local db = nil + if guid and pfUI.libdebuff_casts and pfUI.libdebuff_casts[guid] then + -- Use libdebuff's cast tracking (from SPELL_START_OTHER events) + local castData = pfUI.libdebuff_casts[guid] + if castData.event == "START" and castData.endTime and castData.endTime > GetTime() then + -- Convert libdebuff format to libcast format + db = { + cast = castData.spellName, + rank = nil, + start = castData.startTime, + casttime = castData.duration * 1000, -- Convert back to ms + icon = castData.icon, + channel = nil -- TODO: libdebuff should distinguish channel vs cast + } + end + end + + -- Fallback to name-based lookup (CHAT_MSG castbars) + if not db and libcast.db[unitName] then + db = libcast.db[unitName] + end + -- Fallback to libcast.db for non-player units local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill - local db = libcast.db[unitName] if db and db.cast and db.start + db.casttime / 1000 > GetTime() then if db.channel then return end diff --git a/modules/nameplates.lua b/modules/nameplates.lua index 204d3629..278638de 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -1547,11 +1547,25 @@ nameplates:RegisterEvent("ZONE_CHANGED_NEW_AREA") -- Fallback to API calls if no event data (for non-SuperWoW or target) local channel, cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill + -- Try to get cast info for target plates if isTargetPlate and UnitExists("target") then cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo("target") if not cast then channel, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo("target") end + -- NAMPOWER: For non-target plates, use GUID or mobName + elseif unitstr then + -- unitstr is GUID from Nampower + cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(unitstr) + if not cast then + channel, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo(unitstr) + end + elseif name then + -- Fallback to mob name (for CHAT_MSG castbars) + cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(name) + if not cast then + channel, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo(name) + end end if not cast and not channel then