Fix bug where if it finds wrong door and can't plot route it hogs the pathing
This commit is contained in:
parent
ac45dec544
commit
ad137304bc
|
@ -3409,6 +3409,7 @@ local function calculate_path_through_door (p, t, target)
|
||||||
if not wp then
|
if not wp then
|
||||||
mcl_log("No direct path. Path through door")
|
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"})
|
local cur_door_pos = minetest.find_node_near(target,16,{"group:door"})
|
||||||
if cur_door_pos then
|
if cur_door_pos then
|
||||||
mcl_log("Found a door near: " .. minetest.pos_to_string(cur_door_pos))
|
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)
|
local wp = calculate_path_through_door(p, t, target)
|
||||||
if not wp then
|
if not wp then
|
||||||
mcl_log("Could not calculate path")
|
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
|
end
|
||||||
--output_table(wp)
|
--output_table(wp)
|
||||||
|
|
||||||
|
|
|
@ -609,9 +609,10 @@ local function find_closest_unclaimed_block (p, requested_block_types)
|
||||||
|
|
||||||
for i,n in pairs(nn) do
|
for i,n in pairs(nn) do
|
||||||
local m = minetest.get_meta(n)
|
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
|
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)
|
local distance_to_block = vector.distance(p, n)
|
||||||
mcl_log("Distance to block ".. i .. ": ".. distance_to_block)
|
mcl_log("Distance to block ".. i .. ": ".. distance_to_block)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user