-
Notifications
You must be signed in to change notification settings - Fork 2
/
damage_tracker.lua
46 lines (32 loc) · 1.05 KB
/
damage_tracker.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
local myname, ns = ...
ns.damagetotals, ns.times = {}, {}
local logevents = {
SWING_DAMAGE = true,
RANGE_DAMAGE = true,
SPELL_DAMAGE = true,
SPELL_PERIODIC_DAMAGE = true,
DAMAGE_SHIELD = true,
DAMAGE_SPLIT = true
}
local f = CreateFrame("Frame")
f:SetScript("OnUpdate", function(self, elap)
for unit,id in pairs(ns.ids) do
if UnitAffectingCombat(unit) then ns.times[id] = (ns.times[id] or 0) + elap end
end
ns.Refresh()
end)
function ns.COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, logevent, hideCaster,
sourceGUID, sourceName, sourceFlags, sourceRaidFlags,
destGUID, destName, destFlags, destRaidFlags, ...)
if not logevents[logevent] then return end
local spellId, spellName, spellSchool, amount, overkill, school, resisted,
blocked, absorbed, critical, glancing, crushing = ...
if logevent == "SWING_DAMAGE" then
amount, overkill, school, resisted, blocked, absorbed, critical, glancing,
crushing = ...
end
local unit = ns.units[sourceGUID]
if unit then
ns.damagetotals[unit] = (ns.damagetotals[unit] or 0) + amount
end
end