Call as
addon.Platform:GetUnitStateObservation(unit, kind)
Available directly through addon; no dependency is needed.
What it does
Observe death or ghost state, or friendliness to the player, for the exact selected unit on probe- and restricted-policy clients. A missing, failed, restricted or malformed required observation is unavailable. Unit absence is unavailable rather than a negative match, including under NOT. No cross-poll state is retained.
Arguments
| Name | Type | What it does |
|---|---|---|
self | RMPlatform | Rotation Master platform adapter (implicit with colon calls). |
unit | string | Exact nonempty unit token to observe. |
kind | string | Exactly dead for UnitIsDeadOrGhost, or friendly for UnitIsFriend(player, unit). |
Returns
| 1 | boolean | nil | Readable current state, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Availability or query-validation reason when no current state can be read. |
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
| Game API | |||||
|---|---|---|---|---|---|
UnitExists | |||||
UnitIsDeadOrGhost | |||||
UnitIsFriend |
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 friendly = addon.Platform:GetUnitStateObservation("target", "friendly")
local dead = addon.Platform:GetUnitStateObservation("target", "dead")
if friendly == nil or dead == nil then return nil end
return friendly and dead -- a friend to resurrectSource
Platform/unit_states.lua, line 21. Read only in game; Duplicate makes an editable copy.
Platform.unit_states.GetUnitStateObservation(self, unit, kind)
local policy=self:GetCombatDataPolicy()
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~='dead' and kind~='friendly' then return nil,'invalid-unit-state-query' end
local existsAPI=UnitExists
if type(existsAPI)~='function' then return nil,'missing-api' end
local existsOK,exists=pcall(existsAPI,unit)
if not existsOK then return nil,'api-error' end
if not self:CanReadValue(exists) then return nil,'restricted-value' end
if exists==nil or exists==false then return nil,'unit-data-unavailable' end
if type(exists)~='boolean' then return nil,'invalid-api-result' end
local api
if kind=='dead' then api=UnitIsDeadOrGhost else api=UnitIsFriend end
if type(api)~='function' then return nil,'missing-api' end
local ok,result
if kind=='friendly' 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-state-unavailable' end
if type(result)~='boolean' then return nil,'invalid-api-result' end
return result




