use stepheight for mobs

This commit is contained in:
cale 2016-09-30 18:34:25 +02:00
parent 4ecd4b33de
commit 8377a3bef3
2 changed files with 5 additions and 16 deletions

View File

@ -29,6 +29,7 @@ function mobs.register_mob(name, def)
is_visible = true,
makes_footstep_sound = false,
automatic_rotate = true,
stepheight = 1.1,
speed = 0,
anim = "",
t = 0.0,
@ -90,11 +91,7 @@ function mobs.register_mob(name, def)
local p = self.object:getpos()
local v = vector.multiply(vector.direction(p, obj_p), 4)
local d = obj_p.y - p.y
if d > 0 and d < 2 then
v.y = 2
else
v.y = (def.gravity or -9.2)
end
v.y = (def.gravity or -9.2)
self.object:setvelocity(v)
local yaw = math.atan(v.z/v.x)+math.pi/2

View File

@ -26,6 +26,7 @@ function pets.register_pet(name, def)
pl = nil,
is_pet = false,
anim = "stand",
stepheight = 1.1,
on_rightclick = function(self, clicker)
if not clicker or not clicker:is_player() then
@ -57,18 +58,9 @@ function pets.register_pet(name, def)
t.z = t.z + 1.5
if vector.distance(self.object:getpos(), t) > 2 then
local vec = vector.direction(self.object:getpos(), t)
--vec.y = vec.y * 10
if self.object:getpos().y < t.y+0.5 then
vec.y= vec.y + 2
else
vec.y= -3
end
vec.y= -3
self.object:setvelocity(vector.multiply(vec, 3))
local yaw = math.atan(vec.z/vec.x)+math.pi/2
yaw = yaw+(math.pi/2)
if t.x > t.z then
yaw = yaw+math.pi
end
local yaw = math.atan(vec.z/vec.x)
self.object:setyaw(yaw)
if def.animations then
if self.anim ~= "walk" then