[WIP] Treballant en el jefe. Implementant chase i avoid

This commit is contained in:
2026-04-19 15:56:33 +02:00
parent dab08a0f17
commit 5622392f41
6 changed files with 94 additions and 20 deletions

View File

@@ -15,7 +15,7 @@ end
--
-------------------------------
function imp:reduce_timers()
if self.mood==self.moods.stop then return end
if self.mood=="stop" then return end
if DEBUG_FN_NAME then print_dbg("reduce_timers") end
for key, val in pairs(self.timers) do
@@ -37,13 +37,13 @@ end
--
-------------------------------
function imp:reset_timer( timer )
if self.mood == self.moods.stop then return end
if self.mood == "stop" then return end
if DEBUG_FN_NAME then print_dbg("reduce_timers") end
local time = 0
if timer=="mood" then time = 150
elseif timer=="target" then time = 350
elseif timer=="shot" then time = 100
elseif timer=="super" then time = 200
elseif timer=="super" then time = 600
elseif timer=="super_wait" then time = 200
elseif timer=="flip_wait" then time = 50
end
@@ -55,7 +55,7 @@ end
--
-------------------------------
function imp:analyze_env() --OK
if self.mood==self.moods.stop then return end
if self.mood=="stop" then return end
if DEBUG_FN_NAME then print_dbg("analyze_env") end
-- Distancia fins a l'abad
local r = distancia(self,abad)
@@ -180,10 +180,10 @@ end
--
-------------------------------
function imp:choose_action() -- antic imp:move
if DEBUG_FN_NAME then print_dbg("choose_action "..self.mood.." / "..self.moods.stop) end
-- if self.mood==self.moods.stop then return self.mood end
if DEBUG_FN_NAME then print_dbg("choose_action "..self.mood.." / ".."stop") end
-- if self.mood=="stop" then return self.mood end
-- Si no te ganes de fer res, no moure
if self.mood==self.moods.stop then return self.actions.no_action end
if self.mood=="stop" then return self.actions.no_action end
local next_action = self:next_action()
@@ -513,6 +513,14 @@ function imp:next_action()
next_action = "shot"
end
-- anar a fer el super
if self.timers.super<=0 then
self.pattern:set_target_mode(PATTERN_CHASE,self.pattern.node[1])
else
self.pattern:set_target_mode(self.mood,abad)
end
-- fer el super
if self.timers.super<=0 and self:check_action_event("super_ready") then
if self.x<self.pattern.node[3].x then
local node = 3
@@ -567,7 +575,7 @@ if DEBUG_FN_NAME then print_dbg("") end
end
function imp:state_jumping()
if self.mood==self.moods.stop then return self.mood end
if self.mood=="stop" then return self.mood end
if DEBUG_FN_NAME then print_dbg("state_jumping") end
-- ??
self.wait=self.wait+1
@@ -729,7 +737,7 @@ if DEBUG_FN_NAME then print_dbg("land") end
end
function imp:state_walking()
if self.mood==self.moods.stop then return end
if self.mood=="stop" then return end
if DEBUG_FN_NAME then print("state_walking") end
-- Limitar la velocitat de moviment
@@ -859,3 +867,13 @@ function imp:super_movement()
if DEBUG_FN_NAME then print("super_movement") end
self.move_type = self.move_types.super
end
function imp:choose_mood()
if self.mood=="stop" then return end
if self.timers.mood<=0 then
self.mood=self.moods[math.random(2+(math.random(2)-1))+1] -- chase o avoid o aleatoriament neutral
self:reset_timer("mood")
print(self.mood)
end
end