improved detection of places to stand

This commit is contained in:
Sokomine 2018-06-24 16:02:17 +02:00
parent 0277d88bc5
commit 61d0f00216
2 changed files with 19 additions and 3 deletions

View File

@ -339,9 +339,9 @@ mob_world_interaction.find_nearest_front_door = function( building_data, pos_ins
-- the last "2" indicates "is bed"
path_lists[ i ][ 1 ] = {pos.x, pos.y, pos.z, 2 };
-- param2 is imoprtant for locating the corresponding bed foot
local node = mob_world_interaction.get_node( pos, building_data );
path_lists[ i ][ 1 ][ 5 ] = node.param2;
for j=1,math.min(#path, front_door_index+1) do
local node = mob_world_interaction.get_node( pos, building_data );
path_lists[ i ][ 1 ][ 5 ] = node.param2;
for j=1,math.min(#path, front_door_index+1) do
local is_door = 0;
if( path[j].is_door ) then
is_door = 1;

View File

@ -25,6 +25,22 @@ mob_world_interaction.can_stand_in_node_type = function( node )
if( not( node ) or not( node.name ) or not( minetest.registered_nodes[ node.name ])) then
return false;
end
-- node where the head of the mob is
local node_head = mob_world_interaction.get_node( {x=pos.x, y=pos.y+1, z=pos.z}, data);
-- node below the feet of the mob where he stands on
local n0 = mob_world_interaction.get_node( {x=pos.x, y=pos.y-1, z=pos.z}, data);
--print("standing: "..minetest.pos_to_string( pos ).." nodes: "..tostring( n0.name).." "..tostring(n1.name).." "..tostring(n2.name));
-- can the mob stand at this position? then we are finished
if( n1 and not( mob_world_interaction.walkable( n1, 1, 2 )) -- free space for feet
and n2 and not( mob_world_interaction.walkable( n2, 2, 2 )) -- free space for head
and n0 and ( mob_world_interaction.walkable( n0, 1, 2 ) -- ground for feet to stand on
or mob_world_interaction.climbable( n0 ))) then -- or a ladder
--print("found!");
return {x=pos.x, y=pos.y, z =pos.z, iteration=iteration};
end
--[[
-- maybe there is a convenient place one node lower
end