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:
local evtframe = CreateFrame("Frame", name..'Frame')
evtframe.shields = {
-- Priest stuff
[17] = { max = {}, cur = {} }, -- Power Word: Shield
[47753] = { max = {}, cur = {} }, -- Divine Aegis
-- DK stuff
[77535] = { max = {}, cur = {} }, -- Blood Shield
-- Paladin stuff
[86273] = { max = {}, cur = {} }, -- Illuminated Healing
[96263] = { max = {}, cur = {} }, -- Sacred Shield
}
function evtframe:SPELL_AURA_APPLIED(srcGUID, spellId, spellName, amount)
Debug(spellName..' applied.')
self.shields[spellId].max[srcGUID] = amount
self:SPELL_AURA_REFRESHED(srcGUID, spellId, spellName, amount)
end
function evtframe:SPELL_AURA_REFRESHED(srcGUID, spellId, spellName, amount)
if self.shields[spellId].max[srcGUID] < amount then
self.shields[spellId].max[srcGUID] = amount
end
Debug(spellName..' has '..amount..' of '..(self.shields[spellId].max[srcGUID])..' left')
self.shields[spellId].cur[srcGUID] = amount
end
function evtframe:SPELL_AURA_REMOVED(srcGUID, spellId, spellName, amount)
Debug(spellName..' has been removed or timed out.')
self.shields[spellId].max[srcGUID] = nil
self.shields[spellId].cur[srcGUID] = nil
end
evtframe:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
evtframe:SetScript("OnEvent", function(self, _, timestamp, subevent, srcGUID, srcName, sourceFlags, dstGUID, dstName, dstFlags, spellId, spellName, spellSchool, auraType, amount)
if not (
dstGUID == UnitGUID'player' and
self[subevent] and
self.shields[spellId]
) then return end
--Debug(timestamp, event, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, spellId, spellName, spellSchool, auraType, amount)
self[event](self, srcGUID, spellId, spellName, amount)
end)
Any optimization suggestions(if possible) are also welcome.