#============================================================================== # ★ リージョンジャンプ ver1.0 by USK #------------------------------------------------------------------------------ # ・指定したリージョンを通ろうとすると自動的にジャンプでリージョンを飛び越えます。 #============================================================================== =begin 17行目のMaxJumpValueIdに指定した番号の変数がプレイヤーのジャンプ力となります。 18行目からのJumpRegionでジャンプできるリージョンを設定できます。 ジャンプ力の分だけ連続したリージョンを飛び越えることができます。 =end #============================================================================== # ■ Game_Character #============================================================================== class Game_Character MaxJumpValueId = 2 #最大ジャンプ距離を代入する変数番号 EventMaxJump = 10 #イベントの最大ジャンプ距離 JumpRegion = { :player => 7, #リージョンジャンプに使うリージョン番号(プレイヤーのみ可) :event => 6, #リージョンジャンプに使うリージョン番号(イベントのみ可) :all => 8, #リージョンジャンプに使うリージョン番号(どちらもジャンプ可) } #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- alias usk_region_jump_move_straight move_straight def move_straight(d, turn_ok = true) if maxjump > 0 && jump_region.include?(forward_region(d)) region_jump(d, turn_ok) else reset_jxy usk_region_jump_move_straight(d, turn_ok) end end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def jump_region [] end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def maxjump 0 end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def region_jump(d = direction, turn_ok = true) return if maxjump < 1 ax = ay = r = 0 while jump_region.include?(forward_region(d, @x + ax, @y + ay)) r += 1 ax = [0, 0, 0, 0, -r, 0, r, 0, 0, 0][d] ay = [0, 0, r, 0, 0, 0, 0, 0, -r, 0][d] end r = [r, maxjump].min + 1 ax = [0, 0, 0, 0, -r, 0, r, 0, 0, 0][d] ay = [0, 0, r, 0, 0, 0, 0, 0, -r, 0][d] if jump_passable?(x + ax, y + ay, d) jump(ax, ay) elsif turn_ok set_direction(d) check_event_trigger_touch_front end end #-------------------------------------------------------------------------- # ● ジャンプ #-------------------------------------------------------------------------- alias usk_region_jump_jump jump def jump(x_plus, y_plus) @jx = @x @jy = @y usk_region_jump_jump(x_plus, y_plus) end #-------------------------------------------------------------------------- # ● 通行可能判定 #-------------------------------------------------------------------------- def jump_passable?(x, y, d) x2 = $game_map.round_x_with_direction(x, d) y2 = $game_map.round_y_with_direction(y, d) return false unless $game_map.valid?(x2, y2) return true if @through || debug_through? return false unless map_passable?(x, y, d) return false unless map_passable?(x2, y2, reverse_dir(d)) return false if collide_with_characters?(x2, y2) return false if collide_with_characters?(x, y) return true end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def jx @jx || -1 end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def jy @jy || -1 end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def reset_jxy @jx = @jy = -1 end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def forward_region(d, x = self.x, y = self.y) x += [0, 0, 0, 0, -1, 0, 1, 0, 0, 0][d] y += [0, 0, 1, 0, 0, 0, 0, 0, -1, 0][d] $game_map.region_id(x, y) end #-------------------------------------------------------------------------- # ● 斜めに移動 #-------------------------------------------------------------------------- alias usk_region_jump_move_diagonal move_diagonal def move_diagonal(horz, vert) reset_jxy usk_region_jump_move_diagonal(horz, vert) end end #============================================================================== # ■ Game_Player #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def maxjump $game_variables[MaxJumpValueId] end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def jump_region @jump_region ||= [JumpRegion[:all], JumpRegion[:player]] end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def reset_jxy super unless @followers.jumping? end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def pre_x @x end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def pre_y @y end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def party_jumping? jumping? && @followers.jumping? end #-------------------------------------------------------------------------- # ● ジャンプ時の更新 #-------------------------------------------------------------------------- def update_jump super @followers.move end end #============================================================================== # ■ Game_Follower #============================================================================== class Game_Follower < Game_Character #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias usk_region_jump_update update def update usk_region_jump_update chase_preceding_character if @preceding_character.jumping? end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def pre_x @preceding_character.x end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def pre_y @preceding_character.y end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def jump_region $game_player.jump_region end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def maxjump $game_player.maxjump end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def reset_jxy super unless $game_player.party_jumping? end #-------------------------------------------------------------------------- # ● 斜めに移動 #-------------------------------------------------------------------------- alias usk_region_jump_move_diagonal_f move_diagonal def move_diagonal(horz, vert) if @preceding_character.jx > -1 && @preceding_character.jy > -1 x = @preceding_character.jx - @x y = @preceding_character.jy - @y if x == 0 && y == 0 x = @preceding_character.pre_x - @x y = @preceding_character.pre_y - @y end jump(x, y) if x >= 0 || y >= 0 else usk_region_jump_move_diagonal_f(horz, vert) end end end #============================================================================== # ■ Game_Event #============================================================================== class Game_Event < Game_Character #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def jump_region @jump_region ||= [JumpRegion[:all], JumpRegion[:event]] end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def maxjump EventMaxJump end end #============================================================================== # ■ Game_Followers #============================================================================== class Game_Followers #-------------------------------------------------------------------------- # ● イテレータ #-------------------------------------------------------------------------- def jumping? @data.any? {|follower| follower.jumping? } end end