Spawn monsters/treasure by depth.
This commit is contained in:
parent
0405fb8448
commit
3fe63e8fd8
4 changed files with 94 additions and 38 deletions
30
abms.lua
30
abms.lua
|
@ -61,7 +61,7 @@ local cold_stuff = {"group:surface_cold"}
|
|||
local poison_stuff = {"group:poison"}
|
||||
local gravity_off = {gravity = 0.1}
|
||||
local gravity_on = {gravity = 1}
|
||||
local fortress_group = {'group:fortress'}
|
||||
local dungeon_group = {'group:dungeon'}
|
||||
|
||||
local firework_active = false
|
||||
local function firework()
|
||||
|
@ -403,20 +403,34 @@ minetest.register_abm({
|
|||
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 target_level = math.max(2, math.ceil(pos.y / -2000))
|
||||
|
||||
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 name = desc.name
|
||||
local level = desc.level
|
||||
local mob = minetest.add_entity(pos, name)
|
||||
if not mob then
|
||||
return
|
||||
end
|
||||
--print('spawning '..name)
|
||||
--print('Spawned '..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
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue