Add an option for non-violent explosions.

This commit is contained in:
Duane 2016-06-24 11:07:24 -05:00
parent 9325a474b5
commit 99c9c18ed8
3 changed files with 37 additions and 16 deletions

View file

@ -2,8 +2,6 @@
-- Abms -- Abms
------------------------------------------------------------------- -------------------------------------------------------------------
-- see also, fungal_tree.lua
-- player surface damage and hunger -- player surface damage and hunger
local dps_delay = 3 local dps_delay = 3
@ -26,11 +24,21 @@ for i = 1, 4 do
fungal_tree_leaves[#fungal_tree_leaves+1] = "fun_caves:fungal_tree_leaves_"..i fungal_tree_leaves[#fungal_tree_leaves+1] = "fun_caves:fungal_tree_leaves_"..i
end end
local leaves = {} local is_fungal_leaf = {}
for _, leaf in ipairs(fungal_tree_leaves) do for _, leaf in ipairs(fungal_tree_leaves) do
leaves[leaf] = true is_fungal_leaf[leaf] = true
end end
local fungal_nodes = {}
for _, leaf in pairs(fungal_tree_leaves) do
fungal_nodes[#fungal_nodes+1] = {name = leaf}
end
fungal_nodes[#fungal_nodes+1] = {name = 'fun_caves:fungal_tree_fruit'}
local fungi_to_explode = {} -- see below
local exploding_fungi = fun_caves.exploding_fungi
-- hot spike parameters -- hot spike parameters
local spike_air = {} local spike_air = {}
spike_air['default:lava_source'] = true spike_air['default:lava_source'] = true
@ -323,11 +331,6 @@ minetest.register_abm({
}) })
-- fungal spread -- fungal spread
local fungal_nodes = {}
for _, leaf in pairs(fungal_tree_leaves) do
fungal_nodes[#fungal_nodes+1] = {name = leaf}
end
fungal_nodes[#fungal_nodes+1] = {name = 'fun_caves:fungal_tree_fruit'}
minetest.register_abm({ minetest.register_abm({
nodenames = fungal_tree_leaves, nodenames = fungal_tree_leaves,
neighbors = {"air", "group:liquid"}, neighbors = {"air", "group:liquid"},
@ -352,7 +355,7 @@ minetest.register_abm({
if grow_node and grow_node.name == "air" and (minetest.get_node_light(grow_pos, nil) or 99) <= fun_caves.light_max then if grow_node and grow_node.name == "air" and (minetest.get_node_light(grow_pos, nil) or 99) <= fun_caves.light_max then
minetest.set_node(grow_pos, node) minetest.set_node(grow_pos, node)
return return
elseif grow_node and leaves[grow_node.name] and grow_node.name ~= node.name then elseif grow_node and is_fungal_leaf[grow_node.name] and grow_node.name ~= node.name then
minetest.remove_node(grow_pos) minetest.remove_node(grow_pos)
return return
end end
@ -578,6 +581,15 @@ minetest.after(0, function()
on_blast = def.on_blast, on_blast = def.on_blast,
} }
end end
-- This also has to be done after content ids are established.
for i = 1, 4 do
fungi_to_explode[minetest.get_content_id("fun_caves:fungal_tree_leaves_"..i)] = true
end
fungi_to_explode[minetest.get_content_id('fun_caves:fungal_tree_fruit')] = true
fungi_to_explode[minetest.get_content_id('fun_caves:giant_mushroom_cap')] = true
fungi_to_explode[minetest.get_content_id('fun_caves:giant_mushroom_stem')] = true
fungi_to_explode[minetest.get_content_id('fun_caves:huge_mushroom_cap')] = true
end) end)
local function add_effects(pos, radius) local function add_effects(pos, radius)
@ -613,8 +625,10 @@ local function destroy(pos, cid)
return return
end end
if exploding_fungi or fungi_to_explode[cid] then
minetest.remove_node(pos) minetest.remove_node(pos)
end end
end
local function explode(pos, radius) local function explode(pos, radius)
local pos = vector.round(pos) local pos = vector.round(pos)
@ -625,7 +639,6 @@ local function explode(pos, radius)
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp}) local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data() local data = vm:get_data()
local drops = {}
local p = {} local p = {}
local c_air = minetest.get_content_id("air") local c_air = minetest.get_content_id("air")
@ -697,13 +710,17 @@ fun_caves.soft_boom = function(pos)
return return
end end
if exploding_fungi then
minetest.sound_play("tnt_explode", {pos=pos, gain=1.5, max_hear_distance=2*64}) minetest.sound_play("tnt_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
end
local radius = 5 local radius = 5
minetest.remove_node(pos) minetest.remove_node(pos)
explode(pos, radius) explode(pos, radius)
if exploding_fungi then
entity_physics(pos, radius) entity_physics(pos, radius)
add_effects(pos, radius) add_effects(pos, radius)
end end
end
--local function burn(pos) --local function burn(pos)
-- minetest.get_node_timer(pos):start(1) -- minetest.get_node_timer(pos):start(1)

View file

@ -6,6 +6,7 @@ fun_caves.path = minetest.get_modpath(minetest.get_current_modname())
fun_caves.world = minetest.get_worldpath() fun_caves.world = minetest.get_worldpath()
fun_caves.elixir_armor = minetest.setting_getbool('fun_caves_use_armor_elixirs') fun_caves.elixir_armor = minetest.setting_getbool('fun_caves_use_armor_elixirs')
fun_caves.expire_elixir_on_death = minetest.setting_getbool('fun_caves_expire_elixir_on_death') fun_caves.expire_elixir_on_death = minetest.setting_getbool('fun_caves_expire_elixir_on_death')
fun_caves.exploding_fungi = minetest.setting_getbool('fun_caves_exploding_fungi')
fun_caves.DEBUG = false -- for maintenance only fun_caves.DEBUG = false -- for maintenance only

View file

@ -3,3 +3,6 @@ fun_caves_use_armor_elixirs (Use Armor Elixirs) bool true
# If set, you will lose the effects of elixirs when you die. # If set, you will lose the effects of elixirs when you die.
fun_caves_expire_elixir_on_death (Elixirs Expire On Death) bool true fun_caves_expire_elixir_on_death (Elixirs Expire On Death) bool true
# Unset this to remove exploding fungi from the underworld.
fun_caves_exploding_fungi (Exploding Fungi) bool true