Fix mob promotion problems.

This commit is contained in:
Duane 2016-08-04 04:43:16 -05:00
parent 366a2125b8
commit 8f4c8f7668

View file

@ -135,10 +135,13 @@ minetest.register_globalstep(function(dtime)
local factor = 1 + (math.max(math.abs(pos.x), math.abs(pos.y), math.abs(pos.z)) / 6200)
mob.hp_max = math.floor(mob.hp_max * factor)
mob.damage = math.floor(mob.damage * factor)
mob.object:set_hp(mob.hp_max)
mob.health = mob.hp_max
mob.health = math.floor(mob.health * factor)
mob.object:set_hp(mob.health)
mob.initial_promotion = true
check_for_death(mob)
--local name = mob.object:get_entity_name() or ''
--print('Promoting '..name..': '..mob.health..' health, '..mob.damage..' damage')
end
end
end
@ -422,11 +425,14 @@ minetest.register_abm({
local name = desc.name
local level = desc.level
local mob = minetest.add_entity(pos, name)
local obj = minetest.add_entity(pos, name)
if not obj then
return
end
local mob = obj:get_luaentity()
if not mob then
return
end
--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)
@ -434,10 +440,12 @@ minetest.register_abm({
factor = factor * 1.5
mob.hp_max = math.floor(mob.hp_max * factor)
mob.damage = math.floor(mob.damage * factor)
mob.object:set_hp(mob.hp_max)
mob.health = mob.hp_max
mob.health = math.floor(mob.health * factor)
mob.object:set_hp(mob.health)
mob.initial_promotion = true
check_for_death(mob)
--print('Dungeon quality '..name..': '..mob.health..' health, '..mob.damage..' damage')
end
end
})