Add more dungeon-like fortresses.
This commit is contained in:
parent
138858c2a2
commit
5abe211fb6
5 changed files with 288 additions and 188 deletions
79
mapgen.lua
79
mapgen.lua
|
@ -1,6 +1,4 @@
|
|||
local fortress_depth = -1 -- close to y / 80
|
||||
|
||||
|
||||
local max_depth = 31000
|
||||
local seed_noise = {offset = 0, scale = 32768, seed = 5202, spread = {x = 80, y = 80, z = 80}, octaves = 2, persist = 0.4, lacunarity = 2}
|
||||
local fortress_noise = {offset = 0, scale = 1, seed = -4082, spread = {x = 7, y = 7, z = 7}, octaves = 4, persist = 1, lacunarity = 2}
|
||||
|
||||
|
@ -45,41 +43,6 @@ end
|
|||
-- end
|
||||
--end
|
||||
|
||||
fun_caves.is_fortress = function(pos, cs)
|
||||
if not pos then
|
||||
return
|
||||
end
|
||||
|
||||
-- Fix this to get csize, somehow.
|
||||
-- Remember that this function may be called
|
||||
-- before any chunks are generated.
|
||||
|
||||
pos = vector.round(pos)
|
||||
local cs = cs or {x=80, y=80, z=80}
|
||||
local offset = math.floor(cs.y / 2) - 8 + 1
|
||||
|
||||
local y = math.floor((pos.y + offset) / cs.y)
|
||||
|
||||
-- Fortresses show up below ground.
|
||||
if y > fortress_depth then
|
||||
return false
|
||||
end
|
||||
|
||||
local x = math.floor((pos.x + offset) / cs.x)
|
||||
local z = math.floor((pos.z + offset) / cs.z)
|
||||
|
||||
local n = minetest.get_perlin(fortress_noise):get3d({x=x, y=y, z=z})
|
||||
if not (n and type(n) == 'number') then
|
||||
return
|
||||
end
|
||||
|
||||
if math.floor((n * 10000) % 13) == 1 then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
fun_caves.place_schematic = function(minp, maxp, data, p2data, area, node, pos, schem, center)
|
||||
if not (minp and maxp and data and p2data and area and node and pos and schem and type(data) == 'table' and type(p2data) == 'table' and type(schem) == 'table') then
|
||||
return
|
||||
|
@ -365,6 +328,17 @@ fun_caves.cave_biomes = {
|
|||
}
|
||||
|
||||
|
||||
local ground_nodes = {}
|
||||
ground_nodes[minetest.get_content_id('default:stone')] = true
|
||||
ground_nodes[minetest.get_content_id('default:desert_stone')] = true
|
||||
ground_nodes[minetest.get_content_id('default:sandstone')] = true
|
||||
ground_nodes[minetest.get_content_id('default:dirt')] = true
|
||||
ground_nodes[minetest.get_content_id('default:sand')] = true
|
||||
ground_nodes[minetest.get_content_id('default:dirt_with_grass')] = true
|
||||
ground_nodes[minetest.get_content_id('default:dirt_with_snow')] = true
|
||||
ground_nodes[minetest.get_content_id('default:dirt_with_dry_grass')] = true
|
||||
|
||||
|
||||
local function generate(p_minp, p_maxp, seed)
|
||||
if not (p_minp and p_maxp and seed) then
|
||||
return
|
||||
|
@ -410,6 +384,30 @@ local function generate(p_minp, p_maxp, seed)
|
|||
end
|
||||
end
|
||||
|
||||
-- Correct heightmap.
|
||||
local index = 0
|
||||
for z = minp.z, maxp.z do
|
||||
for x = minp.x, maxp.x do
|
||||
index = index + 1
|
||||
|
||||
local height = heightmap[index]
|
||||
if height and height < maxp.y - 1 and height > minp.y then
|
||||
--nop
|
||||
else
|
||||
height = - max_depth
|
||||
local ivm2 = area:index(x, maxp.y + 8, z)
|
||||
for y = maxp.y + 8, minp.y - 8, -1 do
|
||||
if ground_nodes[data[ivm2]] then
|
||||
height = (y < maxp.y + 8) and y or max_depth
|
||||
break
|
||||
end
|
||||
ivm2 = ivm2 - area.ystride
|
||||
end
|
||||
heightmap[index] = height
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local aster = false
|
||||
if minp.y > 17200 then
|
||||
-- nop
|
||||
|
@ -421,12 +419,11 @@ local function generate(p_minp, p_maxp, seed)
|
|||
elseif minp.y > 4000 and fun_caves.cloudgen then
|
||||
write = fun_caves.cloudgen(minp, maxp, data, p2data, area, node)
|
||||
elseif not underzone and fun_caves.is_fortress(minp, csize) and fun_caves.fortress then
|
||||
--if not underzone then
|
||||
fun_caves.fortress(minp, maxp, data, area, node)
|
||||
write = true
|
||||
elseif fun_caves.cavegen and fun_caves.decogen and fun_caves.treegen then
|
||||
local write_cave, write_deco, write_tree, write_pyr, write_vill, h2
|
||||
write_cave, h2 = fun_caves.cavegen(minp, maxp, data, area, node, heightmap, underzone)
|
||||
write_cave, h2 = fun_caves.cavegen(minp, maxp, data, area, node, heightmap, underzone, ground_nodes)
|
||||
if h2 then
|
||||
heightmap = h2
|
||||
end
|
||||
|
@ -455,7 +452,7 @@ local function generate(p_minp, p_maxp, seed)
|
|||
vm:set_param2_data(p2data)
|
||||
end
|
||||
|
||||
if fun_caves.DEBUG then
|
||||
if true or fun_caves.DEBUG then
|
||||
vm:set_lighting({day = 15, night = 15})
|
||||
else
|
||||
-- set_lighting causes lighting artifacts,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue