#============================================================================== # ■ フィールド並行戦闘 (VX Ace用) #------------------------------------------------------------------------------ # 製作者 : CanariAlternate # サイト名 : カルトの鳥篭 # サイトURL : http://canarialt.blog.fc2.com #------------------------------------------------------------------------------ # ■ 概要 : マップの処理を停止せずに戦闘を実行する。 # # ■ 必須 : なし # # ■ 位置 : 「Scene_Battle」より下 #------------------------------------------------------------------------------ # 更新履歴 : 2012/12/30 Ver1.00 スクリプトを作成した。 # 2012/12/30 Ver1.01 戦闘中の判定のバグを修正した。 # 2013/01/05 Ver1.02 解放済みのウィンドウを更新しないように変更 # 2013/02/19 Ver1.03 共通処理スクリプトの廃止による変更を施した。 # 2013/08/18 Ver1.04 トランジションのバグを修正した。 # 戦闘背景の不透明度の設定方法を拡張した。 #============================================================================== =begin ■□■仕様・設定に関する内容の箇条書き□■□ 文章の表示などは戦闘終了までウェイトする。戦闘イベントは反映される。 コマンド「バトルの処理」も文章の表示と同様に戦闘終了までウェイトする。 コマンド「メニュー画面を開く」なども戦闘終了までウェイトする。 コマンド「画面の色調変更」などはマップで実行すればマップに反映する。 コマンド「画面の色調変更」などは戦闘イベントで実行すれば戦闘画面に反映する。 =end $imported ||= {} $imported[:CanariAlternate_ParallelBattle] = true #============================================================================== # ■ Calt #------------------------------------------------------------------------------ #  CanariAlternateが製作したスクリプト用のモジュールです。 #============================================================================== module Calt #---------------------------------------------------------------------------- # ◆開始時のトランジションと終了時のフェードアウトを有効にするスイッチの番号 TRANSITION_SWITCH = 0 # 0 だと常に無効化 # # ◆戦闘背景(床)の不透明度(負の値に設定すると変数を参照するようになる) # 例 BACK1_OPACITY = -5 # 不透明度を5番の変数で設定 # 例 BACK1_OPACITY = 160 # 不透明度を直接設定 BACK1_OPACITY = 160 # 0 ~ 255 または -変数の番号 # # ◆戦闘背景(壁)の不透明度(負の値に設定すると変数を参照するようになる) # 例 BACK2_OPACITY = -6 # 不透明度を6番の変数で設定 # 例 BACK2_OPACITY = 0 # 不透明度を直接設定 BACK2_OPACITY = 0 # 0 ~ 255 または -変数の番号 #---------------------------------------------------------------------------- end #============================================================================== # ■ Game_Player #------------------------------------------------------------------------------ #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。 #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # ● 移動可能判定 [追加] #-------------------------------------------------------------------------- alias movable_ParallelBattle? movable? def movable? return false if SceneManager.scene_is?(Scene_Battle) # 戦闘中は操作不可 return movable_ParallelBattle? end end #============================================================================== # ■ Game_Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、 # Game_Troop クラス、Game_Event クラスの内部で使用されます。 #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● 画面系コマンドの対象を取得 [◆再定義] #-------------------------------------------------------------------------- def screen battle_event? ? $game_troop.screen : $game_map.screen end #-------------------------------------------------------------------------- # ● キャラクターの取得 [◆再定義] #-------------------------------------------------------------------------- def get_character(param) if $BTEST nil elsif param < 0 $game_player else events = same_map? ? $game_map.events : {} events[param > 0 ? param : @event_id] end end #-------------------------------------------------------------------------- # ● メッセージ表示がビジー状態の間ウェイト [◆再定義] #-------------------------------------------------------------------------- def wait_for_message Fiber.yield while $game_message.busy? || $in_battle_running_map end #-------------------------------------------------------------------------- # ● 自身が戦闘のイベントか判定 [新規] #-------------------------------------------------------------------------- def battle_event? return $game_party.in_battle && !$in_battle_running_map end #-------------------------------------------------------------------------- # ● マップのイベント限定で戦闘中はウェイト [新規] #-------------------------------------------------------------------------- def wait_for_battle Fiber.yield while $game_party.in_battle || $in_battle_running_map end #-------------------------------------------------------------------------- # ● 場所移動 [◆再定義] #-------------------------------------------------------------------------- def command_201 return if $BTEST Fiber.yield while $game_player.transfer? || $game_message.visible if @params[0] == 0 # 直接指定 map_id = @params[1] x = @params[2] y = @params[3] else # 変数で指定 map_id = $game_variables[@params[1]] x = $game_variables[@params[2]] y = $game_variables[@params[3]] end $game_player.reserve_transfer(map_id, x, y, @params[4]) $game_temp.fade_type = @params[5] Fiber.yield while $game_player.transfer? end #-------------------------------------------------------------------------- # ● マップのスクロール [◆再定義] #-------------------------------------------------------------------------- def command_204 return if $BTEST Fiber.yield while $game_map.scrolling? $game_map.start_scroll(@params[0], @params[1], @params[2]) end #-------------------------------------------------------------------------- # ● 隊列メンバーの集合 [◆再定義] #-------------------------------------------------------------------------- def command_217 return if $BTEST $game_player.followers.gather Fiber.yield until $game_player.followers.gather? end #-------------------------------------------------------------------------- # ● 天候の設定 [◆再定義] #-------------------------------------------------------------------------- def command_236 return if $BTEST $game_map.screen.change_weather(@params[0], @params[1], @params[2]) wait(@params[2]) if @params[3] end #-------------------------------------------------------------------------- # ● バトルの処理 [◆再定義] #-------------------------------------------------------------------------- def command_301 return if battle_event? wait_for_battle # 戦闘終了まで待機 if @params[0] == 0 # 直接指定 troop_id = @params[1] elsif @params[0] == 1 # 変数で指定 troop_id = $game_variables[@params[1]] else # マップ指定の敵グループ troop_id = $game_player.make_encounter_troop_id end if $data_troops[troop_id] BattleManager.setup(troop_id, @params[2], @params[3]) BattleManager.event_proc = Proc.new {|n| @branch[@indent] = n } $game_player.make_encounter_count SceneManager.call(Scene_Battle) end Fiber.yield wait_for_battle # 戦闘終了まで待機 end #-------------------------------------------------------------------------- # ● ショップの処理 #-------------------------------------------------------------------------- def command_302 return if battle_event? wait_for_battle # 戦闘終了まで待機 goods = [@params] while next_event_code == 605 @index += 1 goods.push(@list[@index].parameters) end SceneManager.call(Scene_Shop) SceneManager.scene.prepare(goods, @params[4]) Fiber.yield end #-------------------------------------------------------------------------- # ● 名前入力の処理 #-------------------------------------------------------------------------- def command_303 return if battle_event? wait_for_battle # 戦闘終了まで待機 if $data_actors[@params[0]] SceneManager.call(Scene_Name) SceneManager.scene.prepare(@params[0], @params[1]) Fiber.yield end end #-------------------------------------------------------------------------- # ● メニュー画面を開く #-------------------------------------------------------------------------- def command_351 return if battle_event? wait_for_battle # 戦闘終了まで待機 SceneManager.call(Scene_Menu) Window_MenuCommand::init_command_position Fiber.yield end #-------------------------------------------------------------------------- # ● セーブ画面を開く #-------------------------------------------------------------------------- def command_352 return if battle_event? wait_for_battle # 戦闘終了まで待機 SceneManager.call(Scene_Save) Fiber.yield end end #============================================================================== # ■ Spriteset_Battle #------------------------------------------------------------------------------ #  バトル画面のスプライトをまとめたクラスです。このクラスは Scene_Battle クラ # スの内部で使用されます。 #============================================================================== class Spriteset_Battle #-------------------------------------------------------------------------- # ● 戦闘背景(床)スプライトの作成 [追加] #-------------------------------------------------------------------------- alias create_battleback1_ParallelBattle create_battleback1 def create_battleback1 create_battleback1_ParallelBattle return if $BTEST if Calt::BACK1_OPACITY >= 0 @back1_sprite.opacity = Calt::BACK1_OPACITY else @back1_sprite.opacity = $game_variables[-Calt::BACK1_OPACITY] end end #-------------------------------------------------------------------------- # ● 戦闘背景(壁)スプライトの作成 [追加] #-------------------------------------------------------------------------- alias create_battleback2_ParallelBattle create_battleback2 def create_battleback2 create_battleback2_ParallelBattle return if $BTEST if Calt::BACK2_OPACITY >= 0 @back2_sprite.opacity = Calt::BACK2_OPACITY else @back2_sprite.opacity = $game_variables[-Calt::BACK2_OPACITY] end end end #============================================================================== # ■ Scene_Map #------------------------------------------------------------------------------ #  マップ画面の処理を行うクラスです。 #============================================================================== class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 [新規] #------------------------------------------------------------------------- def initialize $in_battle_running_map = false @battle_calling = false end #-------------------------------------------------------------------------- # ● 開始処理 [◆再定義] #-------------------------------------------------------------------------- alias start_ParallelBattle start def start if @battle_calling @battle_calling = false # 戦闘モードを解除 create_message_window create_scroll_text_window return end start_ParallelBattle end #-------------------------------------------------------------------------- # ● 終了処理 [◆再定義] #-------------------------------------------------------------------------- def terminate Graphics.freeze if @battle_calling @message_window.dispose @scroll_text_window.dispose else dispose_all_windows dispose_main_viewport end SceneManager.snapshot_for_background dispose_spriteset unless @battle_calling # 戦闘モードの場合は解放処理は行わない # perform_battle_transition if SceneManager.scene_is?(Scene_Battle) end #-------------------------------------------------------------------------- # ● フレーム更新(戦闘中) [新規] #-------------------------------------------------------------------------- def update_battle instance_variables.each do |varname| ivar = instance_variable_get(varname) ivar.update if ivar.is_a?(Window) && !ivar.disposed? && !ivar.is_a?(Window_Message) && !ivar.is_a?(Window_ScrollText) end $game_map.update(true) $game_player.update @spriteset.update update_transfer_player end #-------------------------------------------------------------------------- # ● バトル画面遷移の前処理 [◆再定義] #-------------------------------------------------------------------------- def pre_battle_scene Graphics.update Graphics.freeze @battle_calling = true # 戦闘モードに移行 SceneManager.scene.parent_scene = self # 戦闘シーンに自身をセット # @spriteset.dispose_characters BattleManager.save_bgm_and_bgs BattleManager.play_battle_bgm Sound.play_battle_start end #-------------------------------------------------------------------------- # ● 戦闘中の解放処理 [新規] #-------------------------------------------------------------------------- def dispose_battle dispose_all_windows dispose_main_viewport dispose_spriteset end end #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :parent_scene #-------------------------------------------------------------------------- # ● オブジェクト初期化 [新規] #------------------------------------------------------------------------- def initialize $in_battle_running_map = false @parent_scene = nil end #-------------------------------------------------------------------------- # ● トランジション実行 [◆再定義] #-------------------------------------------------------------------------- alias perform_transition_ParallelBattle perform_transition def perform_transition if @parent_scene && $game_switches[Calt::TRANSITION_SWITCH] @parent_scene.perform_battle_transition Graphics.transition(0) # Graphics.transition(60, "Graphics/System/BattleStart", 100) else perform_transition_ParallelBattle end end #-------------------------------------------------------------------------- # ● 終了前処理 [◆再定義] #-------------------------------------------------------------------------- def pre_terminate super Graphics.fadeout(30) if SceneManager.scene_is?(Scene_Map) && $game_switches[Calt::TRANSITION_SWITCH] Graphics.fadeout(60) if SceneManager.scene_is?(Scene_Title) end #-------------------------------------------------------------------------- # ● 終了処理 [追加] #-------------------------------------------------------------------------- alias terminate_ParallelBattle terminate def terminate terminate_ParallelBattle if @parent_scene && (SceneManager.scene_is?(Scene_Title) || SceneManager.scene_is?(Scene_Gameover)) @parent_scene.dispose_battle # マップのスプライトなどを解放 end end #-------------------------------------------------------------------------- # ● フレーム更新(基本)[◆再定義] #-------------------------------------------------------------------------- def update_basic super update_map if @parent_scene # 戦闘中のマップ更新 $game_timer.update $game_troop.update @spriteset.update update_info_viewport update_message_open end #-------------------------------------------------------------------------- # ● 戦闘中のマップ更新 [新規] #-------------------------------------------------------------------------- def update_map $in_battle_running_map = true @parent_scene.update_battle $in_battle_running_map = false end end