1
0
Fork 0

get rid of unecessary "if true" statement

This commit is contained in:
epCode 2022-10-09 16:57:26 -07:00 committed by Gitea
parent ef980f2ea0
commit 4a086db4c5
1 changed files with 32 additions and 33 deletions

View File

@ -336,52 +336,51 @@ end
local set_yaw = function(self, yaw, delay, dtime) local set_yaw = function(self, yaw, delay, dtime)
if self.noyaw then return end if self.noyaw then return end
if true then
self._turn_to = yaw self._turn_to = yaw
--clamp our yaw to a 360 range --clamp our yaw to a 360 range
if math.deg(self.object:get_yaw()) > 360 then if math.deg(self.object:get_yaw()) > 360 then
self.object:set_yaw(math.rad(10)) self.object:set_yaw(math.rad(10))
elseif math.deg(self.object:get_yaw()) < 0 then elseif math.deg(self.object:get_yaw()) < 0 then
self.object:set_yaw(math.rad(350)) self.object:set_yaw(math.rad(350))
end
--calculate the shortest way to turn to find our target
local target_shortest_path = shortest_term_of_yaw_rotatoin(self, self.object:get_yaw(), yaw, true)
--turn in the shortest path possible toward our target. if we are attacking, don't dance.
if math.abs(target_shortest_path) > 100 and (self.attack and self.attack:get_pos() or self.following and self.following:get_pos()) then
if self.following then
target_shortest_path = shortest_term_of_yaw_rotatoin(self, self.object:get_yaw(), minetest.dir_to_yaw(vector.direction(self.object:get_pos(), self.following:get_pos())), true)
else
target_shortest_path = shortest_term_of_yaw_rotatoin(self, self.object:get_yaw(), minetest.dir_to_yaw(vector.direction(self.object:get_pos(), self.attack:get_pos())), true)
end end
end
--calculate the shortest way to turn to find our target local ddtime = 0.05 --set_tick_rate
local target_shortest_path = shortest_term_of_yaw_rotatoin(self, self.object:get_yaw(), yaw, true)
--turn in the shortest path possible toward our target. if we are attacking, don't dance. if dtime then
if math.abs(target_shortest_path) > 100 and (self.attack and self.attack:get_pos() or self.following and self.following:get_pos()) then ddtime = dtime
if self.following then end
target_shortest_path = shortest_term_of_yaw_rotatoin(self, self.object:get_yaw(), minetest.dir_to_yaw(vector.direction(self.object:get_pos(), self.following:get_pos())), true)
else if math.abs(target_shortest_path) > 120*ddtime then
target_shortest_path = shortest_term_of_yaw_rotatoin(self, self.object:get_yaw(), minetest.dir_to_yaw(vector.direction(self.object:get_pos(), self.attack:get_pos())), true) if target_shortest_path > 0 then
end self.object:set_yaw(self.object:get_yaw()+3*ddtime)
else
self.object:set_yaw(self.object:get_yaw()-3*ddtime)
end end
local ddtime = 0.05 --set_tick_rate
if dtime then
ddtime = dtime
end
if math.abs(target_shortest_path) > 120*ddtime then
if target_shortest_path > 0 then
self.object:set_yaw(self.object:get_yaw()+3*ddtime)
else
self.object:set_yaw(self.object:get_yaw()-3*ddtime)
end
end
return yaw
end end
delay = delay or 0 delay = delay or 0
yaw = self.object:get_yaw()
if delay == 0 then if delay == 0 then
if self.shaking and dtime then if self.shaking and dtime then
yaw = yaw + (random() * 2 - 1) * 5 * dtime yaw = yaw + (random() * 2 - 1) * 5 * dtime
end end
self.object:set_yaw(yaw)
update_roll(self) update_roll(self)
return yaw return yaw
end end