Quantcast Track a debuff and start a timer when it's removed - WoWInterface
Thread Tools Display Modes
01-24-19, 05:25 PM   #1
FranekW
An Aku'mai Servant
 
FranekW's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 31
Track a debuff and start a timer when it's removed

Hello,

I am trying to build a simple function which will track a certain debuffs, that is to track moments when debuffs are applied and when they are removed. Then I would like to start a simple timer when the debuff which I track is over.

First I tried using UNIT_AURA but it gets fired every time a debuff changes or do damage to a unit. Then I came across COMBAT_LOG_EVENT, which is quite complicated. I have a simple function which I tried to create based on wowpedia and some code from WoW Interface:

Lua Code:
  1. function(timestamp, event, hideCaster,
  2.     sourceGUID, sourceName, sourceFlags, sourceRaidFlags,
  3.     destGUID, destName, destFlags, destRaidFlags, spellId, spellName, spellSchool, ...)
  4.  
  5.     if event == "SPELL_AURA_APPLIED" or event == "SPELL_AURA_REFRESHED" then
  6.         auraType, amount = ...
  7.         if auraType == "DEBUFF" then
  8.             -- Check the debuff is in the list to track
  9.             -- cache Target's GUID and the debuff's ID
  10.         end
  11.     elseif event == "SPELL_AURA_REMOVED" then
  12.         auraType, amount = ...
  13.         if check whether you track that debuff then
  14.             -- Check if debuff is in cache, if it was applied
  15.             -- if Yes, removed from cache and start a timer
  16.         end
  17.     else
  18.         -- do things in case debuff was neither atarted nor removed
  19.     end
  20. end

So the above function is run such that I pass all parameters COMBAT_LOG_EVENT returns. Is this function any close to do what I need it to do? I am simply need to know what aura is applied to a target and when it is over. Then I would like to start a timer.

Thanks.
  Reply With Quote
01-26-19, 05:28 AM   #2
d87
A Flamescale Wyrmkin
 
d87's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 132
CLEU doesn't tell aura durations, so you'll either have to use static values or use UNIT_AURA anyway, which is still complicated because combat log events happen before updated auras become available to UnitAura

Also i'm pretty sure that since 8.0 you have to use CombatLogGetCurrentEventInfo() function to get CLEU args. Like this:

function NugRunning.COMBAT_LOG_EVENT_UNFILTERED( self, event )

local timestamp, eventType, hideCaster,
srcGUID, srcName, srcFlags, srcFlags2,
dstGUID, dstName, dstFlags, dstFlags2,
spellID, spellName, spellSchool, auraType, amount = CombatLogGetCurrentEventInfo()

...
Unless you need to know what's happening with targets that are not assigned to any UnitID, you better stick with UNIT_AURA

Last edited by d87 : 01-26-19 at 05:36 AM.
  Reply With Quote
01-26-19, 08:13 PM   #3
FranekW
An Aku'mai Servant
 
FranekW's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 31
Ok. Thanks for this. Iíll try to find how to work with UNIT_AURA. I just donít how to distinguish between start, end of aura. UNIT_AURA also is triggered when Debuffs / DoTs tick.
  Reply With Quote
01-26-19, 08:13 PM   #4
FranekW
An Aku'mai Servant
 
FranekW's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 31
Ok. Thanks for this. Iíll try to find how to work with UNIT_AURA. I just donít how to distinguish between start, end of aura. UNIT_AURA also is triggered when Debuffs / DoTs tick.
  Reply With Quote
01-26-19, 08:47 PM   #5
jlam
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 27
If you are using UNIT_AURA to track unit debuffs, you will need to keep track of the debuffs that you see when UNIT_AURA is received so that the next time you receive UNIT_AURA, you can figure out what was added, removed, or refreshed. It's a decent amount of state that you have to track.
  Reply With Quote
01-27-19, 09:07 AM   #6
jeruku
A Chromatic Dragonspawn
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 184
You are on the right track. Though watching auras with UnitAura on units by GUID requires that unit to have a token(player, target, raid1-40, party1-5, nameplate1-40, etc...) at nearly all times. Caching the duration on UNIT_AURA can help circumvent this while waiting for the CLEU_AURA_REMOVED trigger for fall off. That CLEU event can also be used to start the timer when the aura is removed.

Since your goal is to watch the aura AND a time period afterward your best bet is to register the CLEU event in UNIT_AURA if you cache any auras. Un-registering CLEU after all auras fall off will prevent excessive overhead from scanning the combat log continuously.
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison

Last edited by jeruku : 01-27-19 at 09:08 AM. Reason: Clarity required.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Track a debuff and start a timer when it's removed

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