Add flora and fauna to clouds.
This commit is contained in:
parent
b5d48307cb
commit
30d5f9ce96
13 changed files with 316 additions and 100 deletions
92
cloudgen.lua
92
cloudgen.lua
|
@ -5,21 +5,29 @@ local rand = math.random
|
||||||
local min = math.min
|
local min = math.min
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
local ceil = math.ceil
|
local ceil = math.ceil
|
||||||
local abs = math.ceil
|
local abs = math.abs
|
||||||
local map_max = 31000
|
local max_depth = 31000
|
||||||
|
|
||||||
|
|
||||||
local cloud_noise_1 = {offset = 10, scale = 10, seed = 3721, spread = {x = 120, y = 120, z = 120}, octaves = 3, persist = 1, lacunarity = 2}
|
local cloud_noise_1 = {offset = 10, scale = 10, seed = 4877, spread = {x = 120, y = 120, z = 120}, octaves = 3, persist = 1, lacunarity = 2}
|
||||||
|
local cloud_noise_2 = {offset = 0, scale = 1, seed = 5748, spread = {x = 40, y = 10, z = 40}, octaves = 3, persist = 1, lacunarity = 2}
|
||||||
|
local plant_noise = {offset = 0.0, scale = 1.0, spread = {x = 200, y = 200, z = 200}, seed = -2525, octaves = 3, persist = 0.7, lacunarity = 2.0}
|
||||||
|
local biome_noise = {offset = 0.0, scale = 1.0, spread = {x = 400, y = 400, z = 400}, seed = -1471, octaves = 3, persist = 0.5, lacunarity = 2.0}
|
||||||
|
|
||||||
fun_caves.cloudgen = function(minp, maxp, data, area, node)
|
fun_caves.cloudgen = function(minp, maxp, data, p2data, area, node)
|
||||||
local clouds = ceil(minp.y / floor(map_max / 7))
|
local clouds = ceil(minp.y / floor(max_depth / 7))
|
||||||
if abs(clouds * floor(map_max / 7) - minp.y) > 80 then
|
if abs(clouds * floor(max_depth / 7) - minp.y) > 80 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local csize = vector.add(vector.subtract(maxp, minp), 1)
|
local csize = vector.add(vector.subtract(maxp, minp), 1)
|
||||||
|
local map_max = {x = csize.x, y = csize.y, z = csize.z}
|
||||||
|
local map_min = {x = minp.x, y = minp.y, z = minp.z}
|
||||||
|
|
||||||
local cloud_1 = minetest.get_perlin_map(cloud_noise_1, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp.x, y=minp.z})
|
local cloud_1 = minetest.get_perlin_map(cloud_noise_1, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp.x, y=minp.z})
|
||||||
|
local cloud_2 = minetest.get_perlin_map(cloud_noise_2, 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 biome_n = minetest.get_perlin_map(biome_noise, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp.x, y=minp.z})
|
||||||
|
|
||||||
local write = false
|
local write = false
|
||||||
|
|
||||||
|
@ -28,25 +36,43 @@ fun_caves.cloudgen = function(minp, maxp, data, area, node)
|
||||||
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 = noise_area:index(x, minp.y-1, z)
|
index3d = (z - minp.z) * (csize.y) * csize.x + (x - minp.x) + 1
|
||||||
index3d = (z - minp.z) * (csize.y + 2) * csize.x + (x - minp.x) + 1
|
local ivm = area:index(x, minp.y, z)
|
||||||
--local height = cloud_1[index] + minp.y + 32
|
|
||||||
local ivm = area:index(x, minp.y-1, z)
|
|
||||||
|
|
||||||
|
local cloud
|
||||||
|
if biome_n[index] < 0 then
|
||||||
|
cloud = 'storm_cloud'
|
||||||
|
else
|
||||||
|
cloud = 'cloud'
|
||||||
|
end
|
||||||
|
|
||||||
|
cloud_1[index] = floor(cloud_1[index] + 0.5)
|
||||||
if cloud_1[index] > 0 then
|
if cloud_1[index] > 0 then
|
||||||
for y = minp.y, maxp.y do
|
for y = minp.y, maxp.y do
|
||||||
local dy = y - minp.y
|
local dy = y - minp.y
|
||||||
if dy > 32 and cloud_1[index] > 15 then
|
if dy > 32 and cloud_1[index] > 15 and dy < 47 then
|
||||||
if dy < 47 then
|
if dy < 47 - (cloud_1[index] - 15) then
|
||||||
if dy < 47 - (cloud_1[index] - 15) then
|
data[ivm] = node['fun_caves:'..cloud]
|
||||||
data[ivm] = node['fun_caves:cloud']
|
else
|
||||||
else
|
data[ivm] = node['default:water_source']
|
||||||
data[ivm] = node['default:water_source']
|
|
||||||
end
|
|
||||||
write = true
|
write = true
|
||||||
end
|
end
|
||||||
elseif dy >= 32 - cloud_1[index] and dy <= 32 + cloud_1[index] then
|
elseif (dy <= 32 or cloud_1[index] <= 15) and dy >= 32 - cloud_1[index] and dy <= 32 + cloud_1[index] then
|
||||||
data[ivm] = node['fun_caves:cloud']
|
data[ivm] = node['fun_caves:'..cloud]
|
||||||
|
write = true
|
||||||
|
elseif data[ivm - area.ystride] == node['fun_caves:'..cloud] and data[ivm] == node['air'] then
|
||||||
|
if rand(30) == 1 and plant_n[index] > 0.5 then
|
||||||
|
data[ivm] = node['fun_caves:moon_weed']
|
||||||
|
write = true
|
||||||
|
elseif rand(60) == 1 and plant_n[index] > 0.5 then
|
||||||
|
fun_caves.place_schematic(minp, maxp, data, p2data, area, node, {x=x,y=y-1,z=z}, fun_caves.schematics['lumin_tree'], true)
|
||||||
|
write = true
|
||||||
|
elseif rand(10) == 1 then
|
||||||
|
data[ivm] = node['default:grass_'..rand(4)]
|
||||||
|
write = true
|
||||||
|
end
|
||||||
|
elseif data[ivm] == node['air'] and (dy < 29 - cloud_1[index] or dy > 35 + cloud_1[index]) and cloud_2[index3d] > abs((dy - 40) / 20) then
|
||||||
|
data[ivm] = node['fun_caves:wispy_cloud']
|
||||||
write = true
|
write = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,5 +83,33 @@ fun_caves.cloudgen = function(minp, maxp, data, area, node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local index = 0
|
||||||
|
local index3d = 0
|
||||||
|
for z = minp.z, maxp.z do
|
||||||
|
for x = minp.x, maxp.x do
|
||||||
|
index = index + 1
|
||||||
|
local ivm = area:index(x, minp.y, z)
|
||||||
|
|
||||||
|
local cloud
|
||||||
|
if biome_n[index] < 0 then
|
||||||
|
cloud = 'storm_cloud'
|
||||||
|
else
|
||||||
|
cloud = 'cloud'
|
||||||
|
end
|
||||||
|
|
||||||
|
cloud_1[index] = floor(cloud_1[index] + 0.5)
|
||||||
|
if cloud_1[index] > 0 then
|
||||||
|
for y = minp.y, maxp.y do
|
||||||
|
local dy = y - minp.y
|
||||||
|
if data[ivm] == node['fun_caves:'..cloud] and data[ivm + area.ystride] == node['default:water_source'] and rand(30) == 1 and fun_caves.surround(node, data, area, ivm) then
|
||||||
|
data[ivm] = node['fun_caves:water_plant_1_water_'..cloud]
|
||||||
|
end
|
||||||
|
|
||||||
|
ivm = ivm + area.ystride
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return write
|
return write
|
||||||
end
|
end
|
||||||
|
|
41
deco.lua
41
deco.lua
|
@ -182,6 +182,47 @@ do
|
||||||
fun_caves.schematics['decaying_tree'] = s
|
fun_caves.schematics['decaying_tree'] = s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local w, h, d = 5, 8, 5
|
||||||
|
local s = fun_caves.schematic_array(w, h, d)
|
||||||
|
|
||||||
|
for y = 0, math.floor(h/2)-1 do
|
||||||
|
s.data[2*d*h + y*d + 2 + 1].name = 'fun_caves:lumin_tree'
|
||||||
|
s.data[2*d*h + y*d + 2 + 1].param1 = 255
|
||||||
|
end
|
||||||
|
|
||||||
|
for z = 0, d-1 do
|
||||||
|
for y = math.floor(h/2), h-1 do
|
||||||
|
for x = 0, w-1 do
|
||||||
|
if y < h - 1 or (x ~= 0 and x ~= w-1 and z ~= 0 and z ~= d-1) then
|
||||||
|
s.data[z*d*h + y*d + x + 1].name = 'fun_caves:leaves_lumin'
|
||||||
|
|
||||||
|
if y == h-1 or x == 0 or x == w-1 or z == 0 or z == d-1 then
|
||||||
|
s.data[z*d*h + y*d + x + 1].param1 = 150
|
||||||
|
else
|
||||||
|
s.data[z*d*h + y*d + x + 1].param1 = 225
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for z = math.floor(d/2)-1, math.floor(d/2)+1, 2 do
|
||||||
|
for x = math.floor(w/2)-1, math.floor(w/2)+1, 2 do
|
||||||
|
s.data[z*d*h + math.floor(h/2)*d + x + 1].name = 'fun_caves:lumin_tree'
|
||||||
|
s.data[z*d*h + math.floor(h/2)*d + x + 1].param1 = 150
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for y = 0, h-1 do
|
||||||
|
if y / 3 == math.floor(y / 3) then
|
||||||
|
s.yslice_prob[#s.yslice_prob+1] = {ypos=y,prob=170}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
fun_caves.schematics['lumin_tree'] = s
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
dofile(fun_caves.path .. "/deco_caves.lua")
|
dofile(fun_caves.path .. "/deco_caves.lua")
|
||||||
--dofile(fun_caves.path.."/deco_dirt.lua")
|
--dofile(fun_caves.path.."/deco_dirt.lua")
|
||||||
|
|
|
@ -1,6 +1,90 @@
|
||||||
|
|
||||||
local newnode = fun_caves.clone_node("default:dirt")
|
local newnode = fun_caves.clone_node("default:dirt")
|
||||||
newnode.description = "Cloud"
|
newnode.description = "Cloud"
|
||||||
newnode.tiles = {'fun_caves_storm_cloud.png'}
|
newnode.tiles = {'fun_caves_cloud.png'}
|
||||||
newnode.sunlight_propagates = true
|
newnode.sunlight_propagates = true
|
||||||
minetest.register_node("fun_caves:cloud", newnode)
|
minetest.register_node("fun_caves:cloud", newnode)
|
||||||
|
|
||||||
|
newnode = fun_caves.clone_node("default:dirt")
|
||||||
|
newnode.description = "Storm Cloud"
|
||||||
|
newnode.tiles = {'fun_caves_storm_cloud.png'}
|
||||||
|
--newnode.sunlight_propagates = true
|
||||||
|
minetest.register_node("fun_caves:storm_cloud", newnode)
|
||||||
|
|
||||||
|
newnode = fun_caves.clone_node("default:dirt")
|
||||||
|
newnode.description = "Wispy Cloud"
|
||||||
|
newnode.tiles = {'fun_caves_wisp.png'}
|
||||||
|
newnode.sunlight_propagates = true
|
||||||
|
newnode.use_texture_alpha = true
|
||||||
|
newnode.walkable = false
|
||||||
|
newnode.buildable_to = true
|
||||||
|
newnode.pointable = false
|
||||||
|
minetest.register_node("fun_caves:wispy_cloud", newnode)
|
||||||
|
|
||||||
|
minetest.register_node("fun_caves:moon_weed", {
|
||||||
|
description = "Moon Weed",
|
||||||
|
drawtype = "plantlike",
|
||||||
|
tiles = {"fun_caves_moon_weed.png"},
|
||||||
|
inventory_image = "fun_caves_moon_weed.png",
|
||||||
|
waving = false,
|
||||||
|
sunlight_propagates = true,
|
||||||
|
paramtype = "light",
|
||||||
|
light_source = 8,
|
||||||
|
walkable = false,
|
||||||
|
groups = {snappy=3,flammable=2,flora=1,attached_node=1},
|
||||||
|
sounds = default.node_sound_leaves_defaults(),
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("fun_caves:leaves_lumin", {
|
||||||
|
description = "Leaves",
|
||||||
|
drawtype = "allfaces_optional",
|
||||||
|
waving = 1,
|
||||||
|
visual_scale = 1.3,
|
||||||
|
tiles = {"default_leaves.png^[colorize:#FFDF00:150"},
|
||||||
|
special_tiles = {"default_leaves_simple.png^[colorize:#FFDF00:150"},
|
||||||
|
paramtype = "light",
|
||||||
|
is_ground_content = false,
|
||||||
|
light_source = 8,
|
||||||
|
groups = {snappy = 3, leafdecay = 4, flammable = 2, leaves = 1},
|
||||||
|
drop = {
|
||||||
|
max_items = 1,
|
||||||
|
items = {
|
||||||
|
--{
|
||||||
|
-- -- player will get sapling with 1/20 chance
|
||||||
|
-- items = {'default:sapling'},
|
||||||
|
-- rarity = 20,
|
||||||
|
--},
|
||||||
|
{
|
||||||
|
-- player will get leaves only if he get no saplings,
|
||||||
|
-- this is because max_items is 1
|
||||||
|
items = {'fun_caves:leaves_lumin'},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sounds = default.node_sound_leaves_defaults(),
|
||||||
|
|
||||||
|
after_place_node = default.after_place_leaves,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("fun_caves:lumin_tree", {
|
||||||
|
description = "Lumin Tree",
|
||||||
|
tiles = {
|
||||||
|
"default_tree_top.png", "default_tree_top.png", "fun_caves_lumin_tree.png"
|
||||||
|
},
|
||||||
|
paramtype = "light",
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = { {-0.25, -0.5, -0.25, 0.25, 0.5, 0.25}, }
|
||||||
|
},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
|
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
|
||||||
|
on_place = minetest.rotate_node
|
||||||
|
})
|
||||||
|
|
|
@ -134,6 +134,14 @@ for _, plant in ipairs(fun_caves.plantlist) do
|
||||||
def2.tiles = { "default_dirt.png", "fun_caves_"..plant.name..".png",}
|
def2.tiles = { "default_dirt.png", "fun_caves_"..plant.name..".png",}
|
||||||
def2.drop = {max_items=2, items={{items={"fun_caves:"..plant.name}, rarity=1}, {items={"default:dirt"}, rarity=1}}}
|
def2.drop = {max_items=2, items={{items={"fun_caves:"..plant.name}, rarity=1}, {items={"default:dirt"}, rarity=1}}}
|
||||||
minetest.register_node("fun_caves:"..plant.name.."_water_soil", def2)
|
minetest.register_node("fun_caves:"..plant.name.."_water_soil", def2)
|
||||||
|
def2 = table.copy(def)
|
||||||
|
def2.tiles = { "fun_caves_cloud.png", "fun_caves_"..plant.name..".png",}
|
||||||
|
def2.drop = {max_items=2, items={{items={"fun_caves:"..plant.name}, rarity=1}, {items={"fun_caves:cloud"}, rarity=1}}}
|
||||||
|
minetest.register_node("fun_caves:"..plant.name.."_water_cloud", def2)
|
||||||
|
def2 = table.copy(def)
|
||||||
|
def2.tiles = { "fun_caves_storm_cloud.png", "fun_caves_"..plant.name..".png",}
|
||||||
|
def2.drop = {max_items=2, items={{items={"fun_caves:"..plant.name}, rarity=1}, {items={"fun_caves:storm_cloud"}, rarity=1}}}
|
||||||
|
minetest.register_node("fun_caves:"..plant.name.."_water_storm_cloud", def2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -199,9 +207,17 @@ do
|
||||||
local water_plant_1_def_soil = table.copy(water_plant_1_def_sand)
|
local water_plant_1_def_soil = table.copy(water_plant_1_def_sand)
|
||||||
water_plant_1_def_soil.place_on = {"group:soil"}
|
water_plant_1_def_soil.place_on = {"group:soil"}
|
||||||
water_plant_1_def_soil.decoration = {"fun_caves:water_plant_1_water_soil",}
|
water_plant_1_def_soil.decoration = {"fun_caves:water_plant_1_water_soil",}
|
||||||
|
local water_plant_1_def_cloud = table.copy(water_plant_1_def_sand)
|
||||||
|
water_plant_1_def_cloud.place_on = {"group:cloud"}
|
||||||
|
water_plant_1_def_cloud.decoration = {"fun_caves:water_plant_1_water_cloud",}
|
||||||
|
local water_plant_1_def_storm_cloud = table.copy(water_plant_1_def_sand)
|
||||||
|
water_plant_1_def_storm_cloud.place_on = {"group:cloud"}
|
||||||
|
water_plant_1_def_storm_cloud.decoration = {"fun_caves:water_plant_1_water_storm_cloud",}
|
||||||
|
|
||||||
register_water_plant(water_plant_1_def_sand)
|
register_water_plant(water_plant_1_def_sand)
|
||||||
register_water_plant(water_plant_1_def_soil)
|
register_water_plant(water_plant_1_def_soil)
|
||||||
|
register_water_plant(water_plant_1_def_cloud)
|
||||||
|
register_water_plant(water_plant_1_def_storm_cloud)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
79
decogen.lua
79
decogen.lua
|
@ -26,79 +26,6 @@ local csize
|
||||||
local node_match_cache = {}
|
local node_match_cache = {}
|
||||||
|
|
||||||
|
|
||||||
local function place_schematic(minp, maxp, data, p2data, area, node, pos, schem, center)
|
|
||||||
local rot = rand(4) - 1
|
|
||||||
local yslice = {}
|
|
||||||
if schem.yslice_prob then
|
|
||||||
for _, ys in pairs(schem.yslice_prob) do
|
|
||||||
yslice[ys.ypos] = ys.prob
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if center then
|
|
||||||
pos.x = pos.x - floor(schem.size.x / 2)
|
|
||||||
pos.z = pos.z - floor(schem.size.z / 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
for z1 = 0, schem.size.z - 1 do
|
|
||||||
for x1 = 0, schem.size.x - 1 do
|
|
||||||
local x, z
|
|
||||||
if rot == 0 then
|
|
||||||
x, z = x1, z1
|
|
||||||
elseif rot == 1 then
|
|
||||||
x, z = schem.size.z - z1 - 1, x1
|
|
||||||
elseif rot == 2 then
|
|
||||||
x, z = schem.size.x - x1 - 1, schem.size.z - z1 - 1
|
|
||||||
elseif rot == 3 then
|
|
||||||
x, z = z1, schem.size.x - x1 - 1
|
|
||||||
end
|
|
||||||
local dz = pos.z - minp.z + z
|
|
||||||
local dx = pos.x - minp.x + x
|
|
||||||
if pos.x + x > minp.x and pos.x + x < maxp.x and pos.z + z > minp.z and pos.z + z < maxp.z then
|
|
||||||
local ivm = area:index(pos.x + x, pos.y, pos.z + z)
|
|
||||||
local isch = z1 * schem.size.y * schem.size.x + x1 + 1
|
|
||||||
for y = 0, schem.size.y - 1 do
|
|
||||||
local dy = pos.y - minp.y + y
|
|
||||||
--if math.min(dx, csize.x - dx) + math.min(dy, csize.y - dy) + math.min(dz, csize.z - dz) > bevel then
|
|
||||||
if yslice[y] or 255 >= rand(255) then
|
|
||||||
local prob = schem.data[isch].prob or schem.data[isch].param1 or 255
|
|
||||||
if prob >= rand(255) and schem.data[isch].name ~= "air" then
|
|
||||||
data[ivm] = node[schem.data[isch].name]
|
|
||||||
end
|
|
||||||
local param2 = schem.data[isch].param2 or 0
|
|
||||||
p2data[ivm] = param2
|
|
||||||
end
|
|
||||||
--end
|
|
||||||
|
|
||||||
ivm = ivm + area.ystride
|
|
||||||
isch = isch + schem.size.x
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function surround(node, data, area, ivm)
|
|
||||||
-- Check to make sure that a plant root is fully surrounded.
|
|
||||||
-- This is due to the kludgy way you have to make water plants
|
|
||||||
-- in minetest, to avoid bubbles.
|
|
||||||
for x1 = -1,1,2 do
|
|
||||||
local n = data[ivm+x1]
|
|
||||||
if n == node["default:river_water_source"] or n == node["default:water_source"] or n == node["air"] then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
for z1 = -area.zstride,area.zstride,2*area.zstride do
|
|
||||||
local n = data[ivm+z1]
|
|
||||||
if n == node["default:river_water_source"] or n == node["default:water_source"] or n == node["air"] then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local biome_noise = {offset = 0.0, scale = 1.0, spread = {x = 400, y = 400, z = 400}, seed = 903, octaves = 3, persist = 0.5, lacunarity = 2.0}
|
local biome_noise = {offset = 0.0, scale = 1.0, spread = {x = 400, y = 400, z = 400}, seed = 903, octaves = 3, persist = 0.5, lacunarity = 2.0}
|
||||||
local plant_noise = {offset = 0.0, scale = 1.0, spread = {x = 200, y = 200, z = 200}, seed = 33, octaves = 3, persist = 0.7, lacunarity = 2.0}
|
local plant_noise = {offset = 0.0, scale = 1.0, spread = {x = 200, y = 200, z = 200}, seed = 33, octaves = 3, persist = 0.7, lacunarity = 2.0}
|
||||||
|
|
||||||
|
@ -308,7 +235,7 @@ fun_caves.decogen = function(minp, maxp, data, p2data, area, node, heightmap, bi
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if air_count > 6 then
|
if air_count > 6 then
|
||||||
place_schematic(minp, maxp, data, p2data, area, node, {x=x,y=y,z=z}, fun_caves.schematics['decaying_tree'], true)
|
fun_caves.place_schematic(minp, maxp, data, p2data, area, node, {x=x,y=y,z=z}, fun_caves.schematics['decaying_tree'], true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif node_below == node["default:dirt"] and biome and biome.fungi then
|
elseif node_below == node["default:dirt"] and biome and biome.fungi then
|
||||||
|
@ -380,7 +307,7 @@ fun_caves.decogen = function(minp, maxp, data, p2data, area, node, heightmap, bi
|
||||||
local node_below = data[ivm - area.ystride]
|
local node_below = data[ivm - area.ystride]
|
||||||
local node_above = data[ivm + area.ystride]
|
local node_above = data[ivm + area.ystride]
|
||||||
|
|
||||||
if y < water_level and data[ivm] == node["default:sand"] and node_above == node["default:water_source"] and data[ivm + area.ystride * 2] == node["default:water_source"] and coral_biomes[biome] and pn < -0.1 and rand(5) == 1 and surround(node, data, area, ivm) then
|
if y < water_level and data[ivm] == node["default:sand"] and node_above == node["default:water_source"] and data[ivm + area.ystride * 2] == node["default:water_source"] and coral_biomes[biome] and pn < -0.1 and rand(5) == 1 and fun_caves.surround(node, data, area, ivm) then
|
||||||
if rand(100) == 1 then
|
if rand(100) == 1 then
|
||||||
data[ivm] = node["fun_caves:precious_coral_water_sand"]
|
data[ivm] = node["fun_caves:precious_coral_water_sand"]
|
||||||
else
|
else
|
||||||
|
@ -404,7 +331,7 @@ fun_caves.decogen = function(minp, maxp, data, p2data, area, node, heightmap, bi
|
||||||
end
|
end
|
||||||
elseif x < maxp.x and y < maxp.y and z < maxp.z and x > minp.x and y > minp.y and z > minp.z and (node_above == node["default:water_source"] or node_above == node["default:river_water_source"]) and (data[ivm] == node["default:sand"] or data[ivm] == node["default:dirt"]) then
|
elseif x < maxp.x and y < maxp.y and z < maxp.z and x > minp.x and y > minp.y and z > minp.z and (node_above == node["default:water_source"] or node_above == node["default:river_water_source"]) and (data[ivm] == node["default:sand"] or data[ivm] == node["default:dirt"]) then
|
||||||
-- Check the biomes and plant water plants, if called for.
|
-- Check the biomes and plant water plants, if called for.
|
||||||
if not surround(node, data, area, ivm) then
|
if not fun_caves.surround(node, data, area, ivm) then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
74
mapgen.lua
74
mapgen.lua
|
@ -74,6 +74,78 @@ fun_caves.is_fortress = function(pos, cs, debug)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun_caves.place_schematic = function(minp, maxp, data, p2data, area, node, pos, schem, center)
|
||||||
|
local rot = rand(4) - 1
|
||||||
|
local yslice = {}
|
||||||
|
if schem.yslice_prob then
|
||||||
|
for _, ys in pairs(schem.yslice_prob) do
|
||||||
|
yslice[ys.ypos] = ys.prob
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if center then
|
||||||
|
pos.x = pos.x - floor(schem.size.x / 2)
|
||||||
|
pos.z = pos.z - floor(schem.size.z / 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
for z1 = 0, schem.size.z - 1 do
|
||||||
|
for x1 = 0, schem.size.x - 1 do
|
||||||
|
local x, z
|
||||||
|
if rot == 0 then
|
||||||
|
x, z = x1, z1
|
||||||
|
elseif rot == 1 then
|
||||||
|
x, z = schem.size.z - z1 - 1, x1
|
||||||
|
elseif rot == 2 then
|
||||||
|
x, z = schem.size.x - x1 - 1, schem.size.z - z1 - 1
|
||||||
|
elseif rot == 3 then
|
||||||
|
x, z = z1, schem.size.x - x1 - 1
|
||||||
|
end
|
||||||
|
local dz = pos.z - minp.z + z
|
||||||
|
local dx = pos.x - minp.x + x
|
||||||
|
if pos.x + x > minp.x and pos.x + x < maxp.x and pos.z + z > minp.z and pos.z + z < maxp.z then
|
||||||
|
local ivm = area:index(pos.x + x, pos.y, pos.z + z)
|
||||||
|
local isch = z1 * schem.size.y * schem.size.x + x1 + 1
|
||||||
|
for y = 0, schem.size.y - 1 do
|
||||||
|
local dy = pos.y - minp.y + y
|
||||||
|
--if math.min(dx, csize.x - dx) + math.min(dy, csize.y - dy) + math.min(dz, csize.z - dz) > bevel then
|
||||||
|
if yslice[y] or 255 >= rand(255) then
|
||||||
|
local prob = schem.data[isch].prob or schem.data[isch].param1 or 255
|
||||||
|
if prob >= rand(255) and schem.data[isch].name ~= "air" then
|
||||||
|
data[ivm] = node[schem.data[isch].name]
|
||||||
|
end
|
||||||
|
local param2 = schem.data[isch].param2 or 0
|
||||||
|
p2data[ivm] = param2
|
||||||
|
end
|
||||||
|
--end
|
||||||
|
|
||||||
|
ivm = ivm + area.ystride
|
||||||
|
isch = isch + schem.size.x
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
fun_caves.surround = function(node, data, area, ivm)
|
||||||
|
-- Check to make sure that a plant root is fully surrounded.
|
||||||
|
-- This is due to the kludgy way you have to make water plants
|
||||||
|
-- in minetest, to avoid bubbles.
|
||||||
|
for x1 = -1,1,2 do
|
||||||
|
local n = data[ivm+x1]
|
||||||
|
if n == node["default:river_water_source"] or n == node["default:water_source"] or n == node["air"] then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for z1 = -area.zstride,area.zstride,2*area.zstride do
|
||||||
|
local n = data[ivm+z1]
|
||||||
|
if n == node["default:river_water_source"] or n == node["default:water_source"] or n == node["air"] then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
fun_caves.underzones = {
|
fun_caves.underzones = {
|
||||||
Caina = {
|
Caina = {
|
||||||
|
@ -303,7 +375,7 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minp.y > 3000 then
|
if minp.y > 3000 then
|
||||||
write = fun_caves.cloudgen(minp, maxp, data, area, node)
|
write = fun_caves.cloudgen(minp, maxp, data, p2data, area, node)
|
||||||
elseif not underzone and fun_caves.is_fortress(minp, csize) then
|
elseif not underzone and fun_caves.is_fortress(minp, csize) then
|
||||||
--if not underzone then
|
--if not underzone then
|
||||||
fun_caves.fortress(minp, maxp, data, area, node)
|
fun_caves.fortress(minp, maxp, data, area, node)
|
||||||
|
|
22
mobs.lua
22
mobs.lua
|
@ -75,6 +75,28 @@ fun_caves.custom_ready = function(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if minetest.registered_entities["kpgmobs:wolf"] then
|
||||||
|
local m = table.copy(minetest.registered_entities["kpgmobs:wolf"])
|
||||||
|
m.textures = { {"fun_caves_white_wolf.png"}, }
|
||||||
|
m.base_texture = m.textures[1]
|
||||||
|
|
||||||
|
minetest.registered_entities["fun_caves:white_wolf"] = m
|
||||||
|
mobs.spawning_mobs["fun_caves:white_wolf"] = true
|
||||||
|
|
||||||
|
mobs:register_spawn("fun_caves:white_wolf", {"default:dirt_with_snow", "fun_caves:cloud", "fun_caves:storm_cloud"}, 20, -1, 11000, 3, 31000)
|
||||||
|
mobs:register_egg("fun_caves:white_wolf", "White Wolf", "wool_white.png", 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
if minetest.registered_entities["kpgmobs:horse2"] then
|
||||||
|
mobs:register_spawn("kpgmobs:horse2", {"fun_caves:cloud", "fun_caves:storm_cloud"}, 20, 8, 11000, 1, 31000)
|
||||||
|
end
|
||||||
|
|
||||||
|
if minetest.registered_entities["mobs_fish:clownfish"] then
|
||||||
|
--local l_spawn_near = {"default:sand","default:dirt","group:seaplants","group:seacoral"}
|
||||||
|
mobs:spawn_specific("mobs_fish:clownfish", {"default:water_source", "default:water_flowing"}, {"default:sand","default:dirt", "fun_caves:cloud", "fun_caves:storm_cloud","group:seaplants","group:seacoral"}, 5, 20, 30, 10000, 1, 4000, 31000)
|
||||||
|
mobs:spawn_specific("mobs_fish:tropical", {"default:water_source", "default:water_flowing"}, {"default:sand","default:dirt", "fun_caves:cloud", "fun_caves:storm_cloud","group:seaplants","group:seacoral"}, 5, 20, 30, 10000, 1, 4000, 31000)
|
||||||
|
end
|
||||||
|
|
||||||
if minetest.registered_entities["mobs_monster:spider"] then
|
if minetest.registered_entities["mobs_monster:spider"] then
|
||||||
-- Deep spider
|
-- Deep spider
|
||||||
local m = table.copy(minetest.registered_entities["mobs_monster:spider"])
|
local m = table.copy(minetest.registered_entities["mobs_monster:spider"])
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
local get_node_or_nil = minetest.get_node_or_nil
|
local get_node_or_nil = minetest.get_node_or_nil
|
||||||
local get_item_group = minetest.get_item_group
|
local get_item_group = minetest.get_item_group
|
||||||
local map_max = 31000
|
local max_depth = 31000
|
||||||
|
|
||||||
local old_is_protected = minetest.is_protected
|
local old_is_protected = minetest.is_protected
|
||||||
function minetest.is_protected(pos, name)
|
function minetest.is_protected(pos, name)
|
||||||
|
@ -143,7 +143,7 @@ local function teleporter(user, area, power)
|
||||||
else
|
else
|
||||||
local newpos
|
local newpos
|
||||||
if area == 'overworld' then
|
if area == 'overworld' then
|
||||||
newpos = {x=(math.random(2)*2-3)*(math.random(math.floor(map_max/6))+power*math.floor(map_max/6)), y=120, z=(math.random(2)*2-3)*(math.random(math.floor(map_max/6))+power*math.floor(map_max/6))}
|
newpos = {x=(math.random(2)*2-3)*(math.random(math.floor(max_depth/6))+power*math.floor(max_depth/6)), y=120, z=(math.random(2)*2-3)*(math.random(math.floor(max_depth/6))+power*math.floor(max_depth/6))}
|
||||||
elseif area == 'hell' then
|
elseif area == 'hell' then
|
||||||
newpos = {x=pos.x, y=fun_caves.underzones[({'Caina','Phlegethos','Dis','Minauros','Styx'})[power+1]].ceiling-30, z=pos.z}
|
newpos = {x=pos.x, y=fun_caves.underzones[({'Caina','Phlegethos','Dis','Minauros','Styx'})[power+1]].ceiling-30, z=pos.z}
|
||||||
else
|
else
|
||||||
|
@ -467,7 +467,7 @@ newnode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local ready = meta:get_string('formspec')
|
local ready = meta:get_string('formspec')
|
||||||
if ready == '' then
|
if ready == '' then
|
||||||
local level = math.max(6, math.ceil(pos.y / math.floor(map_max / 6)))
|
local level = math.max(6, math.ceil(pos.y / math.floor(max_depth / 6)))
|
||||||
local big_item = treasures[level][math.random(#treasures[level])]
|
local big_item = treasures[level][math.random(#treasures[level])]
|
||||||
meta:set_string("formspec", chest_formspec)
|
meta:set_string("formspec", chest_formspec)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
|
BIN
textures/fun_caves_cloud.png
Normal file
BIN
textures/fun_caves_cloud.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
textures/fun_caves_moon_weed.png
Normal file
BIN
textures/fun_caves_moon_weed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
BIN
textures/fun_caves_white_wolf.png
Normal file
BIN
textures/fun_caves_white_wolf.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
BIN
textures/fun_caves_wisp.png
Normal file
BIN
textures/fun_caves_wisp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 21 KiB |
Loading…
Add table
Add a link
Reference in a new issue