--------------------------------
-- copyright Felix S., Chiril --
--------------------------------
-- kind 'a config
-- - - - - - - - - - - - -
local testmode = 0 -- 0 = off, 1 = on
local position_a = "BOTTOM"
local position_b = "CENTER"
local position_x = 0
local position_y = -152
local width = 225
local height = 3
local statusbar = "Interface\\AddOns\\iThreat\\media\\statusbar"
local color ={ r = 255/255, g = 0/255, b = 0/255 }
local tankcolor ={ r = 250/255, g = 88/255, b = 240/255 }
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- real adddon starts here
-- don't change anything if you don't know what you're doing;)
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- create some shit
-- - - - - - - - - - - - -
local function onEvent(self, event, ...)
local unit = ...
if unit == "target" or event == "PLAYER_TARGET_CHANGED" then
self:SetValue(0)
self:Hide()
if UnitCanAttack("player", "target") and not UnitIsPlayer(unit) then
local _, status, threatpct = UnitDetailedThreatSituation("player", "target")
if status and status < 2 then
self:SetValue(threatpct)
self:SetStatusBarColor(color.r, color.g, color.b)
self:Show()
elseif status and status > 2 then
self:SetValue(100)
self:SetStatusBarColor(tankcolor.r, tankcolor.g, tankcolor.b)
self:Show()
end
end
end
end
local frame = CreateFrame("StatusBar", "iThreat", UIParent)
frame:Hide()
frame:SetPoint(position_a, UIParent, position_b, position_x, position_y)
frame:SetWidth(width)
frame:SetHeight(height)
frame:SetStatusBarTexture(statusbar)
frame:SetStatusBarColor(color.r, color.g, color.b)
frame:SetMinMaxValues(0,100)
frame:SetValue(0)
frame:SetBackdrop({ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",insets = {left = -1, right = -1, top = -1, bottom = -1}})
frame:SetBackdropColor(0,0,0,1)
frame:RegisterEvent("UNIT_THREAT_LIST_UPDATE")
frame:RegisterEvent("PLAYER_TARGET_CHANGED")
frame:SetScript("OnEvent", onEvent)
frame.background = frame:CreateTexture(nil, "BACKGROUND")
frame.background:SetAllPoints()
frame.background:SetTexture(statusbar)
frame.background:SetVertexColor(0,0,0, 1)
if testmode == 1 then
frame:SetValue(50)
frame:Show()
end