Pathfinder: Make initial drop collide with climb
This commit is contained in:
parent
657a4320a9
commit
09f665614e
@ -115,9 +115,9 @@ end
|
||||
|
||||
-- Simulate falling with a given drop_height limit
|
||||
-- and returns the final node we land *in*
|
||||
local function drop_down(pos, drop_height, nh, get_node)
|
||||
local blocking_or_walkable = function(node)
|
||||
return nh.blocking(node) or nh.walkable(node)
|
||||
local function drop_down(pos, drop_height, stop_at_climb, nh, get_node)
|
||||
local stop = function(node)
|
||||
return nh.blocking(node) or nh.walkable(node) or (stop_at_climb and climbable(node))
|
||||
end
|
||||
local dpos = table.copy(pos)
|
||||
-- Get the first blocking or walkable node below neighbor
|
||||
@ -126,7 +126,7 @@ local function drop_down(pos, drop_height, nh, get_node)
|
||||
-- we need an 1 node offset for the floor (on which we drop on top)
|
||||
drop_height = drop_height + 1
|
||||
|
||||
local floor = vertical_walk(dpos, -1, drop_height, blocking_or_walkable, true, get_node)
|
||||
local floor = vertical_walk(dpos, -1, drop_height, stop, true, get_node)
|
||||
if not floor then
|
||||
return nil
|
||||
end
|
||||
@ -161,7 +161,7 @@ local function get_neighbor_floor_pos(neighbor_pos, current_pos, clear_height, j
|
||||
end
|
||||
-- Drop down
|
||||
if not nh.walkable(nnode) then
|
||||
local floor = drop_down(npos, drop_height, nh, get_node)
|
||||
local floor = drop_down(npos, drop_height, false, nh, get_node)
|
||||
return floor
|
||||
-- Jump
|
||||
else
|
||||
@ -305,7 +305,8 @@ function rp_pathfinder.find_path(pos1, pos2, searchdistance, options, timeout)
|
||||
return nil, "pos1_blocked"
|
||||
end
|
||||
|
||||
pos1 = drop_down(pos1, max_drop, nh, get_node)
|
||||
-- Simulate an initial drop from pos1
|
||||
pos1 = drop_down(pos1, max_drop, climb, nh, get_node)
|
||||
if not pos1 then
|
||||
return nil, "pos1_too_high"
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user