mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-02-03 04:30:18 +01:00
add hard limit of 10 to mob velocity functions
This commit is contained in:
parent
68fef94ba8
commit
813909c86c
9
api.lua
9
api.lua
@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20200123",
|
version = "20200207",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -230,10 +230,11 @@ function mob_class:set_velocity(v)
|
|||||||
|
|
||||||
local yaw = (self.object:get_yaw() or 0) + self.rotate
|
local yaw = (self.object:get_yaw() or 0) + self.rotate
|
||||||
|
|
||||||
|
-- set velocity with hard limit of 10
|
||||||
self.object:set_velocity({
|
self.object:set_velocity({
|
||||||
x = (sin(yaw) * -v) + c_x,
|
x = max(-10, min((sin(yaw) * -v) + c_x, 10)),
|
||||||
y = self.object:get_velocity().y,
|
y = max(-10, min(self.object:get_velocity().y, 10)),
|
||||||
z = (cos(yaw) * v) + c_y
|
z = max(-10, min((cos(yaw) * v) + c_y, 10))
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user