]> git.lizzy.rs Git - Crafter.git/blob - mods/mob/api/timers.lua
84ae2da3273dfd2ecdc2a6cca10b657c857a6978
[Crafter.git] / mods / mob / api / timers.lua
1 mobs.create_timer_functions = function(def,mob_register)
2         --this controls how fast the mob punches
3         mob_register.manage_punch_timer = function(self,dtime)
4                 if self.punch_timer > 0 then
5                         self.punch_timer = self.punch_timer - dtime
6                 end
7                 --this controls how fast you can punch the mob (punched timer reset)
8                 if self.punched_timer > 0 then
9                         --print(self.punched_timer)
10                         self.punched_timer = self.punched_timer - dtime
11                 end
12         end
13
14         --this controls the hostile state
15         if def.hostile == true or def.attacked_hostile == true then
16                 mob_register.manage_hostile_timer = function(self,dtime)
17                         if self.hostile_timer > 0 then
18                                 self.hostile_timer = self.hostile_timer - dtime
19                         end
20                         if self.hostile_timer <= 0 then
21                                 self.hostile = false
22                         end
23                 end
24         end
25
26         mob_register.manage_hurt_color_timer = function(self,dtime)
27                 if self.hurt_color_timer > 0 then
28                         self.hurt_color_timer = self.hurt_color_timer - dtime
29                         if self.hurt_color_timer  <= 0 then
30                                 self.hurt_color_timer = 0
31                                 self.object:set_texture_mod("")
32                         end
33                 end
34         end
35
36         mob_register.manage_explode_timer = function(self,dtime)
37                 self.tnt_timer = self.tnt_timer - dtime
38                 if self.tnt_timer <= 0 and not self.dead then
39                         
40                         self.object:set_texture_mod("^[colorize:red:130")
41                         
42                         local pos = self.object:get_pos()
43                         --direction.y = direction.y + 1
44                         
45                         tnt(pos,7)
46                         self.death_animation_timer = 1
47                         self.dead = true
48                         self.tnt_timer = 100
49                 end
50         end
51
52         mob_register.manage_projectile_timer = function(self,dtime)
53                 self.projectile_timer = self.projectile_timer - dtime
54         end
55
56         --this stops the pig from flying into the air
57         mob_register.manage_jump_timer = function(self,dtime)
58                 if self.jump_timer > 0 then
59                         self.jump_timer = self.jump_timer - dtime
60                 end
61         end
62         return(mob_register)
63 end