]> git.lizzy.rs Git - Crafter.git/blob - mods/mob/api/timers.lua
d9165e00fb1c42954e1568ffdfcf1a092be13fc9
[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 == false 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
27         mob_register.manage_explode_timer = function(self,dtime)
28                 self.tnt_timer = self.tnt_timer - dtime
29                 if self.tnt_timer <= 0 and not self.dead then
30                         
31                         self.object:set_texture_mod("^[colorize:red:130")
32                         if self.child then
33                                 self.child:set_texture_mod("^[colorize:red:130") 
34                         end
35                         
36                         local pos = self.object:get_pos()
37                         --direction.y = direction.y + 1
38                         
39                         tnt(pos,7)
40                         self.death_animation_timer = 1
41                         self.dead = true
42                         self.tnt_timer = 100
43                 end
44         end
45
46         mob_register.manage_projectile_timer = function(self,dtime)
47                 self.projectile_timer = self.projectile_timer - dtime
48         end
49
50         --this stops the pig from flying into the air
51         mob_register.manage_jump_timer = function(self,dtime)
52                 if self.jump_timer > 0 then
53                         self.jump_timer = self.jump_timer - dtime
54                 end
55         end
56         return(mob_register)
57 end