diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index cf3913af..30955b50 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -2055,34 +2055,29 @@ local do_states = function(self, dtime) -- If mob in or on dangerous block, look for land if is_in_danger then local tab_lp = nil + -- if water breathing, get water blocks around mob position if self.breathes_in_water and self.fly then tab_lp = minetest.find_nodes_in_area({x=s.x-1, y=s.y-1, z=s.z-1}, {x=s.x+1, y=s.y+1, z=s.z+1}, {"group:water"}) + -- if mob is standing in water, it can only escape, if the destination is at water level elseif minetest.get_item_group(self.standing_in, "water") then - tab_lp = minetest.find_nodes_in_area_under_air({x=s.x-1, y=s.y-self.fear_height, z=s.z-1}, {x=s.x+1, y=s.y-1, z=s.z+1}, {"group:solid"}) - elseif not self.jump then tab_lp = minetest.find_nodes_in_area_under_air({x=s.x-1, y=s.y-1, z=s.z-1}, {x=s.x+1, y=s.y-1, z=s.z+1}, {"group:solid"}) + -- if not jumping, destination needs to be on the same level, but we can consider falling down to the destination + elseif not self.jump then + tab_lp = minetest.find_nodes_in_area_under_air({x=s.x-1, y=s.y-self.fear_height, z=s.z-1}, {x=s.x+1, y=s.y-1, z=s.z+1}, {"group:solid"}) + -- otherwise mob can also jump up to its destination else tab_lp = minetest.find_nodes_in_area_under_air({x=s.x-1, y=s.y-self.fear_height, z=s.z-1}, {x=s.x+1, y=s.y+(self.jump_height - 1), z=s.z+1}, {"group:solid"}) end - -- did we find land? + -- did we find land? Iterate over results if #tab_lp >= 1 then for index, lp in ipairs(tab_lp) do local nn = minetest.get_node(lp).name local node_above_ok = false - local y_difference = lp.y - s.y - local y_difference_ok = false - - if y_difference <= 0 then - y_difference_ok = true - elseif (y_difference <= self.jump_height) and not minetest.get_item_group(nn, "water") then - y_difference_ok = true - end - -- is the chosen destination safe and walkable? - if not is_node_dangerous(self, nn) and minetest.registered_nodes[nn].walkable and y_difference_ok then + if not is_node_dangerous(self, nn) and minetest.registered_nodes[nn].walkable then -- check node at y + 2 above local lp_above = {x = lp.x, y = lp.y + 1, z = lp.z} local nn_above = minetest.get_node(lp_above).name