Thread Tools Display Modes
03-11-20, 05:23 AM   #1
FranekW
A Cyclonian
 
FranekW's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 44
Tracking debuffs on multiple units affected by AoE spells

Hello,

What would be the best way to track multiple targets affected by multiple AoE spells?

Each AoE spell applies the same debuff to all units within the area of effect e.g. Druid Feral's Thrash is a multitarget spell which doesn't need a valid single target but applies DoTs to all non-friendly units including invisible units. Similarly, Primal Wrath does the same with a different debuff.

I made a simple function with Thrash. It is logged by CLEU using subevents such as "SPELL_DAMAGE", "SPELL_CAST_SUCCESS", "SPELL_CAST_FAILED", etc. I tried the following code:

Lua Code:
  1. -- spellID, sourceGUID etc. comes from CLEU
  2.  
  3. if sourceGUID ~= UnitGUID("player") then return end
  4.  
  5. -- Thrash spellID: 106830
  6. if subevent == "SPELL_CAST_SUCCESS" and spellID == 106830 then
  7.     local spellName = GetSpellInfo(spellID)
  8.     for i = 1,40 do
  9.         local unit = "nameplate"..i
  10.         if UnitExists(unit)
  11.                 and not UnitIsFriend("player", unit)
  12.                 and IsSpellInRange(spellName, unit) then
  13.             tinsert(auratable.targets, UnitGUID(unit))
  14.         end
  15.     end
  16.     ViragDevTool_AddData(auratable.targets, "Encounter"..encounter)
  17.     auratable.encounter = auratable.encounter + 1
  18. end

but the table auratable.targets is empty after each combat session.

I thought about catching the "UNIT_AURA" event and if a nameplate gains a debuff but having to test 40 units and checking 40 indices of possible debuff per unit each time I apply one of the AoE spells seems like a lot of loops to do.

Last edited by FranekW : 03-12-20 at 05:39 AM.
  Reply With Quote
03-11-20, 09:37 AM   #2
jeruku
A Cobalt Mageweaver
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 223
The IDs referenced in the CLEU are GUIDs. Any ID used for a unit frame is a Unit ID(or token) which normally refers to a frame that can be referenced, or created securely.

You can cache the GUIDs when nameplates are added/removed and use those to check applicable units in the CLEU so you can avoid multiplicative aura scans, especially if you'd be scanning nameplates and raid frames.

Performance tip: Cache the player GUID in the frame your using for the CLEU event and put the IF statements inside the player check.
Lua Code:
  1. frame.playerGUID = UnitGUID('player')
  2. frame.AuraList = { -- skip this if you're not planning on adding more de/buffs
  3.     106830 = true,
  4. }
  5.  
  6. -- CLEU code with assuming your function is passed the frame as self
  7. if sourceGUID == self.playerGUID then
  8.    if subevent == "SPELL_CAST_SUCCESS" and frame.AuraList[spellList] then
  9.        -- some more code
  10.    end
  11. end
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison
  Reply With Quote
03-11-20, 11:36 AM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
And move that player GUID check outside of your OnEvent function. You should just need to grab it once.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
03-12-20, 05:54 AM   #4
FranekW
A Cyclonian
 
FranekW's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 44
First of all, thanks for the performance tip.

Second, I should have mentioned that the function is a part of a lua code inside WeakAuras. I don't fully understand the bit with frame reference. I think you are just pointing out the difference between UnitID related to a frame and unitGUID in CLEU. If I query a unit using `UnitGUID` I should get the unit's GUID. Is that correct?

Regarding the second point, is my approach with for loop good enough for adding / removing nameplates from cache? I am thinking about something like event where a player gets new nameplate etc.

Thanks.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Tracking debuffs on multiple units affected by AoE spells

Thread Tools
Display Modes

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