CyberForte

DoW EquipLearn

Oct 10th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 42.55 KB | None | 0 0
  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
  2. #_/   ◆           Equipment Skills System - KGC_EquipLearnSkill          ◆ VX ◆
  3. #_/   ◇                     Last Update: 2008/02/10                           ◇
  4. #_/   ◆                  Translation by Mr. Anonymous                         ◆
  5. #_/   ◆ KGC Site:                                                             ◆
  6. #_/   ◆ http://ytomy.sakura.ne.jp/                                            ◆
  7. #_/   ◆ Translator's Blog:                                                    ◆
  8. #_/   ◆ http://mraprojects.wordpress.com                                      ◆
  9. #_/-----------------------------------------------------------------------------
  10. #_/  This script allows you to assign skills that can be "learned" by equipping
  11. #_/  designated equipment. Everytime the party defeats an enemy, they recieve
  12. #_/  TP (Training Points) that go toward mastering a skill. Once a skill is
  13. #_/  mastered (with the default setting of NEED_FULL_AP = true), that skill is
  14. #_/  learned. This system is much like the one in Final Fantasy Tactics Advance.
  15. #_/=============================================================================
  16. #_/                       ◆ Instructions For Usage ◆
  17. #_/  To make use of these functions, you must insert the desired tag into the
  18. #_/   "Notes" box located in the specified section of the database.
  19. #_/ <learnskill> is for equipment, <needTP> is for Skills, and <TP> for enemies.
  20. #_/  For example, you want the Club to supply the Dual Attack skill and be
  21. #_/   mastered at 20 TP. You would locate the Club in the weapons tab of the
  22. #_/   database and insert <learnskill 1>. Then, you'd locate Dual Attack in  
  23. #_/   the Skills tab of the database and insert <needTP 20>. Simple, effective.
  24. #_/
  25. #_/  Key: n = Number
  26. #_/       SkillID = The ID number of the desired skill in the skills database
  27. #_/       Amount = The desired amount of TP.
  28. #_/
  29. #_/                        <learnskill SkillID>
  30. #_/  Assigns the given skill to the designated equipment for the actor to use.
  31. #_/
  32. #_/                           <needTP Amount>
  33. #_/  Assigns a specified amount of TP the actor must aquire in order to master
  34. #_/   the skill.
  35. #_/                             <TP Amount>
  36. #_/  Assigns a specified amount of TP earned from defeating the enemy.
  37. #_/
  38. #_/
  39. #_/                          ◆ Script Commands ◆
  40. #_/  These commands are used in "Script" function in the third page of event
  41. #_/   commands under "Advanced".
  42. #_/
  43. #_/  * gain_actor_ap(ActorID, AP Amount, show)
  44. #_/     Allows you to give an actor a specified amount of AP.
  45. #_/     "Show" is a toggle. If set to true, if the skill is mastered, it will
  46. #_/     display the "Skill Mastered" screen. (Ex. gain_actor_ap (1, 50, true))
  47. #_/
  48. #_/  * change_actor_ap(ActorID, SkillID, AP Amount)
  49. #_/     Allows you to modify the amount of AP a specified skill has.
  50. #_/      (Ex. change_actor_ap (1, 3, 100)
  51. #_/  
  52. #_/  * call_ap_viewer(index: ActorID)
  53. #_/     This calls the AP Viewer screen. If you exclude (index:), the first
  54. #_/      actor in the index is automatically called.
  55. #_/     Note: To use this properly, Ex. call_ap_viewer(index: 2) would pull up  
  56. #_/      the AP Viewer screen for the second actor.
  57. #_/
  58. #_/  [Further, please see "Equipment Exclusion" and "Skills Exclusion" located]
  59. #_/  [near the bottom of the Customize block for more control.                ]
  60. #_/
  61. #_/=============================================================================
  62. #_/ Installation: Install above KCG_SkillCPSystem, if you use that script.
  63. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
  64.  
  65. $data_system = load_data("Data/System.rvdata") if $data_system == nil
  66.  
  67. #==============================================================================#
  68. #                           ★ Customization ★                                  #
  69. #==============================================================================#
  70.  
  71. module KGC
  72.  module EquipLearnSkill
  73.   # Note: To avoid confusion with the KCG_DistributeParameter script, I use TP
  74.   #       (Training Point) as the default abbreviation. KGC uses AP.
  75.   #                           ◆ AP Name ◆
  76.   #  This allows you to change the abbreviation of AP.
  77.   VOCAB_AP     = "TP"
  78.   #                      ◆ AP Default Value ◆
  79.   #  This allows you to change the default value of AP gained by an enemy when
  80.   #   not manually specified using the <TP n> tag.
  81.   DEFAULT_AP   = 1
  82.   #                      ◆ Skill Use Mastery ◆
  83.   #  This toggle allows you to change whether a skill is usable when AP hasn't
  84.   #   been maxed out.
  85.   #  true = Skill cannot be used until the skill has been mastered.
  86.   #  false = Skills are usable regardless of AP amount, however, when the item
  87.   #          that provides that skill is unequipped, the skill is removed.
  88.   NEED_FULL_AP = true
  89.  
  90.   #             ◆ AP Result Screen Aquisition Display ◆
  91.   #  The allows you to change the AP aquired message for battle results.
  92.   #  %s : aquired AP amount
  93.   VOCAB_RESULT_OBTAIN_AP         = "Acquired %s #{VOCAB_AP}!"
  94.   # ◆ Display message when skill is mastered on results screen
  95.   #   (beginning of message).
  96.   #  %s : Actor Name
  97.   VOCAB_RESULT_MASTER_SKILL      = "%s's"
  98.   # ◆ Display message when skill mastered on results screen.
  99.   #    (ending of message)
  100.   #  %s : Name of mastered skill
  101.   VOCAB_RESULT_MASTER_SKILL_NAME = "%s was mastered!"
  102.  
  103.   #                         ◆ Command Menu ◆
  104.   # This toggle adds the "AP Viewer" (Training Skills) selection to the main
  105.   #  command menu.
  106.   USE_MENU_AP_VIEWER_COMMAND = true
  107.   # ◆ Text of the Equip Skills selection on the main command window.
  108.   # Could also be written: VOCAB_MENU_AP_VIEWER       = "#{VOCAB_AP} Skills"
  109.   VOCAB_MENU_AP_VIEWER       = "Training"
  110.  
  111.   #                       ◆ AP Viewer Screen ◆
  112.   #  Mastered AP skills column display.
  113.   VOCAB_MASTER_SKILL      = " - LEARNED - "
  114.   #  This toggle shows/hides skills that have 0 AP.
  115.   #   This also evidently affects the skill's usability, though untested.
  116.   #  true = show
  117.   #  false = Hide
  118.   SHOW_ZERO_AP_SKILL      = false
  119.   #  This toggle allows you to hide the name of a skill if the skill has 0 AP.
  120.   #   true = mask the skill name
  121.   #   false = unmask the skill name
  122.   MASK_ZERO_AP_SKILL_NAME = false
  123.   #  This allows you to change the text of a 0 AP masked skill.
  124.   #  (When MASK_ZERO_AP_SKILL_NAME = true)
  125.   ZERO_AP_NAME_MASK       = "Unavailable"
  126.   #  This toggle allows you to mask the text displayed in the "Help" (topmost)
  127.   #   window of a skill that has 0 AP.
  128.   #   true = mask the skill's help text
  129.   #   false = display the text normally
  130.   HIDE_ZERO_AP_SKILL_HELP = true
  131.   #  This allows you to change the text displayed in the "Help" (topmost) window
  132.   #   of a skill that has 0 AP. (When HIDE_ZERO_AP_SKILL_HELP = true)
  133.   ZERO_AP_SKILL_HELP      = "This skill is unavailable."
  134.  
  135.   #                     ◆ Equipment Exclusion ◆
  136.   #  The following lines make it possible for a specified actor to not gain
  137.   #   skills granted by certain Weapons and Armors.
  138.   #  The subscript of the array (The [] brackets) cooresponds to the Actor ID.
  139.   EXCLUDE_WEAPONS = []  # Weapons
  140.   EXCLUDE_ARMORS  = []  # Armor
  141.   #  Example:
  142.   #   ActorID:1 WeaponID:50 and 70
  143.   #   EXCLUDE_WEAPONS[1] = [50, 70]
  144.   #  Ralph cannot aquire the skills given by the weapon of WeaponID 50 and 70.
  145.  
  146.   #                       ◆ Skills Exclusion ◆
  147.   #  The following line makes it possible for a specified actor to not gain
  148.   #   certain skills provided by any equipment that may normally grant them.
  149.   #  The subscript of the array (The [] brackets) cooresponds to the Actor ID.
  150.   EXCLUDE_SKILLS = []
  151.   #  Example:
  152.   #   ActorID:1 SkillID:30
  153.   #   EXCLUDE_SKILLS[1] = [30]
  154.   #  Ralph cannot aquire the skill in SkillID 30 granted by any equipped goods.
  155.  
  156.   #               ◆ Call AP Viewer from the Skills Window ◆
  157.   #  This allows you to change what key/button is pressed on the skills window
  158.   #   to shift to the AP Viewer window.
  159.   #  When set to nil, this is disabled. ( CALL_EQUIPSKILLKEY = Input::nil )
  160.   #  Note: Currently this only works with KGC_CategorizeSkill
  161.   #  I'll revise this later so you may do so without that script.
  162.   #  I also need to add a couple more methods to this anyhow.
  163.    CALL_APVIEWERKEY = Input::Z
  164.   #               ◆ Call Skills Window from the AP Viewer ◆
  165.   #  This allows you to change what key/button is pressed on the AP Viewer
  166.   #   to shift to the skills window.
  167.   #  When set to nil, this is disabled. ( CALL_SKILLSKEY = Input::nil )
  168.    CALL_SKILLSKEY = Input::Y
  169.  end
  170. end
  171.  
  172. # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
  173. #  Unless you know what you're doing, it's best not to alter anything beyond  #
  174. #  this point, as this only affects the tags used for "Notes" in database.    #
  175. # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
  176. #  Whatever word(s) are after the separator ( | ) in the following lines are
  177. #   what are used to determine what is searched for in the "Notes" section.
  178.  
  179. $imported = {} if $imported == nil
  180. $imported["EquipLearnSkill"] = true
  181.  
  182. module KGC::EquipLearnSkill
  183.   # Regular Expressions Defined
  184.   module Regexp
  185.     # Base Item Module
  186.     module BaseItem
  187.       # Learn Skill tag string
  188.       LEARN_SKILL = /<(?:LEARN_SKILL|learnskill)[ ]*(\d+(?:[ ]*,[ ]*\d+)*)>/i
  189.     end
  190.  
  191.     # Base Skill Module
  192.     module Skill
  193.       # Need AP tag string
  194.       NEED_AP = /<(?:NEED_AP|needTP)[ ]*(\d+)>/i
  195.     end
  196.  
  197.     # Base Enemy Module
  198.     module Enemy
  199.       # AP given tag string
  200.       AP = /<TP[ ]*(\d+)>/i
  201.     end
  202.   end
  203. end
  204.  
  205. #==============================================================================
  206. # □ KGC::Commands
  207. #==============================================================================
  208.  
  209. module KGC::Commands
  210.   module_function
  211.   #--------------------------------------------------------------------------
  212.   # ○ AP の獲得
  213.   #     actor_id : アクター ID
  214.   #     ap       : 獲得 AP
  215.   #     show     : マスター表示フラグ
  216.   #--------------------------------------------------------------------------
  217.   def gain_actor_ap(actor_id, ap, show = false)
  218.     $game_actors[actor_id].gain_ap(ap, show)
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ○ AP の変更
  222.   #     actor_id : アクター ID
  223.   #     skill_id : スキル ID
  224.   #     ap       : AP
  225.   #--------------------------------------------------------------------------
  226.   def change_actor_ap(actor_id, skill_id, ap)
  227.     skill = $data_skills[skill_id]
  228.     return if skill == nil
  229.     $game_actors[actor_id].change_ap(skill, ap)
  230.   end
  231.   #--------------------------------------------------------------------------
  232.   # ○ AP ビューアの呼び出し
  233.   #     actor_index : アクターインデックス
  234.   #--------------------------------------------------------------------------
  235.   def call_ap_viewer(actor_index = 0)
  236.     return if $game_temp.in_battle
  237.     $game_temp.next_scene = :ap_viewer
  238.     $game_temp.next_scene_actor_index = actor_index
  239.   end
  240. end
  241.  
  242. class Game_Interpreter
  243.   include KGC::Commands
  244. end
  245.  
  246. #==============================================================================
  247. # ■ Vocab
  248. #==============================================================================
  249.  
  250. module Vocab
  251.   # 戦闘終了メッセージ
  252.   ObtainAP              = KGC::EquipLearnSkill::VOCAB_RESULT_OBTAIN_AP
  253.   ResultFullAPSkill     = KGC::EquipLearnSkill::VOCAB_RESULT_MASTER_SKILL
  254.   ResultFullAPSkillName = KGC::EquipLearnSkill::VOCAB_RESULT_MASTER_SKILL_NAME
  255.  
  256.   # AP
  257.   def self.ap
  258.     return KGC::EquipLearnSkill::VOCAB_AP
  259.   end
  260.  
  261.   # マスターしたスキル
  262.   def self.full_ap_skill
  263.     return KGC::EquipLearnSkill::VOCAB_MASTER_SKILL
  264.   end
  265.  
  266.   # AP ビューア
  267.   def self.ap_viewer
  268.     return KGC::EquipLearnSkill::VOCAB_MENU_AP_VIEWER
  269.   end
  270. end
  271.  
  272. #==============================================================================
  273. # ■ RPG::BaseItem
  274. #==============================================================================
  275.  
  276. class RPG::BaseItem
  277.   #--------------------------------------------------------------------------
  278.   # ○ スキル習得装備のキャッシュ生成
  279.   #--------------------------------------------------------------------------
  280.   def create_equip_learn_skill_cache
  281.     @__learn_skills = []
  282.  
  283.     self.note.split(/[\r\n]+/).each { |line|
  284.       case line
  285.       when KGC::EquipLearnSkill::Regexp::BaseItem::LEARN_SKILL  # スキル習得
  286.         $1.scan(/\d+/).each { |num|
  287.           skill_id = num.to_i
  288.           # 存在するスキルならリストに加える
  289.           @__learn_skills << skill_id if $data_skills[skill_id] != nil
  290.         }
  291.       end
  292.     }
  293.   end
  294.   #--------------------------------------------------------------------------
  295.   # ○ 習得するスキル ID の配列
  296.   #--------------------------------------------------------------------------
  297.   def learn_skills
  298.     create_equip_learn_skill_cache if @__learn_skills == nil
  299.     return @__learn_skills
  300.   end
  301. end
  302.  
  303. #==============================================================================
  304. # ■ RPG::Skill
  305. #==============================================================================
  306.  
  307. class RPG::Skill < RPG::UsableItem
  308.   #--------------------------------------------------------------------------
  309.   # ○ クラス変数
  310.   #--------------------------------------------------------------------------
  311.   @@__masked_name =
  312.     KGC::EquipLearnSkill::ZERO_AP_NAME_MASK  # マスク名
  313.   @@__expand_masked_name = false             # マスク名拡張表示フラグ
  314.  
  315.   if @@__expand_masked_name != nil
  316.     @@__expand_masked_name = (@@__masked_name.scan(/./).size == 1)
  317.   end
  318.   #--------------------------------------------------------------------------
  319.   # ○ スキル習得装備のキャッシュ生成
  320.   #--------------------------------------------------------------------------
  321.   def create_equip_learn_skill_cache
  322.     @__need_ap = 0
  323.  
  324.     self.note.split(/[\r\n]+/).each { |line|
  325.       case line
  326.       when KGC::EquipLearnSkill::Regexp::Skill::NEED_AP  # 必要 AP
  327.         @__need_ap = $1.to_i
  328.       end
  329.     }
  330.   end
  331.   #--------------------------------------------------------------------------
  332.   # ○ マスク名
  333.   #--------------------------------------------------------------------------
  334.   def masked_name
  335.     if KGC::EquipLearnSkill::MASK_ZERO_AP_SKILL_NAME
  336.       if @@__expand_masked_name
  337.         # マスク名を拡張して表示
  338.         return @@__masked_name * self.name.scan(/./).size
  339.       else
  340.         return @@__masked_name
  341.       end
  342.     else
  343.       return self.name
  344.     end
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ○ 習得に必要な AP
  348.   #--------------------------------------------------------------------------
  349.   def need_ap
  350.     create_equip_learn_skill_cache if @__need_ap == nil
  351.     return @__need_ap
  352.   end
  353. end
  354.  
  355. #==============================================================================
  356. # ■ RPG::Enemy
  357. #==============================================================================
  358.  
  359. class RPG::Enemy
  360.   #--------------------------------------------------------------------------
  361.   # ○ スキル習得装備のキャッシュ生成
  362.   #--------------------------------------------------------------------------
  363.   def create_equip_learn_skill_cache
  364.     @__ap = KGC::EquipLearnSkill::DEFAULT_AP
  365.  
  366.     self.note.split(/[\r\n]+/).each { |line|
  367.       case line
  368.       when KGC::EquipLearnSkill::Regexp::Enemy::AP  # 所持 AP
  369.         @__ap = $1.to_i
  370.       end
  371.     }
  372.   end
  373.   #--------------------------------------------------------------------------
  374.   # ○ 所持 AP
  375.   #--------------------------------------------------------------------------
  376.   def ap
  377.     create_equip_learn_skill_cache if @__ap == nil
  378.     return @__ap
  379.   end
  380. end
  381.  
  382. #==============================================================================
  383. # ■ Game_Temp
  384. #==============================================================================
  385.  
  386. unless $imported["CustomMenuCommand"]
  387. class Game_Temp
  388.   #--------------------------------------------------------------------------
  389.   # ● 公開インスタンス変数
  390.   #--------------------------------------------------------------------------
  391.   attr_accessor :next_scene_actor_index   # 次のシーンのアクターインデックス
  392.   #--------------------------------------------------------------------------
  393.   # ● オブジェクト初期化
  394.   #--------------------------------------------------------------------------
  395.   alias initialize_KGC_EquipLearnSkill initialize unless $@
  396.   def initialize
  397.     initialize_KGC_EquipLearnSkill
  398.  
  399.     @next_scene_actor_index = 0
  400.   end
  401. end
  402. end
  403.  
  404. #==============================================================================
  405. # ■ Game_Actor
  406. #==============================================================================
  407.  
  408. class Game_Actor < Game_Battler
  409.   #--------------------------------------------------------------------------
  410.   # ● セットアップ
  411.   #     actor_id : アクター ID
  412.   #--------------------------------------------------------------------------
  413.   alias setup_KGC_EquipLearnSkill setup unless $@
  414.   def setup(actor_id)
  415.     setup_KGC_EquipLearnSkill(actor_id)
  416.  
  417.     @skill_ap = []
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # ○ 指定スキルの AP 取得
  421.   #     skill_id : スキル ID
  422.   #--------------------------------------------------------------------------
  423.   def skill_ap(skill_id)
  424.     @skill_ap = [] if @skill_ap == nil
  425.     return (@skill_ap[skill_id] != nil ? @skill_ap[skill_id] : 0)
  426.   end
  427.   #--------------------------------------------------------------------------
  428.   # ○ AP 変更
  429.   #     skill : スキル
  430.   #     ap    : 新しい AP
  431.   #--------------------------------------------------------------------------
  432.   def change_ap(skill, ap)
  433.     @skill_ap = [] if @skill_ap == nil
  434.     @skill_ap[skill.id] = [[ap, skill.need_ap].min, 0].max
  435.   end
  436.   #--------------------------------------------------------------------------
  437.   # ○ マスターしたスキルの表示
  438.   #     new_skills : 新しくマスターしたスキルの配列
  439.   #--------------------------------------------------------------------------
  440.   def display_full_ap_skills(new_skills)
  441.     $game_message.new_page
  442.     text = sprintf(Vocab::ResultFullAPSkill, name)
  443.     $game_message.texts.push(text)
  444.     new_skills.each { |skill|
  445.       text = sprintf(Vocab::ResultFullAPSkillName, skill.name)
  446.       $game_message.texts.push(text)
  447.     }
  448.   end
  449.   #--------------------------------------------------------------------------
  450.   # ○ AP 獲得
  451.   #     ap   : AP の増加量
  452.   #     show : マスタースキル表示フラグ
  453.   #--------------------------------------------------------------------------
  454.   def gain_ap(ap, show)
  455.     last_full_ap_skills = full_ap_skills
  456.  
  457.     # 装備品により習得しているスキルに AP を加算
  458.     equipment_skills(true).each { |skill|
  459.       change_ap(skill, skill_ap(skill.id) + ap)
  460.     }
  461.  
  462.     # マスターしたスキルを表示
  463.     if show && last_full_ap_skills != full_ap_skills
  464.       display_full_ap_skills(full_ap_skills - last_full_ap_skills)
  465.     end
  466.   end
  467.   #--------------------------------------------------------------------------
  468.   # ● スキルオブジェクトの配列取得
  469.   #--------------------------------------------------------------------------
  470.   alias skills_KGC_EquipLearnSkill skills unless $@
  471.   def skills
  472.     result = skills_KGC_EquipLearnSkill
  473.  
  474.     # 装備品と AP 蓄積済みのスキルを追加
  475.     additional_skills = equipment_skills | full_ap_skills
  476.     return (result | additional_skills).sort! { |a, b| a.id <=> b.id }
  477.   end
  478.   #--------------------------------------------------------------------------
  479.   # ○ 装備品の習得スキル取得
  480.   #     all : 使用不可能なスキルも含める
  481.   #--------------------------------------------------------------------------
  482.   def equipment_skills(all = false)
  483.     result = []
  484.     equips.compact.each { |item|
  485.       next if exclude_learnable_equipment?(item)       # 除外装備なら無視
  486.  
  487.       item.learn_skills.each { |i|
  488.         skill = $data_skills[i]
  489.         next if exclude_equipment_skill?(skill)        # 除外スキルなら無視
  490.         if !all && KGC::EquipLearnSkill::NEED_FULL_AP  # 要蓄積の場合
  491.           next unless ap_full?(skill)                   # 未達成なら無視
  492.         end
  493.         result << skill
  494.       }
  495.     }
  496.     return result
  497.   end
  498.   #--------------------------------------------------------------------------
  499.   # ○ スキル習得装備除外判定
  500.   #     item : 判定装備
  501.   #--------------------------------------------------------------------------
  502.   def exclude_learnable_equipment?(item)
  503.     case item
  504.     when RPG::Weapon  # 武器
  505.       # 除外武器に含まれている場合
  506.       if KGC::EquipLearnSkill::EXCLUDE_WEAPONS[id] != nil &&
  507.           KGC::EquipLearnSkill::EXCLUDE_WEAPONS[id].include?(item.id)
  508.         return true
  509.       end
  510.     when RPG::Armor   # 防具
  511.       # 除外防具に含まれている場合
  512.       if KGC::EquipLearnSkill::EXCLUDE_ARMORS[id] != nil &&
  513.           KGC::EquipLearnSkill::EXCLUDE_ARMORS[id].include?(item.id)
  514.         return true
  515.       end
  516.     else              # 装備品以外
  517.       return true
  518.     end
  519.  
  520.     return false
  521.   end
  522.   #--------------------------------------------------------------------------
  523.   # ○ 装備品による習得スキル除外判定
  524.   #     skill : スキル
  525.   #--------------------------------------------------------------------------
  526.   def exclude_equipment_skill?(skill)
  527.     # 自身が除外されている場合
  528.     if KGC::EquipLearnSkill::EXCLUDE_SKILLS[id] != nil &&
  529.         KGC::EquipLearnSkill::EXCLUDE_SKILLS[id].include?(skill.id)
  530.       return true
  531.     end
  532.  
  533.     return false
  534.   end
  535.   #--------------------------------------------------------------------------
  536.   # ○ AP 蓄積済みのスキルを取得
  537.   #--------------------------------------------------------------------------
  538.   def full_ap_skills
  539.     result = []
  540.     (1...$data_skills.size).each { |i|
  541.       skill = $data_skills[i]
  542.       result << skill if ap_full?(skill) && !exclude_equipment_skill?(skill)
  543.     }
  544.     return result
  545.   end
  546.   #--------------------------------------------------------------------------
  547.   # ○ AP 蓄積可能なスキルを取得
  548.   #--------------------------------------------------------------------------
  549.   def can_gain_ap_skills
  550.     result = []
  551.     equips.compact.each { |item|
  552.       next if exclude_learnable_equipment?(item)  # 除外装備なら無視
  553.  
  554.       item.learn_skills.each { |i|
  555.         skill = $data_skills[i]
  556.         next if exclude_equipment_skill?(skill)   # 除外スキルなら無視
  557.         result << skill
  558.       }
  559.     }
  560.     return (result - full_ap_skills)              # マスターしたものを除く
  561.   end
  562.   #--------------------------------------------------------------------------
  563.   # ○ AP 蓄積済み判定
  564.   #     skill : スキル
  565.   #--------------------------------------------------------------------------
  566.   def ap_full?(skill)
  567.     return false if skill == nil                  # スキルが存在しない
  568.     return false if skill.need_ap == 0            # 必要 AP が 0
  569.     return false if @skills.include?(skill.id)    # 習得済み
  570.  
  571.     return (skill_ap(skill.id) >= skill.need_ap)
  572.   end
  573.   #--------------------------------------------------------------------------
  574.   # ● スキルの使用可能判定
  575.   #     skill : スキル
  576.   #--------------------------------------------------------------------------
  577.   def skill_can_use?(skill)
  578.     return super
  579.   end
  580. end
  581.  
  582. #==============================================================================
  583. # ■ Game_Enemy
  584. #==============================================================================
  585.  
  586. class Game_Enemy < Game_Battler
  587.   #--------------------------------------------------------------------------
  588.   # ○ AP の取得
  589.   #--------------------------------------------------------------------------
  590.   def ap
  591.     return enemy.ap
  592.   end
  593. end
  594.  
  595. #==============================================================================
  596. # ■ Game_Troop
  597. #==============================================================================
  598.  
  599. class Game_Troop < Game_Unit
  600.   #--------------------------------------------------------------------------
  601.   # ○ AP の合計計算
  602.   #--------------------------------------------------------------------------
  603.   def ap_total
  604.     ap = 0
  605.     for enemy in dead_members
  606.       ap += enemy.ap unless enemy.hidden
  607.     end
  608.     return ap
  609.   end
  610. end
  611.  
  612. #==============================================================================
  613. # ■ Window_Command
  614. #==============================================================================
  615.  
  616. class Window_Command < Window_Selectable
  617.   unless method_defined?(:add_command)
  618.   #--------------------------------------------------------------------------
  619.   # ○ コマンドを追加
  620.   #    追加した位置を返す
  621.   #--------------------------------------------------------------------------
  622.   def add_command(command)
  623.     @commands << command
  624.     @item_max = @commands.size
  625.     item_index = @item_max - 1
  626.     refresh_command
  627.     draw_item(item_index)
  628.     return item_index
  629.   end
  630.   #--------------------------------------------------------------------------
  631.   # ○ コマンドをリフレッシュ
  632.   #--------------------------------------------------------------------------
  633.   def refresh_command
  634.     buf = self.contents.clone
  635.     self.height = [self.height, row_max * WLH + 32].max
  636.     create_contents
  637.     self.contents.blt(0, 0, buf, buf.rect)
  638.     buf.dispose
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # ○ コマンドを挿入
  642.   #--------------------------------------------------------------------------
  643.   def insert_command(index, command)
  644.     @commands.insert(index, command)
  645.     @item_max = @commands.size
  646.     refresh_command
  647.     refresh
  648.   end
  649.   #--------------------------------------------------------------------------
  650.   # ○ コマンドを削除
  651.   #--------------------------------------------------------------------------
  652.   def remove_command(command)
  653.     @commands.delete(command)
  654.     @item_max = @commands.size
  655.     refresh
  656.   end
  657.   end
  658. end
  659.  
  660. #==============================================================================
  661. # □ Window_APViewer
  662. #------------------------------------------------------------------------------
  663. #  AP ビューアでスキルを表示するウィンドウです。
  664. #==============================================================================
  665.  
  666. class Window_APViewer < Window_Selectable
  667.   #--------------------------------------------------------------------------
  668.   # ● オブジェクト初期化
  669.   #     x      : ウィンドウの X 座標
  670.   #     y      : ウィンドウの Y 座標
  671.   #     width  : ウィンドウの幅
  672.   #     height : ウィンドウの高さ
  673.   #     actor  : アクター
  674.   #--------------------------------------------------------------------------
  675.   def initialize(x, y, width, height, actor)
  676.     super(x, y, width, height)
  677.     @actor = actor
  678.     @can_gain_ap_skills = []
  679.     self.index = 0
  680.     refresh
  681.   end
  682.   #--------------------------------------------------------------------------
  683.   # ○ スキルの取得
  684.   #--------------------------------------------------------------------------
  685.   def skill
  686.     return @data[self.index]
  687.   end
  688.   #--------------------------------------------------------------------------
  689.   # ○ リフレッシュ
  690.   #--------------------------------------------------------------------------
  691.   def refresh
  692.     @data = []
  693.     @can_gain_ap_skills = @actor.can_gain_ap_skills
  694.     equipment_skills = @actor.equipment_skills(true)
  695.  
  696.     (1...$data_skills.size).each { |i|
  697.       skill = $data_skills[i]
  698.       next if skill.need_ap == 0
  699.       unless KGC::EquipLearnSkill::SHOW_ZERO_AP_SKILL
  700.         # AP が 0 、かつ装備品で習得していないものは無視
  701.         if @actor.skill_ap(skill.id) == 0 && !equipment_skills.include?(skill)
  702.           next
  703.         end
  704.       end
  705.       @data.push(skill)
  706.     }
  707.     @item_max = @data.size
  708.     create_contents
  709.     @item_max.times { |i| draw_item(i) }
  710.   end
  711.   #--------------------------------------------------------------------------
  712.   # ○ 項目の描画
  713.   #     index : 項目番号
  714.   #--------------------------------------------------------------------------
  715.   def draw_item(index)
  716.     rect = item_rect(index)
  717.     self.contents.clear_rect(rect)
  718.     skill = @data[index]
  719.     if skill != nil
  720.       rect.width -= 4
  721.       draw_item_name(skill, rect.x, rect.y, enable?(skill))
  722.       if @actor.ap_full?(skill) || @actor.skill_learn?(skill)
  723.         # マスター
  724.         text = Vocab.full_ap_skill
  725.       else
  726.         # AP 蓄積中
  727.         text = sprintf("%s %4d/%4d",
  728.           Vocab.ap, @actor.skill_ap(skill.id), skill.need_ap)
  729.       end
  730.       # AP を描画
  731.       self.contents.font.color = normal_color
  732.       self.contents.draw_text(rect, text, 2)
  733.     end
  734.   end
  735.   #--------------------------------------------------------------------------
  736.   # ○ スキルを有効状態で表示するかどうか
  737.   #     skill : スキル
  738.   #--------------------------------------------------------------------------
  739.   def enable?(skill)
  740.     return true if @actor.skill_learn?(skill)           # 習得済み
  741.     return true if @actor.ap_full?(skill)               # マスター
  742.     return true if @can_gain_ap_skills.include?(skill)  # AP 蓄積可能
  743.  
  744.     return false
  745.   end
  746.   #--------------------------------------------------------------------------
  747.   # ○ スキルをマスクなしで表示するかどうか
  748.   #     skill : スキル
  749.   #--------------------------------------------------------------------------
  750.   def no_mask?(skill)
  751.     return true if @actor.skill_learn?(skill)           # 習得済み
  752.     return true if @actor.skill_ap(skill.id) > 0        # AP が 1 以上
  753.     return true if @can_gain_ap_skills.include?(skill)  # AP 蓄積可能
  754.  
  755.     return false
  756.   end
  757.   #--------------------------------------------------------------------------
  758.   # ● アイテム名の描画
  759.   #     item    : アイテム (スキル、武器、防具でも可)
  760.   #     x       : 描画先 X 座標
  761.   #     y       : 描画先 Y 座標
  762.   #     enabled : 有効フラグ。false のとき半透明で描画
  763.   #--------------------------------------------------------------------------
  764.   def draw_item_name(item, x, y, enabled = true)
  765.     draw_icon(item.icon_index, x, y, enabled)
  766.     self.contents.font.color = normal_color
  767.     self.contents.font.color.alpha = enabled ? 255 : 128
  768.     self.contents.draw_text(x + 24, y, 172, WLH,
  769.       no_mask?(item) ? item.name : item.masked_name)
  770.   end
  771.   #--------------------------------------------------------------------------
  772.   # ● フレーム更新
  773.   #--------------------------------------------------------------------------
  774.   def update
  775.     super
  776.     return unless self.active
  777.  
  778.     if Input.repeat?(Input::RIGHT)
  779.       cursor_pagedown
  780.     elsif Input.repeat?(Input::LEFT)
  781.       cursor_pageup
  782.     end
  783.   end
  784.   #--------------------------------------------------------------------------
  785.   # ● ヘルプテキスト更新
  786.   #--------------------------------------------------------------------------
  787.   def update_help
  788.     if KGC::EquipLearnSkill::HIDE_ZERO_AP_SKILL_HELP && !no_mask?(skill)
  789.       @help_window.set_text(KGC::EquipLearnSkill::ZERO_AP_SKILL_HELP)
  790.     else
  791.       @help_window.set_text(skill == nil ? "" : skill.description)
  792.     end
  793.   end
  794. end
  795.  
  796. #==============================================================================
  797. # ■ Scene_Map
  798. #==============================================================================
  799.  
  800. class Scene_Map < Scene_Base
  801.   #--------------------------------------------------------------------------
  802.   # ● 画面切り替えの実行
  803.   #--------------------------------------------------------------------------
  804.   alias update_scene_change_KGC_EquipLearnSkill update_scene_change unless $@
  805.   def update_scene_change
  806.     return if $game_player.moving?    # プレイヤーの移動中?
  807.  
  808.     if $game_temp.next_scene == :ap_viewer
  809.       call_ap_viewer
  810.       return
  811.     end
  812.  
  813.     update_scene_change_KGC_EquipLearnSkill
  814.   end
  815.   #--------------------------------------------------------------------------
  816.   # ○ AP ビューアへの切り替え
  817.   #--------------------------------------------------------------------------
  818.   def call_ap_viewer
  819.     $game_temp.next_scene = nil
  820.     $scene = Scene_APViewer.new($game_temp.next_scene_actor_index,
  821.       0, Scene_APViewer::HOST_MAP)
  822.   end
  823. end
  824.  
  825. #==============================================================================
  826. # ■ Scene_Menu
  827. #==============================================================================
  828.  
  829. class Scene_Menu < Scene_Base
  830.   if KGC::EquipLearnSkill::USE_MENU_AP_VIEWER_COMMAND
  831.   #--------------------------------------------------------------------------
  832.   # ● コマンドウィンドウの作成
  833.   #--------------------------------------------------------------------------
  834.   alias create_command_window_KGC_EquipLearnSkill create_command_window unless $@
  835.   def create_command_window
  836.     create_command_window_KGC_EquipLearnSkill
  837.  
  838.     return if $imported["CustomMenuCommand"]
  839.  
  840.     @__command_ap_viewer_index = @command_window.add_command(Vocab.ap_viewer)
  841.     if @command_window.oy > 0
  842.       @command_window.oy -= Window_Base::WLH
  843.     end
  844.     @command_window.index = @menu_index
  845.   end
  846.   end
  847.   #--------------------------------------------------------------------------
  848.   # ● コマンド選択の更新
  849.   #--------------------------------------------------------------------------
  850.   alias update_command_selection_KGC_EquipLearnSkill update_command_selection unless $@
  851.   def update_command_selection
  852.     call_ap_viewer_flag = false
  853.     if Input.trigger?(Input::C)
  854.       case @command_window.index
  855.       when @__command_ap_viewer_index  # AP ビューア
  856.         call_ap_viewer_flag = true
  857.       end
  858.     end
  859.  
  860.     # AP ビューアに移行
  861.     if call_ap_viewer_flag
  862.       if $game_party.members.size == 0
  863.         Sound.play_buzzer
  864.         return
  865.       end
  866.       Sound.play_decision
  867.       start_actor_selection
  868.       return
  869.     end
  870.  
  871.     update_command_selection_KGC_EquipLearnSkill
  872.   end
  873.   #--------------------------------------------------------------------------
  874.   # ● アクター選択の更新
  875.   #--------------------------------------------------------------------------
  876.   alias update_actor_selection_KGC_EquipLearnSkill update_actor_selection unless $@
  877.   def update_actor_selection
  878.     if Input.trigger?(Input::C)
  879.       $game_party.last_actor_index = @status_window.index
  880.       Sound.play_decision
  881.       case @command_window.index
  882.       when @__command_ap_viewer_index  # AP ビューア
  883.         $scene = Scene_APViewer.new(@status_window.index,
  884.           @__command_ap_viewer_index, Scene_APViewer::HOST_MENU)
  885.         return
  886.       end
  887.     end
  888.  
  889.     update_actor_selection_KGC_EquipLearnSkill
  890.   end
  891. end
  892.  
  893. #==============================================================================
  894. # □ Scene_APViewer
  895. #------------------------------------------------------------------------------
  896. #   AP ビューアの処理を行うクラスです。
  897. #==============================================================================
  898.  
  899. class Scene_APViewer < Scene_Base
  900.   HOST_MENU   = 0
  901.   HOST_MAP    = 1
  902.   #--------------------------------------------------------------------------
  903.   # ● オブジェクト初期化
  904.   #     actor_index : アクターインデックス
  905.   #     menu_index  : コマンドのカーソル初期位置
  906.   #     host_scene  : 呼び出し元 (0..メニュー  1..マップ)
  907.   #--------------------------------------------------------------------------
  908.   def initialize(actor_index = 0, menu_index = 0, host_scene = HOST_MENU)
  909.     @actor_index = actor_index
  910.     @menu_index = menu_index
  911.     @host_scene = host_scene
  912.   end
  913.   #--------------------------------------------------------------------------
  914.   # ● 開始処理
  915.   #--------------------------------------------------------------------------
  916.   def start
  917.     super
  918.     create_menu_background
  919.     @actor = $game_party.members[@actor_index]
  920.     @help_window = Window_Help.new
  921.     if $imported["HelpExtension"]
  922.       @help_window.row_max = KGC::HelpExtension::ROW_MAX
  923.     end
  924.     @status_window = Window_SkillStatus.new(0, @help_window.height, @actor)
  925.     dy = @help_window.height + @status_window.height
  926.     @skill_window = Window_APViewer.new(0, dy,
  927.       Graphics.width, Graphics.height - dy, @actor)
  928.     @skill_window.help_window = @help_window
  929.   end
  930.   #--------------------------------------------------------------------------
  931.   # ● 終了処理
  932.   #--------------------------------------------------------------------------
  933.   def terminate
  934.     super
  935.     dispose_menu_background
  936.     @help_window.dispose
  937.     @status_window.dispose
  938.     @skill_window.dispose
  939.   end
  940.   #--------------------------------------------------------------------------
  941.   # ○ 元の画面へ戻る
  942.   #--------------------------------------------------------------------------
  943.   def return_scene
  944.     case @host_scene
  945.     when HOST_MENU
  946.       $scene = Scene_Menu.new(@menu_index)
  947.     when HOST_MAP
  948.       $scene = Scene_Map.new
  949.     end
  950.   end
  951.   #--------------------------------------------------------------------------
  952.   # ○ 次のアクターの画面に切り替え
  953.   #--------------------------------------------------------------------------
  954.   def next_actor
  955.     @actor_index += 1
  956.     @actor_index %= $game_party.members.size
  957.     $scene = Scene_APViewer.new(@actor_index, @menu_index, @host_scene)
  958.   end
  959.   #--------------------------------------------------------------------------
  960.   # ○ 前のアクターの画面に切り替え
  961.   #--------------------------------------------------------------------------
  962.   def prev_actor
  963.     @actor_index += $game_party.members.size - 1
  964.     @actor_index %= $game_party.members.size
  965.     $scene = Scene_APViewer.new(@actor_index, @menu_index, @host_scene)
  966.   end
  967.   #--------------------------------------------------------------------------
  968.   # ● フレーム更新
  969.   #--------------------------------------------------------------------------
  970.   def update
  971.     super
  972.     update_menu_background
  973.     @help_window.update
  974.     @skill_window.update
  975.     @status_window.update
  976.     if @skill_window.active
  977.       update_skill_selection
  978.     end
  979.   end
  980.   #--------------------------------------------------------------------------
  981.   # ○ スキル選択の更新
  982.   #--------------------------------------------------------------------------
  983.   def update_skill_selection
  984.     if Input.trigger?(Input::B)
  985.       Sound.play_cancel
  986.       return_scene
  987.     elsif Input.trigger?(Input::R)
  988.       Sound.play_cursor
  989.       next_actor
  990.     elsif Input.trigger?(Input::L)
  991.       Sound.play_cursor
  992.       prev_actor
  993.     elsif KGC::EquipLearnSkill::CALL_SKILLSKEY != nil &&
  994.       Input.trigger?(KGC::EquipLearnSkill::CALL_SKILLSKEY)
  995.       Sound.play_decision
  996.       $scene = Scene_Skill.new(@actor_index)
  997.     end
  998.   end
  999. end
  1000.  
  1001. #==============================================================================
  1002. # ■ Scene_Battle
  1003. #==============================================================================
  1004.  
  1005. class Scene_Battle < Scene_Base
  1006.   #--------------------------------------------------------------------------
  1007.   # ● メッセージ表示が終わるまでウェイト
  1008.   #--------------------------------------------------------------------------
  1009.   alias wait_for_message_KGC_EquipLearnSkill wait_for_message unless $@
  1010.   def wait_for_message
  1011.     return if @ignore_wait_for_message  # メッセージ終了までのウェイトを無視
  1012.  
  1013.     wait_for_message_KGC_EquipLearnSkill
  1014.   end
  1015.   #--------------------------------------------------------------------------
  1016.   # ● 獲得した経験値とお金の表示
  1017.   #--------------------------------------------------------------------------
  1018.   alias display_exp_and_gold_KGC_EquipLearnSkill display_exp_and_gold unless $@
  1019.   def display_exp_and_gold
  1020.     @ignore_wait_for_message = true
  1021.  
  1022.     display_exp_and_gold_KGC_EquipLearnSkill
  1023.  
  1024.     display_ap
  1025.     @ignore_wait_for_message = false
  1026.     wait_for_message
  1027.   end
  1028.   #--------------------------------------------------------------------------
  1029.   # ● レベルアップの表示
  1030.   #--------------------------------------------------------------------------
  1031.   alias display_level_up_KGC_EquipLearnSkill display_level_up unless $@
  1032.   def display_level_up
  1033.     display_level_up_KGC_EquipLearnSkill
  1034.  
  1035.     display_master_equipment_skill
  1036.   end
  1037.   #--------------------------------------------------------------------------
  1038.   # ○ 獲得 AP の表示
  1039.   #--------------------------------------------------------------------------
  1040.   def display_ap
  1041.     ap = $game_troop.ap_total
  1042.     if ap > 0
  1043.       text = sprintf(Vocab::ObtainAP, ap)
  1044.       $game_message.texts.push('\.' + text)
  1045.     end
  1046.     wait_for_message
  1047.   end
  1048.   #--------------------------------------------------------------------------
  1049.   # ○ マスターしたスキルの表示
  1050.   #--------------------------------------------------------------------------
  1051.   def display_master_equipment_skill
  1052.     ap = $game_troop.ap_total
  1053.     $game_party.existing_members.each { |actor|
  1054.       last_skills = actor.skills
  1055.       actor.gain_ap(ap, true)
  1056.     }
  1057.     wait_for_message
  1058.   end
  1059. end
  1060.  
  1061. #==============================================================================
  1062. # ■ Scene_Skill
  1063. #==============================================================================
  1064. # Added by Mr. Anonymous
  1065. #==============================================================================
  1066. if $imported["CategorizeSkill"]
  1067.   class Scene_Skill < Scene_Base
  1068.   #--------------------------------------------------------------------------
  1069.   #  Update Actor
  1070.   #--------------------------------------------------------------------------
  1071.    alias update_category_selection_KGC_EquipLearnSkill update_category_selection unless $@
  1072.     def update_category_selection
  1073.         if KGC::EquipLearnSkill::CALL_APVIEWERKEY != nil &&
  1074.            Input.trigger?(KGC::EquipLearnSkill::CALL_APVIEWERKEY)
  1075.            Sound.play_decision
  1076.            $scene = Scene_APViewer.new(@actor_index)
  1077.          end
  1078.       update_category_selection_KGC_EquipLearnSkill
  1079.     end
  1080.   end
  1081. end
Advertisement
Add Comment
Please, Sign In to add comment