[WIP] Treballant en el jefe. Super power done!
This commit is contained in:
@@ -6,11 +6,18 @@ fireball={
|
|||||||
wait=0,
|
wait=0,
|
||||||
flip=false,
|
flip=false,
|
||||||
step_length=3,
|
step_length=3,
|
||||||
bb={x=0,y=0,w=4,h=4}
|
power=1,
|
||||||
|
size=1,
|
||||||
|
bb={x=0,y=0,w=4,h=4},
|
||||||
|
x1=0,
|
||||||
|
y1=0,
|
||||||
|
step_length_x=1,
|
||||||
|
step_length_y=1,
|
||||||
}
|
}
|
||||||
|
|
||||||
function fireball.init(_hab,_x,_y,_flip, _off_x, _off_y)
|
function fireball.init(_hab,_x,_y,_flip, _off_x, _off_y, _power)
|
||||||
local world_x, world_y = coords.room_to_world(_hab,_x,_y)
|
local world_x, world_y = coords.room_to_world(_hab,_x,_y)
|
||||||
|
_power = _power or 1
|
||||||
if fireball.hab ~= -1 then return end
|
if fireball.hab ~= -1 then return end
|
||||||
_off_x = _off_x or 0
|
_off_x = _off_x or 0
|
||||||
_off_y = _off_y or 0
|
_off_y = _off_y or 0
|
||||||
@@ -18,19 +25,63 @@ function fireball.init(_hab,_x,_y,_flip, _off_x, _off_y)
|
|||||||
fireball.x= world_x+_off_x
|
fireball.x= world_x+_off_x
|
||||||
fireball.y= world_y+_off_y
|
fireball.y= world_y+_off_y
|
||||||
fireball.flip=_flip
|
fireball.flip=_flip
|
||||||
|
fireball.power=_power
|
||||||
|
fireball.size=1
|
||||||
|
fireball.w = 6
|
||||||
|
fireball.h = 6
|
||||||
|
fireball.bb = {x=0,y=0,w=4,h=4}
|
||||||
end
|
end
|
||||||
|
|
||||||
function fireball.draw()
|
function fireball.draw()
|
||||||
if fireball.hab == -1 then return end
|
if fireball.hab == -1 then return end
|
||||||
local scr_x, scr_y = viewp:screen_coords( fireball.x, fireball.y )
|
local scr_x, scr_y = viewp:screen_coords( fireball.x, fireball.y )
|
||||||
draw.circf(scr_x,scr_y,8,16)
|
draw.circf(scr_x,scr_y,8*fireball.size,16)
|
||||||
draw.circf(scr_x,scr_y,6,3)
|
draw.circf(scr_x,scr_y,6*fireball.size,3)
|
||||||
draw.circf(scr_x,scr_y,2,8)
|
draw.circf(scr_x,scr_y,2*fireball.size,8)
|
||||||
end
|
end
|
||||||
|
|
||||||
function fireball.update()
|
function fireball.update()
|
||||||
|
if fireball.power==2 and fireball.power>fireball.size then
|
||||||
|
fireball.wait = fireball.wait + 1
|
||||||
|
fireball.x1=abad.x+abad.bb.x+(abad.bb.w//2)
|
||||||
|
fireball.y1=abad.y
|
||||||
|
if abad.x<fireball.x then
|
||||||
|
fireball.step_length_x = -1
|
||||||
|
else
|
||||||
|
fireball.step_length_x = 1
|
||||||
|
end
|
||||||
|
if abad.y<fireball.y then
|
||||||
|
fireball.step_length_y = -1
|
||||||
|
else
|
||||||
|
fireball.step_length_y = 1
|
||||||
|
end
|
||||||
|
if fireball.wait==6 then
|
||||||
|
fireball.size = fireball.size+0.1
|
||||||
|
fireball.wait = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local dx = math.abs(fireball.x-fireball.x1)
|
||||||
|
local dy = math.abs(fireball.y-fireball.y1)
|
||||||
|
if dx<dy then
|
||||||
|
if dy~=0 then
|
||||||
|
fireball.step_length_x = fireball.step_length_x*(dx/dy)*2
|
||||||
|
fireball.step_length_y = fireball.step_length_y*2
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if dx~=0 then
|
||||||
|
fireball.step_length_x = fireball.step_length_x*2
|
||||||
|
fireball.step_length_y = fireball.step_length_y*(dy/dx)*2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
fireball.w=6*fireball.size
|
||||||
|
fireball.h=fireball.w
|
||||||
|
fireball.bb = {x=0,y=0,w=4*fireball.size,h=4*fireball.size}
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
if fireball.hab == -1 then return end
|
if fireball.hab == -1 then return end
|
||||||
fireball.wait=fireball.wait+1
|
-- fireball.wait=fireball.wait+1
|
||||||
|
|
||||||
--if fireball.wait==3 then
|
--if fireball.wait==3 then
|
||||||
fireball.wait=0
|
fireball.wait=0
|
||||||
@@ -39,23 +90,33 @@ function fireball.update()
|
|||||||
-- fireball.hab=-1
|
-- fireball.hab=-1
|
||||||
-- return
|
-- return
|
||||||
--end
|
--end
|
||||||
|
if fireball.power==1 then
|
||||||
if arc_check_tile(fireball.x,fireball.y)<tiletype.block then
|
if arc_check_tile(fireball.x,fireball.y)<tiletype.block then
|
||||||
if fireball.flip then
|
if fireball.flip then
|
||||||
fireball.x=fireball.x-fireball.step_length
|
fireball.x=fireball.x-fireball.step_length
|
||||||
|
else
|
||||||
|
fireball.x=fireball.x+fireball.step_length
|
||||||
|
end
|
||||||
else
|
else
|
||||||
fireball.x=fireball.x+fireball.step_length
|
fireball.hab=-1
|
||||||
|
return
|
||||||
end
|
end
|
||||||
else
|
elseif fireball.power==2 then
|
||||||
fireball.hab=-1
|
fireball.x = fireball.x+fireball.step_length_x
|
||||||
return
|
fireball.y = fireball.y+fireball.step_length_y
|
||||||
end
|
end
|
||||||
|
|
||||||
if viewp:inside(fireball.x, fireball.y, fireball.w, fireball.h) then
|
if viewp:inside(fireball.x, fireball.y, fireball.w, fireball.h) then
|
||||||
if collision(fireball,abad) and abad.update~=abad_state_crouch then
|
if collision(fireball,abad) then
|
||||||
|
if fireball.power==1 and abad.update~=abad_state_crouch then
|
||||||
|
abad_hurt(1)
|
||||||
|
elseif fireball.power==2 then
|
||||||
|
abad_hurt(2)
|
||||||
|
end
|
||||||
fireball.hab=-1
|
fireball.hab=-1
|
||||||
abad_hurt(1)
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
fireball.hab=-1
|
||||||
end
|
end
|
||||||
--end
|
--end
|
||||||
end
|
end
|
||||||
|
|||||||
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="stop", -- mode de lluita actiu
|
||||||
fight_mode_cooldown=1500, -- cicles fins al canvi de mode
|
fight_mode_cooldown=1500, -- cicles fins al canvi de mode
|
||||||
-- super_cooldown=2000, -- cicles fins a Super actiu
|
-- 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
|
shot_cooldown=500, -- cicles fina a poder disparar
|
||||||
hot_points={}, -- llista de punts del mapa on anar
|
hot_points={}, -- llista de punts del mapa on anar
|
||||||
target={}, -- següent punt 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
|
analisis={}, -- Resultat de la informació extreta de l'entorn
|
||||||
old_action="-",
|
old_action="-",
|
||||||
invencible=false,
|
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,
|
-- direccio=imp.direccio,
|
||||||
draw=imp.draw,
|
draw=imp.draw,
|
||||||
hit=imp.hit,
|
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[1] = point.new(44, 5, 1, 0, 8,"P1")
|
||||||
self.hot_points[2] = point.new(45, 8, 1, 0, 8,"P2")
|
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[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[4] = point.new(54, 5, 4, -8, 0,"P4")
|
||||||
self.hot_points[5] = point.new(54,12, 4, 8, 0,"P5")
|
self.hot_points[5] = point.new(54,12, 4, 8, 0,"P5")
|
||||||
self.hot_points[6] = point.new(55, 8, 4, 8, 0,"P6")
|
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[8] = point.new(54, 5, 0, 0, 0,"P8")
|
||||||
self.hot_points[9] = point.new(54, 9, 1, 0, 0,"P9")
|
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[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.target = self.hot_points[6]
|
||||||
self.path = {next=6, actions={{action="right",event="target"}}}
|
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"}}},
|
{action="jump" , event="target"}}},
|
||||||
{next=6, actions={{action="right" , 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.fight_mode="chase"
|
||||||
self:pattern_movement()
|
self:pattern_movement()
|
||||||
@@ -259,32 +269,50 @@ end
|
|||||||
function imp:draw()
|
function imp:draw()
|
||||||
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
||||||
if self.invencible then
|
if self.invencible then
|
||||||
pal.subpal(5,15)
|
-- pal.subpal(5,15)
|
||||||
end
|
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)
|
if self.update==self.state_super then
|
||||||
pal.subpal(5)
|
for col=13,15 do
|
||||||
|
local newc = self.super_pal[col]
|
||||||
draw.rect(scr_x+self.bb.x,scr_y+self.bb.y,self.bb.w,self.bb.h,3)
|
if self.super_wait%6 == 0 then
|
||||||
|
newc = newc+1
|
||||||
if #self.hot_points>0 then
|
if newc>15 then newc=13 end
|
||||||
for _, p in pairs(self.hot_points) do
|
|
||||||
if self.target==p then
|
|
||||||
p:draw(true)
|
|
||||||
else
|
|
||||||
p:draw()
|
|
||||||
end
|
end
|
||||||
|
pal.subpal(col,newc)
|
||||||
|
self.super_pal[col]=newc
|
||||||
end
|
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
|
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)
|
-- print("DRAW path= "..#self.path)
|
||||||
if #self.path>0 then
|
-- if #self.path>0 then
|
||||||
for i=1,#self.path do
|
-- 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 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 )
|
-- local scr_x, scr_y = viewp:screen_coords( world_x, world_y )
|
||||||
draw.rect(scr_x, scr_y, 16, 16, 14)
|
-- draw.rect(scr_x, scr_y, 16, 16, 14)
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
end
|
||||||
|
|
||||||
function imp:hit()
|
function imp:hit()
|
||||||
@@ -513,16 +541,24 @@ if DEBUG_FN_NAME then print("state_normal") end
|
|||||||
end
|
end
|
||||||
|
|
||||||
function imp:super_ready()
|
function imp:super_ready()
|
||||||
self.target = self.hot_points["altar"]
|
if not DEBUG_FN_NAME then print("super_ready()") end
|
||||||
if self.x<self.hot_points["altar"].x then
|
if self.x<self.hot_points[3].x then
|
||||||
|
self.target = self.hot_points[3]
|
||||||
self.path = {next=3, actions= {{action="jumpfwd", event="land"},
|
self.path = {next=3, actions= {{action="jumpfwd", event="land"},
|
||||||
{action="right" , event="target"},
|
{action="right" , event="target"},
|
||||||
{action="super" , event="super_ready"}}}
|
{action="super" , event="super_ready"}}}
|
||||||
else
|
|
||||||
self.path = {next=3, actions= {{action="jumpfwd", event="land"},
|
|
||||||
{action="left" , event="target"},
|
|
||||||
{action="super" , event="super_ready"}}}
|
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
function imp:super()
|
function imp:super()
|
||||||
@@ -535,20 +571,31 @@ end
|
|||||||
|
|
||||||
function imp:state_super()
|
function imp:state_super()
|
||||||
if DEBUG_FN_NAME then print("state_super") end
|
if DEBUG_FN_NAME then print("state_super") end
|
||||||
print("state_super()")
|
self.super_wait = self.super_wait -1
|
||||||
-- self.fight_mode = self.fight_modes["end_super"]
|
if self.zoom<1.75 and self.super_wait>100 then
|
||||||
-- self.super_cooldown=2000
|
if self.super_wait%4==0 then self.zoom=self.zoom+0.1 end
|
||||||
-- self.action_event = "end_super"
|
elseif not self.super_fired and self.zoom>=1.75 and self.super_wait>100 then
|
||||||
-- self:advance()
|
local x_ini = self.x+self.bb.x+self.bb.w+4
|
||||||
-- self:actualitzar_comportament()
|
local hab, tx, ty, off_x, off_y = coords.world_to_tile(x_ini,self.y+(self.h/2))
|
||||||
self.update=imp.super_end
|
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
|
end
|
||||||
|
|
||||||
function imp:super_end()
|
function imp:super_end()
|
||||||
print("super_end()")
|
print("super_end()")
|
||||||
|
self.zoom = 1
|
||||||
|
self.super_wait = 200
|
||||||
|
-- self.super_cooldown=2000
|
||||||
self.super_cooldown=200
|
self.super_cooldown=200
|
||||||
self:reset_fight_mode_cooldown()
|
self:reset_fight_mode_cooldown()
|
||||||
self.invencible = false
|
self.invencible = false
|
||||||
|
self.super_fired = false
|
||||||
self:free_movement()
|
self:free_movement()
|
||||||
self.update=imp.state_normal
|
self.update=imp.state_normal
|
||||||
end
|
end
|
||||||
@@ -1027,13 +1074,13 @@ function imp:next_action()
|
|||||||
|
|
||||||
if action=="stay" then
|
if action=="stay" then
|
||||||
if self.movement_type=="free" then
|
if self.movement_type=="free" then
|
||||||
msg_print(10,20,"FREE",true)
|
-- msg_print(10,20,"FREE",true)
|
||||||
action = self:free_next_action()
|
action = self:free_next_action()
|
||||||
elseif self.movement_type=="pattern" then
|
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()
|
action=self:pattern_next_action()
|
||||||
elseif self.movement_type=="super" then
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
BIN
data/tiles.gif
BIN
data/tiles.gif
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Reference in New Issue
Block a user