#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ #_/ ◆ Individual Actor Commands - KGC_SeparationCommand ◆ VX ◆ #_/ ◇ Last update: 04/01/08 #_/ ◆ Written by TOMY #_/ ◆ Translation by Touchfuzzy #_/ ◆ Extended Translation and Annotation by Mr. Anonymous #_/ ◆ KGC Site: #_/ ◆ http://ytomy.sakura.ne.jp/ #_/ ◆ Translator's Blog: #_/ ◆ http://mraprojects.wordpress.com #_/----------------------------------------------------------------------------- #_/ This script has two functions. The first adding the ability to freely #_/ rearrange the battle command menu, even for individual actors. #_/ The second function allows you to group a set of particular skills together #_/ under one command for individual actors. #_/============================================================================= #_/ #_/ ◆ Script Commands ◆ #_/ These commands are used in "Script" function in the third page of event #_/ commands under "Advanced". #_/ #_/ * set_actor_command(ActorID, [Commands]) #_/ Changes the battle command menu for a specific character. If you omit #_/ the [Commands] section it resets to default. Refer to ACTOR_COMMANDS in #_/ the Customization block for an example. #_/ #_/ * set_own_command(ActorID, [SkillID]) #_/ This sets the skills you wish to show up in the Specific Command slot of #_/ the battle menu. You may enter more than one SkillID in, with commas #_/ between (as an array). The maximum amount of skills a command is capable #_/ of holding has not yet been tested. #_/ Example: set_own_command(1, [1, 2, 3]) would set up Ralph's personal #_/ command with Dual Attack, Double Attack, and Triple Attack. #_/ #_/ * add_own_command(ActorID, [SkillID]) #_/ This adds a skill to the Own Command list set with set_own_commands. #_/ #_/ * remove_own_command(ActorID, [SkillID]) #_/ This removes a skill from the Own Command list set with set_own_commands. #_/ #_/ * clear_own_command(ActorID) #_/ This completely clears the Own Command list set with set_own_commands. #_/ #_/============================================================================= #_/ Installation: Insert this script above Main. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ #==============================================================================# # ★ Customization ★ # #==============================================================================# module KGC module SeparationCommand # ★ Default Command Arrangement ★ # This is were you enter the default order of commands you wish to use. # Anything omitted will not be available to that character. # *Note: If you enter a command more than once it will cause an error. # The corresponding number of a command is as follows: # 0. Attack 1. Skill 2. Defend 3. Item 4. Specific Command DEFAULT_COMMANDS = [0, 4, 1, 2, 3] # ★ Actor Specific Command Arrangement ★ # ACTOR_COMMANDS[Actor ID] = [Command] # This allows you to manually assign commands to individual actors. # You can also use the DEFAULT_COMMANDS as a base as follows: # ACTOR_COMMANDS[2] = DEFAULT_COMMANDS - [1] # ↑ ACTOR_COMMANDS[2] = [0, 4, 2, 3] these two lines work the same, if the # defaults are unchanged. ACTOR_COMMANDS = [] # ← DO NOT REMOVE # ★ Insert Custom Actor Commands Below Here ★ # ★ Insert Custom Actor Commands Above Here ★ end end #------------------------------------------------------------------------------# $imported = {} if $imported == nil $imported["SeparationCommand"] = true module KGC::SeparationCommand # Define Regular Expression Module module Regexp # Not sure what this next line does so if you can figure it out please # let us know. OWN_COMMAND = /([S])[ ]*:[ ]*(\d+)/i end end #============================================================================== # □ KGC::Commands #============================================================================== module KGC::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 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