]> git.lizzy.rs Git - Crafter.git/blobdiff - mods/mob/api/api_hook.lua
Make head code for mobs reuse same data
[Crafter.git] / mods / mob / api / api_hook.lua
index 6a3c36034473b8788e0a145f68086624802d8eb4..6c734bd15f570635e34831ad849fdf6b06ae1143 100644 (file)
@@ -1,3 +1,4 @@
+local minetest = minetest
 --class 
 mobs = {}
 
@@ -29,6 +30,7 @@ mob_register.initial_properties = {
        automatic_face_movement_dir = def.automatic_face_movement_dir,
        automatic_face_movement_max_rotation_per_sec = def.automatic_face_movement_max_rotation_per_sec,
        makes_footstep_sound = def.makes_footstep_sound,
+       static_save = false,
 }
 
 
@@ -90,6 +92,7 @@ mob_register.die_sound = def.die_sound
 mob_register.attack_type = def.attack_type
 if def.attack_type == "explode" then
        mob_register.tnt_tick_timer = 0
+       mob_register.explosion_type = def.explosion_type
 end
 mob_register.explosion_radius = def.explosion_radius
 mob_register.explosion_power = def.explosion_power
@@ -104,6 +107,10 @@ mob_register.custom_function_end = def.custom_function_end
 
 mob_register.projectile_timer_cooldown = def.projectile_timer_cooldown
 mob_register.attacked_hostile = def.attacked_hostile
+if not def.hostile and not def.attacked_hostile then
+       mob_register.scared = false
+       mob_register.scared_timer = 0
+end
 mob_register.attack_damage = def.attack_damage
 
 mob_register.projectile_timer = 0
@@ -128,6 +135,16 @@ mob_register.custom_on_death = def.custom_on_death
 
 mob_register.custom_on_activate = def.custom_on_activate
 
+mob_register.custom_on_punch = def.custom_on_punch
+
+mob_register.c_mob_data = def.c_mob_data
+
+mob_register.deactivating = false
+
+mob_register.on_fire = false
+
+mob_register.fire_table = def.fire_table
+
 if def.pathfinds then
        --mob_register.path = {}
        mob_register.pathfinding_timer = 0
@@ -151,6 +168,7 @@ mob_register.on_step = function(self, dtime,moveresult)
                self.custom_function_begin(self,dtime)
        end
        
+       flow(self)
        self.collision_detection(self)
        if self.fall_damage then
                self.fall_damage(self)
@@ -171,6 +189,10 @@ mob_register.on_step = function(self, dtime,moveresult)
 
                self.manage_hurt_color_timer(self,dtime)
 
+               if self.manage_scared_timer then
+                       self.manage_scared_timer(self,dtime)
+               end
+
                if self.set_animation then
                        self.set_animation(self)
                end