#============================================================================== # ■ XP-RGSS-54 ActiveTimeBattle【Wait Mode】[Ver.1.0.0] by Claimh #------------------------------------------------------------------------------ # ウェイトモードのATBです。 # 行動スピードは各キャラクタのステータスによって変化します。 #------------------------------------------------------------------------------ # 行動カウント(ActiveTimer)は素早さ(agi)と器用さ(dex)に依存して増加します。 # カウントの増加値 = (agi/2 + dex/8) * 0.15 # 戦闘開始時の行動カウントは完全にランダムです。(ステータスは関係なし) # 付与ステートによって行動カウントの増加スピードを変化できます。 # 攻撃・アイテムでの行動カウントの増減までは対応してません。 # アクターの行動選択中、バトラーの行動中はカウントを停止します(ウェイトモード) #============================================================================== module ATB_W #---------------------------------------------------------------------------- # 設定START #---------------------------------------------------------------------------- # ATカウント加速(1.5倍)ステートID AT_UP_STATE = 6 # ATカウント減速(1/2)ステートID AT_DN_STATE = 7 # ATカウントがフルになったときのSE(不要ならnilです) AT_FULL_SE = "005-System05" # 先制攻撃用 スイッチID PRE_SW = 10 # バックアタック用 スイッチID BAC_SW = 11 #---------------------------------------------------------------------------- # 設定END #---------------------------------------------------------------------------- # ActiveTimer最大値 AT_MAX = 1000 module_function #-------------------------------------------------------------------------- # ● パーティー先制判定 #-------------------------------------------------------------------------- def party_pattern if $game_switches[PRE_SW] return 1 end if $game_switches[BAC_SW] return 2 end return 0 end #-------------------------------------------------------------------------- # ● トループ先制判定 #-------------------------------------------------------------------------- def troop_pattern if $game_switches[PRE_SW] return 2 end if $game_switches[BAC_SW] return 1 end return 0 end #-------------------------------------------------------------------------- # ● 先制判定用のスイッチ初期化 #-------------------------------------------------------------------------- def reset_sw $game_switches[PRE_SW] = false $game_switches[BAC_SW] = false end end class Game_Battler #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :at # ActiveTimer #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias init_game_b initialize def initialize init_game_b @at = 0 end #-------------------------------------------------------------------------- # ● コマンド入力可能判定 #-------------------------------------------------------------------------- alias atb_inputable? inputable? def inputable? # ActiveTimerがフル状態なら行動開始 if at_full? return atb_inputable? else return false end end #-------------------------------------------------------------------------- # ● ActiveTimerフル判定 #-------------------------------------------------------------------------- def at_full? if @at >= ATB_W::AT_MAX return true end return false end #-------------------------------------------------------------------------- # ● ActiveTimerの初期カウント値 #-------------------------------------------------------------------------- def at_start(pattern = 0) # 戦闘不能時はカウントしない unless self.dead? srand() case pattern when 0 # 通常(完全ランダム) @at = rand(ATB_W::AT_MAX) when 1 # 先制(半分以上) at_half = (ATB_W::AT_MAX/2).round @at = rand(at_half) + at_half when 2 # 後攻(半分以下) @at = rand(at_half) end else at_refresh end end #-------------------------------------------------------------------------- # ● ActiveTimerのカウント #-------------------------------------------------------------------------- def at_plus # 戦闘不能時はカウントしない return if self.dead? # ActiveTimerのカウント値計算 plus = ((agi/2 + dex/8) * 0.15).round # ATカウント加速ステート有り? if @states.include?(ATB_W::AT_UP_STATE) @at += (plus * 1.5).round # ATカウント減速ステート有り? elsif @states.include?(ATB_W::AT_DN_STATE) @at += (plus / 2).round # 通常ATカウント else @at += plus end end #-------------------------------------------------------------------------- # ● ActiveTimerのゼロ化 #-------------------------------------------------------------------------- def at_refresh @at = 0 end #-------------------------------------------------------------------------- # ● ActiveTimerのハーフカウント #-------------------------------------------------------------------------- def at_half @at = (ATB_W::AT_MAX / 2).round end end #============================================================================== # ■ Game_Party #============================================================================== class Game_Party #-------------------------------------------------------------------------- # ● 全アクターのActiveTimer初期化 #-------------------------------------------------------------------------- def at_setup pattern = ATB_W.party_pattern for actor in @actors actor.at_start(pattern) end end #-------------------------------------------------------------------------- # ● 全アクターのActiveTimerゼロ化 #-------------------------------------------------------------------------- def at_all_clear for actor in @actors actor.at_refresh end end #-------------------------------------------------------------------------- # ● ATフル状態判定 #-------------------------------------------------------------------------- def at_full? # 一人でも行動可能なら true を返す for actor in @actors if actor.at_full? return true end end return false end end #============================================================================== # ■ Game_Troop #============================================================================== class Game_Troop #-------------------------------------------------------------------------- # ● 全エネミーのActiveTimer初期化 #-------------------------------------------------------------------------- def at_setup pattern = ATB_W.troop_pattern for enemy in @enemies enemy.at_start(pattern) end end #-------------------------------------------------------------------------- # ● ATフル状態判定 #-------------------------------------------------------------------------- def at_full? # 一人でも行動可能なら true を返す for enemy in @enemies if enemy.at_full? return true end end return false end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● ATB用戦闘終了判定 #-------------------------------------------------------------------------- def at_count_judge # 全滅判定が真、またはパーティ人数が 0 人の場合 if $game_party.all_dead? or $game_party.actors.size == 0 # true を返す return true end # エネミーが 1 体でも存在すれば false を返す for enemy in $game_troop.enemies if enemy.exist? return false end end # true を返す return true end #-------------------------------------------------------------------------- # ● プレバトルフェーズ開始 #-------------------------------------------------------------------------- alias start_phase1_atb_w start_phase1 def start_phase1 start_phase1_atb_w # ActiveTimer初期化 $game_party.at_setup $game_troop.at_setup @active_start = false ATB_W.reset_sw end #-------------------------------------------------------------------------- # ● バトル終了 # result : 結果 (0:勝利 1:敗北 2:逃走) #-------------------------------------------------------------------------- alias battle_end_atb battle_end def battle_end(result) $game_party.at_all_clear battle_end_atb(result) end #-------------------------------------------------------------------------- # ● フレーム更新[再定義] #-------------------------------------------------------------------------- def update # バトルイベント実行中の場合 if $game_system.battle_interpreter.running? # インタプリタを更新 $game_system.battle_interpreter.update # アクションを強制されているバトラーが存在しない場合 if $game_temp.forcing_battler == nil # バトルイベントの実行が終わった場合 unless $game_system.battle_interpreter.running? # 戦闘継続の場合、バトルイベントのセットアップを再実行 unless judge setup_battle_event end end # アフターバトルフェーズでなければ # if @phase != 5 # ステータスウィンドウをリフレッシュ # @status_window.refresh # end end end # システム (タイマー)、画面を更新 $game_system.update $game_screen.update # タイマーが 0 になった場合 if $game_system.timer_working and $game_system.timer == 0 # バトル中断 $game_temp.battle_abort = true end # ウィンドウを更新 @help_window.update @party_command_window.update @actor_command_window.update @status_window.update @message_window.update # スプライトセットを更新 @spriteset.update # トランジション処理中の場合 if $game_temp.transition_processing # トランジション処理中フラグをクリア $game_temp.transition_processing = false # トランジション実行 if $game_temp.transition_name == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $game_temp.transition_name) end end # メッセージウィンドウ表示中の場合 if $game_temp.message_window_showing @message_window.update return end # エフェクト表示中の場合 if @spriteset.effect? # ★スリップダメージ時は止まらないように if @active_start return end end # ゲームオーバーの場合 if $game_temp.gameover # ゲームオーバー画面に切り替え $scene = Scene_Gameover.new return end # タイトル画面に戻す場合 if $game_temp.to_title # タイトル画面に切り替え $scene = Scene_Title.new return end # バトル中断の場合 if $game_temp.battle_abort # バトル開始前の BGM に戻す $game_system.bgm_play($game_temp.map_bgm) # バトル終了 battle_end(1) return end # ウェイト中の場合 # if @wait_count > 0 # # ウェイトカウントを減らす # @wait_count -= 1 # return # end # アクションを強制されているバトラーが存在せず、 # かつバトルイベントが実行中の場合 if $game_temp.forcing_battler == nil and $game_system.battle_interpreter.running? return end # ★行動者が居ない場合のみActiveカウントを行う[ウェイトモード] unless @active_start unless at_count_judge # Activeになっているバトラーが存在しない場合はActiveTimerのカウント unless ($game_party.at_full? or $game_troop.at_full?) # ActiveTimerのカウント for battler in $game_party.actors + $game_troop.enemies battler.at_plus end # ATBバーの更新 @status_window.atb_refresh return else # 行動開始(ActiveTimerのカウント停止) @active_start = true end end end # フェーズによって分岐 case @phase when 1 # プレバトルフェーズ update_phase1 when 2 # パーティコマンドフェーズ update_phase2 when 3 # アクターコマンドフェーズ update_phase3 when 4 # メインフェーズ update_phase4 when 5 # アフターバトルフェーズ update_phase5 end end #-------------------------------------------------------------------------- # ● アクターコマンドウィンドウのセットアップ #-------------------------------------------------------------------------- alias phase3_setup_command_window_atb_w phase3_setup_command_window def phase3_setup_command_window # ★ATB行動開始SE unless ATB_W::AT_FULL_SE.nil? Audio.se_play("Audio/SE/" + ATB_W::AT_FULL_SE) end phase3_setup_command_window_atb_w end #-------------------------------------------------------------------------- # ● 行動順序作成 [再定義] #-------------------------------------------------------------------------- def make_action_orders # 配列 @action_battlers を初期化 @action_battlers = [] # アクターを配列 @action_battlers に追加 for actor in $game_party.actors if actor.at_full? @action_battlers.push(actor) end end # エネミーを配列 @action_battlers に追加 for enemy in $game_troop.enemies if enemy.at_full? @action_battlers.push(enemy) end end # 全員のアクションスピードを決定 for battler in @action_battlers battler.make_action_speed end # アクションスピードの大きい順に並び替え @action_battlers.sort! {|a,b| b.current_action.speed - a.current_action.speed } end #-------------------------------------------------------------------------- # ● 基本アクション 結果作成 #-------------------------------------------------------------------------- alias make_basic_action_result_atb make_basic_action_result def make_basic_action_result make_basic_action_result_atb if @phase4_step == 1 # ★行動できない場合はActiveTimerを初期化 at_reset end end #-------------------------------------------------------------------------- # ● アイテムアクション 結果作成 #-------------------------------------------------------------------------- alias make_item_action_result_atb make_item_action_result def make_item_action_result make_item_action_result_atb if @phase4_step == 1 # ★行動できない場合はActiveTimerを初期化 at_reset end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ) [再定義] #-------------------------------------------------------------------------- alias update_phase4_step6_atb update_phase4_step6 def update_phase4_step6 update_phase4_step6_atb # ActiveTimerのカウント再開 @active_start = false # 行動者のActiveTimer初期化 at_reset end #-------------------------------------------------------------------------- # ● 行動終了:ATカウント初期化 #-------------------------------------------------------------------------- def at_reset @already_party_chain = false # ActiveTimerのカウント再開 @active_start = false # 行動者のActiveTimer初期化 @active_battler.at_refresh # ウィンドウ更新 if @active_battler.is_a?(Game_Actor) @status_window.actor_atb_refresh(@active_battler.index) end end end