Clean up underzones.
This commit is contained in:
parent
10bb057f61
commit
e447a3f506
3 changed files with 139 additions and 79 deletions
52
cavegen.lua
52
cavegen.lua
|
@ -22,9 +22,6 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone)
|
|||
|
||||
local write = false
|
||||
|
||||
-- 32, -41, 123
|
||||
|
||||
|
||||
local index = 0
|
||||
local index3d = 0
|
||||
for z = minp.z, maxp.z do
|
||||
|
@ -53,49 +50,32 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone)
|
|||
end
|
||||
|
||||
for y = minp.y-1, maxp.y+1 do
|
||||
-- Dis
|
||||
if underzone == 6 and y % 4960 < cave_3[index] + 160 and y % 4960 > cave_3[index] + 80 then
|
||||
if y < -29620 then
|
||||
if underzone and underzone.regular_columns and (x - minp.x) < 8 and (z - minp.z) < 8 then
|
||||
data[ivm] = node[underzone.column_node]
|
||||
write = true
|
||||
elseif underzone and underzone.column_node and not underzone.regular_columns and column == 2 then
|
||||
if underzone.column_node_rare and rand(70) == 1 then
|
||||
data[ivm] = node[underzone.column_node_rare]
|
||||
else
|
||||
data[ivm] = node[underzone.column_node]
|
||||
end
|
||||
write = true
|
||||
elseif underzone and (y < underzone.ceiling - (underzone.vary and cave_3[index] or 0) and y > underzone.floor + (underzone.vary and cave_3[index] or 0)) then
|
||||
if underzone.sealevel and y <= underzone.sealevel then
|
||||
data[ivm] = node["default:water_source"]
|
||||
else
|
||||
data[ivm] = node["air"]
|
||||
end
|
||||
write = true
|
||||
elseif underzone == 3 then
|
||||
if (x - minp.x) < 8 and (z - minp.z) < 8 then
|
||||
data[ivm] = node["default:steelblock"]
|
||||
elseif data[ivm] ~= node['air'] and y % 4960 < 160 and y % 4960 > 80 then
|
||||
data[ivm] = node["air"]
|
||||
end
|
||||
write = true
|
||||
-- Caina
|
||||
elseif column == 2 and underzone == 1 and (data[ivm] == node['default:stone'] or data[ivm] == node['default:desert_stone']) then
|
||||
if rand(70) == 1 then
|
||||
data[ivm] = node["fun_caves:thin_ice"]
|
||||
else
|
||||
data[ivm] = node["default:ice"]
|
||||
end
|
||||
write = true
|
||||
-- Phlegethos
|
||||
elseif column == 2 and (data[ivm] == node['default:stone'] or data[ivm] == node['default:desert_stone']) and rand(70) == 1 then
|
||||
data[ivm] = node["fun_caves:hot_stone"]
|
||||
write = true
|
||||
-- Dis
|
||||
elseif column == 1 and underzone ~= 3 and data[ivm] ~= node['air'] and y % 4960 < cave_3[index] + 160 and y % 4960 > cave_3[index] + 80 then
|
||||
if y < -29620 then
|
||||
elseif underzone and (y < underzone.ceiling + 10 - (underzone.vary and cave_3[index] or 0) and y > underzone.floor - 10 + (underzone.vary and cave_3[index] or 0)) then
|
||||
-- nop
|
||||
elseif y < height - cave_3[index] and cave_1[index3d] * cave_2[index3d] > cave_width then
|
||||
if y <= fun_caves.underzones['Styx'].sealevel then
|
||||
data[ivm] = node["default:water_source"]
|
||||
else
|
||||
data[ivm] = node["air"]
|
||||
end
|
||||
write = true
|
||||
elseif column < 2 and underzone ~= 3 and data[ivm] ~= node['air'] and y < height - cave_3[index] and cave_1[index3d] * cave_2[index3d] > cave_width then
|
||||
if y < -29620 then
|
||||
data[ivm] = node["default:water_source"]
|
||||
else
|
||||
data[ivm] = node["air"]
|
||||
end
|
||||
write = true
|
||||
|
||||
if y > 0 and cave_3[index] < 1 and y == height then
|
||||
-- Clear the air above a cave mouth.
|
||||
local ivm2 = ivm
|
||||
|
|
72
decogen.lua
72
decogen.lua
|
@ -117,6 +117,21 @@ fun_caves.decogen = function(minp, maxp, data, p2data, area, node, heightmap, bi
|
|||
local biome_n = minetest.get_perlin_map(biome_noise, map_max):get3dMap_flat(map_min)
|
||||
local plant_n = minetest.get_perlin_map(plant_noise, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp.x, y=minp.z})
|
||||
|
||||
local dis_map = {}
|
||||
if underzone and underzone.name == 'Dis' then
|
||||
for i = 0, 10, 2 do
|
||||
dis_map[i] = {}
|
||||
for j = 0, 10, 2 do
|
||||
dis_map[i][j] = rand(6)
|
||||
if dis_map[i][j] == 6 then
|
||||
dis_map[i][j] = 5 + rand(10)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local undersea = fun_caves.underzones['Styx'].sealevel
|
||||
|
||||
local write = false
|
||||
local write_p2 = false
|
||||
|
||||
|
@ -153,25 +168,11 @@ fun_caves.decogen = function(minp, maxp, data, p2data, area, node, heightmap, bi
|
|||
-------------------
|
||||
--biome_val = -0.75
|
||||
-------------------
|
||||
if underzone == 1 then
|
||||
stone_type = node["default:ice"]
|
||||
if underzone and y < (underzone.ceiling + underzone.floor) / 2 then
|
||||
stone_type = node[underzone.floor_node]
|
||||
stone_depth = 2
|
||||
elseif underzone == 3 then
|
||||
stone_type = node["fun_caves:hot_brass"]
|
||||
stone_depth = 1
|
||||
elseif underzone == 4 and y % 4960 <= 145 then
|
||||
stone_type = node["fun_caves:polluted_dirt"]
|
||||
stone_depth = 2
|
||||
elseif underzone == 4 and y % 4960 > 145 then
|
||||
stone_type = node["fun_caves:black_sand"]
|
||||
stone_depth = 2
|
||||
elseif underzone == 6 then
|
||||
stone_type = node["default:dirt"]
|
||||
stone_depth = 2
|
||||
elseif underzone and y % 4960 <= 145 then
|
||||
stone_type = node["fun_caves:hot_cobble"]
|
||||
elseif underzone and y % 4960 > 145 then
|
||||
stone_type = node["fun_caves:black_sand"]
|
||||
elseif underzone then
|
||||
stone_type = node[underzone.ceiling_node]
|
||||
stone_depth = 2
|
||||
elseif biome_val < -0.65 then
|
||||
stone_type = node["default:ice"]
|
||||
|
@ -187,7 +188,7 @@ fun_caves.decogen = function(minp, maxp, data, p2data, area, node, heightmap, bi
|
|||
stone_type = node["fun_caves:stone_with_lichen"]
|
||||
elseif biome_val < 0.2 then
|
||||
stone_type = node["fun_caves:stone_with_algae"]
|
||||
elseif y < 29620 then
|
||||
elseif y <= undersea then
|
||||
-- This is seperate to prevent the hot biomes spawning underwater.
|
||||
stone_type = node["default:dirt"]
|
||||
stone_depth = 2
|
||||
|
@ -211,10 +212,20 @@ fun_caves.decogen = function(minp, maxp, data, p2data, area, node, heightmap, bi
|
|||
end
|
||||
local node_above = data[ivm + area.ystride]
|
||||
|
||||
if underzone and underzone.name == 'Minauros' and y < underzone.floor + 10 and data[ivm] == node['air'] then
|
||||
data[ivm] = node["fun_caves:water_poison_source"]
|
||||
write = true
|
||||
break
|
||||
elseif underzone and underzone.name == 'Phlegethos' and y < underzone.floor + 5 and data[ivm] == node['air'] then
|
||||
data[ivm] = node["default:lava_source"]
|
||||
write = true
|
||||
break
|
||||
end
|
||||
|
||||
if data[ivm] == node["default:stone"] then
|
||||
local air_above = false
|
||||
for i = 1, stone_depth do
|
||||
if data[ivm + area.ystride * i] == node["air"] or (y < 29620 and data[ivm + area.ystride * i] == node["default:water_source"]) then
|
||||
if data[ivm + area.ystride * i] == node["air"] or (y < undersea and data[ivm + area.ystride * i] == node["default:water_source"]) then
|
||||
air_above = true
|
||||
end
|
||||
end
|
||||
|
@ -278,10 +289,9 @@ fun_caves.decogen = function(minp, maxp, data, p2data, area, node, heightmap, bi
|
|||
end
|
||||
end
|
||||
|
||||
-- Dis
|
||||
if underzone == 3 and data[ivm] == node['air'] and floor((x - minp.x) / 8) % 2 == 0 and floor((z - minp.z) / 8) % 2 == 0 and y % 4960 < 82 + dis_map[floor((x - minp.x) / 8)][floor((z - minp.z) / 8)] * 4 and y % 4960 > 80 then
|
||||
if underzone and underzone.name == 'Dis' and data[ivm] == node['air'] and floor((x - minp.x) / 8) % 2 == 0 and floor((z - minp.z) / 8) % 2 == 0 and y - underzone.floor < dis_map[floor((x - minp.x) / 8)][floor((z - minp.z) / 8)] * 4 + 1 and y - underzone.floor >= 0 then
|
||||
local dx = (x - minp.x) % 16
|
||||
local dy = y % 4960 - 80
|
||||
local dy = y - underzone.floor + 1
|
||||
local dz = (z - minp.z) % 16
|
||||
if dx == 1 and dz == 1 then
|
||||
data[ivm] = node["default:ladder_steel"]
|
||||
|
@ -289,7 +299,7 @@ fun_caves.decogen = function(minp, maxp, data, p2data, area, node, heightmap, bi
|
|||
write_p2 = true
|
||||
elseif ((dx == 0 or dx == 7) and (dz % 3 ~= 2 or dy % 4 == 0)) or ((dz == 0 or dz == 7) and (dx % 3 ~= 2 or dy % 4 == 0)) then
|
||||
data[ivm] = node["fun_caves:hot_iron"]
|
||||
elseif dy %4 == 0 then
|
||||
elseif dy % 4 == 0 then
|
||||
data[ivm] = node["fun_caves:hot_brass"]
|
||||
end
|
||||
write = true
|
||||
|
@ -323,18 +333,22 @@ fun_caves.decogen = function(minp, maxp, data, p2data, area, node, heightmap, bi
|
|||
end
|
||||
|
||||
-- fluids
|
||||
if y > minp.y and (node_below == node["default:stone"] or node_below == node["fun_caves:hot_cobble"]) and rand(300) == 1 then
|
||||
if not underzone and y > minp.y and (node_below == node["default:stone"] or node_below == node["fun_caves:hot_cobble"]) and rand(300) == 1 then
|
||||
data[ivm] = node["default:lava_source"]
|
||||
write = true
|
||||
break
|
||||
elseif node_below == node["fun_caves:polluted_dirt"] and rand(400) == 1 then
|
||||
data[ivm] = node["fun_caves:water_poison_source"]
|
||||
write = true
|
||||
break
|
||||
elseif node_below == node["fun_caves:stone_with_moss"] and rand(300) == 1 then
|
||||
data[ivm] = node["default:water_source"]
|
||||
write = true
|
||||
break
|
||||
elseif underzone and underzone.name == 'Phlegethos' and node_below == node["fun_caves:hot_cobble"] and rand(1200) == 1 then
|
||||
data[ivm] = node["default:lava_source"]
|
||||
write = true
|
||||
break
|
||||
elseif node_below == node["fun_caves:polluted_dirt"] and rand(2000) == 1 then
|
||||
data[ivm] = node["fun_caves:water_poison_source"]
|
||||
write = true
|
||||
break
|
||||
|
||||
-- standing up
|
||||
elseif node_below == node["default:ice"] and rand(12) == 1 then
|
||||
|
|
94
mapgen.lua
94
mapgen.lua
|
@ -74,6 +74,76 @@ fun_caves.is_fortress = function(pos, cs, debug)
|
|||
end
|
||||
|
||||
|
||||
fun_caves.underzones = {
|
||||
Caina={
|
||||
name='Caina',
|
||||
ceiling=-4852,
|
||||
ceiling_node='default:ice',
|
||||
column_node='default:ice',
|
||||
column_node_rare = 'fun_caves:thin_ice',
|
||||
floor=-4972,
|
||||
floor_node='default:ice',
|
||||
lower_bound=-4992,
|
||||
regular_columns=false,
|
||||
upper_bound=-4832,
|
||||
vary=true,
|
||||
},
|
||||
Phlegethos={
|
||||
name='Phlegethos',
|
||||
ceiling=-9892,
|
||||
ceiling_node='fun_caves:black_sand',
|
||||
column_node='default:stone',
|
||||
column_node_rare = 'fun_caves:hot_stone',
|
||||
floor=-10012,
|
||||
floor_node='fun_caves:hot_cobble',
|
||||
lower_bound=-10032,
|
||||
regular_columns=false,
|
||||
upper_bound=-9872,
|
||||
vary=true,
|
||||
},
|
||||
Dis={
|
||||
name='Dis',
|
||||
ceiling=-14914,
|
||||
ceiling_node='fun_caves:hot_brass',
|
||||
column_node='default:steelblock',
|
||||
column_node_rare = nil,
|
||||
floor=-14982,
|
||||
floor_node='fun_caves:hot_brass',
|
||||
lower_bound=-14992,
|
||||
regular_columns=true,
|
||||
upper_bound=-14912,
|
||||
vary=false,
|
||||
},
|
||||
Minauros={
|
||||
name='Minauros',
|
||||
ceiling=-19812,
|
||||
ceiling_node='fun_caves:black_sand',
|
||||
column_node='fun_caves:polluted_dirt',
|
||||
column_node_rare = 'fun_caves:glowing_fungal_stone',
|
||||
floor=-19932,
|
||||
floor_node='fun_caves:polluted_dirt',
|
||||
lower_bound=-19952,
|
||||
regular_columns=false,
|
||||
upper_bound=-19792,
|
||||
vary=true,
|
||||
},
|
||||
Styx={
|
||||
name='Styx',
|
||||
ceiling=-29812,
|
||||
ceiling_node='default:dirt',
|
||||
column_node=nil,
|
||||
column_node_rare = nil,
|
||||
floor=-30012,
|
||||
floor_node='default:dirt',
|
||||
lower_bound=-30032,
|
||||
regular_columns=false,
|
||||
sealevel=-29842,
|
||||
upper_bound=-29792,
|
||||
vary=true,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
local function generate(p_minp, p_maxp, seed)
|
||||
local minp, maxp = p_minp, p_maxp
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
|
@ -88,16 +158,11 @@ local function generate(p_minp, p_maxp, seed)
|
|||
|
||||
local write = false
|
||||
local write_p2 = false
|
||||
local underzone, dis_map = nil, {}
|
||||
if minp.y < -4000 and minp.y % 4960 < 160 and maxp.y % 4960 > 0 then
|
||||
underzone = floor(minp.y / -4960 + 0.5)
|
||||
if underzone == 3 then
|
||||
for i = 0, 10, 2 do
|
||||
dis_map[i] = {}
|
||||
for j = 0, 10, 2 do
|
||||
dis_map[i][j] = rand(4)
|
||||
end
|
||||
end
|
||||
local underzone = nil
|
||||
for _, uz in pairs(fun_caves.underzones) do
|
||||
local avg = (minp.y + maxp.y) / 2
|
||||
if avg <= uz.upper_bound and avg >= uz.lower_bound then
|
||||
underzone = uz
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -106,9 +171,10 @@ local function generate(p_minp, p_maxp, seed)
|
|||
fun_caves.fortress(minp, maxp, data, area, node)
|
||||
write = true
|
||||
else
|
||||
write = fun_caves.cavegen(minp, maxp, data, area, node, heightmap, underzone)
|
||||
|
||||
write, write_p2 = fun_caves.decogen(minp, maxp, data, p2data, area, node, heightmap, biome_ids, underzone, dis_map)
|
||||
local write1, write2
|
||||
write1 = fun_caves.cavegen(minp, maxp, data, area, node, heightmap, underzone)
|
||||
write2, write_p2 = fun_caves.decogen(minp, maxp, data, p2data, area, node, heightmap, biome_ids, underzone)
|
||||
write = write1 or write2
|
||||
end
|
||||
|
||||
|
||||
|
@ -119,7 +185,7 @@ local function generate(p_minp, p_maxp, seed)
|
|||
end
|
||||
|
||||
if fun_caves.DEBUG then
|
||||
vm:set_lighting({day = 10, night = 10})
|
||||
vm:set_lighting({day = 15, night = 15})
|
||||
else
|
||||
-- set_lighting causes shadows
|
||||
--vm:set_lighting({day = 0, night = 0})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue