Thread Tools Display Modes
11-20-23, 12:21 PM   #1
fatrog
A Fallenroot Satyr
Join Date: Nov 2022
Posts: 21
Troubles checking debuff on raid members

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:
  1. local raidTargetIcons = {1, 2, 3, 4}
  2.  
  3. local function UpdateRaidDebuffList()
  4.     for i = 1, GetNumGroupMembers() do
  5.         local unit = "raid" .. i
  6.         for j = 1, 40 do
  7.             local _, _, _, _, _, _, _, _, _, _, spellId, _, _, _, _, _, castSuccess = UnitDebuff(unit, j)
  8.             if not spellId then
  9.                 break
  10.             end
  11.  
  12.             if spellId == 421972 and castSuccess then
  13.                 local icon = table.remove(raidTargetIcons)
  14.                 if icon then
  15.                     print(GetUnitName(unit, true) .. " has successfully cast Controlled Burn.")
  16.                     ApplyRaidTargetIcon(unit, icon)
  17.                 end
  18.                 break
  19.             end
  20.         end
  21.     end
  22. end
  23.  
  24. local function ApplyRaidTargetIcon(unit, icon)
  25.     SetRaidTarget(unit, icon)
  26. end
  27.  
  28. local function ClearRaidTargetIcon(unit)
  29.     SetRaidTarget(unit, 0)
  30. end
  31.  
  32. local function OnEvent(_, event, _, sourceGUID, _, _, _, _, _, destGUID, _, _, spellId)
  33.     if event == "COMBAT_LOG_EVENT_UNFILTERED" then
  34.     elseif event == "SPELL_AURA_REMOVED" and spellId == 421972 then
  35.         local destName = GetUnitName(destGUID, true)
  36.         if destName then
  37.             local icon = GetRaidTargetIndex(destName)
  38.             if icon then
  39.                 table.insert(raidTargetIcons, icon)
  40.                 ClearRaidTargetIcon(destName)
  41.                 print(destName .. "'s Controlled Burn debuff has been removed.")
  42.             end
  43.         end
  44.     end
  45. end
  46.  
  47. local frame = CreateFrame("Frame")
  48. frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  49. frame:SetScript("OnEvent", OnEvent)
  Reply With Quote
11-20-23, 10:38 PM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
You assume people are in a raid, yet you aren't checking for that. Before line 4, you need a check for IsInRaid(). If that returns true, then you can iterate your group members.
  Reply With Quote
11-21-23, 06:03 AM   #3
wardz
A Deviate Faerie Dragon
 
wardz's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 17
You need to call CombatLogGetCurrentEventInfo() inside CLEU event to get the combat log payload nowadays. (You can also get the destName from here instead of using unit GUID, which doesnt work for unit ID functions, but destName/srcName does aslong as they're in your raid.)
Idk if its a typo with the elseif event, but "SPELL_AURA_REMOVED" is the sub event from CombatLogGetCurrentEventInfo(), not main event just incase.

Also unless im too tired, spellID is the 10th argument not 11th for UnitDebuff.

Where do you call UpdateRaidDebuffList?

See https://warcraft.wiki.gg/ for latest up to date API documentation. Other sites are outdated.

Last edited by wardz : 11-21-23 at 06:25 AM.
  Reply With Quote
11-21-23, 09:49 AM   #4
fatrog
A Fallenroot Satyr
Join Date: Nov 2022
Posts: 21
Oh, maybe it's not the right spot for spellId, where can I get the info? because on the combatlog events page on wiki I can't find it or it shown as first.. idk why

Yes, It was a bad pasta, my bad:

Lua Code:
  1. local function OnEvent(_, event, _, sourceGUID, _, _, _, _, _, destGUID, _, _, spellId)
  2.     if event == "COMBAT_LOG_EVENT_UNFILTERED" then
  3.         if event == "SPELL_AURA_APPLIED" and spellId == 421972 then
  4.             UpdateRaidDebuffList()
  5.         elseif event == "SPELL_AURA_REMOVED" and spellId == 421972 then
  6.             local destName = GetUnitName(destGUID, true)
  7.             if destName then
  8.                 local icon = GetRaidTargetIndex(destName)
  9.                 if icon then
  10.                     table.insert(raidTargetIcons, icon)
  11.                     ClearRaidTargetIcon(destName)
  12.                     print(destName .. "'s Controlled Burn debuff has been removed.")
  13.                 end
  14.             end
  15.         end
  16.     end
  17. end
  Reply With Quote
11-21-23, 12:38 PM   #5
wardz
A Deviate Faerie Dragon
 
wardz's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 17
Combat log event handling looks like this now:
lua Code:
  1. local function OnEvent(self, event)
  2.     if event == "COMBAT_LOG_EVENT_UNFILTERED" then
  3.         local _, subEvent, _, srcGUID, srcName, _, _, dstGUID, destName, _, _, spellId = CombatLogGetCurrentEventInfo()
  4.  
  5.  
  6.         if subEvent == "SPELL_AURA_APPLIED" and spellId == 421972 then
  7.             UpdateRaidDebuffList()
  8.         elseif subEvent == "SPELL_AURA_REMOVED" and spellId == 421972 then
  9.             local icon = GetRaidTargetIndex(destName)
  10.             if icon then
  11.                 table.insert(raidTargetIcons, icon)
  12.                 ClearRaidTargetIcon(destName)
  13.                 print(destName .. "'s Controlled Burn debuff has been removed.")
  14.             end
  15.         end
  16.     end
  17. end

The spellId I were refering to earlier is the one inside your UpdateRaidDebuffList function, but not in the combat log event, that one is correct.
Is 'castSuccess' a special variable return thats required for Controlled Burn? If you don't need it, the script can be simplified a lot. (Arguments for table.remove also seems incorrect, its missing the index you want to remove) Let me know and I can post a full example later.


For future cases, you might also want to look into the UNIT_AURA event. This is generally the event you want for these kind of things unless you need to track units that are not in your group or not currently targetted.

Last edited by wardz : 11-22-23 at 07:04 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Troubles checking debuff on raid members


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off