→ WoW API
Returns whether a given spell is in range.
inRange = IsSpellInRange("spellName", "target") inRange = IsSpellInRange(index, "bookType", "target")
- Number - spell book slot index, ascending from 1.
- String - one of BOOKTYPE_SPELL ("spell") or BOOKTYPE_PET ("pet") specifying which spellbook to index.
- String - spell name to check the range of. The player must know the spell.
- String - unit to use as a target for the spell.
- Flag - 1 if the target is in range of the spell, 0 if the target is not in range of the spell, nil if the provided arguments were invalid or inapplicable.
local inRange, unit = 0, "party1" if UnitExists(unit) and UnitIsVisible(unit) and UnitIsFriend(unit) then inRange = IsSpellInRange("Heal", unit) end if inRange==1 then print("party1 is in healing range!") else print("Cannot heal party1") end
- This takes into account talents, and can be used to determine the approximate distance to your raid members.
- The function returns nil if:
- The spell cannot be cast on the unit. i.e. on a friendly unit, or on an hostile unit (such as a mind-controlled raid member)
- If the unit is not 'visible' (per UnitIsVisible) or does not exist (per UnitExists)
- The current player does not know this spell (so you cannot use 'Heal' to test 40 yard range for anyone other than a priest)
- The spell can only be cast on the player (i.e. a self-buff such as or )