#============================================================================== # ■ XP-RGSS-48 作戦オート戦闘 [Ver.1.0.0] by Claimh #------------------------------------------------------------------------------ # パーティー全員の行動作戦を決めて、オート戦闘をします。 # ただし、【オート行動キャラクタ】にてオート行動者に設定されているキャラクタは # 【オート戦闘コマンド】で選択される行動パターンには従いません。 #------------------------------------------------------------------------------ # 必須スクリプト:オート行動キャラクタ(本スクリプトよりも上に配置すること) #------------------------------------------------------------------------------ # [再定義] # Scene_Battle : update_phase2 # Window_PartyCommand : initialize, draw_item, update_cursor_rect #============================================================================== module AutoPlayer #------------------------------------------------------------------------------ # ★設定カスタマイズ #------------------------------------------------------------------------------ #----------------------------------------------------------- # ◆作戦内容設定 #----------------------------------------------------------- # 定数名 = [ # "作戦名", # [nil, アクター1の行動パターン, アクター2の行動パターン, ・・・・] # ] ATPT_PAT_0 = [ "ガンガンいこうぜ", [nil, AT_PATTERN_1_0, AT_PATTERN_2_0, AT_PATTERN_3_0, AT_PATTERN_4_0] ] ATPT_PAT_1 = [ "いのちをたいせつに", [nil, AT_PATTERN_1_1, AT_PATTERN_2_1, AT_PATTERN_3_1, AT_PATTERN_4_1] ] #----------------------------------------------------------- # ◆ 作戦設定(7個まで) #----------------------------------------------------------- ATPT_CMD = [ ATPT_PAT_0, ATPT_PAT_1 ] #------------------------------------------------------------------------------ end #============================================================================== # ■ Window_PartyCommand (全再定義) #============================================================================== class Window_PartyCommand < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0, 640, 64) self.contents = Bitmap.new(width - 32, height - 32) self.back_opacity = 160 @commands = ["戦う", "作戦", "逃げる"] @item_max = 3 @column_max = 2 draw_item(0, normal_color) draw_item(1, normal_color) draw_item(2, $game_temp.battle_can_escape ? normal_color : disabled_color) self.active = false self.visible = false self.index = 0 end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 # color : 文字色 #-------------------------------------------------------------------------- def draw_item(index, color) self.contents.font.color = color rect = Rect.new(80 + index * 160 + 4, 0, 128 - 10, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) self.contents.draw_text(rect, @commands[index], 1) end #-------------------------------------------------------------------------- # ● カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect self.cursor_rect.set(80 + index * 160 + 4, 0, 128 - 10, 32) end end #============================================================================== # ■ Window_AutoPlayCmd #============================================================================== class Window_AutoPlayCmd < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(360, 64, 280, AutoPlayer::ATPT_CMD.size * 32 + 32) self.contents = Bitmap.new(width - 32, height - 32) @item_max = AutoPlayer::ATPT_CMD.size refresh @column_max = 1 self.active = false self.visible = false self.back_opacity = 160 self.index = -1 end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear for index in 0...@item_max y = index * 32 self.contents.draw_text(4, y, 204, 32, AutoPlayer::ATPT_CMD[index][0], 0) end end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- alias main_auto_play main def main @party_auto_cmd_window = Window_AutoPlayCmd.new # オート行動者のストック @auto_pt_stock = [] for actor in $game_party.actors @auto_pt_stock.push(actor.id) if actor.auto_play end main_auto_play @party_auto_cmd_window.dispose end #-------------------------------------------------------------------------- # ● パーティコマンドフェーズ開始 #-------------------------------------------------------------------------- alias start_phase2_auto_play start_phase2 def start_phase2 for actor in $game_party.actors unless @auto_pt_stock.include?(actor.id) actor.auto_play = false end end start_phase2_auto_play end #-------------------------------------------------------------------------- # ● フレーム更新 (パーティコマンドフェーズ) (再定義) #-------------------------------------------------------------------------- def update_phase2 # パーティーコマンドウィンドウがアクティブ if @party_command_window.active update_phase2_party_cmd # 作戦ウィンドウがアクティブ elsif @party_auto_cmd_window.active @party_auto_cmd_window.update update_phase2_auto_cmd end end #-------------------------------------------------------------------------- # ● フレーム更新 (パーティコマンド) #-------------------------------------------------------------------------- def update_phase2_party_cmd # C ボタンが押された場合 if Input.trigger?(Input::C) # パーティコマンドウィンドウのカーソル位置で分岐 case @party_command_window.index when 0 # 戦う # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) @auto_party_cmd_type = nil # アクターコマンドフェーズ開始 start_phase3 when 1 # 作戦 # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) @party_auto_cmd_window.active = true @party_auto_cmd_window.visible = true @party_auto_cmd_window.index = 0 @party_command_window.active = false when 2 # 逃げる # 逃走可能ではない場合 if $game_temp.battle_can_escape == false # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 逃走処理 update_phase2_escape end end end #-------------------------------------------------------------------------- # ● フレーム更新 (作戦コマンド) #-------------------------------------------------------------------------- def update_phase2_auto_cmd # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) @auto_party_cmd_type = @party_auto_cmd_window.index @party_auto_cmd_window.active = false @party_auto_cmd_window.visible = false @party_command_window.active = false @party_command_window.visible = false # オート行動者はストックしておく @auto_pt_stock = [] for actor in $game_party.actors if actor.auto_play @auto_pt_stock.push(actor.id) end actor.auto_play = true end # フェーズ4へ start_phase4 return end if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) @party_auto_cmd_window.active = false @party_auto_cmd_window.visible = false @party_command_window.active = true return end end #-------------------------------------------------------------------------- # ● 行動パターン抽出 #-------------------------------------------------------------------------- alias at_judge_auto_pattern_atpt? at_judge_auto_pattern? def at_judge_auto_pattern? if @auto_party_cmd_type.nil? action_motion = at_judge_auto_pattern_atpt? else action_motion = AutoPlayer::ATPT_CMD[@auto_party_cmd_type][1][@active_battler.id] # 行動パターンが設定されていない if action_motion.nil? # 何もしない @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 3 return nil end end return action_motion end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ) #-------------------------------------------------------------------------- alias update_phase4_step6_autoplay update_phase4_step6 def update_phase4_step6 if @active_battler.is_a?(Game_Actor) unless @auto_party_cmd_type.nil? unless @auto_pt_stock.include?(@active_battler.id) @active_battler.auto_play = false end end end update_phase4_step6_autoplay end end