diff --git a/abms.lua b/abms.lua index 742a17b..dd95d64 100644 --- a/abms.lua +++ b/abms.lua @@ -750,7 +750,7 @@ local last_meteor_strike = 0 minetest.register_abm({ nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass", 'default:dirt_with_snow'}, neighbors = {"air", 'default:snow'}, - interval = 15 * time_factor, + interval = 25 * time_factor, catch_up = false, chance = 32767, action = function(pos, node) diff --git a/cavegen.lua b/cavegen.lua index 80dcacd..abca851 100644 --- a/cavegen.lua +++ b/cavegen.lua @@ -43,14 +43,19 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone) local write = false local index = 0 - local index3d = 0 - local cave_width = fun_caves.cave_width - local styx_sea_level = fun_caves.underzones['Styx'].sealevel + local crater + if not underzone and math.random(10) == 1 then + 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 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] 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 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 if underzone then if cave_3[index] < 30 then @@ -77,7 +106,21 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone) 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 + 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 data[ivm] = node[underzone.column_node] write = true diff --git a/nodes.lua b/nodes.lua index 012bd4a..fad3ede 100644 --- a/nodes.lua +++ b/nodes.lua @@ -110,6 +110,11 @@ newnode.drop = "fun_caves:meteorite" newnode.groups.soil = 0 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.tiles = {'dna.png'}