mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-03 20:20:01 +00:00
fix for nameplates sometimes not showing casttimes of mobs
fix for nameplates sometimes not showing casttimes of mobs
This commit is contained in:
+60
-2
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user