]> git.lizzy.rs Git - Crafter.git/blobdiff - mods/mob/api/animation.lua
Fix mobs catching on fire at night
[Crafter.git] / mods / mob / api / animation.lua
index 2c52b1cb726d777b47cc341ad766c690128d6145..5be7b569c97b963bb6375b381a1f6a855b39400a 100644 (file)
@@ -1,18 +1,27 @@
+local math,vector = math,vector
+
+local speed
+local self_rotation
+local currentvel
+local goal = vector.new(0,0,0)
+local acceleration
 -- 
 mobs.create_animation_functions = function(def,mob_register)
-       mob_register.set_animation = function(self)
-               if self.speed == 0 or vector.equals(self.direction,vector.new(0,0,0)) then
-                       self.current_animation = 0
-                       self.object:set_animation(def.standing_frame, 1, 0, true)
-               else
-                       if self.current_animation ~= 1 then
-                               self.object:set_animation(def.moving_frame, 1, 0, true)
-                               self.current_animation = 1
+       if def.movement_type ~= "jump" then
+               mob_register.set_animation = function(self)
+                       if self.speed == 0 or vector.equals(self.direction,vector.new(0,0,0)) then
+                               self.current_animation = 0
+                               self.object:set_animation(def.standing_frame, 1, 0, true)
+                       else
+                               if self.current_animation ~= 1 then
+                                       self.object:set_animation(def.moving_frame, 1, 0, true)
+                                       self.current_animation = 1
+                               end
+                               
+                               speed = self.object:get_velocity()
+                               speed.y = 0
+                               self.object:set_animation_frame_speed(vector.distance(vector.new(0,0,0),speed)*def.animation_multiplier)
                        end
-                       
-                       local speed = self.object:get_velocity()
-                       speed.y = 0
-                       self.object:set_animation_frame_speed(vector.distance(vector.new(0,0,0),speed)*def.animation_multiplier)
                end
        end
 
@@ -21,7 +30,7 @@ mobs.create_animation_functions = function(def,mob_register)
                if self.death_animation_timer >= 0 and self.dead == true then
                        self.death_animation_timer = self.death_animation_timer - dtime
                        
-                       local self_rotation = self.object:get_rotation()
+                       self_rotation = self.object:get_rotation()
                        
                        if self.death_rotation == "x" then
                                if self_rotation.x < math.pi/2 then
@@ -36,12 +45,11 @@ mobs.create_animation_functions = function(def,mob_register)
                        end
                        
                        --print(self.death_animation_timer)
-                       local currentvel = self.object:getvelocity()
-                       local goal = vector.new(0,0,0)
-                       local acceleration = vector.new(goal.x-currentvel.x,0,goal.z-currentvel.z)
+                       currentvel = self.object:get_velocity()
+                       acceleration = vector.new(goal.x-currentvel.x,0,goal.z-currentvel.z)
                        acceleration = vector.multiply(acceleration, 0.05)
                        self.object:add_velocity(acceleration)
-                       self.object:set_animation({x=0,y=0}, 15, 0, true)
+                       self.object:set_animation(def.standing_frame, 15, 0, true)
                end
        end
        return(mob_register)