7 mobs.create_timer_functions = function(def,mob_register)
8 --this controls how fast the mob punches
9 mob_register.manage_punch_timer = function(self,dtime)
10 if self.punch_timer > 0 then
11 self.punch_timer = self.punch_timer - dtime
13 --this controls how fast you can punch the mob (punched timer reset)
14 if self.punched_timer > 0 then
15 --print(self.punched_timer)
16 self.punched_timer = self.punched_timer - dtime
20 --this controls the hostile state
21 if def.hostile == true or def.attacked_hostile == true then
22 if def.hostile_cooldown == true then
23 mob_register.manage_hostile_timer = function(self,dtime)
24 if self.hostile_timer > 0 then
25 self.hostile_timer = self.hostile_timer - dtime
27 if self.hostile_timer <= 0 then
33 mob_register.manage_scared_timer = function(self,dtime)
34 if self.scared_timer > 0 then
35 self.scared_timer = self.scared_timer - dtime
37 if self.scared_timer <= 0 then
43 mob_register.manage_hurt_color_timer = function(self,dtime)
44 if self.hurt_color_timer > 0 then
45 self.hurt_color_timer = self.hurt_color_timer - dtime
46 if self.hurt_color_timer <= 0 then
47 self.hurt_color_timer = 0
48 self.object:set_texture_mod("")
53 mob_register.manage_explode_timer = function(self,dtime)
54 self.tnt_timer = self.tnt_timer - dtime
55 self.tnt_tick_timer = self.tnt_tick_timer - dtime
56 if self.tnt_tick_timer <= 0 and not self.dead then
57 self.tnt_tick_timer = self.explosion_blink_timer
58 self.tnt_mod_state = math.abs(self.tnt_mod_state-1)
59 if self.tnt_mod_state == 0 then
60 self.object:set_texture_mod("")
62 self.object:set_texture_mod("^[colorize:"..self.explosion_blink_color..":130")
64 --print(self.object:get_texture_mod())
65 --self.object:set_texture_mod("^[colorize:red:130")
67 if self.tnt_timer <= 0 and not self.dead then
69 self.object:set_texture_mod("^[colorize:red:130")
71 pos = self.object:get_pos()
73 tnt(pos,self.explosion_power,self.explosion_type)
77 if def.custom_timer then
78 mob_register.do_custom_timer = function(self,dtime)
79 self.c_timer = self.c_timer + dtime
80 if self.c_timer >= self.custom_timer then
82 self.custom_timer_function(self,dtime)
87 mob_register.manage_projectile_timer = function(self,dtime)
88 self.projectile_timer = self.projectile_timer - dtime
91 if def.friendly_in_daylight then
92 mob_register.handle_friendly_in_daylight_timer = function(self,dtime)
93 self.friendly_in_daylight_timer = self.friendly_in_daylight_timer + dtime
94 if self.friendly_in_daylight_timer >= 2 then
95 self.friendly_in_daylight_timer = 0
96 pos = self.object:get_pos()
97 light = minetest.get_node_light(pos)
98 if pos and light and light >= 13 then --1 greater than torch light
99 if self.following == false then
109 --this stops the pig from flying into the air
110 mob_register.manage_jump_timer = function(self,dtime)
111 if self.jump_timer > 0 then
112 self.jump_timer = self.jump_timer - dtime