mcl_util.deal_damage: Only deal damage to players / mobs that are not already dead

This commit is contained in:
Lizzy Fleckenstein 2021-05-05 08:54:03 +02:00
parent 70db02306f
commit be0cf5788d
1 changed files with 8 additions and 2 deletions

View File

@ -484,12 +484,18 @@ function mcl_util.deal_damage(target, damage, mcl_reason)
elseif luaentity._cmi_is_mob then
-- local puncher = mcl_reason and mcl_reason.direct or target
-- target:punch(puncher, 1.0, {full_punch_interval = 1.0, damage_groups = {fleshy = damage}}, vector.direction(puncher:get_pos(), target:get_pos()), damage)
luaentity.health = luaentity.health - damage
if luaentity.health > 0 then
luaentity.health = luaentity.health - damage
end
return
end
end
target:set_hp(target:get_hp() - damage, {_mcl_reason = mcl_reason})
local hp = target:get_hp()
if hp > 0 then
target:set_hp(hp - damage, {_mcl_reason = mcl_reason})
end
end
function mcl_util.get_hp(obj)