Call as
addon.Platform:GetUnitThreatObservation(unit)
Available directly through addon; no dependency is needed.
What it does
Observe ordered selected-unit existence, hostility from player, then the player threat status on that unit. Known absence, nonenemy and a successfully read nil threat status return false, preserving the no-threat predicate. Finite status numbers including zero retain their original comparison meaning. Required missing, failed, nil, restricted or malformed facts return nil with a reason. No attackability, death, combat or vehicle inference is added.
Arguments
| Name | Type | What it does |
|---|---|---|
self | RMPlatform | Rotation Master platform adapter (implicit with colon calls). |
unit | string | Exact unit token used for existence and as the recipient of player hostility and threat queries. |
Returns
| 1 | number | boolean | nil | Finite native threat status, false for known absence/nonenemy/no-threat, or nil for unavailable observations. |
|---|---|---|
| 2 | string | nil | Policy, query-validation or availability reason for a nil threat observation. |
Editions
Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.
- Not available on that edition (the reason is in the tooltip)
- Only while Blizzard's deprecation fallbacks are on
Secret values (Retail and Forever)
On Retail and Forever the game hands addons secret values. This helper checks what it reads (addon.Platform:CanReadValue) and returns nil with a reason such as restricted-value instead of a secret it cannot compare. Treat nil as unavailable, not as false.
Example
local status = addon.Platform:GetUnitThreatObservation("target")
if status == nil then return nil end
-- false means no target, not an enemy, or no threat; 2 and 3 mean you are tanking
return status ~= false and status >= 2Source
Platform/threat.lua, line 19. Read only in game; Duplicate makes an editable copy.
Platform.threat.GetUnitThreatObservation(self, unit)
local policy=self:GetCombatDataPolicy()
if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
if not self:CanReadValue(unit) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if type(UnitExists)~='function' then return nil,'missing-api' end
local existsOk,exists=pcall(UnitExists,unit)
if not existsOk then return nil,'api-error' end
if not self:CanReadValue(exists) then return nil,'restricted-value' end
if exists==nil then return nil,'unit-data-unavailable' end
if type(exists)~='boolean' then return nil,'invalid-api-result' end
if not exists then return false end
if type(UnitIsEnemy)~='function' then return nil,'missing-api' end
local enemyOk,enemy=pcall(UnitIsEnemy,'player',unit)
if not enemyOk then return nil,'api-error' end
if not self:CanReadValue(enemy) then return nil,'restricted-value' end
if enemy==nil then return nil,'unit-data-unavailable' end
if type(enemy)~='boolean' then return nil,'invalid-api-result' end
if not enemy then return false end
if type(UnitThreatSituation)~='function' then return nil,'missing-api' end
local threatOk,threat=pcall(UnitThreatSituation,'player',unit)
if not threatOk then return nil,'api-error' end
if not self:CanReadValue(threat) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(threat) then return nil,'restricted-value' end
if threat==nil then return false end
if type(threat)~='number' or threat~=threat or threat==math.huge or threat==-math.huge then return nil,'invalid-api-result' end
return threat




