API UnitInRange

Returns whether a unit is close to the player. local inRange, checkedRange = UnitInRange("unit")

Arguments

 * unit : String (unitId) - unit to query; information is only available for members of the player's group.

Returns

 * inRange : Boolean - true if the unit is within ~40 yards of the player, false otherwise
 * checkedRange : Boolean - true if a range check was actually performed; false if the information about distance to the queried unit is unavailable.