Advertisement
Guest User

YEA - Learn Skill Engine

a guest
Dec 13th, 2012
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 52.55 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Learn Skill Engine v1.00
  4. # -- Last Updated: 2012.01.08
  5. # -- Level: Normal, Hard
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-LearnSkillEngine"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.12.13 - Added a function that other scripts may use. By SoundReaper.
  17. # 2012.01.08 - Started Script and Finished.
  18. #
  19. #==============================================================================
  20. # ▼ Introduction
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # For those who want an alternative for actors to learn skills outside of
  23. # leveling, this script allows actors to learn skills through a learn skill
  24. # menu. The actor can use acquired JP, EXP, or Gold to learn skills. Skills can
  25. # also be hidden until certain requirements are met.
  26. #
  27. #==============================================================================
  28. # ▼ Instructions
  29. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. # To install this script, open up your script editor and copy/paste this script
  31. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  32. #
  33. # -----------------------------------------------------------------------------
  34. # Class Notetags - These notetags go in the class notebox in the database.
  35. # -----------------------------------------------------------------------------
  36. # <learn skills: x>
  37. # <learn skills: x, x>
  38. # Sets the class to be able to learn skills x through the Learn Skills menu.
  39. # Insert multiple of these tags to increase the number of skills learned.
  40. #
  41. # -----------------------------------------------------------------------------
  42. # Skill Notetags - These notetags go in the skill notebox in the database.
  43. # -----------------------------------------------------------------------------
  44. # <learn cost: x jp>
  45. # <learn cost: x exp>
  46. # <learn cost: x gold>
  47. # Sets the learn for cost the skill to require x amounts of JP, x amounts of
  48. # exp, or x amounts of gold. Only one type of cost can be used at a time. For
  49. # JP costs, the Yanfly Engine Ace - JP Manager script must be installed.
  50. #
  51. # <learn require level: x>
  52. # Sets the skill to require the actor's current level to be x before the skill
  53. # will show up in the skill learning window.
  54. #
  55. # <learn require skill: x>
  56. # <learn require skill: x, x>
  57. # Sets the skill to require learning skill x (through any means) before the
  58. # skill becomes visible in the skill learning window. Insert multiples of these
  59. # tags to require more skills to be learned in order for the skill to show.
  60. #
  61. # <learn require switch: x>
  62. # <learn require switch: x, x>
  63. # Sets the skill to require switch x to be ON in order for it to show in the
  64. # skill learning window. Insert multiple switches to to increase the number of
  65. # switches needed to be ON before the skill is shown.
  66. #
  67. # <learn require eval>
  68. #  string
  69. #  string
  70. # </learn require eval>
  71. # For the more advanced users, replace string with lines of code to check for
  72. # whether or not the skill will be shown in skill learning window. If multiple
  73. # lines are used, they are all considered part of the same line.
  74. #
  75. #==============================================================================
  76. # ▼ Compatibility
  77. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  78. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  79. # it will run with RPG Maker VX without adjusting.
  80. #
  81. # This script is compatible with Yanfly Engine Ace - JP Manager v1.00+. The
  82. # placement of this script relative to the JP Manager script doesn't matter.
  83. #
  84. #==============================================================================
  85.  
  86. module YEA
  87.   module LEARN_SKILL
  88.    
  89.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  90.     # - General Settings -
  91.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  92.     # Adjust the general settings here for your game. These adjust how the
  93.     # command name appears, a switch to show the Learn Command
  94.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  95.     COMMAND_NAME = "Apprentissage"    # Name used for Learn Skill command.
  96.    
  97.     # This switch will hide the "Learn" command from view if the switch is OFF.
  98.     # The "Learn" command will be shown if the switch is ON. Set this switch to
  99.     # 0 to not use this effect and to always have the Learn command be shown.
  100.     SHOW_SWITCH   = 0
  101.    
  102.     # This adjusts the order the Skill Types appear in for the command window.
  103.     # Any Skill Types unlisted will not be shown.
  104.     STYPE_ORDER = [41..999, 1..40]
  105.    
  106.     # For those who installed Yanfly Engine - Skill Restrictions, you can
  107.     # choose to display warmups or cooldowns inside of the menu here.
  108.     DRAW_WARMUP   = false        # Draw warmups for skills?
  109.     DRAW_COOLDOWN = true        # Draw cooldowns for skills?
  110.    
  111.     #-------------------------------------------------------------------------
  112.     # - Default Cost -
  113.     #-------------------------------------------------------------------------
  114.     # This sets the default costs for all skills. If the JP script isn't
  115.     # installed, the type will become :exp instead.
  116.     #
  117.     # Cost Type       Description
  118.     #  :jp            - Requires YEA - JP Manager.
  119.     #  :exp           - Makes skill cost EXP.
  120.     #  :gold          - Makes skill cost gold.
  121.     #-------------------------------------------------------------------------
  122.     DEFAULT_COST = 100          # Sets the default cost of a skill.
  123.     DEFAULT_TYPE = :jp          # Sets the default cost type.
  124.    
  125.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  126.     # - Learn Window Settings -
  127.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  128.     # These settings adjust the Learn Window's visual appearance. Adjust the
  129.     # way empty text appears, EXP cost suffixes appear, Learned text appears,
  130.     # font sizes, and cost colours here.
  131.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  132.     EMPTY_TEXT     = ""        # Text if no restricts used for the skill.
  133.     EXP_TEXT       = "XP"      # Text used for EXP costs.
  134.     LEARNED_TEXT   = "Appris"  # Text to indicate skill has been learned.
  135.     LEARNED_SIZE   = 20         # Font size used for learned skill text.
  136.     COLOUR_JP      = 24         # Text colour used for JP Cost.
  137.     COLOUR_EXP     =  5         # Text colour used for EXP Cost.
  138.     COLOUR_GOLD    = 21         # Text colour used for Gold Cost.
  139.     COST_SIZE      = 20         # Font size used for skill costs.
  140.    
  141.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  142.     # - Cost Window Settings -
  143.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  144.     # When a skill is selected to be learned, the cost window appears. Adjust
  145.     # the settings here to choose how your game's cost window looks. Change the
  146.     # maximum number of rows, the gold icon used for gold costs, the gold text,
  147.     # the learn skill text, the cancel text, and the cancel icon here.
  148.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  149.     MAXIMUM_ROWS      = 8               # Maximum number of rows displayed.
  150.     GOLD_ICON         = 361             # Icon used for gold costs.
  151.     GOLD_TEXT         = "Coût"     # Text used for gold costs.
  152.     LEARN_SKILL_TEXT  = "Apprendre %s ?"     # Text used to learn skill.
  153.     LEARN_CANCEL_TEXT = "Annuler"        # Text used for do not learn.
  154.     CANCEL_ICON       = 187             # Icon used for cancel.
  155.    
  156.   end # LEARN_SKILL
  157. end # YEA
  158.  
  159. #==============================================================================
  160. # ▼ Editting anything past this point may potentially result in causing
  161. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  162. # halitosis so edit at your own risk.
  163. #==============================================================================
  164.  
  165. module YEA
  166.   module LEARN_SKILL
  167.     module_function
  168.     #--------------------------------------------------------------------------
  169.     # convert_integer_array
  170.     #--------------------------------------------------------------------------
  171.     def convert_integer_array(array)
  172.       result = []
  173.       array.each { |i|
  174.         case i
  175.         when Range; result |= i.to_a
  176.         when Integer; result |= [i]
  177.         end }
  178.       return result
  179.     end
  180.     #--------------------------------------------------------------------------
  181.     # converted_contants
  182.     #--------------------------------------------------------------------------
  183.     STYPE_ORDER = convert_integer_array(STYPE_ORDER)
  184.   end # LEARN_SKILL
  185.   module REGEXP
  186.   module CLASS
  187.    
  188.     LEARN_SKILLS = /<(?:LEARN_SKILLS|learn skills):[ ](\d+(?:\s*,\s*\d+)*)>/i
  189.    
  190.   end # CLASS
  191.   module SKILL
  192.    
  193.     LEARN_COST = /<(?:LEARN_COST|learn cost):[ ](.*)>/i
  194.     LEARN_REQUIRE_LEVEL =
  195.       /<(?:LEARN_REQUIRE_LEVEL|learn require level):[ ](\d+)>/i
  196.     LEARN_REQUIRE_SKILL =
  197.       /<(?:LEARN_REQUIRE_SKILL|learn require skill):[ ](\d+(?:\s*,\s*\d+)*)>/i
  198.     LEARN_REQUIRE_SWITCH =
  199.       /<(?:LEARN_REQUIRE_SWITCH|learn require switch):[ ](\d+(?:\s*,\s*\d+)*)>/i
  200.     LEARN_REQUIRE_EVAL_ON  = /<(?:LEARN_REQUIRE_EVAL|learn require eval)>/i
  201.     LEARN_REQUIRE_EVAL_OFF = /<\/(?:LEARN_REQUIRE_EVAL|learn require eval)>/i
  202.    
  203.   end # SKILL
  204.   end # REGEXP
  205. end # YEA
  206.  
  207. #==============================================================================
  208. # ■ Numeric
  209. #==============================================================================
  210.  
  211. class Numeric
  212.  
  213.   #--------------------------------------------------------------------------
  214.   # new method: group_digits
  215.   #--------------------------------------------------------------------------
  216.   unless $imported["YEA-CoreEngine"]
  217.   def group; return self.to_s; end
  218.   end # $imported["YEA-CoreEngine"]
  219.    
  220. end # Numeric
  221.  
  222. #==============================================================================
  223. # ■ Icon
  224. #==============================================================================
  225.  
  226. module Icon
  227.  
  228.   #--------------------------------------------------------------------------
  229.   # self.cancel
  230.   #--------------------------------------------------------------------------
  231.   def self.cancel
  232.     return YEA::LEARN_SKILL::CANCEL_ICON
  233.   end
  234.  
  235.   #--------------------------------------------------------------------------
  236.   # self.learn_skill_gold
  237.   #--------------------------------------------------------------------------
  238.   def self.learn_skill_gold
  239.     return YEA::LEARN_SKILL::GOLD_ICON
  240.   end
  241.  
  242. end # Icon
  243.  
  244. #==============================================================================
  245. # ■ Switch
  246. #==============================================================================
  247.  
  248. module Switch
  249.  
  250.   #--------------------------------------------------------------------------
  251.   # self.show_learn_skill
  252.   #--------------------------------------------------------------------------
  253.   def self.show_learn_skill
  254.     return true if YEA::LEARN_SKILL::SHOW_SWITCH <= 0
  255.     return $game_switches[YEA::LEARN_SKILL::SHOW_SWITCH]
  256.   end
  257.  
  258. end # Switch
  259.  
  260. #==============================================================================
  261. # ■ DataManager
  262. #==============================================================================
  263.  
  264. module DataManager
  265.  
  266.   #--------------------------------------------------------------------------
  267.   # alias method: load_database
  268.   #--------------------------------------------------------------------------
  269.   class <<self; alias load_database_lse load_database; end
  270.   def self.load_database
  271.     load_database_lse
  272.     load_notetags_lse
  273.   end
  274.  
  275.   #--------------------------------------------------------------------------
  276.   # new method: load_notetags_lse
  277.   #--------------------------------------------------------------------------
  278.   def self.load_notetags_lse
  279.     groups = [$data_classes, $data_skills]
  280.     for group in groups
  281.       for obj in group
  282.         next if obj.nil?
  283.         obj.load_notetags_lse
  284.       end
  285.     end
  286.   end
  287.  
  288. end # DataManager
  289.  
  290. #==============================================================================
  291. # ■ RPG::Class
  292. #==============================================================================
  293.  
  294. class RPG::Class < RPG::BaseItem
  295.  
  296.   #--------------------------------------------------------------------------
  297.   # public instance variables
  298.   #--------------------------------------------------------------------------
  299.   attr_accessor :learn_skills
  300.  
  301.   #--------------------------------------------------------------------------
  302.   # common cache: load_notetags_lse
  303.   #--------------------------------------------------------------------------
  304.   def load_notetags_lse
  305.     @learn_skills = []
  306.     #---
  307.     self.note.split(/[\r\n]+/).each { |line|
  308.       case line
  309.       #---
  310.       when YEA::REGEXP::CLASS::LEARN_SKILLS
  311.         $1.scan(/\d+/).each { |num|
  312.         @learn_skills.push(num.to_i) if num.to_i > 0 }
  313.       end
  314.     } # self.note.split
  315.     #---
  316.   end
  317.  
  318. end # RPG::Class
  319.  
  320. #==============================================================================
  321. # ■ RPG::Skill
  322. #==============================================================================
  323.  
  324. class RPG::Skill < RPG::UsableItem
  325.  
  326.   #--------------------------------------------------------------------------
  327.   # public instance variables
  328.   #--------------------------------------------------------------------------
  329.   attr_accessor :learn_cost
  330.   attr_accessor :learn_require_level
  331.   attr_accessor :learn_require_skill
  332.   attr_accessor :learn_require_switch
  333.   attr_accessor :learn_require_eval
  334.  
  335.   #--------------------------------------------------------------------------
  336.   # common cache: load_notetags_lse
  337.   #--------------------------------------------------------------------------
  338.   def load_notetags_lse
  339.     @learn_cost = [YEA::LEARN_SKILL::DEFAULT_COST]
  340.     @learn_cost.push(YEA::LEARN_SKILL::DEFAULT_TYPE)
  341.     @learn_require_level = 0
  342.     @learn_require_skill = []
  343.     @learn_require_switch = []
  344.     @learn_require_eval_on = false
  345.     #---
  346.     self.note.split(/[\r\n]+/).each { |line|
  347.       case line
  348.       #---
  349.       when YEA::REGEXP::SKILL::LEARN_COST
  350.         case $1.upcase
  351.         when /(\d+)[ ]JP/i
  352.           next unless $imported["YEA-JPManager"]
  353.           @learn_cost = [$1.to_i, :jp]
  354.         when /(\d+)[ ]EXP/i
  355.           @learn_cost = [$1.to_i, :exp]
  356.         when /(\d+)[ ]GOLD/i
  357.           @learn_cost = [$1.to_i, :gold]
  358.         end
  359.       #---
  360.       when YEA::REGEXP::SKILL::LEARN_REQUIRE_LEVEL
  361.         @learn_require_level = $1.to_i
  362.       when YEA::REGEXP::SKILL::LEARN_REQUIRE_SKILL
  363.         $1.scan(/\d+/).each { |num|
  364.         @learn_require_skill.push(num.to_i) if num.to_i > 0 }
  365.       when YEA::REGEXP::SKILL::LEARN_REQUIRE_SWITCH
  366.         $1.scan(/\d+/).each { |num|
  367.         @learn_require_switch.push(num.to_i) if num.to_i > 0 }
  368.       #---
  369.       when YEA::REGEXP::SKILL::LEARN_REQUIRE_EVAL_ON
  370.         @learn_require_eval_on = true
  371.       when YEA::REGEXP::SKILL::LEARN_REQUIRE_EVAL_OFF
  372.         @learn_require_eval_on = false
  373.       else
  374.         next unless @learn_require_eval_on
  375.         @learn_require_eval = "" if @learn_require_eval.nil?
  376.         @learn_require_eval += line.to_s
  377.       #---
  378.       end
  379.     } # self.note.split
  380.     #---
  381.     if !$imported["YEA-JPManager"] && @learn_cost[1] == :jp
  382.       @learn_cost[1] = :exp
  383.     end
  384.   end
  385.  
  386. end # RPG::Skill
  387.  
  388. #==============================================================================
  389. # ■ Game_Actor
  390. #==============================================================================
  391.  
  392. class Game_Actor < Game_Battler
  393.  
  394.   #--------------------------------------------------------------------------
  395.   # alias method: skills
  396.   #--------------------------------------------------------------------------
  397.   alias game_actor_skills_lse skills
  398.   def skills
  399.     btest_add_learn_skills
  400.     game_actor_skills_lse
  401.   end
  402.  
  403.   #--------------------------------------------------------------------------
  404.   # new method: btest_add_learn_skills
  405.   #--------------------------------------------------------------------------
  406.   def btest_add_learn_skills
  407.     return unless $BTEST
  408.     for skill_id in self.class.learn_skills; learn_skill(skill_id); end
  409.   end
  410.  
  411.   #--------------------------------------------------------------------------
  412.   # new method: exp_class
  413.   #--------------------------------------------------------------------------
  414.   def exp_class(class_id)
  415.     @exp[class_id] = 0 if @exp[class_id].nil?
  416.     return @exp[class_id]
  417.   end
  418.  
  419.   #--------------------------------------------------------------------------
  420.   # lose_exp_class
  421.   #--------------------------------------------------------------------------
  422.   def lose_exp_class(value, class_id)
  423.     exp = exp_class(class_id) - value
  424.     change_exp_class(exp, class_id)
  425.   end
  426.  
  427.   #--------------------------------------------------------------------------
  428.   # change_exp_class
  429.   #--------------------------------------------------------------------------
  430.   def change_exp_class(exp, class_id)
  431.     return change_exp(exp, false) if class_id == @class_id
  432.     @exp[class_id] = [exp, 0].max
  433.   end
  434.  
  435.   #--------------------------------------------------------------------------
  436.   # get_learn_skills
  437.   #--------------------------------------------------------------------------
  438.   def get_learn_skills()
  439.     skills = []
  440.     for skill_id in self.class.learn_skills
  441.       skills.push(skill_id) if @level >= $data_skills[skill_id].learn_require_level
  442.     end
  443.     return skills
  444.   end
  445.  
  446. end # Game_Actor
  447.  
  448. #==============================================================================
  449. # ■ Window_SkillCommand
  450. #==============================================================================
  451.  
  452. class Window_SkillCommand < Window_Command
  453.  
  454.   #--------------------------------------------------------------------------
  455.   # alias method: make_command_list
  456.   #--------------------------------------------------------------------------
  457.   alias window_skillcommand_make_command_list_lse make_command_list
  458.   def make_command_list
  459.     window_skillcommand_make_command_list_lse
  460.     return if @actor.nil?
  461.     add_learn_skill_command unless $imported["YEA-SkillMenu"]
  462.   end
  463.  
  464.   #--------------------------------------------------------------------------
  465.   # new method: add_learn_skill_command
  466.   #--------------------------------------------------------------------------
  467.   def add_learn_skill_command
  468.     return unless Switch.show_learn_skill
  469.     name = YEA::LEARN_SKILL::COMMAND_NAME
  470.     add_command(name, :learn_skill, true, @actor.added_skill_types[0])
  471.   end
  472.  
  473. end # Window_SkillCommand
  474.  
  475. #==============================================================================
  476. # ■ Window_LearnSkillCommand
  477. #==============================================================================
  478.  
  479. class Window_LearnSkillCommand < Window_Command
  480.  
  481.   #--------------------------------------------------------------------------
  482.   # public instance variables
  483.   #--------------------------------------------------------------------------
  484.   attr_reader   :skill_window
  485.  
  486.   #--------------------------------------------------------------------------
  487.   # initialize
  488.   #--------------------------------------------------------------------------
  489.   def initialize(dx, dy)
  490.     super(dx, dy)
  491.     @actor = nil
  492.   end
  493.  
  494.   #--------------------------------------------------------------------------
  495.   # window_width
  496.   #--------------------------------------------------------------------------
  497.   def window_width; return 160; end
  498.  
  499.   #--------------------------------------------------------------------------
  500.   # visible_line_number
  501.   #--------------------------------------------------------------------------
  502.   def visible_line_number; return 4; end
  503.  
  504.   #--------------------------------------------------------------------------
  505.   # actor=
  506.   #--------------------------------------------------------------------------
  507.   def actor=(actor)
  508.     return if @actor == actor
  509.     @actor = actor
  510.     refresh
  511.     select(item_max - 1) if index >= item_max
  512.   end
  513.  
  514.   #--------------------------------------------------------------------------
  515.   # make_command_list
  516.   #--------------------------------------------------------------------------
  517.   def make_command_list
  518.     return if @actor.nil?
  519.     make_unlocked_class_skill_types
  520.     correct_unlocked_class_learned_skills
  521.     for stype_id in YEA::LEARN_SKILL::STYPE_ORDER
  522.       next unless include?(stype_id)
  523.       name = $data_system.skill_types[stype_id]
  524.       add_command(name, :skill, true, stype_id)
  525.     end
  526.   end
  527.  
  528.   #--------------------------------------------------------------------------
  529.   # make_unlocked_class_skill_types
  530.   #--------------------------------------------------------------------------
  531.   def make_unlocked_class_skill_types
  532.     return unless $imported["YEA-ClassSystem"]
  533.     @unlocked_types = []
  534.     unlocked_classes = @actor.unlocked_classes.clone
  535.     unlocked_classes |= YEA::CLASS_SYSTEM::DEFAULT_UNLOCKS
  536.     for class_id in unlocked_classes
  537.       next if $data_classes[class_id].nil?
  538.       for feature in $data_classes[class_id].features
  539.         next unless feature.code == 41
  540.         @unlocked_types.push(feature.data_id)
  541.       end
  542.     end
  543.   end
  544.  
  545.   #--------------------------------------------------------------------------
  546.   # correct_unlocked_class_learned_skills
  547.   #--------------------------------------------------------------------------
  548.   def correct_unlocked_class_learned_skills
  549.     return unless $imported["YEA-ClassSystem"]
  550.     unlocked_classes = @actor.unlocked_classes.clone
  551.     unlocked_classes |= YEA::CLASS_SYSTEM::DEFAULT_UNLOCKS
  552.     for class_id in unlocked_classes
  553.       @actor.learn_class_skills(class_id)
  554.     end
  555.   end
  556.  
  557.   #--------------------------------------------------------------------------
  558.   # include?
  559.   #--------------------------------------------------------------------------
  560.   def include?(stype_id)
  561.     return true if @actor.added_skill_types.include?(stype_id)
  562.     if $imported["YEA-ClassSystem"]
  563.       return true if @unlocked_types.include?(stype_id)
  564.     end
  565.     return false
  566.   end
  567.  
  568.   #--------------------------------------------------------------------------
  569.   # update
  570.   #--------------------------------------------------------------------------
  571.   def update
  572.     super
  573.     @skill_window.stype_id = current_ext if @skill_window
  574.   end
  575.  
  576.   #--------------------------------------------------------------------------
  577.   # skill_window=
  578.   #--------------------------------------------------------------------------
  579.   def skill_window=(skill_window)
  580.     @skill_window = skill_window
  581.     update
  582.   end
  583.  
  584. end # Window_LearnSkillCommand
  585.  
  586. #==============================================================================
  587. # ■ Window_LearnSkillList
  588. #==============================================================================
  589.  
  590. class Window_LearnSkillList < Window_SkillList
  591.  
  592.   #--------------------------------------------------------------------------
  593.   # col_max
  594.   #--------------------------------------------------------------------------
  595.   def col_max; return 1; end
  596.  
  597.   #--------------------------------------------------------------------------
  598.   # select_last
  599.   #--------------------------------------------------------------------------
  600.   def select_last; select(0); end
  601.  
  602.   #--------------------------------------------------------------------------
  603.   # actor=
  604.   #--------------------------------------------------------------------------
  605.   def actor=(actor)
  606.     return if @actor == actor
  607.     super(actor)
  608.     make_learn_skills_list
  609.   end
  610.  
  611.   #--------------------------------------------------------------------------
  612.   # make_learn_skills_list
  613.   #--------------------------------------------------------------------------
  614.   def make_learn_skills_list
  615.     @learn_skills = []
  616.     @skill_classes = {}
  617.     return if @actor.nil?
  618.     for skill_id in @actor.class.learn_skills
  619.       next if $data_skills[skill_id].nil?
  620.       next if @learn_skills.include?($data_skills[skill_id])
  621.       skill = $data_skills[skill_id]
  622.       @learn_skills.push(skill)
  623.       @skill_classes[skill] = [] if @skill_classes[skill].nil?
  624.       @skill_classes[skill].push(@actor.class.id)
  625.     end
  626.     make_unlocked_class_skills
  627.   end
  628.  
  629.   #--------------------------------------------------------------------------
  630.   # make_unlocked_class_skills
  631.   #--------------------------------------------------------------------------
  632.   def make_unlocked_class_skills
  633.     return unless $imported["YEA-ClassSystem"]
  634.     @unlocked_types = []
  635.     unlocked_classes = @actor.unlocked_classes.clone
  636.     unlocked_classes |= YEA::CLASS_SYSTEM::DEFAULT_UNLOCKS
  637.     for class_id in unlocked_classes
  638.       next if $data_classes[class_id].nil?
  639.       for skill_id in $data_classes[class_id].learn_skills
  640.         next if $data_skills[skill_id].nil?
  641.         skill = $data_skills[skill_id]
  642.         @learn_skills.push(skill) unless @learn_skills.include?(skill)
  643.         @skill_classes[skill] = [] if @skill_classes[skill].nil?
  644.         @skill_classes[skill] |= [class_id]
  645.       end
  646.     end
  647.   end
  648.  
  649.   #--------------------------------------------------------------------------
  650.   # skill_classes
  651.   #--------------------------------------------------------------------------
  652.   def skill_classes(skill)
  653.     return @skill_classes[skill]
  654.   end
  655.  
  656.   #--------------------------------------------------------------------------
  657.   # make_item_list
  658.   #--------------------------------------------------------------------------
  659.   def make_item_list
  660.     return if @learn_skills.nil?
  661.     @data = @learn_skills.select {|skill| include?(skill) }
  662.   end
  663.  
  664.   #--------------------------------------------------------------------------
  665.   # include?
  666.   #--------------------------------------------------------------------------
  667.   def include?(item)
  668.     return false if item.nil?
  669.     return false unless meet_requirements?(item)
  670.     return item.stype_id == @stype_id
  671.   end
  672.  
  673.   #--------------------------------------------------------------------------
  674.   # meet_requirements?
  675.   #--------------------------------------------------------------------------
  676.   def meet_requirements?(item)
  677.     return false if @actor.nil?
  678.     return false unless meet_level_requirements?(item)
  679.     return false unless meet_skill_requirements?(item)
  680.     return false unless meet_switch_requirements?(item)
  681.     return false unless meet_eval_requirements?(item)
  682.     return true
  683.   end
  684.  
  685.   #--------------------------------------------------------------------------
  686.   # meet_level_requirements?
  687.   #--------------------------------------------------------------------------
  688.   def meet_level_requirements?(item)
  689.     return @actor.level >= item.learn_require_level
  690.   end
  691.  
  692.   #--------------------------------------------------------------------------
  693.   # meet_skill_requirements?
  694.   #--------------------------------------------------------------------------
  695.   def meet_skill_requirements?(item)
  696.     for skill_id in item.learn_require_skill
  697.       next if $data_skills[skill_id].nil?
  698.       return false unless @actor.skill_learn?($data_skills[skill_id])
  699.     end
  700.     return true
  701.   end
  702.  
  703.   #--------------------------------------------------------------------------
  704.   # meet_switch_requirements?
  705.   #--------------------------------------------------------------------------
  706.   def meet_switch_requirements?(item)
  707.     for switch_id in item.learn_require_switch
  708.       return false unless $game_switches[switch_id]
  709.     end
  710.     return true
  711.   end
  712.  
  713.   #--------------------------------------------------------------------------
  714.   # meet_eval_requirements?
  715.   #--------------------------------------------------------------------------
  716.   def meet_eval_requirements?(item)
  717.     return true if item.learn_require_eval.nil?
  718.     return eval(item.learn_require_eval)
  719.   end
  720.  
  721.   #--------------------------------------------------------------------------
  722.   # enable?
  723.   #--------------------------------------------------------------------------
  724.   def enable?(skill)
  725.     return false if skill.nil?
  726.     return false unless enabled_jp?(skill)
  727.     return false unless enabled_exp?(skill)
  728.     return false unless enabled_gold?(skill)
  729.     return !@actor.skill_learn?(skill)
  730.   end
  731.  
  732.   #--------------------------------------------------------------------------
  733.   # enabled_jp?
  734.   #--------------------------------------------------------------------------
  735.   def enabled_jp?(skill)
  736.     return true if skill.learn_cost[1] != :jp
  737.     cost = skill.learn_cost[0]
  738.     for class_id in @skill_classes[skill]
  739.       return true if @actor.jp(class_id) >= cost
  740.     end
  741.     return false
  742.   end
  743.  
  744.   #--------------------------------------------------------------------------
  745.   # enabled_exp?
  746.   #--------------------------------------------------------------------------
  747.   def enabled_exp?(skill)
  748.     return true if skill.learn_cost[1] != :exp
  749.     cost = skill.learn_cost[0]
  750.     for class_id in @skill_classes[skill]
  751.       return true if @actor.exp_class(class_id) >= cost
  752.     end
  753.     return false
  754.   end
  755.  
  756.   #--------------------------------------------------------------------------
  757.   # enabled_gold?
  758.   #--------------------------------------------------------------------------
  759.   def enabled_gold?(skill)
  760.     return true if skill.learn_cost[1] != :gold
  761.     cost = skill.learn_cost[0]
  762.     return $game_party.gold >= cost
  763.   end
  764.  
  765.   #--------------------------------------------------------------------------
  766.   # draw_item
  767.   #--------------------------------------------------------------------------
  768.   def draw_item(index)
  769.     skill = @data[index]
  770.     return if skill.nil?
  771.     rect = item_rect(index)
  772.     rect.width = (contents.width - spacing) / 2 - 4
  773.     draw_item_name(skill, rect.x, rect.y, enable?(skill), rect.width - 24)
  774.     draw_skill_cost(rect, skill)
  775.     draw_restriction_info(skill, index)
  776.     draw_learn_cost(skill, index)
  777.   end
  778.  
  779.   #--------------------------------------------------------------------------
  780.   # skill_restriction?
  781.   #--------------------------------------------------------------------------
  782.   def skill_restriction?(index)
  783.     return false
  784.   end
  785.  
  786.   #--------------------------------------------------------------------------
  787.   # draw_restriction_info
  788.   #--------------------------------------------------------------------------
  789.   def draw_restriction_info(skill, index)
  790.     return unless $imported["YEA-SkillRestrictions"]
  791.     rect = item_rect(index)
  792.     rect.x = contents.width / 2
  793.     rect.width /= 2
  794.     rect.width /= 3
  795.     rect.width -= 8
  796.     draw_skill_warmup(skill, rect)
  797.     rect.x += rect.width + 4
  798.     draw_skill_cooldown(skill, rect)
  799.   end
  800.  
  801.   #--------------------------------------------------------------------------
  802.   # draw_skill_warmup
  803.   #--------------------------------------------------------------------------
  804.   def draw_skill_warmup(skill, rect)
  805.     return unless YEA::LEARN_SKILL::DRAW_WARMUP
  806.     enabled = enable?(skill)
  807.     enabled = false if skill.warmup <= 0
  808.     change_color(warmup_colour, enabled)
  809.     icon = Icon.warmup
  810.     if icon > 0
  811.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  812.       rect.width -= 24
  813.     end
  814.     contents.font.size = YEA::SKILL_RESTRICT::WARMUP_SIZE
  815.     value = skill.warmup > 0 ? skill.warmup.group : empty_text
  816.     text = sprintf(YEA::SKILL_RESTRICT::WARMUP_SUFFIX, value)
  817.     draw_text(rect, text, 2)
  818.     reset_font_settings
  819.   end
  820.  
  821.   #--------------------------------------------------------------------------
  822.   # draw_skill_cooldown
  823.   #--------------------------------------------------------------------------
  824.   def draw_skill_cooldown(skill, rect)
  825.     return unless YEA::LEARN_SKILL::DRAW_COOLDOWN
  826.     enabled = enable?(skill)
  827.     enabled = false if skill.cooldown <= 0
  828.     change_color(cooldown_colour, enabled)
  829.     icon = Icon.cooldown
  830.     if icon > 0
  831.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  832.       rect.width -= 24
  833.     end
  834.     contents.font.size = YEA::SKILL_RESTRICT::COOLDOWN_SIZE
  835.     value = skill.cooldown > 0 ? skill.cooldown.group : empty_text
  836.     text = sprintf(YEA::SKILL_RESTRICT::COOLDOWN_SUFFIX, value)
  837.     draw_text(rect, text, 2)
  838.     reset_font_settings
  839.   end
  840.  
  841.   #--------------------------------------------------------------------------
  842.   # empty_text
  843.   #--------------------------------------------------------------------------
  844.   def empty_text
  845.     return YEA::LEARN_SKILL::EMPTY_TEXT
  846.   end
  847.  
  848.   #--------------------------------------------------------------------------
  849.   # draw_learn_cost
  850.   #--------------------------------------------------------------------------
  851.   def draw_learn_cost(skill, index)
  852.     rect = item_rect(index)
  853.     rect.width -= 4
  854.     if @actor.skill_learn?(skill)
  855.       draw_learned_skill(rect)
  856.     else
  857.       draw_learn_skill_cost(skill, rect)
  858.     end
  859.     reset_font_settings
  860.   end
  861.  
  862.   #--------------------------------------------------------------------------
  863.   # draw_learned_skill
  864.   #--------------------------------------------------------------------------
  865.   def draw_learned_skill(rect)
  866.     contents.font.size = YEA::LEARN_SKILL::LEARNED_SIZE
  867.     change_color(normal_color)
  868.     draw_text(rect, YEA::LEARN_SKILL::LEARNED_TEXT, 2)
  869.   end
  870.  
  871.   #--------------------------------------------------------------------------
  872.   # draw_learn_skill_cost
  873.   #--------------------------------------------------------------------------
  874.   def draw_learn_skill_cost(skill, rect)
  875.     case skill.learn_cost[1]
  876.     when :jp
  877.       return unless $imported["YEA-JPManager"]
  878.       draw_jp_cost(skill, rect)
  879.     when :exp
  880.       draw_exp_cost(skill, rect)
  881.     when :gold
  882.       draw_gold_cost(skill, rect)
  883.     else; return
  884.     end
  885.   end
  886.  
  887.   #--------------------------------------------------------------------------
  888.   # draw_jp_cost
  889.   #--------------------------------------------------------------------------
  890.   def draw_jp_cost(skill, rect)
  891.     enabled = enabled_jp?(skill)
  892.     if Icon.jp > 0
  893.       draw_icon(Icon.jp, rect.x + rect.width - 24, rect.y, enabled)
  894.       rect.width -= 24
  895.     end
  896.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  897.     change_color(system_color, enabled)
  898.     draw_text(rect, Vocab::jp, 2)
  899.     rect.width -= text_size(Vocab::jp).width
  900.     cost = skill.learn_cost[0]
  901.     text = cost.group
  902.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_JP), enabled)
  903.     draw_text(rect, text, 2)
  904.   end
  905.  
  906.   #--------------------------------------------------------------------------
  907.   # draw_exp_cost
  908.   #--------------------------------------------------------------------------
  909.   def draw_exp_cost(skill, rect)
  910.     enabled = enabled_exp?(skill)
  911.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  912.     change_color(system_color, enabled)
  913.     draw_text(rect, YEA::LEARN_SKILL::EXP_TEXT, 2)
  914.     rect.width -= text_size(YEA::LEARN_SKILL::EXP_TEXT).width
  915.     cost = skill.learn_cost[0]
  916.     text = cost.group
  917.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_EXP), enabled)
  918.     draw_text(rect, text, 2)
  919.   end
  920.  
  921.   #--------------------------------------------------------------------------
  922.   # draw_gold_cost
  923.   #--------------------------------------------------------------------------
  924.   def draw_gold_cost(skill, rect)
  925.     enabled = enabled_jp?(skill)
  926.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  927.     change_color(system_color, enabled)
  928.     draw_text(rect, Vocab::currency_unit, 2)
  929.     rect.width -= text_size(Vocab::currency_unit).width
  930.     cost = skill.learn_cost[0]
  931.     text = cost.group
  932.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_GOLD), enabled)
  933.     draw_text(rect, text, 2)
  934.   end
  935.  
  936. end # Window_LearnSkillList
  937.  
  938. #==============================================================================
  939. # ■ Window_LearnSkillCostBack
  940. #==============================================================================
  941.  
  942. class Window_LearnSkillCostBack < Window_Base
  943.  
  944.   #--------------------------------------------------------------------------
  945.   # initialize
  946.   #--------------------------------------------------------------------------
  947.   def initialize(item_window)
  948.     dw = Graphics.width * 3 / 4
  949.     dx = (Graphics.width - dw) / 2
  950.     super(dx, 0, dw, fitting_height(2))
  951.     self.openness = 0
  952.     self.back_opacity = 255
  953.     @front_window = nil
  954.     @item_window = item_window
  955.     @skill = nil
  956.   end
  957.  
  958.   #--------------------------------------------------------------------------
  959.   # reveal
  960.   #--------------------------------------------------------------------------
  961.   def reveal(skill, skill_classes)
  962.     @skill = skill
  963.     return if @skill.nil?
  964.     case @skill.learn_cost[1]
  965.     when :gold
  966.       self.height = fitting_height(3)
  967.     else
  968.       maximum = [skill_classes.size, YEA::LEARN_SKILL::MAXIMUM_ROWS].min
  969.       self.height = fitting_height(maximum + 2)
  970.     end
  971.     create_contents
  972.     self.y = (Graphics.height - self.height) / 2
  973.     refresh
  974.     open
  975.   end
  976.  
  977.   #--------------------------------------------------------------------------
  978.   # refresh
  979.   #--------------------------------------------------------------------------
  980.   def refresh
  981.     contents.clear
  982.     reset_font_settings
  983.     draw_learn_skill_text
  984.     rect = Rect.new(0, 0, contents.width - 4, line_height)
  985.     draw_learn_skill_cost(@skill, rect)
  986.   end
  987.  
  988.   #--------------------------------------------------------------------------
  989.   # draw_learn_skill_text
  990.   #--------------------------------------------------------------------------
  991.   def draw_learn_skill_text
  992.     name = sprintf("\eI[%d]%s", @skill.icon_index, @skill.name)
  993.     fmt = YEA::LEARN_SKILL::LEARN_SKILL_TEXT
  994.     text = sprintf(fmt, name)
  995.     draw_text_ex(4, 0, text)
  996.   end
  997.  
  998.   #--------------------------------------------------------------------------
  999.   # draw_learn_skill_cost
  1000.   #--------------------------------------------------------------------------
  1001.   def draw_learn_skill_cost(skill, rect)
  1002.     case skill.learn_cost[1]
  1003.     when :jp
  1004.       return unless $imported["YEA-JPManager"]
  1005.       draw_jp_cost(skill, rect)
  1006.     when :exp
  1007.       draw_exp_cost(skill, rect)
  1008.     when :gold
  1009.       draw_gold_cost(skill, rect)
  1010.     else; return
  1011.     end
  1012.   end
  1013.  
  1014.   #--------------------------------------------------------------------------
  1015.   # draw_jp_cost
  1016.   #--------------------------------------------------------------------------
  1017.   def draw_jp_cost(skill, rect)
  1018.     enabled = true
  1019.     if Icon.jp > 0
  1020.       draw_icon(Icon.jp, rect.x + rect.width - 24, rect.y, enabled)
  1021.       rect.width -= 24
  1022.     end
  1023.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  1024.     change_color(system_color, enabled)
  1025.     draw_text(rect, Vocab::jp, 2)
  1026.     rect.width -= text_size(Vocab::jp).width
  1027.     cost = skill.learn_cost[0]
  1028.     text = cost.group
  1029.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_JP), enabled)
  1030.     draw_text(rect, text, 2)
  1031.   end
  1032.  
  1033.   #--------------------------------------------------------------------------
  1034.   # draw_exp_cost
  1035.   #--------------------------------------------------------------------------
  1036.   def draw_exp_cost(skill, rect)
  1037.     enabled = true
  1038.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  1039.     change_color(system_color, enabled)
  1040.     draw_text(rect, YEA::LEARN_SKILL::EXP_TEXT, 2)
  1041.     rect.width -= text_size(YEA::LEARN_SKILL::EXP_TEXT).width
  1042.     cost = skill.learn_cost[0]
  1043.     text = cost.group
  1044.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_EXP), enabled)
  1045.     draw_text(rect, text, 2)
  1046.   end
  1047.  
  1048.   #--------------------------------------------------------------------------
  1049.   # draw_gold_cost
  1050.   #--------------------------------------------------------------------------
  1051.   def draw_gold_cost(skill, rect)
  1052.     enabled = true
  1053.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  1054.     change_color(system_color, enabled)
  1055.     draw_text(rect, Vocab::currency_unit, 2)
  1056.     rect.width -= text_size(Vocab::currency_unit).width
  1057.     cost = skill.learn_cost[0]
  1058.     text = cost.group
  1059.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_GOLD), enabled)
  1060.     draw_text(rect, text, 2)
  1061.   end
  1062.  
  1063. end # Window_LearnSkillCostBack
  1064.  
  1065. #==============================================================================
  1066. # ■ Window_LearnSkillCostFront
  1067. #==============================================================================
  1068.  
  1069. class Window_LearnSkillCostFront < Window_Command
  1070.  
  1071.   #--------------------------------------------------------------------------
  1072.   # initialize
  1073.   #--------------------------------------------------------------------------
  1074.   def initialize(item_window, cost_window)
  1075.     super((Graphics.width - window_width) / 2, 0)
  1076.     self.openness = 0
  1077.     self.opacity = 0
  1078.     @item_window = item_window
  1079.     @cost_window = cost_window
  1080.     @skill = nil
  1081.     @actor = nil
  1082.     deactivate
  1083.   end
  1084.  
  1085.   #--------------------------------------------------------------------------
  1086.   # window_width
  1087.   #--------------------------------------------------------------------------
  1088.   def window_width; return Graphics.width * 3 / 4; end
  1089.  
  1090.   #--------------------------------------------------------------------------
  1091.   # skill_class
  1092.   #--------------------------------------------------------------------------
  1093.   def skill_class
  1094.     return @skill_classes.nil? ? nil : @skill_classes[index]
  1095.   end
  1096.  
  1097.   #--------------------------------------------------------------------------
  1098.   # reveal
  1099.   #--------------------------------------------------------------------------
  1100.   def reveal(skill, skill_classes, actor)
  1101.     @skill = skill
  1102.     @skill_classes = skill_classes.clone
  1103.     @actor = actor
  1104.     return if @skill.nil?
  1105.     case @skill.learn_cost[1]
  1106.     when :gold
  1107.       self.height = fitting_height(2)
  1108.     else
  1109.       maximum = [skill_classes.size, YEA::LEARN_SKILL::MAXIMUM_ROWS].min
  1110.       self.height = fitting_height(maximum + 1)
  1111.     end
  1112.     create_contents
  1113.     self.y = @cost_window.y + line_height
  1114.     refresh
  1115.     select(0)
  1116.     open
  1117.     activate
  1118.   end
  1119.  
  1120.   #--------------------------------------------------------------------------
  1121.   # make_command_list
  1122.   #--------------------------------------------------------------------------
  1123.   def make_command_list
  1124.     return if @skill_classes.nil?
  1125.     if @skill.learn_cost[1] == :gold
  1126.       add_command("GOLD", :gold, true)
  1127.       add_command(YEA::LEARN_SKILL::LEARN_CANCEL_TEXT, :cancel, true)
  1128.       return
  1129.     end
  1130.     for class_id in @skill_classes
  1131.       name = $data_classes[class_id].name
  1132.       add_command(name, :class, enabled?(class_id), class_id)
  1133.     end
  1134.     add_command(YEA::LEARN_SKILL::LEARN_CANCEL_TEXT, :cancel, true)
  1135.   end
  1136.  
  1137.   #--------------------------------------------------------------------------
  1138.   # enabled?
  1139.   #--------------------------------------------------------------------------
  1140.   def enabled?(class_id)
  1141.     cost = @skill.learn_cost[0]
  1142.     case @skill.learn_cost[1]
  1143.     when :jp
  1144.       return @actor.jp(class_id) >= cost
  1145.     when :exp
  1146.       return @actor.exp_class(class_id) >= cost
  1147.     end
  1148.     return true
  1149.   end
  1150.  
  1151.   #--------------------------------------------------------------------------
  1152.   # draw_item
  1153.   #--------------------------------------------------------------------------
  1154.   def draw_item(index)
  1155.     reset_font_settings
  1156.     rect = item_rect(index)
  1157.     rect.x += 24
  1158.     rect.width -= 28
  1159.     return draw_cancel_text(index, rect) if @list[index][:symbol] == :cancel
  1160.     draw_class_name(index, rect) if @skill.learn_cost[1] != :gold
  1161.     draw_party_gold(rect) if @skill.learn_cost[1] == :gold
  1162.     draw_learn_skill_cost(@skill, rect, index)
  1163.   end
  1164.  
  1165.   #--------------------------------------------------------------------------
  1166.   # draw_cancel_text
  1167.   #--------------------------------------------------------------------------
  1168.   def draw_cancel_text(index, rect)
  1169.     draw_icon(Icon.cancel, rect.x, rect.y)
  1170.     text = command_name(index)
  1171.     draw_text(rect.x+24, rect.y, rect.width-24, line_height, text)
  1172.   end
  1173.  
  1174.   #--------------------------------------------------------------------------
  1175.   # draw_class_name
  1176.   #--------------------------------------------------------------------------
  1177.   def draw_class_name(index, rect)
  1178.     class_id = @list[index][:ext]
  1179.     return if $data_classes[class_id].nil?
  1180.     enabled = enabled?(class_id)
  1181.     if $imported["YEA-ClassSystem"]
  1182.       draw_icon($data_classes[class_id].icon_index, rect.x, rect.y, enabled)
  1183.     end
  1184.     rect.x += 24
  1185.     rect.width -= 24
  1186.     change_color(normal_color, enabled)
  1187.     draw_text(rect, $data_classes[class_id].name)
  1188.   end
  1189.  
  1190.   #--------------------------------------------------------------------------
  1191.   # draw_class_name
  1192.   #--------------------------------------------------------------------------
  1193.   def draw_party_gold(rect)
  1194.     enabled = true
  1195.     draw_icon(Icon.learn_skill_gold, rect.x, rect.y)
  1196.     rect.x += 24
  1197.     rect.width -= 24
  1198.     change_color(normal_color, enabled)
  1199.     draw_text(rect, YEA::LEARN_SKILL::GOLD_TEXT)
  1200.   end
  1201.  
  1202.   #--------------------------------------------------------------------------
  1203.   # draw_learn_skill_cost
  1204.   #--------------------------------------------------------------------------
  1205.   def draw_learn_skill_cost(skill, rect, index)
  1206.     case skill.learn_cost[1]
  1207.     when :jp
  1208.       return unless $imported["YEA-JPManager"]
  1209.       draw_jp_cost(skill, rect, index)
  1210.     when :exp
  1211.       draw_exp_cost(skill, rect, index)
  1212.     when :gold
  1213.       draw_gold_cost(skill, rect)
  1214.     else; return
  1215.     end
  1216.   end
  1217.  
  1218.   #--------------------------------------------------------------------------
  1219.   # draw_jp_cost
  1220.   #--------------------------------------------------------------------------
  1221.   def draw_jp_cost(skill, rect, index)
  1222.     enabled = enabled?(@list[index][:ext])
  1223.     if Icon.jp > 0
  1224.       draw_icon(Icon.jp, rect.x + rect.width - 24, rect.y, enabled)
  1225.       rect.width -= 24
  1226.     end
  1227.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  1228.     change_color(system_color, enabled)
  1229.     draw_text(rect, Vocab::jp, 2)
  1230.     rect.width -= text_size(Vocab::jp).width
  1231.     cost = @actor.jp(@list[index][:ext])
  1232.     text = cost.group
  1233.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_JP), enabled)
  1234.     draw_text(rect, text, 2)
  1235.   end
  1236.  
  1237.   #--------------------------------------------------------------------------
  1238.   # draw_exp_cost
  1239.   #--------------------------------------------------------------------------
  1240.   def draw_exp_cost(skill, rect, index)
  1241.     enabled = enabled?(@list[index][:ext])
  1242.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  1243.     change_color(system_color, enabled)
  1244.     draw_text(rect, YEA::LEARN_SKILL::EXP_TEXT, 2)
  1245.     rect.width -= text_size(YEA::LEARN_SKILL::EXP_TEXT).width
  1246.     cost = @actor.exp_class(@list[index][:ext])
  1247.     text = cost.group
  1248.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_EXP), enabled)
  1249.     draw_text(rect, text, 2)
  1250.   end
  1251.  
  1252.   #--------------------------------------------------------------------------
  1253.   # draw_gold_cost
  1254.   #--------------------------------------------------------------------------
  1255.   def draw_gold_cost(skill, rect)
  1256.     enabled = $game_party.gold >= skill.learn_cost[0]
  1257.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  1258.     change_color(system_color, enabled)
  1259.     draw_text(rect, Vocab::currency_unit, 2)
  1260.     rect.width -= text_size(Vocab::currency_unit).width
  1261.     cost = $game_party.gold
  1262.     text = cost.group
  1263.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_GOLD), enabled)
  1264.     draw_text(rect, text, 2)
  1265.   end
  1266.  
  1267. end # Window_LearnSkillCostFront
  1268.  
  1269. #==============================================================================
  1270. # ■ Scene_Skill
  1271. #==============================================================================
  1272.  
  1273. class Scene_Skill < Scene_ItemBase
  1274.  
  1275.   #--------------------------------------------------------------------------
  1276.   # alias method: create_command_window
  1277.   #--------------------------------------------------------------------------
  1278.   alias scene_skill_create_command_window_lse create_command_window
  1279.   def create_command_window
  1280.     scene_skill_create_command_window_lse
  1281.     @command_window.set_handler(:learn_skill, method(:command_learn_skill))
  1282.   end
  1283.  
  1284.   #--------------------------------------------------------------------------
  1285.   # new method: command_learn_skill
  1286.   #--------------------------------------------------------------------------
  1287.   def command_learn_skill
  1288.     SceneManager.call(Scene_LearnSkill)
  1289.   end
  1290.  
  1291. end # Scene_Skill
  1292.  
  1293. #==============================================================================
  1294. # ■ Scene_LearnSkill
  1295. #==============================================================================
  1296.  
  1297. class Scene_LearnSkill < Scene_Skill
  1298.  
  1299.   #--------------------------------------------------------------------------
  1300.   # start
  1301.   #--------------------------------------------------------------------------
  1302.   def start
  1303.     super
  1304.     create_cost_windows
  1305.   end
  1306.  
  1307.   #--------------------------------------------------------------------------
  1308.   # create_command_window
  1309.   #--------------------------------------------------------------------------
  1310.   def create_command_window
  1311.     wy = @help_window.height
  1312.     @command_window = Window_LearnSkillCommand.new(0, wy)
  1313.     @command_window.viewport = @viewport
  1314.     @command_window.help_window = @help_window
  1315.     @command_window.actor = @actor
  1316.     @command_window.set_handler(:skill,    method(:command_skill))
  1317.     @command_window.set_handler(:cancel,   method(:return_scene))
  1318.     @command_window.set_handler(:pagedown, method(:next_actor))
  1319.     @command_window.set_handler(:pageup,   method(:prev_actor))
  1320.   end
  1321.  
  1322.   #--------------------------------------------------------------------------
  1323.   # create_item_window
  1324.   #--------------------------------------------------------------------------
  1325.   def create_item_window
  1326.     wx = 0
  1327.     wy = @status_window.y + @status_window.height
  1328.     ww = Graphics.width
  1329.     wh = Graphics.height - wy
  1330.     @item_window = Window_LearnSkillList.new(wx, wy, ww, wh)
  1331.     @item_window.actor = @actor
  1332.     @item_window.viewport = @viewport
  1333.     @item_window.help_window = @help_window
  1334.     @item_window.set_handler(:ok,     method(:on_item_ok))
  1335.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  1336.     @command_window.skill_window = @item_window
  1337.   end
  1338.  
  1339.   #--------------------------------------------------------------------------
  1340.   # create_cost_windows
  1341.   #--------------------------------------------------------------------------
  1342.   def create_cost_windows
  1343.     @cost_window = Window_LearnSkillCostBack.new(@item_window)
  1344.     @cost_front = Window_LearnSkillCostFront.new(@item_window, @cost_window)
  1345.     @cost_window.viewport = @viewport
  1346.     @cost_front.viewport = @viewport
  1347.     @cost_front.set_handler(:ok, method(:on_cost_ok))
  1348.     @cost_front.set_handler(:cancel, method(:on_cost_cancel))
  1349.   end
  1350.  
  1351.   #--------------------------------------------------------------------------
  1352.   # on_item_ok
  1353.   #--------------------------------------------------------------------------
  1354.   def on_item_ok
  1355.     skill = @item_window.item
  1356.     @cost_window.reveal(skill, @item_window.skill_classes(skill))
  1357.     @cost_front.reveal(skill, @item_window.skill_classes(skill), @actor)
  1358.   end
  1359.  
  1360.   #--------------------------------------------------------------------------
  1361.   # on_cost_ok
  1362.   #--------------------------------------------------------------------------
  1363.   def on_cost_ok
  1364.     Sound.play_use_skill
  1365.     skill = @item_window.item
  1366.     @actor.learn_skill(skill.id)
  1367.     cost = skill.learn_cost[0]
  1368.     case skill.learn_cost[1]
  1369.     when :jp
  1370.       @actor.lose_jp(cost, @cost_front.skill_class)
  1371.     when :exp
  1372.       @actor.lose_exp_class(cost, @cost_front.skill_class)
  1373.     when :gold
  1374.       $game_party.lose_gold(cost)
  1375.     end
  1376.     on_cost_cancel
  1377.     refresh_windows
  1378.   end
  1379.  
  1380.   #--------------------------------------------------------------------------
  1381.   # on_cost_cancel
  1382.   #--------------------------------------------------------------------------
  1383.   def on_cost_cancel
  1384.     @cost_front.close
  1385.     @cost_window.close
  1386.     @item_window.activate
  1387.   end
  1388.  
  1389.   #--------------------------------------------------------------------------
  1390.   # refresh_windows
  1391.   #--------------------------------------------------------------------------
  1392.   def refresh_windows
  1393.     @item_window.refresh
  1394.     @status_window.refresh
  1395.   end
  1396.  
  1397. end # Scene_LearnSkill
  1398.  
  1399. #==============================================================================
  1400. #
  1401. # ▼ End of File
  1402. #
  1403. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement