Fix bug where if it finds wrong door and can't plot route it hogs the pathing

This commit is contained in:
ancientmarinerdev 2022-11-03 01:00:48 +00:00
parent ac45dec544
commit ad137304bc
2 changed files with 5 additions and 1 deletions

View File

@ -3409,6 +3409,7 @@ local function calculate_path_through_door (p, t, target)
if not wp then
mcl_log("No direct path. Path through door")
-- This could improve. There could be multiple doors. Check you can path from door to target first.
local cur_door_pos = minetest.find_node_near(target,16,{"group:door"})
if cur_door_pos then
mcl_log("Found a door near: " .. minetest.pos_to_string(cur_door_pos))
@ -3479,6 +3480,8 @@ function mcl_mobs:gopath(self,target,callback_arrived)
local wp = calculate_path_through_door(p, t, target)
if not wp then
mcl_log("Could not calculate path")
self._pf_last_failed = os.time()
-- Cover for a flaw in pathfind where it chooses the wrong door and gets stuck. Take a break, allow others.
end
--output_table(wp)

View File

@ -609,9 +609,10 @@ local function find_closest_unclaimed_block (p, requested_block_types)
for i,n in pairs(nn) do
local m = minetest.get_meta(n)
mcl_log("Block: " .. minetest.pos_to_string(n).. ", owner: ".. m:get_string("villager"))
if m:get_string("villager") == "" then
mcl_log("Block: " .. minetest.pos_to_string(n).. ", owner: ".. m:get_string("villager"))
local distance_to_block = vector.distance(p, n)
mcl_log("Distance to block ".. i .. ": ".. distance_to_block)