Call as
addon.Platform:GetUnitFlagObservation(unit, kind)
Available directly through addon; no dependency is needed.
What it does
Observe one current unit flag: combat uses UnitAffectingCombat, enemy uses UnitIsEnemy with player as the first unit, and pvp uses UnitIsPVP. A readable absent unit returns false without querying the flag. Required missing, failed, restricted or malformed observations return nil with a reason. This preserves the exact selected unit and does not infer friendliness, attackability or other unit states.
Arguments
| Name | Type | What it does |
|---|---|---|
self | RMPlatform | Rotation Master platform adapter (implicit with colon calls). |
unit | string | Exact unit token whose selected flag should be observed. |
kind | string | One of combat, enemy or pvp; other flag kinds are not supported. |
Returns
| 1 | boolean | nil | Readable selected flag, false for a known absent unit, or nil when a required observation is unavailable. |
|---|---|---|
| 2 | string | nil | Policy, query-validation or availability reason for a nil unit flag. |
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 inCombat = addon.Platform:GetUnitFlagObservation("target", "combat")
local enemy = addon.Platform:GetUnitFlagObservation("target", "enemy")
if inCombat == nil or enemy == nil then return nil end
return enemy and not inCombatDependencies
readClientPolicy(builtin:Platform/unit_flags.lua:readClientPolicy)
Source
Platform/unit_flags.lua, line 39. Read only in game; Duplicate makes an editable copy.
Platform.unit_flags.GetUnitFlagObservation(self, unit, kind)
local policy=readClientPolicy(self)
if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
if not self:CanReadValue(unit) or not self:CanReadValue(kind) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if kind~='combat' and kind~='enemy' and kind~='pvp' then return nil,'invalid-unit-flag-query' 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
local api
if kind=='combat' then api=UnitAffectingCombat
elseif kind=='enemy' then api=UnitIsEnemy
else api=UnitIsPVP end
if type(api)~='function' then return nil,'missing-api' end
local ok,result
if kind=='enemy' then ok,result=pcall(api,'player',unit)
else ok,result=pcall(api,unit) end
if not ok then return nil,'api-error' end
if not self:CanReadValue(result) then return nil,'restricted-value' end
if result==nil then return nil,'unit-flag-unavailable' end
if type(result)~='boolean' then return nil,'invalid-api-result' end
return result




