全体化カスタム



改造内容:
・スキル、アイテムだけでなく、防具の属性でも判定を可能に
・全体/個別化用キーをカスタマイズ可能に

※このスクリプトの原作者はTOMY様です。

※以下のモジュールが別途導入必要です。
 VXA風SE

変更点
2015:10:01
・VXA風Sound対応

#----------------------------------------------------------------------------
# 全体化 カスタム by 貪藻矢射妥←
# 微妙に使いづらいです・・・多分(をひ)
#----------------------------------------------------------------------------
# 原作:     ◆ 全体化 - KGC_FlexibleScope ◆
#           ◇ Last update : 2007/03/11 ◇
# 原作者:   TOMY様
# HP:       KGC Software
# アドレス: http://ytomy.sakura.ne.jp/
#
# 改造内容:
# ・スキル、アイテムだけでなく、防具の属性でも判定を可能に
# ・全体/個別化用キーをカスタマイズ可能に
# 
#============================================================================
# 変更点
# 2015:10:01
# ・VXA風Sound対応

#==============================================================================
# ★ カスタマイズ項目 ★
#==============================================================================

module KGC
  # ◆全体化時の効果量 【単位 : %】
  FS_WHOLE_POWER   = 75
  # ◆全体化時のSP消費量 【単位 : %】
  FS_WHOLE_SP_COST = 120

  # ◆敵全体を対象にしたときのヘルプ
  FS_WHOLE_HELP_ENEMY = "敵全体"
  # ◆味方全体を対象にしたときのヘルプ
  FS_WHOLE_HELP_ACTOR = "味方全体"
  
  # ◆全体/個別化用変更キー  
  CHANGE_KEY = [Input::X, Input::Y]
  
  # ◆全体化可能の属性ID
  ALLIZE_ID     = 66
  # ◆全体化不可能の属性ID
  ALLIZE_NOT_ID = 67
  
  # 全体化可能?
  def judg_flexible(scope, element_set)
    if [1, 3, 5].include?(scope)
      if element_set.include?(ALLIZE_NOT_ID)
        return false
      elsif element_set.include?(ALLIZE_ID)
        return true
      else
        return nil
      end
    else
      return false
    end
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

$imported = {} if $imported == nil
$imported["FlexibleScope"] = true


class Game_Actor < Game_Battler
  include KGC
  #--------------------------------------------------------------------------
  # ● 全体化可能
  #--------------------------------------------------------------------------
  def flexible_attack?
    # 属性防御による判定
    for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id, @armor5_id, 
              @armor6_id, @armor7_id]
      armor = $data_armors[i]
      if armor != nil && armor.guard_element_set.include?(ALLIZE_ID) && 
        !armor.guard_element_set.include?(ALLIZE_NOT_ID)
        return true
      end
    end
    # ここまで来て何もなければ全体化ではない。
    return false
  end
end

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ● 一律全体化不可能とする
  #--------------------------------------------------------------------------
  def flexible_attack?
    return false
  end
end

#==============================================================================
# ■ RPG::Item
#==============================================================================

class RPG::Item
  include KGC
  #--------------------------------------------------------------------------
  # ● 全体化可能
  #--------------------------------------------------------------------------
  def flexible?
    return judg_flexible(@scope, @element_set)
    #return [1, 3, 5].include?(@scope) &&
    #  @element_set.include?(ALLIZE_ID) &&
    #  !@element_set.include?(ALLIZE_NOT_ID)
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ RPG::Skill
#==============================================================================

class RPG::Skill
  include KGC
  #--------------------------------------------------------------------------
  # ● 全体化可能
  #--------------------------------------------------------------------------
  def flexible?
    return judg_flexible(@scope, @element_set)
    #return [1, 3, 5].include?(@scope) &&
    #  @element_set.include?(ALLIZE_ID) &&
    #  !@element_set.include?(ALLIZE_NOT_ID)
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Game_Battler (分割定義 1)
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :scope_changed            # 範囲切り替えフラグ
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias initialize_KGC_FlexibleScope initialize
  def initialize
    initialize_KGC_FlexibleScope

    @scope_changed = false
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Window_Target
#==============================================================================

class Window_Target < Window_Selectable
  include KGC
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :whole                    # 全体化フラグ
  attr_accessor :can_whole                # 全体化可能
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias initialize_KGC_FlexibleScope initialize
  def initialize
    initialize_KGC_FlexibleScope

    @whole = false
    @can_whole = false
    @last_index = self.index
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  if !method_defined?(:update_KGC_FlexibleScope)
    alias update_KGC_FlexibleScope update
  end
  def update
    update_KGC_FlexibleScope

    # 全体/単体切り替え
    if @can_whole && (Input.trigger?(CHANGE_KEY[0]) || 
                      Input.trigger?(CHANGE_KEY[1]))
      Sound.play_cursor
      @whole = !@whole
      if @whole
        @last_index = @index
        @index = -1
      else
        @index = @last_index
      end
    end
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Arrow_Base
#==============================================================================

class Arrow_Base < Sprite
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :whole                    # 全体化フラグ
  attr_accessor :can_whole                # 全体化可能
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     viewport : ビューポート
  #--------------------------------------------------------------------------
  alias initialize_KGC_FlexibleScope initialize
  def initialize(viewport)
    initialize_KGC_FlexibleScope(viewport)

    @whole = false
    @can_whole = false
    @whole_duration = 0
    @last_index = 0
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Arrow_Enemy
#==============================================================================

class Arrow_Enemy < Arrow_Base
  include KGC
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias update_KGC_FlexibleScope update
  def update
    # L/R ボタンが押されたら全体/単体切り替え
    if @can_whole && (Input.trigger?(CHANGE_KEY[0]) || 
                      Input.trigger?(CHANGE_KEY[1]))
      Sound.play_cursor
      if get_exist_enemies.size == 1
        @whole = false
      else
        @whole = !@whole
      end
      if @whole
        @last_index = @index
      else
        @index = @last_index
      end
      if $imported["ActiveCountBattle"]
        @help_window.reset
      end
    end
    # 全体化している場合
    if @whole
      super
      # カーソルを小刻みに移動
      @whole_duration = (@whole_duration + 1) % 2
      if @whole_duration == 1
        $game_troop.enemies.size.times {
          @index += 1
          @index %= $game_troop.enemies.size
          break if self.enemy.exist?
        }
      end
      # スプライトの座標を設定
      if self.enemy != nil
        self.x = self.enemy.screen_x
        self.y = self.enemy.screen_y
      end
    else
      # 全体化していない場合は元の処理
      update_KGC_FlexibleScope
    end
  end
  #--------------------------------------------------------------------------
  # ● ヘルプテキスト更新
  #--------------------------------------------------------------------------
  alias update_help_KGC_FlexibleScope update_help
  def update_help
    if @whole
      # ヘルプウィンドウに全体化文字列を表示
      @help_window.set_text(KGC::FS_WHOLE_HELP_ENEMY, 1)
    else
      update_help_KGC_FlexibleScope
    end
  end
  #--------------------------------------------------------------------------
  # ● 存在するエネミーを取得
  #--------------------------------------------------------------------------
  def get_exist_enemies
    return $game_troop.enemies.find_all { |e| e.exist? }
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Arrow_Actor
#==============================================================================

class Arrow_Actor < Arrow_Base
  include KGC
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias update_KGC_FlexibleScope update
  def update
    # L/R ボタンが押されたら全体/単体切り替え
    if @can_whole && (Input.trigger?(CHANGE_KEY[0]) || 
                      Input.trigger?(CHANGE_KEY[1]))
      Sound.play_cursor
      if get_exist_actors.size == 1
        @whole = false
      else
        @whole = !@whole
      end
      if @whole
        @last_index = @index
      else
        @index = @last_index
      end
      if $imported["ActiveCountBattle"]
        @help_window.reset
      end
    end
    # 全体化している場合
    if @whole
      super
      # カーソルを小刻みに移動
      @whole_duration = (@whole_duration + 1) % 2
      if @whole_duration == 1
        @index += $game_party.actors.size - 1
        @index %= $game_party.actors.size
      end
      # スプライトの座標を設定
      if self.actor != nil
        self.x = self.actor.screen_x
        self.y = self.actor.screen_y
      end
    else
      # 全体化していない場合は元の処理
      update_KGC_FlexibleScope
    end
  end
  #--------------------------------------------------------------------------
  # ● ヘルプテキスト更新
  #--------------------------------------------------------------------------
  alias update_help_KGC_FlexibleScope update_help
  def update_help
    if @whole
      # ヘルプウィンドウに全体化文字列を表示
      @help_window.set_text(KGC::FS_WHOLE_HELP_ACTOR, 1)
    else
      update_help_KGC_FlexibleScope
    end
  end
  #--------------------------------------------------------------------------
  # ● 存在するアクターを取得
  #--------------------------------------------------------------------------
  def get_exist_actors
    return $game_party.actors.find_all { |a| a.exist? }
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_Item
#==============================================================================

class Scene_Item
  include KGC
  #--------------------------------------------------------------------------
  # ● メイン処理
  #--------------------------------------------------------------------------
  alias main_KGC_FlexibleScope main
  def main
    main_KGC_FlexibleScope

    # 無理矢理作成したアイテムの後始末
    if @flex_item_id != nil
      $data_items.delete_at(@flex_item_id)
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (アイテムウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  alias update_item_KGC_FlexibleScope update_item
  def update_item
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # アイテムウィンドウで現在選択されているデータを取得
      @item = @item_window.item
      # 全体化可能判定
      if (@item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id) && 
        @item.scope >= 3 && @item.flexible?) || (@item.flexible? == nil && 
        (($scene.is_a?(Scene_Battle) && @actor.flexible_attack?)) || 
        !$scene.is_a?(Scene_Battle))
        # 全体化を有効化
        @target_window.can_whole = true
      else
        # 全体化を無効化
        @target_window.can_whole = false
      end
      @target_window.whole = false
      @scope_changed = false
    end

    update_item_KGC_FlexibleScope
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  alias update_target_KGC_FlexibleScope update_target
  def update_target
    if @target_window.whole && Input.trigger?(Input::C) && !@scope_changed
      # 効果範囲を変更
      change_scope
    end

    update_target_KGC_FlexibleScope
  end
  #--------------------------------------------------------------------------
  # ● アイテムの範囲を操作
  #--------------------------------------------------------------------------
  def change_scope
    if @flex_item_id == nil
      @flex_item_id = $data_items.size
    end
    # 範囲を操作したスキルを無理矢理作成
    $data_items[@flex_item_id] = $data_items[@item.id].clone
    @item = $data_items[@flex_item_id]
    # 全体化
    @item.scope += 1
    # 性能変更
    @item.parameter_points = @item.parameter_points * FS_WHOLE_POWER / 100
    @item.recover_hp_rate  = @item.recover_hp_rate  * FS_WHOLE_POWER / 100
    @item.recover_hp       = @item.recover_hp       * FS_WHOLE_POWER / 100
    @item.recover_sp_rate  = @item.recover_sp_rate  * FS_WHOLE_POWER / 100
    @item.recover_sp       = @item.recover_sp       * FS_WHOLE_POWER / 100
    @scope_changed = true
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_Skill
#==============================================================================

class Scene_Skill
  include KGC
  #--------------------------------------------------------------------------
  # ● メイン処理
  #--------------------------------------------------------------------------
  alias main_KGC_FlexibleScope main
  def main
    main_KGC_FlexibleScope

    # 無理矢理作成したスキルの後始末
    if @flex_skill_id != nil
      $data_skills.delete_at(@flex_skill_id)
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (スキルウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  alias update_skill_KGC_FlexibleScope update_skill
  def update_skill
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # スキルウィンドウで現在選択されているデータを取得
      @skill = @skill_window.skill
      # 全体化可能判定
      if (@skill != nil && @skill.scope >= 3 && @skill.flexible?) || 
        (@skill.flexible? == nil && @actor.flexible_attack?)
        # 全体化を有効化
        @target_window.can_whole = true
      else
        # 全体化を無効化
        @target_window.can_whole = false
      end
      @target_window.whole = false
      @scope_changed = false
    end

    update_skill_KGC_FlexibleScope
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  alias update_target_KGC_FlexibleScope update_target
  def update_target
    # C ボタンが押された場合
    if @target_window.whole && Input.trigger?(Input::C) && !@scope_changed
      # 効果範囲を変更
      change_scope
    end

    update_target_KGC_FlexibleScope
  end
  #--------------------------------------------------------------------------
  # ● スキルの範囲を操作
  #--------------------------------------------------------------------------
  def change_scope
    if @flex_skill_id == nil
      @flex_skill_id = $data_skills.size
    end
    # 範囲を操作したスキルを無理矢理作成
    $data_skills[@flex_skill_id] = $data_skills[@skill.id].clone
    @skill = $data_skills[@flex_skill_id]
    # 全体化
    @skill.scope += 1
    # 性能変更
    @skill.sp_cost = @skill.sp_cost * FS_WHOLE_SP_COST / 100
    @skill.power   = @skill.power   * FS_WHOLE_POWER   / 100
    @scope_changed = true
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_Battle (分割定義 1)
#==============================================================================

#class Scene_Battle
  #--------------------------------------------------------------------------
  # ● メイン処理
  #--------------------------------------------------------------------------
#  alias main_KGC_FlexibleScope main
#  def main
#    main_KGC_FlexibleScope

    # 無理矢理作成したスキル/アイテムの後始末
#    if $_original_skill_data_size != nil
#      $data_skills = $data_skills[0...$_original_skill_data_size]
#    end
#    if $_original_item_data_size != nil
#      $data_items = $data_items[0...$_original_item_data_size]
#    end
#  end
#end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_Battle (分割定義 3)
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● フレーム更新 (アクターコマンドフェーズ : エネミー選択)
  #--------------------------------------------------------------------------
  alias update_phase3_enemy_select_KGC_FlexibleScope update_phase3_enemy_select
  def update_phase3_enemy_select
    # 全体化状態で C ボタンが押された場合
    if @enemy_arrow.whole && Input.trigger?(Input::C)
      # 範囲切り替えフラグをオン
      @active_battler.scope_changed = true
    end

    update_phase3_enemy_select_KGC_FlexibleScope
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (アクターコマンドフェーズ : アクター選択)
  #--------------------------------------------------------------------------
  alias update_phase3_actor_select_KGC_FlexibleScope update_phase3_actor_select
  def update_phase3_actor_select
    # 全体化状態で C ボタンが押された場合
    if @actor_arrow.whole && Input.trigger?(Input::C)
      # 範囲切り替えフラグを設定
      @active_battler.scope_changed = true
    end

    update_phase3_actor_select_KGC_FlexibleScope
  end
  #--------------------------------------------------------------------------
  # ● エネミー選択開始
  #--------------------------------------------------------------------------
  alias start_enemy_select_KGC_FlexibleScope start_enemy_select
  def start_enemy_select
    start_enemy_select_KGC_FlexibleScope

    # 全体化設定
    if @active_battler.flexible_attack? || 
      (@active_battler.current_action.kind == 1 && @skill.flexible?) || 
      (@active_battler.current_action.kind == 2 && @item.flexible?)
      @enemy_arrow.can_whole = true
    end
    if @active_battler.current_action.kind == 0
      @enemy_arrow.can_whole = false
    end
  end
  #--------------------------------------------------------------------------
  # ● アクター選択開始
  #--------------------------------------------------------------------------
  alias start_actor_select_KGC_FlexibleScope start_actor_select
  def start_actor_select
    start_actor_select_KGC_FlexibleScope

    # 全体化設定
    if @active_battler.flexible_attack? || 
      (@active_battler.current_action.kind == 1 && @skill.flexible?) || 
      (@active_battler.current_action.kind == 2 && @item.flexible?)
      @actor_arrow.can_whole = true
    end
    if @active_battler.current_action.kind == 0
      @enemy_arrow.can_whole = false
    end
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_Battle (分割定義 4)
#==============================================================================

class Scene_Battle
  include KGC
  #--------------------------------------------------------------------------
  # ● スキルアクション 結果作成
  #--------------------------------------------------------------------------
  alias make_skill_action_result_KGC_FlexibleScope make_skill_action_result
  def make_skill_action_result
    if @active_battler.scope_changed
      # 効果範囲を変更
      change_skill_scope
      @active_battler.scope_changed = false
    end

    make_skill_action_result_KGC_FlexibleScope
  end
  #--------------------------------------------------------------------------
  # ● スキルの範囲を操作
  #--------------------------------------------------------------------------
  def change_skill_scope
    if @flex_skill_id == nil
      if $_original_skill_data_size == nil
        @flex_skill_id = 0
      else
        @flex_skill_id = $_original_skill_data_size
      end
    end
    #p @flex_skill_id
    # 範囲を操作したスキルを無理矢理作成
    $data_skills[@flex_skill_id] =
      $data_skills[@active_battler.current_action.skill_id].clone
    @active_battler.current_action.skill_id = @flex_skill_id
    skill = $data_skills[@flex_skill_id]
    # 全体化
    skill.scope += 1
    # 性能変更
    skill.sp_cost = skill.sp_cost * FS_WHOLE_SP_COST / 100
    skill.power   = skill.power   * FS_WHOLE_POWER   / 100
  end
  #--------------------------------------------------------------------------
  # ● アイテムアクション 結果作成
  #--------------------------------------------------------------------------
  alias make_item_action_result_KGC_FlexibleScope make_item_action_result
  def make_item_action_result
    if @active_battler.scope_changed
      # 効果範囲を変更
      change_item_scope
      @active_battler.scope_changed = false
    end

    make_item_action_result_KGC_FlexibleScope
  end
  #--------------------------------------------------------------------------
  # ● アイテムの範囲を操作
  #--------------------------------------------------------------------------
  def change_item_scope
    if @flex_item_id == nil
      @flex_item_id = $_original_item_data_size
    end
    # 範囲を操作したアイテムを無理矢理作成
    $data_items[@flex_item_id] =
      $data_items[@active_battler.current_action.item_id].clone
    @active_battler.current_action.item_id = @flex_item_id
    item = $data_items[@flex_item_id]
    # 全体化
    item.scope += 1
    # 性能変更
    item.parameter_points = item.parameter_points * FS_WHOLE_POWER / 100
    item.recover_hp_rate  = item.recover_hp_rate  * FS_WHOLE_POWER / 100
    item.recover_hp       = item.recover_hp       * FS_WHOLE_POWER / 100
    item.recover_sp_rate  = item.recover_sp_rate  * FS_WHOLE_POWER / 100
    item.recover_sp       = item.recover_sp       * FS_WHOLE_POWER / 100
  end
end
基本的にKGC Softの全体化と同じです。 スキル/アイテムに 全体化属性 を付加することで CHANGE_KEY で設定したキーで全体/単体に切り替えられます また、防具の属性防御に 全体化属性 を付加することで同じような効果が得られます。 ※全体化不可能 属性が付加されているスキル/アイテムには効果がありません。

戻る