/branches
-- Configuration -------------------------------------------------------------- |
local updateTime = 0.250 -- Update threshold |
-- Main frame settings |
local xPos = 0 -- X offset for center of 'frame' |
local yPos = -120 -- Y offset for center of 'frame' |
local font = UNIT_NAME_FONT -- What font to use |
local threatSize = 24 -- Font size of 'threat' display |
local infoSize = 12 -- Font size of 'info' display |
local shadow = false -- Font shadow |
local outline = true -- Font outline |
local colorThreat = true -- Color 'threat' based on how close you are to taking or losing aggro |
-- Threat line settings |
local showPercent = true -- Show threat percentage value |
local showRaw = false -- (No function yet) Show raw threat value. Displays the amount of threat until you will pull aggro |
local threatSize = 24 -- Font size of 'threat' |
local colorThreat = true -- Color 'threat' based on how close you are to taking or losing aggro |
local threatYellowThreshold = 80 |
local threatRedThreshold = 100 |
-- Info line settings |
local showInfo = true -- Show 'info' display underneath 'threat' |
local infoSize = 12 -- Font size of 'info' |
local colorInfo = true -- Color 'info' based on status. No effect if 'infoIsTank' is true |
local infoIsTank = false -- Display tank name in 'info'. This will override the default behavior of 'info' |
local locked = true -- Lock the display, set to false for "demo" information |
local showSolo = false |
-- Situational show/hide settings |
local showInRaid = true |
local showInParty = true |
local showWithPet = true |
local showInParty = true |
local showInRaid = true |
local showWhileSolo = true -- [release: default to false] |
local hideIfTanking = false |
local threatYellowThreshold = 80 |
local threatRedThreshold = 100 |
------------------------------------------------------------------------------- |
-- Initialize 'frame' Frame |
local displayHandler = coroutine.create(function() |
local show = false |
-- Group-based handlers |
if (showSolo and not (UnitExists("pet") or GetRealNumPartyMembers() or GetRealNumRaidMembers())) then show = true end |
if (showWithPet and UnitExists("pet")) then show = true end |
if (showInParty and GetRealNumPartyMembers()) then show = true end |
if (showInRaid and GetRealNumRaidMembers()) then show = true end |
-- Aggro handler |
if (showInRaid |
and GetNumRaidMembers() ~= 0) |
then show = true |
elseif (showInParty |
and GetNumPartyMembers() ~= 0 |
and GetNumRaidMembers() == 0) |
then show = true |
elseif (showWithPet |
and UnitExists("pet") |
and GetNumPartyMembers() == 0 |
and GetNumRaidMembers() == 0) |
then show = true |
elseif (showWhileSolo |
and not UnitExists("pet") |
and GetNumPartyMembers() == 0 |
and GetNumRaidMembers() == 0) |
then show = true |
end |
-- Tanking handler |
if (hideIfTanking and playerInfo.tanking) then show = false end |
-- Locked handler |
if (not locked) then show = true end |
if (show) then frame:Show else frame:Hide end |
if (showPercent) then |
if (showTank) then tank:Show() else tank:Hide() end |
if (show) then frame:Show() else frame:Hide() end |
if (showPercent) then threat:Show() else threat:Hide() end |
if (showInfo) then info:Show() else info:Hide() end |
end) |
-- Update handler |
frame:SetScript("OnUpdate", function(self, elapsed) |
local player, tank, ToT = {}, {}, {} |
-- Only run if we have an NPC target with a target (or 'locked' is false), otherwise don't waste the cycles |
if (not UnitExists("target") or not UnitExists("targettarget") or UnitIsPlayer("target") or locked) then return end |
-- Only run if we have an NPC target with a target, otherwise don't waste the cycles |
if (not UnitExists("target") |
or not UnitExists("targettarget") |
or UnitIsPlayer("target")) |
then return end |
-- Don't update too quickly |
if (timeSinceLastUpdate == nil) then timeSinceLastUpdate = 0 end |
player.tanking, player.status, _, _, player.threat = UnitDetailedThreatSituation("player", "target") |
ToT.name = UnitName("targettarget") |
if (tank.name and ToT.name == tank.name) then -- Check to see if ToT is actually our tank so we can display the correct data |
_, _, _, _, tank.threat = UnitDetailedThreatSituation("targettarget", "target") |
_, _, _, _, tank.threat = UnitDetailedThreatSituation(tank.name, "target") |
elseif (tank.name) then |
_, _, _, _, ToT.threat = UnitDetailedThreatSituation(ToT.name, "target") |
_, _, _, _, tank.threat = UnitDetailedThreatSituation(tank.name, "target") |