设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1095|回复: 0
打印 上一主题 下一主题

[已经过期] 请教关于KCG独立战斗指令脚本的使用问题

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2937
在线时间
593 小时
注册时间
2011-9-21
帖子
33
跳转到指定楼层
1
发表于 2012-3-12 16:08:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个脚本好像可以加入新的指令,但我看不懂,请问该如何添加新的战斗指令呢?应该在哪里设置呢?
  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  2. #_/    ◆ 個別戦闘コマンド - KGC_SeparationCommand ◆ VX ◆
  3. #_/    ◇ Last update : 2008/04/01 ◇
  4. #_/----------------------------------------------------------------------------
  5. #_/  キャラ固有のコマンドを作成する機能を追加します。
  6. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

  7. #==============================================================================
  8. # ★ カスタマイズ項目 - Customize ★
  9. #==============================================================================

  10. module KGC
  11. module SeparationCommand
  12.   # ◆ デフォルトのコマンド配置
  13.   #  戦闘時に表示するコマンドを「表示したい順」に記述してください。
  14.   #  使用しないコマンドは書かなくても構いません。
  15.   #  ※ 同じコマンドを2箇所以上に配置するとバグります。
  16.   #   ** 対応表 **
  17.   #  0..攻撃  1..スキル  2..防御  3..アイテム  4..固有コマンド
  18.   DEFAULT_COMMANDS = [0, 4, 1, 2, 3]

  19.   # ◆ アクター別のコマンド配置
  20.   ACTOR_COMMANDS = []  # ← これは消さないこと!
  21.   # ここから下に、アクターごとのコマンド配置を
  22.   #   ACTOR_COMMANDS[アクター ID] = [コマンド]
  23.   # という形式で設定します。
  24.   # 対応表は DEFAULT_COMMANDS と同じです。
  25.   #   <例> アクターID:2 の「スキル」を消す
  26.   ACTOR_COMMANDS[2] = DEFAULT_COMMANDS - [1]
  27.   #  ↑ ACTOR_COMMANDS[2] = [0, 4, 2, 3] でもOK。
  28. end
  29. end

  30. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  31. $imported = {} if $imported == nil
  32. $imported["SeparationCommand"] = true

  33. module KGC::SeparationCommand
  34.   # 正規表現
  35.   module Regexp
  36.     # 固有コマンド
  37.     OWN_COMMAND = /([S])[ ]*:[ ]*(\d+)/i
  38.   end
  39. end

  40. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  41. #==============================================================================
  42. # □ KGC::Commands
  43. #==============================================================================

  44. module KGC
  45. module Commands
  46.   module_function
  47.   #--------------------------------------------------------------------------
  48.   # ○ アクターコマンドの変更
  49.   #     actor_id : アクター ID
  50.   #     commands : コマンドの配列 (省略時: nil)
  51.   #--------------------------------------------------------------------------
  52.   def set_actor_command(actor_id, commands = nil)
  53.     $game_actors[actor_id].actor_commands = commands
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ○ アクターの固有コマンドの登録
  57.   #     actor_id : アクター ID
  58.   #     commands : コマンドの配列
  59.   #--------------------------------------------------------------------------
  60.   def set_own_command(actor_id, commands)
  61.     actor = $game_actors[actor_id]
  62.     actor.clear_own_command            # コマンドをクリア
  63.     commands.each_with_index { |c, i|  # コマンドを登録
  64.       actor.set_own_command(i, c)
  65.     }
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # ○ アクターの固有コマンドの追加登録
  69.   #     actor_id : アクター ID
  70.   #     commands : コマンドの配列
  71.   #--------------------------------------------------------------------------
  72.   def add_own_command(actor_id, commands)
  73.     actor = $game_actors[actor_id]
  74.     commands.each { |c|                # コマンドを追加登録
  75.       actor.set_own_command(actor.own_commands.size + 1, c)
  76.     }
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ○ アクターの固有コマンドの削除
  80.   #     actor_id : アクター ID
  81.   #     commands : コマンドの配列
  82.   #--------------------------------------------------------------------------
  83.   def remove_own_command(actor_id, commands)
  84.     actor = $game_actors[actor_id]
  85.     commands.each { |c|                # コマンドを削除
  86.       actor.remove_own_command(c)
  87.     }
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # ○ アクターの固有コマンドのクリア
  91.   #     actor_id : アクター ID
  92.   #--------------------------------------------------------------------------
  93.   def clear_own_command(actor_id)
  94.     $game_actors[actor_id].clear_own_command
  95.   end
  96. end
  97. end

  98. class Game_Interpreter
  99.   include KGC::Commands
  100. end

  101. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  102. #==============================================================================
  103. # ■ Game_Actor
  104. #==============================================================================

  105. class Game_Actor < Game_Battler
  106.   #--------------------------------------------------------------------------
  107.   # ● 公開インスタンス変数
  108.   #--------------------------------------------------------------------------
  109.   attr_writer   :actor_commands           # アクターコマンド
  110.   attr_writer   :own_commands             # 固有コマンド
  111.   #--------------------------------------------------------------------------
  112.   # ● セットアップ
  113.   #     actor_id : アクター ID
  114.   #--------------------------------------------------------------------------
  115.   alias setup_KGC_SeparationCommand setup
  116.   def setup(actor_id)
  117.     setup_KGC_SeparationCommand(actor_id)

  118.     @actor_commands = nil
  119.     @own_commands = nil
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # ○ アクターコマンド取得
  123.   #--------------------------------------------------------------------------
  124.   def actor_commands
  125.     if @actor_commands.is_a?(Array)
  126.       return @actor_commands
  127.     elsif KGC::SeparationCommand::ACTOR_COMMANDS[actor.id] != nil
  128.       return KGC::SeparationCommand::ACTOR_COMMANDS[actor.id]
  129.     else
  130.       return KGC::SeparationCommand::DEFAULT_COMMANDS
  131.     end
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ○ 固有コマンド取得
  135.   #--------------------------------------------------------------------------
  136.   def own_commands
  137.     clear_own_command if @own_commands == nil
  138.     result = []
  139.     @own_commands.each { |c|
  140.       command = Game_OwnCommand.new(c)
  141.       result << command if command.valid?  # 有効なコマンドのみ追加
  142.     }
  143.     return result
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # ○ 固有コマンド登録
  147.   #     index   : 登録場所
  148.   #     command : スキル ID or コマンド文字列
  149.   #--------------------------------------------------------------------------
  150.   def set_own_command(index, command)
  151.     clear_own_command if @own_commands == nil
  152.     @own_commands[index] = command
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ○ 固有コマンド削除
  156.   #     command : スキル ID or コマンド文字列
  157.   #--------------------------------------------------------------------------
  158.   def remove_own_command(command)
  159.     clear_own_command if @own_commands == nil
  160.     @own_commands.delete(command)
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ○ 固有コマンドをクリア
  164.   #--------------------------------------------------------------------------
  165.   def clear_own_command
  166.     @own_commands = []
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # ● スキルの使用可能判定
  170.   #     skill : スキル
  171.   #--------------------------------------------------------------------------
  172.   def skill_can_use?(skill)
  173.     return super
  174.   end
  175. end

  176. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  177. #==============================================================================
  178. # □ Game_OwnCommand
  179. #------------------------------------------------------------------------------
  180. #   個別戦闘コマンドの情報を格納するクラスです。
  181. #==============================================================================

  182. class Game_OwnCommand
  183.   #--------------------------------------------------------------------------
  184.   # ○ 定数
  185.   #--------------------------------------------------------------------------
  186.   KIND_NONE  = -1  # 無効
  187.   KIND_SKILL = 0   # スキル
  188.   #--------------------------------------------------------------------------
  189.   # ○ 公開インスタンス変数
  190.   #--------------------------------------------------------------------------
  191.   attr_accessor :kind                     # コマンドの種類 (/[S]/)
  192.   attr_accessor :skill_id                 # スキル ID
  193.   #--------------------------------------------------------------------------
  194.   # ○ オブジェクト初期化
  195.   #     command : スキル ID or コマンド文字列
  196.   #--------------------------------------------------------------------------
  197.   def initialize(command)
  198.     @kind = KIND_SKILL
  199.     @skill_id = 0
  200.     setup(command)
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ○ セットアップ
  204.   #     command : スキル ID or コマンド文字列
  205.   #--------------------------------------------------------------------------
  206.   def setup(command)
  207.     if command.is_a?(Integer)       # スキル ID
  208.       @kind = KIND_SKILL
  209.       @skill_id = command
  210.     elsif command.is_a?(String) &&  # 文字列
  211.         command =~ KGC::SeparationCommand::Regexp::OWN_COMMAND
  212.       case $1.upcase
  213.       when "S"  # スキル
  214.         @kind = KIND_SKILL
  215.         @skill_id = $2.to_i
  216.       end
  217.     else                            # 無効
  218.       @kind = KIND_NONE
  219.     end
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ○ 有効判定
  223.   #--------------------------------------------------------------------------
  224.   def valid?
  225.     return @kind != KIND_NONE
  226.   end
  227.   #--------------------------------------------------------------------------
  228.   # ○ スキル取得
  229.   #--------------------------------------------------------------------------
  230.   def skill
  231.     return nil if @kind != KIND_SKILL
  232.     return $data_skills[@skill_id]
  233.   end
  234. end

  235. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  236. #==============================================================================
  237. # ■ Window_ActorCommand
  238. #==============================================================================

  239. class Window_ActorCommand < Window_Command
  240.   #--------------------------------------------------------------------------
  241.   # ● セットアップ
  242.   #     actor : アクター
  243.   #--------------------------------------------------------------------------
  244.   def setup(actor)
  245.     create_commands(actor)
  246.     create_contents
  247.     refresh
  248.     apply_command_enabled(actor)
  249.     self.index = 0
  250.     setup_name_window(actor) if $imported["ActiveCountBattle"]
  251.   end
  252.   #--------------------------------------------------------------------------
  253.   # ○ コマンドを作成
  254.   #     actor : アクター
  255.   #--------------------------------------------------------------------------
  256.   def create_commands(actor)
  257.     @command_index = {}
  258.     @command_enabled = {}
  259.     @commands = []

  260.     actor.actor_commands.each { |c|
  261.       case c
  262.       when 0  # 攻撃
  263.         @command_index[:attack] = @commands.size
  264.         @command_enabled[:attack] = true
  265.         @commands << Vocab.attack
  266.       when 1  # スキル
  267.         @command_index[:skill] = @commands.size
  268.         @command_enabled[:skill] = true
  269.         vocab = Vocab.skill
  270.         if actor.class.skill_name_valid        # スキルのコマンド名が有効?
  271.           vocab = actor.class.skill_name       # コマンド名を置き換える
  272.         end
  273.         @commands << vocab
  274.       when 2  # 防御
  275.         @command_index[:guard] = @commands.size
  276.         @command_enabled[:guard] = true
  277.         @commands << Vocab.guard
  278.       when 3  # アイテム
  279.         @command_index[:item] = @commands.size
  280.         @command_enabled[:item] = true
  281.         @commands << Vocab.item
  282.       when 4  # 固有コマンド
  283.         @command_index[:own_start] = @commands.size
  284.         cmd = create_own_commands(actor)
  285.         unless cmd.empty?
  286.           @commands += cmd
  287.           @command_index[:own_end] = @commands.size - 1
  288.         end
  289.       end
  290.     }
  291.     @item_max = @commands.size
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ○ 固有コマンドを作成
  295.   #     actor : アクター
  296.   #--------------------------------------------------------------------------
  297.   def create_own_commands(actor)
  298.     result = []
  299.     actor.own_commands.each { |c|
  300.       next unless c.is_a?(Game_OwnCommand)  # 固有コマンド以外は無視
  301.       case c.kind
  302.       when Game_OwnCommand::KIND_SKILL  # スキル
  303.         skill = c.skill
  304.         @command_index[skill] = @command_index[:own_start] + result.size
  305.         @command_enabled[skill] = actor.skill_can_use?(skill)
  306.         result << skill.name
  307.       end
  308.     }

  309.     return result
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   # ○ コマンドの有効状態を適用
  313.   #     actor : アクター
  314.   #--------------------------------------------------------------------------
  315.   def apply_command_enabled(actor)
  316.     @command_index.each { |k, v|
  317.       next if k == :own_start || k == :own_end
  318.       # 無効状態のコマンドを描画
  319.       draw_item(v, @command_enabled[k]) unless @command_enabled[k]
  320.     }
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ○ 「攻撃」のインデックス
  324.   #--------------------------------------------------------------------------
  325.   def attack_index
  326.     return @command_index[:attack]
  327.   end
  328.   #--------------------------------------------------------------------------
  329.   # ○ 「スキル」のインデックス
  330.   #--------------------------------------------------------------------------
  331.   def skill_index
  332.     return @command_index[:skill]
  333.   end
  334.   #--------------------------------------------------------------------------
  335.   # ○ 「防御」のインデックス
  336.   #--------------------------------------------------------------------------
  337.   def guard_index
  338.     return @command_index[:guard]
  339.   end
  340.   #--------------------------------------------------------------------------
  341.   # ○ 「アイテム」のインデックス
  342.   #--------------------------------------------------------------------------
  343.   def item_index
  344.     return @command_index[:item]
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ○ 「固有コマンド」の開始インデックス
  348.   #--------------------------------------------------------------------------
  349.   def own_start_index
  350.     return @command_index[:own_start]
  351.   end
  352.   #--------------------------------------------------------------------------
  353.   # ○ 「固有コマンド」のインデックス範囲
  354.   #--------------------------------------------------------------------------
  355.   def own_index_range
  356.     if @command_index[:own_end] == nil
  357.       return nil
  358.     else
  359.       return @command_index[:own_start]..@command_index[:own_end]
  360.     end
  361.   end
  362. end

  363. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  364. #==============================================================================
  365. # ■ Scene_Battle
  366. #==============================================================================

  367. class Scene_Battle
  368.   #--------------------------------------------------------------------------
  369.   # ● アクターコマンド選択の更新
  370.   #--------------------------------------------------------------------------
  371.   def update_actor_command_selection
  372.     if Input.trigger?(Input::B)
  373.       Sound.play_cancel
  374.       prior_actor
  375.     elsif Input.trigger?(Input::C)
  376.       index = @actor_command_window.index
  377.       case index
  378.       when @actor_command_window.attack_index     # 攻撃
  379.         Sound.play_decision
  380.         @active_battler.action.set_attack
  381.         start_target_enemy_selection
  382.       when @actor_command_window.skill_index      # スキル
  383.         Sound.play_decision
  384.         start_skill_selection
  385.       when @actor_command_window.guard_index      # 防御
  386.         Sound.play_decision
  387.         @active_battler.action.set_guard
  388.         next_actor
  389.       when @actor_command_window.item_index       # アイテム
  390.         Sound.play_decision
  391.         start_item_selection
  392.       when @actor_command_window.own_index_range  # 固有コマンド
  393.         own_index = index - @actor_command_window.own_start_index
  394.         process_own_command(own_index)
  395.       end
  396.     end
  397.   end
  398.   #--------------------------------------------------------------------------
  399.   # ○ 固有コマンド処理
  400.   #     index : コマンド index
  401.   #--------------------------------------------------------------------------
  402.   def process_own_command(index)
  403.     command = @active_battler.own_commands[index]
  404.     if command == nil
  405.       Sound.play_buzzer
  406.       return
  407.     end

  408.     # コマンドの種類に応じた処理
  409.     case command.kind
  410.     when Game_OwnCommand::KIND_SKILL  # スキル
  411.       @input_own_command = true
  412.       # ダミーのウィンドウを作成
  413.       @help_window = Window_Help.new
  414.       @help_window.visible = false
  415.       @skill_window = Window_Skill.new(0, 0, 64, 64, @active_battler)
  416.       @skill_window.active = false
  417.       @skill_window.visible = false
  418.       # スキルを選択したと見なす
  419.       @skill = command.skill
  420.       if @active_battler.skill_can_use?(@skill)
  421.         Sound.play_decision
  422.         determine_skill
  423.       else
  424.         Sound.play_buzzer
  425.       end
  426.       # ダミーのウィンドウを破棄
  427.       @help_window.dispose  if @help_window != nil
  428.       @skill_window.dispose if @skill_window != nil
  429.       @help_window = nil
  430.       @skill_window = nil
  431.     else                              # 不明なコマンド
  432.       Sound.play_buzzer
  433.     end
  434.     @input_own_command = false
  435.   end
  436.   #--------------------------------------------------------------------------
  437.   # ● 対象敵キャラ選択の終了
  438.   #--------------------------------------------------------------------------
  439.   alias end_target_enemy_selection_KGC_SeparationCommand end_target_enemy_selection
  440.   def end_target_enemy_selection
  441.     end_target_enemy_selection_KGC_SeparationCommand

  442.     case @actor_command_window.index
  443.     when @actor_command_window.attack_index,     # 攻撃または
  444.           @actor_command_window.own_index_range  # 固有コマンドの場合
  445.       @actor_command_window.active = true         # アクターコマンドに戻る
  446.     else
  447.       @actor_command_window.active = false
  448.     end
  449.   end
  450.   #--------------------------------------------------------------------------
  451.   # ● 対象アクター選択の終了
  452.   #--------------------------------------------------------------------------
  453.   alias end_target_actor_selection_KGC_SeparationCommand end_target_actor_selection
  454.   def end_target_actor_selection
  455.     end_target_actor_selection_KGC_SeparationCommand

  456.     case @actor_command_window.index
  457.     when @actor_command_window.own_index_range  # 固有コマンドの場合
  458.       @actor_command_window.active = true        # アクターコマンドに戻る
  459.     else
  460.       @actor_command_window.active = false
  461.     end
  462.   end
  463. end

复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-6-8 11:24

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表