# # バトルの格闘場化 #  (C)2005 TYPE74RX-T # #============================================================================== # ★ 定数設定 #------------------------------------------------------------------------------ #  以下の設定値は、あくまで一例です。 # 状況に応じて、定数はユーザーで設定して下さい。 #============================================================================== # ★ ゲームスイッチの何番に格闘場モードにするフラグ情報を格納するか設定 RX_T_GAMBLE_MODE_NUM = 5 # ★ ゲームスイッチの何番に勝敗フラグ情報を格納するか設定 RX_T_GAMBLE_WIN_LOSE_NUM = 8 # ★ ゲームスイッチの何番にトループのランダム呼び出し情報を格納するか設定 RX_T_RANDOM_TROOP_G_NUM = 14 # ★ ゲーム変数の何番に掛け金情報を格納するか設定 RX_T_GOLD_FOR_GAMBLE_NUM = 1 # ★ ゲーム変数の何番に所持金情報を格納するか設定 RX_T_GOLD_NUM = 2 # ★ ステート・観戦モードを設定した時のステートIDを格納 RX_T_WATCHING_STATE_NUM = 17 # ★ ステート・賭け対象を設定した時のステートIDを格納 RX_T_GAMBLE_TARGET_ST_NUM = 18 # ★ トループのランダム呼び出し時の最大トループID RX_T_G_RAND_MAX = 6 # ★ トループのランダム呼び出し時の最小トループID RX_T_G_RAND_MIN = 1 #============================================================================== # ■ Window_Base #------------------------------------------------------------------------------ #  ゲーム中のすべてのウィンドウのスーパークラスです。 #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # ● 描画用のステート文字列作成 # actor : アクター # width : 描画先の幅 # need_normal : [正常] が必要かどうか (true / false) #   ★ 「観戦モード」ステートを非表示にする #-------------------------------------------------------------------------- def make_battler_state_text(battler, width, need_normal) # 括弧の幅を取得 brackets_width = self.contents.text_size("[]").width # ステート名の文字列を作成 text = "" for i in battler.states if $data_states[i].rating >= 1 # ★ ステート表示文字列が空か、ステート名が「観戦モード」でない時 if text == "" and $data_states[i].name != "観戦モード" text = $data_states[i].name else # ★ ステート名が「観戦モード」でない時 unless $data_states[i].name == "観戦モード" new_text = text + "/" + $data_states[i].name text_width = self.contents.text_size(new_text).width if text_width > width - brackets_width break end text = new_text end end end end # ステート名の文字列が空の場合は "[正常]" にする if text == "" if need_normal text = "[正常]" end else # 括弧をつける text = "[" + text + "]" end # 完成した文字列を返す return text end end #============================================================================== # ■ Window_Help #------------------------------------------------------------------------------ #  スキルやアイテムの説明、アクターのステータスなどを表示するウィンドウです。 #============================================================================== class Window_Help < Window_Base #-------------------------------------------------------------------------- # ● エネミー設定 # enemy : 名前とステートを表示するエネミー #-------------------------------------------------------------------------- alias rx_t_set_enemy set_enemy def set_enemy(enemy) # ★ 格闘場モード時 if $game_switches[RX_T_GAMBLE_MODE_NUM] text = enemy.name state_text = make_battler_state_text(enemy, 112, false) if state_text != "" text += " " + state_text end rx_t_odds = $rx_t_odds[$rx_t_g_target_index] / 10.0 text = text + ":" + rx_t_odds.to_s + "倍" set_text(text, 1) else rx_t_set_enemy(enemy) end end end #============================================================================== # ■ Window_BattleResult #------------------------------------------------------------------------------ #  バトル終了時に、獲得した EXP やゴールドなどを表示するウィンドウです。 #============================================================================== class Window_GambleResult < Window_Base #-------------------------------------------------------------------------- # ★ オブジェクト初期化 # exp : EXP # gold : ゴールド # treasures : トレジャー #-------------------------------------------------------------------------- def initialize super(160, 0, 320, 64) self.contents = Bitmap.new(width - 32, height - 32) self.y = 160 - height / 2 self.back_opacity = 160 self.visible = false @gold = $game_variables[RX_T_GOLD_FOR_GAMBLE_NUM] * $rx_t_odds[$rx_t_g_target_index] / 10 if $rx_t_gamble_win refresh else refresh_lose end end #-------------------------------------------------------------------------- # ● リフレッシュ(賭けに勝った時) #-------------------------------------------------------------------------- def refresh self.contents.clear x = 4 self.contents.font.color = normal_color cx = contents.text_size(@gold.to_s).width self.contents.draw_text(x, 0, cx, 32, @gold.to_s) x += cx + 4 self.contents.font.color = system_color self.contents.draw_text(x, 0, 320, 32, "Gを手に入れた!") end #-------------------------------------------------------------------------- # ● リフレッシュ(賭けに負けた時) #-------------------------------------------------------------------------- def refresh_lose self.contents.clear self.contents.font.color = normal_color self.contents.draw_text(0, 0, 420, 32, "予想は外れてしまった…") end end class Window_PartyCommand < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias rx_t_g_initialize initialize def initialize # ★ 格闘場モード時 if $game_switches[RX_T_GAMBLE_MODE_NUM] super(0, 0, 640, 64) self.contents = Bitmap.new(width - 32, height - 32) self.back_opacity = 160 @commands = ["賭ける", "やめる"] @item_max = 2 @column_max = 2 draw_item(0, normal_color) draw_item(1, $game_temp.battle_can_escape ? normal_color : disabled_color) self.active = false self.visible = false self.index = 0 else rx_t_g_initialize end end end class Scene_Battle #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- alias rx_t_gamble_main main def main # ★ 格闘場モード時 if $game_switches[RX_T_GAMBLE_MODE_NUM] # ★ 初期設定 $rx_t_gamble_mode = false $rx_t_gamble_win = false $rx_t_g_target_index = 0 # ★ ランダムトループ呼び出しモードの時 if $game_switches[RX_T_RANDOM_TROOP_G_NUM] rx_t_rand = RX_T_G_RAND_MAX - RX_T_G_RAND_MIN + 1 $game_temp.battle_troop_id = rand(rx_t_rand) + RX_T_G_RAND_MIN end end rx_t_gamble_main end #-------------------------------------------------------------------------- # ● 勝敗判定 #-------------------------------------------------------------------------- def judge # 全滅判定が真、またはパーティ人数が 0 人の場合 if $game_party.all_dead? or $game_party.actors.size == 0 # 敗北可能の場合 if $game_temp.battle_can_lose # バトル開始前の BGM に戻す $game_system.bgm_play($game_temp.map_bgm) # バトル終了 battle_end(2) # true を返す return true end # ゲームオーバーフラグをセット $game_temp.gameover = true # true を返す return true end # ★ 格闘場モードの時 if $game_switches[RX_T_GAMBLE_MODE_NUM] # ★ エネミーが 2 体以上存在すれば false を返す rx_t_exist = 0 for enemy in $game_troop.enemies if enemy.exist? rx_t_exist += 1 # ★ ステートに「賭け対象」が含まれていれば if enemy.states.include?(RX_T_GAMBLE_TARGET_ST_NUM) # ギャンブル勝利フラグを立てる $rx_t_gamble_win = true end end # ★ エネミーが2体以上残っていれば if rx_t_exist > 1 # ★ ギャンブル勝利フラグをリセット $rx_t_gamble_win = false return false end end # ★ ギャンブルモードの時 if $rx_t_gamble_mode # アフターバトルフェーズ開始 (勝利) start_gamblephase else if $rx_t_gamble_win # ★ 勝敗フラグをON(勝ち)に $game_switches[RX_T_GAMBLE_WIN_LOSE_NUM] = true # バトル開始前の BGM に戻す $game_system.bgm_play($game_temp.map_bgm) # バトル終了 battle_end(2) # true を返す return true else # ★ 勝敗フラグをOFF(負け)に $game_switches[RX_T_GAMBLE_WIN_LOSE_NUM] = false # バトル開始前の BGM に戻す $game_system.bgm_play($game_temp.map_bgm) # バトル終了 battle_end(2) # true を返す return true end end else # エネミーが 1 体でも存在すれば false を返す for enemy in $game_troop.enemies if enemy.exist? return false end end # アフターバトルフェーズ開始 (勝利) start_phase5 end # true を返す return true end #-------------------------------------------------------------------------- # ★ アフターバトルフェーズ(格闘場用)開始 #-------------------------------------------------------------------------- def start_gamblephase # フェーズ 5 に移行 @phase = 5 $game_party.lose_gold($game_variables[RX_T_GOLD_FOR_GAMBLE_NUM]) if $rx_t_gamble_win # ★ 勝敗フラグをON(勝ち)に $game_switches[RX_T_GAMBLE_WIN_LOSE_NUM] = true # バトル終了 ME を演奏 $game_system.me_play($game_system.battle_end_me) gold = $game_variables[RX_T_GOLD_FOR_GAMBLE_NUM] * $rx_t_odds[$rx_t_g_target_index] / 10 # ゴールド獲得 $game_party.gain_gold(gold) else # ★ 勝敗フラグをOFF(負け)に $game_switches[RX_T_GAMBLE_WIN_LOSE_NUM] = false # ゲームオーバー ME を演奏 $game_system.me_play($data_system.gameover_me) end # バトル開始前の BGM に戻す $game_system.bgm_play($game_temp.map_bgm) # バトルリザルトウィンドウを作成 @result_window = Window_GambleResult.new # ウェイトカウントを設定 @phase5_wait_count = 100 end alias rx_t_g_update_phase2_escape update_phase2_escape #-------------------------------------------------------------------------- # ● フレーム更新 (パーティコマンドフェーズ : 逃げる) #-------------------------------------------------------------------------- def update_phase2_escape # ★ 格闘場モードの時 if $game_switches[RX_T_GAMBLE_MODE_NUM] # 逃走 SE を演奏 $game_system.se_play($data_system.escape_se) # バトル開始前の BGM に戻す $game_system.bgm_play($game_temp.map_bgm) # バトル終了 battle_end(1) else rx_t_g_update_phase2_escape end end #-------------------------------------------------------------------------- # ● アクターコマンドフェーズ開始 #-------------------------------------------------------------------------- def start_phase3 # フェーズ 3 に移行 @phase = 3 # アクターを非選択状態に設定 @actor_index = -1 @active_battler = nil # ★ 格闘場モード時 if $game_switches[RX_T_GAMBLE_MODE_NUM] # パーティコマンドウィンドウを無効化 @party_command_window.active = false @party_command_window.visible = false # ★ ギャンブルモードにする $rx_t_gamble_mode = true # ★ 賭けるエネミーをセレクト start_enemy_select else # 次のアクターのコマンド入力へ phase3_next_actor end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ) #-------------------------------------------------------------------------- def update_phase3 # エネミーアローが有効の場合 if @enemy_arrow != nil # ★ 格闘場モード時 if $game_switches[RX_T_GAMBLE_MODE_NUM] update_phase3_enemy_select_g else update_phase3_enemy_select end # アクターアローが有効の場合 elsif @actor_arrow != nil update_phase3_actor_select # スキルウィンドウが有効の場合 elsif @skill_window != nil update_phase3_skill_select # アイテムウィンドウが有効の場合 elsif @item_window != nil update_phase3_item_select # アクターコマンドウィンドウが有効の場合 elsif @actor_command_window.active update_phase3_basic_command end end #-------------------------------------------------------------------------- # ★ フレーム更新 (アクターコマンドフェーズ(格闘場モード) : エネミー選択) #-------------------------------------------------------------------------- def update_phase3_enemy_select_g # エネミーアローを更新 $rx_t_g_target_index = @enemy_arrow.index @enemy_arrow.update # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # エネミーの選択を終了 end_enemy_select start_phase2 end # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 # ★ ターゲットに賭け対象にするためのステートを付与する $game_troop.enemies[@enemy_arrow.index].add_state(RX_T_GAMBLE_TARGET_ST_NUM) # エネミーの選択を終了 end_enemy_select # ★ パーティー全員を観戦モードに for actor in $game_party.actors actor.add_state(RX_T_WATCHING_STATE_NUM) end # メインフェーズ開始 start_phase4 end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始) #-------------------------------------------------------------------------- def update_phase4_step2 # 強制アクションでなければ unless @active_battler.current_action.forcing # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合 if @active_battler.restriction == 2 or @active_battler.restriction == 3 # アクションに攻撃を設定 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 end # 制約が [行動できない] の場合 if @active_battler.restriction == 4 # アクション強制対象のバトラーをクリア $game_temp.forcing_battler = nil # ステップ 1 に移行 @phase4_step = 1 return end end # 対象バトラーをクリア @target_battlers = [] # アクションの種別で分岐 case @active_battler.current_action.kind when 0 # 基本 # ★ 格闘場モード時 if $game_switches[RX_T_GAMBLE_MODE_NUM] make_basic_action_result_g else make_basic_action_result end when 1 # スキル make_skill_action_result when 2 # アイテム make_item_action_result end # ステップ 3 に移行 if @phase4_step == 2 @phase4_step = 3 end end #-------------------------------------------------------------------------- # ★ 基本アクション 結果作成(格闘場モード時) #-------------------------------------------------------------------------- def make_basic_action_result_g # 攻撃の場合 if @active_battler.current_action.basic == 0 # アニメーション ID を設定 @animation1_id = @active_battler.animation1_id @animation2_id = @active_battler.animation2_id # 行動側バトラーがエネミーの場合 if @active_battler.is_a?(Game_Enemy) if @active_battler.restriction == 3 target = $game_troop.random_target_enemy elsif @active_battler.restriction == 2 index = @active_battler.current_action.target_index # ★ 誤選択防止1・エラー回避 unless index < $game_troop.enemies.size index = $game_troop.enemies.size - 1 end target_hp = $game_troop.enemies[index].hp # ★ 誤選択防止2・自分またはHP0の相手を攻撃しない while index == @active_battler.index or target_hp == 0 # ターゲットを再定義 index = rand($game_troop.enemies.size) # 再定義されたターゲットのHPを求める target_hp = $game_troop.enemies[index].hp end target = $game_troop.smooth_target_enemy(index) else index = @active_battler.current_action.target_index # ★ 誤選択防止1・エラー回避 unless index < $game_troop.enemies.size index = $game_troop.enemies.size - 1 end target_hp = $game_troop.enemies[index].hp # ★ 誤選択防止2・自分またはHP0の相手を攻撃しない while index == @active_battler.index or target_hp == 0 # ターゲットを再定義 index = rand($game_troop.enemies.size) # 再定義されたターゲットのHPを求める target_hp = $game_troop.enemies[index].hp end target = $game_troop.smooth_target_enemy(index) end end # 行動側バトラーがアクターの場合 if @active_battler.is_a?(Game_Actor) if @active_battler.restriction == 3 target = $game_party.random_target_actor elsif @active_battler.restriction == 2 target = $game_troop.random_target_enemy else index = @active_battler.current_action.target_index target = $game_troop.smooth_target_enemy(index) end end # 対象側バトラーの配列を設定 @target_battlers = [target] # 通常攻撃の効果を適用 for target in @target_battlers target.attack_effect(@active_battler) end return end # 防御の場合 if @active_battler.current_action.basic == 1 # ヘルプウィンドウに "防御" を表示 @help_window.set_text($data_system.words.guard, 1) return end # 逃げるの場合 if @active_battler.is_a?(Game_Enemy) and @active_battler.current_action.basic == 2 # ヘルプウィンドウに "逃げる" を表示 @help_window.set_text("逃げる", 1) # 逃げる @active_battler.escape return end # 何もしないの場合 if @active_battler.current_action.basic == 3 # アクション強制対象のバトラーをクリア $game_temp.forcing_battler = nil # ステップ 1 に移行 @phase4_step = 1 return end end #-------------------------------------------------------------------------- # ★ スキルまたはアイテムの対象側バトラー設定(格闘場モード時) # scope : スキルまたはアイテムの効果範囲 #-------------------------------------------------------------------------- def set_target_battlers_g(scope) # 行動側バトラーがエネミーの場合 if @active_battler.is_a?(Game_Enemy) # 効果範囲で分岐 case scope when 1 # 敵単体 index = @active_battler.current_action.target_index # ★ 誤選択防止1・エラー回避 unless index < $game_troop.enemies.size index = $game_troop.enemies.size - 1 end target_hp = $game_troop.enemies[index].hp # ★ 誤選択防止2・自分またはHP0の相手を攻撃しない while index == @active_battler.index or target_hp == 0 # ターゲットを再定義 index = rand($game_troop.enemies.size) # 再定義されたターゲットのHPを求める target_hp = $game_troop.enemies[index].hp end @target_battlers.push($game_troop.smooth_target_enemy(index)) when 2 # 敵全体 for enemy in $game_troop.enemies # ★ ターゲットが生存しているか、自分がターゲットになっていない場合 if enemy.exist? and enemy.index != @active_battler.index @target_battlers.push(enemy) end end when 3 # 味方単体 @target_battlers.push(@active_battler) when 4 # 味方全体 @target_battlers.push(@active_battler) when 5 # 味方単体 (HP 0) when 6 # 味方全体 (HP 0) when 7 # 使用者 @target_battlers.push(@active_battler) end end # 行動側バトラーがアクターの場合 if @active_battler.is_a?(Game_Actor) # 効果範囲で分岐 case scope when 1 # 敵単体 index = @active_battler.current_action.target_index @target_battlers.push($game_troop.smooth_target_enemy(index)) when 2 # 敵全体 for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 3 # 味方単体 index = @active_battler.current_action.target_index @target_battlers.push($game_party.smooth_target_actor(index)) when 4 # 味方全体 for actor in $game_party.actors if actor.exist? @target_battlers.push(actor) end end when 5 # 味方単体 (HP 0) index = @active_battler.current_action.target_index actor = $game_party.actors[index] if actor != nil and actor.hp0? @target_battlers.push(actor) end when 6 # 味方全体 (HP 0) for actor in $game_party.actors if actor != nil and actor.hp0? @target_battlers.push(actor) end end when 7 # 使用者 @target_battlers.push(@active_battler) end end end #-------------------------------------------------------------------------- # ● スキルアクション 結果作成 #-------------------------------------------------------------------------- def make_skill_action_result # スキルを取得 @skill = $data_skills[@active_battler.current_action.skill_id] # 強制アクションでなければ unless @active_battler.current_action.forcing # SP 切れなどで使用できなくなった場合 unless @active_battler.skill_can_use?(@skill.id) # アクション強制対象のバトラーをクリア $game_temp.forcing_battler = nil # ステップ 1 に移行 @phase4_step = 1 return end end # SP 消費 @active_battler.sp -= @skill.sp_cost # ステータスウィンドウをリフレッシュ @status_window.refresh # ヘルプウィンドウにスキル名を表示 @help_window.set_text(@skill.name, 1) # アニメーション ID を設定 @animation1_id = @skill.animation1_id @animation2_id = @skill.animation2_id # コモンイベント ID を設定 @common_event_id = @skill.common_event_id # ★ 格闘場モード時 if $game_switches[RX_T_GAMBLE_MODE_NUM] # 対象側バトラーを設定 set_target_battlers_g(@skill.scope) else # 対象側バトラーを設定 set_target_battlers(@skill.scope) end # スキルの効果を適用 for target in @target_battlers target.skill_effect(@active_battler, @skill) end end end