Add more dungeon-like fortresses.
This commit is contained in:
parent
138858c2a2
commit
5abe211fb6
5 changed files with 288 additions and 188 deletions
64
abms.lua
64
abms.lua
|
@ -162,45 +162,45 @@ minetest.register_globalstep(function(dtime)
|
|||
return
|
||||
end
|
||||
|
||||
local do_fortress_spawns = (fun_caves.fortress_spawns and #fun_caves.fortress_spawns > 0)
|
||||
--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 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 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 #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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue