[WIP] Treballant en el jefe. 'chase' i 'away'
This commit is contained in:
60
data/imp.lua
60
data/imp.lua
@@ -54,8 +54,8 @@ function imp.new(_hab, _x, _y)
|
|||||||
action="", -- Acció a realitzar en el "pad"
|
action="", -- Acció a realitzar en el "pad"
|
||||||
movement="", -- Cap on es mou independentment de si està "flipat"
|
movement="", -- Cap on es mou independentment de si està "flipat"
|
||||||
fight_modes=_fight_modes, -- mode de lluita (Llevar?)
|
fight_modes=_fight_modes, -- mode de lluita (Llevar?)
|
||||||
mode="stop", -- mode de lluita actiu
|
fight_mode="stop", -- mode de lluita actiu
|
||||||
mode_cooldown=500, -- 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
|
||||||
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
|
||||||
@@ -87,7 +87,7 @@ function imp.new(_hab, _x, _y)
|
|||||||
do_flip=imp.do_flip, -- Orienta a l'imp cap a l'actor
|
do_flip=imp.do_flip, -- Orienta a l'imp cap a l'actor
|
||||||
-- mode_controller=imp.mode_controller,
|
-- mode_controller=imp.mode_controller,
|
||||||
reduce_cooldown=imp.reduce_cooldown, -- Decrementa els cooldown
|
reduce_cooldown=imp.reduce_cooldown, -- Decrementa els cooldown
|
||||||
reset_mode_cooldown=imp.reset_mode_cooldown, -- Asignar un valor a mode_cooldown (per a mantindre una coherència cada volta que es crida)
|
reset_fight_mode_cooldown=imp.reset_fight_mode_cooldown, -- Asignar un valor a fight_mode_cooldown (per a mantindre una coherència cada volta que es crida)
|
||||||
controller_input=imp.controller_input, -- Traduir l'accio en moviment
|
controller_input=imp.controller_input, -- Traduir l'accio en moviment
|
||||||
actualitzar_comportament=imp.actualitzar_comportament, -- "Pensar" que fer
|
actualitzar_comportament=imp.actualitzar_comportament, -- "Pensar" que fer
|
||||||
analyze_env=imp.analyze_env, -- Analitza l'entorn a vore que està pasant
|
analyze_env=imp.analyze_env, -- Analitza l'entorn a vore que està pasant
|
||||||
@@ -241,7 +241,7 @@ if DEBUG_FN_NAME then print("fight") end
|
|||||||
}
|
}
|
||||||
self.paths[11] = {}
|
self.paths[11] = {}
|
||||||
|
|
||||||
self.mode="chase"
|
self.fight_mode="chase"
|
||||||
self:pattern_movement()
|
self:pattern_movement()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -484,16 +484,16 @@ 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
|
||||||
self.mode = self.fight_modes["super"]
|
self.fight_mode = self.fight_modes["super"]
|
||||||
self.mode_cooldown=1
|
self:reset_fight_mode_cooldown(1)
|
||||||
self.super_cooldown=2000
|
self.super_cooldown=2000
|
||||||
self.update=imp.state_normal
|
self.update=imp.state_normal
|
||||||
end
|
end
|
||||||
|
|
||||||
function imp:shot(actor)
|
function imp:shot(actor)
|
||||||
if DEBUG_FN_NAME then print("shot") end
|
if DEBUG_FN_NAME then print("shot") end
|
||||||
self.mode = self.fight_modes["shot"]
|
self.fight_mode = self.fight_modes["shot"]
|
||||||
self.mode_cooldown=1
|
self:reset_fight_mode_cooldown(1)
|
||||||
print("FIREBALL!!")
|
print("FIREBALL!!")
|
||||||
self.shot_cooldown = 500
|
self.shot_cooldown = 500
|
||||||
end
|
end
|
||||||
@@ -505,17 +505,17 @@ end
|
|||||||
|
|
||||||
function imp:reduce_cooldown()
|
function imp:reduce_cooldown()
|
||||||
if DEBUG_FN_NAME then print("reduce_cooldown") end
|
if DEBUG_FN_NAME then print("reduce_cooldown") end
|
||||||
if self.mode=="stop" then return end
|
if self.fight_mode=="stop" then return end
|
||||||
|
|
||||||
self.mode_cooldown = self.mode_cooldown -1
|
self.fight_mode_cooldown = self.fight_mode_cooldown -1
|
||||||
self.super_cooldown = self.super_cooldown -1
|
self.super_cooldown = self.super_cooldown -1
|
||||||
self.shoot_cooldown = self.shoot_cooldown -1
|
self.shoot_cooldown = self.shoot_cooldown -1
|
||||||
end
|
end
|
||||||
|
|
||||||
function imp:reset_mode_cooldown( value )
|
function imp:reset_fight_mode_cooldown( value )
|
||||||
if DEBUG_FN_NAME then print("reset_mode_cooldown") end
|
if DEBUG_FN_NAME then print("reset_fight_mode_cooldown") end
|
||||||
value = value or 500
|
value = value or 1500
|
||||||
self.mode_cooldown = value
|
self.fight_mode_cooldown = value
|
||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -583,7 +583,7 @@ function imp:path_next_action( from )
|
|||||||
if DEBUG_FN_NAME then print("path_next_action "..from) end
|
if DEBUG_FN_NAME then print("path_next_action "..from) end
|
||||||
if #self.paths[from]>0 then
|
if #self.paths[from]>0 then
|
||||||
self:pattern_movement()
|
self:pattern_movement()
|
||||||
self:reset_mode_cooldown()
|
self:reset_fight_mode_cooldown()
|
||||||
-- Activar següent target
|
-- Activar següent target
|
||||||
self:next_target(from)
|
self:next_target(from)
|
||||||
action = self:path_action()
|
action = self:path_action()
|
||||||
@@ -627,7 +627,7 @@ if DEBUG_FN_NAME then print("free_next_action") end
|
|||||||
|
|
||||||
--Comprovar si está en target
|
--Comprovar si está en target
|
||||||
if collision(self, self.target) then
|
if collision(self, self.target) then
|
||||||
self:reset_mode_cooldown()
|
self:reset_fight_mode_cooldown()
|
||||||
|
|
||||||
-- Buscar quin es el target
|
-- Buscar quin es el target
|
||||||
local idx = 1
|
local idx = 1
|
||||||
@@ -876,6 +876,7 @@ end
|
|||||||
|
|
||||||
function imp:next_action()
|
function imp:next_action()
|
||||||
local action = "stay"
|
local action = "stay"
|
||||||
|
|
||||||
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()
|
||||||
@@ -892,6 +893,14 @@ function imp:next_target(from)
|
|||||||
else
|
else
|
||||||
action=self:pattern_next_target( from )
|
action=self:pattern_next_target( from )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- seleccionar mode d'acció
|
||||||
|
--local last_mode=self.fight_mode
|
||||||
|
-- self.fight_mode=self.fight_modes["chase"]
|
||||||
|
if self.fight_mode_cooldown<=0 then
|
||||||
|
self.fight_mode=self.fight_modes[math.random(2)] -- chase o away
|
||||||
|
self:reset_fight_mode_cooldown()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------
|
-------------------------------
|
||||||
@@ -902,32 +911,31 @@ end
|
|||||||
-- traduir a acció de pad
|
-- traduir a acció de pad
|
||||||
-------------------------------
|
-------------------------------
|
||||||
function imp:move( )
|
function imp:move( )
|
||||||
if DEBUG_FN_NAME then print("move "..self.mode) end
|
if DEBUG_FN_NAME then print("move "..self.fight_mode) end
|
||||||
local action = "stay"
|
local action = "stay"
|
||||||
|
|
||||||
if self.mode=="stop" then return action end
|
if self.fight_mode=="stop" then return action end
|
||||||
|
|
||||||
-- S'ha acabat el temps per a arribar a un target
|
-- S'ha acabat el temps per a arribar a un target
|
||||||
if self.mode_cooldown <= 0 then
|
if self.fight_mode_cooldown <= 0 then
|
||||||
-- Canviar a moviment lliure
|
-- Canviar a moviment lliure
|
||||||
self:free_movement()
|
self:free_movement()
|
||||||
|
|
||||||
-- seleccionar mode d'acció
|
|
||||||
local last_mode=self.mode
|
|
||||||
|
|
||||||
-- Reinicialitzar el patró de moviment i el cooldown
|
-- Reinicialitzar el patró de moviment i el cooldown
|
||||||
self:reset_mode_cooldown()
|
self:reset_fight_mode_cooldown()
|
||||||
self:path_reset()
|
self:path_reset()
|
||||||
|
|
||||||
self.mode=self.fight_modes["chase"]
|
|
||||||
|
|
||||||
-- Seleccionar el següent target aleatoriament
|
-- Seleccionar el següent target aleatoriament
|
||||||
self:next_target()
|
self:next_target()
|
||||||
|
|
||||||
print("Next random target => "..self.target.id)
|
print("Next random target => "..self.target.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:do_flip(abad)
|
if self.fight_mode==self.fight_modes["chase"] then
|
||||||
|
self:do_flip(abad)
|
||||||
|
else
|
||||||
|
self:do_flip(self.target)
|
||||||
|
end
|
||||||
|
|
||||||
if self.analisis.going_to_fall then self.action_event="prefall" end
|
if self.analisis.going_to_fall then self.action_event="prefall" end
|
||||||
if self.analisis.target_reached then self.action_event="target" end
|
if self.analisis.target_reached then self.action_event="target" end
|
||||||
|
|||||||
Reference in New Issue
Block a user