Thread Tools Display Modes
04-18-11, 04:32 AM   #1
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Need help tracking current absorb values for player auras

I have plans to make an addon to track absorb effects on myself. I have the tracking part done for when aura's are applied/refreshed/removed and want to find a way to update the current values for the effects whenever you absorb something. One way would be tooltip scanning I think, but I'm wondering if there's any other way.

Here is my current code:
lua Code:
  1. local evtframe = CreateFrame("Frame", name..'Frame')
  2. evtframe.shields = {
  3.     -- Priest stuff
  4.     [17] = { max = {}, cur = {} }, -- Power Word: Shield
  5.     [47753] = { max = {}, cur = {} }, -- Divine Aegis
  6.     -- DK stuff
  7.     [77535] = { max = {}, cur = {} }, -- Blood Shield
  8.     -- Paladin stuff
  9.     [86273] = { max = {}, cur = {} }, -- Illuminated Healing
  10.     [96263] = { max = {}, cur = {} }, -- Sacred Shield
  11. }
  12.  
  13. function evtframe:SPELL_AURA_APPLIED(srcGUID, spellId, spellName, amount)
  14.     Debug(spellName..' applied.')
  15.     self.shields[spellId].max[srcGUID] = amount
  16.     self:SPELL_AURA_REFRESHED(srcGUID, spellId, spellName, amount)
  17. end
  18.  
  19. function evtframe:SPELL_AURA_REFRESHED(srcGUID, spellId, spellName, amount)
  20.     if self.shields[spellId].max[srcGUID] < amount then
  21.         self.shields[spellId].max[srcGUID] = amount
  22.     end
  23.     Debug(spellName..' has '..amount..' of '..(self.shields[spellId].max[srcGUID])..' left')
  24.     self.shields[spellId].cur[srcGUID] = amount
  25. end
  26.  
  27. function evtframe:SPELL_AURA_REMOVED(srcGUID, spellId, spellName, amount)
  28.     Debug(spellName..' has been removed or timed out.')
  29.     self.shields[spellId].max[srcGUID] = nil
  30.     self.shields[spellId].cur[srcGUID] = nil
  31. end
  32.  
  33. evtframe:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
  34. evtframe:SetScript("OnEvent", function(self, _, timestamp, subevent, srcGUID, srcName, sourceFlags, dstGUID, dstName, dstFlags, spellId, spellName, spellSchool, auraType, amount)
  35.     if not (
  36.         dstGUID == UnitGUID'player' and
  37.         self[subevent] and
  38.         self.shields[spellId]
  39.     ) then return end
  40.     --Debug(timestamp, event, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, spellId, spellName, spellSchool, auraType, amount)
  41.     self[event](self, srcGUID, spellId, spellName, amount)
  42. end)

Any optimization suggestions(if possible) are also welcome.
  Reply With Quote
04-26-11, 04:05 AM   #2
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
after you get a shield's absorb amount, couldnt you just use the C_L_E_U and do math to determine the absorb amount, merely rechecking the tooltip from time to time for accuracy

like if playerA gets a pw:shield and the tooltip says absorbs 1500, then you get a C_L_E_U event and one of the absorbed counters says 1200, you know theres 300 left without needing to scan the tooltip, then perhaps periodically, maybe every few seconds, check the tooltip for accuracy.

and i dont know how to optimize lol
__________________
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
04-26-11, 07:17 AM   #3
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Originally Posted by Xubera View Post
after you get a shield's absorb amount, couldnt you just use the C_L_E_U and do math to determine the absorb amount, merely rechecking the tooltip from time to time for accuracy

like if playerA gets a pw:shield and the tooltip says absorbs 1500, then you get a C_L_E_U event and one of the absorbed counters says 1200, you know theres 300 left without needing to scan the tooltip, then perhaps periodically, maybe every few seconds, check the tooltip for accuracy.

and i dont know how to optimize lol
The problem with this is that CLEU does not give you information on what aura(s) absorbed damage. So I think I have to scan tooltips every time on:
  • A partial absorb from a white melee attack
  • A partial absorb from a ranged shot ,spell, or dot
  • A missed white melee attack(type == "ABSORB")
  • A missed ranged shot, spell, or dot(type == "ABSORB")

Bah

I'm currently using this code to do so, I have yet to write the tooltipscanner.
I also removed the functions for the subevents, because, well, they feel like they are unneeded.
lua Code:
  1. evtframe:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
  2. evtframe:SetScript("OnEvent", function(self, _, timestamp, type, srcGUID, srcName, sourceFlags, dstGUID, dstName, dstFlags, ...)
  3.     if dstGUID ~= UnitGUID('player') then
  4.         return
  5.     end
  6.  
  7.     local hasshields = ns:HasActiveShields()
  8.     -- Aura applied or removed
  9.     if type == 'SPELL_AURA_APPLIED' or
  10.         hasshields and (
  11.             type == 'SPELL_AURA_REFRESHED' or
  12.             type == 'SPELL_AURA_REMOVED'
  13.         )
  14.     then
  15.         local unit = GUIDToUnitID(srcGUID)
  16.         local id, name, school, type, amount = ...
  17.         -- make sure we have a trackable unit
  18.         -- make sure we want to track the aura
  19.         if not unit or not ns.shields[id] then return end
  20.         if type == 'SPELL_AURA_REMOVED' then
  21.             ns:UpdateMax(unit, srcGUID, id, name, type, amount, true)
  22.         else
  23.             ns:UpdateMax(unit, srcGUID, id, name, type, amount)
  24.         end
  25.         ns:UpdateAllBars()
  26.     -- Do not proceed if there are no shields active
  27.     -- This is to prevent tracking of absorbed damage via soul link (warlocks)
  28.     -- and other shields that absorb a percentage of health
  29.     -- There is no need to check in that case.
  30.     elseif hasshields then
  31.         -- "Melee" partial absorb
  32.         if type == "SWING_DAMAGE" then
  33.             local _, _, _, _, _, absorbed = ...
  34.             if not absorbed then return end
  35.             ns:UpdateFromTooltips()
  36.         -- "Spell" partial absorb
  37.         elseif type == "RANGE_DAMAGE"
  38.             or type == "SPELL_DAMAGE"
  39.             or type == "SPELL_PERIODIC_DAMAGE"
  40.         then
  41.             local _, _, _, _, _, _, _, _, absorbed = ...
  42.             if not absorbed then return end
  43.             ns:UpdateFromTooltips()
  44.         -- "Melee" full absorb
  45.         elseif type == "SWING_MISSED"  then
  46.             local missType = ...
  47.             if missType ~= "ABSORB"  then return end
  48.             ns:UpdateFromTooltips()
  49.         -- "Spell" full absorb
  50.         elseif type == "RANGE_MISSED"
  51.             or type == "SPELL_MISSED"
  52.             or type == "SPELL_PERIODIC_MISSED"
  53.         then
  54.             local _, _, _, missType = ...
  55.             if missType ~= "ABSORB" then return end
  56.             ns:UpdateFromTooltips()
  57.         end
  58.     end
  59. end)
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Need help tracking current absorb values for player auras


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