diff --git a/df_caverns/primordial.lua b/df_caverns/primordial.lua index 8ce5dbc..e32d760 100644 --- a/df_caverns/primordial.lua +++ b/df_caverns/primordial.lua @@ -20,6 +20,8 @@ local perlin_wave_primordial = { persist = 0.63 } +local c_air = minetest.get_content_id("air") + ----------------------------------------------------------------------------------------- -- Fungal biome @@ -50,7 +52,7 @@ local mushroom_cavern_floor = function(abs_cracks, humidity, vi, area, data, dat local rand = math.random() * math.min(abs_cracks, 1) * humidityfactor if rand < 0.001 then data[vi+ystride] = c_giant_mycelium - elseif rand < 0.01 then + elseif rand < 0.005 then local schematic = df_primordial_items.get_primordial_mushroom() 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) @@ -133,6 +135,7 @@ local c_jungle_dirt = minetest.get_content_id("df_primordial_items:dirt_with_jun 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 c_ivy = minetest.get_content_id("df_primordial_items:jungle_ivy") local jungle_cavern_floor = function(abs_cracks, humidity, vi, area, data, data_param2) local ystride = area.ystride @@ -141,13 +144,13 @@ local jungle_cavern_floor = function(abs_cracks, humidity, vi, area, data, data_ data[vi] = c_jungle_dirt local rand = math.random() - if rand < 0.05 * humidityfactor then + if rand < 0.025 * humidityfactor 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 * (1-humidityfactor) then + elseif rand < 0.05 * (1-humidityfactor) then df_primordial_items.spawn_jungle_mushroom_vm(vi+ystride, area, data) - elseif rand < 0.125 * (1-humidityfactor) then + elseif rand < 0.1 * (1-humidityfactor) 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)] @@ -157,12 +160,38 @@ end local jungle_cavern_ceiling = function(abs_cracks, vi, area, data, data_param2) if abs_cracks < 0.25 then data[vi] = c_glowstone + elseif abs_cracks > 0.75 and math.random() < 0.1 then + local ystride = area.ystride + local index = vi - ystride + for i = 1, math.random(16) do + if data[index] == c_air then + data[index] = c_ivy + index = index - ystride + else + break + end + end end end local jungle_warren_ceiling = function(abs_cracks, vi, area, data, data_param2) + if abs_cracks < 0.1 then + data[vi] = c_glowstone + end end +local jungle_warren_floor = function(abs_cracks, vi, area, data, data_param2) + local ystride = area.ystride + if abs_cracks < 0.7 then + data[vi] = c_jungle_dirt + local rand = math.random() * abs_cracks + if rand < 0.1 then + data[vi+ystride] = jungle_plants[math.random(1,#jungle_plants)] + end + elseif abs_cracks < 1 then + data[vi] = c_dirt + end +end --------------------------------------------------------------------------------------------------------- local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, data) @@ -233,11 +262,11 @@ local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, da local abs_cracks = math.abs(cracks) local jungle = nvals_cave[vi] < 0 --- if jungle then --- jungle_warren_ceiling(abs_cracks, vi, area, data, data_param2) --- else + if jungle then + jungle_warren_ceiling(abs_cracks, vi, area, data, data_param2) + else mushroom_warren_ceiling(abs_cracks, vi, area, data, data_param2) --- end + end end @@ -250,17 +279,21 @@ local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, da local abs_cracks = math.abs(cracks) local jungle = nvals_cave[vi] < 0 --- if jungle then --- jungle_warren_floor(abs_cracks, vi, area, data, data_param2) --- else + if jungle then + jungle_warren_floor(abs_cracks, vi, area, data, data_param2) + else mushroom_warren_floor(abs_cracks, vi, area, data, data_param2) --- end + end end -- columns + -- no flowstone below the Sunless Sea, replace with something else for _, vi in ipairs(node_arrays.column_nodes) do local jungle = nvals_cave[vi] < 0 if jungle then + data[vi] = c_plant_matter + else + data[vi] = c_mycelial_dirt end end @@ -276,14 +309,14 @@ subterrane.register_layer({ perlin_cave = perlin_cave_primordial, perlin_wave = perlin_wave_primordial, solidify_lava = true, - columns = { - maximum_radius = 20, - minimum_radius = 5, - node = "df_mapitems:wet_flowstone", --TODO: no flowstone below the Sunless Sea, replace with something else - weight = 0.5, - maximum_count = 60, - minimum_count = 10, - }, +-- columns = { +-- maximum_radius = 20, +-- minimum_radius = 5, +-- node = "df_mapitems:wet_flowstone", -- no flowstone below the Sunless Sea, replace with something else +-- weight = 0.5, +-- maximum_count = 60, +-- minimum_count = 10, +-- }, decorate = decorate_primordial, double_frequency = true, is_ground_content = df_caverns.is_ground_content, diff --git a/df_caverns/shared.lua b/df_caverns/shared.lua index af6a949..48ab793 100644 --- a/df_caverns/shared.lua +++ b/df_caverns/shared.lua @@ -211,7 +211,6 @@ end --------------------------------------------------------------------------------- -- This method allows subterrane to overgenerate caves without destroying any of the decorations --- Water is included so that the sunless sea won't have gaps torn in it local dfcaverns_nodes = nil local dfcaverns_mods = { "df_farming:", diff --git a/df_caverns/underworld.lua b/df_caverns/underworld.lua index e14aff3..fc6ae65 100644 --- a/df_caverns/underworld.lua +++ b/df_caverns/underworld.lua @@ -5,6 +5,7 @@ end local bones_loot_path = minetest.get_modpath("bones_loot") local c_slade = minetest.get_content_id("df_underworld_items:slade") +local c_slade_block = minetest.get_content_id("df_underworld_items:slade_block") local c_air = minetest.get_content_id("air") local c_water = minetest.get_content_id("default:water_source") @@ -60,6 +61,9 @@ local y_min = median - 2*wave_mult + floor_displace - 2*floor_mult --df_caverns.config.underworld_min = y_min +--local poisson = mapgen_helper.get_poisson_points({x=-32000, z=-32000}, {x=32000, z=32000}, 1000) +--minetest.debug(dump(poisson.objects)) + --------------------------------------------------------- -- Buildings @@ -207,21 +211,24 @@ local get_corner = function(pos) return {x = math.floor((pos.x+32) / pit_region_size) * pit_region_size - 32, z = math.floor((pos.z+32) / pit_region_size) * pit_region_size - 32} end -local mapgen_seed = tonumber(minetest.get_mapgen_setting("seed")) +local mapgen_seed = tonumber(minetest.get_mapgen_setting("seed")) % 2^21 local get_pit = function(pos) if region_mapblocks < 1 then return nil end local corner_xz = get_corner(pos) - local next_seed = math.floor(math.random() * 2^31) + local next_seed = math.floor(math.random() * 2^21) math.randomseed(corner_xz.x + corner_xz.z * 2 ^ 8 + mapgen_seed) local location = scatter_2d(corner_xz, pit_region_size, radius_pit_max + radius_pit_variance) local variance_multiplier = math.random() local radius = variance_multiplier * (radius_pit_max - 15) + 15 local variance = radius_pit_variance/2 + radius_pit_variance*variance_multiplier/2 local depth = math.random(plasma_depth_min, plasma_depth_max) + + local shaft_seed = math.random() + local shaft_location = corner_xz math.randomseed(next_seed) - return {location = location, radius = radius, variance = variance, depth = depth} + return {location = location, radius = radius, variance = variance, depth = depth}, {seed = shaft_seed, location = shaft_location} end local perlin_pit = { @@ -241,12 +248,14 @@ minetest.register_chatcommand("find_pit", { decription = "find a nearby glowing pit", func = function(name, param) local player = minetest.get_player_by_name(name) - local pit = get_pit(player:get_pos()) - minetest.chat_send_player(name, "Pit location: x=" .. math.floor(pit.location.x) .. " z=" .. math.floor(pit.location.z)) + local pit, shaft = get_pit(player:get_pos()) + if pit then + minetest.chat_send_player(name, "Pit location: x=" .. math.floor(pit.location.x) .. " z=" .. math.floor(pit.location.z)) + minetest.chat_send_player(name, "Shaft location: x=" .. math.floor(shaft.location.x) .. " z=" .. math.floor(shaft.location.z)) + end end, }) - minetest.register_on_generated(function(minp, maxp, seed) --if out of range of cave definition limits, abort @@ -264,9 +273,9 @@ minetest.register_on_generated(function(minp, maxp, seed) local nvals_wave = mapgen_helper.perlin2d("df_caverns:underworld_wave", emin, emax, perlin_wave) --cave noise for structure local nvals_zone = mapgen_helper.perlin2d("df_caverns:underworld_zone", emin, emax, perlin_zone) --building zones - local pit = get_pit(minp) + local pit, shaft = get_pit(minp) --minetest.chat_send_all(minetest.pos_to_string(pit.location)) - + local buildings = get_buildings(emin, emax, nvals_zone) local pit_uninitialized = true @@ -279,8 +288,9 @@ minetest.register_on_generated(function(minp, maxp, seed) local wave = nvals_wave[index2d] * wave_mult local floor_height = math.floor(abs_cave * floor_mult + median + floor_displace + wave) + local underside_height = y_min + math.abs(wave) / 5 local ceiling_height = math.floor(abs_cave * ceiling_mult + median + ceiling_displace + wave) - if y < floor_height and y > y_min + math.abs(wave) / 5 then -- divide wave by five to smooth out the underside of the slade, we only want the interface to ripple a little down here + if y < floor_height and y > underside_height then -- divide wave by five to smooth out the underside of the slade, we only want the interface to ripple a little down here data[vi] = c_slade if pit and pit.location.x - radius_pit_max - radius_pit_variance < maxp.x and @@ -388,6 +398,50 @@ minetest.register_on_generated(function(minp, maxp, seed) end end end + + -- puzzle shaft + local puzzle_init = nil + if pit_uninitialized and minp.x == shaft.location.x and minp.z == shaft.location.z then + local index2d = mapgen_helper.index2d(emin, emax, minp.x + 3, minp.z + 3) + local abs_cave = math.abs(nvals_cave[index2d]) -- range is from 0 to approximately 2, with 0 being connected and 2s being islands + local wave = nvals_wave[index2d] * wave_mult + + local floor_height = math.floor(abs_cave * floor_mult + median + floor_displace + wave) + local underside_height = math.floor(y_min + math.abs(wave) / 5) + + local shaftwallmin = {x=minp.x, y=math.max(underside_height-3, minp.y), z=minp.z} + local shaftwallmax = {x=minp.x+4, y=math.min(floor_height, maxp.y), z=minp.z+4} + local shaftcoremin = {x=minp.x+1, y=shaftwallmin.y, z=minp.z+1} + local shaftcoremax = {x=minp.x+3, y=math.min(floor_height+3, maxp.y), z=minp.z+3} + + minetest.debug("minp,maxp") + minetest.debug(minetest.pos_to_string(minp)) + minetest.debug(minetest.pos_to_string(maxp)) + + minetest.debug("wall") + minetest.debug(minetest.pos_to_string(shaftwallmin)) + minetest.debug(minetest.pos_to_string(shaftwallmax)) + + for wall_vi in area:iterp(shaftwallmin, shaftwallmax) do + data[wall_vi] = c_slade_block + end + + minetest.debug("core") + minetest.debug(minetest.pos_to_string(shaftcoremin)) + minetest.debug(minetest.pos_to_string(shaftcoremax)) + + for core_vi in area:iterp(shaftcoremin, shaftcoremax) do + data[core_vi] = c_air + end + + local puzzle_seal_y = floor_height-1--math.floor((floor_height+underside_height)/2) + if puzzle_seal_y < maxp.y and puzzle_seal_y > minp.y then + for seal_vi in area:iter(minp.x+1, puzzle_seal_y, minp.z+1, minp.x+3, puzzle_seal_y, minp.z+3) do + data[seal_vi] = c_slade_block + end + puzzle_init = {x=minp.x+2, y=puzzle_seal_y, z=minp.z+2} + end + end --send data back to voxelmanip vm:set_data(data) @@ -399,6 +453,9 @@ minetest.register_on_generated(function(minp, maxp, seed) --write it to world vm:write_to_map() + if puzzle_init ~= nil then + end + if bones_loot_path then for i = 1, 30 do local x = math.random(minp.x, maxp.x) diff --git a/df_primordial_items/depends.txt b/df_primordial_items/depends.txt deleted file mode 100644 index 5473e9f..0000000 --- a/df_primordial_items/depends.txt +++ /dev/null @@ -1,4 +0,0 @@ -default -mapgen_helper -subterrane -df_underworld_items \ No newline at end of file diff --git a/df_primordial_items/fungal_nodes.lua b/df_primordial_items/fungal_nodes.lua index 5b77131..9e2220a 100644 --- a/df_primordial_items/fungal_nodes.lua +++ b/df_primordial_items/fungal_nodes.lua @@ -26,7 +26,7 @@ minetest.register_node("df_primordial_items:fungal_grass_1", { }) minetest.register_node("df_primordial_items:fungal_grass_2", { - description = S("Primordial Jungle Grass"), + description = S("Primordial Fungal Grass"), _doc_items_longdesc = df_primordial_items.doc.fungal_grass_desc, _doc_items_usagehelp = df_primordial_items.doc.fungal_grass_usage, tiles = {"dfcaverns_mush_grass_02.png"}, diff --git a/df_primordial_items/giant_mycelium.lua b/df_primordial_items/giant_mycelium.lua index 596b11f..03f5c31 100644 --- a/df_primordial_items/giant_mycelium.lua +++ b/df_primordial_items/giant_mycelium.lua @@ -33,7 +33,7 @@ minetest.register_node("df_primordial_items:giant_hypha_root", { light_source = 2, is_ground_content = false, groups = {oddly_breakable_by_hand = 1, choppy = 2, hypha = 1}, - sounds = default.node_sound_wood_defaults(), + sounds = df_trees.node_sound_tree_soft_fungus_defaults(), drop = { max_items = 1, items = { @@ -60,7 +60,7 @@ minetest.register_node("df_primordial_items:giant_hypha", { light_source = 2, is_ground_content = false, groups = {oddly_breakable_by_hand = 1, choppy = 2, hypha = 1}, - sounds = default.node_sound_wood_defaults(), + sounds = df_trees.node_sound_tree_soft_fungus_defaults(), drop = { max_items = 1, items = { @@ -300,7 +300,7 @@ minetest.register_node("df_primordial_items:giant_hypha_apical_meristem", { is_ground_content = false, groups = {oddly_breakable_by_hand = 1, choppy = 2, hypha = 1, light_sensitive_fungus = 13}, _dfcaverns_dead_node = "df_primordial_items:giant_hypha_root", - sounds = default.node_sound_wood_defaults(), + sounds = df_trees.node_sound_tree_soft_fungus_defaults(), on_construct = function(pos) minetest.get_node_timer(pos):start(math.random(min_growth_delay, max_growth_delay)) end, @@ -362,7 +362,7 @@ minetest.register_node("df_primordial_items:giant_hypha_apical_mapgen", { is_ground_content = false, groups = {oddly_breakable_by_hand = 1, choppy = 2, hypha = 1, not_in_creative_inventory = 1}, - sounds = default.node_sound_wood_defaults(), + sounds = df_trees.node_sound_tree_soft_fungus_defaults(), }) local grow_mycelium_immediately = function(pos) diff --git a/df_primordial_items/jungle_mushroom.lua b/df_primordial_items/jungle_mushroom.lua index 5006c57..57cc7ed 100644 --- a/df_primordial_items/jungle_mushroom.lua +++ b/df_primordial_items/jungle_mushroom.lua @@ -13,7 +13,7 @@ minetest.register_node("df_primordial_items:jungle_mushroom_trunk", { paramtype2 = "facedir", is_ground_content = false, groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, - sounds = default.node_sound_wood_defaults(), + sounds = df_trees.node_sound_tree_soft_fungus_defaults(), on_place = minetest.rotate_node }) @@ -25,7 +25,7 @@ minetest.register_node("df_primordial_items:jungle_mushroom_cap_1", { paramtype2 = "facedir", is_ground_content = false, groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, - sounds = default.node_sound_wood_defaults(), + sounds = df_trees.node_sound_tree_soft_fungus_defaults(), on_place = minetest.rotate_node, drop = { max_items = 1, @@ -49,7 +49,7 @@ minetest.register_node("df_primordial_items:jungle_mushroom_cap_2", { paramtype2 = "facedir", is_ground_content = false, groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, - sounds = default.node_sound_wood_defaults(), + sounds = df_trees.node_sound_tree_soft_fungus_defaults(), on_place = minetest.rotate_node, drop = { max_items = 1, diff --git a/df_primordial_items/jungle_nodes.lua b/df_primordial_items/jungle_nodes.lua index ff5a001..f9ca8cd 100644 --- a/df_primordial_items/jungle_nodes.lua +++ b/df_primordial_items/jungle_nodes.lua @@ -174,19 +174,21 @@ minetest.register_node("df_primordial_items:jungle_ivy", { tiles = {"dfcaverns_jungle_ivy_01.png"}, inventory_image = "dfcaverns_jungle_ivy_01.png", wield_image = "dfcaverns_jungle_ivy_01.png", - groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1}, + groups = {snappy = 3, flora = 1, flammable = 1}, paramtype = "light", - paramtype2 = "wallmounted", - drawtype = "signlike", + drawtype = "plantlike", + place_param2 = 3, + --paramtype2 = "wallmouinted", + --drawtype = "signlike", sounds = default.node_sound_leaves_defaults(), use_texture_alpha = true, sunlight_propagates = true, is_ground_content = false, walkable = false, climbable = true, - selection_box = { - type = "wallmounted", - }, +-- selection_box = { +-- type = "wallmounted", +-- }, }) ------------------------------------------------------------------------------------- @@ -259,6 +261,18 @@ minetest.register_node("df_primordial_items:packed_roots", { sounds = default.node_sound_wood_defaults(), }) +minetest.register_abm({ + label = "Plant matter converting to roots", + nodenames = {"df_primordial_items:plant_matter"}, + interval = 10.0, + chance = 5, + action = function(pos, node, active_object_count, active_object_count_wider) + if minetest.find_node_near(pos, 1, {"air"}) == nil then + minetest.set_node(pos, {name="df_primordial_items:packed_roots"}) + end + end +}) + ---------------------------------------------------------------------------------------- -- Roots diff --git a/df_primordial_items/jungle_tree.lua b/df_primordial_items/jungle_tree.lua index 8eb1197..0128bd9 100644 --- a/df_primordial_items/jungle_tree.lua +++ b/df_primordial_items/jungle_tree.lua @@ -10,6 +10,7 @@ minetest.register_node("df_primordial_items:jungle_leaves", { drawtype = "plantlike", walkable = false, waving = 2, + visual_scale = 1.2, tiles = {"dfcaverns_jungle_leaves_01.png"}, inventory_image = "dfcaverns_jungle_leaves_01.png", wield_image = "dfcaverns_jungle_leaves_01.png", @@ -40,6 +41,7 @@ minetest.register_node("df_primordial_items:jungle_leaves_glowing", { drawtype = "plantlike", walkable = false, waving = 2, + visual_scale = 1.2, tiles = {"dfcaverns_jungle_leaves_02.png"}, inventory_image = "dfcaverns_jungle_leaves_02.png", wield_image = "dfcaverns_jungle_leaves_02.png", diff --git a/df_primordial_items/mod.conf b/df_primordial_items/mod.conf index 194ff3d..a9ad26e 100644 --- a/df_primordial_items/mod.conf +++ b/df_primordial_items/mod.conf @@ -1,3 +1,3 @@ name = df_primordial_items description = A collection of flora found in the "primordial" cavern layer of DF Caverns -depends = default, mapgen_helper, subterrane \ No newline at end of file +depends = default, mapgen_helper, subterrane, df_underworld_items, df_trees \ No newline at end of file diff --git a/df_primordial_items/primordial_mushroom.lua b/df_primordial_items/primordial_mushroom.lua index 5941be1..5597c15 100644 --- a/df_primordial_items/primordial_mushroom.lua +++ b/df_primordial_items/primordial_mushroom.lua @@ -10,7 +10,7 @@ minetest.register_node("df_primordial_items:mushroom_trunk", { paramtype2 = "facedir", is_ground_content = false, groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, - sounds = default.node_sound_wood_defaults(), + sounds = df_trees.node_sound_tree_soft_fungus_defaults(), on_place = minetest.rotate_node }) @@ -22,7 +22,7 @@ minetest.register_node("df_primordial_items:mushroom_cap", { paramtype2 = "facedir", is_ground_content = false, groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, - sounds = default.node_sound_wood_defaults(), + sounds = df_trees.node_sound_tree_soft_fungus_defaults(), on_place = minetest.rotate_node }) diff --git a/df_trees/tunnel_tube.lua b/df_trees/tunnel_tube.lua index 29dafd7..b2e5e93 100644 --- a/df_trees/tunnel_tube.lua +++ b/df_trees/tunnel_tube.lua @@ -393,6 +393,10 @@ df_trees.spawn_tunnel_tube_vm = function(vi, area, data, param2_data, height, di local previous_vi = vi local pattern = tunnel_tube_patterns[height] + if pattern == nil then + minetest.log("error", "Tunnel tube pattern was nil somehow. height: " .. string(height) .. " location: " .. minetest.pos_to_string(area:position(vi))) + return nil + end for i, nodepattern in ipairs(pattern) do local current_vi = vi + nodepattern[1] * increment if data[current_vi] == c_air or data[current_vi] == c_ignore then