[WIP] Treballant en el jefe. Super!

This commit is contained in:
2026-04-17 23:49:16 +02:00
parent 1b3aa47d9e
commit 5843953b7b
2 changed files with 104 additions and 24 deletions

View File

@@ -19,10 +19,13 @@ function imp:reduce_timers()
if DEBUG_FN_NAME then print_dbg("reduce_timers") end if DEBUG_FN_NAME then print_dbg("reduce_timers") end
for key, val in pairs(self.timers) do for key, val in pairs(self.timers) do
local is_locked = string.sub(key, -7) == "_locked"
if not is_locked then
self.timers[key] = val - 1 self.timers[key] = val - 1
if (val-1)<0 then self.timers[key] = 0 end if (val-1)<0 then self.timers[key] = 0 end
end end
end end
end
------------------------------- -------------------------------
-- --
@@ -32,9 +35,10 @@ function imp:reset_timer( timer )
if DEBUG_FN_NAME then print_dbg("reduce_timers") end if DEBUG_FN_NAME then print_dbg("reduce_timers") end
local time = 0 local time = 0
if timer=="mood" then time = 150 if timer=="mood" then time = 150
elseif timer=="target" then time = 250 elseif timer=="target" then time = 350
elseif timer=="shot" then time = 100 elseif timer=="shot" then time = 100
elseif timer=="super" then time = 200 elseif timer=="super" then time = 200
elseif timer=="super_wait" then time = 200
elseif timer=="flip_wait" then time = 50 elseif timer=="flip_wait" then time = 50
end end
@@ -142,7 +146,7 @@ function imp:update_action_events()
end end
if self.analisis.can_go_altar then if self.analisis.can_go_altar then
self:add_action_event("super_init") self:add_action_event("super_ready")
end end
if self.x_old>self.x then if self.x_old>self.x then
@@ -180,7 +184,7 @@ if DEBUG_FN_NAME then print_dbg("choose_action "..self.mood.." / "..self.moods.s
if self.analisis.target_reached and next_action=="super" then if self.analisis.target_reached and next_action=="super" then
self.add_action_event("super ready") self.add_action_event("super ready")
-- next_action = self:next_action() -- next_action = self:next_action()
self:super() -- self:super()
end end
if self.old_action~=next_action then if self.old_action~=next_action then
@@ -201,7 +205,6 @@ if DEBUG_FN_NAME then print_dbg("controller_input") end
-- for k,v in pairs(self.actions) do -- for k,v in pairs(self.actions) do
-- if v==self.action then print("CONTROLLER => "..self.action.." / "..k) end -- if v==self.action then print("CONTROLLER => "..self.action.." / "..k) end
-- end -- end
if (self.action == self.actions.right or if (self.action == self.actions.right or
self.action == self.actions.left) then self.action == self.actions.left) then
if self.moure == imp.state_normal or self.moure == imp.state_walking then if self.moure == imp.state_normal or self.moure == imp.state_walking then
@@ -218,7 +221,7 @@ if DEBUG_FN_NAME then print_dbg("controller_input") end
elseif (self.action == self.actions.shot) then elseif (self.action == self.actions.shot) then
self:shot() self:shot()
elseif (self.action == self.actions.super) then elseif (self.action == self.actions.super) then
self:super()
end end
-- if --(self.moure==imp.state_normal or self.moure==imp.state_walking) and -- if --(self.moure==imp.state_normal or self.moure==imp.state_walking) and
@@ -258,6 +261,7 @@ if DEBUG_FN_NAME then print_dbg("fight") end
self.mood=self.moods.chase self.mood=self.moods.chase
self:pattern_movement() self:pattern_movement()
self:_moure(imp.state_normal,"") self:_moure(imp.state_normal,"")
self.stucked = {x=0, y=0, t=0 }
end end
------------------------------- -------------------------------
@@ -377,18 +381,18 @@ function imp:load_pattern_paths() --OK
} }
self.pattern.path[4] = { self.pattern.path[4] = {
{target=1, actions={{action="jump" , event="target"}}}, {target=1, actions={{action="jump" , event="target"}}},
{target=5, actions={{action="right", event="target"}}}, --{target=5, actions={{action="right", event="target"}}},
{target=6, actions={{action="right", event="target"}}}, --{target=6, actions={{action="right", event="target"}}},
{target=8, actions={{action="jump" , event="target"}}}, --{target=8, actions={{action="jump" , event="target"}}},
} }
self.pattern.path[5] = { self.pattern.path[5] = {
{target=4, actions={{action="left" , event="target"}}}, {target=4, actions={{action="left" , event="target"}}},
{target=6, actions={{action="right", event="target"}}} {target=6, actions={{action="right", event="target"}}}
} }
self.pattern.path[6] = { self.pattern.path[6] = {
{target=2, actions={{action="jump", event="target"}}}, --{target=2, actions={{action="jump", event="target"}}},
{target=5, actions={{action="left", event="target"}}}, --{target=5, actions={{action="left", event="target"}}},
{target=7, actions={{action="jump", event="target"}}}, --{target=7, actions={{action="jump", event="target"}}},
{target=4, actions={{action="left", event="target"}}} {target=4, actions={{action="left", event="target"}}}
} }
self.pattern.path[7] = { self.pattern.path[7] = {
@@ -450,7 +454,7 @@ end
function imp:pattern_movement() --OK function imp:pattern_movement() --OK
if DEBUG_FN_NAME then print_dbg("pattern_movement") end if DEBUG_FN_NAME then print_dbg("pattern_movement") end
self.movement_type = "pattern" self.move_type = self.move_types.pattern
-- print("Pattern") -- print("Pattern")
end end
@@ -517,9 +521,19 @@ function imp:next_action()
next_action = "shot" next_action = "shot"
end end
if self.timers.super<=0 and self:check_action_event("super_ready") then
if self.x<self.pattern.node[3].x then
local node = 3
local path = {target=3, actions= {{action="jumpfwd", event="land"},
{action="right" , event="target"},
{action="super" , event="super"}}}
self.pattern:add_manual_target(node, path)
end
end
-- Resta d'accions -- Resta d'accions
if next_action==self.actions.no_action then if next_action==self.actions.no_action then
if self.timers.target<=0 then if self.timers.target<=0 or self.stucked.t>=self.timers.stucked_locked then
self:pattern_recovery() self:pattern_recovery()
self:reset_timer("target") self:reset_timer("target")
end end
@@ -541,10 +555,10 @@ function imp:next_action()
elseif self.move_type==self.move_types.super then elseif self.move_type==self.move_types.super then
-- SUPER -- SUPER
-- --
next_action = "no_action"
end end
end end
self.action_event = {} self.action_event = {}
-- next_action es text, traduir -- next_action es text, traduir
return self.actions[next_action] return self.actions[next_action]
end end
@@ -805,5 +819,57 @@ end
function imp:do_flip( actor ) function imp:do_flip( actor )
actor = actor or self.pattern:target_node() actor = actor or self.pattern:target_node()
-- enllaçat a actor -- enllaçat a actor
if actor.x<self.x then self.flip=true else self.flip=false end if actor.x<self.x then
self.flip=true
else
self.flip=false
end
self:reset_timer("flip_wait")
end
function imp:super()
if DEBUG_FN_NAME then print("super()") end
self:super_movement()
-- self.fight_mode = self.fight_modes["super"]
self.invencible = true
self:_moure(imp.state_super,"")
self:reset_timer("super_wait")
end
function imp:state_super()
if DEBUG_FN_NAME then print("state_super") end
-- self.super_wait = self.super_wait -1
local wait = self.timers.super_wait
if self.zoom<1.75 and wait>100 then
if wait%4==0 then self.zoom=self.zoom+0.1 end
elseif not self.super_fired and self.zoom>=1.75 and wait>100 then
local x_ini = self.x+self.bb.x+self.bb.w+4
local hab, tx, ty, off_x, off_y = coords.world_to_tile(x_ini,self.y+(self.h/2))
fireball.init(hab, tx, ty, false, off_x, off_y, 2)
self.super_fired = true
elseif self.zoom>1 and wait<=100 then
if wait%4==0 then self.zoom=self.zoom-0.1 end
end
if wait == 0 then
self:_moure(imp.super_end,"")
end
end
function imp:super_end()
self.zoom = 1
self.invencible = false
self.super_fired = false
self:_moure(imp.state_normal,"")
self:reset_timer("mood")
self:reset_timer("super")
self:reset_timer("super_wait")
self:pattern_movement()
self:pattern_recovery()
end
function imp:super_movement()
if DEBUG_FN_NAME then print("super_movement") end
self.move_type = self.move_types.super
end end

View File

@@ -34,7 +34,7 @@ function imp.new(_hab,_x,_y)
step=0, step=0,
moods={stop=0, chase=1, avoid=2, neutral=4}, moods={stop=0, chase=1, avoid=2, neutral=4},
mood=0, --anterior fight_mode mood=0, --anterior fight_mode
timers={mood=150,target=100, shot=100, super=200, flip_wait=50}, --anterior *_cooldown timers={mood=150,target=350, shot=100, super=200, super_wait=200, flip_wait=50, stucked_locked=50}, --anterior *_cooldown
move_types={free=0, pattern=1, super=2}, move_types={free=0, pattern=1, super=2},
move_type=1, -- anterior movement_type move_type=1, -- anterior movement_type
actions={no_action=0, up=1, down=2, left=4, right=8, jump=16, shot=32, super=64, jumpfwd=128}, actions={no_action=0, up=1, down=2, left=4, right=8, jump=16, shot=32, super=64, jumpfwd=128},
@@ -50,6 +50,11 @@ function imp.new(_hab,_x,_y)
action_event = {}, action_event = {},
action = 0, action = 0,
old_action = 0, old_action = 0,
stucked = {x=0, y=0, t=0 },
invencible = false,
zoom = 1,
super_pal={[13]=13,[14]=14,[15]=15},
super_fired = false,
-- --
moure = noop, moure = noop,
draw=imp.draw, draw=imp.draw,
@@ -75,6 +80,8 @@ function imp.new(_hab,_x,_y)
add_action_event = imp.add_action_event, add_action_event = imp.add_action_event,
shot = imp.shot, shot = imp.shot,
pattern_recovery = imp.pattern_recovery, pattern_recovery = imp.pattern_recovery,
super = imp.super,
super_movement = imp.super_movement,
-- debug -- debug
_moure = imp._moure, _moure = imp._moure,
_pause = false, _pause = false,
@@ -86,11 +93,11 @@ function imp:draw() --OK
local scr_x, scr_y = viewp:screen_coords( self.x, self.y ) local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
-- Modo super -- Modo super
if self.moure==self.state_super then if self.moure==imp.state_super then
-- rotar paleta -- rotar paleta
for col=13,15 do for col=13,15 do
local newc = self.super_pal[col] local newc = self.super_pal[col]
if self.super_wait%6 == 0 then if self.timers.super_wait%6 == 0 then
newc = newc+1 newc = newc+1
if newc>15 then newc=13 end if newc>15 then newc=13 end
end end
@@ -184,7 +191,14 @@ function imp:update_normal()
-- moviment -- moviment
self:controller_input() self:controller_input()
self:moure() self:moure()
-- Que no conte si està en modo Super
if self.stucked.x == self.x and self.stucked.y == self.y then
self.stucked.t = self.stucked.t + 1
else
self.stucked.x = self.x
self.stucked.y = self.y
self.stucked.t = 0
end
-- Logica per a selecció de frame -- Logica per a selecció de frame
self:next_frame() self:next_frame()
end end