Somewhat assemble the dispeller
This commit is contained in:
16
FreshShit/WarlockDispelMaster/event.lua
Normal file
16
FreshShit/WarlockDispelMaster/event.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
-- TICKER_200
|
||||
function()
|
||||
for _, unit in ipairs(Units) do
|
||||
if UnitExists(unit) and not UnitIsDeadOrGhost(unit) and HasDispellableDebuff(unit) then
|
||||
local unitName = UnitName(unit)
|
||||
local frame = GetFrameFromName(unitName)
|
||||
if frame == nil then
|
||||
print("Frame not found for " .. unitName)
|
||||
-- Unexpected behavior, bail!
|
||||
return
|
||||
end
|
||||
print("Dispel " .. unitName)
|
||||
MakeFrameGlow(frame)
|
||||
end
|
||||
end
|
||||
end
|
||||
4
FreshShit/WarlockDispelMaster/event2.lua
Normal file
4
FreshShit/WarlockDispelMaster/event2.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
-- TICKER_1000
|
||||
function()
|
||||
SetupPartyCache()
|
||||
end
|
||||
85
FreshShit/WarlockDispelMaster/init.lua
Normal file
85
FreshShit/WarlockDispelMaster/init.lua
Normal file
@@ -0,0 +1,85 @@
|
||||
LCG = LibStub("LibCustomGlow-1.0")
|
||||
---@table <string, boolean>
|
||||
BusyFrames = {}
|
||||
|
||||
Units = {
|
||||
"player",
|
||||
"party1",
|
||||
"party2",
|
||||
"party3",
|
||||
"party4",
|
||||
"party5",
|
||||
}
|
||||
|
||||
---@param unit string
|
||||
---@return boolean, nil|string
|
||||
function HasDispellableDebuff(unit)
|
||||
for i = 1, 20 do
|
||||
local debuff, _, _, _, type = UnitDebuff(unit, i)
|
||||
if debuff == nil then
|
||||
return false, nil
|
||||
end
|
||||
if type == "Magic" then
|
||||
return true, nil
|
||||
end
|
||||
end
|
||||
|
||||
return false, nil
|
||||
end
|
||||
|
||||
---@param frame Frame
|
||||
---@return string, nil|string
|
||||
function GetNameFromFrame(frame)
|
||||
if frame == nil then
|
||||
return "", "Frame is nil"
|
||||
end
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
if frame.Name == nil then
|
||||
return "", "Frame.Name is nil"
|
||||
end
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
return frame.Name:GetText(), nil
|
||||
end
|
||||
|
||||
---@param name string
|
||||
---@return Frame|nil
|
||||
function GetFrameFromName(name)
|
||||
return PartyCache[name]
|
||||
end
|
||||
|
||||
---@param name string
|
||||
---@return string
|
||||
---@return number
|
||||
function RemoveNamePadding(name)
|
||||
return string.gsub(name, "|c%w%w%w%w%w%w%w%w", "", 1)
|
||||
end
|
||||
|
||||
function MakeFrameGlow(frame)
|
||||
local frameName = frame:GetName()
|
||||
if frame ~= nil and BusyFrames[frameName] == nil then
|
||||
---@type Frame
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local healthBar = frame.Health
|
||||
if healthBar ~= nil then
|
||||
LCG.PixelGlow_Start(healthBar, {1, 1, 0, 1}, 16, 0.35, 8, 4)
|
||||
BusyFrames[frameName] = true
|
||||
C_Timer.After(1, function()
|
||||
LCG.PixelGlow_Stop(healthBar)
|
||||
BusyFrames[frameName] = nil
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
PartyCache = {}
|
||||
function SetupPartyCache()
|
||||
for i = 1, 5 do
|
||||
-- /dump _G[string.format("ElvUF_RaidGroup1UnitButton%d", 1)].Name:GetText()
|
||||
local raidFrame = _G[string.format("ElvUF_RaidGroup1UnitButton%d", i + 1)]
|
||||
local name, err = GetNameFromFrame(raidFrame)
|
||||
if err == nil then
|
||||
name = RemoveNamePadding(name)
|
||||
PartyCache[name] = raidFrame
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user