Allow use of most mapgens. Add some dungeon variety.

This commit is contained in:
Duane 2016-06-23 20:21:38 -05:00
parent 1aebdf3b47
commit 3e3e0c17d6
11 changed files with 280 additions and 211 deletions

View file

@ -12,6 +12,10 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone)
local map_max = {x = csize.x, y = csize.y + 2, z = csize.z}
local map_min = {x = minp.x, y = minp.y - 1, z = minp.z}
if not heightmap then
heightmap = {}
end
local cave_1 = minetest.get_perlin_map(fun_caves.cave_noise_1, map_max):get3dMap_flat(map_min)
local cave_2 = minetest.get_perlin_map(fun_caves.cave_noise_2, map_max):get3dMap_flat(map_min)
local cave_3 = minetest.get_perlin_map(cave_noise_3, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp.x, y=minp.z})
@ -29,11 +33,18 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone)
local ivm = area:index(x, minp.y-1, z)
local height = heightmap[index]
if height >= maxp.y - 1 and data[area:index(x, maxp.y, z)] ~= node['air'] then
height = max_depth
heightmap[index] = height
elseif height <= minp.y then
height = -max_depth
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 data[ivm2] ~= node['air'] and data[ivm2] ~= node['ignore'] then
height = (y < maxp.y + 8) and y or max_depth
break
end
ivm2 = ivm2 - area.ystride
end
heightmap[index] = height
end
@ -92,5 +103,5 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone)
end
end
return write
return write, heightmap
end