[WIP] Treballant en el jefe. Super power done!
This commit is contained in:
131
data/imp.lua
131
data/imp.lua
@@ -57,7 +57,7 @@ function imp.new(_hab, _x, _y)
|
||||
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
|
||||
super_cooldown=100, -- cicles fins a Super actiu
|
||||
super_cooldown=200, -- cicles fins a Super actiu
|
||||
shot_cooldown=500, -- cicles fina a poder disparar
|
||||
hot_points={}, -- llista de punts del mapa on anar
|
||||
target={}, -- següent punt on anar
|
||||
@@ -69,7 +69,11 @@ 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
|
||||
flip_wait=100, -- Temps per a forçar un flip
|
||||
super_wait=200,
|
||||
zoom=1,
|
||||
super_pal={[13]=13,[14]=14,[15]=15},
|
||||
super_fired = false,
|
||||
-- direccio=imp.direccio,
|
||||
draw=imp.draw,
|
||||
hit=imp.hit,
|
||||
@@ -127,7 +131,6 @@ if DEBUG_FN_NAME then print("fight") end
|
||||
self.hot_points[1] = point.new(44, 5, 1, 0, 8,"P1")
|
||||
self.hot_points[2] = point.new(45, 8, 1, 0, 8,"P2")
|
||||
self.hot_points[3] = point.new(44,12, 5, 8, 0,"P3")
|
||||
self.hot_points["altar"] = self.hot_points[3]
|
||||
self.hot_points[4] = point.new(54, 5, 4, -8, 0,"P4")
|
||||
self.hot_points[5] = point.new(54,12, 4, 8, 0,"P5")
|
||||
self.hot_points[6] = point.new(55, 8, 4, 8, 0,"P6")
|
||||
@@ -135,7 +138,9 @@ if DEBUG_FN_NAME then print("fight") end
|
||||
self.hot_points[8] = point.new(54, 5, 0, 0, 0,"P8")
|
||||
self.hot_points[9] = point.new(54, 9, 1, 0, 0,"P9")
|
||||
self.hot_points[10] = point.new(55,4, 1, 0, 0,"P10")
|
||||
self.hot_points[11] = abad
|
||||
-- self.hot_points[11] = abad
|
||||
-- self.hot_points[11] = point.new(45, 1, 5, 8, 0,"altar-R")
|
||||
-- self.hot_points[12] = point.new(44,11, 5, 0, 0,"altar-L")
|
||||
|
||||
self.target = self.hot_points[6]
|
||||
self.path = {next=6, actions={{action="right",event="target"}}}
|
||||
@@ -250,7 +255,12 @@ if DEBUG_FN_NAME then print("fight") end
|
||||
{action="jump" , event="target"}}},
|
||||
{next=6, actions={{action="right" , event="target"}}}
|
||||
}
|
||||
-- self.paths[11] = {}
|
||||
self.paths[11] = {
|
||||
{next=4, actions={{action="left", event="target"}}}
|
||||
}
|
||||
self.paths[12] = {
|
||||
{next=6, actions={{action="right", event="target"}}}
|
||||
}
|
||||
|
||||
self.fight_mode="chase"
|
||||
self:pattern_movement()
|
||||
@@ -259,32 +269,50 @@ end
|
||||
function imp:draw()
|
||||
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
||||
if self.invencible then
|
||||
pal.subpal(5,15)
|
||||
-- pal.subpal(5,15)
|
||||
end
|
||||
|
||||
draw.surf((self.frame&7)*self.w, (self.frame>>cxr2)*self.h, self.w, self.h, scr_x, scr_y, self.w, self.h, self.flip)
|
||||
pal.subpal(5)
|
||||
|
||||
draw.rect(scr_x+self.bb.x,scr_y+self.bb.y,self.bb.w,self.bb.h,3)
|
||||
|
||||
if #self.hot_points>0 then
|
||||
for _, p in pairs(self.hot_points) do
|
||||
if self.target==p then
|
||||
p:draw(true)
|
||||
else
|
||||
p:draw()
|
||||
if self.update==self.state_super then
|
||||
for col=13,15 do
|
||||
local newc = self.super_pal[col]
|
||||
if self.super_wait%6 == 0 then
|
||||
newc = newc+1
|
||||
if newc>15 then newc=13 end
|
||||
end
|
||||
pal.subpal(col,newc)
|
||||
self.super_pal[col]=newc
|
||||
end
|
||||
draw.surf(96, 32, self.w, self.h,
|
||||
scr_x, scr_y-self.h*(self.zoom-1),
|
||||
self.w*self.zoom, self.h*self.zoom,
|
||||
self.flip)
|
||||
for col=13,15 do pal.subpal(col) end
|
||||
--draw.surf(96, 32, self.w, self.h, scr_x, scr_y, self.w, self.h, self.flip)
|
||||
else
|
||||
draw.surf((self.frame&7)*self.w, (self.frame>>cxr2)*self.h, self.w, self.h, scr_x, scr_y, self.w, self.h, self.flip)
|
||||
pal.subpal(5)
|
||||
end
|
||||
|
||||
-- draw.rect(scr_x+self.bb.x,scr_y+self.bb.y,self.bb.w,self.bb.h,3)
|
||||
|
||||
--if #self.hot_points>0 then
|
||||
-- for _, p in pairs(self.hot_points) do
|
||||
-- if self.target==p then
|
||||
-- p:draw(true)
|
||||
-- else
|
||||
-- p:draw()
|
||||
-- end
|
||||
-- end
|
||||
--end
|
||||
|
||||
-- print("DRAW path= "..#self.path)
|
||||
if #self.path>0 then
|
||||
for i=1,#self.path do
|
||||
local world_x, world_y = coords.room_to_world(self.path[i][1], self.path[i][2], self.path[i][3])
|
||||
local scr_x, scr_y = viewp:screen_coords( world_x, world_y )
|
||||
draw.rect(scr_x, scr_y, 16, 16, 14)
|
||||
end
|
||||
end
|
||||
-- if #self.path>0 then
|
||||
-- for i=1,#self.path do
|
||||
-- local world_x, world_y = coords.room_to_world(self.path[i][1], self.path[i][2], self.path[i][3])
|
||||
-- local scr_x, scr_y = viewp:screen_coords( world_x, world_y )
|
||||
-- draw.rect(scr_x, scr_y, 16, 16, 14)
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
function imp:hit()
|
||||
@@ -513,16 +541,24 @@ if DEBUG_FN_NAME then print("state_normal") end
|
||||
end
|
||||
|
||||
function imp:super_ready()
|
||||
self.target = self.hot_points["altar"]
|
||||
if self.x<self.hot_points["altar"].x then
|
||||
if not DEBUG_FN_NAME then print("super_ready()") end
|
||||
if self.x<self.hot_points[3].x then
|
||||
self.target = self.hot_points[3]
|
||||
self.path = {next=3, actions= {{action="jumpfwd", event="land"},
|
||||
{action="right" , event="target"},
|
||||
{action="super" , event="super_ready"}}}
|
||||
else
|
||||
self.path = {next=3, actions= {{action="jumpfwd", event="land"},
|
||||
{action="left" , event="target"},
|
||||
{action="super" , event="super_ready"}}}
|
||||
{action="right" , event="target"},
|
||||
{action="super" , event="super_ready"}}}
|
||||
end
|
||||
--if self.x<self.hot_points[3].x then
|
||||
-- self.target = self.hot_points[11]
|
||||
-- self.path = {next=11, actions= {{action="jumpfwd", event="land"},
|
||||
-- {action="right" , event="target"},
|
||||
-- {action="super" , event="super_ready"}}}
|
||||
--else
|
||||
-- self.target = self.hot_points[12]
|
||||
-- self.path = {next=12, actions= {{action="jumpfwd", event="land"},
|
||||
-- {action="left" , event="target"},
|
||||
-- {action="super" , event="super_ready"}}}
|
||||
--end
|
||||
end
|
||||
|
||||
function imp:super()
|
||||
@@ -535,20 +571,31 @@ end
|
||||
|
||||
function imp:state_super()
|
||||
if DEBUG_FN_NAME then print("state_super") end
|
||||
print("state_super()")
|
||||
-- self.fight_mode = self.fight_modes["end_super"]
|
||||
-- self.super_cooldown=2000
|
||||
-- self.action_event = "end_super"
|
||||
-- self:advance()
|
||||
-- self:actualitzar_comportament()
|
||||
self.update=imp.super_end
|
||||
self.super_wait = self.super_wait -1
|
||||
if self.zoom<1.75 and self.super_wait>100 then
|
||||
if self.super_wait%4==0 then self.zoom=self.zoom+0.1 end
|
||||
elseif not self.super_fired and self.zoom>=1.75 and self.super_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 self.super_wait<=100 then
|
||||
if self.super_wait%4==0 then self.zoom=self.zoom-0.1 end
|
||||
end
|
||||
if self.super_wait == 0 then
|
||||
self.update=imp.super_end
|
||||
end
|
||||
end
|
||||
|
||||
function imp:super_end()
|
||||
print("super_end()")
|
||||
self.zoom = 1
|
||||
self.super_wait = 200
|
||||
-- self.super_cooldown=2000
|
||||
self.super_cooldown=200
|
||||
self:reset_fight_mode_cooldown()
|
||||
self.invencible = false
|
||||
self.super_fired = false
|
||||
self:free_movement()
|
||||
self.update=imp.state_normal
|
||||
end
|
||||
@@ -1027,13 +1074,13 @@ function imp:next_action()
|
||||
|
||||
if action=="stay" then
|
||||
if self.movement_type=="free" then
|
||||
msg_print(10,20,"FREE",true)
|
||||
-- msg_print(10,20,"FREE",true)
|
||||
action = self:free_next_action()
|
||||
elseif self.movement_type=="pattern" then
|
||||
msg_print(10,20,"PATTERN "..self.action_event,true)
|
||||
-- msg_print(10,20,"PATTERN "..self.action_event,true)
|
||||
action=self:pattern_next_action()
|
||||
elseif self.movement_type=="super" then
|
||||
msg_print(10,20,"SUPER "..self.action_event,true)
|
||||
-- msg_print(10,20,"SUPER "..self.action_event,true)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user