Get in sight, then cast
For a caster: walk to the nearest spot that sees the target within spell range, then cast.
The short way: move_to_sight
local function get_in_sight(target, on_ready)
local client = _G.AXIOM_NAV and _G.AXIOM_NAV.client
if not client then return end
client:move_to_sight(target:get_position(), function(ok, reason)
if ok then
on_ready() -- "in_sight" (no walk) or arrived at the spot
elseif reason == "no_sight_spot" then
core.log_warning("no spot sees the target")
else
core.log_warning("could not get in sight: " .. tostring(reason))
end
end, { range = 30, min_range = 8, avoid_mobs = true })
endYour own choice: find_sight_spot
When your plugin wants to decide (compare spots, check other things first), ask without walking:
client:find_sight_spot(target:get_position(), function(ok, r)
if not ok or not r.found then return end
if r.already then return cast_now() end
-- r.spot: where to stand, r.walk: the walk there in yards
client:move_to(r.spot, function(arrived) if arrived then cast_now() end end)
end, { range = 30, min_range = 8 })Just checking
local me = core.object_manager.get_local_player():get_position()
client:has_line_of_sight(me, target:get_position(), function(ok, r)
if ok and r.clear then cast_now() end
end)The game server's own rule for spells: buildings, rock and cave walls block; trees, barrels and crates do not. Doors are not in the files.