#============================================================================== # ■ Game_Battler #------------------------------------------------------------------------------ #  バトラーを扱うクラスです。このクラスは Game_Actor クラスと Game_Enemy クラ # スのスーパークラスとして使用されます。 #============================================================================== class Game_Battler #include(Game_Target) #-------------------------------------------------------------------------- # ● 自動行動 (アクション決定) #-------------------------------------------------------------------------- def auto_action_set for i in @states if $data_states[i].restriction == 2 or $data_states[i].restriction == 3 state_name = $data_states[i].name break end end case state_name when "混乱" # 通常攻撃のみ @current_action.kind = 0 @current_action.basic = 0 when "ブースト" # 通常攻撃のみ @current_action.kind = 0 @current_action.basic = 0 when "ヴァリー" # 一番威力が高く、使え、ある程度ダメージの見込みがある魔法を使う set = (self.is_a?(Game_Actor) ? $game_troop.enemies : $game_party.actors) targets = sort.select{|battler| battler.exist } sort = @skills.select{|id| if $data_skills[id].scope == 1 or $data_skills[id].scope == 2 magic = Numset.const_defined?("MAGIC") ? Numset::MAGIC : XRXS19::MAGIC if XRXS.element_include?($data_skills[id].element_set, magic) and self.skill_can_use?(id) # 平均抵抗力が50以上の場合、候補から外す rate = 0 if $data_skills[id].scope == 1 for battler in targets rate = [rate, battler.elements_correct(self.skill_element_set($data_skills[id]))].max end rate <= 50 elsif $data_skills[id].scope == 2 for battler in targets rate += battler.elements_correct(self.skill_element_set($data_skills[id])) end rate > (50 * target.size) end else false end else false end } if sort != [] @current_action.kind = 1 sort.sort{|a, b| if ($data_skills[a].power <=> $data_skills[b].power) == 0 rand(2) == 0 ? 1 : -1 else $data_skills[a].power <=> $data_skills[b].power end } @current_action.skill_id = sort.last else @current_action.kind = 0 @current_action.basic = 0 end end end #-------------------------------------------------------------------------- # ● 自動行動 (ターゲット決定) #-------------------------------------------------------------------------- def auto_target_set for i in @states if $data_states[i].restriction == 2 or $data_states[i].restriction == 3 state_name = $data_states[i].name break end end case state_name when "混乱" # 自分を除く誰かを指定 set = $game_party.actors + $game_troop.enemies - [self] targets = set.select{|battler| not battler.exist } @target_battler = [targets[rand(set.size)]] when "ブースト" # 最も残りHPが少ない敵を指定 set = (self.is_a?(Game_Actor) ? $game_troop.enemies : $game_party.actors) targets = sort.select{|battler| battler.exist } sort = targets.sort{|a, b| if a.hp == b.hp -(a.maxhp) <=> -(b.maxhp) else a.hp <=> b.hp end } @target_battler = [sort[0]] when "ヴァリー" # 対象が単体の場合、最も属性抵抗力が低い敵に攻撃 skill = $data_skills[@current_action.skill_id] targets = (self.is_a?(Game_Actor)) ? $game_troop.enemies : $game_party.actors if skill.scope == 1 sort = targets.select{|battler| battler.exist } sort.sort{|a, b| if (a.elements_correct(self.skill_element_set(skill)) <=> b.elements_correct(self.skill_element_set(skill))) == 0 rand(2) == 0 ? 1 : -1 else a.elements_correct(self.skill_element_set(skill)) <=> b.elements_correct(self.skill_element_set(skill)) end } @target_battler = [sort.last] end end end end #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始) #-------------------------------------------------------------------------- def update_phase4_step2 # 対象バトラーをクリア @target_battlers = [] # 強制アクションでなければ unless @active_battler.current_action.forcing # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合 if @active_battler.restriction == 2 or @active_battler.restriction == 3 # アクションセット @active_battler.auto_action_set end # 制約が [行動できない] の場合 if @active_battler.restriction == 4 # アクション強制対象のバトラーをクリア $game_temp.forcing_battler = nil # ステップ 1 に移行 @phase4_step = 1 return end end # アクションの種別で分岐 case @active_battler.current_action.kind when 0 # 基本 make_basic_action_result when 1 # スキル make_skill_action_result when 2 # アイテム make_item_action_result end # ステップ 3 に移行 if @phase4_step == 2 @phase4_step = 3 end end # ScopeExとの併用化のため、再定義するメソッドも分岐 if Scene_Battle.method_defined?("make_basic_action_target_set") #-------------------------------------------------------------------------- # ○ 基本アクションのターゲット配列作成 #-------------------------------------------------------------------------- def make_basic_action_target_set # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合 if @active_battler.restriction == 2 or @active_battler.restriction == 3 @active_battler.auto_target_set set_target_battlers(1) return else # 行動側バトラーがエネミーの場合 if @active_battler.is_a?(Game_Enemy) # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合 set_target_battlers(1) return # 行動側バトラーがアクターの場合 elsif @active_battler.is_a?(Game_Actor) set_target_battlers(1) return end end # 対象側バトラーの配列を設定 @target_battlers = [target] end else #-------------------------------------------------------------------------- # ● 基本アクション 結果作成 #-------------------------------------------------------------------------- def make_basic_action_result # 攻撃の場合 if @active_battler.current_action.basic == 0 # アニメーション ID を設定 @animation1_id = @active_battler.animation1_id @animation2_id = @active_battler.animation2_id # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合 if @active_battler.restriction == 2 or @active_battler.restriction == 3 @target_battlers = @active_battler.auto_target_set else # 行動側バトラーがエネミーの場合 if @active_battler.is_a?(Game_Enemy) index = @active_battler.current_action.target_index @target_battlers = [$game_party.smooth_target_actor(index)] # 行動側バトラーがアクターの場合 elsif @active_battler.is_a?(Game_Actor) index = @active_battler.current_action.target_index @target_battlers = [$game_troop.smooth_target_enemy(index)] end end # 通常攻撃の効果を適用 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 end #-------------------------------------------------------------------------- # ● スキルアクション 結果作成 #-------------------------------------------------------------------------- alias xrxs69_make_skill_action_result make_skill_action_result def make_skill_action_result # スキルを取得 @skill = $data_skills[@active_battler.current_action.skill_id] # 使用するスキルの特殊効果の取得 @active_battler.set_xrxs69_special_scope(@active_battler.skill_element_set(@skill)) # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合 if @active_battler.restriction == 2 or @active_battler.restriction == 3 @target_battlers = @active_battler.auto_target_set end # 呼び戻す xrxs69_make_skill_action_result end #-------------------------------------------------------------------------- # ● アイテムアクション 結果作成 #-------------------------------------------------------------------------- alias xrxs69_make_item_action_result make_item_action_result def make_item_action_result # アイテムを取得 @item = $data_items[@active_battler.current_action.item_id] # アイテム切れなどで使用できなくなった場合 unless $game_party.item_can_use?(@item.id) # 呼び戻す xrxs69_make_item_action_result return end # 特殊効果の設定 @active_battler.set_xrxs69_special_scope(@item.element_set) # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合 if @active_battler.restriction == 2 or @active_battler.restriction == 3 @target_battlers = @active_battler.auto_target_set end # 呼び戻す xrxs69_make_item_action_result end #-------------------------------------------------------------------------- # ● スキルまたはアイテムの対象側バトラー設定 #-------------------------------------------------------------------------- alias :base_set_target_battlers :set_target_battlers def set_target_battlers(scope) base_set_target_battlers if target == [] end end