| 
 
| 赞 | 0 |  
| VIP | 0 |  
| 好人卡 | 0 |  
| 积分 | 30 |  
| 经验 | 13785 |  
| 最后登录 | 2025-7-28 |  
| 在线时间 | 595 小时 |  
 Lv3.寻梦者 
	梦石0 星屑2957 在线时间595 小时注册时间2011-9-21帖子33 | 
| 这个脚本好像可以加入新的指令,但我看不懂,请问该如何添加新的战斗指令呢?应该在哪里设置呢? 复制代码#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆ 個別戦闘コマンド - KGC_SeparationCommand ◆ VX ◆
#_/    ◇ Last update : 2008/04/01 ◇
#_/----------------------------------------------------------------------------
#_/  キャラ固有のコマンドを作成する機能を追加します。
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# ★ カスタマイズ項目 - Customize ★
#==============================================================================
module KGC
module SeparationCommand
  # ◆ デフォルトのコマンド配置
  #  戦闘時に表示するコマンドを「表示したい順」に記述してください。
  #  使用しないコマンドは書かなくても構いません。
  #  ※ 同じコマンドを2箇所以上に配置するとバグります。
  #   ** 対応表 **
  #  0..攻撃  1..スキル  2..防御  3..アイテム  4..固有コマンド
  DEFAULT_COMMANDS = [0, 4, 1, 2, 3]
  # ◆ アクター別のコマンド配置
  ACTOR_COMMANDS = []  # ← これは消さないこと!
  # ここから下に、アクターごとのコマンド配置を
  #   ACTOR_COMMANDS[アクター ID] = [コマンド]
  # という形式で設定します。
  # 対応表は DEFAULT_COMMANDS と同じです。
  #   <例> アクターID:2 の「スキル」を消す
  ACTOR_COMMANDS[2] = DEFAULT_COMMANDS - [1]
  #  ↑ ACTOR_COMMANDS[2] = [0, 4, 2, 3] でもOK。
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
$imported = {} if $imported == nil
$imported["SeparationCommand"] = true
module KGC::SeparationCommand
  # 正規表現
  module Regexp
    # 固有コマンド
    OWN_COMMAND = /([S])[ ]*:[ ]*(\d+)/i
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ KGC::Commands
#==============================================================================
module KGC
module Commands
  module_function
  #--------------------------------------------------------------------------
  # ○ アクターコマンドの変更
  #     actor_id : アクター ID
  #     commands : コマンドの配列 (省略時: nil)
  #--------------------------------------------------------------------------
  def set_actor_command(actor_id, commands = nil)
    $game_actors[actor_id].actor_commands = commands
  end
  #--------------------------------------------------------------------------
  # ○ アクターの固有コマンドの登録
  #     actor_id : アクター ID
  #     commands : コマンドの配列
  #--------------------------------------------------------------------------
  def set_own_command(actor_id, commands)
    actor = $game_actors[actor_id]
    actor.clear_own_command            # コマンドをクリア
    commands.each_with_index { |c, i|  # コマンドを登録
      actor.set_own_command(i, c)
    }
  end
  #--------------------------------------------------------------------------
  # ○ アクターの固有コマンドの追加登録
  #     actor_id : アクター ID
  #     commands : コマンドの配列
  #--------------------------------------------------------------------------
  def add_own_command(actor_id, commands)
    actor = $game_actors[actor_id]
    commands.each { |c|                # コマンドを追加登録
      actor.set_own_command(actor.own_commands.size + 1, c)
    }
  end
  #--------------------------------------------------------------------------
  # ○ アクターの固有コマンドの削除
  #     actor_id : アクター ID
  #     commands : コマンドの配列
  #--------------------------------------------------------------------------
  def remove_own_command(actor_id, commands)
    actor = $game_actors[actor_id]
    commands.each { |c|                # コマンドを削除
      actor.remove_own_command(c)
    }
  end
  #--------------------------------------------------------------------------
  # ○ アクターの固有コマンドのクリア
  #     actor_id : アクター ID
  #--------------------------------------------------------------------------
  def clear_own_command(actor_id)
    $game_actors[actor_id].clear_own_command
  end
end
end
class Game_Interpreter
  include KGC::Commands
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_writer   :actor_commands           # アクターコマンド
  attr_writer   :own_commands             # 固有コマンド
  #--------------------------------------------------------------------------
  # ● セットアップ
  #     actor_id : アクター ID
  #--------------------------------------------------------------------------
  alias setup_KGC_SeparationCommand setup
  def setup(actor_id)
    setup_KGC_SeparationCommand(actor_id)
    @actor_commands = nil
    @own_commands = nil
  end
  #--------------------------------------------------------------------------
  # ○ アクターコマンド取得
  #--------------------------------------------------------------------------
  def actor_commands
    if @actor_commands.is_a?(Array)
      return @actor_commands
    elsif KGC::SeparationCommand::ACTOR_COMMANDS[actor.id] != nil
      return KGC::SeparationCommand::ACTOR_COMMANDS[actor.id]
    else
      return KGC::SeparationCommand::DEFAULT_COMMANDS
    end
  end
  #--------------------------------------------------------------------------
  # ○ 固有コマンド取得
  #--------------------------------------------------------------------------
  def own_commands
    clear_own_command if @own_commands == nil
    result = []
    @own_commands.each { |c|
      command = Game_OwnCommand.new(c)
      result << command if command.valid?  # 有効なコマンドのみ追加
    }
    return result
  end
  #--------------------------------------------------------------------------
  # ○ 固有コマンド登録
  #     index   : 登録場所
  #     command : スキル ID or コマンド文字列
  #--------------------------------------------------------------------------
  def set_own_command(index, command)
    clear_own_command if @own_commands == nil
    @own_commands[index] = command
  end
  #--------------------------------------------------------------------------
  # ○ 固有コマンド削除
  #     command : スキル ID or コマンド文字列
  #--------------------------------------------------------------------------
  def remove_own_command(command)
    clear_own_command if @own_commands == nil
    @own_commands.delete(command)
  end
  #--------------------------------------------------------------------------
  # ○ 固有コマンドをクリア
  #--------------------------------------------------------------------------
  def clear_own_command
    @own_commands = []
  end
  #--------------------------------------------------------------------------
  # ● スキルの使用可能判定
  #     skill : スキル
  #--------------------------------------------------------------------------
  def skill_can_use?(skill)
    return super
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ Game_OwnCommand
#------------------------------------------------------------------------------
#   個別戦闘コマンドの情報を格納するクラスです。
#==============================================================================
class Game_OwnCommand
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  KIND_NONE  = -1  # 無効
  KIND_SKILL = 0   # スキル
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :kind                     # コマンドの種類 (/[S]/)
  attr_accessor :skill_id                 # スキル ID
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #     command : スキル ID or コマンド文字列
  #--------------------------------------------------------------------------
  def initialize(command)
    @kind = KIND_SKILL
    @skill_id = 0
    setup(command)
  end
  #--------------------------------------------------------------------------
  # ○ セットアップ
  #     command : スキル ID or コマンド文字列
  #--------------------------------------------------------------------------
  def setup(command)
    if command.is_a?(Integer)       # スキル ID
      @kind = KIND_SKILL
      @skill_id = command
    elsif command.is_a?(String) &&  # 文字列
        command =~ KGC::SeparationCommand::Regexp::OWN_COMMAND
      case $1.upcase
      when "S"  # スキル
        @kind = KIND_SKILL
        @skill_id = $2.to_i
      end
    else                            # 無効
      @kind = KIND_NONE
    end
  end
  #--------------------------------------------------------------------------
  # ○ 有効判定
  #--------------------------------------------------------------------------
  def valid?
    return @kind != KIND_NONE
  end
  #--------------------------------------------------------------------------
  # ○ スキル取得
  #--------------------------------------------------------------------------
  def skill
    return nil if @kind != KIND_SKILL
    return $data_skills[@skill_id]
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Window_ActorCommand
#==============================================================================
class Window_ActorCommand < Window_Command
  #--------------------------------------------------------------------------
  # ● セットアップ
  #     actor : アクター
  #--------------------------------------------------------------------------
  def setup(actor)
    create_commands(actor)
    create_contents
    refresh
    apply_command_enabled(actor)
    self.index = 0
    setup_name_window(actor) if $imported["ActiveCountBattle"]
  end
  #--------------------------------------------------------------------------
  # ○ コマンドを作成
  #     actor : アクター
  #--------------------------------------------------------------------------
  def create_commands(actor)
    @command_index = {}
    @command_enabled = {}
    @commands = []
    actor.actor_commands.each { |c|
      case c
      when 0  # 攻撃
        @command_index[:attack] = @commands.size
        @command_enabled[:attack] = true
        @commands << Vocab.attack
      when 1  # スキル
        @command_index[:skill] = @commands.size
        @command_enabled[:skill] = true
        vocab = Vocab.skill
        if actor.class.skill_name_valid        # スキルのコマンド名が有効?
          vocab = actor.class.skill_name       # コマンド名を置き換える
        end
        @commands << vocab
      when 2  # 防御
        @command_index[:guard] = @commands.size
        @command_enabled[:guard] = true
        @commands << Vocab.guard
      when 3  # アイテム
        @command_index[:item] = @commands.size
        @command_enabled[:item] = true
        @commands << Vocab.item
      when 4  # 固有コマンド
        @command_index[:own_start] = @commands.size
        cmd = create_own_commands(actor)
        unless cmd.empty?
          @commands += cmd
          @command_index[:own_end] = @commands.size - 1
        end
      end
    }
    @item_max = @commands.size
  end
  #--------------------------------------------------------------------------
  # ○ 固有コマンドを作成
  #     actor : アクター
  #--------------------------------------------------------------------------
  def create_own_commands(actor)
    result = []
    actor.own_commands.each { |c|
      next unless c.is_a?(Game_OwnCommand)  # 固有コマンド以外は無視
      case c.kind
      when Game_OwnCommand::KIND_SKILL  # スキル
        skill = c.skill
        @command_index[skill] = @command_index[:own_start] + result.size
        @command_enabled[skill] = actor.skill_can_use?(skill)
        result << skill.name
      end
    }
    return result
  end
  #--------------------------------------------------------------------------
  # ○ コマンドの有効状態を適用
  #     actor : アクター
  #--------------------------------------------------------------------------
  def apply_command_enabled(actor)
    @command_index.each { |k, v|
      next if k == :own_start || k == :own_end
      # 無効状態のコマンドを描画
      draw_item(v, @command_enabled[k]) unless @command_enabled[k]
    }
  end
  #--------------------------------------------------------------------------
  # ○ 「攻撃」のインデックス
  #--------------------------------------------------------------------------
  def attack_index
    return @command_index[:attack]
  end
  #--------------------------------------------------------------------------
  # ○ 「スキル」のインデックス
  #--------------------------------------------------------------------------
  def skill_index
    return @command_index[:skill]
  end
  #--------------------------------------------------------------------------
  # ○ 「防御」のインデックス
  #--------------------------------------------------------------------------
  def guard_index
    return @command_index[:guard]
  end
  #--------------------------------------------------------------------------
  # ○ 「アイテム」のインデックス
  #--------------------------------------------------------------------------
  def item_index
    return @command_index[:item]
  end
  #--------------------------------------------------------------------------
  # ○ 「固有コマンド」の開始インデックス
  #--------------------------------------------------------------------------
  def own_start_index
    return @command_index[:own_start]
  end
  #--------------------------------------------------------------------------
  # ○ 「固有コマンド」のインデックス範囲
  #--------------------------------------------------------------------------
  def own_index_range
    if @command_index[:own_end] == nil
      return nil
    else
      return @command_index[:own_start]..@command_index[:own_end]
    end
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle
  #--------------------------------------------------------------------------
  # ● アクターコマンド選択の更新
  #--------------------------------------------------------------------------
  def update_actor_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      prior_actor
    elsif Input.trigger?(Input::C)
      index = @actor_command_window.index
      case index
      when @actor_command_window.attack_index     # 攻撃
        Sound.play_decision
        @active_battler.action.set_attack
        start_target_enemy_selection
      when @actor_command_window.skill_index      # スキル
        Sound.play_decision
        start_skill_selection
      when @actor_command_window.guard_index      # 防御
        Sound.play_decision
        @active_battler.action.set_guard
        next_actor
      when @actor_command_window.item_index       # アイテム
        Sound.play_decision
        start_item_selection
      when @actor_command_window.own_index_range  # 固有コマンド
        own_index = index - @actor_command_window.own_start_index
        process_own_command(own_index)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ○ 固有コマンド処理
  #     index : コマンド index
  #--------------------------------------------------------------------------
  def process_own_command(index)
    command = @active_battler.own_commands[index]
    if command == nil
      Sound.play_buzzer
      return
    end
    # コマンドの種類に応じた処理
    case command.kind
    when Game_OwnCommand::KIND_SKILL  # スキル
      @input_own_command = true
      # ダミーのウィンドウを作成
      @help_window = Window_Help.new
      @help_window.visible = false
      @skill_window = Window_Skill.new(0, 0, 64, 64, @active_battler)
      @skill_window.active = false
      @skill_window.visible = false
      # スキルを選択したと見なす
      @skill = command.skill
      if @active_battler.skill_can_use?(@skill)
        Sound.play_decision
        determine_skill
      else
        Sound.play_buzzer
      end
      # ダミーのウィンドウを破棄
      @help_window.dispose  if @help_window != nil
      @skill_window.dispose if @skill_window != nil
      @help_window = nil
      @skill_window = nil
    else                              # 不明なコマンド
      Sound.play_buzzer
    end
    @input_own_command = false
  end
  #--------------------------------------------------------------------------
  # ● 対象敵キャラ選択の終了
  #--------------------------------------------------------------------------
  alias end_target_enemy_selection_KGC_SeparationCommand end_target_enemy_selection
  def end_target_enemy_selection
    end_target_enemy_selection_KGC_SeparationCommand
    case @actor_command_window.index
    when @actor_command_window.attack_index,     # 攻撃または
          @actor_command_window.own_index_range  # 固有コマンドの場合
      @actor_command_window.active = true         # アクターコマンドに戻る
    else
      @actor_command_window.active = false
    end
  end
  #--------------------------------------------------------------------------
  # ● 対象アクター選択の終了
  #--------------------------------------------------------------------------
  alias end_target_actor_selection_KGC_SeparationCommand end_target_actor_selection
  def end_target_actor_selection
    end_target_actor_selection_KGC_SeparationCommand
    case @actor_command_window.index
    when @actor_command_window.own_index_range  # 固有コマンドの場合
      @actor_command_window.active = true        # アクターコマンドに戻る
    else
      @actor_command_window.active = false
    end
  end
end
 | 
 |