Stricter dirt room spawn requirements
parent
2c9658b805
commit
1ef1b305e5
40
init.lua
40
init.lua
|
@ -936,21 +936,29 @@ end
|
||||||
-- main_cave_coords is the center of the floor of the dirt room, from which
|
-- main_cave_coords is the center of the floor of the dirt room, from which
|
||||||
-- all corridors expand.
|
-- all corridors expand.
|
||||||
local function create_corridor_system(main_cave_coords)
|
local function create_corridor_system(main_cave_coords)
|
||||||
--[[ Start building in the ground. Prevents corridors starting
|
|
||||||
in mid-air or in liquids. ]]
|
-- Dirt room size
|
||||||
if not IsGround(main_cave_coords) then
|
local size = pr:next(3, 9)
|
||||||
return false
|
|
||||||
|
--[[ Only build if starter coords are in the ground.
|
||||||
|
Prevents corridors starting in mid-air or in liquids. ]]
|
||||||
|
local check_coords = {
|
||||||
|
-- Center of the room, on the floor
|
||||||
|
{x=0,y=0,z=0},
|
||||||
|
-- Also check near the 4 bottom corners of the dirt room
|
||||||
|
{x= size-1, y=0, z=size-1},
|
||||||
|
{x=-size+1, y=0, z=size-1},
|
||||||
|
{x= size-1, y=0, z=-size+1},
|
||||||
|
{x=-size+1, y=0, z=-size+1},
|
||||||
|
}
|
||||||
|
for c=1, #check_coords do
|
||||||
|
if not IsGround(vector.add(main_cave_coords, check_coords[c])) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local center_node = minetest.get_node(main_cave_coords)
|
local center_node = minetest.get_node(main_cave_coords)
|
||||||
|
|
||||||
-- Determine if this corridor system is “damaged” (some rails removed) and to which extent
|
|
||||||
local damage = 0
|
|
||||||
if pr:next() < probability_damage then
|
|
||||||
damage = pr:next(10, 50)
|
|
||||||
end
|
|
||||||
--[[ Starter cube: A big hollow dirt cube from which the corridors will extend.
|
|
||||||
Corridor generation starts here. ]]
|
|
||||||
local size = pr:next(3, 9)
|
|
||||||
local height = pr:next(4, 7)
|
local height = pr:next(4, 7)
|
||||||
if height > size then
|
if height > size then
|
||||||
height = size
|
height = size
|
||||||
|
@ -961,9 +969,17 @@ local function create_corridor_system(main_cave_coords)
|
||||||
end
|
end
|
||||||
local dirt_mode = pr:next(1,2)
|
local dirt_mode = pr:next(1,2)
|
||||||
|
|
||||||
|
--[[ Starting point: A big hollow dirt cube from which the corridors will extend.
|
||||||
|
Corridor generation starts here. ]]
|
||||||
DirtRoom(main_cave_coords, size, height, dirt_mode)
|
DirtRoom(main_cave_coords, size, height, dirt_mode)
|
||||||
main_cave_coords.y = main_cave_coords.y + 2 + floor_diff
|
main_cave_coords.y = main_cave_coords.y + 2 + floor_diff
|
||||||
|
|
||||||
|
-- Determine if this corridor system is “damaged” (some rails removed) and to which extent
|
||||||
|
local damage = 0
|
||||||
|
if pr:next() < probability_damage then
|
||||||
|
damage = pr:next(10, 50)
|
||||||
|
end
|
||||||
|
|
||||||
-- Get wood and fence post types, using gameconfig.
|
-- Get wood and fence post types, using gameconfig.
|
||||||
|
|
||||||
local wood, post
|
local wood, post
|
||||||
|
|
Loading…
Reference in New Issue