X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=mods%2Fmob%2Fapi%2Ftimers.lua;h=72d01efb90ac2fdfc58e80603db1973bb3c3681d;hb=f0ed02f964af90ef2472e98dc99a2b7ac57c9472;hp=a835f987907508d59c042acda001358f0cfa324c;hpb=9bd7774e76da882f91d2ea2491e6309768a893d2;p=Crafter.git diff --git a/mods/mob/api/timers.lua b/mods/mob/api/timers.lua index a835f98..72d01ef 100644 --- a/mods/mob/api/timers.lua +++ b/mods/mob/api/timers.lua @@ -23,6 +23,15 @@ mobs.create_timer_functions = function(def,mob_register) end end end + else + mob_register.manage_scared_timer = function(self,dtime) + if self.scared_timer > 0 then + self.scared_timer = self.scared_timer - dtime + end + if self.scared_timer <= 0 then + self.scared = false + end + end end mob_register.manage_hurt_color_timer = function(self,dtime) @@ -54,12 +63,18 @@ mobs.create_timer_functions = function(def,mob_register) self.object:set_texture_mod("^[colorize:red:130") local pos = self.object:get_pos() - --direction.y = direction.y + 1 - + self.object:remove() tnt(pos,self.explosion_power) - self.death_animation_timer = 1 - self.dead = true - self.tnt_timer = 100 + end + end + + if def.custom_timer then + mob_register.do_custom_timer = function(self,dtime) + self.c_timer = self.c_timer + dtime + if self.c_timer >= self.custom_timer then + self.c_timer = 0 + self.custom_timer_function(self,dtime) + end end end @@ -67,6 +82,24 @@ mobs.create_timer_functions = function(def,mob_register) self.projectile_timer = self.projectile_timer - dtime end + if def.friendly_in_daylight then + mob_register.handle_friendly_in_daylight_timer = function(self,dtime) + self.friendly_in_daylight_timer = self.friendly_in_daylight_timer + dtime + if self.friendly_in_daylight_timer >= 2 then + self.friendly_in_daylight_timer = 0 + local pos = self.object:get_pos() + local light = minetest.get_node_light(pos) + if pos and light and light >= 13 then --1 greater than torch light + if self.following == false then + self.hostile = false + end + else + self.hostile = true + end + end + end + end + --this stops the pig from flying into the air mob_register.manage_jump_timer = function(self,dtime) if self.jump_timer > 0 then