Quantcast

this should finally fix random aggro numbers on nameplates

Darthpred [08-03-16 - 04:14]
this should finally fix random aggro numbers on nameplates
Filename
ElvUI_SLE/modules/nameplates.lua
diff --git a/ElvUI_SLE/modules/nameplates.lua b/ElvUI_SLE/modules/nameplates.lua
index 4f545b9..f04550e 100644
--- a/ElvUI_SLE/modules/nameplates.lua
+++ b/ElvUI_SLE/modules/nameplates.lua
@@ -52,7 +52,7 @@ hooksecurefunc(NP, 'Update_ThreatList', function(self, myPlate)
 			if unit and not T.UnitIsPlayer(unit) and T.UnitCanAttack('player', unit) then
 				local status, percent = T.select(2, T.UnitDetailedThreatSituation('player', unit))
 				if (status) then
-					myPlate.threatInfo:SetFormattedText('%s%.0f%%|r', Hex(T.GetThreatStatusColor(status)), percent)
+					myPlate.threatInfo:SetFormattedText('%s%.0f%%|r', Hex(T.GetThreatStatusColor(status)), percent or "")
 				end
 			end
 		end
@@ -116,12 +116,19 @@ function N:StartRosterUpdate()
 	end
 end

+function N:NAME_PLATE_UNIT_REMOVED(event, unit, frame, ...)
+	local frame = frame or NP:GetNamePlateForUnit(unit);
+	frame.UnitFrame.unit = nil
+	frame.UnitFrame.threatInfo:SetText("")
+end
+
 function N:Initialize()
 	if not SLE.initialized or not E.private.nameplates.enable then return end
 	if E.db.sle.nameplate then E.db.sle.nameplates = E.db.sle.nameplate; E.db.sle.nameplate = nil end
 	N.db = E.db.sle.nameplates
 	self:RegisterEvent("GROUP_ROSTER_UPDATE", "StartRosterUpdate")
 	self:RegisterEvent("UNIT_TARGET", "UpdateCount")
+	self:RegisterEvent("NAME_PLATE_UNIT_REMOVED")

 	E:Delay(.3, function() N:UpdateCount(nil,"player", true) end)
 	function N:ForUpdateAll()