From 128df2f09d5588cd99869bb17323b29bd5a9f643 Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 20 Jan 2018 20:03:44 +0100 Subject: [PATCH] unitframes: update aggro scan mechanics --- api/unitframes.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index b14c331b..aa851d0b 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -26,8 +26,13 @@ for i=1,40 do pfValidUnits["raidpet" .. i .. "target"] = true end local aggrodata = { } function pfUI.api.UnitHasAggro(unit) - if UnitExists(unit) and UnitIsFriend(unit, "player") and ( not aggrodata[unit] or GetTime() < aggrodata[unit].check + 1 ) then - aggrodata[unit] = { check = GetTime(), state = 0} + if aggrodata[unit] and GetTime() > aggrodata[unit].check + 1 then + return aggrodata[unit].state + end + + aggrodata[unit] = aggrodata[unit] or { check = GetTime(), state = 0} + + if UnitExists(unit) and UnitIsFriend(unit, "player") then for u in pairs(pfValidUnits) do local t = u .. "target" local tt = t .. "target" @@ -36,7 +41,8 @@ function pfUI.api.UnitHasAggro(unit) end end end - return aggrodata[unit] and aggrodata[unit].state or 0 + + return aggrodata[unit].state end pfUI.uf.glow = CreateFrame("Frame")