1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2024-12-24 09:40:21 +01:00

add additional nil backups for set_velocity

This commit is contained in:
TenPlus1 2020-12-02 15:14:11 +00:00
parent a4d2918383
commit 4a6518eeba

View File

@ -277,10 +277,10 @@ function mob_class:set_velocity(v)
c_x, c_y = unpack(self:collision()) c_x, c_y = unpack(self:collision())
end end
local yaw = (self.object:get_yaw() or 0) + self.rotate local yaw = (self.object:get_yaw() or 0) + (self.rotate or 0)
-- nil check for velocity -- nil check for velocity
v = v or 0 v = v or 0.01
-- check if standing in liquid with max viscosity of 7 -- check if standing in liquid with max viscosity of 7
local visc = min(minetest.registered_nodes[self.standing_in].liquid_viscosity, 7) local visc = min(minetest.registered_nodes[self.standing_in].liquid_viscosity, 7)
@ -292,8 +292,8 @@ function mob_class:set_velocity(v)
v = v / (visc + 1) v = v / (visc + 1)
end end
-- set velocity with hard limit of 10 -- set velocity
local vel = self.object:get_velocity() local vel = self.object:get_velocity() or 0
local new_vel = { local new_vel = {
x = (sin(yaw) * -v) + c_x, x = (sin(yaw) * -v) + c_x,