Streamline abms. Fix manticore poison.
This commit is contained in:
parent
678b025cb0
commit
5ae6e9f89c
5 changed files with 294 additions and 392 deletions
193
abms.lua
193
abms.lua
|
@ -58,6 +58,7 @@ spike_soil['fun_caves:black_sand'] = true
|
||||||
-- all the fun_caves globalstep functions
|
-- all the fun_caves globalstep functions
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
local hot_stuff = {"group:surface_hot"}
|
local hot_stuff = {"group:surface_hot"}
|
||||||
|
local traps = {"group:trap"}
|
||||||
local cold_stuff = {"group:surface_cold"}
|
local cold_stuff = {"group:surface_cold"}
|
||||||
local poison_stuff = {"group:poison"}
|
local poison_stuff = {"group:poison"}
|
||||||
local gravity_off = {gravity = 0.1}
|
local gravity_off = {gravity = 0.1}
|
||||||
|
@ -99,6 +100,8 @@ local function firework()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local sparking = {}
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
if not (dtime and type(dtime) == 'number') then
|
if not (dtime and type(dtime) == 'number') then
|
||||||
return
|
return
|
||||||
|
@ -113,40 +116,11 @@ minetest.register_globalstep(function(dtime)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Execute only after an interval.
|
-- Trap check
|
||||||
if last_dps_check and time - last_dps_check < dps_delay then
|
if last_dps_check and time - last_dps_check < 1 then
|
||||||
return
|
return
|
||||||
end
|
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
|
|
||||||
end
|
|
||||||
|
|
||||||
local minetest_find_nodes_in_area = minetest.find_nodes_in_area
|
local minetest_find_nodes_in_area = minetest.find_nodes_in_area
|
||||||
local players = minetest.get_connected_players()
|
local players = minetest.get_connected_players()
|
||||||
if not (players and type(players) == 'table') then
|
if not (players and type(players) == 'table') then
|
||||||
|
@ -156,8 +130,53 @@ minetest.register_globalstep(function(dtime)
|
||||||
for i = 1, #players do
|
for i = 1, #players do
|
||||||
local player = players[i]
|
local player = players[i]
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
|
pos = vector.round(pos)
|
||||||
local player_name = player:get_player_name()
|
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"})
|
||||||
|
|
||||||
|
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
|
||||||
|
object: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)
|
||||||
|
|
||||||
|
minetest.after(1, function()
|
||||||
|
sparking[player_name] = nil
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
minetest.remove_node(tpos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
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 pos.y >= 11168 and pos.y <= 15168 then
|
||||||
if not players_in_orbit[player_name] then
|
if not players_in_orbit[player_name] then
|
||||||
player:set_physics_override(gravity_off)
|
player:set_physics_override(gravity_off)
|
||||||
|
@ -251,6 +270,41 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
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
|
||||||
|
end
|
||||||
|
|
||||||
-- Set this outside of the player loop, to affect everyone.
|
-- Set this outside of the player loop, to affect everyone.
|
||||||
if dps_count % hunger_delay == 0 then
|
if dps_count % hunger_delay == 0 then
|
||||||
|
@ -285,8 +339,8 @@ minetest.register_abm({
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"fun_caves:hot_cobble",},
|
nodenames = {"fun_caves:hot_cobble",},
|
||||||
neighbors = {"group:water"},
|
neighbors = {"group:water"},
|
||||||
interval = 5,
|
interval = time_factor,
|
||||||
chance = 60,
|
chance = 30,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node) then
|
if not (pos and node) then
|
||||||
|
@ -302,8 +356,8 @@ minetest.register_abm({
|
||||||
-- Exploding fungal fruit
|
-- Exploding fungal fruit
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"fun_caves:fungal_tree_fruit"},
|
nodenames = {"fun_caves:fungal_tree_fruit"},
|
||||||
interval = 2 * time_factor,
|
interval = 12 * time_factor,
|
||||||
chance = 150,
|
chance = 400,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node) then
|
if not (pos and node) then
|
||||||
|
@ -333,8 +387,8 @@ minetest.register_abm({
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"fire:basic_flame"},
|
nodenames = {"fire:basic_flame"},
|
||||||
interval = time_factor,
|
interval = 2 * time_factor,
|
||||||
chance = 100,
|
chance = 50,
|
||||||
action = function(p0, node, _, _)
|
action = function(p0, node, _, _)
|
||||||
minetest.remove_node(p0)
|
minetest.remove_node(p0)
|
||||||
end,
|
end,
|
||||||
|
@ -342,8 +396,8 @@ minetest.register_abm({
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"fun_caves:coffer"},
|
nodenames = {"fun_caves:coffer"},
|
||||||
interval = 2,
|
interval = 5,
|
||||||
chance = 50,
|
chance = 20,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(p0, node, _, _)
|
action = function(p0, node, _, _)
|
||||||
minetest.remove_node(p0)
|
minetest.remove_node(p0)
|
||||||
|
@ -354,11 +408,13 @@ minetest.register_abm({
|
||||||
-- creation
|
-- creation
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
|
|
||||||
|
if fun_caves.dungeon_spawns and #fun_caves.dungeon_spawns > 0 then
|
||||||
|
print('go monster')
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"fun_caves:dungeon_floor_1"},
|
nodenames = {"fun_caves:dungeon_floor_1"},
|
||||||
neighbors = {'air'},
|
neighbors = {'air'},
|
||||||
interval = 5 * time_factor,
|
interval = 7 * time_factor,
|
||||||
chance = 500,
|
chance = 350,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node, aoc, active_object_count_wider)
|
action = function(pos, node, aoc, active_object_count_wider)
|
||||||
if not (pos and node) or active_object_count_wider > dungeon_monster_density then
|
if not (pos and node) or active_object_count_wider > dungeon_monster_density then
|
||||||
|
@ -413,12 +469,14 @@ minetest.register_abm({
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if false then
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"fun_caves:dungeon_floor_1"},
|
nodenames = {"fun_caves:dungeon_floor_1"},
|
||||||
neighbors = {'air'},
|
neighbors = {'air'},
|
||||||
interval = 10 * time_factor,
|
interval = 20 * time_factor,
|
||||||
chance = 2000,
|
chance = 1000,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node) then
|
if not (pos and node) then
|
||||||
|
@ -438,8 +496,8 @@ minetest.register_abm({
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"fun_caves:dungeon_wall_1"},
|
nodenames = {"fun_caves:dungeon_wall_1"},
|
||||||
neighbors = {'air'},
|
neighbors = {'air'},
|
||||||
interval = 1 * time_factor,
|
interval = 4 * time_factor,
|
||||||
chance = 1000,
|
chance = 250,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node) then
|
if not (pos and node) then
|
||||||
|
@ -475,6 +533,7 @@ minetest.register_abm({
|
||||||
minetest.set_node(pos, {name = 'default:torch', param2 = p2})
|
minetest.set_node(pos, {name = 'default:torch', param2 = p2})
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
-- This puts the burdon on fires, which shouldn't be happening much.
|
-- This puts the burdon on fires, which shouldn't be happening much.
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
@ -494,8 +553,8 @@ minetest.register_abm({
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"default:leaves"},
|
nodenames = {"default:leaves"},
|
||||||
neighbors = {'air'},
|
neighbors = {'air'},
|
||||||
interval = 5 * time_factor,
|
interval = 10 * time_factor,
|
||||||
chance = 1000,
|
chance = 500,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node) then
|
if not (pos and node) then
|
||||||
|
@ -512,8 +571,8 @@ minetest.register_abm({
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"default:apple"},
|
nodenames = {"default:apple"},
|
||||||
interval = time_factor,
|
interval = 2 * time_factor,
|
||||||
chance = 100,
|
chance = 50,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node) then
|
if not (pos and node) then
|
||||||
|
@ -543,8 +602,8 @@ 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'}}
|
local wood_nodes = {{name = 'fun_caves:diamondwood'}, {name = 'fun_caves:ironwood'}, {name = 'fun_caves:sap'}, {name = 'fun_caves:tree'}}
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
neighbors = {'air'},
|
neighbors = {'air'},
|
||||||
interval = 5 * time_factor,
|
interval = 10 * time_factor,
|
||||||
chance = 900,
|
chance = 450,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node) then
|
if not (pos and node) then
|
||||||
|
@ -612,8 +671,8 @@ minetest.register_abm({
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = fungal_tree_leaves,
|
nodenames = fungal_tree_leaves,
|
||||||
neighbors = {"air", "group:liquid"},
|
neighbors = {"air", "group:liquid"},
|
||||||
interval = math.ceil(time_factor / 2),
|
interval = 4 * time_factor,
|
||||||
chance = 100,
|
chance = 200,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node) then
|
if not (pos and node) then
|
||||||
|
@ -661,8 +720,8 @@ local huge_mushroom_cap_node = {name = 'fun_caves:huge_mushroom_cap'}
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"fun_caves:giant_mushroom_stem"},
|
nodenames = {"fun_caves:giant_mushroom_stem"},
|
||||||
neighbors = {'air'},
|
neighbors = {'air'},
|
||||||
interval = time_factor,
|
interval = 4 * time_factor,
|
||||||
chance = 300,
|
chance = 200,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node) then
|
if not (pos and node) then
|
||||||
return
|
return
|
||||||
|
@ -688,8 +747,8 @@ end
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"default:dirt"},
|
nodenames = {"default:dirt"},
|
||||||
neighbors = {'fun_caves:stone_with_lichen', 'fun_caves:stone_with_algae', 'fun_caves:giant_mushroom_stem'},
|
neighbors = {'fun_caves:stone_with_lichen', 'fun_caves:stone_with_algae', 'fun_caves:giant_mushroom_stem'},
|
||||||
interval = time_factor,
|
interval = 10 * time_factor,
|
||||||
chance = 300,
|
chance = 500,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node and pos.y < 0) then
|
if not (pos and node and pos.y < 0) then
|
||||||
|
@ -713,8 +772,8 @@ minetest.register_abm({
|
||||||
local giant_mushroom_stem_node = {name = 'fun_caves:giant_mushroom_stem'}
|
local giant_mushroom_stem_node = {name = 'fun_caves:giant_mushroom_stem'}
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = mushrooms,
|
nodenames = mushrooms,
|
||||||
interval = 5 * time_factor,
|
interval = 20 * time_factor,
|
||||||
chance = 750,
|
chance = 700,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node and pos.y < 0) then
|
if not (pos and node and pos.y < 0) then
|
||||||
|
@ -743,7 +802,7 @@ minetest.register_abm({
|
||||||
local giant_mushroom_cap_node = {name = "fun_caves:giant_mushroom_cap"}
|
local giant_mushroom_cap_node = {name = "fun_caves:giant_mushroom_cap"}
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"fun_caves:huge_mushroom_cap"},
|
nodenames = {"fun_caves:huge_mushroom_cap"},
|
||||||
interval = 9 * time_factor,
|
interval = 40 * time_factor,
|
||||||
chance = 2000,
|
chance = 2000,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
|
@ -773,8 +832,8 @@ minetest.register_abm({
|
||||||
-- Spike spread and death
|
-- Spike spread and death
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = fun_caves.hot_spikes,
|
nodenames = fun_caves.hot_spikes,
|
||||||
interval = time_factor,
|
interval = 40 * time_factor,
|
||||||
chance = 900,
|
chance = 2000,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node and pos.y < 0) then
|
if not (pos and node and pos.y < 0) then
|
||||||
return
|
return
|
||||||
|
@ -821,11 +880,11 @@ local last_meteor_strike = 0
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass", 'default:dirt_with_snow'},
|
nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass", 'default:dirt_with_snow'},
|
||||||
neighbors = {"air", 'default:snow'},
|
neighbors = {"air", 'default:snow'},
|
||||||
interval = 25 * time_factor,
|
interval = 150 * time_factor,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
chance = 32767,
|
chance = 5500,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node) then
|
if not (pos and node and pos.y > 0) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -865,8 +924,8 @@ minetest.register_abm({
|
||||||
-- Remove old craters.
|
-- Remove old craters.
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"fun_caves:meteorite_crater"},
|
nodenames = {"fun_caves:meteorite_crater"},
|
||||||
interval = 3 * time_factor,
|
interval = 5 * time_factor,
|
||||||
chance = 330,
|
chance = 200,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not (pos and node) then
|
if not (pos and node) then
|
||||||
return
|
return
|
||||||
|
|
|
@ -196,7 +196,7 @@ newnode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
|
|
||||||
local ready = meta:get_string('formspec')
|
local ready = meta:get_string('formspec')
|
||||||
if treasures and ready == '' then
|
if treasures and ready == '' then
|
||||||
if math.random(10) == 1 then
|
if math.random(10) == 1 and fun_caves.dungeon_spawns and #fun_caves.dungeon_spawns > 0 then
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
|
||||||
local desc = fun_caves.dungeon_spawns[math.random(#fun_caves.dungeon_spawns)]
|
local desc = fun_caves.dungeon_spawns[math.random(#fun_caves.dungeon_spawns)]
|
||||||
|
@ -518,7 +518,7 @@ fun_caves.dungeon = function(minp_in, maxp_in, data, p2data, area, node, heightm
|
||||||
if not leave_alone[data[ivm]] then
|
if not leave_alone[data[ivm]] then
|
||||||
if ry == 0 and (cy > 0 or not centered_in) then
|
if ry == 0 and (cy > 0 or not centered_in) then
|
||||||
if content[cx][cy][cz] == 'room' then
|
if content[cx][cy][cz] == 'room' then
|
||||||
local r = math.random(1000)
|
local r = math.random(100)
|
||||||
if r == 1 then
|
if r == 1 then
|
||||||
data[ivm] = node['fun_caves:stone_with_gold_trap']
|
data[ivm] = node['fun_caves:stone_with_gold_trap']
|
||||||
elseif r == 2 then
|
elseif r == 2 then
|
||||||
|
|
234
goblin.lua
234
goblin.lua
|
@ -404,37 +404,12 @@ minetest.register_node("fun_caves:mossycobble_trap", {
|
||||||
description = "Messy Gobblestone",
|
description = "Messy Gobblestone",
|
||||||
tiles = {"default_mossycobble.png"},
|
tiles = {"default_mossycobble.png"},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {cracky = 2, stone = 1},
|
groups = {cracky = 2, stone = 1, trap = 1},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
light_source = 4,
|
light_source = 4,
|
||||||
})
|
})
|
||||||
|
|
||||||
--[[ too bad we can't keep track of what physics are set too by other mods...]]
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"fun_caves:mossycobble_trap"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
if not pos then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 0.95)
|
|
||||||
if not (objects and type(objects) == 'table') then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, object in ipairs(objects) do -- IDKWTF this is but it works
|
|
||||||
if object:is_player() then
|
|
||||||
object:set_physics_override({speed = 0.1})
|
|
||||||
minetest.after(1, function() -- this effect is temporary
|
|
||||||
object:set_physics_override({speed = 1}) -- we'll just set it to 1 and be done.
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "cooking",
|
type = "cooking",
|
||||||
output = "default:stone",
|
output = "default:stone",
|
||||||
|
@ -444,56 +419,15 @@ minetest.register_craft({
|
||||||
minetest.register_node("fun_caves:stone_with_coal_trap", {
|
minetest.register_node("fun_caves:stone_with_coal_trap", {
|
||||||
description = "Coal Trap",
|
description = "Coal Trap",
|
||||||
tiles = {"default_cobble.png^default_mineral_coal.png"},
|
tiles = {"default_cobble.png^default_mineral_coal.png"},
|
||||||
groups = {cracky = 3},
|
groups = {cracky = 3, trap = 1},
|
||||||
drop = 'default:coal_lump',
|
drop = 'default:coal_lump',
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
if minetest.registered_nodes['tnt:tnt_burning'] then
|
||||||
nodenames = {"fun_caves:stone_with_coal_trap"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
if not pos then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 2)
|
|
||||||
if not (objects and type(objects) == 'table') then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, object in ipairs(objects) do
|
|
||||||
if object:is_player() then
|
|
||||||
minetest.set_node(pos, {name="fire:basic_flame"})
|
|
||||||
if object:get_hp() > 0 then
|
|
||||||
object:set_hp(object:get_hp()-2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
local singleplayer = minetest.is_singleplayer()
|
|
||||||
local setting = minetest.setting_getbool("enable_tnt")
|
|
||||||
local diamond_trap
|
|
||||||
if (not singleplayer and setting ~= true) or (singleplayer and setting == false) then
|
|
||||||
-- wimpier trap for non-tnt settings
|
|
||||||
diamond_trap = function(pos, player)
|
|
||||||
if not (pos and player) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.set_node(pos, {name="default:lava_source"})
|
|
||||||
if player:get_hp() > 0 then
|
|
||||||
player:set_hp(player:get_hp()-2)
|
|
||||||
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- 5... 4... 3... 2... 1...
|
-- 5... 4... 3... 2... 1...
|
||||||
diamond_trap = function(pos, player)
|
fun_caves.diamond_trap = function(pos, player)
|
||||||
if not (pos and player) then
|
if not (pos and player) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -505,12 +439,26 @@ else
|
||||||
end
|
end
|
||||||
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
|
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
-- wimpier trap for non-tnt settings
|
||||||
|
fun_caves.diamond_trap = function(pos, player)
|
||||||
|
if not (pos and player) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.set_node(pos, {name="default:lava_source"})
|
||||||
|
local hp = player:get_hp()
|
||||||
|
if hp > 0 then
|
||||||
|
player:set_hp(hp - 2)
|
||||||
|
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("fun_caves:stone_with_diamond_trap", {
|
minetest.register_node("fun_caves:stone_with_diamond_trap", {
|
||||||
description = "Diamond Trap",
|
description = "Diamond Trap",
|
||||||
tiles = {"default_cobble.png^(default_mineral_diamond.png^[colorize:#000000:160)"},
|
tiles = {"default_cobble.png^(default_mineral_diamond.png^[colorize:#000000:160)"},
|
||||||
groups = {cracky = 3},
|
groups = {cracky = 3, trap = 1},
|
||||||
drop = 'default:diamond',
|
drop = 'default:diamond',
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
@ -520,35 +468,13 @@ minetest.register_node("fun_caves:stone_with_diamond_trap", {
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.random(3) == 1 then
|
if math.random(3) == 1 then
|
||||||
diamond_trap(pos, digger)
|
fun_caves.diamond_trap(pos, digger)
|
||||||
else
|
else
|
||||||
minetest.node_dig(pos, node, digger)
|
minetest.node_dig(pos, node, digger)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"fun_caves:stone_with_diamond_trap"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos)
|
|
||||||
if not pos then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 3)
|
|
||||||
if not (objects and type(objects) == 'table') then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _,object in ipairs(objects) do
|
|
||||||
if object:is_player() then
|
|
||||||
diamond_trap(pos, object)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
newnode = fun_caves.clone_node("default:lava_source")
|
newnode = fun_caves.clone_node("default:lava_source")
|
||||||
newnode.description = "Molten Gold Source"
|
newnode.description = "Molten Gold Source"
|
||||||
|
@ -581,19 +507,23 @@ bucket.register_liquid(
|
||||||
{}
|
{}
|
||||||
)
|
)
|
||||||
|
|
||||||
local gold_trap = function(pos, player)
|
fun_caves.gold_trap = function(pos, player)
|
||||||
if not (pos and player) then
|
if not (pos and player) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.set_node(pos, {name="fun_caves:molten_gold_source"})
|
minetest.set_node(pos, {name="fun_caves:molten_gold_source"})
|
||||||
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
|
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
|
||||||
|
local hp = player:get_hp()
|
||||||
|
if hp > 0 then
|
||||||
|
player:set_hp(hp - 2)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("fun_caves:stone_with_gold_trap", {
|
minetest.register_node("fun_caves:stone_with_gold_trap", {
|
||||||
description = "Gold Trap",
|
description = "Gold Trap",
|
||||||
tiles = {"default_cobble.png^(default_mineral_gold.png^[colorize:#000000:160)"},
|
tiles = {"default_cobble.png^(default_mineral_gold.png^[colorize:#000000:160)"},
|
||||||
groups = {cracky = 3},
|
groups = {cracky = 3, trap = 1},
|
||||||
drop = 'default:gold_lump',
|
drop = 'default:gold_lump',
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
@ -603,37 +533,15 @@ minetest.register_node("fun_caves:stone_with_gold_trap", {
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.random(3) == 1 then
|
if math.random(3) == 1 then
|
||||||
gold_trap(pos, digger)
|
fun_caves.gold_trap(pos, digger)
|
||||||
else
|
else
|
||||||
minetest.node_dig(pos, node, digger)
|
minetest.node_dig(pos, node, digger)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"fun_caves:stone_with_gold_trap"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos)
|
|
||||||
if not pos then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 2)
|
fun_caves.ice_trap = function(pos, player)
|
||||||
if not (objects and type(objects) == 'table') then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _,object in ipairs(objects) do
|
|
||||||
if object:is_player() then
|
|
||||||
gold_trap(pos, object)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
local ice_trap = function(pos, player)
|
|
||||||
if not (pos and player) then
|
if not (pos and player) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -659,7 +567,7 @@ end
|
||||||
minetest.register_node("fun_caves:ice_trap", {
|
minetest.register_node("fun_caves:ice_trap", {
|
||||||
description = "Ice Trap",
|
description = "Ice Trap",
|
||||||
tiles = {"default_ice.png^fun_caves_mineral_moonstone.png"},
|
tiles = {"default_ice.png^fun_caves_mineral_moonstone.png"},
|
||||||
groups = {cracky = 3},
|
groups = {cracky = 3, trap = 1},
|
||||||
drop = 'default:ice',
|
drop = 'default:ice',
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
@ -669,35 +577,13 @@ minetest.register_node("fun_caves:ice_trap", {
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.random(3) == 1 then
|
if math.random(3) == 1 then
|
||||||
ice_trap(pos, digger)
|
fun_caves.ice_trap(pos, digger)
|
||||||
else
|
else
|
||||||
minetest.node_dig(pos, node, digger)
|
minetest.node_dig(pos, node, digger)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"fun_caves:ice_trap"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos)
|
|
||||||
if not pos then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 2)
|
|
||||||
if not (objects and type(objects) == 'table') then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _,object in ipairs(objects) do
|
|
||||||
if object:is_player() then
|
|
||||||
ice_trap(pos, object)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
local function lightning_effects(pos, radius)
|
local function lightning_effects(pos, radius)
|
||||||
if not (pos and radius) then
|
if not (pos and radius) then
|
||||||
|
@ -721,13 +607,14 @@ local function lightning_effects(pos, radius)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local copper_trap = function(pos, player)
|
fun_caves.copper_trap = function(pos, player)
|
||||||
if not (pos and player) then
|
if not (pos and player) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if player:get_hp() > 0 then
|
local hp = player:get_hp()
|
||||||
player:set_hp(player:get_hp()-1)
|
if hp > 0 then
|
||||||
|
player:set_hp(hp - 1)
|
||||||
lightning_effects(pos, 3)
|
lightning_effects(pos, 3)
|
||||||
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
|
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
|
||||||
end
|
end
|
||||||
|
@ -736,7 +623,7 @@ end
|
||||||
minetest.register_node("fun_caves:stone_with_copper_trap", {
|
minetest.register_node("fun_caves:stone_with_copper_trap", {
|
||||||
description = "Copper Trap",
|
description = "Copper Trap",
|
||||||
tiles = {"default_cobble.png^(default_mineral_copper.png^[colorize:#000000:160)"},
|
tiles = {"default_cobble.png^(default_mineral_copper.png^[colorize:#000000:160)"},
|
||||||
groups = {cracky = 3},
|
groups = {cracky = 3, trap = 1},
|
||||||
drop = 'default:copper_lump',
|
drop = 'default:copper_lump',
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
@ -746,43 +633,20 @@ minetest.register_node("fun_caves:stone_with_copper_trap", {
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.random(3) == 1 then
|
if math.random(3) == 1 then
|
||||||
copper_trap(pos, digger)
|
fun_caves.copper_trap(pos, digger)
|
||||||
else
|
else
|
||||||
minetest.node_dig(pos, node, digger)
|
minetest.node_dig(pos, node, digger)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
--[[ based on dwarves cactus]]
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"fun_caves:stone_with_copper_trap"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 2,
|
|
||||||
action = function(pos)
|
|
||||||
if not pos then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 3)
|
|
||||||
if not (objects and type(objects) == 'table') then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _,object in ipairs(objects) do
|
|
||||||
if object:is_player() then
|
|
||||||
copper_trap(pos, object)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
-- summon a metallic goblin?
|
-- summon a metallic goblin?
|
||||||
-- pit of iron razors?
|
-- pit of iron razors?
|
||||||
minetest.register_node("fun_caves:stone_with_iron_trap", {
|
minetest.register_node("fun_caves:stone_with_iron_trap", {
|
||||||
description = "Iron Trap",
|
description = "Iron Trap",
|
||||||
tiles = {"default_cobble.png^(default_mineral_iron.png^[colorize:#000000:160)"},
|
tiles = {"default_cobble.png^(default_mineral_iron.png^[colorize:#000000:160)"},
|
||||||
groups = {cracky = 3},
|
groups = {cracky = 3, trap = 1},
|
||||||
drop = 'default:iron_lump',
|
drop = 'default:iron_lump',
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
@ -792,31 +656,9 @@ minetest.register_node("fun_caves:stone_with_iron_trap", {
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.random(3) == 1 then
|
if math.random(3) == 1 then
|
||||||
copper_trap(pos, digger)
|
fun_caves.copper_trap(pos, digger)
|
||||||
else
|
else
|
||||||
minetest.node_dig(pos, node, digger)
|
minetest.node_dig(pos, node, digger)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"fun_caves:stone_with_iron_trap"},
|
|
||||||
interval = 2,
|
|
||||||
chance = 2,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
if not pos then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 3)
|
|
||||||
if not (objects and type(objects) == 'table') then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, object in ipairs(objects) do
|
|
||||||
if object:is_player() then
|
|
||||||
copper_trap(pos, object)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ mobs:register_mob("fun_caves:manticore", {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.attack and math.random(3) == 1 then
|
if self.attack and math.random(3) == 1 and self.attack:is_player(self.attack) and minetest.line_of_sight(self.attack:getpos(), self.object:getpos(), stepsize) then
|
||||||
local player_name = self.attack:get_player_name()
|
local player_name = self.attack:get_player_name()
|
||||||
if player_name and player_name ~= '' then
|
if player_name and player_name ~= '' then
|
||||||
minetest.chat_send_player(player_name, minetest.colorize('#FF0000', 'You\'ve been poisoned!'))
|
minetest.chat_send_player(player_name, minetest.colorize('#FF0000', 'You\'ve been poisoned!'))
|
||||||
|
|
3
init.lua
3
init.lua
|
@ -207,7 +207,6 @@ end
|
||||||
|
|
||||||
--dofile(fun_caves.path .. "/recipe_list.lua")
|
--dofile(fun_caves.path .. "/recipe_list.lua")
|
||||||
|
|
||||||
dofile(fun_caves.path .. "/abms.lua")
|
|
||||||
dofile(fun_caves.path .. "/nodes.lua")
|
dofile(fun_caves.path .. "/nodes.lua")
|
||||||
dofile(fun_caves.path .. "/deco.lua")
|
dofile(fun_caves.path .. "/deco.lua")
|
||||||
dofile(fun_caves.path .. "/fungal_tree.lua")
|
dofile(fun_caves.path .. "/fungal_tree.lua")
|
||||||
|
@ -222,6 +221,8 @@ if minetest.get_modpath("mobs") and mobs and mobs.mod == "redo" then
|
||||||
dofile(fun_caves.path .. "/mobs.lua")
|
dofile(fun_caves.path .. "/mobs.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
dofile(fun_caves.path .. "/abms.lua")
|
||||||
|
|
||||||
--fun_caves.print_recipes()
|
--fun_caves.print_recipes()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue