mirror of
https://github.com/ElCeejo/animalia.git
synced 2025-04-30 13:31:39 -04:00
fix crash in animalia.action_melee when target disappears immediately when punched
This commit is contained in:
parent
259e741282
commit
696a051ad5
1 changed files with 8 additions and 6 deletions
|
@ -591,12 +591,14 @@ function animalia.action_melee(self, target)
|
||||||
if stage == 2
|
if stage == 2
|
||||||
and dist < mob.width + 1 then
|
and dist < mob.width + 1 then
|
||||||
mob:punch_target(target)
|
mob:punch_target(target)
|
||||||
|
if target:get_pos() then -- target may have died and disappeared
|
||||||
local knockback = minetest.calculate_knockback(
|
local knockback = minetest.calculate_knockback(
|
||||||
target, mob.object, 1.0,
|
target, mob.object, 1.0,
|
||||||
{damage_groups = {fleshy = mob.damage}},
|
{damage_groups = {fleshy = mob.damage}},
|
||||||
dir, 2.0, mob.damage
|
dir, 2.0, mob.damage
|
||||||
)
|
)
|
||||||
target:add_velocity({x = dir.x * knockback, y = dir.y * knockback, z = dir.z * knockback})
|
target:add_velocity({x = dir.x * knockback, y = dir.y * knockback, z = dir.z * knockback})
|
||||||
|
end
|
||||||
|
|
||||||
stage = 3
|
stage = 3
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue