WoWInterface SVN NoThreat

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 4 to Rev 5
    Reverse comparison

Rev 4 → Rev 5

tags/NoThreat_v1.0/NoThreat.toc New file
0,0 → 1,6
## Interface: 30100
## Title: NoThreat
## Author: Rakzul
## Version: 1.0
## Notes: Displays your current threat on your target in percentage
core.lua
\ No newline at end of file
tags/NoThreat_v1.0/core.lua New file
0,0 → 1,97
-- Configuration --------------------------------------------------------------
 
local xPos = 0 -- X pos for text
local yPos = -90 -- Y pos for text
local size = 20 -- Font size
local shadow = true -- Font shadow (true=yes, false=no)
local updateTime = 0.250 -- Threat update threshold
local showTank = true -- Display tank name (true=yes, false=no)
local hideIfAggro = true -- Hide display if we get aggro (true=yes, false=no)
local locked = false -- Lock the display, set to false for configuring
local font = UNIT_NAME_FONT -- What font to use
 
-------------------------------------------------------------------------------
 
local frame = CreateFrame("Button", "NoThreat", UIParent)
frame:SetPoint("CENTER", UIParent, "CENTER", xPos, yPos)
frame:SetHeight(size)
frame:SetWidth(size)
 
local threat = frame:CreateFontString(nil, "OVERLAY")
threat:SetPoint("CENTER", frame, "CENTER")
threat:SetFont(font, size, "NONE")
 
if (shadow) then
threat:SetShadowColor(0, 0, 0, 1)
threat:SetShadowOffset(1, -1)
end
 
threat:SetTextColor(1, 1, 1)
 
local lastTime = 0
 
frame:SetScript("OnUpdate", function(self, elapsed)
local tankThreat, playerThreat, threatDiff, currentTime, tankName
 
-- For configuring the anchor
if (not locked) then
if (showTank) then
threat:SetText("50%\nSomeTank")
else
threat:SetText("50%")
end
return
end
 
-- Don't update too quickly
currentTime = GetTime()
if ((currentTime - lastTime) < updateTime) then
return
end
 
lastTime = currentTime;
 
-- Clear display if no target
if (not UnitExists("target") or not UnitExists("targettarget")) then
threat:SetText(" ")
return
end
 
-- Don't update if we don't have a pet, are not in a party or raid
if (not UnitExists("pet")) and (not UnitExists("Party1")) and (not UnitExists("Raid1")) then
threat:SetText(" ")
return
end
 
-- Player got aggro
if (hideIfAggro and (UnitIsUnit("player", "targettarget"))) then
threat:SetText(" ")
return
end
 
-- Do the magic
_, _, _, _, playerThreat = UnitDetailedThreatSituation("player", "target")
_, _, _, _, tankThreat = UnitDetailedThreatSituation("targettarget", "target")
 
-- Showing tank name
if (showTank) then
tankName = UnitName("targettarget")
else
tankName = ""
end
 
if (playerThreat and playerThreat > 0 and tankThreat and tankThreat > 0) then
threatDiff = (playerThreat / tankThreat) * 100;
 
if (threatDiff > 130) then
-- We got aggro for sure, don't display anything
threat:SetText(" ")
elseif (threatDiff >= 100) then
threat:SetText((tostring(threatDiff):sub(1,3) .. "%") .. "\n" .. tankName)
elseif (threatDiff >= 10) then
threat:SetText((tostring(threatDiff):sub(1,2) .. "%") .. "\n" .. tankName)
else
threat:SetText((tostring(threatDiff):sub(1,1) .. "%") .. "\n" .. tankName)
end
end
end)
\ No newline at end of file