Remove everything except the caves.
This commit is contained in:
parent
e5e7475476
commit
6cb7f1da1d
205 changed files with 1251 additions and 15326 deletions
662
abms.lua
662
abms.lua
|
@ -1,22 +1,20 @@
|
|||
-- Fun_Caves abms.lua
|
||||
-- Copyright Duane Robertson (duane@duanerobertson.com), 2017
|
||||
-- Distributed under the LGPLv2.1 (https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html)
|
||||
|
||||
|
||||
-------------------------------------------------------------------
|
||||
-- Abms
|
||||
-------------------------------------------------------------------
|
||||
|
||||
-- player surface damage and hunger
|
||||
-- player surface damage
|
||||
local dps_delay = 3
|
||||
|
||||
local last_dps_check = 0
|
||||
local cold_delay = 5
|
||||
local monster_delay = 3
|
||||
local hunger_delay = 60
|
||||
local dps_count = hunger_delay
|
||||
local dungeon_monster_density = 5
|
||||
local players_in_orbit = {}
|
||||
|
||||
local dps_count = cold_delay
|
||||
local mushrooms = {"flowers:mushroom_brown", "flowers:mushroom_red"}
|
||||
|
||||
local time_factor = (fun_caves.time_factor or 10)
|
||||
local light_max = (fun_caves.light_max or 10)
|
||||
local time_factor = (fun_caves_mod.time_factor or 10)
|
||||
local light_max = (fun_caves_mod.light_max or 10)
|
||||
|
||||
|
||||
-- fungal tree nodes
|
||||
|
@ -37,7 +35,7 @@ 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
|
||||
local exploding_fungi = fun_caves_mod.exploding_fungi
|
||||
if not exploding_fungi then
|
||||
exploding_fungi = {}
|
||||
end
|
||||
|
@ -58,70 +56,26 @@ spike_soil['fun_caves:black_sand'] = true
|
|||
-- all the fun_caves globalstep functions
|
||||
------------------------------------------------------------
|
||||
local hot_stuff = {"group:surface_hot"}
|
||||
local traps = {"group:trap"}
|
||||
local cold_stuff = {"group:surface_cold"}
|
||||
local poison_stuff = {"group:poison"}
|
||||
local gravity_off = {gravity = 0.1}
|
||||
local gravity_on = {gravity = 1}
|
||||
local dungeon_group = {'group:dungeon'}
|
||||
|
||||
local firework_active = false
|
||||
local function firework()
|
||||
local t = minetest.get_timeofday()
|
||||
if not (t and type(t) == 'number') then
|
||||
return
|
||||
end
|
||||
|
||||
if not firework_active and (t < 0.25 or t > 0.75) then
|
||||
firework_active = true
|
||||
local ps = {}
|
||||
local players = minetest.get_connected_players()
|
||||
if not (players and type(players) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, #players do
|
||||
local pp = players[i]:getpos()
|
||||
if pp and pp.y > 0 then
|
||||
local sky = {}
|
||||
sky.bgcolor, sky.type, sky.textures = players[i]:get_sky()
|
||||
ps[#ps+1] = { p = players[i], sky = sky }
|
||||
--players[i]:set_sky(0xffffff, "plain", {})
|
||||
players[i]:set_sky('#000000', 'skybox', {'fun_caves_firework_'..math.random(3)..'.png', 'fun_caves_blank.png', 'fun_caves_blank.png', 'fun_caves_blank.png', 'fun_caves_blank.png', 'fun_caves_blank.png'})
|
||||
end
|
||||
minetest.sound_play("fireworks", {gain = 1, pos = pp, max_hear_distance = 2})
|
||||
end
|
||||
minetest.after(4, function()
|
||||
for i = 1, #ps do
|
||||
ps[i].p:set_sky(ps[i].sky.bgcolor, ps[i].sky.type, ps[i].sky.textures)
|
||||
end
|
||||
firework_active = false
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local sparking = {}
|
||||
local minetest_find_nodes_in_area = minetest.find_nodes_in_area
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
if not (dtime and type(dtime) == 'number') then
|
||||
return
|
||||
end
|
||||
|
||||
if not (fun_caves.db.status and fun_caves.registered_status) then
|
||||
return
|
||||
end
|
||||
|
||||
local time = minetest.get_gametime()
|
||||
if not (time and type(time) == 'number') then
|
||||
return
|
||||
end
|
||||
|
||||
-- Trap check
|
||||
if last_dps_check and time - last_dps_check < 1 then
|
||||
return
|
||||
end
|
||||
-- Execute only after an interval.
|
||||
if not last_dps_check or time - last_dps_check < dps_delay then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local minetest_find_nodes_in_area = minetest.find_nodes_in_area
|
||||
local players = minetest.get_connected_players()
|
||||
if not (players and type(players) == 'table') then
|
||||
return
|
||||
|
@ -133,182 +87,53 @@ minetest.register_globalstep(function(dtime)
|
|||
pos = vector.round(pos)
|
||||
local player_name = player:get_player_name()
|
||||
|
||||
local minp = vector.subtract(pos, 2)
|
||||
local maxp = vector.add(pos, 2)
|
||||
local counts = minetest_find_nodes_in_area(minp, maxp, traps)
|
||||
if counts and type(counts) == 'table' and #counts > 0 then
|
||||
for _, tpos in ipairs(counts) do
|
||||
local node = minetest.get_node_or_nil(tpos)
|
||||
if not node then
|
||||
return
|
||||
end
|
||||
if node.name == 'fun_caves:stone_with_coal_trap' then
|
||||
minetest.set_node(tpos, {name="fire:basic_flame"})
|
||||
-- environmental damage
|
||||
if fun_caves_mod.DEBUG and player:get_hp() < 20 then
|
||||
-- Regenerate the player while testing.
|
||||
print("HP: "..player:get_hp())
|
||||
player:set_hp(20)
|
||||
return
|
||||
else
|
||||
local minp = vector.subtract(pos, 0.5)
|
||||
local maxp = vector.add(pos, 0.5)
|
||||
|
||||
local hp = player:get_hp()
|
||||
if hp > 0 then
|
||||
player:set_hp(hp - 1)
|
||||
end
|
||||
elseif node.name == 'fun_caves:stone_with_diamond_trap' then
|
||||
fun_caves.diamond_trap(tpos, player)
|
||||
elseif node.name == 'fun_caves:stone_with_gold_trap' then
|
||||
fun_caves.gold_trap(tpos, player)
|
||||
elseif node.name == 'fun_caves:mossycobble_trap' then
|
||||
player:set_physics_override({speed = 0.1})
|
||||
minetest.after(1, function() -- this effect is temporary
|
||||
player:set_physics_override({speed = 1}) -- we'll just set it to 1 and be done.
|
||||
end)
|
||||
elseif node.name == 'fun_caves:ice_trap' then
|
||||
fun_caves.ice_trap(tpos, player)
|
||||
elseif node.name == 'fun_caves:stone_with_copper_trap' or node.name == 'fun_caves:stone_with_iron_trap' then
|
||||
if not sparking[player_name] then
|
||||
sparking[player_name] = true
|
||||
fun_caves.copper_trap(tpos, player)
|
||||
-- ... from standing on or near hot objects.
|
||||
local counts = minetest_find_nodes_in_area(minp, maxp, hot_stuff)
|
||||
if not (counts and type(counts) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.after(1, function()
|
||||
sparking[player_name] = nil
|
||||
end)
|
||||
end
|
||||
else
|
||||
minetest.remove_node(tpos)
|
||||
end
|
||||
end
|
||||
end
|
||||
if #counts > 1 then
|
||||
player:set_hp(player:get_hp() - 1)
|
||||
end
|
||||
|
||||
-- Execute only after an interval.
|
||||
if last_dps_check and time - last_dps_check > dps_delay then
|
||||
if pos.y >= 11168 and pos.y <= 15168 then
|
||||
if not players_in_orbit[player_name] then
|
||||
player:set_physics_override(gravity_off)
|
||||
player:set_sky("#000000", "plain")
|
||||
players_in_orbit[player_name] = true
|
||||
end
|
||||
elseif players_in_orbit[player_name] then
|
||||
player:set_sky("#000000", "regular")
|
||||
minetest.after(20, function()
|
||||
player:set_physics_override(gravity_on)
|
||||
end)
|
||||
players_in_orbit[player_name] = false
|
||||
end
|
||||
-- ... from standing on or near poison.
|
||||
local counts = minetest_find_nodes_in_area(minp, maxp, poison_stuff)
|
||||
if not (counts and type(counts) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
-- environmental damage
|
||||
if fun_caves.DEBUG and player:get_hp() < 20 then
|
||||
-- Regenerate the player while testing.
|
||||
print("HP: "..player:get_hp())
|
||||
player:set_hp(20)
|
||||
return
|
||||
else
|
||||
local minp = vector.subtract(pos, 0.5)
|
||||
local maxp = vector.add(pos, 0.5)
|
||||
if #counts > 1 then
|
||||
player:set_hp(player:get_hp() - 1)
|
||||
end
|
||||
|
||||
-- Remove status effects.
|
||||
local status = fun_caves.db.status[player_name]
|
||||
for status_name, status_param in pairs(status) do
|
||||
local def = fun_caves.registered_status[status_name]
|
||||
if not def then
|
||||
print('Fun Caves: Error - unregistered status ' .. status_name)
|
||||
break
|
||||
end
|
||||
-- ... from standing on or near cold objects (less often).
|
||||
if dps_count % cold_delay == 0 then
|
||||
counts = minetest_find_nodes_in_area(minp, maxp, cold_stuff)
|
||||
if not (counts and type(counts) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
local remove
|
||||
if type(status_param.remove) == 'number' then
|
||||
if status_param.remove < time then
|
||||
remove = true
|
||||
end
|
||||
elseif def.remove then
|
||||
remove = def.remove(player)
|
||||
else
|
||||
print('Fun Caves: Error in status remove for ' .. status_name)
|
||||
end
|
||||
|
||||
if remove then
|
||||
fun_caves.remove_status(player_name, status_name)
|
||||
elseif def.during then
|
||||
def.during(player)
|
||||
end
|
||||
end
|
||||
|
||||
if fun_caves.db.status[player_name]['breathe'] then
|
||||
player:set_breath(11)
|
||||
end
|
||||
|
||||
-- ... from standing on or near hot objects.
|
||||
local counts = minetest_find_nodes_in_area(minp, maxp, hot_stuff)
|
||||
if not (counts and type(counts) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
if #counts > 1 then
|
||||
player:set_hp(player:get_hp() - 1)
|
||||
end
|
||||
|
||||
-- ... from standing on or near poison.
|
||||
local counts = minetest_find_nodes_in_area(minp, maxp, poison_stuff)
|
||||
if not (counts and type(counts) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
if #counts > 1 then
|
||||
player:set_hp(player:get_hp() - 1)
|
||||
end
|
||||
|
||||
-- ... from standing on or near cold objects (less often).
|
||||
if dps_count % cold_delay == 0 then
|
||||
counts = minetest_find_nodes_in_area(minp, maxp, cold_stuff)
|
||||
if not (counts and type(counts) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
if #counts > 1 then
|
||||
player:set_hp(player:get_hp() - 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- ... from hunger (even less often).
|
||||
if dps_count % hunger_delay == 0 and fun_caves.hunger_change then
|
||||
fun_caves.hunger_change(player, -1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Execute only after an interval.
|
||||
if last_dps_check and time - last_dps_check < dps_delay then
|
||||
return
|
||||
end
|
||||
|
||||
local out = io.open(fun_caves.world..'/fun_caves_data.txt','w')
|
||||
if out then
|
||||
out:write(minetest.serialize(fun_caves.db))
|
||||
out:close()
|
||||
end
|
||||
|
||||
if fun_caves.date and fun_caves.date[2] == 7 and fun_caves.date[3] == 4 and math.random(30) == 1 then
|
||||
firework()
|
||||
end
|
||||
|
||||
-- Promote mobs based on spawn position
|
||||
for _, mob in pairs(minetest.luaentities) do
|
||||
if not mob.initial_promotion then
|
||||
local pos = mob.object:getpos()
|
||||
if mob.hp_max and mob.object and mob.health and mob.damage then
|
||||
local factor = 1 + (math.max(math.abs(pos.x), math.abs(pos.y), math.abs(pos.z)) / 6200)
|
||||
mob.hp_max = math.floor(mob.hp_max * factor)
|
||||
mob.damage = math.floor(mob.damage * factor)
|
||||
mob.health = math.floor(mob.health * factor)
|
||||
mob.object:set_hp(mob.health)
|
||||
mob.initial_promotion = true
|
||||
check_for_death(mob)
|
||||
|
||||
--local name = mob.object:get_entity_name() or ''
|
||||
--print('Promoting '..name..': '..mob.health..' health, '..mob.damage..' damage')
|
||||
end
|
||||
end
|
||||
if #counts > 1 then
|
||||
player:set_hp(player:get_hp() - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Set this outside of the player loop, to affect everyone.
|
||||
if dps_count % hunger_delay == 0 then
|
||||
dps_count = hunger_delay
|
||||
if dps_count % cold_delay < 1 then
|
||||
dps_count = cold_delay
|
||||
end
|
||||
|
||||
last_dps_check = minetest.get_gametime()
|
||||
|
@ -323,19 +148,6 @@ end)
|
|||
-- destruction
|
||||
------------------------------------------------------------
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:flare",},
|
||||
interval = 5,
|
||||
chance = 10,
|
||||
action = function(pos, node)
|
||||
if not (pos and node) then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.remove_node(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:hot_cobble",},
|
||||
neighbors = {"group:water"},
|
||||
|
@ -364,7 +176,7 @@ minetest.register_abm({
|
|||
return
|
||||
end
|
||||
|
||||
fun_caves.soft_boom(pos)
|
||||
fun_caves_mod.soft_boom(pos)
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -385,285 +197,20 @@ minetest.register_abm({
|
|||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fire:basic_flame"},
|
||||
interval = 2 * time_factor,
|
||||
chance = 50,
|
||||
action = function(p0, node, _, _)
|
||||
minetest.remove_node(p0)
|
||||
end,
|
||||
})
|
||||
--minetest.register_abm({
|
||||
-- nodenames = {"fire:basic_flame"},
|
||||
-- interval = 2 * time_factor,
|
||||
-- chance = 50,
|
||||
-- action = function(p0, node, _, _)
|
||||
-- minetest.remove_node(p0)
|
||||
-- end,
|
||||
--})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:coffer"},
|
||||
interval = 5,
|
||||
chance = 20,
|
||||
catch_up = false,
|
||||
action = function(p0, node, _, _)
|
||||
minetest.remove_node(p0)
|
||||
end,
|
||||
})
|
||||
|
||||
------------------------------------------------------------
|
||||
-- creation
|
||||
------------------------------------------------------------
|
||||
|
||||
if fun_caves.dungeon_spawns and #fun_caves.dungeon_spawns > 0 then
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:dungeon_floor_1"},
|
||||
neighbors = {'air'},
|
||||
interval = 7 * time_factor,
|
||||
chance = 350,
|
||||
catch_up = false,
|
||||
action = function(pos, node, aoc, active_object_count_wider)
|
||||
if not (pos and node) or active_object_count_wider > dungeon_monster_density then
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, 2 do
|
||||
pos.y = pos.y + 1
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if not node or node.name ~= "air" then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local target_level = math.max(2, math.ceil((pos.y - 3 ^ math.random(9)) / -200))
|
||||
|
||||
local desc
|
||||
for i = 1, 100 do
|
||||
desc = fun_caves.dungeon_spawns[math.random(#fun_caves.dungeon_spawns)]
|
||||
if desc.level <= target_level then
|
||||
break
|
||||
else
|
||||
desc = nil
|
||||
end
|
||||
end
|
||||
|
||||
if not desc then
|
||||
return
|
||||
end
|
||||
|
||||
local obj = minetest.add_entity(pos, desc.name)
|
||||
if not obj then
|
||||
return
|
||||
end
|
||||
local mob = obj:get_luaentity()
|
||||
if not mob then
|
||||
return
|
||||
end
|
||||
|
||||
if mob.hp_max and mob.object and mob.health and mob.damage then
|
||||
local factor = 1 + (math.max(math.abs(pos.x), math.abs(pos.y), math.abs(pos.z)) / 6200)
|
||||
mob.started_in_dungeon = true
|
||||
factor = factor * 1.5
|
||||
mob.hp_max = math.floor(mob.hp_max * factor)
|
||||
mob.damage = math.floor(mob.damage * factor)
|
||||
mob.health = math.floor(mob.health * factor)
|
||||
mob.object:set_hp(mob.health)
|
||||
mob.initial_promotion = true
|
||||
check_for_death(mob)
|
||||
|
||||
--print('Dungeon quality '..desc.name..': '..mob.health..' health, '..mob.damage..' damage')
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:dungeon_floor_1"},
|
||||
neighbors = {'air'},
|
||||
interval = 20 * time_factor,
|
||||
chance = 1000,
|
||||
catch_up = false,
|
||||
action = function(pos, node)
|
||||
if not (pos and node) then
|
||||
return
|
||||
end
|
||||
|
||||
pos.y = pos.y + 1
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if not node or node.name ~= "air" then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.set_node(pos, {name = 'fun_caves:coffer'})
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:dungeon_wall_1"},
|
||||
neighbors = {'air'},
|
||||
interval = 25 * time_factor,
|
||||
chance = 2000,
|
||||
catch_up = false,
|
||||
action = function(pos, node)
|
||||
if not (pos and node) then
|
||||
return
|
||||
end
|
||||
|
||||
pos = vector.round(pos)
|
||||
|
||||
local dir = math.random(4)
|
||||
local p2 = 3
|
||||
if dir == 1 then
|
||||
pos.x = pos.x + 1
|
||||
elseif dir == 2 then
|
||||
pos.x = pos.x - 1
|
||||
p2 = 2
|
||||
elseif dir == 3 then
|
||||
pos.z = pos.z + 1
|
||||
p2 = 5
|
||||
elseif dir == 4 then
|
||||
pos.z = pos.z - 1
|
||||
p2 = 4
|
||||
end
|
||||
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if not node or node.name ~= "air" then
|
||||
return
|
||||
end
|
||||
|
||||
if (minetest.get_node_light(pos, nil) or 99) > 0 then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.set_node(pos, {name = 'default:torch', param2 = p2})
|
||||
end
|
||||
})
|
||||
|
||||
-- This puts the burdon on fires, which shouldn't be happening much.
|
||||
minetest.register_abm({
|
||||
nodenames = {'fire:basic_flame'},
|
||||
neighbors = {"fun_caves:tree"},
|
||||
interval = time_factor,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
if not (pos and node) then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.set_node(pos, {name = 'fun_caves:sap'})
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:leaves"},
|
||||
neighbors = {'air'},
|
||||
interval = 10 * time_factor,
|
||||
chance = 500,
|
||||
catch_up = false,
|
||||
action = function(pos, node)
|
||||
if not (pos and node) then
|
||||
return
|
||||
end
|
||||
|
||||
pos.y = pos.y - 1
|
||||
local node_below = minetest.get_node_or_nil(pos)
|
||||
if node_below and node_below.name == 'air' then
|
||||
minetest.set_node(pos, {name = 'default:apple'})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:apple"},
|
||||
interval = 2 * time_factor,
|
||||
chance = 50,
|
||||
catch_up = false,
|
||||
action = function(pos, node)
|
||||
if not (pos and node) then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
})
|
||||
|
||||
-- Freezing vapor hardens into ice.
|
||||
local ice_node = {name = 'default:ice'}
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:freezing_vapor"},
|
||||
interval = time_factor,
|
||||
chance = 10,
|
||||
action = function(pos, node)
|
||||
if not (pos and node) then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.set_node(pos, ice_node)
|
||||
end
|
||||
})
|
||||
|
||||
local no_tree_grow = {'fun_caves:bark', 'fun_caves:leaves'}
|
||||
local wood_nodes = {{name = 'fun_caves:diamondwood'}, {name = 'fun_caves:ironwood'}, {name = 'fun_caves:sap'}, {name = 'fun_caves:tree'}}
|
||||
minetest.register_abm({
|
||||
neighbors = {'air'},
|
||||
interval = 10 * time_factor,
|
||||
chance = 450,
|
||||
catch_up = false,
|
||||
action = function(pos, node)
|
||||
if not (pos and node) then
|
||||
return
|
||||
end
|
||||
|
||||
local new_pos = minetest.find_node_near(pos, 1, no_tree_grow)
|
||||
if new_pos then
|
||||
return
|
||||
end
|
||||
|
||||
new_pos = minetest.find_node_near(pos, 1, "air")
|
||||
if not new_pos then
|
||||
return
|
||||
end
|
||||
|
||||
if math.random(50) == 1 then
|
||||
minetest.set_node(new_pos, wood_nodes[1])
|
||||
elseif math.random(25) == 1 then
|
||||
minetest.set_node(new_pos, wood_nodes[2])
|
||||
elseif math.random(25) == 1 then
|
||||
minetest.set_node(new_pos, wood_nodes[3])
|
||||
else
|
||||
minetest.set_node(new_pos, wood_nodes[4])
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- vacuum sucks
|
||||
local vacuum = {name = 'fun_caves:vacuum'}
|
||||
local air_list = {'air'}
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:vacuum"},
|
||||
neighbors = {"air"},
|
||||
interval = time_factor,
|
||||
chance = 10,
|
||||
action = function(pos, node)
|
||||
if not (pos and node) then
|
||||
return
|
||||
end
|
||||
|
||||
if pos.y <= 11168 or pos.y >= 15168 then
|
||||
return
|
||||
end
|
||||
|
||||
local p1 = vector.subtract(pos, 1)
|
||||
local p2 = vector.add(pos, 1)
|
||||
local positions = minetest.find_nodes_in_area(p1, p2, air_list)
|
||||
if not (positions and type(positions) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
local minetest_get_node_or_nil = minetest.get_node_or_nil
|
||||
local minetest_set_node = minetest.set_node
|
||||
for _, p3 in pairs(positions) do
|
||||
local node2 = minetest_get_node_or_nil(p3)
|
||||
if node2 and node2.name == 'air' then
|
||||
minetest_set_node(p3, vacuum)
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- fungal spread
|
||||
minetest.register_abm({
|
||||
nodenames = fungal_tree_leaves,
|
||||
|
@ -828,7 +375,7 @@ minetest.register_abm({
|
|||
|
||||
-- Spike spread and death
|
||||
minetest.register_abm({
|
||||
nodenames = fun_caves.hot_spikes,
|
||||
nodenames = fun_caves_mod.hot_spikes,
|
||||
interval = 40 * time_factor,
|
||||
chance = 2000,
|
||||
action = function(pos, node)
|
||||
|
@ -836,17 +383,17 @@ minetest.register_abm({
|
|||
return
|
||||
end
|
||||
|
||||
if not (fun_caves.hot_spike and fun_caves.hot_spikes) then
|
||||
if not (fun_caves_mod.hot_spike and fun_caves_mod.hot_spikes) then
|
||||
return
|
||||
end
|
||||
|
||||
local spike_num = fun_caves.hot_spike[node.name]
|
||||
local spike_num = fun_caves_mod.hot_spike[node.name]
|
||||
if not spike_num then
|
||||
return
|
||||
end
|
||||
|
||||
if spike_num < #fun_caves.hot_spikes then
|
||||
minetest.set_node(pos, {name=fun_caves.hot_spikes[spike_num+1]})
|
||||
if spike_num < #fun_caves_mod.hot_spikes then
|
||||
minetest.set_node(pos, {name=fun_caves_mod.hot_spikes[spike_num+1]})
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -868,71 +415,6 @@ minetest.register_abm({
|
|||
})
|
||||
|
||||
|
||||
------------------------------------------------------------
|
||||
-- meteors
|
||||
------------------------------------------------------------
|
||||
|
||||
local last_meteor_strike = 0
|
||||
-- meteor strikes
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass", 'default:dirt_with_snow'},
|
||||
neighbors = {"air", 'default:snow'},
|
||||
interval = 150 * time_factor,
|
||||
catch_up = false,
|
||||
chance = 5500,
|
||||
action = function(pos, node)
|
||||
if not (pos and node and pos.y > 0) then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.set_node(pos, {name="fun_caves:meteorite_crater"})
|
||||
|
||||
local time = minetest.get_gametime()
|
||||
if time - last_meteor_strike < 10 then
|
||||
return
|
||||
end
|
||||
last_meteor_strike = time
|
||||
|
||||
local ps = {}
|
||||
local players = minetest.get_connected_players()
|
||||
if not (players and type(players) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, #players do
|
||||
local pp = players[i]:getpos()
|
||||
local pd = vector.subtract(pp, pos)
|
||||
if pp and pp.y > 0 and math.abs(pd.x) < 1000 and math.abs(pd.z) < 1000 then
|
||||
local sky = {}
|
||||
sky.bgcolor, sky.type, sky.textures = players[i]:get_sky()
|
||||
ps[#ps+1] = { p = players[i], sky = sky }
|
||||
players[i]:set_sky(0xffffff, "plain")
|
||||
end
|
||||
end
|
||||
|
||||
minetest.after(1, function()
|
||||
for i = 1, #ps do
|
||||
ps[i].p:set_sky(ps[i].sky.bgcolor, ps[i].sky.type, ps[i].sky.textures)
|
||||
end
|
||||
end)
|
||||
end
|
||||
})
|
||||
|
||||
-- Remove old craters.
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:meteorite_crater"},
|
||||
interval = 5 * time_factor,
|
||||
chance = 200,
|
||||
action = function(pos, node)
|
||||
if not (pos and node) then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.set_node(pos, {name="default:dirt"})
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
------------------------------------------------------------
|
||||
-- explosive functions
|
||||
------------------------------------------------------------
|
||||
|
@ -1010,6 +492,7 @@ local function destroy(pos, cid)
|
|||
end
|
||||
end
|
||||
|
||||
local math_random = math.random
|
||||
local function explode(pos, radius)
|
||||
if not (pos and radius and type(radius) == 'number') then
|
||||
return
|
||||
|
@ -1027,7 +510,6 @@ local function explode(pos, radius)
|
|||
|
||||
local c_air = minetest.get_content_id("air")
|
||||
|
||||
local math_random = math.random
|
||||
for z = -radius, radius do
|
||||
for y = -radius, 4*radius do
|
||||
local vi = a:index(pos.x + (-radius), pos.y + y, pos.z + z)
|
||||
|
@ -1096,7 +578,7 @@ local function entity_physics(pos, radius)
|
|||
end
|
||||
end
|
||||
|
||||
fun_caves.soft_boom = function(pos)
|
||||
fun_caves_mod.soft_boom = function(pos)
|
||||
if not pos then
|
||||
return
|
||||
end
|
||||
|
@ -1118,10 +600,6 @@ fun_caves.soft_boom = function(pos)
|
|||
end
|
||||
end
|
||||
|
||||
--local function burn(pos)
|
||||
-- minetest.get_node_timer(pos):start(1)
|
||||
--end
|
||||
|
||||
|
||||
-----------------------------------------------
|
||||
-- testing only -- remove before distribution
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue