Thread Tools Display Modes
11-09-10, 08:05 AM   #1
Juanito
Guest
Posts: n/a
Keeping track of aura?

I've been looking around and haven't really found the answer to my question on my own, so I'll make a post:

What would be the most efficient way of keeping track of all your applied auras and getting their duration/expirationTime? I've been thinking of watching CLEU for SPELL_AURA_* and adding that aura to a table by destGUID, and then watching PLAYER_TARGET_CHANGED and UNIT_AURA, checking the table to see if the current target's GUID exists in the table, and doing the setup of timers there in UNIT_AURA (and calling the UNIT_AURA function from PTC), unless...

Is there any way to get aura duration/expirationTime from the CLEU event without the UnitID to call UnitAura() with?
  Reply With Quote
11-09-10, 08:10 AM   #2
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
well you could store the destGUID from the CLEU and then iterate through your party/raid

Code:
for i=1, 40 do
  if UnitExists("raid"..i) then
    if UnitGUID("raid"..i) == storedGUID then
       --nest a for loop to iterate through UnitAura
    end
  else
    break
  end
end
If you plan on using this for players possibly outside your group (random people in the world or perhaps people in wintergrasp outside your raid), then you'd have to rely on the CLEU, because it would be unreliable to find the person except for "target". Possible iterate through all raid members as in "raid"..i.."target" to see if you can get a matching GUID.

Also you could use a better way to iterate through raid members, but that would be a generic loop i suppose
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote
11-09-10, 08:16 AM   #3
Juanito
Guest
Posts: n/a
Well, if the aura in question was a friendly buff, doesn't UnitAura accept player names a proper unitId? But what about hostile npcs where the only real way to keep track of Scary Skeleton 1 and Scary Skeleton 2 is by their GUID >>

Because the only way I can think of doing this is to watch UNIT_AURA which can get pretty spammy when there are 25 people and a raid boss applying/removing auras from the units that will fire the UNIT_AURA event, but I was thinking if i at least had a table of guids that I actually had auras applied to, I could at least check that before going off and calling UnitAura every .01 second ><
  Reply With Quote
11-09-10, 08:47 AM   #4
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
well its simple really, the CLEU for spell auras gives a sourceGUID, destGUID, spellID, and the event being called

so if sourceGUID == UnitGUID("player") i.e you then we continue on to the next step

if the event is SPELL_AURA_APPLIED then we know a buff just got applied

SPELL_PERIODIC_DAMAGE means we just kicked some ass and some big numbers went flyin (it might not be SPELL_PERIODIC_DAMAGE, but work with me)

so if we are tracking our auras on Scary Skeleton1 and SS2 then we get our information like so

Code:
local timestamp, event, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, spellID, spellName, spellSchool, auraType = ...

if sourceGUID == UnitGUID("player") then --its ours
  if event == "SPELL_AURA_APPLIED" then --we added a buff
    tinsert(guidTable, destGUID)
    for k,v in ipairs(guidTable) do
      print(v) --prints each GUID that has one of my auras applied
    end
  end
  elseif event == "SPELL_AURA_REMOVED" then
    for k,v in ipairs(guidTable) do
      if v == destGUID then
        tremove(guidTable, k) --removes that guid from my table
      end
    end
  end
end
and then for other events, or perhaps onupdate for your frame, you update the timers you have or let em run.

So like,you couldnt use UnitAura(guid) but you could run a for loop to get your raid member targets to see if they match up. Or if you know the duration of the buff, you could assign that to a timer.

lol, hope that makes sense
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>

Last edited by Xubera : 11-09-10 at 08:49 AM.
  Reply With Quote
11-09-10, 09:06 AM   #5
Taroven
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 49
UNIT_AURA returns a unit. Without knowing too much about the code, you can do something like this (drycode, don't trust it too much):
Code:
local guidcache = {}
local GUIDCache = function ()
    table.wipe(guidcache)
    table.wipe(unitcache)
    local group = GetNumRaidMembers() > 1 and 'raid' or 'party'
    for i = 1,40 do
        local unit = group..i
        if UnitExists(unit) then
            local guid = UnitGUID(unit)
            guidcache[unit] = guid -- guidcache.raid4 = UnitGUID('raid4')
            unitcache[guid] = unit -- guidcache.0xstuff = 'raid4'
        else break end
    end
    -- cache GUIDs/units for player, target, etc as needed outside the loop
end

-- example aura caching from EventHorizon - Cache all auras and then cherrypick them in specific functions as needed
local mainframe_UNIT_AURA = function (self,unit)
	if vars.buff[unit] then
		table.wipe(vars.buff[unit])
		for i = 1,50 do
			local name, _, icon, count, _, duration, expirationTime, source, _, _, spellID = UnitBuff(unit,i)
			--print(name,icon,count,duration,expirationTime,source,spellID)
			if not (name and spellID) then break end
			table.insert(vars.buff[unit],{
				name = name,
				icon = icon,
				count = count,
				duration = duration,
				expirationTime = expirationTime,
				source = source,
				spellID = spellID,
			})
		end
	end
	if vars.debuff[unit] then
		table.wipe(vars.debuff[unit])
		for i = 1,100 do
			local name, _, icon, count, _, duration, expirationTime, source, _, _, spellID = UnitDebuff(unit,i)
			if not (name and spellID) then break end
			table.insert(vars.debuff[unit], {
				name = name,
				icon = icon,
				count = count,
				duration = duration,
				expirationTime = expirationTime,
				source = source,
				spellID = spellID,
			})
		end
	end	
	for i,spellframe in pairs(ns.frames.frames) do
		if (spellframe.auraunit and spellframe.auraunit == unit) then
			spellframe:UNIT_AURA(unit)
		end
	end
end
That should give you an idea of very basic GUID caching and how to store aura info in a sane manner for later retrieval.

Edit: To clarify, GUID caching is only really needed on your target/focus/tot, and only if you intend to continue tracking effects after switching targets.
__________________
Former author of EventHorizon Continued and Other Releases.

Last edited by Taroven : 11-09-10 at 09:20 AM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Keeping track of aura?


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