Add monster-summoning chest.
This commit is contained in:
parent
3244b2f1ff
commit
f182dd902a
1 changed files with 32 additions and 1 deletions
33
dungeon.lua
33
dungeon.lua
|
@ -196,7 +196,38 @@ newnode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
|||
|
||||
local ready = meta:get_string('formspec')
|
||||
if treasures and ready == '' then
|
||||
if math.random(20) == 1 then
|
||||
if math.random(10) == 1 then
|
||||
minetest.remove_node(pos)
|
||||
|
||||
local desc = fun_caves.dungeon_spawns[math.random(#fun_caves.dungeon_spawns)]
|
||||
|
||||
if not desc then
|
||||
return
|
||||
end
|
||||
|
||||
local obj = minetest.add_entity(pos, desc.name)
|
||||
if not obj then
|
||||
return
|
||||
end
|
||||
local mob = obj:get_luaentity()
|
||||
if not mob then
|
||||
return
|
||||
end
|
||||
|
||||
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_dungeon = true
|
||||
factor = factor * 1.5
|
||||
mob.hp_max = math.floor(mob.hp_max * factor)
|
||||
mob.damage = math.floor(mob.damage * factor)
|
||||
mob.health = math.floor(mob.health * factor)
|
||||
mob.object:set_hp(mob.health)
|
||||
mob.initial_promotion = true
|
||||
check_for_death(mob)
|
||||
|
||||
--print('Dungeon quality '..desc.name..': '..mob.health..' health, '..mob.damage..' damage')
|
||||
end
|
||||
elseif math.random(20) == 1 then
|
||||
local player_name = clicker:get_player_name()
|
||||
if not player_name or player_name == '' or not fun_caves.set_status then
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue