Spawn monsters/treasure by depth.
This commit is contained in:
parent
0405fb8448
commit
3fe63e8fd8
4 changed files with 94 additions and 38 deletions
74
dungeon.lua
74
dungeon.lua
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue