#=========================================================================== # ◆ A1 Scripts ◆ # 戦闘BGM制御(RGSS3) # # バージョン : 1.00 (2012/01/03) # 作者 : A1 # URL     : http://a1tktk.web.fc2.com/ #--------------------------------------------------------------------------- # 機能: # ・戦闘BGMを無効化し、戦闘前のBGMを引き継ぎます # ・戦闘から戻っても勝利MEを演奏終了まで勝利MEを演奏します # ・戦闘から戻る時、勝利MEをフェードアウトさせます # ・戦闘終了後に演奏するBGM/BGSを指定します # ・戦闘終了後に演奏するBGM/BGSをフェードインさせます #--------------------------------------------------------------------------- # 更新履歴   :2012/01/03 Ver1.00 リリース #--------------------------------------------------------------------------- # 設置場所 #  A1共通スクリプトより下 # (Audioフェードインより下) # # 必要スクリプト # A1共通スクリプトVer3.50以上 #--------------------------------------------------------------------------- # 使い方 # イベントコマンド「注釈」に記述 # # 戦闘BGM無効 on|off # onにすると戦闘BGMが無効化され、戦闘前のBGMを引き継ぎます # # 戦闘後BGM name,volume,pitch # 戦闘後BGS name,volume,pitch # name のBGM/BGSを ボリューム volume ピッチ pitch で演奏します # # 例:戦闘後BGM Field3,100,100 # 戦闘終了後 Field3 を ボリューム 100 ピッチ 100 で演奏します # # 例:戦闘後BGM ,100,100 # 戦闘終了後 無音になります # # 勝利ME継続 on|off # on にするとマップに戻っても勝利MEが終わるまで演奏し続けます # # 勝利MEフェードアウト時間 time # # 勝利MEのフェードアウト時間をミリ秒(1000ミリ秒 = 1秒)で指定します # 0 にするとフェードアウト機能を使用しません # 0以上にすると、勝利ME継続が on になります # # 以下「Audioフェードイン」スクリプトが必要 # # 戦闘後BGMフェードイン時間 time # # 戦闘後BGMのフェードイン時間をミリ秒(1000ミリ秒 = 1秒)で指定します # 0 にするとフェードイン機能を使用しません # # 戦闘後BGSフェードイン時間 time # # 戦闘後BGSのフェードイン時間をミリ秒(1000ミリ秒 = 1秒)で指定します # 0 にするとフェードイン機能を使用しません #--------------------------------------------------------------------------- # 補足 # 戦闘後BGM/BGS 以外はセーブファイルに保存されます # 一度設定したら再度同じ設定をする必要はありません #============================================================================== $imported ||= {} $imported["A1_BattleAudio"] = true if $imported["A1_Common_Script"] old_common_script("戦闘BGM制御", "3.50") if common_version < 3.50 #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ★ 終了処理 #-------------------------------------------------------------------------- def terminate super dispose_spriteset @info_viewport.dispose victory_me_end end #-------------------------------------------------------------------------- # ○ 勝利MEの終了 #-------------------------------------------------------------------------- def victory_me_end return RPG::ME.stop unless $game_system.continue_victory_me return if $game_system.victory_me_fadeout_time == 0 RPG::ME.fade($game_system.victory_me_fadeout_time) end end #============================================================================== # ■ Game_System #------------------------------------------------------------------------------ #  システム周りのデータを扱うクラスです。セーブやメニューの禁止状態などを保存 # します。このクラスのインスタンスは $game_system で参照されます。 #============================================================================== class Game_System #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :disable_battle_bgm attr_accessor :continue_victory_me attr_accessor :victory_me_fadeout_time attr_accessor :after_battle_bgm_fadein_time attr_accessor :after_battle_bgs_fadein_time #-------------------------------------------------------------------------- # ☆ オブジェクト初期化 #-------------------------------------------------------------------------- alias a1_enable_battle_bgm_initialize initialize def initialize a1_enable_battle_bgm_initialize @disable_battle_bgm = false @continue_victory_me = false @victory_me_fadeout_time = false @after_battle_bgm_fadein_time = 0 @after_battle_bgs_fadein_time = 0 end #-------------------------------------------------------------------------- # ○ 勝利MEフェードアウト時間 #-------------------------------------------------------------------------- def victory_me_fadeout_time @victory_me_fadeout_time ||= 0 return @victory_me_fadeout_time end #-------------------------------------------------------------------------- # ○ 戦闘後BGMフェードイン時間 #-------------------------------------------------------------------------- def after_battle_bgm_fadein_time @after_battle_bgm_fadein_time ||= 0 return @after_battle_bgm_fadein_time end #-------------------------------------------------------------------------- # ○ 戦闘後BGSフェードイン時間 #-------------------------------------------------------------------------- def after_battle_bgs_fadein_time @after_battle_bgs_fadein_time ||= 0 return @after_battle_bgs_fadein_time end end #============================================================================== # ■ Game_Temp #------------------------------------------------------------------------------ #  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン # スタンスは $game_temp で参照されます。 #============================================================================== class Game_Temp #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :after_battle_bgm attr_accessor :after_battle_bgs #-------------------------------------------------------------------------- # ☆ オブジェクト初期化 #-------------------------------------------------------------------------- alias a1_enable_battle_bgm_gt_initialize initialize def initialize a1_enable_battle_bgm_gt_initialize init_after_battle_audio end #-------------------------------------------------------------------------- # ○ 戦闘後Audioの初期化 #-------------------------------------------------------------------------- def init_after_battle_audio @after_battle_bgm = nil @after_battle_bgs = nil end end #============================================================================== # ■ BattleManager #------------------------------------------------------------------------------ #  戦闘の進行を管理するモジュールです。 #============================================================================== module BattleManager #-------------------------------------------------------------------------- # ○ エイリアス用特異メソッド #-------------------------------------------------------------------------- class << self alias :a1_enable_battle_bgm_play_battle_bgm :play_battle_bgm alias :a1_enable_battle_bgm_play_battle_end_me :play_battle_end_me alias :a1_enable_battle_save_bgm_and_bgs :save_bgm_and_bgs alias :a1_enable_battle_replay_bgm_and_bgs :replay_bgm_and_bgs end #-------------------------------------------------------------------------- # ☆ BGM と BGS の保存 #-------------------------------------------------------------------------- def self.save_bgm_and_bgs a1_enable_battle_save_bgm_and_bgs @map_bgm = $game_temp.after_battle_bgm if $game_temp.after_battle_bgm @map_bgs = $game_temp.after_battle_bgs if $game_temp.after_battle_bgs return unless $imported["A1_AudioFadeIn"] setup_after_battle_bgm_fadein if $game_system.after_battle_bgm_fadein_time > 0 setup_after_battle_bgs_fadein if $game_system.after_battle_bgs_fadein_time > 0 end #-------------------------------------------------------------------------- # ○ 戦闘後BGMのフェードインのセットアップ #-------------------------------------------------------------------------- def self.setup_after_battle_bgm_fadein return if $game_system.disable_battle_bgm @org_bgm_volume = @map_bgm.volume @map_bgm.volume = 0 end #-------------------------------------------------------------------------- # ○ 戦闘後BGSのフェードインのセットアップ #-------------------------------------------------------------------------- def self.setup_after_battle_bgs_fadein @org_bgs_volume = @map_bgs.volume @map_bgs.volume = 0 end #-------------------------------------------------------------------------- # ☆ 戦闘 BGM の演奏 #-------------------------------------------------------------------------- def self.play_battle_bgm return if $game_system.disable_battle_bgm a1_enable_battle_bgm_play_battle_bgm end #-------------------------------------------------------------------------- # ☆ BGM と BGS の再開 #-------------------------------------------------------------------------- def self.replay_bgm_and_bgs a1_enable_battle_replay_bgm_and_bgs $game_temp.init_after_battle_audio return unless $imported["A1_AudioFadeIn"] after_battle_bgm_fadein if $game_system.after_battle_bgm_fadein_time > 0 after_battle_bgs_fadein if $game_system.after_battle_bgs_fadein_time > 0 end #-------------------------------------------------------------------------- # ○ 戦闘後BGMのフェードイン開始 #-------------------------------------------------------------------------- def self.after_battle_bgm_fadein return if @map_bgm.name.empty? || $game_system.disable_battle_bgm audio_class = A1_System::AudioFile.new(@map_bgm, @org_bgm_volume, $game_system.after_battle_bgm_fadein_time) $a1_common.fadein_bgm = audio_class end #-------------------------------------------------------------------------- # ○ 戦闘後BGSのフェードイン開始 #-------------------------------------------------------------------------- def self.after_battle_bgs_fadein return if @map_bgs.name.empty? audio_class = A1_System::AudioFile.new(@map_bgs, @org_bgs_volume, $game_system.after_battle_bgs_fadein_time) $a1_common.fadein_bgs = audio_class end end #============================================================================== # ■ A1_System::CommonModule #============================================================================== class A1_System::CommonModule #-------------------------------------------------------------------------- # ☆ 注釈コマンド定義 #-------------------------------------------------------------------------- alias a1_enable_battle_bgm_define_command define_command def define_command a1_enable_battle_bgm_define_command @cmd_108["戦闘BGM無効"] = :enable_battle_bgm @cmd_108["勝利ME継続"] = :continue_victory_me @cmd_108["勝利MEフェードアウト時間"] = :victory_me_fadeout_time @cmd_108["戦闘後BGM"] = :after_battle_bgm @cmd_108["戦闘後BGS"] = :after_battle_bgs @cmd_108["戦闘後BGMフェードイン時間"] = :after_battle_bgm_fadein_time @cmd_108["戦闘後BGSフェードイン時間"] = :after_battle_bgs_fadein_time end end #============================================================================== # ■ Game_Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、 # Game_Troop クラス、Game_Event クラスの内部で使用されます。 #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ○ 戦闘BGM無効 #-------------------------------------------------------------------------- def enable_battle_bgm(params) $game_system.disable_battle_bgm = params[0] == "on" ? true : false end #-------------------------------------------------------------------------- # ○ 勝利ME継続 #-------------------------------------------------------------------------- def continue_victory_me(params) $game_system.continue_victory_me = params[0] == "on" ? true : false end #-------------------------------------------------------------------------- # ○ 勝利MEフェードアウト時間 #-------------------------------------------------------------------------- def victory_me_fadeout_time(params) time = params[0].to_i $game_system.victory_me_fadeout_time = time $game_system.continue_victory_me = time > 0 ? true : false end #-------------------------------------------------------------------------- # ○ 戦闘後BGM #-------------------------------------------------------------------------- def after_battle_bgm(params) $game_temp.after_battle_bgm = RPG::BGM.new(params[0], params[1].to_i, params[2].to_i) end #-------------------------------------------------------------------------- # ○ 戦闘後BGS #-------------------------------------------------------------------------- def after_battle_bgs(params) $game_temp.after_battle_bgs = RPG::BGS.new(params[0], params[1].to_i, params[2].to_i) end #-------------------------------------------------------------------------- # ○ 戦闘後BGMフェードイン時間 #-------------------------------------------------------------------------- def after_battle_bgm_fadein_time(params) $game_system.after_battle_bgm_fadein_time = params[0].to_i end #-------------------------------------------------------------------------- # ○ 戦闘後BGSフェードイン時間 #-------------------------------------------------------------------------- def after_battle_bgs_fadein_time(params) $game_system.after_battle_bgs_fadein_time = params[0].to_i end end end