From bc07e123ce0380e5c1e0ddcebb5611de11945d58 Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Sun, 7 Aug 2022 14:27:29 -0600 Subject: [PATCH] 'splosions! --- df_dependencies/helper_functions.lua | 11 +++++++ df_dependencies/mod.conf | 2 +- df_dependencies/nodes.lua | 5 ++++ df_dependencies/sounds.lua | 1 + df_trees/config.lua | 3 +- df_trees/tunnel_tube.lua | 44 ++++++++++++++++++---------- df_underworld_items/glow_stone.lua | 3 +- df_underworld_items/puzzle_seal.lua | 6 ++-- df_underworld_items/slade.lua | 2 +- mine_gas/init.lua | 4 ++- 10 files changed, 58 insertions(+), 23 deletions(-) diff --git a/df_dependencies/helper_functions.lua b/df_dependencies/helper_functions.lua index e15908c..26a0149 100644 --- a/df_dependencies/helper_functions.lua +++ b/df_dependencies/helper_functions.lua @@ -180,4 +180,15 @@ df_dependencies.register_all_stairs_and_fences = function(name, override_def) df_dependencies.register_stairs(name, override_def) df_dependencies.register_more_stairs(name, override_def) df_dependencies.register_all_fences(name, override_def) +end + +df_dependencies.mods_required.tnt = true +df_dependencies.mods_required.mcl_explosions = true + +if minetest.get_modpath("tnt") then + df_dependencies.tnt_boom = tnt.boom +elseif minetest.get_modpath("mcl_explosions") then + df_dependencies.tnt_boom = function(pos, def) + mcl_explosions.explode(pos, def.radius) + end end \ No newline at end of file diff --git a/df_dependencies/mod.conf b/df_dependencies/mod.conf index 465ccec..846f1af 100644 --- a/df_dependencies/mod.conf +++ b/df_dependencies/mod.conf @@ -1,4 +1,4 @@ name = df_dependencies description = A utility mod for df_caverns that gathers all dependencies on minetest_game in one place, to ease compatibility efforts with mineclone and other such games depends = -optional_depends = beds, bucket, default, doors, farming, fireflies, mcl_beds, mcl_buckets, mcl_chests, mcl_compatibility, mcl_copper, mcl_core, mcl_doors, mcl_farming, mcl_furnaces, mcl_init, mcl_lanterns, mcl_mapgen, mcl_mobitems, mcl_ocean, mcl_potions, mcl_sounds, mcl_strongholds, mcl_torches, mcl_wool, mcl_worlds, mclx_core, mesecons, moreblocks, stairs, vessels, wool, mcl_stairs \ No newline at end of file +optional_depends = beds, bucket, default, doors, farming, fireflies, mcl_beds, mcl_buckets, mcl_chests, mcl_compatibility, mcl_copper, mcl_core, mcl_doors, mcl_explosions, mcl_farming, mcl_fences, mcl_furnaces, mcl_init, mcl_mapgen, mcl_mobitems, mcl_ocean, mcl_potions, mcl_sounds, mcl_stairs, mcl_strongholds, mcl_tnt, mcl_torches, mcl_wool, mcl_worlds, mclx_core, mesecons, moreblocks, stairs, tnt, vessels, wool \ No newline at end of file diff --git a/df_dependencies/nodes.lua b/df_dependencies/nodes.lua index ad84269..b21d5bf 100644 --- a/df_dependencies/nodes.lua +++ b/df_dependencies/nodes.lua @@ -99,3 +99,8 @@ df_dependencies.node_name_stair_inner_slade_brick = select_required("stairs:stai df_dependencies.node_name_stair_outer_slade_brick = select_required("stairs:stair_outer_slade_brick", "mcl_stairs:stair_slade_brick_outer") df_dependencies.node_name_stair_slade_block = select_required("stairs:stair_slade_block", "mcl_stairs:stair_slade_block") df_dependencies.node_name_stair_slade_brick = select_required("stairs:stair_slade_brick", "mcl_stairs:stair_slade_brick") + +-- from "tnt" + +-- TODO: make optional +df_dependencies.node_name_gunpowder = select_required("tnt:gunpowder", "mcl_mobitems:gunpowder") \ No newline at end of file diff --git a/df_dependencies/sounds.lua b/df_dependencies/sounds.lua index 392b868..95f9031 100644 --- a/df_dependencies/sounds.lua +++ b/df_dependencies/sounds.lua @@ -35,3 +35,4 @@ df_dependencies.soundfile_grass_footstep = select_required({default="default_gra df_dependencies.soundfile_snow_footstep = select_required({default="default_snow_footstep", mcl_sounds="pedology_snow_soft_footstep"}) df_dependencies.soundfile_gravel_footstep = select_required({default="default_gravel_footstep", mcl_sounds="default_gravel_footstep"}) df_dependencies.soundfile_cool_lava = select_required({default="default_cool_lava", mcl_sounds="default_cool_lava"}) +df_dependencies.soundfile_tnt_ignite = select_required({default="tnt_ignite", mcl_tnt="tnt_ignite"}) \ No newline at end of file diff --git a/df_trees/config.lua b/df_trees/config.lua index c45f015..41f4f86 100644 --- a/df_trees/config.lua +++ b/df_trees/config.lua @@ -43,7 +43,8 @@ for _, tree in pairs(trees) do setting("float", tree.name.."_delay_multiplier", tree.delay_multiplier, tree.name.." growth delay multiplier") end -if minetest.get_modpath("tnt") then +-- TODO: mineclone settings +if df_dependencies.tnt_boom then df_trees.config.enable_tnt = minetest.settings:get_bool("enable_tnt") if df_trees.config.enable_tnt == nil then -- Default to enabled when in singleplayer diff --git a/df_trees/tunnel_tube.lua b/df_trees/tunnel_tube.lua index 9cab322..dc85fb4 100644 --- a/df_trees/tunnel_tube.lua +++ b/df_trees/tunnel_tube.lua @@ -180,12 +180,22 @@ minetest.register_craft({ -- TNT ----------------------------------------------------------------------------------------------------------- + +local gunpowder = df_dependencies.node_name_gunpowder +local tnt_ignite_sound = df_dependencies.soundfile_tnt_ignite +local tnt_boom = df_dependencies.tnt_boom + if df_trees.config.enable_tnt then local tnt_radius = tonumber(minetest.settings:get("tnt_radius") or 3) * 2/3 local tnt_def = {radius = tnt_radius, damage_radius = tnt_radius * 2} local torch_item = df_trees.node_names.torch + local on_burn = function(pos) + minetest.swap_node(pos, {name = "df_trees:tunnel_tube_fruiting_body_burning"}) + minetest.registered_nodes["df_trees:tunnel_tube_fruiting_body_burning"].on_construct(pos) + end + minetest.register_node("df_trees:tunnel_tube_fruiting_body", { description = S("Tunnel Tube Fruiting Body"), _doc_items_longdesc = df_trees.doc.tunnel_tube_desc, @@ -204,11 +214,11 @@ if df_trees.config.enable_tnt then rarity = 2, }, { - items = {'df_trees:tunnel_tube_sapling', 'tnt:gunpowder'}, + items = {'df_trees:tunnel_tube_sapling', gunpowder}, rarity = 2, }, { - items = {'df_trees:tunnel_tube_sapling', 'tnt:gunpowder 2'}, + items = {'df_trees:tunnel_tube_sapling', gunpowder .. ' 2'}, rarity = 2, }, }, @@ -224,25 +234,22 @@ if df_trees.config.enable_tnt then end end, on_blast = function(pos, intensity) + minetest.swap_node(pos, {name="air"}) minetest.after(0.1, function() - tnt.boom(pos, tnt_def) + tnt_boom(pos, tnt_def) end) end, mesecons = {effector = {action_on = function(pos) - tnt.boom(pos, tnt_def) + minetest.swap_node(pos, {name="air"}) + tnt_boom(pos, tnt_def) end } }, - on_burn = function(pos) - minetest.swap_node(pos, {name = "df_trees:tunnel_tube_fruiting_body_burning"}) - minetest.registered_nodes["df_trees:tunnel_tube_fruiting_body_burning"].on_construct(pos) - end, - on_ignite = function(pos, igniter) - minetest.swap_node(pos, {name = "df_trees:tunnel_tube_fruiting_body_burning"}) - minetest.registered_nodes["df_trees:tunnel_tube_fruiting_body_burning"].on_construct(pos) - end, + on_burn = on_burn, + on_ignite = on_burn, + _on_burn = on_burn, }) minetest.register_node("df_trees:tunnel_tube_fruiting_body_burning", { @@ -258,12 +265,17 @@ if df_trees.config.enable_tnt then _mcl_blast_resistance = 0, _mcl_hardness = 2, on_timer = function(pos, elapsed) - tnt.boom(pos, tnt_def) + minetest.swap_node(pos, {name="air"}) + tnt_boom(pos, tnt_def) + end, + on_blast = function(pos) + minetest.swap_node(pos, {name="air"}) + minetest.after(0.1, function() + tnt_boom(pos, tnt_def) + end) end, - -- unaffected by explosions - on_blast = function() end, on_construct = function(pos) - minetest.sound_play("tnt_ignite", {pos = pos}) + minetest.sound_play(tnt_ignite_sound, {pos = pos}) minetest.get_node_timer(pos):start(4) end, }) diff --git a/df_underworld_items/glow_stone.lua b/df_underworld_items/glow_stone.lua index e774d7d..25593aa 100644 --- a/df_underworld_items/glow_stone.lua +++ b/df_underworld_items/glow_stone.lua @@ -27,9 +27,10 @@ local glowstone_def = { _mcl_blast_resistance = 0.5, _mcl_hardness = 0.5, } +local tnt_boom = df_dependencies.tnt_boom if minetest.get_modpath("tnt") then glowstone_def.on_dig = function(pos, node, digger) - tnt.boom(pos, {radius=3}) + tnt_boom(pos, {radius=3}) end end minetest.register_node("df_underworld_items:glowstone", glowstone_def) \ No newline at end of file diff --git a/df_underworld_items/puzzle_seal.lua b/df_underworld_items/puzzle_seal.lua index 20d041a..9825bb3 100644 --- a/df_underworld_items/puzzle_seal.lua +++ b/df_underworld_items/puzzle_seal.lua @@ -245,6 +245,8 @@ minetest.register_node("df_underworld_items:puzzle_seal", puzzle_seal_def) -------------------------------------------------------------------------------- -- Once the seal is opened, it turns into this and digs its way down through the slade. +local tnt_boom = df_dependencies.tnt_boom + local digging_seal_def = { description = S("Active Slade Breacher"), _doc_items_longdesc = nil, @@ -310,7 +312,7 @@ local digging_seal_def = { }) if minetest.get_item_group(below_node.name, "slade") == 0 then - tnt.boom({x=pos.x, y=pos.y-2, z=pos.z}, {radius=3}) + tnt_boom({x=pos.x, y=pos.y-2, z=pos.z}, {radius=3}) minetest.set_node(pos, {name=lava_source}) return end @@ -329,7 +331,7 @@ local digging_seal_def = { minetest.place_schematic({x=pos.x-3, y=pos.y-2, z=pos.z-3}, df_underworld_items.seal_stair_schem, 270, {}, true) node.param2 = 0 else - tnt.boom(pos, {radius=3}) + tnt_boom(pos, {radius=3}) minetest.set_node(pos, {name=lava_source}) return end diff --git a/df_underworld_items/slade.lua b/df_underworld_items/slade.lua index a6bcc24..f5dacf7 100644 --- a/df_underworld_items/slade.lua +++ b/df_underworld_items/slade.lua @@ -72,7 +72,7 @@ local slade_wall_def = { tiles = {"dfcaverns_slade_brick.png"}, walkable = true, is_ground_content = false, - groups = { cracky=3, stone=1, level=3, slade=1, pit_plasma_resistant=1, mese_radiation_shield=1}, + groups = { cracky=3, stone=1, level=3, slade=1, pit_plasma_resistant=1, mese_radiation_shield=1, wall=1}, sounds = df_underworld_items.sounds.slade, _mcl_blast_resistance = 1200, _mcl_hardness = 50, diff --git a/mine_gas/init.lua b/mine_gas/init.lua index cf61c32..299e88f 100644 --- a/mine_gas/init.lua +++ b/mine_gas/init.lua @@ -145,6 +145,8 @@ minetest.register_abm({ end, }) +local tnt_boom = df_dependencies.tnt_boom + if minetest.get_modpath("tnt") then minetest.register_abm({ label = "mine_gas:gas ignition", @@ -155,7 +157,7 @@ if minetest.get_modpath("tnt") then catch_up = true, action = function(pos, node) if minetest.find_node_near(pos, 1, "air") then - tnt.boom(pos, {radius=1, damage_radius=6}) + tnt_boom(pos, {radius=1, damage_radius=6}) -- One in a hundred explosions will spawn a gas wisp if math.random() < 0.01 then minetest.set_node(pos, {name="mine_gas:gas_wisp"})