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

simplify yaw rotation

This commit is contained in:
TenPlus1 2017-01-17 15:02:47 +00:00
parent dcae1b846a
commit 58317c55b2

22
api.lua
View File

@ -112,8 +112,8 @@ set_yaw = function(self, yaw)
return return
end end
self.yaw = yaw self.yaw = yaw - self.rotate
self.object:setyaw(yaw) self.object:setyaw(self.yaw)
end end
@ -1284,7 +1284,7 @@ local follow_flop = function(self)
z = p.z - s.z z = p.z - s.z
} }
local yaw = (atan2(vec.z, vec.x) - pi / 2) - self.rotate local yaw = atan2(vec.z, vec.x) - pi / 2
set_yaw(self, yaw) set_yaw(self, yaw)
@ -1389,7 +1389,7 @@ local do_states = function(self, dtime)
z = lp.z - s.z z = lp.z - s.z
} }
yaw = (atan2(vec.z, vec.x) - pi / 2) - self.rotate yaw = atan2(vec.z, vec.x) - pi / 2
else else
yaw = random() * 2 * pi yaw = random() * 2 * pi
end end
@ -1453,7 +1453,7 @@ local do_states = function(self, dtime)
z = lp.z - s.z z = lp.z - s.z
} }
yaw = atan2(vec.z, vec.x) + pi / 2 - self.rotate yaw = atan2(vec.z, vec.x) + pi / 2
else else
yaw = random() * 2 * pi yaw = random() * 2 * pi
end end
@ -1465,7 +1465,7 @@ local do_states = function(self, dtime)
z = lp.z - s.z z = lp.z - s.z
} }
yaw = atan2(vec.z, vec.x) + pi / 2 - self.rotate yaw = atan2(vec.z, vec.x) + pi / 2
end end
set_yaw(self, yaw) set_yaw(self, yaw)
@ -1560,7 +1560,7 @@ local do_states = function(self, dtime)
z = p.z - s.z z = p.z - s.z
} }
yaw = atan2(vec.z, vec.x) - pi / 2 - self.rotate yaw = atan2(vec.z, vec.x) - pi / 2
set_yaw(self, yaw) set_yaw(self, yaw)
@ -1724,7 +1724,7 @@ local do_states = function(self, dtime)
z = p.z - s.z z = p.z - s.z
} }
yaw = (atan2(vec.z, vec.x) - pi / 2) - self.rotate yaw = atan2(vec.z, vec.x) - pi / 2
set_yaw(self, yaw) set_yaw(self, yaw)
@ -1832,7 +1832,7 @@ local do_states = function(self, dtime)
z = p.z - s.z z = p.z - s.z
} }
yaw = (atan2(vec.z, vec.x) - pi / 2) - self.rotate yaw = atan2(vec.z, vec.x) - pi / 2
set_yaw(self, yaw) set_yaw(self, yaw)
@ -2095,7 +2095,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
z = lp.z - s.z z = lp.z - s.z
} }
local yaw = atan(vec.z / vec.x) + 3 * pi / 2 - self.rotate local yaw = atan(vec.z / vec.x) + 3 * pi / 2
if lp.x > s.x then if lp.x > s.x then
yaw = yaw + pi yaw = yaw + pi
@ -2233,7 +2233,7 @@ local mob_activate = function(self, staticdata, dtime_s, def)
-- set anything changed above -- set anything changed above
self.object:set_properties(self) self.object:set_properties(self)
set_yaw(self, ((random(0, 360) - 180) / 180 * pi)) set_yaw(self, random() * 2 * pi)
update_tag(self) update_tag(self)
end end