]> git.lizzy.rs Git - Crafter.git/blobdiff - mods/mob/api/head_code.lua
Make combat a bit more fast paced
[Crafter.git] / mods / mob / api / head_code.lua
index a06936dc7f01f2f9c826ccce827976dbae5828bc..6fe07e1423e6ae9547f70129b0f241ef879e21f4 100644 (file)
@@ -108,6 +108,9 @@ mobs.create_head_functions = function(def,mob_register)
                                                ---begin pitch calculation
                                                --feed a 2D coordinate flipped into dir to yaw to calculate pitch
                                                head_rotation.x = degrees(minetest.dir_to_yaw(vector.new(vector.distance(vector.new(pos.x,0,pos.z),vector.new(pos2.x,0,pos2.z)),0,pos.y-pos2.y))+(math.pi/2))
+                                               if self.flip_pitch then
+                                                       head_rotation.x = head_rotation.x * -1
+                                               end
                                                head_rotation.z = head_yaw
                                                self.object:set_bone_position(self.head_bone, head_position, head_rotation)
                                                return(true)
@@ -148,7 +151,7 @@ mobs.create_head_functions = function(def,mob_register)
                                --print(self.head_rotation.y)
                                --if passed a direction to look
                                local pos = self.object:get_pos()
-                               local body_yaw = self.object:get_yaw()-math.pi/2
+                               local body_yaw = self.object:get_yaw()-math.pi/2+self.rotational_correction
                                                                
                                local dir = vector.multiply(minetest.yaw_to_dir(body_yaw),self.head_directional_offset)
                                
@@ -194,6 +197,9 @@ mobs.create_head_functions = function(def,mob_register)
                                                ---begin pitch calculation
                                                --feed a 2D coordinate flipped into dir to yaw to calculate pitch
                                                head_rotation.x = degrees(minetest.dir_to_yaw(vector.new(vector.distance(vector.new(pos.x,0,pos.z),vector.new(pos2.x,0,pos2.z)),0,pos.y-pos2.y))+(math.pi/2))
+                                               if self.flip_pitch then
+                                                       head_rotation.x = head_rotation.x * -1
+                                               end
                                                head_rotation.y = -head_yaw
                                                self.object:set_bone_position(self.head_bone, head_position, head_rotation)
                                                return(true)