mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-23 08:29:34 +01:00
Add punch mobs knockback to players when hit
This commit is contained in:
parent
8c9356a18c
commit
1ed3377559
1 changed files with 17 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
local vector_direction = vector.direction
|
local vector_direction = vector.direction
|
||||||
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
||||||
local vector_distance = vector.distance
|
local vector_distance = vector.distance
|
||||||
|
local vector_multiply = vector.multiply
|
||||||
--[[
|
--[[
|
||||||
_____ _ _
|
_____ _ _
|
||||||
| ___| | | | |
|
| ___| | | | |
|
||||||
|
@ -129,4 +130,20 @@ mobs.punch_attack = function(self)
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
self.punch_timer = self.punch_timer_cooloff
|
self.punch_timer = self.punch_timer_cooloff
|
||||||
|
|
||||||
|
|
||||||
|
--knockback
|
||||||
|
local pos1 = self.object:get_pos()
|
||||||
|
pos1.y = 0
|
||||||
|
local pos2 = self.attacking:get_pos()
|
||||||
|
pos2.y = 0
|
||||||
|
local dir = vector_direction(pos1,pos2)
|
||||||
|
|
||||||
|
dir = vector_multiply(dir,3)
|
||||||
|
|
||||||
|
if self.attacking:get_velocity().y <= 1 then
|
||||||
|
dir.y = 5
|
||||||
|
end
|
||||||
|
|
||||||
|
self.attacking:add_velocity(dir)
|
||||||
end
|
end
|
Loading…
Reference in a new issue