############################################################################ # # 戦闘テスト # 作者:リック(http://mugenrick.seesaa.net) # 最終更新日:2020/4/25 # ############################################################################ # # 【説明】 # 表示される敵グループ一覧からひとつを選択して # 戦闘を行うことができる制作補助ツールです。 # データベースの敵グループからでも戦闘のテストは行なえますが、 # それでは物足りないと感じたときにご利用ください。 # # 【使用方法】 # イベントコマンドのスクリプトにて、 # "start_debug_battle" # と入力することで戦闘テストを行うことができます。 # 選択ウィンドウを開いた時や戦闘終了時に全回復を行うかどうかは、 # この説明文の下のほうにある"module DEBUG_BATTLE"の部分で変更できます # (デフォルトでは全回復するようになっています)。 # 導入位置ですが、基本的に「▼ 素材」の下、 # 「▼ メイン」の上であればどこでも構いません。 # # 【更新履歴】 # 2020/ 4/25 公開 # ############################################################################# module DEBUG_BATTLE RECOV = true #選択ウィンドウを開いた時と戦闘終了時に全回復を行うか #true:行う false:行わない end $imported ||= {} $imported["戦闘テスト"] = true ############################################################################# # ■ 一時変数 ############################################################################# class Game_Temp #-------------------------------------------------------------------------- # ■ 最終カーソル位置取得 #-------------------------------------------------------------------------- def debug_battle_cursor @debug_battle_cursor || 0 end #-------------------------------------------------------------------------- # ■ 最終カーソル位置代入 #-------------------------------------------------------------------------- def debug_battle_cursor=(value) @debug_battle_cursor = value end end ############################################################################# # ■ インタプリタ ############################################################################# class Game_Interpreter #-------------------------------------------------------------------------- # ■ 戦闘テストシーン呼び出し #-------------------------------------------------------------------------- def start_debug_battle SceneManager.call(Scene_DebugBattle) end end ############################################################################# # ■ 新規クラス:敵グループ選択ウィンドウ ############################################################################# class Window_DebugBTLeft < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, width) super(x, y, width, Graphics.height) make_item_list create_enem_window select($game_temp.debug_battle_cursor) end #-------------------------------------------------------------------------- # ● 敵グループ内容ウィンドウの作成 #-------------------------------------------------------------------------- def create_enem_window x = self.width width = Graphics.width - x @enem_window = Window_DebugBTRight.new(x, 0, width, self.height) end #-------------------------------------------------------------------------- # ● 項目数の取得 #-------------------------------------------------------------------------- def item_max (@data || []).size end #-------------------------------------------------------------------------- # ● 現在選択中の敵グループ取得 #-------------------------------------------------------------------------- def get_troop @data[index] end #-------------------------------------------------------------------------- # ● 敵グループリストの作成 #-------------------------------------------------------------------------- def make_item_list @data = [] $data_troops[1..-1].each do |tr| @data.push(tr) if tr.name != "" end end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) txt = get_num_txt(index + 1) rect = get_txt_rect(index, txt) draw_text(rect[0], txt) draw_text(rect[1], @data[index].name) end #-------------------------------------------------------------------------- # ● 番号テキスト作成 #-------------------------------------------------------------------------- def get_num_txt(num) txt = "" (@data.size.to_s.size - num.to_s.size).times { txt += "0" } return "#{txt}#{num}:" end #-------------------------------------------------------------------------- # ● 番号テキスト/名称テキストそれぞれの矩形取得 #-------------------------------------------------------------------------- def get_txt_rect(index, txt) rect = [item_rect_for_text(index)] rect.push(rect[0].clone) rect[0].width = text_size(txt).width + 2 rect[1].x = rect[0].width rect[1].width -= rect[0].width rect end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh create_contents draw_all_items end #-------------------------------------------------------------------------- # ● 項目の選択 #-------------------------------------------------------------------------- def select(index) super if index $game_temp.debug_battle_cursor = index @enem_window.troop = get_troop @enem_window.refresh end end #-------------------------------------------------------------------------- # ● 解放 (同時に敵グループ内容ウィンドウも解放) #-------------------------------------------------------------------------- def dispose super @enem_window.dispose end end ############################################################################# # ■ 新規クラス:敵グループ内容ウィンドウ ############################################################################# class Window_DebugBTRight < Window_Base #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :troop # 敵グループ #-------------------------------------------------------------------------- # ● 描画 #-------------------------------------------------------------------------- def draw_all_items return if !@troop @troop.members.each_with_index do |e, i| next if !$data_enemies[e.enemy_id] txt = $data_enemies[e.enemy_id].name change_color(normal_color, !e.hidden) draw_text(0, line_height * i, contents.width, contents.font.size, txt) end end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh create_contents draw_all_items end end ############################################################################# # ■ 新規クラス テスト戦闘選択シーン ############################################################################# class Scene_DebugBattle < Scene_MenuBase #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super create_item_window $game_map.screen.clear_flash #スリップ演出防止 $game_party.all_members.each {|a| a.recover_all } if DEBUG_BATTLE::RECOV end #-------------------------------------------------------------------------- # ● 終了前処理 #-------------------------------------------------------------------------- def pre_terminate super Scene_Map.pre_battle_scene if SceneManager.scene_is?(Scene_Battle) end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate super SceneManager.snapshot_for_background Scene_Map.perform_battle_transition if SceneManager.scene_is?(Scene_Battle) end #-------------------------------------------------------------------------- # ● 敵グループ選択ウィンドウの作成 #-------------------------------------------------------------------------- def create_item_window @item_window = Window_DebugBTLeft.new(0, 0, Graphics.width / 2) @item_window.set_handler(:ok, method(:on_select_ok)) @item_window.set_handler(:cancel, method(:return_scene)) @item_window.refresh @item_window.activate end #-------------------------------------------------------------------------- # ● 決定 #-------------------------------------------------------------------------- def on_select_ok if (troop = @item_window.get_troop) BattleManager.setup(troop.id, true, true) SceneManager.call(Scene_Battle) end end end ############################################################################# # ● マップ画面の処理 クラスメソッド化 ############################################################################# class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # ■ バトル画面遷移の前処理 #-------------------------------------------------------------------------- def self.pre_battle_scene tmp = self.new tmp.deb_bt_spriteset = DebugBattle_Error.new tmp.pre_battle_scene end #-------------------------------------------------------------------------- # ■ 戦闘前トランジション実行 #-------------------------------------------------------------------------- def self.perform_battle_transition self.new.perform_battle_transition end #-------------------------------------------------------------------------- # ■ エラー落ち回避用 クラスメソッド内インスタンス変数セット #-------------------------------------------------------------------------- def deb_bt_spriteset=(value) @spriteset = value end end ############################################################################# # ■ 新規クラス エラー落ち回避用 @spritesetに格納する ############################################################################# class DebugBattle_Error def dispose_characters end end