# # マップループ処理スクリプト Ver 1.05 #  Copyright 2005,2007 TYPE74RX-T # #============================================================================== # ★ 定数設定 #------------------------------------------------------------------------------ #  設定値は、あくまでこのサンプルのために設定した数値です。 # 状況に応じて、定数はユーザーで設定して下さい。 #============================================================================== # ★ マップループフラグ情報をゲーム変数の何番に格納するか設定 RX_T_MAP_LOOP_NUMBER = 1 #============================================================================== # ■ Game_Character #------------------------------------------------------------------------------ #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event # クラスのスーパークラスとして使用されます。 #============================================================================== class Game_Character #-------------------------------------------------------------------------- # ● 移動タイプ : カスタム #-------------------------------------------------------------------------- def move_type_custom # 停止中でなければ中断 if jumping? or moving? return end # 移動コマンドのリストの最後に到達するまでループ while @move_route_index < @move_route.list.size # 移動コマンドを取得 command = @move_route.list[@move_route_index] # コマンドコード 0 番 (リストの最後) の場合 if command.code == 0 # オプション [動作を繰り返す] が ON の場合 if @move_route.repeat # 移動ルートのインデックスを最初に戻す @move_route_index = 0 end # オプション [動作を繰り返す] が OFF の場合 unless @move_route.repeat # 移動ルート強制中の場合 if @move_route_forcing and not @move_route.repeat # 移動ルートの強制を解除 @move_route_forcing = false # オリジナルの移動ルートを復帰 @move_route = @original_move_route @move_route_index = @original_move_route_index @original_move_route = nil end # 停止カウントをクリア @stop_count = 0 end return end # 移動系コマンド (下に移動~ジャンプ) の場合 if command.code <= 14 # コマンドコードで分岐 case command.code when 1 # 下に移動 @moveway = 2 move_down when 2 # 左に移動 @moveway = 4 move_left when 3 # 右に移動 @moveway = 6 move_right when 4 # 上に移動 @moveway = 8 move_up when 5 # 左下に移動 @moveway = 1 move_lower_left when 6 # 右下に移動 @moveway = 3 move_lower_right when 7 # 左上に移動 @moveway = 7 move_upper_left when 8 # 右上に移動 @moveway = 9 move_upper_right when 9 # ランダムに移動 move_random when 10 # プレイヤーに近づく move_toward_player when 11 # プレイヤーから遠ざかる move_away_from_player when 12 # 一歩前進 move_forward when 13 # 一歩後退 move_backward when 14 # ジャンプ jump(command.parameters[0], command.parameters[1]) end # オプション [移動できない場合は無視] が OFF で、移動失敗の場合 if not @move_route.skippable and not moving? and not jumping? return end @move_route_index += 1 return end # ウェイトの場合 if command.code == 15 # ウェイトカウントを設定 @wait_count = command.parameters[0] * 2 - 1 @move_route_index += 1 return end # 向き変更系のコマンドの場合 if command.code >= 16 and command.code <= 26 # コマンドコードで分岐 case command.code when 16 # 下を向く turn_down when 17 # 左を向く turn_left when 18 # 右を向く turn_right when 19 # 上を向く turn_up when 20 # 右に 90 度回転 turn_right_90 when 21 # 左に 90 度回転 turn_left_90 when 22 # 180 度回転 turn_180 when 23 # 右か左に 90 度回転 turn_right_or_left_90 when 24 # ランダムに方向転換 turn_random when 25 # プレイヤーの方を向く turn_toward_player when 26 # プレイヤーの逆を向く turn_away_from_player end @move_route_index += 1 return end # その他のコマンドの場合 if command.code >= 27 # コマンドコードで分岐 case command.code when 27 # スイッチ ON $game_switches[command.parameters[0]] = true $game_map.need_refresh = true when 28 # スイッチ OFF $game_switches[command.parameters[0]] = false $game_map.need_refresh = true when 29 # 移動速度の変更 @move_speed = command.parameters[0] when 30 # 移動頻度の変更 @move_frequency = command.parameters[0] when 31 # 移動時アニメ ON @walk_anime = true when 32 # 移動時アニメ OFF @walk_anime = false when 33 # 停止時アニメ ON @step_anime = true when 34 # 停止時アニメ OFF @step_anime = false when 35 # 向き固定 ON @direction_fix = true when 36 # 向き固定 OFF @direction_fix = false when 37 # すり抜け ON @through = true when 38 # すり抜け OFF @through = false when 39 # 最前面に表示 ON @always_on_top = true when 40 # 最前面に表示 OFF @always_on_top = false when 41 # グラフィック変更 @tile_id = 0 @character_name = command.parameters[0] @character_hue = command.parameters[1] if @original_direction != command.parameters[2] @direction = command.parameters[2] @original_direction = @direction @prelock_direction = 0 end if @original_pattern != command.parameters[3] @pattern = command.parameters[3] @original_pattern = @pattern end when 42 # 不透明度の変更 @opacity = command.parameters[0] when 43 # 合成方法の変更 @blend_type = command.parameters[0] when 44 # SE の演奏 $game_system.se_play(command.parameters[0]) when 45 # スクリプト result = eval(command.parameters[0]) end @move_route_index += 1 end end end end #============================================================================== # ■ Game_Player #------------------------------------------------------------------------------ #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。 #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # ● 通行可能判定 # x : X 座標 # y : Y 座標 # d : 方向 (0,2,4,6,8) ※ 0 = 全方向通行不可の場合を判定 (ジャンプ用) #-------------------------------------------------------------------------- def passable?(x, y, d) # 新しい座標を求める new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0) new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0) # ★マップループ用のスイッチがONの時 if $game_switches[RX_T_MAP_LOOP_NUMBER] == true # ★マップループ処理 chkwidth = $game_map.width chkwidth -= 10 chkheight = $game_map.height chkheight -= 10 case @moveway when 1 if new_x <= 9 new_x = chkwidth - 1 moveto(new_x,new_y) end if new_y >= chkheight new_y = 10 moveto(new_x,new_y) end when 2 if new_y >= chkheight new_y = 10 moveto(new_x,new_y) end when 3 if new_x >= chkwidth new_x = 10 moveto(new_x,new_y) end if new_y >= chkheight new_y = 10 moveto(new_x,new_y) end when 4 if new_x <= 9 new_x = chkwidth - 1 moveto(new_x,new_y) end when 6 if new_x >= chkwidth new_x = 10 moveto(new_x,new_y) end when 7 if new_x <= 9 new_x = chkwidth - 1 moveto(new_x,new_y) end if new_y <= 9 new_y = chkheight - 1 moveto(new_x,new_y) end when 8 if new_y <= 9 new_y = chkheight - 1 moveto(new_x,new_y) end when 9 if new_x >= chkwidth new_x = 10 moveto(new_x,new_y) end if new_y <= 9 new_y = chkheight - 1 moveto(new_x,new_y) end end else # 座標がマップ外の場合 unless $game_map.valid?(new_x, new_y) # 通行不可 return false end end # デバッグモードが ON かつ CTRL キーが押されている場合 if $DEBUG and Input.press?(Input::CTRL) # 通行可 return true end super end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ローカル変数に移動中かどうかを記憶 last_moving = moving? # 移動中、イベント実行中、移動ルート強制中、 # メッセージウィンドウ表示中のいずれでもない場合 unless moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing # 方向ボタンが押されていれば、その方向へプレイヤーを移動 # ★方向情報も取得(@moveway) case Input.dir4 when 2 @moveway = 2 move_down when 4 @moveway = 4 move_left when 6 @moveway = 6 move_right when 8 @moveway = 8 move_up end end # ローカル変数に座標を記憶 last_real_x = @real_x last_real_y = @real_y super # キャラクターが下に移動し、かつ画面上の位置が中央より下の場合 if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y # マップを下にスクロール $game_map.scroll_down(@real_y - last_real_y) end # キャラクターが左に移動し、かつ画面上の位置が中央より左の場合 if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X # マップを左にスクロール $game_map.scroll_left(last_real_x - @real_x) end # キャラクターが右に移動し、かつ画面上の位置が中央より右の場合 if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X # マップを右にスクロール $game_map.scroll_right(@real_x - last_real_x) end # キャラクターが上に移動し、かつ画面上の位置が中央より上の場合 if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y # マップを上にスクロール $game_map.scroll_up(last_real_y - @real_y) end # 移動中ではない場合 unless moving? # 前回プレイヤーが移動中だった場合 if last_moving # 同位置のイベントとの接触によるイベント起動判定 result = check_event_trigger_here([1,2]) # 起動したイベントがない場合 if result == false # デバッグモードが ON かつ CTRL キーが押されている場合を除き unless $DEBUG and Input.press?(Input::CTRL) # エンカウント カウントダウン if @encounter_count > 0 @encounter_count -= 1 end end end end # C ボタンが押された場合 if Input.trigger?(Input::C) # 同位置および正面のイベント起動判定 check_event_trigger_here([0]) check_event_trigger_there([0,1,2]) end end end end