Permanent
Creation

RPGツクールXP/VX用のRGSS素材です。
一部英語版対応です。 (A few materials can be used for English RPG MAKER XP/VX.)
競合率はルファーの独断と偏見なのでたまにハズレます。


#==============================================================================
# ■ ダブルプレイヤーモード (分割定義 8)
#------------------------------------------------------------------------------
#  2 つのデータを読み込んで対戦するシーンクラスの定義です。
# ゲーム内で使うには、 $scene = Scene_DoublePlayersLoad.new というスクリプトを
# どこかに挿入する必要があります。
# (C) ルファー
# HP  https://tkoolerlufar.pages.dev/
#==============================================================================

#----------------------------------------------------------------------------
# ◆ Scene_DoublePlayersBattle クラス
#----------------------------------------------------------------------------
class Scene_DoublePlayersBattle
  #--------------------------------------------------------------------------
  # ● メインフェーズ開始
  #--------------------------------------------------------------------------
  def start_phase3
    @phase = 3
    $game_temp.battle_turn += 1
    @actor_index = -1
    @active_battler = nil
    @command_window.mode = 0
    @command_window.help_window = nil
    $game_temp.battle_main_phase = true
    make_action_orders
    @phase3_step = 1
  end
  #--------------------------------------------------------------------------
  # ● 行動順序作成
  #--------------------------------------------------------------------------
  def make_action_orders
    @action_battlers = []
    for i in 0..1
      for battler in $game_doubleplayers[i].actors
        @action_battlers.push(battler)
      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
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ)
  #--------------------------------------------------------------------------
  def update_phase3
    case @phase3_step
    when 1
      update_phase3_step1
    when 2
      update_phase3_step2
    when 3
      update_phase3_step3
    when 4
      update_phase3_step4
    when 5
      update_phase3_step5
    when 6
      update_phase3_step6
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 1 : アクション準備)
  #--------------------------------------------------------------------------
  def update_phase3_step1
    @help_window.set_text("")
    if judge
      return
    end
    if @action_battlers.size == 0
      start_phase2
      return
    end
    @animation1_id = 0
    @animation2_id = 0
    @active_battler = @action_battlers.shift
    if @active_battler.index == nil
      return
    end
    @allies_player_index = @active_battler.player_index
    @enemies_player_index = @active_battler.player_index ^ 1
    if @active_battler.hp > 0 and @active_battler.slip_damage?
      @active_battler.slip_damage_effect
      @active_battler.damage_pop = true
    end
    @active_battler.remove_states_auto
    @p1_status_window.refresh
    @p2_status_window.refresh
    @phase3_step = 2
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  #--------------------------------------------------------------------------
  def update_phase3_step2
    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
      @phase3_step = 1
      return
    end
    @target_battlers = []
    if @active_battler.current_action.kind == 0
      make_basic_action_result
    else
      make_skill_action_result
    end
    if @phase3_step == 2
      @phase3_step = 3
    end
  end
  #--------------------------------------------------------------------------
  # ● 基本アクション 結果作成
  #--------------------------------------------------------------------------
  def make_basic_action_result
    if @active_battler.current_action.basic == 0
      @animation1_id = @active_battler.animation1_id
      @animation2_id = @active_battler.animation2_id
      if @active_battler.restriction == 3
        target =
          $game_doubleplayers[@allies_player_index].random_target_actor
      elsif @active_battler.restriction == 2
        target =
          $game_doubleplayers[@enemies_player_index].random_target_actor
      else
        target =
          $game_doubleplayers[@enemies_player_index].smooth_target_actor(
            @active_battler.current_action.target_index)
      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.current_action.basic == 3
      $game_temp.forcing_battler = nil
      @phase3_step = 1
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● スキルの対象側バトラー設定
  #     scope : スキルの効果範囲
  #--------------------------------------------------------------------------
  def set_target_battlers(scope)
    case scope
    when 1
      index = @active_battler.current_action.target_index
      @target_battlers.push(
        $game_doubleplayers[@enemies_player_index].smooth_target_actor(
          index))
    when 2
      for actor in $game_doubleplayers[@enemies_player_index].actors
        @target_battlers.push(actor) if actor.exist?
      end
    when 3
      index = @active_battler.current_action.target_index
      @target_battlers.push(
        $game_doubleplayers[@allies_player_index].smooth_target_actor(index))
    when 4
      for actor in $game_doubleplayers[@allies_player_index].actors
        @target_battlers.push(actor) if actor.exist?
      end
    when 5
      index = @active_battler.current_action.target_index
      actor = $game_doubleplayers[@allies_player_index].actors[index]
      @target_battlers.push(actor) if actor != nil and actor.hp0?
    when 6
      for actor in $game_doubleplayers[@allies_player_index].actors
        @target_battlers.push(actor) if actor != nil and actor.hp0?
      end
    when 7
      @target_battlers.push(@active_battler)
    end
  end
  #--------------------------------------------------------------------------
  # ● スキルアクション 結果作成
  #--------------------------------------------------------------------------
  def make_skill_action_result
    @skill = $data_skills[@active_battler.current_action.skill_id]
    unless @active_battler.skill_can_use?(@skill.id)
      $game_temp.forcing_battler = nil
      @phase3_step = 1
      return
    end
    @active_battler.sp -= @skill.sp_cost
    @p1_status_window.refresh
    @p2_status_window.refresh
    @help_window.set_text(@skill.name, 1)
    @animation1_id = @skill.animation1_id
    @animation2_id = @skill.animation2_id
    @common_event_id = @skill.common_event_id
    set_target_battlers(@skill.scope)
    for target in @target_battlers
      target.skill_effect(@active_battler, @skill)
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 3 : 行動側アニメーション)
  #--------------------------------------------------------------------------
  def update_phase3_step3
    if @animation1_id == 0
      @active_battler.white_flash = true
    else
      @active_battler.animation_id = @animation1_id
      @active_battler.animation_hit = true
    end
    @phase3_step = 4
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション)
  #--------------------------------------------------------------------------
  def update_phase3_step4
    for target in @target_battlers
      target.animation_id = @animation2_id
      target.animation_hit = target.damage != "Miss"
    end
    @wait_count = 8
    @phase3_step = 5
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  #--------------------------------------------------------------------------
  def update_phase3_step5
    @help_window.set_text("")
    @p1_status_window.refresh
    @p2_status_window.refresh
    for target in @target_battlers
      target.damage_pop = true if target.damage != nil
    end
    @phase3_step = 6
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
  #--------------------------------------------------------------------------
  def update_phase3_step6
    $game_temp.forcing_battler = nil
    @phase3_step = 1
  end
end

戻る