fix crash in animalia.action_melee when target disappears immediately when punched

This commit is contained in:
Jacob Lifshay 2024-09-07 16:30:44 -07:00
parent 259e741282
commit 696a051ad5
No known key found for this signature in database

View file

@ -591,12 +591,14 @@ function animalia.action_melee(self, target)
if stage == 2
and dist < mob.width + 1 then
mob:punch_target(target)
local knockback = minetest.calculate_knockback(
target, mob.object, 1.0,
{damage_groups = {fleshy = mob.damage}},
dir, 2.0, mob.damage
)
target:add_velocity({x = dir.x * knockback, y = dir.y * knockback, z = dir.z * knockback})
if target:get_pos() then -- target may have died and disappeared
local knockback = minetest.calculate_knockback(
target, mob.object, 1.0,
{damage_groups = {fleshy = mob.damage}},
dir, 2.0, mob.damage
)
target:add_velocity({x = dir.x * knockback, y = dir.y * knockback, z = dir.z * knockback})
end
stage = 3
end