Add large craters.

This commit is contained in:
Duane 2016-07-21 03:07:36 -05:00
parent 212511b754
commit e9765fabfc
3 changed files with 54 additions and 6 deletions

View file

@ -750,7 +750,7 @@ local last_meteor_strike = 0
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass", 'default:dirt_with_snow'}, nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass", 'default:dirt_with_snow'},
neighbors = {"air", 'default:snow'}, neighbors = {"air", 'default:snow'},
interval = 15 * time_factor, interval = 25 * time_factor,
catch_up = false, catch_up = false,
chance = 32767, chance = 32767,
action = function(pos, node) action = function(pos, node)

View file

@ -43,14 +43,19 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone)
local write = false local write = false
local index = 0 local index = 0
local index3d = 0 local crater
local cave_width = fun_caves.cave_width if not underzone and math.random(10) == 1 then
local styx_sea_level = fun_caves.underzones['Styx'].sealevel crater = {
x = minp.x + math.random(math.floor(csize.x / 2)) + math.floor(csize.x / 4),
y = 15,
z = minp.z + math.random(math.floor(csize.z / 2)) + math.floor(csize.z / 4),
}
end
local crater_min = 33000
for z = minp.z, maxp.z do for z = minp.z, maxp.z do
for x = minp.x, maxp.x do for x = minp.x, maxp.x do
index = index + 1 index = index + 1
index3d = (z - minp.z) * (csize.y + 2) * csize.x + (x - minp.x) + 1
local ivm = area:index(x, minp.y-1, z)
local height = heightmap[index] local height = heightmap[index]
if height and height < maxp.y - 1 and height > minp.y then if height and height < maxp.y - 1 and height > minp.y then
@ -68,6 +73,30 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone)
heightmap[index] = height heightmap[index] = height
end end
if crater then
local dist = crater.y - math.sqrt((x - crater.x) ^ 2 + (z - crater.z) ^ 2)
if dist > 0 and (height > maxp.y or height < minp.y + crater.y) then
crater = nil
end
if crater and dist > 0 and dist <= 1 and crater_min > height then
crater_min = height
end
end
end
end
index = 0
local index3d = 0
local cave_width = fun_caves.cave_width
local styx_sea_level = fun_caves.underzones['Styx'].sealevel
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
index = index + 1
index3d = (z - minp.z) * (csize.y + 2) * csize.x + (x - minp.x) + 1
local ivm = area:index(x, minp.y-1, z)
local height = heightmap[index]
local column = 0 local column = 0
if underzone then if underzone then
if cave_3[index] < 30 then if cave_3[index] < 30 then
@ -77,7 +106,21 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone)
end end
end end
local dist
if crater then
dist = crater.y - math.sqrt((x - crater.x) ^ 2 + (z - crater.z) ^ 2)
end
for y = minp.y-1, maxp.y+1 do for y = minp.y-1, maxp.y+1 do
if crater and dist and dist > 0 then
if y > crater_min - 1.5 * dist and y < maxp.y - 1.5 * dist then
data[ivm] = data[ivm + (math.floor((height - crater_min) * dist / crater.y) + math.ceil(dist / 2)) * area.ystride]
end
if y > crater_min - dist and ground_nodes[data[ivm]] and math.random(300) == 1 then
data[ivm] = node['fun_caves:stone_with_meteoritic_iron']
end
end
if underzone and underzone.regular_columns and (x - minp.x) < 8 and (z - minp.z) < 8 then if underzone and underzone.regular_columns and (x - minp.x) < 8 and (z - minp.z) < 8 then
data[ivm] = node[underzone.column_node] data[ivm] = node[underzone.column_node]
write = true write = true

View file

@ -110,6 +110,11 @@ newnode.drop = "fun_caves:meteorite"
newnode.groups.soil = 0 newnode.groups.soil = 0
minetest.register_node("fun_caves:meteorite_crater", newnode) minetest.register_node("fun_caves:meteorite_crater", newnode)
local newnode = fun_caves.clone_node("default:stone_with_iron")
newnode.description = "Stone With Meteoritic Iron"
newnode.drop = "fun_caves:meteorite"
minetest.register_node("fun_caves:stone_with_meteoritic_iron", newnode)
newnode = fun_caves.clone_node("default:stone") newnode = fun_caves.clone_node("default:stone")
newnode.tiles = {'dna.png'} newnode.tiles = {'dna.png'}