From 09f665614e779b7ced19af768fc0559cdeeab04c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 28 Mar 2024 15:24:48 +0100 Subject: [PATCH] Pathfinder: Make initial drop collide with climb --- mods/rp_pathfinder/init.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mods/rp_pathfinder/init.lua b/mods/rp_pathfinder/init.lua index 164c6fb4..6bfa4487 100644 --- a/mods/rp_pathfinder/init.lua +++ b/mods/rp_pathfinder/init.lua @@ -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