Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 0a61781
Author: FaceDeer <[email protected]>
Date:   Mon Aug 1 14:50:07 2022 -0600

    add an additional check to ensure old timers don't cause inappropriate growth

commit 1d7b601
Author: FaceDeer <[email protected]>
Date:   Mon Aug 1 13:21:29 2022 -0600

    stop timers when seeds are picked up

commit c8fa25c
Author: FaceDeer <[email protected]>
Date:   Mon Aug 1 13:05:24 2022 -0600

    fix replacements for dwarven syrup taffy recipe

commit 4de45bb
Author: FaceDeer <[email protected]>
Date:   Mon Aug 1 11:09:48 2022 -0600

    account for some additional mod dependencies

commit 83ea06b
Author: FaceDeer <[email protected]>
Date:   Mon Aug 1 11:09:14 2022 -0600

    update cooking recipes to be more specific.

commit 302da3e
Author: FaceDeer <[email protected]>
Date:   Fri Jul 29 17:12:59 2022 -0600

    add location logging for debugging purposes

commit 11667e1
Author: FaceDeer <[email protected]>
Date:   Sun Jul 24 16:54:21 2022 -0600

    add checks for submods being present

    the df_trees and df_farming checks are likely redundant, but if primordial layers are disabled someone might not have df_primordial_items installed.

commit 5906308
Author: FaceDeer <[email protected]>
Date:   Sun Jul 24 16:49:23 2022 -0600

    add config settings for biome restrictions, vastly reduce copy and paste in code

commit e52820c
Author: FaceDeer <[email protected]>
Date:   Sat Jul 23 20:45:26 2022 -0600

    add initial stab at growing conditions - biome restrictions for trees

commit 7b99556
Author: FaceDeer <[email protected]>
Date:   Sat Jul 23 12:08:41 2022 -0600

    adding biome API. Not yet tested.

commit bf82b3b
Author: FaceDeer <[email protected]>
Date:   Fri Jul 22 21:22:37 2022 -0600

    added stubs for growth permission for farming plants

commit 46765df
Author: FaceDeer <[email protected]>
Date:   Fri Jul 22 18:36:45 2022 -0600

    initial work for restricted plant growth. split out growth conditions for trees, and reworked torchspine to not use ABMs while I was at it.
  • Loading branch information
FaceDeer committed Aug 1, 2022
1 parent f23d411 commit dbc5dd3
Show file tree
Hide file tree
Showing 58 changed files with 721 additions and 340 deletions.
10 changes: 9 additions & 1 deletion chasms/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ end
local c_air = minetest.get_content_id("air")
local c_web

local log_location
if mapgen_helper.log_location_enabled then
log_location = mapgen_helper.log_first_location
end

local big_webs_path = minetest.get_modpath("big_webs")
if big_webs_path then
c_web = minetest.get_content_id("big_webs:webbing")
Expand Down Expand Up @@ -145,13 +150,16 @@ minetest.register_on_generated(function(minp, maxp, seed)
webs = webs or calculate_web_array(minp, maxp) -- only calculate webs when we know we're in a chasm
if webs[y + z*z_displace] and math.random() < 0.85 then -- random holes in the web
data[i] = c_web
minetest.get_node_timer({x=x,y=y,z=z}):start(1) -- this timer will check for unsupported webs
local web_pos = vector.new(x,y,z)
minetest.get_node_timer(web_pos):start(1) -- this timer will check for unsupported webs
if log_location then log_location("chasm_web", web_pos) end
else
data[i] = c_air
end
else
data[i] = c_air
end
if log_location then log_location("chasm", vector.new(x,y,z)) end
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions df_caverns/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ setting("int", "underworld_glowing_pit_mapblocks", 8, "Average pit spacing measu
setting("bool", "enable_primordial", true, "Enable primordial cavern")
setting("int", "primordial_max", -3393, "Upper limit to primordial caverns")
setting("int", "primordial_min", -4032, "Lower limit to primordial caverns")

setting("bool", "restrict_trees_to_biomes", false, "Restrict underground tree growth to their home biomes")
setting("bool", "restrict_farmables_to_biomes", false, "Restrict underground farmable plant growth to their home biomes")
48 changes: 48 additions & 0 deletions df_caverns/growth_restrictions.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
local add_biome_restrictions = function(root_table, function_name, biome_set)
local old_function = root_table[function_name]
root_table[function_name] = function(pos)
local biome = df_caverns.get_biome(pos)
return old_function(pos) and biome_set[biome]
end
end

if df_caverns.config.restrict_trees_to_biomes then

if minetest.get_modpath("df_trees") then
add_biome_restrictions(df_trees, "black_cap_growth_permitted", {blackcap = true})
add_biome_restrictions(df_trees, "blood_thorn_growth_permitted", {bloodthorn = true})
add_biome_restrictions(df_trees, "fungiwood_growth_permitted", {fungiwood = true, fungispore = true})
add_biome_restrictions(df_trees, "goblin_cap_growth_permitted", {goblincap = true, towergoblin = true})
add_biome_restrictions(df_trees, "nether_cap_growth_permitted", {nethercap = true})
add_biome_restrictions(df_trees, "spore_tree_growth_permitted", {sporetree = true, fungispore = true})
add_biome_restrictions(df_trees, "tower_cap_growth_permitted", {towercap = true, towergoblin = true})
add_biome_restrictions(df_trees, "tunnel_tube_growth_permitted", {tunneltube = true})
-- Deliberately not biome-restricted
--add_biome_restrictions(df_trees, "torchspine_growth_permitted", {})
--add_biome_restrictions(df_trees, "spindlestem_growth_permitted", {})
end

if minetest.get_modpath("df_primordial_items") then
add_biome_restrictions(df_primordial_items, "primordial_mushroom_growth_permitted", {["primordial fungus"] = true})
add_biome_restrictions(df_primordial_items, "giant_mycelium_growth_permitted", {["primordial fungus"] = true})
add_biome_restrictions(df_primordial_items, "giant_fern_growth_permitted", {["primordial jungle"] = true})
add_biome_restrictions(df_primordial_items, "jungle_mushroom_growth_permitted", {["primordial jungle"] = true})
add_biome_restrictions(df_primordial_items, "jungletree_growth_permitted", {["primordial jungle"] = true})
end

end

if df_caverns.config.restrict_farmables_to_biomes and minetest.get_modpath("df_farming") then
add_biome_restrictions(df_farming.growth_permitted, "df_farming:cave_wheat_seed",
{fungiwood = true, tunneltube = true, sporetree = true, fungispore = true})
add_biome_restrictions(df_farming.growth_permitted, "df_farming:dimple_cup_seed",
{towergoblin = true})
add_biome_restrictions(df_farming.growth_permitted, "df_farming:pig_tail_seed",
{sporetree = true, fungispore = true})
add_biome_restrictions(df_farming.growth_permitted, "df_farming:quarry_bush_seed",
{bloodthorn = true})
add_biome_restrictions(df_farming.growth_permitted, "df_farming:sweet_pod_seed",
{tunneltube = true, fungispore = true})
add_biome_restrictions(df_farming.growth_permitted, "df_farming:plump_helmet_spawn",
{fungiwood = true, towercap = true, goblincap = true, towergoblin = true})
end
1 change: 1 addition & 0 deletions df_caverns/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ dofile(modpath.."/lava_sea.lua")
dofile(modpath.."/underworld.lua")
dofile(modpath.."/primordial.lua")
dofile(modpath.."/dungeon_loot.lua")
dofile(modpath.."/growth_restrictions.lua")
8 changes: 8 additions & 0 deletions df_caverns/lava_sea.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ local c_mese_crystal = df_caverns.node_id.mese_crystal
local c_mese_crystal_block = df_caverns.node_id.mese_crystal_block
local c_obsidian = df_caverns.node_id.obsidian

local log_location
if mapgen_helper.log_location_enabled then
log_location = mapgen_helper.log_first_location
end
-------------------------------------------------------------------------------------------

local perlin_cave = {
Expand Down Expand Up @@ -84,6 +88,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
data[vi] = c_air
else
data[vi] = c_lava
if log_location then log_location("magma_sea", area:position(vi)) end
end
elseif y > floor_height - 5 and y < ceiling_height and y <= lava_height + 2 and not mapgen_helper.buildable_to(data[vi]) then
data[vi] = c_obsidian -- thick obsidian floor
Expand Down Expand Up @@ -112,13 +117,16 @@ minetest.register_on_generated(function(minp, maxp, seed)
-- decorate ceiling
if math.random() < 0.25 then
data[vi] = c_meseore
if log_location then log_location("magma_sea_meseore", area:position(vi)) end
elseif mese_intensity > 0.75 and math.random() < 0.1 then
data[vi] = c_meseore
local bi = vi-area.ystride
data[bi] = c_mese_crystal
data_param2[bi] = math.random(1,4) + 19
if log_location then log_location("magma_sea_mesecrystal", area:position(vi)) end
elseif mese_intensity > 0.85 and math.random() < 0.025 then
subterrane.big_stalactite(vi-area.ystride, area, data, 6, 13, c_meseore, c_meseore, c_mese_crystal_block)
if log_location then log_location("magma_sea_mesebig", area:position(vi)) end
end
end
end
Expand Down
23 changes: 23 additions & 0 deletions df_caverns/level1.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ if minetest.get_modpath("df_farming") then
}
end

local log_location
if mapgen_helper.log_location_enabled then
log_location = mapgen_helper.log_first_location
end

local subsea_level = df_caverns.config.level1_min - (df_caverns.config.level1_min - df_caverns.config.ymax) * 0.33
local flooding_threshold = math.min(df_caverns.config.tunnel_flooding_threshold, df_caverns.config.cavern_threshold)

Expand All @@ -41,6 +46,13 @@ local get_biome = function(heat, humidity)
end
end

table.insert(df_caverns.get_biome_at_pos_list, function(pos, heat, humidity)
if pos.y < df_caverns.config.level1_min or pos.y > df_caverns.config.ymax then
return nil
end
return get_biome(heat, humidity)
end)

local tower_cap_cavern_floor = function(abs_cracks, vert_rand, vi, area, data, data_param2)
local ystride = area.ystride
if abs_cracks < 0.1 then
Expand Down Expand Up @@ -118,15 +130,20 @@ local decorate_level_1 = function(minp, maxp, seed, vm, node_arrays, area, data)
if minp.y < subsea_level and area:get_y(vi) < subsea_level and flooded_caverns then
-- underwater floor
df_caverns.flooded_cavern_floor(abs_cracks, vert_rand, vi, area, data)
if log_location then log_location("level1_flooded_"..biome_name, area:position(vi)) end
elseif biome_name == "towercap" then
tower_cap_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
if log_location then log_location("level1_towercap", area:position(vi)) end
elseif biome_name == "fungiwood" then
fungiwood_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
if log_location then log_location("level1_fungiwood", area:position(vi)) end
elseif biome_name == "barren" then
if flooded_caverns then
df_caverns.wet_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
if log_location then log_location("level1_barren_wet", area:position(vi)) end
else
df_caverns.dry_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
if log_location then log_location("level1_barren_dry", area:position(vi)) end
end
end
end
Expand Down Expand Up @@ -215,6 +232,12 @@ local decorate_level_1 = function(minp, maxp, seed, vm, node_arrays, area, data)
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local ystride = area.ystride

if log_location then
local flood_name = ""
if flooded_caverns then flood_name = "_flooded" end
log_location("level1_warren_"..biome_name..flood_name, area:position(vi))
end

if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then
if flooded_caverns or biome_name ~= "barren" then
-- we're in flooded areas or are not barren
Expand Down
26 changes: 25 additions & 1 deletion df_caverns/level2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ local c_pearls = df_caverns.node_id.pearls

local chasms_path = minetest.get_modpath("chasms")

local log_location
if mapgen_helper.log_location_enabled then
log_location = mapgen_helper.log_first_location
end

local wall_vein_perlin_params = {
offset = 0,
Expand Down Expand Up @@ -43,6 +47,13 @@ local get_biome = function(heat, humidity)
end
end

table.insert(df_caverns.get_biome_at_pos_list, function(pos, heat, humidity)
if pos.y < df_caverns.config.level2_min or pos.y >= df_caverns.config.level1_min then
return nil
end
return get_biome(heat, humidity)
end)

local goblin_cap_shrublist
local tunnel_tube_shrublist
local spore_tree_shrublist
Expand Down Expand Up @@ -161,6 +172,7 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data)
if data[vi] == c_air and math.abs(vein_noise[vein_area:transform(area, vi)]) < 0.02 then
data[vi] = c_veinstone
end
if log_location then log_location("level2_veinstone", area:position(vi)) end
end
end
if data[vi] == c_air and y <= subsea_level then
Expand All @@ -182,18 +194,24 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data)
if minp.y < subsea_level and area:get_y(vi) < subsea_level and flooded_caverns then
-- underwater floor
df_caverns.flooded_cavern_floor(abs_cracks, vert_rand, vi, area, data)
if log_location then log_location("level2_flooded_"..biome_name, area:position(vi)) end
elseif biome_name == "barren" then
if flooded_caverns then
df_caverns.wet_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
if log_location then log_location("level2_barren_wet", area:position(vi)) end
else
df_caverns.dry_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
if log_location then log_location("level2_barren_dry", area:position(vi)) end
end
elseif biome_name == "goblincap" then
goblin_cap_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
goblin_cap_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
if log_location then log_location("level2_goblincap", area:position(vi)) end
elseif biome_name == "sporetree" then
spore_tree_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
if log_location then log_location("level2_sporetree", area:position(vi)) end
elseif biome_name == "tunneltube" then
tunnel_tube_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
if log_location then log_location("level2_tunneltube", area:position(vi)) end
end
end

Expand Down Expand Up @@ -296,6 +314,12 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.

if log_location then
local flood_name = ""
if flooded_caverns then flood_name = "_flooded" end
log_location("level2_warren_"..biome_name..flood_name, area:position(vi))
end

if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then
if flooded_caverns or biome_name ~= "barren" then
-- we're in flooded areas or are not barren
Expand Down
37 changes: 35 additions & 2 deletions df_caverns/level3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ local c_webs_egg = df_caverns.node_id.big_webs_egg

local chasms_path = minetest.get_modpath("chasms")

local log_location
if mapgen_helper.log_location_enabled then
log_location = mapgen_helper.log_first_location
end

local subsea_level = math.floor(df_caverns.config.level3_min - (df_caverns.config.level3_min - df_caverns.config.level2_min) * 0.33)
local flooding_threshold = math.min(df_caverns.config.tunnel_flooding_threshold, df_caverns.config.cavern_threshold)

Expand All @@ -36,6 +41,20 @@ local get_biome = function(heat, humidity)
end
end

table.insert(df_caverns.get_biome_at_pos_list, function(pos, heat, humidity)
if pos.y < df_caverns.config.level3_min or pos.y >= df_caverns.config.level2_min then
return nil
end
local biome = get_biome(heat, humidity)
if biome == "bloodnether" then
if subterrane.get_cavern_value("cavern layer 3", pos) < 0 then
return "nethercap"
end
return "bloodthorn"
end
return biome
end)

local black_cap_shrublist
local nether_cap_shrublist
local blood_thorn_shrublist
Expand Down Expand Up @@ -214,10 +233,12 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data)
-- oil slick
if y == subsea_level and data[vi] == c_water and math.abs(cave) + nvals_cracks[index2d]*0.025 < cavern_def.cave_threshold + 0.1 then
data[vi] = c_oil
if log_location then log_location("level3_blackcap_oil", vector.new(x,y,z)) end
end
elseif biome_name == "bloodnether" and y <= subsea_level and y > subsea_level - ice_thickness and data[vi] == c_water then
-- floating ice
data[vi] = c_ice
if log_location then log_location("level3_nethercap_floating_ice", vector.new(x,y,z)) end
end
end
end
Expand All @@ -236,7 +257,7 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data)
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.

if flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level then
-- underwater floor
-- underwater floor. Not using df_caverns.flooded_cavern_floor to make level 3 water darker
local ystride = area.ystride
if abs_cracks > 0.25 and data[vi-ystride] ~= c_water then
data[vi] = c_gravel
Expand All @@ -247,25 +268,31 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data)
subterrane.big_stalagmite(vi+ystride, area, data, 6, 15, c_wet_flowstone, c_wet_flowstone, c_wet_flowstone)
end
end
if log_location then log_location("level3_flooded_"..biome_name, area:position(vi)) end
elseif biome_name == "barren" then
if flooded_caverns then
-- wet zone floor
df_caverns.dry_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
if log_location then log_location("level3_barren_dry", area:position(vi)) end
else
-- dry zone floor, add crystals
if abs_cracks < 0.075 then
df_caverns.stalagmites(abs_cracks, vert_rand, vi, area, data, data_param2, false)
elseif abs_cracks > 0.3 and math.random() < 0.005 then
df_mapitems.place_big_crystal_cluster(area, data, data_param2, vi+area.ystride, math.random(0,2), false)
end
if log_location then log_location("level3_barren_wet", area:position(vi)) end
end
elseif biome_name == "blackcap" then
black_cap_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
black_cap_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
if log_location then log_location("level3_blackcap", area:position(vi)) end
elseif biome_name == "bloodnether" then
if flooded_caverns then
nether_cap_cavern_floor(cracks, abs_cracks, vert_rand, vi, area, data, data_param2)
if log_location then log_location("level3_nethercap", area:position(vi)) end
else
blood_thorn_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
if log_location then log_location("level3_bloodthorn", area:position(vi)) end
end
end
end
Expand Down Expand Up @@ -396,6 +423,12 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.

if log_location then
local flood_name = ""
if flooded_caverns then flood_name = "_flooded" end
log_location("level3_warren_"..biome_name..flood_name, area:position(vi))
end

if flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level then
-- underwater ceiling, do nothing
elseif biome_name == "bloodnether" and flooded_caverns then
Expand Down
6 changes: 6 additions & 0 deletions df_caverns/oil_sea.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ local c_gas_wisp = df_caverns.node_id.gas_wisp
local c_lava = df_caverns.node_id.lava
local c_obsidian = df_caverns.node_id.obsidian

local log_location
if mapgen_helper.log_location_enabled then
log_location = mapgen_helper.log_first_location
end

-------------------------------------------------------------------------------------------

local perlin_cave = {
Expand Down Expand Up @@ -86,6 +91,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
else
data[vi] = c_oil
if log_location then log_location("oil_sea", area:position(vi)) end
end
end

Expand Down
Loading

0 comments on commit dbc5dd3

Please sign in to comment.