# 経路探索を使用する USE_SEARCH_ROUTE = true class Game_Event if USE_SEARCH_ROUTE #-------------------------------------------------------------------------- # ● 指定の座標に近づく #-------------------------------------------------------------------------- def move_toward_pos(pos) sx = distance_x_from(pos[0]) sy = distance_y_from(pos[1]) if sx != 0 && sy != 0 move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2) if !@move_succeed && !@event_waiting if sx.abs > sy.abs move_straight(sx > 0 ? 4 : 6) move_straight(sy > 0 ? 8 : 2) if !@move_succeed && !@event_waiting else move_straight(sy > 0 ? 8 : 2) move_straight(sx > 0 ? 4 : 6) if !@move_succeed && !@event_waiting end end move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0 && !@event_waiting elsif sx != 0 move_straight(sx > 0 ? 4 : 6) move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0 && !@event_waiting else#if sy != 0 move_straight(sy > 0 ? 8 : 2) move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0 && !@event_waiting end end #-------------------------------------------------------------------------- # ● キャラクターに近づく #-------------------------------------------------------------------------- def saba_dungeon_move_toward_character(character) if !$game_map.dungeon? sx = distance_x_from(character.x) sy = distance_y_from(character.y) if sx.abs > sy.abs move_straight(sx > 0 ? 4 : 6) move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0 elsif sy != 0 move_straight(sy > 0 ? 8 : 2) move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0 end p rand(256) else sx = distance_x_from(character.x) sy = distance_y_from(character.y) if sx != 0 && sy != 0 move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2) elsif sx != 0 move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sy != 0 && !@event_waiting if @last_pos == [x, y + 1] move_straight(2) elsif @last_pos == [x, y - 1] move_straight(8) else move_straight(sy > 0 ? 8 : 2) end end elsif sy != 0 move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sx != 0 && !@event_waiting if @last_pos == [x - 1, y] move_straight(4) elsif @last_pos == [x + 1, y] move_straight(6) else move_straight(sx > 0 ? 4 : 6) end end end @last_pos = [x, y] if $game_map.room(x, y) == nil end end #-------------------------------------------------------------------------- # ● まっすぐに移動 #-------------------------------------------------------------------------- def move_straight(d, turn_ok = true) super end else # if USE_SEARCH_ROUTE #-------------------------------------------------------------------------- # ● キャラクターに近づく #-------------------------------------------------------------------------- def move_toward_character(character) return super unless $game_map.dungeon? sx = distance_x_from(character.x) sy = distance_y_from(character.y) if sx != 0 && sy != 0 move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2) elsif sx != 0 move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sy != 0 && !@event_waiting if @last_pos == [x, y + 1] move_straight(2) elsif @last_pos == [x, y - 1] move_straight(8) else move_straight(sy > 0 ? 8 : 2) end end elsif sy != 0 move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sx != 0 && !@event_waiting if @last_pos == [x - 1, y] move_straight(4) elsif @last_pos == [x + 1, y] move_straight(6) else move_straight(sx > 0 ? 4 : 6) end end end @last_pos = [x, y] if $game_map.room(x, y) == nil end end # if USE_SEARCH_ROUTE end class Game_Player #-------------------------------------------------------------------------- # ● 方向ボタン入力による移動処理 #-------------------------------------------------------------------------- alias saba_dungeon_move_by_input_2 move_by_input def move_by_input unless $game_map.dungeon? saba_dungeon_move_by_input_2 return end if !movable? || $game_map.interpreter.running? @start_move = false return end if Input.dir8 > 0 return if $game_map.wait_for_event? saba_dungeon_move_by_input_2 @start_move = @move_succeed else @start_move = false end end end