[WIP] Treballant en el jefe. Moviment per patró assegurat
This commit is contained in:
76
data/imp.lua
76
data/imp.lua
@@ -100,7 +100,9 @@ function imp.new(_hab, _x, _y)
|
||||
pattern_movement=imp.pattern_movement, -- Pasar a mode de moviment per patró
|
||||
pattern_next_action=imp.pattern_next_action, -- Següent acció en mode pattern
|
||||
pattern_next_target=imp.pattern_next_target, -- Següent target en mode pattern
|
||||
pattern_recovery=imp.pattern_recovery, -- Si per algun motiu perd el mode pattern recuperar-lo
|
||||
|
||||
-- Al afegir pattern_recovery el moviment lliure no te sentit (ni es gasta en este moment), se queda ara per si de cas
|
||||
free_movement=imp.free_movement, -- Pasar a mode de moviment lliure
|
||||
free_next_action=imp.free_next_action, -- Següent acció en mode lliure
|
||||
free_next_target=imp.free_next_target, -- Següent target en mode free
|
||||
@@ -152,10 +154,10 @@ if DEBUG_FN_NAME then print("fight") end
|
||||
{next=5, actions= {{action="right" , event="target"}}}
|
||||
}
|
||||
self.paths[2] = {
|
||||
{next=3, actions={{action="left" , event="prefall"},
|
||||
{action="jumpfwd" , event="land"},
|
||||
{next=3, actions= {{action="left" , event="prefall"},
|
||||
{action="jumpfwd", event="land"},
|
||||
{action="left" , event="target"}}},
|
||||
{next=6, actions={{action="left" , event="land"},
|
||||
{next=6, actions= {{action="left" , event="land"},
|
||||
{action="right" , event="target"}}},
|
||||
{next=6, actions= {{action="left" , event="prefall"},
|
||||
{action="jumpfwd", event="land"},
|
||||
@@ -170,7 +172,7 @@ if DEBUG_FN_NAME then print("fight") end
|
||||
{action="jumpfwd", event="land"},
|
||||
{action="left" , event="land"},
|
||||
{action="right" , event="target"}}},
|
||||
{next=5, actions={{action="left" , event="target"}}}
|
||||
{next=5, actions= {{action="left" , event="target"}}}
|
||||
}
|
||||
self.paths[3] = {
|
||||
{next=1, actions={{action="left" , event="prefall"},
|
||||
@@ -202,9 +204,9 @@ if DEBUG_FN_NAME then print("fight") end
|
||||
}
|
||||
self.paths[6] = {
|
||||
{next=2, actions={{action="jump", event="target"}}},
|
||||
{next=5, actions={{action="left", event="target"}}},
|
||||
{next=7, actions={{action="jump", event="target"}}},
|
||||
{next=4, actions={{action="left", event="target"}}}
|
||||
--{next=5, actions={{action="left", event="target"}}},
|
||||
--{next=7, actions={{action="jump", event="target"}}},
|
||||
--{next=4, actions={{action="left", event="target"}}}
|
||||
}
|
||||
self.paths[7] = {
|
||||
{next=5, actions={{action="left" , event="prefall"},
|
||||
@@ -240,7 +242,7 @@ 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] = {}
|
||||
|
||||
self.fight_mode="chase"
|
||||
self:pattern_movement()
|
||||
@@ -568,6 +570,7 @@ if DEBUG_FN_NAME then print("pattern_next_action") end
|
||||
-- print(" ACTION 2= "..action)
|
||||
end
|
||||
end
|
||||
self.action_event = ""; -- Action_event processat
|
||||
-- print(" ACTION ="..action)
|
||||
return action
|
||||
end
|
||||
@@ -580,6 +583,7 @@ if DEBUG_FN_NAME then print("pattern_next_target") end
|
||||
self.path = self.paths[from][next_path_idx]
|
||||
self.path_curr_action = 1
|
||||
self.target = self.hot_points[self.path.next]
|
||||
print("Next pattern target => "..self.path.next)
|
||||
end
|
||||
|
||||
function imp:path_next_action( from )
|
||||
@@ -593,8 +597,9 @@ if DEBUG_FN_NAME then print("path_next_action "..from) end
|
||||
action = self:path_action()
|
||||
-- self.action_event=""
|
||||
else
|
||||
self:free_movement()
|
||||
action = self:next_action()
|
||||
-- self:free_movement()
|
||||
-- action = self:next_action()
|
||||
action = self:pattern_recovery()
|
||||
end
|
||||
return action
|
||||
end
|
||||
@@ -606,6 +611,49 @@ if DEBUG_FN_NAME then print("free_movement") end
|
||||
print("Free")
|
||||
end
|
||||
|
||||
function imp:pattern_recovery()
|
||||
self:pattern_movement()
|
||||
self:path_reset()
|
||||
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.hot_points[4].x<self.x then x_after_4 = true end
|
||||
if self.hot_points[5].x<self.x then x_after_5 = true end
|
||||
if self.hot_points[6].x<self.x then x_after_6 = true end
|
||||
if self.hot_points[4].y>self.y+self.h then y_upper_4 = true end
|
||||
if self.hot_points[5].y>self.y+self.h then y_upper_5 = true end
|
||||
if self.hot_points[6].y>self.y+self.h then y_upper_6 = true end
|
||||
|
||||
if not y_upper_5 then
|
||||
-- target 5
|
||||
self.target = self.hot_points[5]
|
||||
if not x_after_5 then
|
||||
-- right target
|
||||
self.path = {next=5, actions={{action="right",event="target"}}}
|
||||
else
|
||||
-- left target
|
||||
self.path = {next=5, actions={{action="left",event="target"}}}
|
||||
end
|
||||
else
|
||||
if x_after_5 then
|
||||
--target 4
|
||||
self.target = self.hot_points[4]
|
||||
-- left target
|
||||
self.path = {next=4, actions={{action="left",event="target"}}}
|
||||
else
|
||||
--target 6
|
||||
self.target = self.hot_points[6]
|
||||
-- right target
|
||||
self.path = {next=6, actions={{action="right",event="target"}}}
|
||||
end
|
||||
end
|
||||
return self.path.actions[1].action
|
||||
end
|
||||
|
||||
function imp:free_next_action()
|
||||
if DEBUG_FN_NAME then print("free_next_action") end
|
||||
-- Moviment horitzontal
|
||||
@@ -900,9 +948,9 @@ end
|
||||
|
||||
function imp:next_target(from)
|
||||
if self.movement_type=="free" then
|
||||
action = self:free_next_target()
|
||||
self:free_next_target()
|
||||
else
|
||||
action=self:pattern_next_target( from )
|
||||
self:pattern_next_target( from )
|
||||
end
|
||||
|
||||
-- seleccionar mode d'acció
|
||||
@@ -940,6 +988,9 @@ if DEBUG_FN_NAME then print("move "..self.fight_mode) end
|
||||
self:next_target()
|
||||
|
||||
print("Next random target => "..self.target.id)
|
||||
|
||||
-- Intentar recuperar el mode per patró
|
||||
self:pattern_recovery()
|
||||
end
|
||||
|
||||
if self.flip_wait<=0 then
|
||||
@@ -961,7 +1012,6 @@ if DEBUG_FN_NAME then print("move "..self.fight_mode) end
|
||||
end
|
||||
|
||||
self.action = action
|
||||
self.action_event = ""
|
||||
|
||||
return action
|
||||
|
||||
|
||||
Reference in New Issue
Block a user