]> git.lizzy.rs Git - Crafter.git/blobdiff - mods/mob/api/api_hook.lua
Implement better path shortcutting when less than 4 steps in path
[Crafter.git] / mods / mob / api / api_hook.lua
index 8f945b859388f047db4e22cb48fc9a3c9d269ac1..40b062697d773a1cb9b310ee8b685ab31205e7e0 100644 (file)
@@ -55,7 +55,13 @@ mob_register.death_animation_timer = 0
 mob_register.dead = false
 
 mob_register.mob = true
+
 mob_register.hostile = def.hostile
+if def.friendly_in_daylight == true then
+       mob_register.friendly_in_daylight = def.friendly_in_daylight
+       mob_register.friendly_in_daylight_timer = 0
+end
+
 mob_register.hostile_cooldown = def.hostile_cooldown
 
 mob_register.hostile_timer = 0
@@ -121,7 +127,8 @@ mob_register.mob = true
 mob_register.collision_boundary = def.collision_boundary or 1
 
 if def.pathfinds then
-       mob_register.path = {}
+       --mob_register.path = {}
+       mob_register.pathfinding_timer = 0
 end
 
 mobs.create_movement_functions(def,mob_register)
@@ -153,6 +160,14 @@ mob_register.on_step = function(self, dtime,moveresult)
                        self.look_around(self,dtime)
                end
                
+               if self.pathfinding then
+                       self.pathfinding(self,dtime)
+               end
+
+               if self.handle_friendly_in_daylight_timer then
+                       self.handle_friendly_in_daylight_timer(self,dtime)
+               end
+
                self.manage_punch_timer(self,dtime)
        else
                self.manage_death_animation(self,dtime)