Reference › Function reference › Conditions

Conditions.spatial.rcf

dependency

Call as

Conditions.spatial.rcf(unit)

Record the dependency Conditions.spatial.rcf, then call it by that name. A namespaced call does not pass self: use a colon call or pass the object yourself.

What it does

Returns the LibRangeCheck-3.0 range estimate for a unit as minimum and maximum yards. It is neither cached nor protected itself; the distance conditions call it through getCached or protectedRead.

Arguments

NameTypeWhat it does
unitstringUnit token, such as "target".

Returns

1number | nilMinimum distance in yards, or nil when no range is known.
2number | nilMaximum distance in yards, or nil when the unit is beyond every checked range or no range is known.

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.

It reads no game API directly.

Example

-- needs the dependency Conditions.spatial.rcf
local ok, minRange, maxRange = pcall(Functions.cache.getCached, cache, Conditions.spatial.rcf, "target")
if not ok or maxRange == nil then return nil, "range-unavailable" end
return maxRange <= 8

Dependencies

Source

Conditions/spatial.lua, line 53. Read only in game; Duplicate makes an editable copy.

Conditions.spatial.rcf(unit)
 return RangeCheck:GetRange(unit)

Back to Function reference