diff --git a/data/imp3-functions.lua b/data/imp3-functions.lua index 9b556f6..2802010 100644 --- a/data/imp3-functions.lua +++ b/data/imp3-functions.lua @@ -19,8 +19,11 @@ function imp:reduce_timers() if DEBUG_FN_NAME then print_dbg("reduce_timers") end for key, val in pairs(self.timers) do - self.timers[key] = val - 1 - if (val-1)<0 then self.timers[key] = 0 end + local is_locked = string.sub(key, -7) == "_locked" + if not is_locked then + self.timers[key] = val - 1 + if (val-1)<0 then self.timers[key] = 0 end + end end end @@ -31,10 +34,11 @@ function imp:reset_timer( timer ) if self.mood == self.moods.stop then return end if DEBUG_FN_NAME then print_dbg("reduce_timers") end local time = 0 - if timer=="mood" then time = 150 - elseif timer=="target" then time = 250 - elseif timer=="shot" then time = 100 - elseif timer=="super" then time = 200 + if timer=="mood" then time = 150 + elseif timer=="target" then time = 350 + elseif timer=="shot" then time = 100 + elseif timer=="super" then time = 200 + elseif timer=="super_wait" then time = 200 elseif timer=="flip_wait" then time = 50 end @@ -142,7 +146,7 @@ function imp:update_action_events() end if self.analisis.can_go_altar then - self:add_action_event("super_init") + self:add_action_event("super_ready") end 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 self.add_action_event("super ready") -- next_action = self:next_action() - self:super() + -- self:super() end 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 -- if v==self.action then print("CONTROLLER => "..self.action.." / "..k) end -- end - if (self.action == self.actions.right or self.action == self.actions.left) 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 self:shot() elseif (self.action == self.actions.super) then - + self:super() end -- 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:pattern_movement() self:_moure(imp.state_normal,"") + self.stucked = {x=0, y=0, t=0 } end ------------------------------- @@ -377,18 +381,18 @@ function imp:load_pattern_paths() --OK } self.pattern.path[4] = { {target=1, actions={{action="jump" , event="target"}}}, - {target=5, actions={{action="right", event="target"}}}, - {target=6, actions={{action="right", event="target"}}}, - {target=8, actions={{action="jump" , event="target"}}}, + --{target=5, actions={{action="right", event="target"}}}, + --{target=6, actions={{action="right", event="target"}}}, + --{target=8, actions={{action="jump" , event="target"}}}, } self.pattern.path[5] = { {target=4, actions={{action="left" , event="target"}}}, {target=6, actions={{action="right", event="target"}}} } self.pattern.path[6] = { - {target=2, actions={{action="jump", event="target"}}}, - {target=5, actions={{action="left", event="target"}}}, - {target=7, actions={{action="jump", event="target"}}}, + --{target=2, actions={{action="jump", event="target"}}}, + --{target=5, actions={{action="left", event="target"}}}, + --{target=7, actions={{action="jump", event="target"}}}, {target=4, actions={{action="left", event="target"}}} } self.pattern.path[7] = { @@ -450,7 +454,7 @@ end function imp:pattern_movement() --OK if DEBUG_FN_NAME then print_dbg("pattern_movement") end - self.movement_type = "pattern" + self.move_type = self.move_types.pattern -- print("Pattern") end @@ -517,9 +521,19 @@ function imp:next_action() next_action = "shot" end + if self.timers.super<=0 and self:check_action_event("super_ready") then + if self.x=self.timers.stucked_locked then self:pattern_recovery() self:reset_timer("target") end @@ -541,10 +555,10 @@ function imp:next_action() elseif self.move_type==self.move_types.super then -- SUPER -- + next_action = "no_action" end end self.action_event = {} - -- next_action es text, traduir return self.actions[next_action] end @@ -805,5 +819,57 @@ end function imp:do_flip( actor ) actor = actor or self.pattern:target_node() -- enllaçat a actor - if actor.x100 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 diff --git a/data/imp3.lua b/data/imp3.lua index c360386..f3793b9 100644 --- a/data/imp3.lua +++ b/data/imp3.lua @@ -34,7 +34,7 @@ function imp.new(_hab,_x,_y) step=0, moods={stop=0, chase=1, avoid=2, neutral=4}, 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_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}, @@ -50,6 +50,11 @@ function imp.new(_hab,_x,_y) action_event = {}, 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, draw=imp.draw, @@ -75,6 +80,8 @@ function imp.new(_hab,_x,_y) add_action_event = imp.add_action_event, shot = imp.shot, pattern_recovery = imp.pattern_recovery, + super = imp.super, + super_movement = imp.super_movement, -- debug _moure = imp._moure, _pause = false, @@ -86,11 +93,11 @@ function imp:draw() --OK local scr_x, scr_y = viewp:screen_coords( self.x, self.y ) -- Modo super - if self.moure==self.state_super then + if self.moure==imp.state_super then -- rotar paleta for col=13,15 do local newc = self.super_pal[col] - if self.super_wait%6 == 0 then + if self.timers.super_wait%6 == 0 then newc = newc+1 if newc>15 then newc=13 end end @@ -184,7 +191,14 @@ function imp:update_normal() -- moviment self:controller_input() 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 self:next_frame() end