]> git.lizzy.rs Git - Crafter.git/blobdiff - mods/mob/api/api_hook.lua
Overhaul mob collisionboxes and texture mod handling when hurt
[Crafter.git] / mods / mob / api / api_hook.lua
index 3067f62fd372c88a2b5d9da85c5ece50990d1521..4a79a895cea50cdbcb05061f033345eef67f883b 100644 (file)
@@ -13,7 +13,7 @@ mobs.register_mob = function(def)
 
 
 
-mob_register = {}
+local mob_register = {}
 
 ------------------------------------------------
 mob_register.initial_properties = {
@@ -45,6 +45,7 @@ if def.head_bone then
        mob_register.head_height_offset = def.head_height_offset
        mob_register.head_rotation_offset = def.head_rotation_offset
        mob_register.head_position_correction = def.head_position_correction
+       mob_register.head_coord = def.head_coord
 else
        print("create some other functions to turn mob " .. def.mobname)
 end
@@ -67,6 +68,7 @@ mob_register.view_distance = def.view_distance
 
 mob_register.punch_timer = 0
 mob_register.punched_timer = 0
+mob_register.group_attack = def.group_attack
 
 mob_register.death_rotation = def.death_rotation
 
@@ -84,6 +86,8 @@ mob_register.explosion_time = def.explosion_time
 mob_register.custom_function_begin = def.custom_function_begin
 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
+
 
 mob_register.projectile_timer = 0
 mob_register.projectile_type = def.projectile_type
@@ -97,6 +101,7 @@ mob_register.die_in_light = def.die_in_light
 mob_register.die_in_light_level = def.die_in_light_level
 
 mob_register.current_animation = 0
+mob_register.hurt_color_timer = 0
 
 mob_register.mob = true
 
@@ -120,6 +125,8 @@ mob_register.on_step = function(self, dtime)
        
        if self.dead == false and self.death_animation_timer == 0 then
                self.move(self,dtime)
+               
+               self.manage_hurt_color_timer(self,dtime)
                self.set_animation(self)
                
                if self.look_around then
@@ -130,6 +137,7 @@ mob_register.on_step = function(self, dtime)
                --self.debug_nametag(self,dtime)
        else
                self.manage_death_animation(self,dtime)
+               self.move_head(self,nil,dtime)
        end
        --fix zombie state again
        if self.dead == true and self.death_animation_timer <= 0 then
@@ -147,9 +155,6 @@ mob_register.on_step = function(self, dtime)
        if self.custom_function_end then
                self.custom_function_end(self,dtime)
        end
-       
-       
-       self.move_head(self)
 end
 
 minetest.register_entity("mob:"..def.mobname, mob_register)