Skip to content

Instantly share code, notes, and snippets.

@xanahopper
Last active July 27, 2020 13:18
Show Gist options
  • Save xanahopper/27d645718cf4cbb932de03d7d51c5de4 to your computer and use it in GitHub Desktop.
Save xanahopper/27d645718cf4cbb932de03d7d51c5de4 to your computer and use it in GitHub Desktop.
function (self, unitId, unitFrame, envTable)
--after editing this script, save it and /reload
Plater.TargetIndicators ["KuiArrow"] = {
path = [[Interface\Addons\Kui_Nameplates_Core\media\target-arrow]],
coords = {
{0, 1, 0, 1},
{1, 0, 0, 1}
},
desaturated = false,
width = 18,
height = 18,
x = 14,
y = 0,
blend = "ADD",
color = "white",
}
--- Threat Indicators ---
local aggroIndicator = {
path = [[Interface\AddOns\Kui_Nameplates_Core\media\threat-bracket]],
coords = {
{0, 1, 0, 1},
{1, 0, 0, 1}
},
width = 18,
height = 9,
x = 18,
y = 0,
blend = "ADD",
color = "red"
}
local originalUpdateNameplateThread = Plater.UpdateNameplateThread
local THREAT_DRAW_LAYER = 7
local tinsert = table.insert
--actor types
local ACTORTYPE_FRIENDLY_PLAYER = "friendlyplayer"
local ACTORTYPE_FRIENDLY_NPC = "friendlynpc"
local ACTORTYPE_ENEMY_PLAYER = "enemyplayer"
local ACTORTYPE_ENEMY_NPC = "enemynpc"
local ACTORTYPE_PLAYER = "player"
local function IsPlayerEffectivelyTank()
local assignedRole = UnitGroupRolesAssigned ("player")
if (assignedRole == "NONE") then
local spec = GetSpecialization()
return spec and GetSpecializationRole (spec) == "TANK"
end
return assignedRole == "TANK"
end
Plater.UpdateNameplateThread = function (unitFrame)
originalUpdateNameplateThread(unitFrame)
--make sure there's a unitID in the unit frame
local healthBar = unitFrame.healthBar
local healthBarHeight = healthBar:GetHeight()
if (not unitFrame.AggroIndicatorFrame) then
unitFrame.AggroIndicatorFrame = {}
local aggroTextures = unitFrame.AggroIndicatorFrame
-- inited aggro textures
if (#aggroTextures == 0) then
for i = 1, 4 do
local aggroTexture = healthBar:CreateTexture (nil, "overlay")
aggroTexture:SetDrawLayer ("overlay", THREAT_DRAW_LAYER)
aggroTexture:SetTexture (aggroIndicator.path)
aggroTexture:SetBlendMode ("ADD")
tinsert(unitFrame.AggroIndicatorFrame, aggroTexture)
end
end
end
local isTanking, threatStatus, threatpct = UnitDetailedThreatSituation ("player", unitFrame.displayedUnit)
threatpct = threatpct or 0
threatStatus = threatStatus or 0
local scale = healthBar:GetHeight()
local scale = healthBarHeight / 10
local playerIsTank = IsPlayerEffectivelyTank()
if (threatStatus > 1) then
for i = 1, 4 do
local texture = unitFrame.AggroIndicatorFrame[i]
texture:Show()
texture:SetSize (12 * scale, 12 * scale)
if (threatStatus == 2) then
texture:SetVertexColor (1, 0.2, 0, 1)
elseif (threatStatus == 3) then
texture:SetVertexColor (1, 0, 0, 1)
end
if (i == 1) then
texture:SetTexCoord (0, 1, 0, 1)
texture:SetPoint ("bottomright", healthBar, "topleft", 0, 0)
elseif (i == 2) then
texture:SetTexCoord (0, 1, 1, 0)
texture:SetPoint ("topright", healthBar, "bottomleft", 0, 0)
elseif (i == 3) then
texture:SetTexCoord (1, 0, 0, 1)
texture:SetPoint ("bottomleft", healthBar, "topright", 0, 0)
elseif (i == 4) then
texture:SetTexCoord (1, 0, 1, 0)
texture:SetPoint ("topleft", healthBar, "bottomright", 0, 0)
end
end
else
for i = 1, 4 do
local texture = unitFrame.AggroIndicatorFrame[i]
texture:Hide()
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment