CyberForte

DoW Skill CP

Oct 10th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 60.32 KB | None | 0 0
  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
  2. #_/ ◆ Skill CP System - KGC_SkillCPSystem ◆ VX ◆
  3. #_/ ◇  Last Update: 03/31/2009
  4. #_/ ◆ Written by TOMY    
  5. #_/ ◆ Translation by Mr. Anonymous                  
  6. #_/ ◆ KGC Site:                                                  
  7. #_/ ◆  http://ytomy.sakura.ne.jp/                                  
  8. #_/ ◆ Translator's Blog:                                            
  9. #_/ ◆  http://mraprojects.wordpress.com    
  10. #_/-----------------------------------------------------------------------------
  11. #_/  This script allows the designer to limit the amount of skills the player
  12. #_/   may have at his disposal in battle. The player may assign skills the
  13. #_/   actor has learned to an available skills list by using CP. Additional CP
  14. #_/   is gained upon level-up.
  15. #_/-----------------------------------------------------------------------------
  16. #_/                       ◆ Instructions For Usage ◆
  17. #_/ ◆ Assign CP Cost to a skill:
  18. #_/ To manually set individual CP requirements to a given skill, locate the
  19. #_/ desired skill in the Skills tab of the database, and enter:
  20. #_/
  21. #_/  <CP Value>
  22. #_/
  23. #_/   into that skill's "Note" box.
  24. #_/     Where Value = the desired number of CP it costs to assign that skill to
  25. #_/      a skill slot.
  26. #_/   Example: You'd like Dual Strike to cost 2 CP to equip. You'd locate
  27. #_/    'Dual Strike' in the database an insert <CP 2> in the notebox.
  28. #_/
  29. #_/ ◆ Increase/Decrease MAX CP by equipping item:
  30. #_/ To create an equipable item that changes an actor's MAX CP, locate the
  31. #_/ desired item in the Weapons or Armors tab of the database, and enter:
  32. #_/
  33. #_/  <MAX CP Modifier Value> OR <max CP Modifier Value>
  34. #_/
  35. #_/   into that item's "Note" box.
  36. #_/     Where Modifier = + (Addition)  or  - (Subtraction)
  37. #_/     Where Value = the desired number of CP that is increased/decreased.
  38. #_/  
  39. #_/   Example: You'd like Long Sword to add 1 CP when equipped. You'd locate
  40. #_/    'Long Sword' in the database an insert <MAX CP + 1> in the notebox.
  41. #_/
  42. #_/ ◆ Increase/Decrease Max Battle Skill Slots by equipping item:
  43. #_/ To create an equipable item that changes an actor's max battle skill slots,
  44. #_/ locate the desired item in the Weapons or Armors tab of the database, enter:
  45. #_/
  46. #_/  <BATTLE_SKILL_MAX Modifier Value> OR <max_battle_skill Modifier Value>
  47. #_/
  48. #_/   into that item's "Note" box.
  49. #_/     Where Modifier = + (Addition)  or  - (Subtraction)
  50. #_/     Where Value = the desired number of slots that to increase/decrease.
  51. #_/  
  52. #_/   Example: You'd like Leather Shield to reduce the actor's maximum battle
  53. #_/     skill slots by 2 when equipped. You'd locate 'Leather Shield' in the
  54. #_/     armor database an insert <BATTLE_SKILL_MAX - 2> in the notebox.
  55. #_/
  56. #_/  
  57. #_/                           ◆ Script Commands ◆
  58. #_/  These commands are used in "Script" function in the third page of event
  59. #_/   commands under "Advanced".
  60. #_/
  61. #_/  * set_own_cp(ActorID, Value)
  62. #_/     This allows you to set an individual actor's CP. This value cannot
  63. #_/      exceed the default settings for CP_MAX (See the Customization block.)
  64. #_/  
  65. #_/  * set_battle_skill_max(ActorID, Value)
  66. #_/     This allows you to set the maximum amount of skill slots available to
  67. #_/      a individual actors in battle. When the value is omitted, the default
  68. #_/      value of MAX_SKILLS is returned. (See the Customization block.)
  69. #_/  
  70. #_/  * set_battle_skill(ActorID, SkillSlot_index, SkillID)
  71. #_/     This function is still under testing.
  72. #_/  
  73. #_/  * add_battle_skill(ActorID, SkillID)
  74. #_/      Adds a skill to the actor's available skill slots. If the slot is
  75. #_/       unavailable, nothing is added.
  76. #_/  
  77. #_/  * gain_actor_cp(ActorID, Value)
  78. #_/      Allows you to change the amount of skill slots an actor has.
  79. #_/  
  80. #_/  * clear_battle_skill(ActorID)
  81. #_/      All skills are removed from the actor's skill slots. (State: Amnesia!)
  82. #_/  
  83. #_/  * call_set_battle_skill(ActorID)
  84. #_/     This calls the Set Skills screen for the selected actor.
  85. #_/  
  86. #_/  [ Quick Key:                                                              ]
  87. #_/  [ ActorID = The ID number of the selected Actor in the database.          ]
  88. #_/  [                                                                         ]
  89. #_/  [ SkillID = The ID number of the selected Skill in the database.          ]
  90. #_/  [                                                                         ]
  91. #_/  [ Value = A set numerical value.                                          ]
  92. #_/  [                                                                         ]
  93. #_/  [ SkillSlot_Index = The position of the actor's skill slots.              ]
  94. #_/  [                                                                         ]
  95. #_/=============================================================================
  96. #_/ Install: Insert below KGC_EquipLearnSkill, if applicable.
  97. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
  98.  
  99. #==============================================================================#
  100. #                           ★ Customization ★                                  #
  101. #==============================================================================#
  102.  
  103. module KGC
  104. module SkillCPSystem
  105.   #                ◆ Skill CP Window Display Settings ◆
  106.   # ◆  The maximum amount of skills a character is permitted to assign.
  107.   MAX_SKILLS = 11
  108.   # ◆ CP Display Text
  109.   VOCAB_CP   = "SP"
  110.   # ◆ CP Display Text (Abbreviation)
  111.   VOCAB_CP_A = "SP"
  112.   # ◆ Display CP in status screen.
  113.   SHOW_STATUS_CP = true
  114.  
  115.   #                      ◆ CP Values & Level Gain ◆
  116.   #  Default CP cost when not manually assigned to a skill using the <CP n> tag.
  117.   DEFAULT_CP_COST = 1
  118.   # This affects the maximum amount of CP that can be gained.
  119.   CP_MAX = 40
  120.   # This affects the amount of CP actors will begin with when initialized into
  121.   #  the party, including when the player starts the game.
  122.   CP_MIN = 1
  123.   # ◆ Revised CP Maximum
  124.   #  This affects the maximum amount of CP that can be gained when items that
  125.   #   increase CP are equipped.
  126.   REVISED_CP_MAX = 50
  127.   # ◆ Revised CP Minimum
  128.   REVISED_CP_MIN = 0
  129.   #  ◆ CP Level Gain Calculation
  130.   #  Even if the result of this formula is a decimal, it's automatically
  131.   #   converted into an integer.
  132.   #  You may set this value to 0 if you plan on manually assigning each actor's
  133.   #   CP individually.
  134.   CP_CALC_EXP = "level * 0.5 + 5.0"
  135.   # ◆ Individual Actor CP Level Gain
  136.   PERSONAL_CP_CALC_EXP = [] # <- Do not alter or remove!
  137.   #  Below here, you may specify formulas for individual actors that dictates
  138.   #   the amount of CP they recieve upon leveling up. Like CP_CALC_EXP, the
  139.   #   result is converted to an integer.
  140.   #  Format: PERSONAL_CP_CALC_EXP[ActorID] = "Formula"
  141.   #  The format is just like CP_CALC_EXP, except each actor is defined after
  142.   #   PERSONAL_CP_CALC_EXP in brackets [].
  143.   #  Any actor not specified uses the CP_CALC_EXP formula.
  144.   #  Example:
  145.   # PERSONAL_CP_CALC_EXP[1] = "level * 0.8 + 2.0"
  146.   #                 ◆ Insert Personal CP Calculations Below Here ◆
  147.   ### PERSONAL_CP_CALC_EXP[1] = "level * 0.8 + 2.0"
  148.  
  149.   # ◆ Disable Skill CP System During Battle Test
  150.   #  true  : Disables the Skill CP System during Battle Test
  151.   #  false : Enables the Skill CP System during Battle Test (may cause errors)
  152.   DISABLE_IN_BATTLETEST  = true
  153.  
  154.   #                      ◆ Misc CP Settings Toggles ◆
  155.   #  This toggle allows you to show skills in the Set Skills window when the
  156.   #   actor doesn't meet the requirements to use that skill, such as
  157.   #   insufficient MP.
  158.   #  true = Unusuable skills are shown (and able to be set/assigned).
  159.   #  false = Unusuable skill
  160.   SHOW_UNUSABLE_SKILL    = true   #AHHHHHHHHHHHHHHHHHHH
  161.   # ◆ This toggle allows the player to use CP skills even if the CP value is 0.
  162.   USABLE_COST_ZERO_SKILL = true
  163.   #  This toggle allows you to change whether Passive Skills (KCG_PassiveSkill)
  164.   #   need to be set by the player in order for their effects to take place.
  165.   #   *Note: As of now, KCG_HiddenSkills takes no effect on this menu even if
  166.   #          PASSIVE_NEED_TO_SET = false
  167.   #  true = Passive Skills must be set by the player.
  168.   #  false = Passive Skills effects are automatically in effect.
  169.    PASSIVE_NEED_TO_SET    = false
  170.   # ◆ Automatically Set New Skills
  171.   #  This toggle allows you to specify whether new skills are automatically
  172.   #   assigned to skill slots.
  173.   #  true  : Automatically assign new skills to skill slots.
  174.   #         * Skills aquired from KGC_EquipLearnSkill are not automatically set.
  175.   #  false : Require new skills to be set manually.
  176.   AUTO_SET_NEW_SKILL     = true
  177.   # ◆ Display 0 CP Cost
  178.   #  true  : 0 CP Cost is displayed
  179.   #  false : Only 0 or higher CP cost is displayed
  180.   SHOW_ZERO_COST         = false
  181.  
  182.   #                        ◆ CP Gauge Colorization ◆
  183.   # This allows you to change the color of the guages that appear under in the
  184.   #  CP bar. By default, the colors are determined by system colors (the same as
  185.   #  changing the color of text (\c[n]) in the 'Show Message...' event command).
  186.   # The color can also be determined by red, green, and blue values:
  187.   #  Example: GAUGE_END_COLOR = Color.new(255, 0, 0)  <- This is red.
  188.   #  This is the fill color for the early phase of the guage.
  189.   GAUGE_START_COLOR = 13
  190.   #  This is the fill color for the late phase of the guage. (When Full)
  191.   GAUGE_END_COLOR   = 5
  192.  
  193.   #                            ◆ Command Menu ◆
  194.   # This toggle adds the "Assign Skills" (Set Skills) selection to the main
  195.   #  command menu.
  196.   USE_MENU_SET_SKILL_COMMAND = true
  197.   #  Text of the Set Skills selection on the main command window.
  198.   VOCAB_MENU_SET_SKILL       = "Set Skills"
  199.  
  200.   #                         ◆ Misc Vocab Settings ◆
  201.   #  This allows you to change the text displayed in empty skill slots.
  202.   BLANK_TEXT   = "-  EMPTY  -"
  203.   #  This allows you to change the text in the assigned skills header.
  204.   RELEASE_TEXT = "(- NONE -)"
  205.  
  206.   end
  207. end
  208.  
  209. #=============================================================================#
  210. #                          ★ End Customization ★                              #
  211. #=============================================================================#
  212.  
  213. #=================================================#
  214. #                    IMPORT                       #
  215. #=================================================#
  216.  
  217. $imported = {} if $imported == nil
  218. $imported["SkillCPSystem"] = true
  219.  
  220. #=================================================#
  221.  
  222. #==============================================================================
  223. # □ KGC::SkillCPSystem::Regexp
  224. #==============================================================================
  225. # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
  226. #                          Note Field Tag Strings                             #
  227. # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
  228. #  Whatever word(s) are after the separator ( | ) in the following lines are
  229. #   what are used to determine what is searched for in the "Note" section of a
  230. #   skill or equipment.  
  231.  
  232. module KGC::SkillCPSystem
  233.   # Regular Expressions Module
  234.   module Regexp
  235.     # Base Item Module
  236.     module BaseItem
  237.       # Max CP Plus tag string
  238.       MAXCP_PLUS = /<(?:MAX|max)CP\s*([\-\+]?\d+)>/
  239.       # Max Battle Skill Plus tag string
  240.       BATTLE_SKILL_MAX = /<(?:BATTLE_SKILL_MAX|max_battle_skill)\s*([\-\+]?\d+)>/i
  241.     end
  242.  
  243.     # Skill Module
  244.     module Skill
  245.       # CP Cost tag string
  246.       CP_COST = /<CP\s*(\d+)>/i
  247.     end
  248.   end
  249. end
  250.  
  251. #=================================================#
  252.  
  253. #==============================================================================
  254. # □ KGC::Commands
  255. #==============================================================================
  256.  
  257. module KGC
  258. module Commands
  259.   module_function
  260.   #--------------------------------------------------------------------------
  261.   # ○ MaxCP 補正値の取得
  262.   #     actor_id    : アクター ID
  263.   #     variable_id : 取得した値を代入する変数の ID
  264.   #--------------------------------------------------------------------------
  265.   def get_actor_own_cp(actor_id, variable_id = 0)
  266.     value = $game_actors[actor_id].maxcp_plus
  267.     $game_variables[variable_id] = value if variable_id > 0
  268.     return value
  269.   end
  270.   alias get_own_cp get_actor_own_cp unless $@
  271.   #--------------------------------------------------------------------------
  272.   # ○ MaxCP 補正値の変更
  273.   #     actor_id : アクター ID
  274.   #     value    : MaxCP 補正値
  275.   #--------------------------------------------------------------------------
  276.   def set_actor_own_cp(actor_id, value)
  277.     $game_actors[actor_id].maxcp_plus = value
  278.   end
  279.   alias set_own_cp set_actor_own_cp unless $@
  280.   #--------------------------------------------------------------------------
  281.   # ○ アクターの MaxCP 補正値の増加
  282.   #     actor_id : アクター ID
  283.   #     value    : 増加量
  284.   #--------------------------------------------------------------------------
  285.   def gain_actor_cp(actor_id, value)
  286.     $game_actors[actor_id].maxcp_plus += value
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # ○ 登録スキル最大数の取得
  290.   #     actor_id : アクター ID
  291.   #     variable_id : 取得した値を代入する変数の ID
  292.   #--------------------------------------------------------------------------
  293.   def get_battle_skill_max(actor_id, variable_id = 0)
  294.     value = $game_actors[actor_id].battle_skill_max
  295.     $game_variables[variable_id] = value if variable_id > 0
  296.     return value
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # ○ 登録スキル最大数の変更
  300.   #     actor_id : アクター ID
  301.   #     value    : 登録可能数
  302.   #--------------------------------------------------------------------------
  303.   def set_battle_skill_max(actor_id, value = -1)
  304.     $game_actors[actor_id].battle_skill_max = value
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   # ○ スキルが登録されているか
  308.   #     actor_id : アクター ID
  309.   #     skill_id : 確認するスキル ID
  310.   #--------------------------------------------------------------------------
  311.   def battle_skill_set?(actor_id, skill_id)
  312.     return $game_actors[actor_id].battle_skill_ids.include?(skill_id)
  313.   end
  314.   #--------------------------------------------------------------------------
  315.   # ○ スキルの登録
  316.   #     actor_id : アクター ID
  317.   #     index    : 登録箇所
  318.   #     skill_id : 登録するスキル ID (nil で解除)
  319.   #--------------------------------------------------------------------------
  320.   def set_battle_skill(actor_id, index, skill_id = nil)
  321.     actor = $game_actors[actor_id]
  322.     if skill_id.is_a?(Integer)
  323.       # 登録
  324.       skill = $data_skills[skill_id]
  325.       return unless actor.battle_skill_settable?(index, skill)  # セット不可
  326.  
  327.       actor.set_battle_skill(index, skill)
  328.       actor.restore_battle_skill
  329.     else
  330.       # 解除
  331.       actor.remove_battle_skill(index)
  332.     end
  333.   end
  334.   #--------------------------------------------------------------------------
  335.   # ○ スキルの追加登録
  336.   #     actor_id : アクター ID
  337.   #     skill_id : 登録するスキル ID
  338.   #--------------------------------------------------------------------------
  339.   def add_battle_skill(actor_id, skill_id)
  340.     actor = $game_actors[actor_id]
  341.     skill = $data_skills[skill_id]
  342.     return if actor == nil || skill == nil
  343.  
  344.     actor.add_battle_skill(skill)
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ○ スキルの全解除
  348.   #     actor_id : アクター ID
  349.   #--------------------------------------------------------------------------
  350.   def clear_battle_skill(actor_id)
  351.     $game_actors[actor_id].clear_battle_skill
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # ○ スキル設定画面の呼び出し
  355.   #     actor_index : アクターインデックス
  356.   #--------------------------------------------------------------------------
  357.   def call_set_battle_skill(actor_index = 0)
  358.     return if $game_temp.in_battle
  359.     $game_temp.next_scene = :set_battle_skill
  360.     $game_temp.next_scene_actor_index = actor_index
  361.   end
  362. end
  363. end
  364.  
  365. class Game_Interpreter
  366.   include KGC::Commands
  367. end
  368.  
  369. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  370.  
  371. #==============================================================================
  372. # ■ Vocab
  373. #==============================================================================
  374.  
  375. module Vocab
  376.   # CP
  377.   def self.cp
  378.     return KGC::SkillCPSystem::VOCAB_CP
  379.   end
  380.  
  381.   # CP (略)
  382.   def self.cp_a
  383.     return KGC::SkillCPSystem::VOCAB_CP_A
  384.   end
  385.  
  386.   # スキル設定
  387.   def self.set_battle_skill
  388.     return KGC::SkillCPSystem::VOCAB_MENU_SET_SKILL
  389.   end
  390. end
  391.  
  392. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  393.  
  394. #==============================================================================
  395. # ■ RPG::BaseItem
  396. #==============================================================================
  397.  
  398. class RPG::BaseItem
  399.   #--------------------------------------------------------------------------
  400.   # ○ スキルCP制のキャッシュを生成
  401.   #--------------------------------------------------------------------------
  402.   def create_skill_cp_system_cache
  403.     @__maxcp_plus = 0
  404.     @__battle_skill_max_plus = 0
  405.  
  406.     self.note.each_line { |line|
  407.       case line
  408.       when KGC::SkillCPSystem::Regexp::BaseItem::MAXCP_PLUS
  409.         # 最大 CP
  410.         @__maxcp_plus += $1.to_i
  411.       when KGC::SkillCPSystem::Regexp::BaseItem::BATTLE_SKILL_MAX
  412.         # 登録スキル数
  413.         @__battle_skill_max_plus += $1.to_i
  414.       end
  415.     }
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # ○ 最大 CP 補正
  419.   #--------------------------------------------------------------------------
  420.   def maxcp_plus
  421.     create_skill_cp_system_cache if @__maxcp_plus == nil
  422.     return @__maxcp_plus
  423.   end
  424.   #--------------------------------------------------------------------------
  425.   # ○ 登録スキル数補正
  426.   #--------------------------------------------------------------------------
  427.   def battle_skill_max_plus
  428.     create_skill_cp_system_cache if @__battle_skill_max_plus == nil
  429.     return @__battle_skill_max_plus
  430.   end
  431. end
  432.  
  433. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  434.  
  435. #==============================================================================
  436. # ■ RPG::Skill
  437. #==============================================================================
  438.  
  439. class RPG::Skill < RPG::UsableItem
  440.   #--------------------------------------------------------------------------
  441.   # ○ スキルCP制のキャッシュを生成
  442.   #--------------------------------------------------------------------------
  443.   def create_skill_cp_system_cache
  444.     @__cp_cost = KGC::SkillCPSystem::DEFAULT_CP_COST
  445.  
  446.     self.note.each_line { |line|
  447.       case line
  448.       when KGC::SkillCPSystem::Regexp::Skill::CP_COST
  449.         # 消費 CP
  450.         @__cp_cost = $1.to_i
  451.       end
  452.     }
  453.   end
  454.   #--------------------------------------------------------------------------
  455.   # ○ 消費 CP
  456.   #--------------------------------------------------------------------------
  457.   def cp_cost
  458.     create_skill_cp_system_cache if @__cp_cost == nil
  459.     return @__cp_cost
  460.   end
  461. end
  462.  
  463. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  464.  
  465. #==============================================================================
  466. # ■ Game_Battler
  467. #==============================================================================
  468.  
  469. class Game_Battler
  470.   #--------------------------------------------------------------------------
  471.   # ○ 戦闘用スキルセット済み判定
  472.   #     skill : スキル
  473.   #--------------------------------------------------------------------------
  474.   def battle_skill_set?(skill)
  475.     return true
  476.   end
  477. end
  478.  
  479. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  480.  
  481. #==============================================================================
  482. # ■ Game_Actor
  483. #==============================================================================
  484.  
  485. class Game_Actor < Game_Battler
  486.   #--------------------------------------------------------------------------
  487.   # ● 公開インスタンス変数
  488.   #--------------------------------------------------------------------------
  489.   attr_writer   :maxcp_plus               # MaxCP 補正値
  490.   #--------------------------------------------------------------------------
  491.   # ○ MaxCP 取得
  492.   #--------------------------------------------------------------------------
  493.   def maxcp
  494.     calc_exp = KGC::SkillCPSystem::PERSONAL_CP_CALC_EXP[self.id]
  495.     if calc_exp == nil
  496.       calc_exp = KGC::SkillCPSystem::CP_CALC_EXP
  497.     end
  498.     n = Integer(eval(calc_exp))
  499.     n = [[n, cp_limit].min, KGC::SkillCPSystem::CP_MIN].max
  500.     n += maxcp_plus + maxcp_plus_equip
  501.     return [[n, revised_cp_limit].min, KGC::SkillCPSystem::REVISED_CP_MIN].max
  502.   end
  503.   #--------------------------------------------------------------------------
  504.   # ○ CP 取得
  505.   #--------------------------------------------------------------------------
  506.   def cp
  507.     return [maxcp - consumed_cp, 0].max
  508.   end
  509.   #--------------------------------------------------------------------------
  510.   # ○ CP 消費量取得
  511.   #--------------------------------------------------------------------------
  512.   def consumed_cp
  513.     n = 0
  514.     battle_skills.compact.each { |skill| n += skill.cp_cost }
  515.     return n
  516.   end
  517.   #--------------------------------------------------------------------------
  518.   # ○ CP 上限取得
  519.   #--------------------------------------------------------------------------
  520.   def cp_limit
  521.     return KGC::SkillCPSystem::CP_MAX
  522.   end
  523.   #--------------------------------------------------------------------------
  524.   # ○ 補正後の CP 上限取得
  525.   #--------------------------------------------------------------------------
  526.   def revised_cp_limit
  527.     return KGC::SkillCPSystem::REVISED_CP_MAX
  528.   end
  529.   #--------------------------------------------------------------------------
  530.   # ○ MaxCP 補正値取得
  531.   #--------------------------------------------------------------------------
  532.   def maxcp_plus
  533.     if @maxcp_plus == nil
  534.       if @own_cp != nil
  535.         @maxcp_plus = @own_cp
  536.         @own_cp = nil
  537.       else
  538.         @maxcp_plus = 0
  539.       end
  540.     end
  541.     return @maxcp_plus
  542.   end
  543.   #--------------------------------------------------------------------------
  544.   # ○ 装備品による MaxCP 補正値取得
  545.   #--------------------------------------------------------------------------
  546.   def maxcp_plus_equip
  547.     n = 0
  548.     equips.compact.each { |item| n += item.maxcp_plus }
  549.     return n
  550.   end
  551.   #--------------------------------------------------------------------------
  552.   # ● スキル取得
  553.   #--------------------------------------------------------------------------
  554.   alias skills_KGC_SkillCPSystem skills unless $@
  555.   def skills
  556.     return (skill_cp_restrict? ? restricted_skills : skills_KGC_SkillCPSystem)
  557.   end
  558.   #--------------------------------------------------------------------------
  559.   # ○ スキルを制限するか
  560.   #--------------------------------------------------------------------------
  561.   def skill_cp_restrict?
  562.     if $game_temp.in_battle
  563.       # 戦闘テストでないか、戦闘テストでも制限する場合
  564.       return true unless $BTEST && KGC::SkillCPSystem::DISABLE_IN_BATTLETEST
  565.     end
  566.  
  567.     return false
  568.   end
  569.   #--------------------------------------------------------------------------
  570.   # ○ スキルを制限
  571.   #--------------------------------------------------------------------------
  572.   def restricted_skills
  573.     result = all_skills
  574.     result.each_with_index { |skill, i|
  575.       # 消費 CP > 0 のスキルを除外
  576.       if !KGC::SkillCPSystem::USABLE_COST_ZERO_SKILL || skill.cp_cost > 0
  577.         result[i] = nil
  578.       end
  579.       # パッシブスキルを除外
  580.       if $imported["PassiveSkill"] && KGC::SkillCPSystem::PASSIVE_NEED_TO_SET
  581.         if skill.passive &&
  582.             (!KGC::SkillCPSystem::USABLE_COST_ZERO_SKILL || skill.cp_cost > 0)
  583.           result[i] = nil
  584.         end
  585.       end
  586.     }
  587.     result.compact!
  588.     # 戦闘スキルを追加
  589.     result |= battle_skills
  590.     result.sort! { |a, b| a.id <=> b.id }
  591.     return result
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # ○ 全スキル取得
  595.   #--------------------------------------------------------------------------
  596.   def all_skills
  597.     # 一時的に非戦闘中にする
  598.     last_in_battle = $game_temp.in_battle
  599.     $game_temp.in_battle = false
  600.  
  601.     result = skills_KGC_SkillCPSystem
  602.     if $imported["EquipLearnSkill"]
  603.       result |= (equipment_skills | full_ap_skills)
  604.       result.sort! { |a, b| a.id <=> b.id }
  605.     end
  606.  
  607.     # 戦闘中フラグを戻す
  608.     $game_temp.in_battle = last_in_battle
  609.  
  610.     return result
  611.   end
  612.   #--------------------------------------------------------------------------
  613.   # ○ 登録スキル最大数取得
  614.   #--------------------------------------------------------------------------
  615.   def battle_skill_max
  616.     @battle_skill_max = -1 if @battle_skill_max == nil
  617.     n = (@battle_skill_max < 0 ?
  618.       KGC::SkillCPSystem::MAX_SKILLS : @battle_skill_max)
  619.     n += equipment_battle_skill_max_plus
  620.     return [n, 0].max
  621.   end
  622.   #--------------------------------------------------------------------------
  623.   # ○ 装備品による登録スキル数補正
  624.   #--------------------------------------------------------------------------
  625.   def equipment_battle_skill_max_plus
  626.     n = 0
  627.     equips.compact.each { |item| n += item.battle_skill_max_plus }
  628.     return n
  629.   end
  630.   #--------------------------------------------------------------------------
  631.   # ○ 登録スキル最大数設定
  632.   #--------------------------------------------------------------------------
  633.   def battle_skill_max=(value)
  634.     @battle_skill_max = value
  635.     if @battle_skills == nil
  636.       @battle_skills = []
  637.     else
  638.       @battle_skills = @battle_skills[0...value]
  639.     end
  640.     restore_passive_rev if $imported["PassiveSkill"]
  641.   end
  642.   #--------------------------------------------------------------------------
  643.   # ○ 戦闘用スキル ID 取得
  644.   #--------------------------------------------------------------------------
  645.   def battle_skill_ids
  646.     @battle_skills = [] if @battle_skills == nil
  647.     return @battle_skills
  648.   end
  649.   #--------------------------------------------------------------------------
  650.   # ○ 戦闘用スキル取得
  651.   #--------------------------------------------------------------------------
  652.   def battle_skills
  653.     result = []
  654.     battle_skill_ids.each { |i|
  655.       next if i == nil           # 無効なスキルは無視
  656.       result << $data_skills[i]
  657.     }
  658.     return result
  659.   end
  660.   #--------------------------------------------------------------------------
  661.   # ○ 戦闘用スキル登録
  662.   #     index : 位置
  663.   #     skill : スキル (nil で解除)
  664.   #--------------------------------------------------------------------------
  665.   def set_battle_skill(index, skill)
  666.     if skill == nil
  667.       @battle_skills[index] = nil
  668.     else
  669.       return unless skill.is_a?(RPG::Skill)  # スキル以外
  670.       return if cp < skill.cp_cost           # CP 不足
  671.       return if KGC::SkillCPSystem::USABLE_COST_ZERO_SKILL && skill.cp_cost == 0
  672.  
  673.       @battle_skills[index] = skill.id
  674.     end
  675.     restore_passive_rev if $imported["PassiveSkill"]
  676.   end
  677.   #--------------------------------------------------------------------------
  678.   # ○ 戦闘用スキル追加登録
  679.   #     skill : スキル
  680.   #--------------------------------------------------------------------------
  681.   def add_battle_skill(skill)
  682.     return unless skill.is_a?(RPG::Skill)  # スキル以外
  683.     skills = battle_skill_ids
  684.     return if skills.include?(skill.id)    # 登録済み
  685.     return if cp < skill.cp_cost           # CP 不足
  686.     return if KGC::SkillCPSystem::USABLE_COST_ZERO_SKILL && skill.cp_cost == 0
  687.  
  688.     battle_skill_max.times { |i|
  689.       # 空きがあれば登録
  690.       if skills[i] == nil
  691.         set_battle_skill(i, skill)
  692.         break
  693.       end
  694.     }
  695.     restore_battle_skill
  696.   end
  697.   #--------------------------------------------------------------------------
  698.   # ○ 戦闘用スキル解除
  699.   #     index : 位置
  700.   #--------------------------------------------------------------------------
  701.   def remove_battle_skill(index)
  702.     @battle_skills[index] = nil
  703.     restore_passive_rev if $imported["PassiveSkill"]
  704.   end
  705.   #--------------------------------------------------------------------------
  706.   # ○ 戦闘用スキル全解除
  707.   #--------------------------------------------------------------------------
  708.   def clear_battle_skill
  709.     @battle_skills = []
  710.     restore_passive_rev if $imported["PassiveSkill"]
  711.   end
  712.   #--------------------------------------------------------------------------
  713.   # ○ 戦闘用スキルセット可否判定
  714.   #     index : 位置
  715.   #     skill : スキル
  716.   #--------------------------------------------------------------------------
  717.   def battle_skill_settable?(index, skill)
  718.     return false if battle_skill_max <= index  # 範囲外
  719.     return true  if skill == nil               # nil は解除なので OK
  720.  
  721.     return false if battle_skill_ids.include?(skill.id)  # セット済み
  722.  
  723.     skill_id = battle_skill_ids[index]
  724.     curr_skill = (skill_id != nil ? $data_skills[skill_id] : nil)
  725.     offset = (curr_skill != nil ? curr_skill.cp_cost : 0)
  726.     return false if self.cp < (skill.cp_cost - offset)  # CP 不足
  727.  
  728.     return true
  729.   end
  730.   #--------------------------------------------------------------------------
  731.   # ○ 戦闘用スキルを修復
  732.   #--------------------------------------------------------------------------
  733.   def restore_battle_skill
  734.     result = battle_skill_ids.clone
  735.     usable_skills = all_skills
  736.  
  737.     result.each_with_index { |n, i|
  738.       next if n == nil
  739.       # 未修得の場合は解除
  740.       if (usable_skills.find { |s| s.id == n }) == nil
  741.         result[i] = nil
  742.       end
  743.     }
  744.     @battle_skills = result[0...battle_skill_max]
  745.     # CP 不足のスキルを下から順に外す
  746.     (battle_skill_max - 1).downto(0) { |i|
  747.       @battle_skills[i] = nil if maxcp - consumed_cp < 0
  748.     }
  749.   end
  750.   #--------------------------------------------------------------------------
  751.   # ● 装備の変更 (オブジェクトで指定)
  752.   #     equip_type : 装備部位 (0..4)
  753.   #     item       : 武器 or 防具 (nil なら装備解除)
  754.   #     test       : テストフラグ (戦闘テスト、または装備画面での一時装備)
  755.   #--------------------------------------------------------------------------
  756.   alias change_equip_KGC_SkillCPSystem change_equip unless $@
  757.   def change_equip(equip_type, item, test = false)
  758.     change_equip_KGC_SkillCPSystem(equip_type, item, test)
  759.  
  760.     unless test
  761.       restore_battle_skill
  762.       restore_passive_rev if $imported["PassiveSkill"]
  763.     end
  764.   end
  765.   #--------------------------------------------------------------------------
  766.   # ● 装備の破棄
  767.   #     item : 破棄する武器 or 防具
  768.   #    武器/防具の増減で「装備品も含める」のとき使用する。
  769.   #--------------------------------------------------------------------------
  770.   alias discard_equip_KGC_SkillCPSystem discard_equip unless $@
  771.   def discard_equip(item)
  772.     discard_equip_KGC_SkillCPSystem(item)
  773.  
  774.     restore_battle_skill
  775.     restore_passive_rev if $imported["PassiveSkill"]
  776.   end
  777.   #--------------------------------------------------------------------------
  778.   # ● 経験値の変更
  779.   #     exp  : 新しい経験値
  780.   #     show : レベルアップ表示フラグ
  781.   #--------------------------------------------------------------------------
  782.   alias change_exp_KGC_SkillCPSystem change_exp unless $@
  783.   def change_exp(exp, show)
  784.     # 習得したスキルを表示するため、戦闘中フラグを一時的に解除
  785.     last_in_battle = $game_temp.in_battle
  786.     $game_temp.in_battle = false
  787.  
  788.     change_exp_KGC_SkillCPSystem(exp, show)
  789.  
  790.     $game_temp.in_battle = last_in_battle
  791.   end
  792.  
  793.   if KGC::SkillCPSystem::AUTO_SET_NEW_SKILL
  794.   #--------------------------------------------------------------------------
  795.   # ● スキルを覚える
  796.   #     skill_id : スキル ID
  797.   #--------------------------------------------------------------------------
  798.   alias learn_skill_KGC_SkillCPSystem learn_skill unless $@
  799.   def learn_skill(skill_id)
  800.     learn_skill_KGC_SkillCPSystem(skill_id)
  801.  
  802.     add_battle_skill($data_skills[skill_id])
  803.   end
  804.   end  # <- if KGC::SkillCPSystem::AUTO_SET_NEW_SKILL
  805.  
  806.   #--------------------------------------------------------------------------
  807.   # ● スキルを忘れる
  808.   #     skill_id : スキル ID
  809.   #--------------------------------------------------------------------------
  810.   alias forget_skill_KGC_SkillCPSystem forget_skill unless $@
  811.   def forget_skill(skill_id)
  812.     # 忘れるスキルを戦闘用スキルから削除
  813.     battle_skill_ids.each_with_index { |s, i|
  814.       remove_battle_skill(i) if s == skill_id
  815.     }
  816.  
  817.     forget_skill_KGC_SkillCPSystem(skill_id)
  818.   end
  819.   #--------------------------------------------------------------------------
  820.   # ○ 戦闘用スキルセット済み判定
  821.   #     skill : スキル
  822.   #--------------------------------------------------------------------------
  823.   def battle_skill_set?(skill)
  824.     return false unless skill.is_a?(RPG::Skill)  # スキル以外
  825.  
  826.     return battle_skill_ids.include?(skill.id)
  827.   end
  828. end
  829.  
  830. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  831.  
  832. #==============================================================================
  833. # ■ Window_Base
  834. #==============================================================================
  835.  
  836. class Window_Base < Window
  837.   #--------------------------------------------------------------------------
  838.   # ○ CP の文字色を取得
  839.   #     actor : アクター
  840.   #--------------------------------------------------------------------------
  841.   def cp_color(actor)
  842.     return knockout_color if actor.maxcp > 0 && actor.cp == 0
  843.     return normal_color
  844.   end
  845.   #--------------------------------------------------------------------------
  846.   # ○ CP ゲージの色 1 の取得
  847.   #--------------------------------------------------------------------------
  848.   def cp_gauge_color1
  849.     color = KGC::SkillCPSystem::GAUGE_START_COLOR
  850.     return (color.is_a?(Integer) ? text_color(color) : color)
  851.   end
  852.   #--------------------------------------------------------------------------
  853.   # ○ CP ゲージの色 2 の取得
  854.   #--------------------------------------------------------------------------
  855.   def cp_gauge_color2
  856.     color = KGC::SkillCPSystem::GAUGE_END_COLOR
  857.     return (color.is_a?(Integer) ? text_color(color) : color)
  858.   end
  859.   #--------------------------------------------------------------------------
  860.   # ○ CP の描画
  861.   #     actor : アクター
  862.   #     x     : 描画先 X 座標
  863.   #     y     : 描画先 Y 座標
  864.   #     width : 幅
  865.   #--------------------------------------------------------------------------
  866.   def draw_actor_cp(actor, x, y, width = 120)
  867.     draw_actor_cp_gauge(actor, x, y, width)
  868.     self.contents.font.color = system_color
  869.     self.contents.draw_text(x, y, 30, WLH, Vocab::cp_a)
  870.     self.contents.font.color = cp_color(actor)
  871.     xr = x + width
  872.     if width < 120
  873.       self.contents.draw_text(xr - 40, y, 40, WLH, actor.cp, 2)
  874.     else
  875.       self.contents.draw_text(xr - 90, y, 40, WLH, actor.cp, 2)
  876.       self.contents.font.color = normal_color
  877.       self.contents.draw_text(xr - 50, y, 10, WLH, "/", 2)
  878.       self.contents.draw_text(xr - 40, y, 40, WLH, actor.maxcp, 2)
  879.     end
  880.     self.contents.font.color = normal_color
  881.   end
  882.   #--------------------------------------------------------------------------
  883.   # ○ CP ゲージの描画
  884.   #     actor : アクター
  885.   #     x     : 描画先 X 座標
  886.   #     y     : 描画先 Y 座標
  887.   #     width : 幅
  888.   #--------------------------------------------------------------------------
  889.   def draw_actor_cp_gauge(actor, x, y, width = 120)
  890.     gw = width * actor.cp / [actor.maxcp, 1].max
  891.     gc1 = cp_gauge_color1
  892.     gc2 = cp_gauge_color2
  893.     self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
  894.     self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
  895.   end
  896. end
  897.  
  898. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  899.  
  900. #==============================================================================
  901. # ■ Window_Command
  902. #==============================================================================
  903.  
  904. class Window_Command < Window_Selectable
  905.   unless method_defined?(:add_command)
  906.   #--------------------------------------------------------------------------
  907.   # ○ コマンドを追加
  908.   #    追加した位置を返す
  909.   #--------------------------------------------------------------------------
  910.   def add_command(command)
  911.     @commands << command
  912.     @item_max = @commands.size
  913.     item_index = @item_max - 1
  914.     refresh_command
  915.     draw_item(item_index)
  916.     return item_index
  917.   end
  918.   #--------------------------------------------------------------------------
  919.   # ○ コマンドをリフレッシュ
  920.   #--------------------------------------------------------------------------
  921.   def refresh_command
  922.     buf = self.contents.clone
  923.     self.height = [self.height, row_max * WLH + 32].max
  924.     create_contents
  925.     self.contents.blt(0, 0, buf, buf.rect)
  926.     buf.dispose
  927.   end
  928.   #--------------------------------------------------------------------------
  929.   # ○ コマンドを挿入
  930.   #--------------------------------------------------------------------------
  931.   def insert_command(index, command)
  932.     @commands.insert(index, command)
  933.     @item_max = @commands.size
  934.     refresh_command
  935.     refresh
  936.   end
  937.   #--------------------------------------------------------------------------
  938.   # ○ コマンドを削除
  939.   #--------------------------------------------------------------------------
  940.   def remove_command(command)
  941.     @commands.delete(command)
  942.     @item_max = @commands.size
  943.     refresh
  944.   end
  945.   end
  946. end
  947.  
  948. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  949.  
  950. #==============================================================================
  951. # ■ Window_Status
  952. #==============================================================================
  953.  
  954. if KGC::SkillCPSystem::SHOW_STATUS_CP
  955. class Window_Status < Window_Base
  956.   #--------------------------------------------------------------------------
  957.   # ● 基本情報の描画
  958.   #     x : 描画先 X 座標
  959.   #     y : 描画先 Y 座標
  960.   #--------------------------------------------------------------------------
  961.   alias draw_basic_info_KGC_SkillCPSystem draw_basic_info unless $@
  962.   def draw_basic_info(x, y)
  963.     draw_basic_info_KGC_SkillCPSystem(x, y)
  964.  
  965.     draw_actor_cp(@actor, x, y + WLH * 4)
  966.   end
  967. end
  968. end
  969.  
  970. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  971.  
  972. #==============================================================================
  973. # □ Window_BattleSkillStatus
  974. #------------------------------------------------------------------------------
  975. #   戦闘スキル設定画面で、設定者のステータスを表示するウィンドウです。
  976. #==============================================================================
  977.  
  978. class Window_BattleSkillStatus < Window_Base
  979.   #--------------------------------------------------------------------------
  980.   # ● オブジェクト初期化
  981.   #     x     : ウィンドウの X 座標
  982.   #     y     : ウィンドウの Y 座標
  983.   #     actor : アクター
  984.   #--------------------------------------------------------------------------
  985.   def initialize(x, y, actor)
  986.     super(x, y, Graphics.width, WLH + 32)
  987.     @actor = actor
  988.     refresh
  989.   end
  990.   #--------------------------------------------------------------------------
  991.   # ● リフレッシュ
  992.   #--------------------------------------------------------------------------
  993.   def refresh
  994.     self.contents.clear
  995.     draw_actor_name(@actor, 4, 0)
  996.     draw_actor_level(@actor, 140, 0)
  997.     draw_actor_cp(@actor, 240, 0)
  998.   end
  999. end
  1000.  
  1001. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  1002.  
  1003. #==============================================================================
  1004. # □ Window_BattleSkillSlot
  1005. #------------------------------------------------------------------------------
  1006. #   戦闘スキル選択画面で、設定したスキルの一覧を表示するウィンドウです。
  1007. #==============================================================================
  1008.  
  1009. class Window_BattleSkillSlot < Window_Selectable
  1010.   #--------------------------------------------------------------------------
  1011.   # ● オブジェクト初期化
  1012.   #     x      : ウィンドウの X 座標
  1013.   #     y      : ウィンドウの Y 座標
  1014.   #     width  : ウィンドウの幅
  1015.   #     height : ウィンドウの高さ
  1016.   #     actor  : アクター
  1017.   #--------------------------------------------------------------------------
  1018.   def initialize(x, y, width, height, actor)
  1019.     super(x, y, width, height)
  1020.     @actor = actor
  1021.     self.index = 0
  1022.     self.active = false
  1023.     refresh
  1024.   end
  1025.   #--------------------------------------------------------------------------
  1026.   # ○ スキルの取得
  1027.   #--------------------------------------------------------------------------
  1028.   def skill
  1029.     return @data[self.index]
  1030.   end
  1031.   #--------------------------------------------------------------------------
  1032.   # ● リフレッシュ
  1033.   #--------------------------------------------------------------------------
  1034.   def refresh
  1035.     @data = []
  1036.     skill_ids = @actor.battle_skill_ids
  1037.     @actor.battle_skill_max.times { |i|
  1038.       if skill_ids[i] != nil
  1039.         @data << $data_skills[skill_ids[i]]
  1040.       else
  1041.         @data << nil
  1042.       end
  1043.     }
  1044.     @item_max = @data.size
  1045.     create_contents
  1046.     @item_max.times { |i| draw_item(i) }
  1047.   end
  1048.   #--------------------------------------------------------------------------
  1049.   # ○ 消費 CP 描画判定
  1050.   #--------------------------------------------------------------------------
  1051.   def cp_cost_show?(skill)
  1052.     return true if KGC::SkillCPSystem::SHOW_ZERO_COST
  1053.  
  1054.     return (skill.cp_cost > 0)
  1055.   end
  1056.   #--------------------------------------------------------------------------
  1057.   # ○ 項目の描画
  1058.   #     index : 項目番号
  1059.   #--------------------------------------------------------------------------
  1060.   def draw_item(index)
  1061.     rect = item_rect(index)
  1062.     self.contents.clear_rect(rect)
  1063.     skill = @data[index]
  1064.     if skill != nil
  1065.       rect.width -= 4
  1066.       draw_item_name(skill, rect.x, rect.y)
  1067.       self.contents.draw_text(rect, skill.cp_cost, 2) if cp_cost_show?(skill)
  1068.     else
  1069.       self.contents.draw_text(rect, KGC::SkillCPSystem::BLANK_TEXT, 1)
  1070.     end
  1071.   end
  1072.   #--------------------------------------------------------------------------
  1073.   # ● カーソルを 1 ページ後ろに移動
  1074.   #--------------------------------------------------------------------------
  1075.   def cursor_pagedown
  1076.     return if Input.repeat?(Input::R)
  1077.     super
  1078.   end
  1079.   #--------------------------------------------------------------------------
  1080.   # ● カーソルを 1 ページ前に移動
  1081.   #--------------------------------------------------------------------------
  1082.   def cursor_pageup
  1083.     return if Input.repeat?(Input::L)
  1084.     super
  1085.   end
  1086.   #--------------------------------------------------------------------------
  1087.   # ● フレーム更新
  1088.   #--------------------------------------------------------------------------
  1089.   def update
  1090.     super
  1091.     return unless self.active
  1092.  
  1093.     if Input.repeat?(Input::RIGHT)
  1094.       Sound.play_cursor
  1095.       cursor_pagedown
  1096.     elsif Input.repeat?(Input::LEFT)
  1097.       Sound.play_cursor
  1098.       cursor_pageup
  1099.     end
  1100.   end
  1101.   #--------------------------------------------------------------------------
  1102.   # ● ヘルプテキスト更新
  1103.   #--------------------------------------------------------------------------
  1104.   def update_help
  1105.     @help_window.set_text(skill == nil ? "" : skill.description)
  1106.   end
  1107. end
  1108.  
  1109. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  1110.  
  1111. #==============================================================================
  1112. # □ Window_BattleSkillList
  1113. #------------------------------------------------------------------------------
  1114. #   戦闘スキル選択画面で、設定できるスキルの一覧を表示するウィンドウです。
  1115. #==============================================================================
  1116.  
  1117. class Window_BattleSkillList < Window_Selectable
  1118.   #--------------------------------------------------------------------------
  1119.   # ● 公開インスタンス変数
  1120.   #--------------------------------------------------------------------------
  1121.   attr_accessor :slot_index               # スロット番号
  1122.   #--------------------------------------------------------------------------
  1123.   # ● オブジェクト初期化
  1124.   #     x      : ウィンドウの X 座標
  1125.   #     y      : ウィンドウの Y 座標
  1126.   #     width  : ウィンドウの幅
  1127.   #     height : ウィンドウの高さ
  1128.   #     actor  : アクター
  1129.   #--------------------------------------------------------------------------
  1130.   def initialize(x, y, width, height, actor)
  1131.     super(x, y, width, height)
  1132.     @actor = actor
  1133.     @slot_index = 0
  1134.     self.index = 0
  1135.     self.active = false
  1136.     refresh
  1137.   end
  1138.   #--------------------------------------------------------------------------
  1139.   # ○ スキルの取得
  1140.   #--------------------------------------------------------------------------
  1141.   def skill
  1142.     return @data[self.index]
  1143.   end
  1144.   #--------------------------------------------------------------------------
  1145.   # ● リフレッシュ
  1146.   #--------------------------------------------------------------------------
  1147.   def refresh
  1148.     @data = [nil]
  1149.     # 選択可能なスキルのみを取得
  1150.     @actor.all_skills.each { |skill|
  1151.       @data.push(skill) if selectable?(skill)
  1152.     }
  1153.  
  1154.     @item_max = @data.size
  1155.     create_contents
  1156.     @item_max.times { |i| draw_item(i) }
  1157.   end
  1158.   #--------------------------------------------------------------------------
  1159.   # ○ スキル選択可否判定
  1160.   #     skill : スキル
  1161.   #--------------------------------------------------------------------------
  1162.   def selectable?(skill)
  1163.     return false if skill == nil
  1164.  
  1165.     # 消費 CP 0 なら常に使用可能な場合
  1166.     if KGC::SkillCPSystem::USABLE_COST_ZERO_SKILL && skill.cp_cost == 0
  1167.       return false
  1168.     end
  1169.     # 戦闘時に使用可能ならOK
  1170.     return true if skill.battle_ok?
  1171.     # 使用不可でもセット可能な場合
  1172. ###    if KGC::SkillCPSystem::SHOW_UNUSABLE_SKILL && skill.occasion == 3
  1173. ###      return true
  1174. ###    end
  1175.  
  1176.     return false
  1177.   end
  1178.   #--------------------------------------------------------------------------
  1179.   # ○ 消費 CP 描画判定
  1180.   #--------------------------------------------------------------------------
  1181.   def cp_cost_show?(skill)
  1182.     return true if KGC::SkillCPSystem::SHOW_ZERO_COST
  1183.  
  1184.     return (skill.cp_cost > 0)
  1185.   end
  1186.   #--------------------------------------------------------------------------
  1187.   # ○ 項目の描画
  1188.   #     index : 項目番号
  1189.   #--------------------------------------------------------------------------
  1190.   def draw_item(index)
  1191.     rect = item_rect(index)
  1192.     self.contents.clear_rect(rect)
  1193.     skill = @data[index]
  1194.     if skill != nil
  1195.       rect.width -= 4
  1196.       enabled = @actor.battle_skill_settable?(@slot_index, skill)
  1197.       draw_item_name(skill, rect.x, rect.y, enabled)
  1198.       self.contents.draw_text(rect, skill.cp_cost, 2) if cp_cost_show?(skill)
  1199.     else
  1200.       self.contents.draw_text(rect, KGC::SkillCPSystem::RELEASE_TEXT, 1)
  1201.     end
  1202.   end
  1203.   #--------------------------------------------------------------------------
  1204.   # ● フレーム更新
  1205.   #--------------------------------------------------------------------------
  1206.   def update
  1207.     super
  1208.     return unless self.active
  1209.  
  1210.     if Input.repeat?(Input::RIGHT)
  1211.       cursor_pagedown
  1212.     elsif Input.repeat?(Input::LEFT)
  1213.       cursor_pageup
  1214.     end
  1215.   end
  1216.   #--------------------------------------------------------------------------
  1217.   # ● ヘルプテキスト更新
  1218.   #--------------------------------------------------------------------------
  1219.   def update_help
  1220.     @help_window.set_text(skill == nil ? "" : skill.description)
  1221.   end
  1222. end
  1223.  
  1224. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  1225.  
  1226. #==============================================================================
  1227. # ■ Scene_Map
  1228. #==============================================================================
  1229.  
  1230. class Scene_Map < Scene_Base
  1231.   #--------------------------------------------------------------------------
  1232.   # ● 画面切り替えの実行
  1233.   #--------------------------------------------------------------------------
  1234.   alias update_scene_change_KGC_SkillCPSystem update_scene_change unless $@
  1235.   def update_scene_change
  1236.     return if $game_player.moving?    # プレイヤーの移動中?
  1237.  
  1238.     if $game_temp.next_scene == :set_battle_skill
  1239.       call_set_battle_skill
  1240.       return
  1241.     end
  1242.  
  1243.     update_scene_change_KGC_SkillCPSystem
  1244.   end
  1245.   #--------------------------------------------------------------------------
  1246.   # ○ スキル設定画面への切り替え
  1247.   #--------------------------------------------------------------------------
  1248.   def call_set_battle_skill
  1249.     $game_temp.next_scene = nil
  1250.     $scene = Scene_SetBattleSkill.new(
  1251.       $game_temp.next_scene_actor_index,
  1252.       0,
  1253.       Scene_SetBattleSkill::HOST_MAP)
  1254.   end
  1255. end
  1256.  
  1257. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  1258.  
  1259. #==============================================================================
  1260. # ■ Scene_Menu
  1261. #==============================================================================
  1262.  
  1263. class Scene_Menu < Scene_Base
  1264.   if KGC::SkillCPSystem::USE_MENU_SET_SKILL_COMMAND
  1265.   #--------------------------------------------------------------------------
  1266.   # ● コマンドウィンドウの作成
  1267.   #--------------------------------------------------------------------------
  1268.   alias create_command_window_KGC_SkillCPSystem create_command_window unless $@
  1269.   def create_command_window
  1270.     create_command_window_KGC_SkillCPSystem
  1271.  
  1272.     return if $imported["CustomMenuCommand"]
  1273.  
  1274.     @__command_set_battle_skill_index =
  1275.       @command_window.add_command(Vocab.set_battle_skill)
  1276.     if @command_window.oy > 0
  1277.       @command_window.oy -= Window_Base::WLH
  1278.     end
  1279.     @command_window.index = @menu_index
  1280.   end
  1281.   end
  1282.   #--------------------------------------------------------------------------
  1283.   # ● コマンド選択の更新
  1284.   #--------------------------------------------------------------------------
  1285.   alias update_command_selection_KGC_SkillCPSystem update_command_selection unless $@
  1286.   def update_command_selection
  1287.     call_set_battle_skill_flag = false
  1288.     if Input.trigger?(Input::C)
  1289.       case @command_window.index
  1290.       when @__command_set_battle_skill_index  # スキル設定
  1291.         call_set_battle_skill_flag = true
  1292.       end
  1293.     end
  1294.  
  1295.     # スキル設定画面に移行
  1296.     if call_set_battle_skill_flag
  1297.       if $game_party.members.size == 0
  1298.         Sound.play_buzzer
  1299.         return
  1300.       end
  1301.       Sound.play_decision
  1302.       start_actor_selection
  1303.       return
  1304.     end
  1305.  
  1306.     update_command_selection_KGC_SkillCPSystem
  1307.   end
  1308.   #--------------------------------------------------------------------------
  1309.   # ● アクター選択の更新
  1310.   #--------------------------------------------------------------------------
  1311.   alias update_actor_selection_KGC_SkillCPSystem update_actor_selection unless $@
  1312.   def update_actor_selection
  1313.     if Input.trigger?(Input::C)
  1314.       $game_party.last_actor_index = @status_window.index
  1315.       Sound.play_decision
  1316.       case @command_window.index
  1317.       when @__command_set_battle_skill_index  # スキル設定
  1318.         $scene = Scene_SetBattleSkill.new(
  1319.           @status_window.index,
  1320.           @__command_set_battle_skill_index,
  1321.           Scene_SetBattleSkill::HOST_MENU)
  1322.         return
  1323.       end
  1324.     end
  1325.  
  1326.     update_actor_selection_KGC_SkillCPSystem
  1327.   end
  1328. end
  1329.  
  1330. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  1331.  
  1332. #==============================================================================
  1333. # □ Scene_SetBattleSkill
  1334. #------------------------------------------------------------------------------
  1335. #   戦闘スキル設定画面の処理を行うクラスです。
  1336. #==============================================================================
  1337.  
  1338. class Scene_SetBattleSkill < Scene_Base
  1339.   #--------------------------------------------------------------------------
  1340.   # ○ 定数
  1341.   #--------------------------------------------------------------------------
  1342.   HOST_MENU   = 0  # 呼び出し元 : メニュー
  1343.   HOST_MAP    = 1  # 呼び出し元 : マップ
  1344.   #--------------------------------------------------------------------------
  1345.   # ● オブジェクト初期化
  1346.   #     actor_index : アクターインデックス
  1347.   #     menu_index  : コマンドのカーソル初期位置
  1348.   #     host_scene  : 呼び出し元 (0..メニュー  1..マップ)
  1349.   #--------------------------------------------------------------------------
  1350.   def initialize(actor_index = 0, menu_index = 0, host_scene = HOST_MENU)
  1351.     @actor_index = actor_index
  1352.     @menu_index = menu_index
  1353.     @host_scene = host_scene
  1354.   end
  1355.   #--------------------------------------------------------------------------
  1356.   # ● 開始処理
  1357.   #--------------------------------------------------------------------------
  1358.   def start
  1359.     super
  1360.     create_menu_background
  1361.  
  1362.     @actor = $game_party.members[@actor_index]
  1363.     create_windows
  1364.   end
  1365.   #--------------------------------------------------------------------------
  1366.   # ○ ウィンドウ作成
  1367.   #--------------------------------------------------------------------------
  1368.   def create_windows
  1369.     @help_window = Window_Help.new
  1370.     if $imported["HelpExtension"]
  1371.       @help_window.row_max = KGC::HelpExtension::ROW_MAX
  1372.     end
  1373.  
  1374.     dy = @help_window.height
  1375.     @status_window = Window_BattleSkillStatus.new(0, dy, @actor)
  1376.  
  1377.     dy += @status_window.height
  1378.     @slot_window = Window_BattleSkillSlot.new(
  1379.       0,
  1380.       dy,
  1381.       Graphics.width / 2,
  1382.       Graphics.height - dy,
  1383.       @actor)
  1384.     @slot_window.help_window = @help_window
  1385.     @slot_window.active = true
  1386.  
  1387.     @list_window = Window_BattleSkillList.new(
  1388.       Graphics.width - @slot_window.width,
  1389.       dy,
  1390.       Graphics.width - @slot_window.width,
  1391.       Graphics.height - dy,
  1392.       @actor)
  1393.     @list_window.help_window = @help_window
  1394.   end
  1395.   #--------------------------------------------------------------------------
  1396.   # ● 終了処理
  1397.   #--------------------------------------------------------------------------
  1398.   def terminate
  1399.     super
  1400.     dispose_menu_background
  1401.     @help_window.dispose
  1402.     @status_window.dispose
  1403.     @slot_window.dispose
  1404.     @list_window.dispose
  1405.   end
  1406.   #--------------------------------------------------------------------------
  1407.   # ○ 元の画面へ戻る
  1408.   #--------------------------------------------------------------------------
  1409.   def return_scene
  1410.     case @host_scene
  1411.     when HOST_MENU
  1412.       $scene = Scene_Menu.new(@menu_index)
  1413.     when HOST_MAP
  1414.       $scene = Scene_Map.new
  1415.     end
  1416.   end
  1417.   #--------------------------------------------------------------------------
  1418.   # ● フレーム更新
  1419.   #--------------------------------------------------------------------------
  1420.   def update
  1421.     super
  1422.     update_menu_background
  1423.     update_window
  1424.     if @slot_window.active
  1425.       update_slot
  1426.     elsif @list_window.active
  1427.       update_list
  1428.     end
  1429.   end
  1430.   #--------------------------------------------------------------------------
  1431.   # ○ ウィンドウ更新
  1432.   #--------------------------------------------------------------------------
  1433.   def update_window
  1434.     @help_window.update
  1435.     @status_window.update
  1436.     @slot_window.update
  1437.     @list_window.update
  1438.   end
  1439.   #--------------------------------------------------------------------------
  1440.   # ○ ウィンドウ再描画
  1441.   #--------------------------------------------------------------------------
  1442.   def refresh_window
  1443.     @status_window.refresh
  1444.     @slot_window.refresh
  1445.     @list_window.refresh
  1446.   end
  1447.   #--------------------------------------------------------------------------
  1448.   # ○ 次のアクターの画面に切り替え
  1449.   #--------------------------------------------------------------------------
  1450.   def next_actor
  1451.     @actor_index += 1
  1452.     @actor_index %= $game_party.members.size
  1453.     $scene = Scene_SetBattleSkill.new(@actor_index, @menu_index, @host_scene)
  1454.   end
  1455.   #--------------------------------------------------------------------------
  1456.   # ○ 前のアクターの画面に切り替え
  1457.   #--------------------------------------------------------------------------
  1458.   def prev_actor
  1459.     @actor_index += $game_party.members.size - 1
  1460.     @actor_index %= $game_party.members.size
  1461.     $scene = Scene_SetBattleSkill.new(@actor_index, @menu_index, @host_scene)
  1462.   end
  1463.   #--------------------------------------------------------------------------
  1464.   # ○ フレーム更新 (スロットウィンドウがアクティブの場合)
  1465.   #--------------------------------------------------------------------------
  1466.   def update_slot
  1467.     # 選択項目が変化した場合
  1468.     if @last_slot_index != @slot_window.index
  1469.       @list_window.slot_index = @slot_window.index
  1470.       @list_window.refresh
  1471.       @last_slot_index = @slot_window.index
  1472.     end
  1473.  
  1474.     if Input.trigger?(Input::A)
  1475.       Sound.play_decision
  1476.       # 選択しているスキルを外す
  1477.       @actor.remove_battle_skill(@slot_window.index)
  1478.       refresh_window
  1479.     elsif Input.trigger?(Input::B)
  1480.       Sound.play_cancel
  1481.       return_scene
  1482.     elsif Input.trigger?(Input::C)
  1483.       Sound.play_decision
  1484.       # リストウィンドウに切り替え
  1485.       @slot_window.active = false
  1486.       @list_window.active = true
  1487.     elsif Input.trigger?(Input::R)
  1488.       Sound.play_cursor
  1489.       next_actor
  1490.     elsif Input.trigger?(Input::L)
  1491.       Sound.play_cursor
  1492.       prev_actor
  1493.     end
  1494.   end
  1495.   #--------------------------------------------------------------------------
  1496.   # ○ フレーム更新 (リストウィンドウがアクティブの場合)
  1497.   #--------------------------------------------------------------------------
  1498.   def update_list
  1499.     if Input.trigger?(Input::B)
  1500.       Sound.play_cancel
  1501.       # スロットウィンドウに切り替え
  1502.       @slot_window.active = true
  1503.       @list_window.active = false
  1504.     elsif Input.trigger?(Input::C)
  1505.       skill = @list_window.skill
  1506.       # セットできない場合
  1507.       unless @actor.battle_skill_settable?(@slot_window.index, skill)
  1508.         Sound.play_buzzer
  1509.         return
  1510.       end
  1511.       Sound.play_decision
  1512.       set_skill(@slot_window.index, skill)
  1513.       # スロットウィンドウに切り替え
  1514.       @slot_window.active = true
  1515.       @list_window.active = false
  1516.     end
  1517.   end
  1518.   #--------------------------------------------------------------------------
  1519.   # ○ スキル設定
  1520.   #     index : 設定する場所
  1521.   #     skill : 設定するスキル
  1522.   #--------------------------------------------------------------------------
  1523.   def set_skill(index, skill)
  1524.     @actor.remove_battle_skill(index)
  1525.     if skill != nil
  1526.       @actor.set_battle_skill(index, skill)
  1527.     end
  1528.     refresh_window
  1529.   end
  1530. end
Add Comment
Please, Sign In to add comment