Call as
addon.Platform:GetSpellRangeState(id, unit, bank)
Available directly through addon; no dependency is needed.
What it does
Read spell-specific range for a unit using the appropriate client API or spell-book slot. A spell without a range restriction returns applicable=false; otherwise applicable=true and inRange records whether the unit is in range. Unknown or inaccessible observations return nil with a reason.
Arguments
| Name | Type | What it does |
|---|---|---|
self | RMPlatform | Rotation Master platform adapter. A dot reference requires addon.Platform as the first argument; a colon call supplies it implicitly. |
id | number | Spell ID whose range should be checked. |
unit | string | nil | Unit token, such as target; nil uses target. |
bank | string | Spell-book scope: spell, pet or any. |
Returns
| 1 | table | nil | Range record with applicable and, when applicable, inRange; nil when unavailable. |
|---|---|---|
| 2 | string | nil | Availability or validation reason when the record is nil. |
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 record = addon.Platform:GetSpellRangeState(value.spell, "target", "any")
if not record then return nil end
-- A spell with no range restriction can always reach the target.
return not record.applicable or record.inRangeDependencies
call→Platform.actions.callfindSlot→Platform.actions.findSlotrangeIn(builtin:Platform/actions.lua:rangeIn)rangeNotApplicable(builtin:Platform/actions.lua:rangeNotApplicable)rangeOut(builtin:Platform/actions.lua:rangeOut)spellID→Platform.actions.spellID
Source
Platform/actions.lua, line 120. Read only in game; Duplicate makes an editable copy.
Platform.actions.GetSpellRangeState(self, id, unit, bank)
local valid,reason=spellID(id)
if not valid then return nil,reason end
if not self:CanReadValue(unit) or not self:CanReadValue(bank) then return nil,"restricted-value" end
if unit~=nil and (type(unit)~="string" or unit=="") then return nil,"invalid-unit" end
if bank~="spell" and bank~="pet" and bank~="any" then return nil,"invalid-spell-bank" end
unit=unit or "target"
local nativeRange=C_Spell and C_Spell.IsSpellInRange
local nativeShape=C_Spell and C_Spell.SpellHasRange
local slot,book,slotReason
local hasRange,why,queriedShape
if type(nativeShape)=="function" then
queriedShape=true
hasRange,why=call(nativeShape,id)
elseif type(nativeRange)~="function" and type(SpellHasRange)=="function" then
if not slot then slot,book,slotReason=findSlot(id,bank) end
if not slot then return nil,slotReason end
queriedShape=true
hasRange,why=call(SpellHasRange,slot,book)
end
if why then return nil,why end
if hasRange~=nil then
if type(hasRange)~="boolean" then return nil,"invalid-api-result" end
if not hasRange then return rangeNotApplicable end
elseif queriedShape then return nil,"invalid-api-result" end
local inRange
if type(nativeRange)=="function" then
inRange,why=call(nativeRange,id,unit)
if why then return nil,why end
if inRange~=nil and type(inRange)~="boolean" then return nil,"invalid-api-result" end
else
if type(IsSpellInRange)~="function" then return nil,"missing-api" end
if not slot then slot,book,slotReason=findSlot(id,bank) end
if not slot then return nil,slotReason end
inRange,why=call(IsSpellInRange,slot,book,unit)
if why then return nil,why end
if inRange==0 then inRange=false elseif inRange==1 then inRange=true end
if inRange~=nil and type(inRange)~="boolean" then return nil,"invalid-api-result" end
end
if inRange==nil then return nil,"invalid-range-check" end
return inRange and rangeIn or rangeOut




