WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Track a debuff and start a timer when it's removed (https://www.wowinterface.com/forums/showthread.php?t=56995)

FranekW 01-24-19 05:25 PM

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.

d87 01-26-19 05:28 AM

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:

Quote:

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

FranekW 01-26-19 08:13 PM

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.

FranekW 01-26-19 08:13 PM

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.

jlam 01-26-19 08:47 PM

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.

jeruku 01-27-19 09:07 AM

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.


All times are GMT -6. The time now is 11:27 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI