summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2017-07-29 19:57:55 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2017-07-29 19:57:55 +0100
commit83600fbba82a96d215e00262845ebfb06227165d (patch)
treefabb5d3f74dd9bc1943b3b15eeca35fe75a4328f
parent276c2fc0ceb73fdaddcb4f936d6f436aa9ac841a (diff)
mobs turn in small rotations
-rw-r--r--api.lua22
1 files changed, 14 insertions, 8 deletions
diff --git a/api.lua b/api.lua
index 2846ec6..2640cb6 100644
--- a/api.lua
+++ b/api.lua
@@ -139,7 +139,8 @@ end
-- set defined animation
local set_animation = function(self, anim)
- if not self.animation then return end
+ if not self.animation
+ or not anim then return end
self.animation.current = self.animation.current or ""
@@ -586,7 +587,6 @@ local do_env_damage = function(self)
-- don't fall when on ignore, just stand still
if self.standing_in == "ignore" then
self.object:setvelocity({x = 0, y = 0, z = 0})
- --print ("--- stopping on ignore")
end
local nodef = minetest.registered_nodes[self.standing_in]
@@ -706,7 +706,7 @@ local do_jump = function(self)
local v = self.object:getvelocity()
- v.y = self.jump_height -- + 1
+ v.y = self.jump_height
set_animation(self, "jump") -- only when defined
@@ -1432,8 +1432,8 @@ end
-- execute current state (stand, walk, run, attacks)
local do_states = function(self, dtime)
- local yaw = 0
-
+ local yaw = self.object:get_yaw() or 0
+print ("---- yaw", yaw)
if self.state == "stand" then
if random(1, 4) == 1 then
@@ -1462,7 +1462,9 @@ local do_states = function(self, dtime)
if lp.x > s.x then yaw = yaw + pi end
else
- yaw = (random(0, 360) - 180) / 180 * pi
+-- yaw = (random(0, 360) - 180) / 180 * pi
+
+ yaw = yaw + random(-0.5, 0.5)
end
yaw = set_yaw(self.object, yaw)
@@ -1542,7 +1544,9 @@ local do_states = function(self, dtime)
do_jump(self)
set_velocity(self, self.walk_velocity)
else
- yaw = (random(0, 360) - 180) / 180 * pi
+-- yaw = (random(0, 360) - 180) / 180 * pi
+
+ yaw = yaw + random(-0.5, 0.5)
end
else
@@ -1563,7 +1567,9 @@ local do_states = function(self, dtime)
elseif random(1, 100) <= 30 then
--yaw = random() * 2 * pi
- yaw = (random(0, 360) - 180) / 180 * pi
+-- yaw = (random(0, 360) - 180) / 180 * pi
+
+ yaw = yaw + random(-0.5, 0.5)
yaw = set_yaw(self.object, yaw)
end