Spawn monsters/treasure by depth.

This commit is contained in:
Duane 2016-08-03 02:55:30 -05:00
parent 0405fb8448
commit 3fe63e8fd8
4 changed files with 94 additions and 38 deletions

View file

@ -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)

View file

@ -47,32 +47,46 @@ minetest.register_node("fun_caves:dungeon_wall_2", newnode)
local treasures = {
{'fun_caves:aquamarine', 'fun_caves:garnet', 'fun_caves:zoisite', 'fun_caves:coral_gem', 'fun_caves:moonstone', 'fun_caves:pure_copper', 'fun_caves:sky_iron', 'fun_caves:sky_iron', 'fun_caves:sky_iron', 'fun_caves:sky_iron', 'default:obsidian'},
{'fun_caves:aquamarine', 'fun_caves:garnet', 'fun_caves:zoisite', 'fun_caves:coral_gem', 'fun_caves:moonstone', 'fun_caves:pure_copper', 'fun_caves:metallic_ice', 'fun_caves:metallic_ice', 'fun_caves:metallic_ice', 'fun_caves:metallic_ice', 'default:obsidian'},
{'fun_caves:aquamarine', 'fun_caves:garnet', 'fun_caves:zoisite', 'fun_caves:coral_gem', 'fun_caves:moonstone', 'default:obsidian'},
{'fun_caves:aquamarine', 'fun_caves:garnet', 'fun_caves:zoisite', 'fun_caves:coral_gem', 'fun_caves:moonstone', 'default:obsidian'},
{'fun_caves:aquamarine', 'fun_caves:garnet', 'fun_caves:zoisite', 'fun_caves:coral_gem', 'fun_caves:moonstone', 'default:obsidian'},
{'fun_caves:aquamarine', 'fun_caves:garnet', 'fun_caves:zoisite', 'fun_caves:coral_gem', 'fun_caves:moonstone', 'default:obsidian'},
{ level = 1, rarity = 10, name = 'default:apple 10', },
{ level = 1, rarity = 50, name = 'default:bronze_ingot 10', },
{ level = 1, rarity = 20, name = 'default:coal_lump 10', },
{ level = 1, rarity = 40, name = 'default:copper_ingot 10', },
{ level = 1, rarity = 60, name = 'default:diamond 10', },
{ level = 1, rarity = 60, name = 'default:gold_ingot 10', },
{ level = 1, rarity = 70, name = 'default:mese_crystal', },
{ level = 1, rarity = 80, name = 'default:obsidian', },
{ level = 1, rarity = 40, name = 'default:obsidian_shard', },
{ level = 1, rarity = 180, name = 'default:pick_diamond', },
{ level = 1, rarity = 210, name = 'default:pick_mese', },
{ level = 1, rarity = 30, name = 'default:steel_ingot 10', },
{ level = 1, rarity = 120, name = 'default:sword_diamond', },
{ level = 1, rarity = 140, name = 'default:sword_mese', },
{ level = 1, rarity = 10, name = 'default:wood 10', },
{ level = 1, rarity = 400, name = 'fun_caves:aquamarine', },
{ level = 1, rarity = 400, name = 'fun_caves:constant_flame', },
{ level = 1, rarity = 400, name = 'fun_caves:coral_gem', },
{ level = 1, rarity = 400, name = 'fun_caves:garnet', },
{ level = 2, rarity = 400, name = 'fun_caves:metallic_ice', },
{ level = 1, rarity = 480, name = 'fun_caves:moon_glass 10', },
{ level = 1, rarity = 240, name = 'fun_caves:moon_juice 10', },
{ level = 1, rarity = 400, name = 'fun_caves:moonstone', },
{ level = 1, rarity = 1000, name = 'fun_caves:philosophers_stone', },
{ level = 1, rarity = 320, name = 'fun_caves:pure_copper', },
{ level = 2, rarity = 60, name = 'fun_caves:silver_ingot 10', },
{ level = 1, rarity = 400, name = 'fun_caves:sky_iron', },
{ level = 1, rarity = 50, name = 'fun_caves:meteorite', },
{ level = 1, rarity = 1000, name = 'fun_caves:unobtainium', },
}
local filler = {'default:apple 50', 'default:coal_lump 99', 'default:wood 99', 'default:obsidian_shard', 'default:steel_ingot 10', 'default:mese_crystal', 'default:copper_ingot 10', 'default:bronze_ingot 10', 'default:diamond 10', 'fun_caves:silver_ingot 10', 'default:gold_ingot 10', 'fun_caves:moon_glass 25', 'fun_caves:moon_juice 50', 'default:sword_mese', 'default:pick_mese', 'default:sword_diamond', 'default:pick_diamond', 'fun_caves:constant_flame'}
if minetest.registered_entities['mobs_monster:stone_monster'] then
filler[#filler+1] = 'mobs_monster:stone_monster'
treasures[#treasures+1] = { level = 1, rarity = 400, name = 'mobs_monster:stone_monster', }
end
if minetest.registered_entities['mobs_monster:dungeon_master'] then
filler[#filler+1] = 'mobs_monster:dungeon_master'
treasures[#treasures+1] = { level = 1, rarity = 400, name = 'mobs_monster:dungeon_master', }
end
local trophies = {
{'fun_caves:unobtainium', 'fun_caves:philosophers_stone'},
{'fun_caves:unobtainium', 'fun_caves:philosophers_stone'},
{'fun_caves:unobtainium', 'fun_caves:philosophers_stone'},
{'fun_caves:unobtainium', 'fun_caves:philosophers_stone'},
{'fun_caves:unobtainium', 'fun_caves:philosophers_stone'},
{'fun_caves:unobtainium', 'fun_caves:philosophers_stone'},
}
local chest_formspec =
"size[8,9]" ..
default.gui_bg ..
@ -98,20 +112,28 @@ newnode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if not meta then
return
end
local depth = math.max(1, math.ceil(pos.y / -2000))
local level = math.max(1, math.floor(pos.y / -4900))
local ready = meta:get_string('formspec')
if ready == '' then
local level = math.max(6, math.ceil(pos.y / math.floor(max_depth / 6)))
local big_item = treasures[level][math.random(#treasures[level])]
if treasures and ready == '' then
meta:set_string("formspec", chest_formspec)
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
inv:add_item('main', big_item)
for i = 1, math.random(12) do
inv:add_item('main', filler[math.random(#filler)])
end
if math.random(70) == 1 then
inv:add_item('main', trophies[level][math.random(#trophies[level])])
local something
for i = 1, 100 do
for j = 1, 3 * depth do
for _, tre in pairs(treasures) do
if tre.name and tre.level and tre.rarity and tre.level <= level and math.random(tre.rarity) == 1 then
inv:add_item('main', tre.name)
something = true
end
end
end
if something then
break
end
end
end
end

View file

@ -821,7 +821,7 @@ if fun_caves.path then
dofile(fun_caves.path.."/demon.lua")
end
fun_caves.fortress_spawns = {}
fun_caves.dungeon_spawns = {}
local t_mobs = {
"mobs_monster:dungeon_master",
"mobs_monster:lava_flan",
@ -851,7 +851,27 @@ local t_mobs = {
}
for _, mob in pairs(t_mobs) do
if minetest.registered_entities[mob] then
--mobs:register_spawn(mob, {"fun_caves:dungeon_floor_1"}, 20, 0, 2000, 5, 31000)
fun_caves.fortress_spawns[#fun_caves.fortress_spawns+1] = mob
local obj = minetest.registered_entities[mob]
if obj.hp_max and obj.hp_min and obj.damage then
local hp = (obj.hp_min + obj.hp_max) / 2
local level = math.floor(hp / 10 + obj.damage + 0.5)
fun_caves.dungeon_spawns[#fun_caves.dungeon_spawns+1] = {
name = mob,
level = level,
}
end
end
end
table.sort(fun_caves.dungeon_spawns, function(a, b)
if a.level < b.level then
return true
elseif a.level > b.level then
return false
elseif a.name < b.name then
return true
else
return false
end
end)

View file

@ -9,7 +9,7 @@ function minetest.is_protected(pos, name)
end
local node = get_node_or_nil(pos)
if node and get_item_group(node.name, "fortress") ~= 0 then
if node and get_item_group(node.name, "dungeon") ~= 0 then
return true
end
if node and node.name == 'fun_caves:translocator' and (name == '' or not minetest.get_player_by_name(name)) then