function imp:choose_action() -- antic imp:move if self.mood==self.moods.stop then return self.mood end if DEBUG_FN_NAME then print("choose_action "..self.mood) end local next_action = self.actions.no_action -- Si no te ganes de fer res, no moure if self.mood==self.moods.stop then return self.actions.no_action 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.can_go_altar then self:super_ready() end -- if self.fight_mode == self.fight_modes["super"] then self.action_event="super" end -- if self.fight_mode == self.fight_modes["end_super"] then self.action_event="end_super" end next_action = self:next_action() if self.analisis.target_reached and next_action=="super" then -- print("Super READY!") self.action_event = "super_ready" -- next_action = self:next_action() self:super() end if self.old_action~=next_action then self.old_action=next_action -- print(self.old_action) end self.action = next_action return next_action end function imp:next_action() local next_action = self.actions.no_action -- Si el blanc està a tir if self.timers.shot<=0 then if h_collision(self, self.shot_target) then next_action = self.actions.shot end end print("next_action= "..next_action.." == "..self.actions.no_action) if next_action==self.actions.no_action then if self.move_type==self.move_types.free then -- msg_print(10,20,"FREE",true) next_action = self:free_next_action() elseif self.move_type==self.move_types.pattern then -- msg_print(10,20,"PATTERN "..self.action_event,true) print("imp_action.lua -> next_action -> pattern") next_action=self:pattern_next_action() print("imp_action.lua -> next_action -> pattern => "..next_action) elseif self.move_type==self.move_types.super then -- msg_print(10,20,"SUPER "..self.action_event,true) end end return next_action end function imp:free_next_action() if DEBUG_FN_NAME then print("free_next_action") end -- Moviment horitzontal if self.target.x+self.target.bb.x>=self.x+self.bb.x then action="right" elseif self.target.x+self.target.bb.xself.target.y or self.y pattern_next_action -> "..self.action_event.."~="..pattern_event) -- -- Si no s'ha donat l'event mantindre el moviment -- if self.action_event~=pattern_event then -- action = self.actions[self.pattern.actions[self.pattern_point].action] -- else -- -- Si s'ha donat l'event avançar el punter del path -- -- En el path -- self.pattern_point = self.pattern_point + 1 -- -- Si no queden accions carregar el següent path -- print(self.pattern_point..">#"..#self.pattern.actions) -- if self.pattern_point>#self.pattern.actions then -- self:pattern_get_next_path() -- end -- print("-self.pattern_point= ".. self.pattern_point) -- action = self:pattern_action() -- end -- self.action_event = ""; -- Action_event processat -- return action -- end function imp:pattern_next_action() if DEBUG_FN_NAME then print("pattern_next_action") end local pattern_event = self.pattern:event() print("imp_action.lua -> pattern_next_action -> "..self.action_event.."~="..self.pattern:event()) -- Si no s'ha donat l'event mantindre el moviment if self.action_event~=self.pattern:event() then action = self.pattern:action() else -- Següent acció action = self.pattern:next_action() end self.action_event = ""; -- Action_event processat return self.actions[action] end function imp:pattern_action() if not DEBUG_FN_NAME then print("pattern_action") end local idx = self.pattern_point print(idx) local pattern_action = self.pattern.actions[idx] local curr_action = pattern_action.action local next_action = self.actions[curr_action] return next_action end function imp:_moure( foo, name ) name = name or "anonymous" print("_moure= "..name) self.moure = foo end -- function imp:path_next_action() -- if not DEBUG_FN_NAME then print("path_next_action "..from) end -- if #self.paths[self.path.target]>0 then -- -- self:pattern_movement() -- self:reset_target_timer() -- self:next_target() -- action = self:path_action() -- else -- action = self:pattern_recovery() -- print("PNA Recovery "..action) -- end -- return action -- end