diff --git a/data/imp.lua b/data/imp.lua index 64d6c2f..09d5eec 100644 --- a/data/imp.lua +++ b/data/imp.lua @@ -68,6 +68,7 @@ function imp.new(_hab, _x, _y) analisis={}, -- Resultat de la informació extreta de l'entorn old_action="-", invencible=false, + flip_wait=100, -- Temps per a forçar un flip -- direccio=imp.direccio, draw=imp.draw, hit=imp.hit, @@ -492,8 +493,10 @@ end function imp:shot(actor) if DEBUG_FN_NAME then print("shot") end - self.fight_mode = self.fight_modes["shot"] - self:reset_fight_mode_cooldown(1) + -- self.fight_mode = self.fight_modes["shot"] + -- self:reset_fight_mode_cooldown(1) + self:do_flip(abad) + self.flip_wait=100 print("FIREBALL!!") self.shot_cooldown = 500 end @@ -509,7 +512,8 @@ if DEBUG_FN_NAME then print("reduce_cooldown") end self.fight_mode_cooldown = self.fight_mode_cooldown -1 self.super_cooldown = self.super_cooldown -1 - self.shoot_cooldown = self.shoot_cooldown -1 + self.shot_cooldown = self.shot_cooldown -1 + self.flip_wait = self.flip_wait -1 end function imp:reset_fight_mode_cooldown( value ) @@ -538,7 +542,7 @@ function imp:pattern_movement() if DEBUG_FN_NAME then print("pattern_movement") end self.movement_type = "pattern" - print("Pattern") + -- print("Pattern") end function imp:pattern_next_action() @@ -876,13 +880,20 @@ end function imp:next_action() local action = "stay" - - if self.movement_type=="free" then - msg_print(10,20,"FREE",true) - action = self:free_next_action() - else - msg_print(10,20,"PATTERN "..self.action_event,true) - action=self:pattern_next_action() + if self.shot_cooldown<=0 then + if h_collision(self, abad) then + action = "shot" + end + end + + if action=="stay" then + if self.movement_type=="free" then + msg_print(10,20,"FREE",true) + action = self:free_next_action() + else + msg_print(10,20,"PATTERN "..self.action_event,true) + action=self:pattern_next_action() + end end return action end @@ -930,11 +941,13 @@ if DEBUG_FN_NAME then print("move "..self.fight_mode) end print("Next random target => "..self.target.id) end - - if self.fight_mode==self.fight_modes["chase"] then - self:do_flip(abad) - else - self:do_flip(self.target) + + if self.flip_wait<=0 then + if self.fight_mode==self.fight_modes["chase"] then + self:do_flip(abad) + else + self:do_flip(self.target) + end end if self.analisis.going_to_fall then self.action_event="prefall" end