View Single Post
03-08-14, 08:06 AM   #5
Oppugno
A Fallenroot Satyr
Join Date: Sep 2012
Posts: 22
So two hours later the website is stable enough so I can finally post:

As far as I'm aware it is unfeasible to get accurate threat information for nameplates other than from the supplied threat region on the nameplate(s). This is because the methods for determining threat (UnitThreatSituation, UnitDetailedThreatSituation) require a unitID (for both the threater and threatee). Because nameplates inherently don't have unitIDs linked to them and although it would be possible to match unitIDs to nameplates in a limited scope it's just not feasible as a threat indicator on a large scale.

The practical way to guarantee known threat on nameplates is to use the provided threat region on them.

If you want a simple solution to your answer replace lines 132-141 in Threat with this:
Lua Code:
  1. for _, plate in pairs(caelUI.plates) do
  2.     if plate:Visible() -- This won't be neccessary if the table only contains active nameplates
  3.         if plate.healthBar.oldGlow:IsShown() then
  4.             local r, g, b = plate.healthBar.oldGlow:GetVertexColor()
  5.            
  6.             -- 0 - Unit has less than 100% raw threat (default UI shows no indicator)
  7.             -- 1 - Unit has 100% or higher raw threat but isn't mobUnit's primary target (default UI shows yellow indicator)
  8.             -- 2 - Unit is mobUnit's primary target, and another unit has 100% or higher raw threat (default UI shows orange indicator)
  9.             -- 3 - Unit is mobUnit's primary target, and no other unit has 100% or higher raw threat (default UI shows red indicator)
  10.             -- You can get the colours from GetThreatStatusColor(#)
  11.             local status = (g + b == 0 and 3) or (b == 0 and 2) or 1
  12.            
  13.             plate.healthBar.hpGlow:SetBackdropBorderColor(unpack(aggroColors[playerIsTank][status]))
  14.         else
  15.             plate.healthBar.npGlow:SetBackdropBorderColor(0, 0, 0)
  16.         end
  17.     end
  18. end
However, I'm not certain nameplates update for events as immediately as standard frames (I've seen 0.5s + delays) so your threat update events will probably trigger before the new threat colours show up on the nameplates.

Personally, the way I do it is as you've done previously, with an OnUpdate script. However, I use a single OnUpdate script and a table for tracking currently visible nameplates. It will benefit from less CPU time and less memory usage (compared to giving each nameplate it's own OnUpdate script).

Last edited by Oppugno : 03-08-14 at 08:19 AM. Reason: Clarified some stuff.
  Reply With Quote