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
-------------------------------------------------------------------
-- see also, fungal_tree.lua
-- player surface damage and hunger
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
end
local leaves = {}
local is_fungal_leaf = {}
for _, leaf in ipairs(fungal_tree_leaves) do
leaves[leaf] = true
is_fungal_leaf[leaf] = true
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
local spike_air = {}
spike_air['default:lava_source'] = true
@ -323,11 +331,6 @@ minetest.register_abm({
})
-- 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({
nodenames = fungal_tree_leaves,
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
minetest.set_node(grow_pos, node)
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)
return
end
@ -578,6 +581,15 @@ minetest.after(0, function()
on_blast = def.on_blast,
}
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)
local function add_effects(pos, radius)
@ -613,7 +625,9 @@ local function destroy(pos, cid)
return
end
if exploding_fungi or fungi_to_explode[cid] then
minetest.remove_node(pos)
end
end
local function explode(pos, radius)
@ -625,7 +639,6 @@ local function explode(pos, radius)
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data()
local drops = {}
local p = {}
local c_air = minetest.get_content_id("air")
@ -697,12 +710,16 @@ fun_caves.soft_boom = function(pos)
return
end
if exploding_fungi then
minetest.sound_play("tnt_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
end
local radius = 5
minetest.remove_node(pos)
explode(pos, radius)
if exploding_fungi then
entity_physics(pos, radius)
add_effects(pos, radius)
end
end
--local function burn(pos)

View file

@ -6,6 +6,7 @@ fun_caves.path = minetest.get_modpath(minetest.get_current_modname())
fun_caves.world = minetest.get_worldpath()
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.exploding_fungi = minetest.setting_getbool('fun_caves_exploding_fungi')
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.
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