#============================================================================== # ■ RGSS3 簡易バトルログ Ver1.01 by 星潟 #============================================================================== # その戦闘中、ターン毎にログウィンドウに表示された文字列を自動保存し # 指定した方法で確認できるようにします。 # なお、空の文字列と判定されたログは自動保存されません。 # # 一部、ログウィンドウを非表示にするスクリプトでも # 内部的に出力しているバトルログを保存しますが # きちんと通常の出力用のデータを設定している必要があります。 # (例えばXPスタイルバトルのBATTLELOG_TYPE = 2) #============================================================================== # イベントコマンドのスクリプトで使用 #------------------------------------------------------------------------------ # c = 1 # t = "さしすせそたちつてと" # add_easy_battle_log(c,t) # # 1ターン目のバトルログデータに「さしすせそたちつてと」を追加する。 # (どうしても後付けしたい場合用) #------------------------------------------------------------------------------ # c = $game_troop.turn_count # t = "あいうえおかきくけこ" # add_easy_battle_log(c,t) # # 現在ターンのバトルログデータに「あいうえおかきくけこ」を追加する。 # (どうしても後付けしたい場合用) #------------------------------------------------------------------------------ # easy_battle_log_clear(1) # # 1ターン目のバトルログデータを削除する。 # (どうしても削除したい場合用) #------------------------------------------------------------------------------ # easy_battle_log_clear # # 全バトルログデータを削除する。 # (どうしても削除したい場合用。ウェーブ形式のバトルなどで利用価値があるかも) #============================================================================== module EasyBattleLog #テストモード限定にするかを指定。 #trueでテストモード限定。falseで限定なし。 Test = false #実装タイプを指定。 #0ならパーティコマンドに追加。 #1ならアクターコマンドに追加。 #2ならパーティコマンド選択中に特定ボタンを押した際に表示。 #3ならアクターコマンド選択中に特定ボタンを押した際に表示。 #4ならパーティコマンドorアクターコマンド選択中に特定ボタンを押した際に表示。 Type1 = 0 #表示タイプを指定。 #trueならターン毎にまとめる。 #falseならまとめず、全て一括で管理する。 Type2 = true #何らかのスクリプトによりコマンド入力中にバトルログの追加が行われた場合 #次ターンのターンカウントにて表示するようにするかを指定。 InTP1 = true #関連ウィンドウのZ座標を指定。 Z = 1000 #実装タイプが1以下の場合(特定ウィンドウのコマンドに追加) #どのような名前のコマンドにするかを指定。 Name = "バトルログ" #実装タイプが2以上の場合(特定ウィンドウ選択中に特定ボタンを押した際に表示) #バトルログを表示するボタンシンボルを指定。 #デフォルトでは:XはAキー、:YはSキー、:ZはDキー、 #:LはQキー、:RはWキー、:AはShiftキー、 #:F6〜:F9は対応するファンクションキーが対応。 KeySymbol = :Z #表示タイプ(Type2)がtrueの場合 #ターン表示をターン数が新しいものから表示するか、古いものから表示するか。 #trueの場合新しいもの、falseの場合古いものから表示。 TR = true #表示タイプ(Type2)がtrueの場合 #1行に何ターン分表示するかを指定。 CM = 10 #表示タイプ(Type2)がtrueの場合 #項目間の横スペースを指定。 SP = 4 #表示タイプ(Type2)がtrueの場合 #何ターン分のバトルログを保持するかを指定。 #表示タイプ(Type2)がfalseの場合 #何行分のバトルログを保持するかを指定。 TMax = 120 #表示スイッチIDを指定。 #0で常時表示。1で指定スイッチIDがONの時表示。 SID1 = 0 #機能有効化スイッチIDを指定。 #0で常時有効。1で指定スイッチIDがONの時有効。 SID2 = 0 #ターン選択中のヘルプメッセージに表示する内容を指定。 TF = "バトルログを確認したいターンを選択してください。" #ターン選択中のヘルプメッセージに表示する内容を指定。 DF = "上/左キー:前のページへ 下/右キー:次のページへ" #表示タイプ(Type2)がtrueの場合 #何ターン目のログかを表示するフォーマットを指定。 #%dの部分にターン数が入る。 TD1 = "%dターン目のログ" #表示タイプ(Type2)がfalseの場合 #ログ表示ウィンドウの左上に表示する見出しを指定。 #%dの部分にターン数が入る。 TD2 = "バトルログ" #ページ数表示用フォーマットを指定。 #例.PD = "%3d/%3d" #この場合 #基本3桁分を想定した現在ページ数/基本3桁分を想定した3桁分の最大ページ数 #このような表示となる。 PD = "%3d/%3d" end if EasyBattleLog::Test ? $TEST : true module BattleManager def self.input_check_for_easy_battle_log @phase == :input end end class Game_Unit #-------------------------------------------------------------------------- # 戦闘開始処理 #-------------------------------------------------------------------------- alias on_battle_start_easy_battle_log on_battle_start def on_battle_start on_battle_start_easy_battle_log easy_battle_log_clear if self.is_a?(Game_Party) end #-------------------------------------------------------------------------- # 戦闘終了処理 #-------------------------------------------------------------------------- alias on_battle_end_easy_battle_log on_battle_end def on_battle_end on_battle_end_easy_battle_log easy_battle_log_clear if self.is_a?(Game_Party) end end class Game_Party < Game_Unit #-------------------------------------------------------------------------- # バトルログ #-------------------------------------------------------------------------- def easy_battle_log if EasyBattleLog::Type2 @easy_battle_log ||= {} else @easy_battle_log ||= [] end end #-------------------------------------------------------------------------- # バトルログ追加 #-------------------------------------------------------------------------- def add_easy_battle_log(turn_count,text) if EasyBattleLog::Type2 @easy_battle_log ||= {} unless @easy_battle_log[turn_count] @easy_battle_log[turn_count] = [] if @easy_battle_log.size > EasyBattleLog::TMax @easy_battle_log.delete(@easy_battle_log.keys.min) end end @easy_battle_log[turn_count].push(text) else @easy_battle_log ||= [] @easy_battle_log.push(text) @easy_battle_log.shift if @easy_battle_log.size > EasyBattleLog::TMax end end #-------------------------------------------------------------------------- # バトルログ消去 #-------------------------------------------------------------------------- def easy_battle_log_clear(turn_count = nil) if @easy_battle_log if turn_count @easy_battle_log.delete(turn_count) if EasyBattleLog::Type2 else @easy_battle_log.clear end else @easy_battle_log = EasyBattleLog::Type2 ? {} : [] end end end class Window_BattleLog < Window_Selectable #-------------------------------------------------------------------------- # 文章の追加 #-------------------------------------------------------------------------- alias add_text_easy_battle_log add_text def add_text(text) add_text_easy_battle_log(text) add_easy_battle_log($game_troop.turn_count,text) end #-------------------------------------------------------------------------- # 文章の置き換え #-------------------------------------------------------------------------- alias replace_text_easy_battle_log replace_text def replace_text(text) replace_text_easy_battle_log(text) add_easy_battle_log($game_troop.turn_count,text) end #-------------------------------------------------------------------------- # バトルログ追加共通処理 #-------------------------------------------------------------------------- def add_easy_battle_log(turn_count,text) c = turn_count + ((EasyBattleLog::InTP1 && BattleManager.input_check_for_easy_battle_log) ? 1 : 0) unless text.empty? $game_party.add_easy_battle_log(c,convert_escape_characters(text).gsub(/\e/) { "\\" }) end end end case EasyBattleLog::Type1 when 0 class Window_PartyCommand < Window_Command #-------------------------------------------------------------------------- # コマンドリストの作成 #-------------------------------------------------------------------------- alias make_command_list_easy_battle_log make_command_list def make_command_list make_command_list_easy_battle_log if EasyBattleLog::Type1 == 0 && (EasyBattleLog::SID1 > 0 ? $game_switches[EasyBattleLog::SID1] : true) add_command(EasyBattleLog::Name, :easy_battle_log, EasyBattleLog::SID2 > 0 ? $game_switches[EasyBattleLog::SID2] : true) end end end when 1 class Window_ActorCommand < Window_Command #-------------------------------------------------------------------------- # コマンドリストの作成 #-------------------------------------------------------------------------- alias make_command_list_easy_battle_log make_command_list def make_command_list make_command_list_easy_battle_log if EasyBattleLog::Type1 == 1 && (EasyBattleLog::SID1 > 0 ? $game_switches[EasyBattleLog::SID1] : true) add_command(EasyBattleLog::Name, :easy_battle_log, EasyBattleLog::SID2 > 0 ? $game_switches[EasyBattleLog::SID2] : true) end end end end class Window_EasyBattleLogTurnSelect < Window_Command #-------------------------------------------------------------------------- # 初期化 #-------------------------------------------------------------------------- def initialize(help_window) yd = help_window.y + help_window.height hd = Graphics.height - yd @window_height = hd super(0,help_window.y + help_window.height) self.back_opacity = 255 deactivate end #-------------------------------------------------------------------------- # コマンドリストの作成 #-------------------------------------------------------------------------- def make_command_list ks = $game_party.easy_battle_log.keys ks.sort! ks.reverse! if EasyBattleLog::TR ks.each {|k,v| add_command(k, :detail, true, k)} end #-------------------------------------------------------------------------- # 桁数の取得 #-------------------------------------------------------------------------- def col_max EasyBattleLog::CM end #-------------------------------------------------------------------------- # 横に項目が並ぶときの空白の幅を取得 #-------------------------------------------------------------------------- def spacing EasyBattleLog::SP end #-------------------------------------------------------------------------- # アライメントの取得 #-------------------------------------------------------------------------- def alignment 2 end #-------------------------------------------------------------------------- # ウィンドウ高さの取得 #-------------------------------------------------------------------------- def window_width Graphics.width end #-------------------------------------------------------------------------- # ウィンドウ高さの取得 #-------------------------------------------------------------------------- def window_height @window_height end end class Window_EasyBattleLog < Window_Selectable attr_accessor :turn_count #-------------------------------------------------------------------------- # 初期化 #-------------------------------------------------------------------------- def initialize(help_window) yd = help_window.y + help_window.height hd = Graphics.height - yd super(0,yd,Graphics.width,hd) self.back_opacity = 255 lh = line_height @line_max_in_page = (hd - standard_padding * 2 - lh * 2) / lh deactivate end #-------------------------------------------------------------------------- # ターン設定変更 #-------------------------------------------------------------------------- def turn_count=(new_turn_count) @turn_count = new_turn_count if EasyBattleLog::Type2 log_data = $game_party.easy_battle_log[@turn_count].clone else log_data = $game_party.easy_battle_log.clone end @page_data = {} page_index = 0 line_index = 0 log_data.each {|l| @page_data[page_index] ||= [] @page_data[page_index].push(l) line_index += 1 if line_index == @line_max_in_page line_index = 0 page_index += 1 end} @page_max = @page_data.size @page_count = EasyBattleLog::Type2 ? 0 : @page_max - 1 self.oy = 0 refresh end #-------------------------------------------------------------------------- # リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear a = @page_data[@page_count] return if !a or a.empty? lh = line_height cw = contents_width r = Rect.new(0,0,cw,lh) reset_font_settings draw_text(r,EasyBattleLog::Type2 ? sprintf(EasyBattleLog::TD1,@turn_count) : EasyBattleLog::TD2,0) draw_text(r,sprintf(EasyBattleLog::PD,@page_count + 1,@page_max),2) r = Rect.new(0,lh * 1.5 - 1,cw,2) c = system_color c.alpha = translucent_alpha contents.fill_rect(r,c) a.each_with_index {|t,i| draw_text_ex(0,lh * (i + 2),t)} end #-------------------------------------------------------------------------- # 最大項目数 #-------------------------------------------------------------------------- def item_max return 1 unless @turn_count a = $game_party.easy_battle_log[@turn_count] a ? $game_party.easy_battle_log[@turn_count].size : 1 end #-------------------------------------------------------------------------- # カーソルを下に移動 #-------------------------------------------------------------------------- def cursor_down(wrap = false) easy_battle_log_next_page end #-------------------------------------------------------------------------- # カーソルを上に移動 #-------------------------------------------------------------------------- def cursor_up(wrap = false) easy_battle_log_prev_page end #-------------------------------------------------------------------------- # カーソルを右に移動 #-------------------------------------------------------------------------- def cursor_right(wrap = false) easy_battle_log_next_page end #-------------------------------------------------------------------------- # カーソルを左に移動 #-------------------------------------------------------------------------- def cursor_left(wrap = false) easy_battle_log_prev_page end #-------------------------------------------------------------------------- # カーソルを 1 ページ後ろに移動 #-------------------------------------------------------------------------- def cursor_pagedown end #-------------------------------------------------------------------------- # カーソルを 1 ページ前に移動 #-------------------------------------------------------------------------- def cursor_pageup end #-------------------------------------------------------------------------- # 次のページへ #-------------------------------------------------------------------------- def easy_battle_log_next_page return if @page_count >= @page_max - 1 @page_count += 1 self.oy = 0 Sound.play_cursor refresh end #-------------------------------------------------------------------------- # 前のページへ #-------------------------------------------------------------------------- def easy_battle_log_prev_page return if @page_count <= 0 @page_count -= 1 self.oy = 0 Sound.play_cursor refresh end end class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # 全ウィンドウの作成 #-------------------------------------------------------------------------- alias create_all_windows_easy_battle_log create_all_windows def create_all_windows create_all_windows_easy_battle_log create_easy_battle_log_help_window create_easy_battle_log_turn_select_window create_easy_battle_log_window end case EasyBattleLog::Type1 when 0 #-------------------------------------------------------------------------- # パーティコマンドウィンドウの作成 #-------------------------------------------------------------------------- alias create_party_command_window_easy_battle_log create_party_command_window def create_party_command_window create_party_command_window_easy_battle_log @party_command_window.set_handler(:easy_battle_log, method(:start_easy_battle_log_party)) end when 1 #-------------------------------------------------------------------------- # アクターコマンドウィンドウの作成 #-------------------------------------------------------------------------- alias create_actor_command_window_easy_battle_log create_actor_command_window def create_actor_command_window create_actor_command_window_easy_battle_log @actor_command_window.set_handler(:easy_battle_log, method(:start_easy_battle_log_actor)) end else #-------------------------------------------------------------------------- # 更新処理 #-------------------------------------------------------------------------- alias update_easy_battle_log update def update update_easy_battle_log return unless Input.trigger?(EasyBattleLog::KeySymbol) sid2 = EasyBattleLog::SID2 return if sid2 > 0 && !$game_switches[EasyBattleLog::SID2] type = nil case EasyBattleLog::Type1 when 2 if @party_command_window.active type = 0 end when 3 if @actor_command_window.active type = 1 end else if @actor_command_window.active type = 1 elsif @party_command_window.active type = 0 end end return unless type Sound.play_ok @party_command_window.deactivate#無料配布版XPスタイルバトル対策 case type when 0 start_easy_battle_log_party when 1 @actor_command_window.deactivate start_easy_battle_log_actor end end end #-------------------------------------------------------------------------- # バトルログ専用ヘルプウィンドウの作成 #-------------------------------------------------------------------------- def create_easy_battle_log_help_window @easy_battle_log_help_window = Window_Help.new(1) @easy_battle_log_help_window.back_opacity = 255 @easy_battle_log_help_window.hide @easy_battle_log_help_window.z = EasyBattleLog::Z end #-------------------------------------------------------------------------- # バトルログターン選択ウィンドウの作成 #-------------------------------------------------------------------------- def create_easy_battle_log_turn_select_window return unless EasyBattleLog::Type2 @easy_battle_log_turn_select_window = Window_EasyBattleLogTurnSelect.new(@easy_battle_log_help_window) @easy_battle_log_turn_select_window.set_handler(:detail, method(:start_easy_battle_log_detail)) @easy_battle_log_turn_select_window.set_handler(:cancel, method(:cancel_easy_battle_log)) @easy_battle_log_turn_select_window.hide @easy_battle_log_turn_select_window.z = EasyBattleLog::Z end #-------------------------------------------------------------------------- # バトルログウィンドウの作成 #-------------------------------------------------------------------------- def create_easy_battle_log_window @easy_battle_log_window = Window_EasyBattleLog.new(@easy_battle_log_help_window) @easy_battle_log_window.set_handler(:cancel, method(:cancel_easy_battle_log_detail)) @easy_battle_log_window.hide @easy_battle_log_window.z = EasyBattleLog::Z end #-------------------------------------------------------------------------- # バトルログ開始 #-------------------------------------------------------------------------- def start_easy_battle_log @easy_battle_log_help_window.show @easy_battle_log_help_window.set_text(EasyBattleLog::TF) if EasyBattleLog::Type2 @easy_battle_log_turn_select_window.refresh @easy_battle_log_turn_select_window.index = 0 @easy_battle_log_turn_select_window.show.activate else @easy_battle_log_window.show @easy_battle_log_window.turn_count = 0 @easy_battle_log_window.activate @easy_battle_log_help_window.set_text(EasyBattleLog::DF) end end #-------------------------------------------------------------------------- # パーティコマンドからバトルログ開始 #-------------------------------------------------------------------------- def start_easy_battle_log_party @easy_battle_log_type = :party start_easy_battle_log end #-------------------------------------------------------------------------- # アクターコマンドからバトルログ開始 #-------------------------------------------------------------------------- def start_easy_battle_log_actor @easy_battle_log_type = :actor start_easy_battle_log end #-------------------------------------------------------------------------- # バトルログ詳細 #-------------------------------------------------------------------------- def start_easy_battle_log_detail @easy_battle_log_turn_select_window.hide @easy_battle_log_window.show @easy_battle_log_window.turn_count = @easy_battle_log_turn_select_window.current_ext @easy_battle_log_window.activate @easy_battle_log_help_window.set_text(EasyBattleLog::DF) end #-------------------------------------------------------------------------- # バトルログキャンセル #-------------------------------------------------------------------------- def cancel_easy_battle_log @easy_battle_log_help_window.hide @easy_battle_log_turn_select_window.hide case @easy_battle_log_type when :party @party_command_window.activate when :actor @actor_command_window.activate end end #-------------------------------------------------------------------------- # バトルログ詳細キャンセル #-------------------------------------------------------------------------- def cancel_easy_battle_log_detail if EasyBattleLog::Type2 @easy_battle_log_help_window.set_text(EasyBattleLog::TF) @easy_battle_log_window.hide @easy_battle_log_turn_select_window.show.activate else @easy_battle_log_help_window.hide @easy_battle_log_window.hide case @easy_battle_log_type when :party @party_command_window.activate when :actor @actor_command_window.activate end end end end class Game_Interpreter #-------------------------------------------------------------------------- # バトルログ追加 #-------------------------------------------------------------------------- def add_easy_battle_log(turn_count,text) if SceneManager.scene.is_a?(Scene_Battle) SceneManager.scene.instance_variable_get(:@log_window).add_easy_battle_log(turn_count,text) end end #-------------------------------------------------------------------------- # バトルログ消去 #-------------------------------------------------------------------------- def easy_battle_log_clear(turn_count = nil) $game_party.easy_battle_log_clear(turn_count) end end end