# # 逃走時にバトルイベント発動 #  (C)2007 TYPE74RX-T # #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- alias rx_rgsss15_main main def main # ★ 初期設定 @rx_runaway_judge = [] @rx_runaway_judge[0] = false # 逃走フラグ @rx_runaway_judge[1] = true # 逃走失敗フラグ # メソッドを呼び戻す rx_rgsss15_main end #-------------------------------------------------------------------------- # ● バトル終了 # result : 結果 (0:勝利 1:敗北 2:逃走) #-------------------------------------------------------------------------- alias rx_rgsss15_battle_end battle_end def battle_end(result) # ★ 逃走成功(または敗北)の時に逃走フラグが立っていたら # 処理:逃走用のイベントを発生させるためにバトル終了を一時阻止 if result = 1 and @rx_runaway_judge[0] # 逃走失敗フラグをオフに @rx_runaway_judge[1] = false # パーティ全員のアクションをクリア $game_party.clear_actions # メインフェーズ開始 start_phase4 return end # メソッドを呼び戻す rx_rgsss15_battle_end(result) end #-------------------------------------------------------------------------- # ● バトルイベントのセットアップ #-------------------------------------------------------------------------- alias rx_rgsss15_setup_battle_event setup_battle_event def setup_battle_event # 変数の初期化 rx_next = false # ★ 逃走フラグがオン、かつターン数が 1 以上の時 # 処理:逃走フラグが立っていれば逃走行為用イベントを発動させる if @rx_runaway_judge[0] and $game_temp.battle_turn > 0 # バトルイベント実行中の場合 if $game_system.battle_interpreter.running? return end # バトルイベントの全ページを検索 for index in 0...$data_troops[@troop_id].pages.size # イベントページを取得 page = $data_troops[@troop_id].pages[index] # イベント条件を c で参照可能に c = page.condition # 何か条件が指定されていれば次のページへ if c.turn_valid or c.enemy_valid or c.actor_valid or c.switch_valid next end # 逃走に失敗していれば次のページへ unless rx_next if @rx_runaway_judge[1] rx_next = true next end end # 実行済みの場合は逃走行為用イベントを終了させる if $game_temp.battle_event_flags[index] return end # イベントをセットアップ $game_system.battle_interpreter.setup(page.list, 0) # このページのスパンが [バトル] か [ターン] の場合 if page.span <= 1 # 実行済みフラグをセット $game_temp.battle_event_flags[index] = true end return end end # メソッドを呼び戻す rx_rgsss15_setup_battle_event end #-------------------------------------------------------------------------- # ● フレーム更新 (パーティコマンドフェーズ : 逃げる) #-------------------------------------------------------------------------- alias rx_rgsss15_update_phase2_escape update_phase2_escape def update_phase2_escape # ★ 逃走フラグをオンに @rx_runaway_judge[0] = true # メソッドを呼び戻す rx_rgsss15_update_phase2_escape end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ) #-------------------------------------------------------------------------- alias rx_rgsss15_update_phase4 update_phase4 def update_phase4 # ★ 逃走フラグがオン、メインフェーズのステップが2以上で #   逃走失敗フラグがオフの場合 # 処理:逃走行為に成功した場合、イベントを発生させてからバトルを終わらせる if @rx_runaway_judge[0] and @phase4_step > 1 and not @rx_runaway_judge[1] # 逃走フラグをオフに @rx_runaway_judge[0] = false # バトル終了 battle_end(1) end # ★ メインフェーズのステップが2以上で #   逃走フラグ、逃走失敗フラグが共にオンの場合 # 処理:逃走失敗による全滅、またはバトル中断を正常に行わせる if @rx_runaway_judge[0] and @rx_runaway_judge[1] and @phase4_step > 1 # 逃走フラグをオフに @rx_runaway_judge[0] = false end # メソッドを呼び戻す rx_rgsss15_update_phase4 end end