[WIP] Treballant en el jefe. Super!
This commit is contained in:
@@ -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.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
|
||||
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: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.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
|
||||
|
||||
Reference in New Issue
Block a user