[WIP] Treballant en el jefe. Organitzant codi (Ha deixat de funcionar quasi tot)

[FIX] Els warps reutilitzats mantenien l'estat anterior
[NEW] Funcio distancia(a, b)
This commit is contained in:
2026-04-12 23:02:35 +02:00
parent f26d43a97d
commit a43173a940
15 changed files with 1293 additions and 22 deletions

View File

@@ -58,7 +58,7 @@ function imp.new(_hab, _x, _y)
fight_mode_cooldown=1500, -- cicles fins al canvi de mode
-- super_cooldown=2000, -- cicles fins a Super actiu
super_cooldown=200, -- cicles fins a Super actiu
shot_cooldown=500, -- cicles fina a poder disparar
shot_cooldown=100, -- cicles fina a poder disparar
hot_points={}, -- llista de punts del mapa on anar
target={}, -- següent punt on anar
old_target={}, -- target anterior
@@ -69,6 +69,7 @@ function imp.new(_hab, _x, _y)
analisis={}, -- Resultat de la informació extreta de l'entorn
old_action="-",
invencible=false,
invencible_time=50,
flip_wait=100, -- Temps per a forçar un flip
super_wait=200,
zoom=1,
@@ -207,9 +208,9 @@ if DEBUG_FN_NAME then print("fight") end
}
self.paths[4] = {
{next=1, actions={{action="jump" , event="target"}}},
--{next=5, actions={{action="right", event="target"}}},
--{next=6, actions={{action="right", event="target"}}},
--{next=8, actions={{action="jump" , event="target"}}},
{next=5, actions={{action="right", event="target"}}},
{next=6, actions={{action="right", event="target"}}},
{next=8, actions={{action="jump" , event="target"}}},
}
self.paths[5] = {
{next=4, actions={{action="left" , event="target"}}},
@@ -268,9 +269,7 @@ end
function imp:draw()
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
if self.invencible then
-- pal.subpal(5,15)
end
if self.update==self.state_super then
for col=13,15 do
@@ -289,6 +288,9 @@ function imp:draw()
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
if self.invencible then
pal.subpal(5,1)
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)
end
@@ -319,10 +321,10 @@ function imp:hit()
if DEBUG_FN_NAME then print("hit") end
if not self.invencible then
self.energia = self.energia -1
--if self:distancia(abad)<100 then
-- self.invencible = true
-- self.invencible_time = 50
--end
if distancia(self, abad)<50 and self.invencible_time<=0 then
self.invencible = true
self.invencible_time = 50
end
end
if self.energia==1 then self.can_warp=true end
if self.energia <= 0 then
@@ -614,11 +616,11 @@ if DEBUG_FN_NAME then print("shot") end
flip=true
x_ini = self.x-4
end
local hab, tx, ty, off_x, off_y = coords.world_to_tile(x_ini,self.y+(self.h/2))
local hab, tx, ty, off_x, off_y = coords.world_to_tile(x_ini,self.y+(self.h/4))
fireball.init(hab, tx, ty, flip, off_x, off_y)
sound.play(audio_hit)
self.shot_cooldown = 500
self.shot_cooldown = 100
end
function imp:do_flip(actor)
@@ -634,6 +636,7 @@ if DEBUG_FN_NAME then print("reduce_cooldown") end
self.super_cooldown = self.super_cooldown -1
self.shot_cooldown = self.shot_cooldown -1
self.flip_wait = self.flip_wait -1
self.invencible_time = self.invencible_time -1
end
function imp:reset_fight_mode_cooldown( value )
@@ -868,9 +871,7 @@ if DEBUG_FN_NAME then print("analyze_env") end
-- end
-- Distancia fins a l'abad
dx = (self.x-abad.x)
dy = (self.y-abad.y)
r = math.sqrt(dx*dx+dy*dy)
local r = distancia(self,abad)
-- msg_print(10,20,r,true)
self.analisis.can_chase_abad = false
if r<=100 then
@@ -1030,6 +1031,7 @@ end
function imp:actualitzar_comportament()
if DEBUG_FN_NAME then print("actualitzar_comportament") end
self:reduce_cooldown()
if self.invencible_time<=0 then self.invencible=false end
-- if self.update==imp.state_jumping or self.update==imp.state_falling then
-- -- self:think()
-- -- self:move()