From cc5ad5d3d44fe243a5f2155249068f99bfa61e4a Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 10 May 2024 09:25:40 +0200 Subject: [PATCH] castbar: rework channel and superwow logic --- modules/castbar.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/castbar.lua b/modules/castbar.lua index 033e39a4..4a88fc32 100644 --- a/modules/castbar.lua +++ b/modules/castbar.lua @@ -81,26 +81,28 @@ pfUI:RegisterModule("castbar", "vanilla:tbc", function () this:SetAlpha(this:GetAlpha()-0.05) end + local channel = nil local name = this.unitstr and UnitName(this.unitstr) or this.unitname + local query = this.unitstr or this.unitname if not name then return end - local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(this.unitstr or this.unitname) - if not cast then - -- scan for channel spells if no cast was found - cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo(this.unitstr or this.unitname) - end - - -- read enemy casts from SuperWoW if enabled + -- try to read cast and guid from SuperWoW (except for self casts) if superwow_active and this.unitstr and not UnitIsUnit(this.unitstr, 'player') then local _, guid = UnitExists(this.unitstr) - cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(guid) + query = guid or query + end + + local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(query) + if not cast then + -- scan for channel spells if no cast was found + channel, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo(query) + cast = channel end if cast then local duration = endTime - startTime local max = duration / 1000 local cur = GetTime() - startTime / 1000 - local channel = UnitChannelInfo(name) this:SetAlpha(1)