Most dungeon features working.
This commit is contained in:
parent
5abe211fb6
commit
61c3cb0edd
7 changed files with 570 additions and 710 deletions
159
abms.lua
159
abms.lua
|
@ -10,8 +10,6 @@ local cold_delay = 5
|
|||
local monster_delay = 3
|
||||
local hunger_delay = 60
|
||||
local dps_count = hunger_delay
|
||||
-- maximum number of mobs near player in fortresses
|
||||
local fortress_mob_count = 5
|
||||
local players_in_orbit = {}
|
||||
|
||||
local mushrooms = {"flowers:mushroom_brown", "flowers:mushroom_red"}
|
||||
|
@ -63,7 +61,6 @@ local cold_stuff = {"group:surface_cold"}
|
|||
local poison_stuff = {"group:poison"}
|
||||
local gravity_off = {gravity = 0.1}
|
||||
local gravity_on = {gravity = 1}
|
||||
local fortress_floor = {x = 30, y = 2, z = 30}
|
||||
local fortress_group = {'group:fortress'}
|
||||
|
||||
local firework_active = false
|
||||
|
@ -131,20 +128,11 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
|
||||
-- Promote mobs based on spawn position
|
||||
local is_fortress = fun_caves.is_fortress
|
||||
if not is_fortress then
|
||||
return
|
||||
end
|
||||
|
||||
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)
|
||||
if is_fortress(pos) then
|
||||
mob.started_in_fortress = true
|
||||
factor = factor * 1.5
|
||||
end
|
||||
mob.hp_max = math.floor(mob.hp_max * factor)
|
||||
mob.damage = math.floor(mob.damage * factor)
|
||||
mob.object:set_hp(mob.hp_max)
|
||||
|
@ -155,53 +143,17 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
end
|
||||
|
||||
-- Spawn mobs in fortresses -- only when a player is near
|
||||
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
|
||||
end
|
||||
|
||||
--local do_fortress_spawns = (fun_caves.fortress_spawns and #fun_caves.fortress_spawns > 0)
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
local pos = player:getpos()
|
||||
local player_name = player:get_player_name()
|
||||
|
||||
--if do_fortress_spawns and is_fortress(pos) and dps_count % monster_delay == 0 then
|
||||
-- -- How many mobs are up at the moment? This is a rough check.
|
||||
-- local mob_count = 0
|
||||
-- for _, mob in pairs(minetest.luaentities) do
|
||||
-- if mob.health and mob.started_in_fortress then
|
||||
-- local dist = vector.subtract(pos, mob.object:getpos())
|
||||
-- local dist2 = math.max(math.abs(dist.x), math.abs(dist.y * 5), math.abs(dist.z))
|
||||
-- if dist2 < 30 then
|
||||
-- mob_count = mob_count + 1
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- -- If we need more, spawn them.
|
||||
-- if mob_count < fortress_mob_count then
|
||||
-- local f1 = vector.subtract(pos, fortress_floor)
|
||||
-- local f2 = vector.add(pos, fortress_floor)
|
||||
-- local floor_nodes = minetest.find_nodes_in_area_under_air(f1, f2, fortress_group)
|
||||
-- if not (floor_nodes and type(floor_nodes) == 'table') then
|
||||
-- return
|
||||
-- end
|
||||
|
||||
-- if #floor_nodes > 0 then
|
||||
-- local new_mob_pos = floor_nodes[math.random(#floor_nodes)]
|
||||
-- new_mob_pos.y = new_mob_pos.y + 2
|
||||
-- --------------------------------------
|
||||
-- -- Mobs are treated exacty the same. Spawn harder ones differently?
|
||||
-- --------------------------------------
|
||||
-- local name = fun_caves.fortress_spawns[math.random(#fun_caves.fortress_spawns)]
|
||||
-- minetest.add_entity(new_mob_pos, name)
|
||||
-- end
|
||||
-- end
|
||||
--end
|
||||
|
||||
if pos.y >= 11168 and pos.y <= 15168 then
|
||||
if not players_in_orbit[player_name] then
|
||||
player:set_physics_override(gravity_off)
|
||||
|
@ -421,10 +373,121 @@ minetest.register_abm({
|
|||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:coffer"},
|
||||
interval = time_factor,
|
||||
chance = 10,
|
||||
action = function(p0, node, _, _)
|
||||
minetest.remove_node(p0)
|
||||
end,
|
||||
})
|
||||
|
||||
------------------------------------------------------------
|
||||
-- creation
|
||||
------------------------------------------------------------
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:dungeon_floor_1"},
|
||||
interval = 20 * time_factor,
|
||||
chance = 250,
|
||||
catch_up = false,
|
||||
action = function(pos, node, aoc, active_object_count_wider)
|
||||
if not (pos and node) or active_object_count_wider > 10 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
|
||||
|
||||
--------------------------------------
|
||||
-- Mobs are treated exacty the same. Spawn harder ones differently?
|
||||
--------------------------------------
|
||||
local name = fun_caves.fortress_spawns[math.random(#fun_caves.fortress_spawns)]
|
||||
local mob = minetest.add_entity(pos, name)
|
||||
if not mob then
|
||||
return
|
||||
end
|
||||
print('spawning '..name)
|
||||
|
||||
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_fortress = true
|
||||
factor = factor * 1.5
|
||||
mob.hp_max = math.floor(mob.hp_max * factor)
|
||||
mob.damage = math.floor(mob.damage * factor)
|
||||
mob.object:set_hp(mob.hp_max)
|
||||
mob.health = mob.hp_max
|
||||
mob.initial_promotion = true
|
||||
check_for_death(mob)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:dungeon_floor_1"},
|
||||
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"},
|
||||
interval = time_factor,
|
||||
chance = 100,
|
||||
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
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"fun_caves:tree"},
|
||||
neighbors = {'fire:basic_flame'},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue