#============================================================================== # ★ 滑らか歩行+隊列ジャンプ ver1.0 by USK #------------------------------------------------------------------------------ # ・移動ルート等での移動で一マスごと1フレーム止まるのを修正します # ・隊列歩行のままでジャンプしたとき全員がジャンプできるようにします #============================================================================== =begin ・スクリプト導入前に作成済みの移動ルートの動作にタイミングのずれなどの影響が  でる可能性が高いです。 =end #============================================================================== # ■ Game_Character #============================================================================== class Game_Character #-------------------------------------------------------------------------- # ● 移動時の更新 #-------------------------------------------------------------------------- alias :usk_fix_update_move :update_move def update_move usk_fix_update_move fix_route_update end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def fix_route_update if !moving? && (@move_type == 3 || @move_route_forcing) update_routine_move if @move_route_index == 0 update_routine_move end end end end #============================================================================== # ■ Game_Event #============================================================================== class Game_Event #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def fix_route_update super if !moving? && @move_type != 3 && !@move_route_forcing update_self_movement end end end #============================================================================== # ■ Game_Player #============================================================================== class Game_Player #-------------------------------------------------------------------------- # ● 移動時の更新 #-------------------------------------------------------------------------- alias :usk_fix_update_jump :update_jump def update_jump return if followers.jumping? usk_fix_update_jump set_route_history unless jumping? end #-------------------------------------------------------------------------- # ● 歩行/足踏みアニメの更新 #-------------------------------------------------------------------------- alias :usk_fix_update_animation :update_animation def update_animation return if followers.jumping? usk_fix_update_animation end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def route_history @route_history end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def set_route_history @route_history = [[@x, @y]] * ($game_party.max_battle_members) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def fix_route_update super if !moving? && !@move_route_forcing move_by_input end end #-------------------------------------------------------------------------- # ● まっすぐに移動 #-------------------------------------------------------------------------- alias :usk_fix_move_straight :move_straight def move_straight(d, turn_ok = true) return if followers.jumping?(true) if passable?(@x, @y, d) @route_history.pop @route_history.insert(1,[@x, @y]) end usk_fix_move_straight(d, turn_ok) end #-------------------------------------------------------------------------- # ● 指定位置に移動 #-------------------------------------------------------------------------- alias :usk_fix_moveto :moveto def moveto(x, y) @route_history = [[x, y]] * ($game_party.max_battle_members) usk_fix_moveto(x, y) end #-------------------------------------------------------------------------- # ● 斜めに移動 #-------------------------------------------------------------------------- alias :usk_fix_move_diagonal :move_diagonal def move_diagonal(horz, vert) return if followers.jumping?(true) if diagonal_passable?(@x, @y, horz, vert) @route_history.pop @route_history.insert(1,[@x, @y]) end usk_fix_move_diagonal(horz, vert) end #-------------------------------------------------------------------------- # ● ジャンプ #-------------------------------------------------------------------------- alias :usk_fix_jump :jump def jump(x_plus, y_plus) followers.jump(x_plus, y_plus) usk_fix_jump(x_plus, y_plus) end end #============================================================================== # ■ Game_Follower #============================================================================== class Game_Follower #-------------------------------------------------------------------------- # ● 先導キャラクターを追う #-------------------------------------------------------------------------- alias :usk_fix_chase_preceding_character :chase_preceding_character def chase_preceding_character if $game_player.followers.gathering? usk_fix_chase_preceding_character else _x, _y = *($game_player.route_history[@member_index]) sx = distance_x_from(_x) sy = distance_y_from(_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) elsif sy != 0 move_straight(sy > 0 ? 8 : 2) end end end #-------------------------------------------------------------------------- # ● ジャンプ #-------------------------------------------------------------------------- def reserve_jump(x_plus, y_plus) @jump_fiber = Fiber.new do loop do chase_preceding_character break unless moving? while moving? Fiber.yield end end i = @member_index * 8 while i > 0 i -= 1 unless $game_player.followers.jumping? Fiber.yield end jump(x_plus, y_plus) @jump_fiber = nil end end #-------------------------------------------------------------------------- # ● ジャンプ #-------------------------------------------------------------------------- def reserve_jump?(bool = false) @jump_fiber && (bool || moving?) end #-------------------------------------------------------------------------- # ● 停止時の更新 #-------------------------------------------------------------------------- alias :usk_fix_update :update def update usk_fix_update @jump_fiber.resume if @jump_fiber end end #============================================================================== # ■ Game_Followers #============================================================================== class Game_Followers #-------------------------------------------------------------------------- # ● 集合 #-------------------------------------------------------------------------- alias :usk_fix_gather :gather def gather $game_player.set_route_history usk_fix_gather end #-------------------------------------------------------------------------- # ● ジャンプ #-------------------------------------------------------------------------- def jump(x_plus, y_plus) $game_player.set_route_history each do |member| member.reserve_jump(x_plus, y_plus) end end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def jumping?(bool = false) visible_folloers.any? {|follower| follower.reserve_jump?(bool) } end end