Call as
addon.Platform:GetUnitAttackabilityObservation(unit)
Available directly through addon; no dependency is needed.
What it does
Observe whether the player can attack a selected unit that is not dead, using the exact UnitExists, UnitCanAttack and UnitIsDead predicates. Known absence or a readable false attack result returns false without querying death. Required missing, failed, restricted or malformed observations return nil with a reason. This does not test ghosts, range, hostility or ability usability, and does not redirect unit ownership.
Arguments
| Name | Type | What it does |
|---|---|---|
self | RMPlatform | Rotation Master platform adapter (implicit with colon calls). |
unit | string | Exact selected unit token; the attacker remains player. |
Returns
| 1 | boolean | nil | True for a readable attackable non-dead unit, false for a conclusive negative result, or nil when a required observation is unavailable. |
|---|---|---|
| 2 | string | nil | Policy, query-validation or availability reason for nil attackability. |
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 | |||||
|---|---|---|---|---|---|
UnitCanAttack | |||||
UnitExists | |||||
UnitIsDead |
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 attackable = addon.Platform:GetUnitAttackabilityObservation("target")
if attackable == nil then return nil end
return attackableDependencies
readClientPolicy(builtin:Platform/unit_attackability.lua:readClientPolicy)
Source
Platform/unit_attackability.lua, line 38. Read only in game; Duplicate makes an editable copy.
Platform.unit_attackability.GetUnitAttackabilityObservation(self, unit)
local policy=readClientPolicy(self)
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(UnitCanAttack)~='function' then return nil,'missing-api' end
local attackOk,attack=pcall(UnitCanAttack,'player',unit)
if not attackOk then return nil,'api-error' end
if not self:CanReadValue(attack) then return nil,'restricted-value' end
if attack==nil then return nil,'attackability-data-unavailable' end
if type(attack)~='boolean' then return nil,'invalid-api-result' end
if not attack then return false end
if type(UnitIsDead)~='function' then return nil,'missing-api' end
local deadOk,dead=pcall(UnitIsDead,unit)
if not deadOk then return nil,'api-error' end
if not self:CanReadValue(dead) then return nil,'restricted-value' end
if dead==nil then return nil,'death-data-unavailable' end
if type(dead)~='boolean' then return nil,'invalid-api-result' end
return not dead




