Hello,
I have made a custom tiny addon just for my personal use. (It helps me getting better with addon making)
My goal is to put a symbol on the 4 players who got the debuff "Controlled Burn" (used by the first boss of the new raid)
But despite what I tried, I can't get it working...
Here is my actual code so far:
Lua Code:
local raidTargetIcons = {1, 2, 3, 4}
local function UpdateRaidDebuffList()
for i = 1, GetNumGroupMembers() do
local unit = "raid" .. i
for j = 1, 40 do
local _, _, _, _, _, _, _, _, _, _, spellId, _, _, _, _, _, castSuccess = UnitDebuff(unit, j)
if not spellId then
break
end
if spellId == 421972 and castSuccess then
local icon = table.remove(raidTargetIcons)
if icon then
print(GetUnitName(unit, true) .. " has successfully cast Controlled Burn.")
ApplyRaidTargetIcon(unit, icon)
end
break
end
end
end
end
local function ApplyRaidTargetIcon(unit, icon)
SetRaidTarget(unit, icon)
end
local function ClearRaidTargetIcon(unit)
SetRaidTarget(unit, 0)
end
local function OnEvent(_, event, _, sourceGUID, _, _, _, _, _, destGUID, _, _, spellId)
if event == "COMBAT_LOG_EVENT_UNFILTERED" then
elseif event == "SPELL_AURA_REMOVED" and spellId == 421972 then
local destName = GetUnitName(destGUID, true)
if destName then
local icon = GetRaidTargetIndex(destName)
if icon then
table.insert(raidTargetIcons, icon)
ClearRaidTargetIcon(destName)
print(destName .. "'s Controlled Burn debuff has been removed.")
end
end
end
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:SetScript("OnEvent", OnEvent)