[WIP] Treballant en el jefe. Pattern recovery

This commit is contained in:
2026-04-17 21:57:00 +02:00
parent 82e00e04d1
commit 1b3aa47d9e
3 changed files with 77 additions and 8 deletions

View File

@@ -248,8 +248,10 @@ if DEBUG_FN_NAME then print_dbg("fight") end
self:create_hot_points() self:create_hot_points()
self:load_pattern_paths() self:load_pattern_paths()
self.pattern.manual_target = self.pattern.node[6] local node = 6
self.pattern.manual_path = {target=6, actions={{action="right",event="target"}}} local path = {target=6, actions={{action="right",event="target"}}}
self.pattern:add_manual_target ( node, path )
-- self.pattern.recovery = imp.pattern_recovery
self.shot_target = abad self.shot_target = abad
@@ -452,6 +454,59 @@ if DEBUG_FN_NAME then print_dbg("pattern_movement") end
-- print("Pattern") -- print("Pattern")
end end
function imp:pattern_recovery() -- OK
-- print("Pattern recovery")
self:pattern_movement() -- Canviar a moviment per patró
-- Situar-se en el mapa respecte als punts de recuperació (els tres punts del pis)
local x_after_4 = false
local x_after_5 = false
local x_after_6 = false
local y_upper_4 = false
local y_upper_5 = false
local y_upper_6 = false
if self.pattern.node[4].x<self.x then x_after_4 = true end
if self.pattern.node[5].x<self.x then x_after_5 = true end
if self.pattern.node[6].x<self.x then x_after_6 = true end
-- Comparar en el punt dels peus
if self.pattern.node[4].y>self.y+self.h then y_upper_4 = true end
if self.pattern.node[5].y>self.y+self.h then y_upper_5 = true end
if self.pattern.node[6].y>self.y+self.h then y_upper_6 = true end
local node = 0
local path = {}
-- Seleccionar les instruccions segons la posicio
if not y_upper_5 then
-- target 5
node = 5
if not x_after_5 then
-- right target
path = {target=5, actions={{action="right",event="target"}}}
else
-- left target
path = {target=5, actions={{action="left",event="target"}}}
end
else
if x_after_5 then
--target 4
node = 4
-- left target
path = {target=4, actions={{action="left",event="target"}}}
else
--target 6
node = 6
-- right target
path = {target=6, actions={{action="right",event="target"}}}
end
end
self.pattern:add_manual_target ( node, path )
-- Tornar l'acció a fer
-- return self.actions[self.path.actions[1].action]
end
------------------------------------------------------------------- -------------------------------------------------------------------
-- // ACTION -- // ACTION
function imp:next_action() function imp:next_action()
@@ -464,6 +519,10 @@ function imp:next_action()
-- Resta d'accions -- Resta d'accions
if next_action==self.actions.no_action then if next_action==self.actions.no_action then
if self.timers.target<=0 then
self:pattern_recovery()
self:reset_timer("target")
end
if self.move_type==self.move_types.free then if self.move_type==self.move_types.free then
-- FREE -- FREE
-- next_action = self:free_next_action() -- next_action = self:free_next_action()

View File

@@ -34,7 +34,7 @@ function imp.new(_hab,_x,_y)
step=0, step=0,
moods={stop=0, chase=1, avoid=2, neutral=4}, moods={stop=0, chase=1, avoid=2, neutral=4},
mood=0, --anterior fight_mode mood=0, --anterior fight_mode
timers={mood=150,target=250, shot=100, super=200, flip_wait=50}, --anterior *_cooldown timers={mood=150,target=100, shot=100, super=200, flip_wait=50}, --anterior *_cooldown
move_types={free=0, pattern=1, super=2}, move_types={free=0, pattern=1, super=2},
move_type=1, -- anterior movement_type 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}, actions={no_action=0, up=1, down=2, left=4, right=8, jump=16, shot=32, super=64, jumpfwd=128},
@@ -74,6 +74,7 @@ function imp.new(_hab,_x,_y)
check_action_event = imp.check_action_event, check_action_event = imp.check_action_event,
add_action_event = imp.add_action_event, add_action_event = imp.add_action_event,
shot = imp.shot, shot = imp.shot,
pattern_recovery = imp.pattern_recovery,
-- debug -- debug
_moure = imp._moure, _moure = imp._moure,
_pause = false, _pause = false,
@@ -172,6 +173,7 @@ function imp:update_normal()
-- analisis -- analisis
self:analyze_env() self:analyze_env()
self:update_action_events() self:update_action_events()
if self.analisis.target_reached then self:reset_timer("target") end
-- print_analisis() -- print_analisis()
-- decisio -- decisio

View File

@@ -17,12 +17,24 @@ function pattern.new()
action = pattern.action, action = pattern.action,
event = pattern.event, event = pattern.event,
actions = pattern.actions, actions = pattern.actions,
recovery = pattern.recovery, -- recovery = pattern.noop,
draw = pattern.draw, draw = pattern.draw,
collision = pattern.collision, collision = pattern.collision,
add_manual_target = pattern.add_manual_target
} }
end end
function pattern:add_manual_target ( node, path )
self.manual_target = self.node[node]
self.manual_path = path
self.target_idx = 1
self.action_idx = 1
end
function pattern:noop()
print("NO OP")
end
function pattern:draw() function pattern:draw()
local scr_x = 0 local scr_x = 0
local scr_y = 0 local scr_y = 0
@@ -179,10 +191,6 @@ function pattern:in_target( a )
return self:collision( a ) return self:collision( a )
end end
function pattern:recovery( point, target)
print_dbg("")
end
function pattern:collision( a ) function pattern:collision( a )
local b = self:target_node() local b = self:target_node()
return (a.x+a.bb.x+a.bb.w >= b.x+b.bb.x) return (a.x+a.bb.x+a.bb.w >= b.x+b.bb.x)