Mobs take damage in damage_per_second nodes

This commit is contained in:
Wuzzy 2019-09-22 23:58:16 +02:00
parent bb724dd893
commit a198d3c1d9

View File

@ -182,6 +182,7 @@ function mobs:register_mob(name, def)
light_damage = def.light_damage or 0,
water_damage = def.water_damage or 0,
lava_damage = def.lava_damage or 0,
takes_node_damage = def.takes_node_damage or true,
fall_damage = def.fall_damage or 1,
fall_speed = def.fall_speed or -10, -- must be lower than -2 (default: -10)
drops = def.drops or {},
@ -524,6 +525,18 @@ function mobs:register_mob(name, def)
if check_for_death(self) then return end
end
-- node damage
if self.takes_node_damage == true
and nodef.damage_per_second > 0 then
self.object:set_hp(self.object:get_hp() - nodef.damage_per_second)
if enable_blood then
effect(pos, self.blood_amount, self.blood_texture)
else
effect(pos, self.blood_amount, "default_grass_clump_tall.png")
end
if check_for_death(self) then return end
end
end
local do_jump = function(self)