Call as
addon.Platform:GetUnitHealthObservation(unit, includeMaximum)
Available directly through addon; no dependency is needed.
What it does
Observe readable current health and optionally maximum health on supported clients. A readable absent unit returns exists=false. Missing, failed, restricted or malformed observations return nil with a reason; they do not establish an absent unit or a health value.
Arguments
| Name | Type | What it does |
|---|---|---|
self | RMPlatform | Rotation Master platform adapter (implicit with colon calls). |
unit | string | Unit token whose current health should be observed. |
includeMaximum | boolean | nil | True also observes maximum health; false or nil reads current health only. |
Returns
| 1 | table | nil | Fresh readable record with exists and, when present, current health. Maximum health is included only when requested. |
|---|---|---|
| 2 | string | nil | Policy, validation or availability reason for a nil health 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 health = addon.Platform:GetUnitHealthObservation("target", true)
if not health then return nil end
if not health.exists then return false end
if health.maximum == 0 then return nil end
return health.current / health.maximum < 0.2Dependencies
finite→Platform.unit_health.finite
Source
Platform/unit_health.lua, line 28. Read only in game; Duplicate makes an editable copy.
Platform.unit_health.GetUnitHealthObservation(self, unit, includeMaximum)
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(includeMaximum) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if includeMaximum~=nil and type(includeMaximum)~='boolean' then return nil,'invalid-health-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 {exists=false} end
if type(UnitHealth)~='function' then return nil,'missing-api' end
local currentOk,current=pcall(UnitHealth,unit)
if not currentOk then return nil,'api-error' end
if not self:CanReadValue(current) then return nil,'restricted-value' end
-- Keep the native proof visible at the arithmetic boundary; the platform
-- guard above also covers older clients and the issecretvalue predicate.
if canaccessvalue and not canaccessvalue(current) then return nil,'restricted-value' end
if current==nil then return nil,'health-data-unavailable' end
if not finite(current) or current<0 then return nil,'invalid-api-result' end
local record={exists=true,current=current}
if includeMaximum then
if type(UnitHealthMax)~='function' then return nil,'missing-api' end
local maximumOk,maximum=pcall(UnitHealthMax,unit)
if not maximumOk then return nil,'api-error' end
if not self:CanReadValue(maximum) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(maximum) then return nil,'restricted-value' end
if maximum==nil then return nil,'health-data-unavailable' end
if not finite(maximum) or maximum<0 then return nil,'invalid-api-result' end
record.maximum=maximum
end
return record




