mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-23 08:29:34 +01:00
Implement rotation locking when standing, fix rotation unlock/lock for fly/swim mobs
This commit is contained in:
parent
fa059b5df2
commit
aac1e19336
2 changed files with 29 additions and 0 deletions
|
@ -102,6 +102,8 @@ local land_state_execution = function(self,dtime)
|
||||||
mobs.reverse_explosion_animation(self,dtime)
|
mobs.reverse_explosion_animation(self,dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mobs.lock_yaw(self)
|
||||||
|
|
||||||
elseif self.state == "walk" then
|
elseif self.state == "walk" then
|
||||||
|
|
||||||
self.walk_timer = self.walk_timer - dtime
|
self.walk_timer = self.walk_timer - dtime
|
||||||
|
@ -275,6 +277,8 @@ local swim_state_execution = function(self,dtime)
|
||||||
mobs.set_static_pitch(self)
|
mobs.set_static_pitch(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mobs.lock_yaw(self)
|
||||||
|
|
||||||
elseif self.state == "swim" then
|
elseif self.state == "swim" then
|
||||||
|
|
||||||
self.walk_timer = self.walk_timer - dtime
|
self.walk_timer = self.walk_timer - dtime
|
||||||
|
@ -307,6 +311,9 @@ local swim_state_execution = function(self,dtime)
|
||||||
if self.tilt_swim then
|
if self.tilt_swim then
|
||||||
mobs.set_dynamic_pitch(self)
|
mobs.set_dynamic_pitch(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--enable rotation locking
|
||||||
|
mobs.movement_rotation_lock(self)
|
||||||
end
|
end
|
||||||
--flop around if not inside swim node
|
--flop around if not inside swim node
|
||||||
else
|
else
|
||||||
|
@ -415,6 +422,8 @@ local fly_state_execution = function(self,dtime)
|
||||||
mobs.set_static_pitch(self)
|
mobs.set_static_pitch(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mobs.lock_yaw(self)
|
||||||
|
|
||||||
elseif self.state == "fly" then
|
elseif self.state == "fly" then
|
||||||
|
|
||||||
self.walk_timer = self.walk_timer - dtime
|
self.walk_timer = self.walk_timer - dtime
|
||||||
|
@ -446,6 +455,10 @@ local fly_state_execution = function(self,dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
mobs.set_fly_velocity(self,self.walk_velocity)
|
mobs.set_fly_velocity(self,self.walk_velocity)
|
||||||
|
|
||||||
|
--enable rotation locking
|
||||||
|
mobs.movement_rotation_lock(self)
|
||||||
|
|
||||||
elseif self.state == "attack" then
|
elseif self.state == "attack" then
|
||||||
|
|
||||||
--execute mob attack type
|
--execute mob attack type
|
||||||
|
@ -544,6 +557,8 @@ local jump_state_execution = function(self,dtime)
|
||||||
--set the velocity of the mob
|
--set the velocity of the mob
|
||||||
mobs.set_velocity(self,0)
|
mobs.set_velocity(self,0)
|
||||||
|
|
||||||
|
mobs.lock_yaw(self)
|
||||||
|
|
||||||
elseif self.state == "jump" then
|
elseif self.state == "jump" then
|
||||||
|
|
||||||
self.walk_timer = self.walk_timer - dtime
|
self.walk_timer = self.walk_timer - dtime
|
||||||
|
|
|
@ -136,6 +136,20 @@ mobs.set_yaw_while_attacking = function(self)
|
||||||
self.yaw = new_yaw
|
self.yaw = new_yaw
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--this is used to unlock a mob's yaw after attacking
|
||||||
|
mobs.unlock_yaw = function(self)
|
||||||
|
if self.object:get_properties().automatic_face_movement_dir == false then
|
||||||
|
self.object:set_properties{automatic_face_movement_dir = self.rotate}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--this is used to lock a mob's yaw when they're standing
|
||||||
|
mobs.lock_yaw = function(self)
|
||||||
|
if self.object:get_properties().automatic_face_movement_dir then
|
||||||
|
self.object:set_properties{automatic_face_movement_dir = false}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local calculate_pitch = function(self)
|
local calculate_pitch = function(self)
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
|
Loading…
Reference in a new issue