# # バトルのリトライ(Ver2.0) #  (C)2005,2007 TYPE74RX-T # # ★ カスタマイズポイント:9~10行目 module RX_T BATTLE_RETRY_COMMAND1 = "もう一度挑戦する" # リトライする場合のコマンド名 BATTLE_RETRY_COMMAND2 = "ギブアップする" # ギブアップする場合のコマンド名 end #============================================================================== # ■ Game_Temp #------------------------------------------------------------------------------ #  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン # スタンスは $game_temp で参照されます。 #============================================================================== class Game_Temp #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias rx_rgssb3_initialize initialize def initialize # メソッドを呼び戻す rx_rgssb3_initialize # ★ バトルのリトライフラグ(デフォルト:ON) @rx_battle_retry = true end #-------------------------------------------------------------------------- # ★ バトルのリトライのフラグ状態 #-------------------------------------------------------------------------- def rx_battle_retry return @rx_battle_retry end #-------------------------------------------------------------------------- # ★ バトルのリトライフラグをオン #-------------------------------------------------------------------------- def rx_battle_retry_on @rx_battle_retry = true end #-------------------------------------------------------------------------- # ★ バトルのリトライのフラグをオフ #-------------------------------------------------------------------------- def rx_battle_retry_off @rx_battle_retry = false end end #============================================================================== # ■ Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_System クラ # スや Game_Event クラスの内部で使用されます。 #============================================================================== class Interpreter #-------------------------------------------------------------------------- # ★ 注釈 #-------------------------------------------------------------------------- alias rx_rgssb3_command_108 command_108 def command_108 # バトルのリトライを可能にする if @parameters[0].include?("バトルリトライON") # バトルのリトライフラグをオン $game_temp.rx_battle_retry_on # 継続(競合対策) return true end # バトルのリトライを不可能にする if @parameters[0].include?("バトルリトライOFF") # バトルのリトライフラグをオフ $game_temp.rx_battle_retry_off # 継続(競合対策) return true end # メソッドを呼び戻す rx_rgssb3_command_108 end end #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- alias rx_rgssb3_main main def main # バトルのリトライフラグがオンなら if $game_temp.rx_battle_retry # 戦闘開始時の状態をファイルに保存 file = File.open("Qsave.rxdata", "wb") write_save_data(file) file.close end # メソッドを呼び戻す rx_rgssb3_main end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias rx_rgssb3_update update def update # ゲームオーバーの場合 if $game_temp.gameover and $game_temp.rx_battle_retry # 戦闘テストの場合 if $BTEST $scene = nil else # リトライ画面に切り替え go_game_over end return end # メソッドを呼び戻す rx_rgssb3_update end #-------------------------------------------------------------------------- # ★ バトルのリトライ用セーブデータの書き込み # file : 書き込み用ファイルオブジェクト (オープン済み) #-------------------------------------------------------------------------- def write_save_data(file) # 各種ゲームオブジェクトを書き込む Marshal.dump($game_switches, file) Marshal.dump($game_variables, file) Marshal.dump($game_self_switches, file) Marshal.dump($game_actors, file) Marshal.dump($game_party, file) Marshal.dump($game_troop, file) end #-------------------------------------------------------------------------- # ★ バトルのリトライ用セーブデータの読み込み # file : 読み込み用ファイルオブジェクト (オープン済み) #-------------------------------------------------------------------------- def read_save_data(file) # 各種ゲームオブジェクトを読み込む $game_switches = Marshal.load(file) $game_variables = Marshal.load(file) $game_self_switches = Marshal.load(file) $game_actors = Marshal.load(file) $game_party = Marshal.load(file) $game_troop = Marshal.load(file) # ゲームオーバー判定を初期化する $game_temp.gameover = false # パーティメンバーをリフレッシュ $game_party.refresh end #-------------------------------------------------------------------------- # ★ バトルのリトライ用メイン処理 #-------------------------------------------------------------------------- def go_game_over # コマンドウィンドウを作成 s1 = RX_T::BATTLE_RETRY_COMMAND1 s2 = RX_T::BATTLE_RETRY_COMMAND2 @g_over_window = Window_Command.new(192, [s1, s2]) @g_over_window.x = 320 - @g_over_window.width / 2 @g_over_window.y = 240 - @g_over_window.height / 2 # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 go_update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # ウィンドウを解放 @g_over_window.dispose end #-------------------------------------------------------------------------- # ★ バトルのリトライ用フレーム更新 #-------------------------------------------------------------------------- def go_update # コマンドウィンドウを更新 @g_over_window.update # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # ゲームオーバー画面へ $scene = Scene_Gameover.new return end # C ボタンが押された場合 if Input.trigger?(Input::C) # コマンドウィンドウのカーソル位置で分岐 case @g_over_window.index when 0 # リトライする command_retry when 1 # ゲームオーバー画面へ $scene = Scene_Gameover.new end return end end #-------------------------------------------------------------------------- # ★ コマンド [もう一度挑戦する] 選択時の処理 #-------------------------------------------------------------------------- def command_retry # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 戦闘開始時の状態をファイルから読み込む file = File.open("Qsave.rxdata", "rb") read_save_data(file) file.close $scene = Scene_Battle.new end end