From c86b38ccf5e4e2b815efd91058564804b3b393cd Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Sun, 20 Jan 2008 21:18:38 +0000 Subject: [PATCH] * Patch from [Ammo] to fix aggro detection * Added SetFormattedText() in the buffs module --- PerfectRaid_Aggro.lua | 77 ++++++++++++++++++++++++++----------------------- PerfectRaid_Buffs.lua | 2 +- 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/PerfectRaid_Aggro.lua b/PerfectRaid_Aggro.lua index ca5b3bc..b65094f 100644 --- a/PerfectRaid_Aggro.lua +++ b/PerfectRaid_Aggro.lua @@ -77,49 +77,54 @@ end local elapsed = 0 function Aggro.OnUpdate() - local self = Aggro elapsed = elapsed + arg1 if elapsed >= rate then + -- Aggro check for unit,tbl in pairs(frames) do - -- Aggro check - - - for unit,tbl in pairs(frames) do - if not targets[unit] then - targets[unit] = unit.."target" - victims[unit] = unit.."targettarget" - aggro[unit] = 0 - end + if not targets[unit] then + targets[unit] = unit.."target" + victims[unit] = unit.."targettarget" + aggro[unit] = 0 + end - local target = targets[unit] - local victim = victims[unit] - if UnitIsUnit(victim, unit) and UnitCanAttack(unit, target) then - -- unit is being targeted by a hostile mob - local val = aggro[unit] - if val < 20 then - aggro[unit] = val + 10 + local target = targets[unit] + local victim = victims[unit] + + if UnitExists(target) and UnitCanAttack(unit, target) and UnitExists( victim ) and UnitCanAttack(victim, target) then + for unit2, tbl2 in pairs(frames) do + if unit2 and UnitIsUnit( unit2, victim ) then + -- unit is being targeted by a hostile mob + if not targets[unit2] then + targets[unit2] = unit2.."target" + victims[unit2] = unit2.."targettarget" + aggro[unit2] = 0 + end + local val = aggro[unit2] + if val < 20 then + aggro[unit2] = val + 10 + end end + end + end + end + + -- aggro update + for unit, tbl in pairs(frames) do + -- Aggro decay (thanks BanzaiLib) + if aggro[unit] >= 5 then + aggro[unit] = aggro[unit] - 5 + end + -- Use this when a unit has aggro + if aggro[unit] >= 15 then + if not marked[unit] then + PerfectRaid:UNIT_HEALTH(nil, unit) + marked[unit] = true end - - -- Aggro decay (thanks BanzaiLib) - if aggro[unit] >= 5 then - aggro[unit] = aggro[unit] - 5 - end - - -- Use this when a unit has aggro - if aggro[unit] >= 15 then - if not marked[unit] then - PerfectRaid:UNIT_HEALTH(nil, unit) - marked[unit] = true - end - else - if marked[unit] then - PerfectRaid:UNIT_HEALTH(nil, unit) - marked[unit] = nil - end + else + if marked[unit] then + PerfectRaid:UNIT_HEALTH(nil, unit) + marked[unit] = nil end - - local name = UnitName(unit) end end elapsed = 0 diff --git a/PerfectRaid_Buffs.lua b/PerfectRaid_Buffs.lua index b3b57f9..b2d0c25 100644 --- a/PerfectRaid_Buffs.lua +++ b/PerfectRaid_Buffs.lua @@ -234,7 +234,7 @@ function Buffs:UNIT_AURA(event, unit) local status = strjoin(" ", unpack(work)) for frame in pairs(frames[unit]) do - frame.aura:SetText(status) + frame.aura:SetFormattedText(status) frame:SetBackdropColor(r,g,b,a) frame.backdropset = bdset end -- 1.7.9.5