forked from VoxeLibre/VoxeLibre
Fix third party mobs getting no damage from deal_damage
This commit is contained in:
parent
6b8226dae3
commit
6907f7cc4f
|
@ -545,26 +545,16 @@ function mcl_util.deal_damage(target, damage, mcl_reason)
|
||||||
if luaentity then
|
if luaentity then
|
||||||
if luaentity.deal_damage then
|
if luaentity.deal_damage then
|
||||||
luaentity:deal_damage(damage, mcl_reason or {type = "generic"})
|
luaentity:deal_damage(damage, mcl_reason or {type = "generic"})
|
||||||
return
|
else
|
||||||
elseif luaentity.is_mob then
|
local puncher = mcl_reason and mcl_reason.direct or target
|
||||||
-- 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)
|
||||||
-- target:punch(puncher, 1.0, {full_punch_interval = 1.0, damage_groups = {fleshy = damage}}, vector.direction(puncher:get_pos(), target:get_pos()), damage)
|
|
||||||
if luaentity.health > 0 then
|
|
||||||
luaentity.health = luaentity.health - damage
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
else -- Player
|
||||||
|
local hp = target:get_hp()
|
||||||
|
|
||||||
local is_immortal = target:get_armor_groups().immortal or 0
|
if hp > 0 then
|
||||||
if is_immortal>0 then
|
target:set_hp(hp - damage, {_mcl_reason = mcl_reason})
|
||||||
return
|
end
|
||||||
end
|
|
||||||
|
|
||||||
local hp = target:get_hp()
|
|
||||||
|
|
||||||
if hp > 0 then
|
|
||||||
target:set_hp(hp - damage, {_mcl_reason = mcl_reason})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue