From d5dc2aba5f23c1799b3d7ee6fefb915e7e98ab4a Mon Sep 17 00:00:00 2001 From: JailGamer Date: Sat, 11 Apr 2026 11:56:57 +0200 Subject: [PATCH] [WIP] Treballant en el jefe. 'chase' i 'away' --- data/imp.lua | 60 +++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/data/imp.lua b/data/imp.lua index 6caa129..64d6c2f 100644 --- a/data/imp.lua +++ b/data/imp.lua @@ -54,8 +54,8 @@ function imp.new(_hab, _x, _y) action="", -- Acció a realitzar en el "pad" movement="", -- Cap on es mou independentment de si està "flipat" fight_modes=_fight_modes, -- mode de lluita (Llevar?) - mode="stop", -- mode de lluita actiu - mode_cooldown=500, -- cicles fins al canvi de mode + fight_mode="stop", -- mode de lluita actiu + fight_mode_cooldown=1500, -- cicles fins al canvi de mode super_cooldown=2000, -- cicles fins a Super actiu shot_cooldown=500, -- cicles fina a poder disparar hot_points={}, -- llista de punts del mapa on anar @@ -87,7 +87,7 @@ function imp.new(_hab, _x, _y) do_flip=imp.do_flip, -- Orienta a l'imp cap a l'actor -- mode_controller=imp.mode_controller, reduce_cooldown=imp.reduce_cooldown, -- Decrementa els cooldown - reset_mode_cooldown=imp.reset_mode_cooldown, -- Asignar un valor a mode_cooldown (per a mantindre una coherència cada volta que es crida) + reset_fight_mode_cooldown=imp.reset_fight_mode_cooldown, -- Asignar un valor a fight_mode_cooldown (per a mantindre una coherència cada volta que es crida) controller_input=imp.controller_input, -- Traduir l'accio en moviment actualitzar_comportament=imp.actualitzar_comportament, -- "Pensar" que fer analyze_env=imp.analyze_env, -- Analitza l'entorn a vore que està pasant @@ -241,7 +241,7 @@ if DEBUG_FN_NAME then print("fight") end } self.paths[11] = {} - self.mode="chase" + self.fight_mode="chase" self:pattern_movement() end @@ -484,16 +484,16 @@ end function imp:state_super() if DEBUG_FN_NAME then print("state_super") end - self.mode = self.fight_modes["super"] - self.mode_cooldown=1 + self.fight_mode = self.fight_modes["super"] + self:reset_fight_mode_cooldown(1) self.super_cooldown=2000 self.update=imp.state_normal end function imp:shot(actor) if DEBUG_FN_NAME then print("shot") end - self.mode = self.fight_modes["shot"] - self.mode_cooldown=1 + self.fight_mode = self.fight_modes["shot"] + self:reset_fight_mode_cooldown(1) print("FIREBALL!!") self.shot_cooldown = 500 end @@ -505,17 +505,17 @@ end function imp:reduce_cooldown() if DEBUG_FN_NAME then print("reduce_cooldown") end - if self.mode=="stop" then return end + if self.fight_mode=="stop" then return end - self.mode_cooldown = self.mode_cooldown -1 + self.fight_mode_cooldown = self.fight_mode_cooldown -1 self.super_cooldown = self.super_cooldown -1 self.shoot_cooldown = self.shoot_cooldown -1 end -function imp:reset_mode_cooldown( value ) -if DEBUG_FN_NAME then print("reset_mode_cooldown") end - value = value or 500 - self.mode_cooldown = value +function imp:reset_fight_mode_cooldown( value ) +if DEBUG_FN_NAME then print("reset_fight_mode_cooldown") end + value = value or 1500 + self.fight_mode_cooldown = value return value end @@ -583,7 +583,7 @@ function imp:path_next_action( from ) if DEBUG_FN_NAME then print("path_next_action "..from) end if #self.paths[from]>0 then self:pattern_movement() - self:reset_mode_cooldown() + self:reset_fight_mode_cooldown() -- Activar següent target self:next_target(from) action = self:path_action() @@ -627,7 +627,7 @@ if DEBUG_FN_NAME then print("free_next_action") end --Comprovar si está en target if collision(self, self.target) then - self:reset_mode_cooldown() + self:reset_fight_mode_cooldown() -- Buscar quin es el target local idx = 1 @@ -876,6 +876,7 @@ 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() @@ -892,6 +893,14 @@ function imp:next_target(from) else action=self:pattern_next_target( from ) end + + -- seleccionar mode d'acció + --local last_mode=self.fight_mode + -- self.fight_mode=self.fight_modes["chase"] + if self.fight_mode_cooldown<=0 then + self.fight_mode=self.fight_modes[math.random(2)] -- chase o away + self:reset_fight_mode_cooldown() + end end ------------------------------- @@ -902,32 +911,31 @@ end -- traduir a acció de pad ------------------------------- function imp:move( ) -if DEBUG_FN_NAME then print("move "..self.mode) end +if DEBUG_FN_NAME then print("move "..self.fight_mode) end local action = "stay" - if self.mode=="stop" then return action end + if self.fight_mode=="stop" then return action end -- S'ha acabat el temps per a arribar a un target - if self.mode_cooldown <= 0 then + if self.fight_mode_cooldown <= 0 then -- Canviar a moviment lliure self:free_movement() - -- seleccionar mode d'acció - local last_mode=self.mode - -- Reinicialitzar el patró de moviment i el cooldown - self:reset_mode_cooldown() + self:reset_fight_mode_cooldown() self:path_reset() - self.mode=self.fight_modes["chase"] - -- Seleccionar el següent target aleatoriament self:next_target() print("Next random target => "..self.target.id) end - self:do_flip(abad) + if self.fight_mode==self.fight_modes["chase"] then + self:do_flip(abad) + else + self:do_flip(self.target) + end if self.analisis.going_to_fall then self.action_event="prefall" end if self.analisis.target_reached then self.action_event="target" end