1 local minetest,math = minetest,math
2 mobs.create_timer_functions = function(def,mob_register)
3 --this controls how fast the mob punches
4 mob_register.manage_punch_timer = function(self,dtime)
5 if self.punch_timer > 0 then
6 self.punch_timer = self.punch_timer - dtime
8 --this controls how fast you can punch the mob (punched timer reset)
9 if self.punched_timer > 0 then
10 --print(self.punched_timer)
11 self.punched_timer = self.punched_timer - dtime
15 --this controls the hostile state
16 if def.hostile == true or def.attacked_hostile == true then
17 if def.hostile_cooldown == true then
18 mob_register.manage_hostile_timer = function(self,dtime)
19 if self.hostile_timer > 0 then
20 self.hostile_timer = self.hostile_timer - dtime
22 if self.hostile_timer <= 0 then
28 mob_register.manage_scared_timer = function(self,dtime)
29 if self.scared_timer > 0 then
30 self.scared_timer = self.scared_timer - dtime
32 if self.scared_timer <= 0 then
38 mob_register.manage_hurt_color_timer = function(self,dtime)
39 if self.hurt_color_timer > 0 then
40 self.hurt_color_timer = self.hurt_color_timer - dtime
41 if self.hurt_color_timer <= 0 then
42 self.hurt_color_timer = 0
43 self.object:set_texture_mod("")
48 mob_register.manage_explode_timer = function(self,dtime)
49 self.tnt_timer = self.tnt_timer - dtime
50 self.tnt_tick_timer = self.tnt_tick_timer - dtime
51 if self.tnt_tick_timer <= 0 and not self.dead then
52 self.tnt_tick_timer = self.explosion_blink_timer
53 self.tnt_mod_state = math.abs(self.tnt_mod_state-1)
54 if self.tnt_mod_state == 0 then
55 self.object:set_texture_mod("")
57 self.object:set_texture_mod("^[colorize:"..self.explosion_blink_color..":130")
59 --print(self.object:get_texture_mod())
60 --self.object:set_texture_mod("^[colorize:red:130")
62 if self.tnt_timer <= 0 and not self.dead then
64 self.object:set_texture_mod("^[colorize:red:130")
66 local pos = self.object:get_pos()
68 tnt(pos,self.explosion_power,self.explosion_type)
72 if def.custom_timer then
73 mob_register.do_custom_timer = function(self,dtime)
74 self.c_timer = self.c_timer + dtime
75 if self.c_timer >= self.custom_timer then
77 self.custom_timer_function(self,dtime)
82 mob_register.manage_projectile_timer = function(self,dtime)
83 self.projectile_timer = self.projectile_timer - dtime
86 if def.friendly_in_daylight then
87 mob_register.handle_friendly_in_daylight_timer = function(self,dtime)
88 self.friendly_in_daylight_timer = self.friendly_in_daylight_timer + dtime
89 if self.friendly_in_daylight_timer >= 2 then
90 self.friendly_in_daylight_timer = 0
91 local pos = self.object:get_pos()
92 local light = minetest.get_node_light(pos)
93 if pos and light and light >= 13 then --1 greater than torch light
94 if self.following == false then
104 --this stops the pig from flying into the air
105 mob_register.manage_jump_timer = function(self,dtime)
106 if self.jump_timer > 0 then
107 self.jump_timer = self.jump_timer - dtime