forked from VoxeLibre/VoxeLibre
Add pvp knockback reduction when moving towards player while attacking
This commit is contained in:
parent
14cec16c63
commit
fe90424ee4
|
@ -318,6 +318,12 @@ function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool
|
||||||
minetest.after(0.25, function()
|
minetest.after(0.25, function()
|
||||||
player:add_velocity({x = 0, y = (v.y + added_v) * -0.375, z = 0})
|
player:add_velocity({x = 0, y = (v.y + added_v) * -0.375, z = 0})
|
||||||
end)
|
end)
|
||||||
|
-- reduce knockback when moving towards hitter while attacking
|
||||||
|
local self_dir_dot = (v.x * dir.x) + (v.z * dir.z)
|
||||||
|
local control = player:get_player_control()
|
||||||
|
if self_dir_dot < -4.3 and control.up and control.LMB then
|
||||||
|
knockback = knockback * 0.6
|
||||||
|
end
|
||||||
-- remove knockback if invulnerable
|
-- remove knockback if invulnerable
|
||||||
if invul > 0 then
|
if invul > 0 then
|
||||||
knockback = 0
|
knockback = 0
|
||||||
|
|
Loading…
Reference in New Issue