diff --git a/df_caverns/primordial.lua b/df_caverns/primordial.lua index e386405..414e55c 100644 --- a/df_caverns/primordial.lua +++ b/df_caverns/primordial.lua @@ -2,13 +2,6 @@ if not df_caverns.config.enable_primordial or not minetest.get_modpath("df_primo return end -local c_orb = minetest.get_content_id("df_primordial_items:glow_orb_hanging") -local c_mycelial_dirt = minetest.get_content_id("df_primordial_items:dirt_with_mycelium") -local c_dirt = minetest.get_content_id("default:dirt") -local c_giant_mycelium = minetest.get_content_id("df_primordial_items:giant_hypha_apical_mapgen") - ------------------------------------------------------------------------------------------ - local perlin_cave_primordial = { offset = 0, scale = 1, @@ -27,8 +20,15 @@ local perlin_wave_primordial = { persist = 0.63 } +----------------------------------------------------------------------------------------- +-- Fungal biome -local plants = { +local c_orb = minetest.get_content_id("df_primordial_items:glow_orb_hanging") +local c_mycelial_dirt = minetest.get_content_id("df_primordial_items:dirt_with_mycelium") +local c_dirt = minetest.get_content_id("default:dirt") +local c_giant_mycelium = minetest.get_content_id("df_primordial_items:giant_hypha_apical_mapgen") + +local fungal_plants = { minetest.get_content_id("df_primordial_items:fungal_grass_1"), minetest.get_content_id("df_primordial_items:fungal_grass_2"), minetest.get_content_id("df_primordial_items:glow_orb"), @@ -55,7 +55,7 @@ local mushroom_cavern_floor = function(abs_cracks, humidity, vi, area, data, dat local rotation = (math.random(1,4)-1)*90 mapgen_helper.place_schematic_on_data_if_it_fits(data, data_param2, area, area:position(vi+ystride), schematic, rotation) elseif rand < 0.05 then - data[vi+ystride] = plants[math.random(1,5)] + data[vi+ystride] = fungal_plants[math.random(1,5)] end end @@ -108,19 +108,63 @@ local mushroom_warren_floor = function(abs_cracks, vi, area, data, data_param2) if rand < 0.001 then data[vi+ystride] = c_giant_mycelium elseif rand < 0.03 then - data[vi+ystride] = plants[math.random(1,5)] + data[vi+ystride] = fungal_plants[math.random(1,5)] end end -local jungle_cavern_floor = function(abs_cracks, vi, area, data, data_param2) +-------------------------------------------------------------------------------------------------- +-- Jungle biome + + +local jungle_plants = { + minetest.get_content_id("df_primordial_items:fern_1"), + minetest.get_content_id("df_primordial_items:fern_2"), + minetest.get_content_id("df_primordial_items:glow_plant_1"), + minetest.get_content_id("df_primordial_items:glow_plant_2"), + minetest.get_content_id("df_primordial_items:glow_plant_3"), + minetest.get_content_id("df_primordial_items:jungle_grass_1"), + minetest.get_content_id("df_primordial_items:jungle_grass_2"), + minetest.get_content_id("df_primordial_items:jungle_grass_3"), + minetest.get_content_id("df_primordial_items:jungle_mushroom_1"), + minetest.get_content_id("df_primordial_items:jungle_mushroom_2"), +} + +local c_jungle_dirt = minetest.get_content_id("df_primordial_items:dirt_with_jungle_grass") +local c_plant_matter = minetest.get_content_id("df_primordial_items:plant_matter") +local c_packed_roots = minetest.get_content_id("df_primordial_items:packed_roots") +local c_glowstone = minetest.get_content_id("df_underworld_items:glowstone") + +local jungle_cavern_floor = function(abs_cracks, humidity, vi, area, data, data_param2) local ystride = area.ystride + local humidityfactor = humidity/100 + + data[vi] = c_jungle_dirt + + local rand = math.random() + if rand < 0.05 then + local fern_schematic = df_primordial_items.get_fern_schematic() + local rotation = (math.random(1,4)-1)*90 + mapgen_helper.place_schematic_on_data_if_it_fits(data, data_param2, area, area:position(vi+ystride), fern_schematic, rotation) + elseif rand < 0.075 then + df_primordial_items.spawn_jungle_mushroom_vm(vi+ystride, area, data) + elseif rand < 0.125 then + df_primordial_items.spawn_jungle_tree_vm(math.random(8,14), vi+ystride, area, data) + elseif rand < 0.3 then + data[vi+ystride] = jungle_plants[math.random(1,#jungle_plants)] + end end local jungle_cavern_ceiling = function(abs_cracks, vi, area, data, data_param2) + if abs_cracks < 0.25 then + data[vi] = c_glowstone + end end + local jungle_warren_ceiling = function(abs_cracks, vi, area, data, data_param2) end +--------------------------------------------------------------------------------------------------------- + local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, data) math.randomseed(minp.x + minp.y*2^8 + minp.z*2^16 + seed) -- make decorations consistent between runs @@ -143,11 +187,11 @@ local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, da local humidity = humiditymap[index2d] local jungle = nvals_cave[cave_area:transform(area, vi)] < 0 --- if jungle then --- jungle_cavern_floor(abs_cracks, vi, area, data, data_param2) --- else + if jungle then + jungle_cavern_floor(abs_cracks, humidity, vi, area, data, data_param2) + else mushroom_cavern_floor(abs_cracks, humidity, vi, area, data, data_param2) --- end + end end -------------------------------------- @@ -159,11 +203,11 @@ local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, da local abs_cracks = math.abs(cracks) local jungle = nvals_cave[cave_area:transform(area, vi)] < 0 local humidity = humiditymap[index2d] --- if jungle then --- jungle_cavern_ceiling(abs_cracks, vi, area, data, data_param2) --- else + if jungle then + jungle_cavern_ceiling(abs_cracks, vi, area, data, data_param2) + else mushroom_cavern_ceiling(abs_cracks, humidity, vi, area, data, data_param2) --- end + end end diff --git a/df_primordial_items/depends.txt b/df_primordial_items/depends.txt index 6e1e8e7..5473e9f 100644 --- a/df_primordial_items/depends.txt +++ b/df_primordial_items/depends.txt @@ -1,3 +1,4 @@ default mapgen_helper -subterrane \ No newline at end of file +subterrane +df_underworld_items \ No newline at end of file diff --git a/df_primordial_items/giant_fern.lua b/df_primordial_items/giant_fern.lua index c04f220..cb62dfc 100644 --- a/df_primordial_items/giant_fern.lua +++ b/df_primordial_items/giant_fern.lua @@ -238,6 +238,10 @@ local fern_9_nodes_tall = { local ferns = {fern_4_nodes_tall, fern_5_nodes_tall, fern_6_nodes_tall, fern_9_nodes_tall} local rotations = {0, 90, 180, 270} +df_primordial_items.get_fern_schematic = function() + return ferns[math.random(1,4)] +end + minetest.register_node("df_primordial_items:fern_sapling", { description = S("Giant Fern Sapling"), _doc_items_longdesc = df_primordial_items.doc.giant_fern_desc, @@ -254,9 +258,10 @@ minetest.register_node("df_primordial_items:fern_sapling", { use_texture_alpha = true, sunlight_propagates = true, on_construct = function(pos) - local fern = ferns[math.random(1,#ferns)] + --TODO timer + local fern = df_primordial_items.get_fern_schematic() local rotation = rotations[math.random(1,#rotations)] minetest.set_node(pos, {name="air"}) -- clear sapling so fern can replace it mapgen_helper.place_schematic(pos, fern, rotation) end, -}) \ No newline at end of file +}) diff --git a/df_primordial_items/jungle_mushroom.lua b/df_primordial_items/jungle_mushroom.lua index 88027c3..e55d48a 100644 --- a/df_primordial_items/jungle_mushroom.lua +++ b/df_primordial_items/jungle_mushroom.lua @@ -70,7 +70,7 @@ minetest.register_craftitem("df_primordial_items:diced_mushroom", { _doc_items_longdesc = df_primordial_items.doc.big_mushroom_desc, _doc_items_usagehelp = df_primordial_items.doc.big_mushroom_usage, inventory_image = "dfcaverns_mush_diced_giant_mushroom.png", - groups = {food = 1}, + groups = {food = 1, dfcaverns_cookable = 1}, on_use = minetest.item_eat(1), }) diff --git a/df_primordial_items/jungle_tree.lua b/df_primordial_items/jungle_tree.lua index 5e7ca1a..a940b75 100644 --- a/df_primordial_items/jungle_tree.lua +++ b/df_primordial_items/jungle_tree.lua @@ -46,7 +46,7 @@ minetest.register_node("df_primordial_items:jungle_leaves_glowing", { paramtype = "light", is_ground_content = false, buildable_to = true, - light_source = 4, + light_source = 2, groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, sounds = default.node_sound_leaves_defaults(), drop = { @@ -140,6 +140,17 @@ df_primordial_items.spawn_jungle_tree = function(pos) vm:update_map() end +local get_tree_nodes = function() + local rand = math.random() + if rand < 0.5 then + return c_trunk_glow, c_leaves_glow + end + if rand < 0.75 then + return c_trunk_mossy, c_leaves + end + return c_trunk, c_leaves +end + df_primordial_items.spawn_jungle_tree_vm = function(height, vi, area, data) local ystride = area.ystride local zstride = area.zstride @@ -149,10 +160,11 @@ df_primordial_items.spawn_jungle_tree_vm = function(height, vi, area, data) for i = 1, 6 do local root_column = vi + math.random(-1,1) + math.random(-1,1)*zstride if not roots_done[root_column] then + local trunknode = get_tree_nodes() for y = -2, math.random(0,1) do -- root height is 1 to 2 nodes above ground local root_index = root_column + y * ystride if buildable_to(data[root_index]) then - data[root_index] = c_trunk + data[root_index] = trunknode end end end @@ -160,9 +172,11 @@ df_primordial_items.spawn_jungle_tree_vm = function(height, vi, area, data) end -- puts a trunk node in the center and surrounds it with leaves - local branch = function(bi) + local branch = function(bi, glow) + local trunknode, leafnode if buildable_to(data[bi]) then - data[bi] = c_trunk + trunknode, leafnode = get_tree_nodes() + data[bi] = trunknode else return -- if a branch is placed in a non-viable place, don't add leaves end @@ -172,7 +186,7 @@ df_primordial_items.spawn_jungle_tree_vm = function(height, vi, area, data) if math.random() < 0.75 then local li = bi + x + z*zstride + y*ystride if buildable_to(data[li]) then - data[li] = c_leaves + data[li] = leafnode end end end @@ -183,7 +197,7 @@ df_primordial_items.spawn_jungle_tree_vm = function(height, vi, area, data) for i = 0, height-2 do local y_index = vi + i * ystride if buildable_to(data[y_index]) then - data[y_index] = c_trunk + data[y_index] = get_tree_nodes() else return -- if we hit something we can't grow through, stop. end