diff --git a/.gitignore b/.gitignore index ac2d29a..7d2b232 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ release/* *.exe *.dll *.xcf +desktop.ini mini mini_debug data-old diff --git a/data/imp2.lua b/data/imp2.lua index a54a94a..1cdff76 100644 --- a/data/imp2.lua +++ b/data/imp2.lua @@ -160,7 +160,7 @@ function imp.new(_hab,_x,_y) actions={no_action=0, up=1, down=2, left=4, right=8, jump=16, shot=32, super=64}, moods={stop=0, chase=1, avoid=2, neutral=4}, mood=0, --anterior fight_mode - timers={mood=150,target=150, shot=25, super=200, flip_wait=50}, --anterior *_cooldown + timers={mood=150,target=150, shot=2500, super=20000, flip_wait=50}, --anterior *_cooldown move_types={free=0, pattern=1, super=2}, move_type=1, -- anterior movement_type paths={}, -- Llista de "camins" a fer des d'un hot_point @@ -173,6 +173,9 @@ function imp.new(_hab,_x,_y) hot_points={}, -- llista de punts del mapa on anar step_length=1, falling = 0, + action_event="", -- Event d'acció que ha passat + jump_height=0, + max_jump_height=24, -- funcions next_frame = imp.staying_next_frame, -- funcio de seleccio del frame choose_mood = imp.choose_mood, @@ -188,6 +191,7 @@ function imp.new(_hab,_x,_y) pattern_movement = imp.pattern_movement, next_action = imp.next_action, pattern_next_action = imp.pattern_next_action, + pattern_action = imp.pattern_action, moure = imp.state_normal, controller_input = imp.controller_input, reduce_timers = imp.reduce_timers, @@ -198,10 +202,12 @@ function imp.new(_hab,_x,_y) pattern_next_target = imp.pattern_next_target, super_next_target = imp.super_next_target, pattern_recovery = imp.pattern_recovery, + pattern_get_next_path = imp.pattern_get_next_path, + do_jump = imp.do_jump, land = imp.land, shot = imp.shot, - _moure=imp._moure, -- temporal debug advance=imp.advance, + _moure=imp._moure, -- temporal debug } end @@ -272,10 +278,14 @@ function imp:update_hit() end function imp:update_normal() - self:reduce_timers() +print("-------------------------------------------------") +print("") +if self.pattern.target then print("TARGET= "..self.pattern.target) end +if self.pattern.target then print("ACTIONS= "..#self.pattern.actions) end + --self:reduce_timers() -- Ajustar mood (emocions) - self:choose_mood() + --self:choose_mood() -- analisis self:analyze_env() @@ -289,10 +299,10 @@ function imp:update_normal() self:moure() -- Logica per a selecció de frame - self:next_frame() + --self:next_frame() -- colisions en personatges - self:colisions() + --self:colisions() end -- imp.next_frame() @@ -448,13 +458,13 @@ if DEBUG_FN_NAME then print("reset_target_timer") end end function imp:pattern_get_next_path() -if DEBUG_FN_NAME then print("pattern_get_next_path") end +if not DEBUG_FN_NAME then print("pattern_get_next_path") end -- obtindre uno dels possibles camins des del target en el que està -- Si el camí s'ha acabat estarà en el punt self.path.target - local next_path_idx = math.random(#self.paths[self.path.target]) + local next_path_idx = math.random(#self.paths[self.pattern.target]) - self.path = self.paths[self.path.target][next_path_idx] - self.path_point = 1 + self.pattern = self.paths[self.pattern.target][next_path_idx] + self.pattern_point = 1 end function imp:create_hot_points() --OK @@ -599,8 +609,8 @@ if DEBUG_FN_NAME then print("fight") end self:load_pattern_paths() self.target = self.hot_points[6] - self.pattern = {next=6, actions={{action="right",event="target"}}} - + self.pattern = {target=6, actions={{action="right",event="target"}}} +print("imp2.lua -> #self.pattern.actions= "..#self.pattern.actions) self.shot_target = abad self.mood=self.moods.chase diff --git a/data/imp_action.lua b/data/imp_action.lua index d4684ec..4c94e89 100644 --- a/data/imp_action.lua +++ b/data/imp_action.lua @@ -41,14 +41,16 @@ function imp:next_action() 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 @@ -110,21 +112,23 @@ end function imp:pattern_next_action() if DEBUG_FN_NAME then print("pattern_next_action") end +print("self.pattern_point= ".. self.pattern_point) local pattern_event = self.pattern.actions[self.pattern_point].event - +print("imp_action.lua -> 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 - -- Si no queden accions carregar el següent path - if self.pattern_point<#self.pattern.actions then - self:pattern_get_next_path() - self.pattern_point = 0 - end - -- 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 @@ -132,8 +136,13 @@ if DEBUG_FN_NAME then print("pattern_next_action") end end function imp:pattern_action() -if DEBUG_FN_NAME then print("pattern_action") end - return self.actions[self.path.actions[self.pattern_point].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 diff --git a/data/imp_movement.lua b/data/imp_movement.lua index b13241a..5ee32fa 100644 --- a/data/imp_movement.lua +++ b/data/imp_movement.lua @@ -66,11 +66,6 @@ function imp:pattern_recovery() -- OK return self.actions[self.path.actions[1].action] end -function imp:pattern_next_target() -if DEBUG_FN_NAME then print("pattern_next_target") end - self.target = self.hot_points[self.path.next] -end - ------------------------------- -- imp.controller_input() -- @@ -79,14 +74,13 @@ end function imp:controller_input() if DEBUG_FN_NAME then print("controller_input") end -print(self.action) --To Do: JumpFWD if self.action == self.actions.right or self.action == self.actions.left then self.movement = self.action -- self.moure=imp.state_walking self:_moure(imp.state_walking, "state_walking (movement)") elseif self.action == self.actions.jump then - -- self:do_jump() + self:do_jump() elseif self.action == "jumpfwd" then -- self:do_jump(true) elseif self.action == self.actions.shot then diff --git a/data/imp_target.lua b/data/imp_target.lua index f8a88e5..294fbaf 100644 --- a/data/imp_target.lua +++ b/data/imp_target.lua @@ -40,4 +40,11 @@ if DEBUG_FN_NAME then print("free_next_target") end ---- ... ara s'intenta tornar al moviment per patró self:pattern_recovery() +end + +function imp:pattern_next_target() +if not DEBUG_FN_NAME then print("pattern_next_target") end + local next_target = self.hot_points[self.pattern.target] + print(next_target.id) + self.target = next_target end \ No newline at end of file