1
0
Fork 0

Counteract self forward velocity when hit by players in pvp

This commit is contained in:
Eliy21 2023-12-20 15:50:37 +00:00
parent e19de85990
commit 96fa6c251e
1 changed files with 5 additions and 0 deletions

View File

@ -308,6 +308,11 @@ function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool
knockback = knockback + 0.609375
end
end
-- counteract forward velocity when hit
local self_dir_dot = (v.x * dir.x) + (v.z * dir.z)
if self_dir_dot < 0 then
player:add_velocity({x = v.x * -1, y = 0, z = v.z * -1})
end
-- add player velocity to knockback
local h_name = hitter:get_player_name()
local hv = hitter:get_velocity()