#============================================================================== # ■ Numset #------------------------------------------------------------------------------ #  定数を扱うモジュールです。 #============================================================================== module Numset Numset::ACTORS_NAME = "味方" # 味方全体を指す場合のヘルプ Numset::ENEMIES_NAME = "敵" # 敵全体を指す場合のヘルプ Numset::ALL_NAME = "全員" # 対象全体を指す場合のヘルプ end #============================================================================== # ■ Arrow_Base #------------------------------------------------------------------------------ #  バトル画面で使用するアローカーソル表示用のスプライトです。このクラスは # Arrow_Enemy クラスと Arrow_Actor クラスのスーパークラスとして使用されます。 #============================================================================== class Arrow_Base < Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :index # カーソル位置 attr_reader :help_window # ヘルプウィンドウ attr_reader :mode # サイド #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート #-------------------------------------------------------------------------- def initialize(viewport, mode) super(viewport) self.bitmap = RPG::Cache.windowskin($game_system.windowskin_name) self.ox = 16 self.oy = 32 self.z = 2500 @mode = mode @blink_count = 0 @index = 0 @help_window = nil update end end #============================================================================== # ■ Arrow_Single #------------------------------------------------------------------------------ #  単体を選択させるためのアローカーソルです。このクラスは Arrow_Base クラ # スを継承します。 #============================================================================== class Arrow_Single < Arrow_Base #-------------------------------------------------------------------------- # ● カーソルが指しているバトラーの取得 #-------------------------------------------------------------------------- def battler if @mode return $game_troop.enemies[@index] else return $game_party.actors[@index] end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super if @mode # 存在しないエネミーを指していたら飛ばす $game_troop.enemies.size.times do break if self.battler.exist? @index += 1 @index %= $game_troop.enemies.size end # カーソル上 if Input.repeat?(Input::UP) $game_system.se_play($data_system.cursor_se) $game_troop.enemies.size.times do @index += 1 @index %= $game_troop.enemies.size break if self.battler.exist? end end # カーソル下 if Input.repeat?(Input::DOWN) $game_system.se_play($data_system.cursor_se) $game_troop.enemies.size.times do @index += $game_troop.enemies.size - 1 @index %= $game_troop.enemies.size break if self.battler.exist? end end else # 存在しないエネミーを指していたら飛ばす $game_party.actors.size.times do if self.battler.exist? break else if $scene.active_battler.current_action.kind == 1 and $data_skills[$scene.active_battler.current_action.skill_id].scope == 5 break elsif $scene.active_battler.current_action.kind == 2 and $data_items[$scene.active_battler.current_action.item_id].scope == 5 break else @index += 1 @index %= $game_party.actors.size end end end # カーソル上 if Input.repeat?(Input::UP) $game_system.se_play($data_system.cursor_se) $game_party.actors.size.times do if self.battler.exist? @index += 1 @index %= $game_party.actors.size break else if $scene.active_battler.current_action.kind == 1 and $data_skills[$scene.active_battler.current_action.skill_id].scope == 5 break elsif $scene.active_battler.current_action.kind == 2 and $data_items[$scene.active_battler.current_action.item_id].scope == 5 break else @index += 1 @index %= $game_party.actors.size end end end end # カーソル下 if Input.repeat?(Input::DOWN) $game_system.se_play($data_system.cursor_se) $game_party.actors.size.times do if self.battler.exist? @index += ($game_party.actors.size - 1) @index %= $game_party.actors.size break else if $scene.active_battler.current_action.kind == 1 and $data_skills[$scene.active_battler.current_action.skill_id].scope == 5 break elsif $scene.active_battler.current_action.kind == 2 and $data_items[$scene.active_battler.current_action.item_id].scope == 5 break else @index += ($game_party.actors.size - 1) @index %= $game_party.actors.size end end end end end # カーソル横 if Input.repeat?(Input::LEFT) or Input.repeat?(Input::RIGHT) $game_system.se_play($data_system.cursor_se) if @mode @mode = false if @index >= $game_party.actors.size @index %= $game_party.actors.size unless $scene.active_battler.current_action.kind != 1 and $data_skills[$scene.active_battler.current_action.skill_id].scope != 5 unless $scene.active_battler.current_action.kind != 2 and $data_items[$scene.active_battler.current_action.item_id].scope != 5 $game_party.actors.size.times do @index += $game_party.actors.size - 1 @index %= $game_party.actors.size break if self.battler.exist? end end end end else @mode = true if @index >= $game_troop.enemies.size @index %= $game_troop.enemies.size unless $scene.active_battler.current_action.kind != 1 and $data_skills[$scene.active_battler.current_action.skill_id].scope != 5 unless $scene.active_battler.current_action.kind != 2 and $data_items[$scene.active_battler.current_action.item_id].scope != 5 $game_party.actors.size.times do @index += $game_party.actors.size - 1 @index %= $game_party.actors.size break if self.battler.exist? end end end end end end # スプライトの座標を設定 if self.battler != nil self.x = self.battler.screen_x self.y = self.battler.screen_y end end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help if @mode # ヘルプウィンドウにエネミーの名前とステートを表示 @help_window.set_enemy(self.battler) else # ヘルプウィンドウにアクターのステータスを表示 @help_window.set_actor(self.battler) end end end #============================================================================== # ■ Arrow_All #------------------------------------------------------------------------------ #  サイドを選択させるためのアローカーソルです。このクラスは Arrow_Base クラ # スを継承します。 #============================================================================== class Arrow_All < Arrow_Base #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # カーソル if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::LEFT) $game_system.se_play($data_system.cursor_se) @mode ^= true end size = 0 arrow_x = 0 if @mode for battler in $game_troop.enemies if battler.exist? arrow_x += battler.screen_x size += 1 end end else for battler in $game_party.actors arrow_x += battler.screen_x size += 1 end end arrow_x /= size # スプライトの座標を設定 self.x = arrow_x self.y = 300 end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text((@mode ? Numset::ENEMIES_NAME : Numset::ACTORS_NAME), 1) end end #============================================================================== # ■ Arrow_Freeze #------------------------------------------------------------------------------ #  固定されたアローカーソルです。このクラスは Arrow_Base クラ # スを継承します。 #============================================================================== class Arrow_Freeze < Arrow_Base #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # スプライトの座標を設定 if @mode == true self.x = $scene.active_battler.screen_x self.y = $scene.active_battler.screen_y else self.x = arrow_x self.y = 300 end end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text((@mode ? $scene.active_battler.name : Numset::ALL_NAME), 1) end end end #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ) #-------------------------------------------------------------------------- def update_phase3 # シングルアローが有効の場合 if @single_arrow != nil update_phase3_battler_select # オールアローが有効の場合 elsif @all_arrow != nil update_phase3_battler_select # フリーズアローが有効の場合 elsif @freeze_arrow != nil update_phase3_battler_select # スキルウィンドウが有効の場合 elsif @skill_window != nil update_phase3_skill_select # アイテムウィンドウが有効の場合 elsif @item_window != nil update_phase3_item_select # アクターコマンドウィンドウが有効の場合 else update_phase3_basic_command end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド) #-------------------------------------------------------------------------- def update_phase3_basic_command # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # 前のアクターのコマンド入力へ phase3_prior_actor return end # C ボタンが押された場合 if Input.trigger?(Input::C) # アクターコマンドウィンドウのカーソル位置で分岐 case @actor_command_window.index when 0 # 攻撃 # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 # 選択を開始 start_battler_select when 1 # スキル # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_battler.current_action.kind = 1 # スキルの選択を開始 start_skill_select when 2 # 防御 # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 1 # 次のアクターのコマンド入力へ phase3_next_actor when 3 # アイテム # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_battler.current_action.kind = 2 # アイテムの選択を開始 start_item_select end return end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : スキル選択) #-------------------------------------------------------------------------- def update_phase3_skill_select # スキルウィンドウを可視状態にする @skill_window.visible = true # スキルウィンドウを更新 @skill_window.update # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # スキルの選択を終了 end_skill_select return end # C ボタンが押された場合 if Input.trigger?(Input::C) # スキルウィンドウで現在選択されているデータを取得 @skill = @skill_window.skill # 使用できない場合 if @skill == nil or not @active_battler.skill_can_use?(@skill.id) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_battler.current_action.skill_id = @skill.id # スキルウィンドウを不可視状態にする @skill_window.visible = false # どちらにしろ選択を開始 start_battler_select return end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : アイテム選択) #-------------------------------------------------------------------------- def update_phase3_item_select # アイテムウィンドウを可視状態にする @item_window.visible = true # アイテムウィンドウを更新 @item_window.update # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # アイテムの選択を終了 end_item_select return end # C ボタンが押された場合 if Input.trigger?(Input::C) # アイテムウィンドウで現在選択されているデータを取得 @item = @item_window.item # 使用できない場合 unless $game_party.item_can_use?(@item.id) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_battler.current_action.kind = 2 @active_battler.current_action.item_id = @item.id # アイテムウィンドウを不可視状態にする @item_window.visible = false # どちらにしろ選択を開始 start_battler_select return end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : バトラー選択) #-------------------------------------------------------------------------- def update_phase3_battler_select # アローを更新 if @single_arrow != nil @single_arrow.update elsif @all_arrow != nil @all_arrow.update elsif @freeze_arrow != nil @freeze_arrow.update end # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # バトラーの選択を中断 end_battler_select return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 if @single_arrow != nil @active_battler.current_action.target_index = @single_arrow.index end # バトラーの選択を終了 end_battler_select # スキルウィンドウ表示中の場合 if @skill_window != nil # スキルの選択を終了 end_skill_select end # アイテムウィンドウ表示中の場合 if @item_window != nil # アイテムの選択を終了 end_item_select end # 次のアクターのコマンド入力へ phase3_next_actor end end #-------------------------------------------------------------------------- # ● バトラー選択開始 #-------------------------------------------------------------------------- def start_battler_select # スコープを作成 if Game_BattleAction.method_defined?("scope_force") and @active_battler.current_action.scope_force != 0 scope = @active_battler.current_action.scope_force else case @active_battler.current_action.kind when 0 scope = 1 when 1 scope = @skill.scope when 2 scope = @item.scope end end # アロー号事件 case scope when 1 # 敵単体 @single_arrow = Arrow_Single.new(@spriteset.viewport1, true) when 2 # 敵全体 @all_arrow = Arrow_All.new(@spriteset.viewport1, true) when 3 # 味方単体 @single_arrow = Arrow_Single.new(@spriteset.viewport1, false) when 4 # 味方全体 @all_arrow = Arrow_All.new(@spriteset.viewport1, false) when 5 # 戦闘不能の味方単体 @single_arrow = Arrow_Single.new(@spriteset.viewport1, false) when 6 # 戦闘不能の味方全体 @all_arrow = Arrow_All.new(@spriteset.viewport1, false) when 7 # 自分自身 @freeze_arrow = Arrow_Freeze.new(@spriteset.viewport1, true) when 8 # 敵味方全体 @freeze_arrow = Arrow_Freeze.new(@spriteset.viewport1, false) when 9 # 敵ランダム @all_arrow = Arrow_All.new(@spriteset.viewport1, true) when 10 # 味方ランダム @all_arrow = Arrow_All.new(@spriteset.viewport1, false) when 11 # 敵味方ランダム @freeze_arrow = Arrow_Freeze.new(@spriteset.viewport1, false) when 12 # 全体化 case @active_battler.current_action.kind when 0 scope = 1 when 1 scope = @skill.scope when 2 scope = @item.scope end case scope when 1, 2 @all_arrow = Arrow_All.new(@spriteset.viewport1, true) when 3, 4 @all_arrow = Arrow_All.new(@spriteset.viewport1, false) when 5, 6 @all_arrow = Arrow_All.new(@spriteset.viewport1, false) end end # ヘルプウィンドウを関連付け if @single_arrow != nil @single_arrow.help_window = @help_window elsif @all_arrow != nil @all_arrow.help_window = @help_window elsif @freeze_arrow != nil @freeze_arrow.help_window = @help_window end # アクターコマンドウィンドウを無効化 @actor_command_window.active = false @actor_command_window.visible = false end #-------------------------------------------------------------------------- # ● バトラー選択終了 #-------------------------------------------------------------------------- def end_battler_select if @single_arrow != nil @single_arrow.dispose @single_arrow = nil elsif @all_arrow != nil @all_arrow.dispose @all_arrow = nil elsif @freeze_arrow != nil @freeze_arrow.dispose @freeze_arrow = nil end # ヘルプウィンドウを隠す @help_window.visible = false # コマンドが [戦う] の場合 if @actor_command_window.index == 0 # アクターコマンドウィンドウを有効化 @actor_command_window.active = true @actor_command_window.visible = true end end #-------------------------------------------------------------------------- # ● スキルまたはアイテムの対象側バトラー設定 # scope : スキルまたはアイテムの効果範囲 #-------------------------------------------------------------------------- def set_target_battlers(scope) if Game_BattleAction.method_defined?("scope_force") and @active_battler.current_action.scope_force != 0 # 強引に切り替え if @active_battler.current_action.scope_force == 12 case scope when 1, 2 scope = 2 when 3, 3 scope = 4 when 5, 6 scope = 6 end else scope = @active_battler.current_action.scope_force end end # 行動側バトラーがエネミーの場合 if @active_battler.is_a?(Game_Enemy) # 効果範囲で分岐 case scope when 1 # 敵単体 index = battler.current_action.target_index @target_battlers.push($game_party.smooth_target_actor(index)) when 2 # 敵全体 for actor in $game_party.actors if actor.exist? @target_battlers.push(actor) end end when 3 # 味方単体 index = battler.current_action.target_index @target_battlers.push($game_troop.smooth_target_enemy(index)) when 4 # 味方全体 for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 5 # 味方単体 (HP 0) index = battler.current_action.target_index @target_battlers.push($game_troop.enemies[index]) when 6 # 味方全体 (HP 0) for enemy in $game_troop.enemies if enemy != nil @target_battlers.push(enemy) end end when 7 # 使用者 @target_battlers.push(battler) when 8, 11 # 敵味方全体、敵味方ランダム @target_battlers = [] for battler in $game_party.actors + $game_troop.enemies @target_battlers.push(battler) if battler.exist? end # 自分以外 if @active_battler.current_action.self_exclusion @target_battlers -= [@active_battler] end # 対象ランダムの場合は一体に絞る if scope == 11 @target_battlers = [@target_battlers[rand(@target_battlers.size)]] end when 9 # 敵ランダム targets = [] for actor in $game_party.actors targets.push(actor) if actor.exist? end @target_battlers = [targets[rand(targets.size)]] when 10 # 味方ランダム targets = [] for enemy in $game_troop.enemies if enemy.exist? unless @active_battler.current_action.self_exclusion and enemy == @active_battler targets.push(enemy) end end end @target_battlers = [targets[rand(targets.size)]] end end # 行動側バトラーがアクターの場合 if @active_battler.is_a?(Game_Actor) # 効果範囲で分岐 case scope when 1, 3, 5 # 単体 index = battler.current_action.target_index if @single_arrow.mode @target_battlers.push($game_troop.smooth_target_enemy(index)) else @target_battlers.push($game_party.smooth_target_actor(index)) end when 2, 4, 6 # 全体 if @all_arrow.mode for target in $game_troop.enemies if target.exist? @target_battlers.push(target) end end else for target in $game_party.actors if target.exist? @target_battlers.push(target) end end end when 7 # 使用者 @target_battlers.push(battler) when 8, 11 # 敵味方全体、敵味方ランダム @target_battlers = [] for battler in $game_party.actors + $game_troop.enemies @target_battlers.push(battler) if battler.exist? end # 自分以外 if @active_battler.current_action.self_exclusion @target_battlers -= [@active_battler] end # 対象ランダムの場合は一体に絞る if scope == 11 @target_battlers = [@target_battlers[rand(@target_battlers.size)]] end when 9, 10 # ランダム if @all_arrow.mode for target in $game_troop.enemies if target.exist? targets.push(target) end end else for target in $game_party.actors if target.exist? targets.push(target) end end end @target_battlers = [targets[rand(targets.size)]] end end end end