Apply more checks in igloo basement generation

This commit is contained in:
Wuzzy 2019-10-02 22:06:26 +02:00
parent b3e1df7e9b
commit da149d5a58

View File

@ -78,16 +78,23 @@ end
mcl_structures.generate_igloo = function(pos)
-- TODO: Check if we're allowed to destroy nodes
-- FIXME: Some nodes (water, ice) don't get overwritten by ladder
-- FIXME: Nodes at Y=0 don't get overwritten by ladder
-- FIXME: Apply basement height limit in other dimensions
-- TODO: Check if basement generation would not be too obvious
-- TODO: Generate basement with 50% chance only
local success, rotation = mcl_structures.generate_igloo_top(pos)
if success then
local buffer = pos.y - (mcl_vars.mg_lava_overworld_max + 10)
local dim = mcl_worlds.pos_to_dimension(pos)
buffer = pos.y - (mcl_vars.mg_lava_overworld_max + 10)
if dim == "nether" then
buffer = pos.y - (mcl_vars.mg_lava_nether_max + 10)
elseif dim == "end" then
buffer = pos.y - (mcl_vars.mg_end_min + 1)
elseif dim == "overworld" then
buffer = pos.y - (mcl_vars.mg_lava_overworld_max + 10)
else
return success
end
if buffer <= 19 then
return
return success
end
local depth = math.random(19, buffer)
local bpos = {x=pos.x, y=pos.y-depth, z=pos.z}
@ -113,8 +120,6 @@ mcl_structures.generate_igloo = function(pos)
else
return success
end
-- TODO: more reliable param2
minetest.set_node(tpos, {name="mcl_doors:trapdoor", param2=20+minetest.dir_to_facedir(dir)})
local set_brick = function(pos)
local c = math.random(1, 3) -- cracked chance
local m = math.random(1, 10) -- chance for monster egg
@ -135,14 +140,26 @@ mcl_structures.generate_igloo = function(pos)
minetest.set_node(pos, {name=brick})
end
local ladder_param2 = minetest.dir_to_wallmounted(tdir)
local real_depth = 0
for y=1, depth-5 do
real_depth = real_depth + 1
local node = minetest.get_node({x=tpos.x,y=tpos.y-y,z=tpos.z})
local def = minetest.registered_nodes[node.name]
if (not def) or (not def.walkable) or (def.liquidtype ~= "none") then
bpos.y = tpos.y-y-4
break
end
set_brick({x=tpos.x-1,y=tpos.y-y,z=tpos.z })
set_brick({x=tpos.x+1,y=tpos.y-y,z=tpos.z })
set_brick({x=tpos.x ,y=tpos.y-y,z=tpos.z-1})
set_brick({x=tpos.x ,y=tpos.y-y,z=tpos.z+1})
minetest.set_node({x=tpos.x,y=tpos.y-y,z=tpos.z}, {name="mcl_core:ladder", param2=ladder_param2})
end
mcl_structures.generate_igloo_basement(bpos, rotation)
if real_depth > 1 then
-- TODO: more reliable param2
minetest.set_node(tpos, {name="mcl_doors:trapdoor", param2=20+minetest.dir_to_facedir(dir)})
mcl_structures.generate_igloo_basement(bpos, rotation)
end
end
return success
end