Add new code snippets
This commit is contained in:
43
Complete Projects/Legion/Target TTD.lua
Normal file
43
Complete Projects/Legion/Target TTD.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
--GAVE UP
|
||||
--COMBAT_LOG_EVENT_UNFILTERED
|
||||
function(e, ...)
|
||||
local se = select(2, ...)
|
||||
if se and (se == "SPELL_DAMAGE" or se == "SPELL_PERIODIC_DAMAGE" or se == "SWING_DAMAGE") then
|
||||
local targetguid = select(8, ...)
|
||||
local hit = select(15, ...)
|
||||
if se == "SWING_DAMAGE" then
|
||||
hit = select(12, ...)
|
||||
end
|
||||
if targetguid and hit and targetguid == UnitGUID("target") then
|
||||
aura_env.hitTable[#aura_env.hitTable + 1] = hit
|
||||
aura_env.hitTimerTable[#aura_env.hitTimerTable + 1] = debugprofilestop()
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
--DISPLAY
|
||||
function()
|
||||
local totalDamage = 0
|
||||
if UnitExists("target") then
|
||||
local thp, tmhp = UnitHealth("target"), UnitHealthMax("target")
|
||||
for k, v in ipairs(aura_env.hitTable) do
|
||||
totalDamage = totalDamage + v
|
||||
end
|
||||
return thp / (totalDamage / aura_env.lifespan)
|
||||
end
|
||||
end
|
||||
|
||||
--EVERY_FRAME
|
||||
function()
|
||||
if aura_env.hitTimerTable[1] and debugprofilestop() - aura_env.hitTimerTable[1] > aura_env.lifespan then
|
||||
table.remove(aura_env.hitTimerTable, 1)
|
||||
table.remove(aura_env.hitTable, 1)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
--INIT
|
||||
aura_env.hitTable = {}
|
||||
aura_env.hitTimerTable = {}
|
||||
aura_env.lifespan = 5000
|
||||
Reference in New Issue
Block a user