Advertisement
Guest User

YEM Skill Overhaul

a guest
Jan 23rd, 2011
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 99.98 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Yanfly Engine Melody - Skill Overhaul
  4. # Last Date Updated: 2010.06.30
  5. # Level: Normal
  6. #
  7. # This script rewrites the skill scene and adds a new currency called JP, which
  8. # stands for Job Points. Job Points are earned through battle and used to
  9. # purchase new skills and passives.
  10. #
  11. # Note that this script does not rework the way skills function. This script
  12. # only reworks the way the Skill Scene appears and what it can be used for.
  13. # However, what this script does do is create a new passive item based off of
  14. # status effects. Passives are essentially status effects that stick around
  15. # once an actor has learned them.
  16. #
  17. #===============================================================================
  18. # Updates
  19. # -----------------------------------------------------------------------------
  20. # o 2010.06.30 - Battle End Bugfix.
  21. # o 2010.06.25 - Fixed JP level up bug.
  22. # o 2010.06.20 - Improved applied and canceled states in data windows.
  23. # o 2010.06.18 - Added switch enabling for both learning skills and passives.
  24. # o 2010.06.14 - Skill Equip System Compatibility.
  25. # o 2010.06.11 - Finished Script.
  26. # o 2010.06.03 - Started Script.
  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. # Skill Tags - For Skill only.
  35. # -----------------------------------------------------------------------------
  36. # <jp cost: x>
  37. # This sets the JP cost of the skill to x value. This is how much JP is needed
  38. # by the actor in the actor's current class to learn the skill.
  39. #
  40. # <jp require level: x>
  41. # This requires the actor to be at least level x before being able to acquire
  42. # the skill through JP.
  43. #
  44. # <jp require skill: x>  or  <jp require skill: x, x>
  45. # In order for the actor to learn the skill through using JP costs, the skill
  46. # x must also be learned. If multiple tags are used, then all of the skills
  47. # must be learned before the skill can be acquired through JP.
  48. #
  49. # <jp require passive: x>  or  <jp require passive: x, x>
  50. # In order for the actor to learn the passive through using JP costs, the
  51. # passive x must also be learned. If multiple tags are used, then all of the
  52. # passives must be learned before the passive can be acquired through JP.
  53. #
  54. # <jp require switch: x>  or  <jp require switches: x, x>
  55. # This requires switch x to be on in order for the skill to appear in the list.
  56. #
  57. # <custom data>
  58. # icon, string1, string2
  59. # </custom data>
  60. # This allows you to input in custom data to be displayed in the learn skill
  61. # data window. Replace "icon" with a number to depict which icon you want
  62. # shown in the data. Replace "string1" with the category you want shown in the
  63. # data. Replace "string2" with the text you want shown in the data.
  64. #
  65. # -----------------------------------------------------------------------------
  66. # State Tags - For Status Effects only.
  67. # -----------------------------------------------------------------------------
  68. # <jp gain: x%>
  69. # This state adjusts the JP gain for the actor by x%. Stackable.
  70. #
  71. # <jp cost: x>
  72. # This sets the JP cost of the passive to x value. This is how much JP is
  73. # needed by the actor in the actor's current class to learn the passive.
  74. #
  75. # <jp require level: x>
  76. # This requires the actor to be at least level x before being able to acquire
  77. # the passive through JP.
  78. #
  79. # <jp require skill: x>  or  <jp require skill: x, x>
  80. # In order for the actor to learn the passive through using JP costs, the skill
  81. # x must also be learned. If multiple tags are used, then all of the skills
  82. # must be learned before the passive can be acquired through JP.
  83. #
  84. # <jp require passive: x>  or  <jp require passive: x, x>
  85. # In order for the actor to learn the passive through using JP costs, the
  86. # passive x must also be learned. If multiple tags are used, then all of the
  87. # passives must be learned before the passive can be acquired through JP.
  88. #
  89. # <jp require switch: x>  or  <jp require switches: x, x>
  90. # This requires switch x to be on in order for the passive to appear in list.
  91. #
  92. # <custom data>
  93. # icon, string1, string2
  94. # </custom data>
  95. # This allows you to input in custom data to be displayed in the learn skill
  96. # data window. Replace "icon" with a number to depict which icon you want
  97. # shown in the data. Replace "string1" with the category you want shown in the
  98. # data. Replace "string2" with the text you want shown in the data.
  99. #
  100. # -----------------------------------------------------------------------------
  101. # Enemy Tags - For Enemies only.
  102. # -----------------------------------------------------------------------------
  103. # <jp: x>
  104. # This is the amount of JP the enemy provides the party when it is defeated.
  105. # If this tag is not used, then the default enemy JP value will be used instead.
  106. #
  107. # -----------------------------------------------------------------------------
  108. # Debug Shortcuts - Only during $TEST and $BTEST mode
  109. # -----------------------------------------------------------------------------
  110. # During testplay mode, pressing F7 or F8 at the learning skill menus will
  111. # lower or raise the current class's JP totals. Press F6 to refresh the windows
  112. # and press F5 to learn the selected skill. Hold down Shift and press F5 to
  113. # forget the selected skill.
  114. #===============================================================================
  115.  
  116. $imported = {} if $imported == nil
  117. $imported["SkillOverhaul"] = true
  118.  
  119. module YEM
  120.   module SKILL
  121.    
  122.     #===========================================================================
  123.     # Section I. Basic Settings
  124.     # --------------------------------------------------------------------------
  125.     # The following below will adjust the basic settings and vocabulary that
  126.     # will display throughout the script. Change them as you see fit.
  127.     #===========================================================================
  128.    
  129.     # These switches must be on in order for the learn skill and learn passive
  130.     # items to appear in the skill menu.
  131.     LEARN_SKILL_SWITCH   = 41
  132.     LEARN_PASSIVE_SWITCH = 42
  133.    
  134.     # This adjusts the commands used within the skill scene. The command window
  135.     # is the window that lets you switch between various skill scene options.
  136.     #
  137.     # :view_skills     View all of the available skills usable by the actor.
  138.     # :learn_skill     Teach the actor new skills using JP.
  139.     # :learn_passive   Teach the actor new passives using JP.
  140.     # :equip_skill     Requires Skill Equip System.
  141.     #
  142.     COMMANDS =[
  143.       :view_skills,   # View all of the available skills usable by the actor.
  144.       :learn_skill,   # Teach the actor new skills using JP.
  145.       :learn_passive, # Teach the actor new passives using JP.
  146.       :equip_skill,   # Requires Skill Equip System.
  147.     ] # Do not remove this.
  148.    
  149.     # The following determines the vocabulary used for the remade skill scene.
  150.     # Adjust it accordingly to set the way text is displayed.
  151.     VOCAB ={
  152.       :view_skills   => "Ability List",
  153.       :learn_skill   => "Learn Skill",
  154.       :learn_passive => "Learn Aux",
  155.     } # Do not remove this.
  156.    
  157.     #===========================================================================
  158.     # Section II. JP Ruleset
  159.     # --------------------------------------------------------------------------
  160.     # This adjusts the rules regarding the way JP appears, is earned, and spent
  161.     # in the game. Adjust it as you see fit. Each character's JP pool is class-
  162.     # based, meaning that for each class, actors will have different JP values.
  163.     # These values are stored and retained for future usage.
  164.     #===========================================================================
  165.    
  166.     # This is how JP will appear in your game both visually and verbally.
  167.     JP_TERM = "JP"   # This is the vocab used for the JP currency.
  168.     JP_ICON = 145    # This is the icon used for JP.
  169.     JP_SIZE = 16     # This is the font size used for JP costs.
  170.     HIDE_JP = false  # If true, JP is hidden in the skill scene.
  171.    
  172.     # This sets the maximum amount of JP a character can earn per class.
  173.     MAXIMUM_JP = 9999999
  174.    
  175.     # This will be the text displayed if the skill has been learned.
  176.     LEARNED_TEXT = "Learned"
  177.    
  178.     # These hashes adjust what skills each class can learn. Fill in the arrays
  179.     # with the skill ID's of learnable skills. Class 0's hash allows all classes
  180.     # to be able to learn from it. Do not delete class 0.
  181.     CLASS_SKILLS ={
  182.     # ID => [Skill ID's],
  183.        0 => [],
  184.        1 => [1..20, 71, 72, 79, 83],
  185.        2 => [21..45, 73, 74, 80],
  186.        3 => [45..70, 75, 76, 77, 81],
  187.        4 => [241..280],
  188.     } # Do not remove this.
  189.    
  190.     # These hashes adjust what passives each class can learn. Fill in the arrays
  191.     # with the skill ID's of status effects. Class 0's hash allows all classes
  192.     # to be able to learn from it. Do not delete class 0.
  193.     CLASS_PASSIVES ={
  194.     # ID => [State ID's],
  195.        0 => [],
  196.        1 => [],
  197.        2 => [],
  198.        3 => [],
  199.        4 => [],
  200.     } # Do not remove this.
  201.    
  202.     # This is the default JP cost of each of the skills without a <jp cost: x>
  203.     # tag placed in the skill's notebox.
  204.     DEFAULT_JP_SKILL_COST   = 100
  205.     DEFAULT_JP_PASSIVE_COST = 1000
  206.    
  207.     # Setting the following to true will have the game automatically create
  208.     # JP costs based on what the game deems to be reasonable for each skill.
  209.     AUTO_CREATE_JP_SKILL_COSTS = true
  210.     JP_SKILL_COSTS ={
  211.     # Skill Property => Factor,
  212.       :base_damage   => 0.2000, # Additional cost per base damage point.
  213.       :variance      => 0.5000, # Additional cost per amount of variance.
  214.       :atk_f         => 0.5000, # Additional cost per ATK_F multiplier.
  215.       :def_f         => 0.2500, # Additional cost per DEF_F multiplier.
  216.       :spi_f         => 0.3333, # Additional cost per SPI_F multiplier.
  217.       :res_f         => 0.3000, # Additional cost per RES_F multiplier.
  218.       :dex_f         => 0.2750, # Additional cost per DEX_F multiplier.
  219.       :agi_f         => 0.2000, # Additional cost per AGI_F multiplier.
  220.       :physical      => 50.000, # Additional cost if a physical attack.
  221.       :damage_to_mp  => 50.000, # Additional cost if deals damage to MP.
  222.       :absorb_dmg    => 100.00, # Additional cost if it absorbs damage.
  223.       :ignore_def    => 100.00, # Additional cost if it ignores defense.
  224.       :element       => 25.000, # Additional cost per element.
  225.       :status_effect => 20.000, # Additional cost per status effect.
  226.       :multi_target  => 2.5000, # Multiply by this amount if multi-target.
  227.     } # Do not remove this.
  228.    
  229.     #===========================================================================
  230.     # Section III. Learn Data Window
  231.     # --------------------------------------------------------------------------
  232.     # This section adjusts the properties for the learn skill portion's data
  233.     # window that appears in the lower right corner of the screen. This window
  234.     # displays information regarding JP costs and various skill properties.
  235.     #===========================================================================
  236.    
  237.     # This hash contains all of the information and data regarding the learn
  238.     # data window. Adjust it accordingly.
  239.     LEARN_DATA ={
  240.       :fontsize   => 16,
  241.       :require    => "Requirements",
  242.       :properties => "Properties",
  243.       :jp_cost    => "JP Cost",
  244.       :skill_cost => "Skill Cost",
  245.       :dmg_icon   => 119,
  246.       :heal_icon  => 128,
  247.       :base_dmg   => "Base Damage",
  248.       :base_heal  => "Base Healing",
  249.       :multiplier => "%s Multiplier",
  250.       :element    => "Element",
  251.       :add_state  => "Applies",
  252.       :rem_state  => "Cancels",
  253.       :stat_rate  => "%s Rate",
  254.       :stat_set   => "%s Change",
  255.     } # Do not remove this.
  256.    
  257.     # This array contains all of the elements you want displayed and in which
  258.     # order to display them in. You can display them as individual integers or
  259.     # as number ranges.
  260.     SHOWN_ELEMENTS = [3, 4, 5, 6..10]
  261.    
  262.     # Since elements do not have icons innately, use the following hash below
  263.     # adjust and apply icons to them.
  264.     ELEMENT_ICONS ={
  265.       3 => 104,  # Fire element.
  266.       4 => 105,  # Ice element.
  267.       5 => 106,  # Volt element.
  268.       6 => 108,  # Earth element.
  269.       7 => 107,  # Water element.
  270.       8 => 109,  # Air element.
  271.       9 => 110,  # Light element.
  272.      10 => 111,  # Dark element.
  273.     } # Do not remove this.
  274.    
  275.     #===========================================================================
  276.     # Section IV. JP Earning Settings
  277.     # --------------------------------------------------------------------------
  278.     # JP can be earned through a number of ways. They can be earned through
  279.     # regular attacks, guarding, using skills, using items, or simply leveling
  280.     # up an actor.
  281.     #===========================================================================
  282.    
  283.     # This hash adjusts the various cases of when actors earn JP and by how
  284.     # much. JP earned can come from a set factor, a random factor, or both.
  285.     EARN_JP ={
  286.       :attack_set  => 10,  # Set JP earned from regular attacks.
  287.       :attack_rand => 5,   # Random JP earned from regular attacks.
  288.       :guard_set   => 8,   # Set JP earned from guarding.
  289.       :guard_rand  => 4,   # Random JP earned from regular guarding.
  290.       :skill_set   => 12,  # Set JP earned from using skills.
  291.       :skill_rand  => 6,   # Random JP earned from using skills.
  292.       :item_set    => 6,   # Set JP earned from using items.
  293.       :item_rand   => 3,   # Random JP earned from using items.
  294.       :level_set   => 500, # Set JP earned from leveling up.
  295.       :level_rand  => 200, # Random JP earned from leveling up.
  296.       :enemy_set   => 100, # The default JP an enemy leaves when killed.
  297.     } # Do not remove this.
  298.    
  299.   end # SKILL
  300. end # YEM
  301.  
  302. #===============================================================================
  303. # Editting anything past this point may potentially result in causing computer
  304. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  305. # Therefore, edit at your own risk.
  306. #===============================================================================
  307.  
  308. module YEM
  309.   module REGEXP
  310.   module SKILL
  311.    
  312.     JP_COST  = /<(?:JP_COST|jp cost):[ ]*(\d+)>/i
  313.     JP_REQ   = /<(?:JP_REQUIRE|jp require)[ ](.*):[ ](\d+(?:\s*,\s*\d+)*)>/i
  314.    
  315.     CUSTOM_DATA1 = /<(?:CUSTOM_DATA|custom data)>/i
  316.     CUSTOM_DATA2 = /<\/(?:CUSTOM_DATA|custom data)>/i
  317.    
  318.   end # SKILL
  319.   module STATE
  320.    
  321.     JP_COST  = /<(?:JP_COST|jp cost):[ ]*(\d+)>/i
  322.     JP_REQ   = /<(?:JP_REQUIRE|jp require)[ ](.*):[ ](\d+(?:\s*,\s*\d+)*)>/i
  323.    
  324.     JP_RATE  = /<(?:JP_GAIN|jp gain):[ ]*(\d+)([%])>/i
  325.    
  326.     PASSIVE_DESCRIPTION1 = /<(?:PASSIVE_DESCRIPTION|passive description)>/i
  327.     PASSIVE_DESCRIPTION2 = /<\/(?:PASSIVE_DESCRIPTION|passive description)>/i
  328.     CUSTOM_DATA1 = /<(?:CUSTOM_DATA|custom data)>/i
  329.     CUSTOM_DATA2 = /<\/(?:CUSTOM_DATA|custom data)>/i
  330.    
  331.   end # STATE
  332.   module ENEMY
  333.    
  334.     JP = /<(?:JP|jp):[ ]*(\d+)>/i
  335.    
  336.   end # ENEMY
  337.   end # REGEXP
  338.   module SKILL
  339.     module_function
  340.     #--------------------------------------------------------------------------
  341.     # convert_integer_array
  342.     #--------------------------------------------------------------------------
  343.     def convert_integer_array(array)
  344.       result = []
  345.       array.each { |i|
  346.         case i
  347.         when Range; result |= i.to_a
  348.         when Integer; result |= [i]
  349.         end }
  350.       return result
  351.     end
  352.    
  353.     #--------------------------------------------------------------------------
  354.     # full_convert_hash
  355.     #--------------------------------------------------------------------------
  356.     def full_convert_hash(hash)
  357.       result = {}
  358.       hash.each { |key|
  359.         result[key[0]] = convert_integer_array(key[1]) }
  360.       return result
  361.     end
  362.  
  363.     #--------------------------------------------------------------------------
  364.     # converted_contants
  365.     #--------------------------------------------------------------------------
  366.     CLASS_SKILLS = full_convert_hash(CLASS_SKILLS)
  367.     CLASS_PASSIVES = full_convert_hash(CLASS_PASSIVES)
  368.     SHOWN_ELEMENTS = convert_integer_array(SHOWN_ELEMENTS)
  369.   end # SKILL
  370. end # YEM
  371.  
  372. #===============================================================================
  373. # Vocab
  374. #===============================================================================
  375.  
  376. module Vocab
  377.  
  378.   #--------------------------------------------------------------------------
  379.   # self.jp
  380.   #--------------------------------------------------------------------------
  381.   def self.jp; return YEM::SKILL::JP_TERM; end
  382.  
  383. end # Vocab
  384.  
  385. #===============================================================================
  386. # module Icon
  387. #===============================================================================
  388.  
  389. module Icon
  390.  
  391.   #--------------------------------------------------------------------------
  392.   # self.element
  393.   #--------------------------------------------------------------------------
  394.   def self.element(element_id)
  395.     icon = YEM::SKILL::ELEMENT_ICONS[element_id]
  396.     return (icon == nil) ? 0 : icon
  397.   end
  398.  
  399.   #--------------------------------------------------------------------------
  400.   # self.jp
  401.   #--------------------------------------------------------------------------
  402.   def self.jp; return YEM::SKILL::JP_ICON; end
  403.    
  404.   #--------------------------------------------------------------------------
  405.   # self.level
  406.   #--------------------------------------------------------------------------
  407.   def self.level; return YEM::SKILL::JP_ICON; end
  408.  
  409.   #--------------------------------------------------------------------------
  410.   # self.base_damage
  411.   #--------------------------------------------------------------------------
  412.   def self.base_damage; return YEM::SKILL::LEARN_DATA[:dmg_icon]; end
  413.  
  414.   #--------------------------------------------------------------------------
  415.   # self.base_healing
  416.   #--------------------------------------------------------------------------
  417.   def self.base_healing; return YEM::SKILL::LEARN_DATA[:heal_icon]; end
  418.  
  419. end # Icon
  420.  
  421. #===============================================================================
  422. # RPG::Skill
  423. #===============================================================================
  424.  
  425. class RPG::Skill < RPG::UsableItem
  426.  
  427.   #--------------------------------------------------------------------------
  428.   # public instance variables
  429.   #--------------------------------------------------------------------------
  430.   attr_accessor :custom_data
  431.   attr_accessor :jp_cost
  432.   attr_accessor :jp_require
  433.  
  434.   #--------------------------------------------------------------------------
  435.   # common cache: yem_cache_skill_so
  436.   #--------------------------------------------------------------------------
  437.   def yem_cache_skill_so
  438.     return if @cached_skill_so; @cached_skill_so = true
  439.     create_default_jp_cost
  440.     @custom_data = []
  441.     enable_custom_data = false
  442.     @jp_require = {} if @jp_require == nil
  443.     #---
  444.     self.note.split(/[\r\n]+/).each { |line|
  445.       case line
  446.       #---
  447.       when YEM::REGEXP::SKILL::JP_COST
  448.         @jp_cost = $1.to_i
  449.       #---
  450.       when YEM::REGEXP::SKILL::JP_REQ
  451.         case $1.upcase
  452.         when "SKILL", "SKILLS"
  453.           type = :skills
  454.         when "PASSIVE", "PASSIVES"
  455.           type = :passives
  456.         when "LEVEL"
  457.           type = :level
  458.         when "SWITCH", "SWITCHES"
  459.           type = :switches
  460.         else; next
  461.         end
  462.         @jp_require[type] = [] if @jp_require[type] == nil
  463.         $2.scan(/\d+/).each { |num|
  464.         @jp_require[type].push(num.to_i) if num.to_i > 0 }
  465.       #---
  466.       when YEM::REGEXP::SKILL::CUSTOM_DATA1
  467.         enable_custom_data = true
  468.       when YEM::REGEXP::SKILL::CUSTOM_DATA2
  469.         enable_custom_data = false
  470.       when /(\d+),[ ](.*),[ ](.*)/i
  471.         next unless enable_custom_data
  472.         array = [$1.to_i, $2.to_s, $3.to_s]
  473.         @custom_data.push(array)
  474.       #---
  475.       end
  476.     } # self.note.split
  477.   end # yem_cache_skill_so
  478.  
  479.   #--------------------------------------------------------------------------
  480.   # new method: create_default_jp_cost
  481.   #--------------------------------------------------------------------------
  482.   def create_default_jp_cost
  483.     @jp_cost = YEM::SKILL::DEFAULT_JP_SKILL_COST
  484.     return unless YEM::SKILL::AUTO_CREATE_JP_SKILL_COSTS
  485.     if $imported["BattleEngineMelody"]
  486.       yem_cache_baseitem_bem
  487.       yem_cache_usableitem_bem
  488.     end
  489.     hash = YEM::SKILL::JP_SKILL_COSTS
  490.     @jp_cost += (@base_damage * hash[:base_damage]).abs
  491.     @jp_cost += @variance * hash[:variance]
  492.     @jp_cost += @atk_f * hash[:atk_f]
  493.     @jp_cost += @spi_f * hash[:spi_f]
  494.     if $imported["BattleEngineMelody"]
  495.       @jp_cost += @def_f * hash[:def_f]
  496.       @jp_cost += @agi_f * hash[:agi_f]
  497.       @jp_cost += @dex_f * hash[:dex_f] if $imported["DEX Stat"]
  498.       @jp_cost += @res_f * hash[:res_f] if $imported["DEX Stat"]
  499.     end
  500.     @jp_cost += hash[:physical] if @physical_attack
  501.     @jp_cost += hash[:damage_to_mp] if @damage_to_mp
  502.     @jp_cost += hash[:absorb_dmg] if @absorb_damage
  503.     @jp_cost += hash[:ignore_def] if @ignore_defense
  504.     @jp_cost += @element_set.size * hash[:element]
  505.     @jp_cost += @plus_state_set.size * hash[:status_effect]
  506.     @jp_cost += @minus_state_set.size * hash[:status_effect]
  507.     @jp_cost *= hash[:multi_target] if [2, 3, 5, 6, 8, 10].include?(@scope)
  508.     @jp_cost = Integer(@jp_cost)
  509.   end
  510.  
  511. end # RPG::Skill
  512.  
  513. #===============================================================================
  514. # RPG::State
  515. #===============================================================================
  516.  
  517. class RPG::State
  518.  
  519.   #--------------------------------------------------------------------------
  520.   # public instance variables
  521.   #--------------------------------------------------------------------------
  522.   attr_accessor :custom_data
  523.   attr_accessor :jp_cost
  524.   attr_accessor :jp_rate
  525.   attr_accessor :jp_require
  526.   attr_accessor :passive_description
  527.  
  528.   #--------------------------------------------------------------------------
  529.   # common cache: yem_cache_state_so
  530.   #--------------------------------------------------------------------------
  531.   def yem_cache_state_so
  532.     return if @cached_state_so; @cached_state_so = true
  533.     @jp_cost = YEM::SKILL::DEFAULT_JP_PASSIVE_COST
  534.     @jp_rate = 100
  535.     @custom_data = []
  536.     @jp_require = {} if @jp_require == nil
  537.     @passive_description = ""
  538.     enable_custom_data = false
  539.     enable_passive_description = false
  540.     #---
  541.     self.note.split(/[\r\n]+/).each { |line|
  542.       case line
  543.       #---
  544.       when YEM::REGEXP::STATE::JP_COST
  545.         @jp_cost = $1.to_i
  546.       when YEM::REGEXP::STATE::JP_RATE
  547.         @jp_rate = $1.to_i
  548.       #---
  549.       when YEM::REGEXP::STATE::JP_REQ
  550.         case $1.upcase
  551.         when "SKILL", "SKILLS"
  552.           type = :skills
  553.         when "PASSIVE", "PASSIVES"
  554.           type = :passives
  555.         when "LEVEL"
  556.           type = :level
  557.         when "SWITCH", "SWITCHES"
  558.           type = :switches
  559.         else; next
  560.         end
  561.         @jp_require[type] = [] if @jp_require[type] == nil
  562.         $2.scan(/\d+/).each { |num|
  563.         @jp_require[type].push(num.to_i) if num.to_i > 0 }
  564.       #---
  565.       when YEM::REGEXP::STATE::CUSTOM_DATA1
  566.         enable_custom_data = true
  567.       when YEM::REGEXP::STATE::CUSTOM_DATA2
  568.         enable_custom_data = false
  569.       when /(.*),[ ](.*),[ ](.*)/i
  570.         next unless enable_custom_data
  571.         array = [$1.to_i, $2.to_s, $3.to_s]
  572.         @custom_data.push(array)
  573.       #---
  574.       #---
  575.       when YEM::REGEXP::STATE::PASSIVE_DESCRIPTION1
  576.         enable_passive_description = true
  577.       when YEM::REGEXP::STATE::PASSIVE_DESCRIPTION2
  578.         enable_passive_description = false
  579.       else
  580.         @passive_description += line.to_s if enable_passive_description
  581.       end
  582.     } # self.note.split
  583.   end # yem_cache_state_so
  584.  
  585. end # RPG::State
  586.  
  587. #===============================================================================
  588. # RPG::Enemy
  589. #===============================================================================
  590.  
  591. class RPG::Enemy
  592.  
  593.   #--------------------------------------------------------------------------
  594.   # public instance variables
  595.   #--------------------------------------------------------------------------
  596.   attr_accessor :jp
  597.  
  598.   #--------------------------------------------------------------------------
  599.   # common cache: yem_cache_enemy_so
  600.   #--------------------------------------------------------------------------
  601.   def yem_cache_enemy_so
  602.     return if @cached_enemy_so; @cached_enemy_so = true
  603.     @jp = YEM::SKILL::EARN_JP[:enemy_set]
  604.     #---
  605.     self.note.split(/[\r\n]+/).each { |line|
  606.       case line
  607.       #---
  608.       when YEM::REGEXP::ENEMY::JP
  609.         @jp = $1.to_i
  610.       end
  611.     } # self.note.split
  612.   end # yem_cache_enemy_so
  613.  
  614. end # RPG::Enemy
  615.  
  616. #===============================================================================
  617. # Scene_Title
  618. #===============================================================================
  619.  
  620. class Scene_Title < Scene_Base
  621.  
  622.   #--------------------------------------------------------------------------
  623.   # alias method: load_bt_database
  624.   #--------------------------------------------------------------------------
  625.   alias load_bt_database_so load_bt_database unless $@
  626.   def load_bt_database
  627.     load_bt_database_so
  628.     load_so_cache
  629.   end
  630.  
  631.   #--------------------------------------------------------------------------
  632.   # alias method: load_database
  633.   #--------------------------------------------------------------------------
  634.   alias load_database_so load_database unless $@
  635.   def load_database
  636.     load_database_so
  637.     load_so_cache
  638.   end
  639.  
  640.   #--------------------------------------------------------------------------
  641.   # new method: load_so_cache
  642.   #--------------------------------------------------------------------------
  643.   def load_so_cache
  644.     groups = [$data_skills, $data_states, $data_enemies]
  645.     for group in groups
  646.       for obj in group
  647.         next if obj == nil
  648.         obj.yem_cache_skill_so if obj.is_a?(RPG::Skill)
  649.         obj.yem_cache_state_so if obj.is_a?(RPG::State)
  650.         obj.yem_cache_enemy_so if obj.is_a?(RPG::Enemy)
  651.       end
  652.     end
  653.   end
  654.  
  655. end # Scene_Title
  656.  
  657. #===============================================================================
  658. # Game_Actor
  659. #===============================================================================
  660.  
  661. class Game_Battler
  662.  
  663.   #--------------------------------------------------------------------------
  664.   # alias method: states
  665.   #--------------------------------------------------------------------------
  666.   alias states_so states unless $@
  667.   def states
  668.     result = states_so
  669.     result |= self.passives if self.actor?
  670.     return result
  671.   end
  672.  
  673. end # Game_Battler
  674.  
  675. #===============================================================================
  676. # Game_Actor
  677. #===============================================================================
  678.  
  679. class Game_Actor < Game_Battler
  680.  
  681.   #--------------------------------------------------------------------------
  682.   # alias method: level_up
  683.   #--------------------------------------------------------------------------
  684.   alias level_up_so level_up unless $@
  685.   def level_up
  686.     level_up_so
  687.     jp = YEM::SKILL::EARN_JP[:level_set]
  688.     random = YEM::SKILL::EARN_JP[:level_rand]
  689.     jp += rand(random) if random > 0
  690.     earn_jp(jp)
  691.   end
  692.  
  693.   #--------------------------------------------------------------------------
  694.   # new method: jp
  695.   #--------------------------------------------------------------------------
  696.   def jp(cl_id = 0)
  697.     @jp = {} if @jp == nil
  698.     cl_id = @class_id if cl_id <= 0
  699.     @jp[cl_id] = 0 if @jp[cl_id] == nil
  700.     return @jp[cl_id]
  701.   end
  702.  
  703.   #--------------------------------------------------------------------------
  704.   # new method: earn_jp
  705.   #--------------------------------------------------------------------------
  706.   def earn_jp(amount = 0)
  707.     @jp = {} if @jp == nil
  708.     @jp[@class_id] = 0 if @jp[@class_id] == nil
  709.     for state in states
  710.       cases = $imported["BattleEngineMelody"] ? stack(state) : 1
  711.       cases.times do amount *= state.jp_rate / 100.0 end
  712.     end
  713.     change_jp(@class_id, Integer(amount))
  714.   end
  715.  
  716.   #--------------------------------------------------------------------------
  717.   # new method: lose_jp
  718.   #--------------------------------------------------------------------------
  719.   def lose_jp(amount = 0)
  720.     @jp = {} if @jp == nil
  721.     @jp[@class_id] = 0 if @jp[@class_id] == nil
  722.     change_jp(@class_id, -amount)
  723.   end
  724.  
  725.   #--------------------------------------------------------------------------
  726.   # new method: change_jp
  727.   #--------------------------------------------------------------------------
  728.   def change_jp(cl_id, amount)
  729.     @jp = {} if @jp == nil
  730.     @jp[cl_id] = 0 if @jp[cl_id] == nil
  731.     @jp[cl_id] = [[@jp[cl_id] + amount, 0].max, YEM::SKILL::MAXIMUM_JP].min
  732.   end
  733.  
  734.   #--------------------------------------------------------------------------
  735.   # new method: passives
  736.   #--------------------------------------------------------------------------
  737.   def passives
  738.     result = []
  739.     @learned_passives = [] if @learned_passives == nil
  740.     for state_id in @learned_passives
  741.       state = $data_states[state_id]
  742.       next if state == nil
  743.       result.push(state)
  744.     end
  745.     return result
  746.   end
  747.  
  748.   #--------------------------------------------------------------------------
  749.   # new method: passive_learn?
  750.   #--------------------------------------------------------------------------
  751.   def passive_learn?(state)
  752.     state = state.id if state.is_a?(RPG::State)
  753.     @learned_passives = [] if @learned_passives == nil
  754.     return @learned_passives.include?(state)
  755.   end
  756.  
  757.   #--------------------------------------------------------------------------
  758.   # new method: learn_passive
  759.   #--------------------------------------------------------------------------
  760.   def learn_passive(state_id)
  761.     return if passive_learn?(state_id)
  762.     @learned_passives = [] if @learned_passives == nil
  763.     @learned_passives.push(state_id)
  764.     @learned_passives.sort!
  765.   end
  766.  
  767.   #--------------------------------------------------------------------------
  768.   # new method: forget_passive
  769.   #--------------------------------------------------------------------------
  770.   def forget_passive(state_id)
  771.     @learned_passives = [] if @learned_passives == nil
  772.     @learned_passives.delete(state_id)
  773.   end
  774.  
  775. end # Game_Actor
  776.  
  777. #===============================================================================
  778. # Game_Party
  779. #===============================================================================
  780.  
  781. class Game_Party < Game_Unit
  782.  
  783.   #--------------------------------------------------------------------------
  784.   # alias method: setup_starting_members
  785.   #--------------------------------------------------------------------------
  786.   alias setup_starting_members_so setup_starting_members unless $@
  787.   def setup_starting_members
  788.     setup_starting_members_so
  789.     $game_switches[YEM::SKILL::LEARN_SKILL_SWITCH] = true
  790.     $game_switches[YEM::SKILL::LEARN_PASSIVE_SWITCH] = true
  791.   end
  792.  
  793. end # Game_Party
  794.  
  795. #===============================================================================
  796. # Game_Troop
  797. #===============================================================================
  798.  
  799. class Game_Troop < Game_Unit
  800.  
  801.   #--------------------------------------------------------------------------
  802.   # distribute_jp
  803.   #--------------------------------------------------------------------------
  804.   def distribute_jp
  805.     jp = 0
  806.     for member in dead_members
  807.       jp += member.enemy.jp
  808.     end
  809.     for member in $game_party.members
  810.       member.earn_jp(jp)
  811.     end
  812.   end
  813.  
  814. end # Game_Troop
  815.  
  816. #===============================================================================
  817. # Window_Command_Centered
  818. #===============================================================================
  819.  
  820. class Window_Command_Centered < Window_Command
  821.  
  822.   #--------------------------------------------------------------------------
  823.   # draw_item
  824.   #--------------------------------------------------------------------------
  825.   def draw_item(index, enabled = true)
  826.     rect = item_rect(index)
  827.     rect.x += 4
  828.     rect.width -= 8
  829.     self.contents.clear_rect(rect)
  830.     self.contents.font.color = normal_color
  831.     self.contents.font.color.alpha = enabled ? 255 : 128
  832.     self.contents.draw_text(rect, @commands[index], 1)
  833.   end
  834.  
  835. end # Window_Command_Centered
  836.  
  837. #===============================================================================
  838. # Window_Actor_Skill_Status
  839. #===============================================================================
  840.  
  841. class Window_Actor_Skill_Status < Window_Base
  842.  
  843.   #--------------------------------------------------------------------------
  844.   # initialize
  845.   #--------------------------------------------------------------------------
  846.   def initialize(actor)
  847.     super(160, 0, Graphics.width - 160, 128)
  848.     @actor = actor
  849.     @class_id = actor.class_id
  850.     refresh
  851.   end
  852.  
  853.   #--------------------------------------------------------------------------
  854.   # actor=
  855.   #--------------------------------------------------------------------------
  856.   def actor=(new_actor)
  857.     @actor = new_actor
  858.     @class_id = new_actor.class_id
  859.     refresh
  860.   end
  861.  
  862.   #--------------------------------------------------------------------------
  863.   # class_id=
  864.   #--------------------------------------------------------------------------
  865.   def class_id=(new_class)
  866.     @class_id = new_class
  867.     refresh
  868.   end
  869.  
  870.   #--------------------------------------------------------------------------
  871.   # refresh
  872.   #--------------------------------------------------------------------------
  873.   def refresh
  874.     self.contents.clear
  875.     draw_actor_face(@actor, 0, 0)
  876.     dx = 108; dy = 0
  877.     draw_actor_name(@actor, dx, dy)
  878.     draw_actor_class(@actor, dx + 120, dy)
  879.     draw_actor_level(@actor, dx, dy + WLH * 1)
  880.     draw_actor_state(@actor, dx, dy + WLH * 2)
  881.     draw_actor_hp(@actor, dx + 120, dy + WLH * 1)
  882.     draw_actor_mp(@actor, dx + 120, dy + WLH * 2)
  883.     draw_actor_jp(@actor, @class_id, dx + 120, dy + WLH * 3)
  884.   end
  885.  
  886.   #--------------------------------------------------------------------------
  887.   # draw_actor_jp
  888.   #--------------------------------------------------------------------------
  889.   def draw_actor_jp(actor, class_id, dx, dy)
  890.     return if YEM::SKILL::HIDE_JP
  891.     self.contents.font.color = system_color
  892.     self.contents.draw_text(dx, dy, 120, WLH, Vocab.jp, 0)
  893.     draw_icon(Icon.jp, dx+96, dy)
  894.     jp = actor.jp(class_id)
  895.     self.contents.font.color = normal_color
  896.     self.contents.draw_text(dx, dy, 96, WLH, jp, 2)
  897.   end
  898.  
  899. end # Window_Actor_Skill_Status
  900.  
  901. #===============================================================================
  902. # Window_Skill
  903. #===============================================================================
  904.  
  905. class Window_Skill < Window_Selectable
  906.  
  907.   #--------------------------------------------------------------------------
  908.   # new method: actor=
  909.   #--------------------------------------------------------------------------
  910.   def actor=(new_actor)
  911.     @actor = new_actor
  912.     refresh
  913.     self.oy = 0
  914.     self.index = 0
  915.   end
  916.  
  917. end # Window_Skill
  918.  
  919. #===============================================================================
  920. # Window_LearnSkill
  921. #===============================================================================
  922.  
  923. class Window_LearnSkill < Window_Selectable
  924.  
  925.   #--------------------------------------------------------------------------
  926.   # initialize
  927.   #--------------------------------------------------------------------------
  928.   def initialize(actor, help_window)
  929.     @actor = actor
  930.     @class_id = @actor.class_id
  931.     @help_window = help_window
  932.     dy = @help_window.y + @help_window.height
  933.     super(0, dy, Graphics.width - 240, Graphics.height - dy)
  934.     refresh
  935.     self.active = false
  936.     self.index = 0
  937.   end
  938.  
  939.   #--------------------------------------------------------------------------
  940.   # skill
  941.   #--------------------------------------------------------------------------
  942.   def skill; return @data[self.index]; end
  943.  
  944.   #--------------------------------------------------------------------------
  945.   # actor=
  946.   #--------------------------------------------------------------------------
  947.   def actor=(new_actor)
  948.     @actor = new_actor
  949.     @class_id = new_actor.class_id
  950.     refresh
  951.     self.oy = 0
  952.     self.index = 0
  953.   end
  954.  
  955.   #--------------------------------------------------------------------------
  956.   # class_id=
  957.   #--------------------------------------------------------------------------
  958.   def class_id=(new_class)
  959.     @class_id = new_class
  960.     refresh
  961.     self.oy = 0
  962.     self.index = 0
  963.   end
  964.  
  965.   #--------------------------------------------------------------------------
  966.   # refresh
  967.   #--------------------------------------------------------------------------
  968.   def refresh
  969.     if @cache_class != @class_id
  970.       @cache_class = @class_id
  971.       array = YEM::SKILL::CLASS_SKILLS[0]
  972.       if YEM::SKILL::CLASS_SKILLS.include?(@class_id)
  973.         array |= YEM::SKILL::CLASS_SKILLS[@class_id]
  974.         array.sort!
  975.       end
  976.       @data = []
  977.       for skill_id in array
  978.         skill = $data_skills[skill_id]
  979.         next unless include?(skill)
  980.         @data.push(skill)
  981.       end
  982.     end
  983.     @item_max = @data.size
  984.     self.index = [[self.index, @item_max-1].min, 0].max
  985.     create_contents
  986.     for i in 0...@item_max; draw_item(i); end
  987.   end
  988.  
  989.   #--------------------------------------------------------------------------
  990.   # include?
  991.   #--------------------------------------------------------------------------
  992.   def include?(skill)
  993.     return false if skill == nil
  994.     return false if skill.name == ""
  995.     if skill.jp_require[:switches] != nil
  996.       for switch_id in skill.jp_require[:switches]
  997.         return false unless $game_switches[switch_id]
  998.       end
  999.     end
  1000.     return true
  1001.   end
  1002.  
  1003.   #--------------------------------------------------------------------------
  1004.   # draw_item
  1005.   #--------------------------------------------------------------------------
  1006.   def draw_item(index)
  1007.     rect = item_rect(index)
  1008.     self.contents.clear_rect(rect)
  1009.     skill = @data[index]
  1010.     return if skill == nil
  1011.     enabled = enabled?(skill)
  1012.     draw_obj_name(skill, rect.clone, enabled)
  1013.     draw_obj_cost(skill, rect.clone, enabled)
  1014.   end
  1015.  
  1016.   #--------------------------------------------------------------------------
  1017.   # enabled?
  1018.   #--------------------------------------------------------------------------
  1019.   def enabled?(skill)
  1020.     return false if skill == nil
  1021.     return true if @actor.skill_learn?(skill)
  1022.     #---
  1023.     if skill.jp_require[:level] != nil
  1024.       return false if skill.jp_require[:level][0] > @actor.level
  1025.     end
  1026.     #---
  1027.     if skill.jp_require[:skills] != nil
  1028.       for skill_id in skill.jp_require[:skills]
  1029.         next if $data_skills[skill_id] == nil
  1030.         return false unless @actor.skill_learn?($data_skills[skill_id])
  1031.       end
  1032.     end
  1033.     #---
  1034.     if skill.jp_require[:passives] != nil
  1035.       for state_id in skill.jp_require[:passives]
  1036.         next if $data_states[state_id] == nil
  1037.         return false unless @actor.passive_learn?($data_states[state_id])
  1038.       end
  1039.     end
  1040.     #---
  1041.     return @actor.jp(@class_id) >= skill.jp_cost
  1042.   end
  1043.  
  1044.   #--------------------------------------------------------------------------
  1045.   # new method: draw_obj_name
  1046.   #--------------------------------------------------------------------------
  1047.   def draw_obj_name(obj, rect, enabled)
  1048.     draw_icon(obj.icon_index, rect.x, rect.y, enabled)
  1049.     self.contents.font.size = Font.default_size
  1050.     self.contents.font.color = normal_color
  1051.     self.contents.font.color.alpha = enabled ? 255 : 128
  1052.     rect.width -= 96
  1053.     self.contents.draw_text(rect.x+24, rect.y, rect.width, WLH, obj.name, 0)
  1054.   end
  1055.  
  1056.   #--------------------------------------------------------------------------
  1057.   # new method: draw_obj_cost
  1058.   #--------------------------------------------------------------------------
  1059.   def draw_obj_cost(obj, rect, enabled)
  1060.     if @actor.skill_learn?(obj)
  1061.       self.contents.font.size = YEM::SKILL::JP_SIZE
  1062.       self.contents.font.color = normal_color
  1063.       self.contents.font.color.alpha = enabled ? 255 : 128
  1064.       text = YEM::SKILL::LEARNED_TEXT
  1065.       self.contents.draw_text(rect.x, rect.y, rect.width-4, WLH, text, 2)
  1066.     else
  1067.       draw_icon(Icon.jp, rect.x + rect.width - 24, rect.y, enabled)
  1068.       self.contents.font.size = YEM::SKILL::JP_SIZE
  1069.       self.contents.font.color = normal_color
  1070.       self.contents.font.color.alpha = enabled ? 255 : 128
  1071.       cost = obj.jp_cost
  1072.       self.contents.draw_text(rect.x, rect.y, rect.width-24, WLH, cost, 2)
  1073.     end
  1074.   end
  1075.  
  1076.   #--------------------------------------------------------------------------
  1077.   # update_help
  1078.   #--------------------------------------------------------------------------
  1079.   def update_help
  1080.     @help_window.set_text(skill == nil ? "" : skill.description)
  1081.   end
  1082.  
  1083. end # Window_LearnSkill
  1084.  
  1085. #===============================================================================
  1086. # Window_LearnData
  1087. #===============================================================================
  1088.  
  1089. class Window_LearnData < Window_Base
  1090.  
  1091.   #--------------------------------------------------------------------------
  1092.   # initialize
  1093.   #--------------------------------------------------------------------------
  1094.   def initialize(actor, main_window)
  1095.     @actor = actor
  1096.     @class_id = @actor.class_id
  1097.     @main_window = main_window
  1098.     super(@main_window.width, @main_window.y, 240, @main_window.height)
  1099.     refresh
  1100.   end
  1101.  
  1102.   #--------------------------------------------------------------------------
  1103.   # actor=
  1104.   #--------------------------------------------------------------------------
  1105.   def actor=(new_actor)
  1106.     @actor = new_actor
  1107.     @class_id = @actor.class_id
  1108.     refresh
  1109.   end
  1110.  
  1111.   #--------------------------------------------------------------------------
  1112.   # class_id=
  1113.   #--------------------------------------------------------------------------
  1114.   def class_id=(new_class)
  1115.     @class_id = new_class
  1116.     refresh
  1117.   end
  1118.  
  1119.   #--------------------------------------------------------------------------
  1120.   # update
  1121.   #--------------------------------------------------------------------------
  1122.   def update
  1123.     super
  1124.     refresh if @skill != @main_window.skill and !@anti_update
  1125.   end
  1126.  
  1127.   #--------------------------------------------------------------------------
  1128.   # refresh
  1129.   #--------------------------------------------------------------------------
  1130.   def refresh
  1131.     self.contents.clear
  1132.     @skill = @main_window.skill
  1133.     return if @skill == nil
  1134.     draw_obj_name
  1135.     dy = WLH
  1136.     dy = draw_requirements(dy)
  1137.     dy = draw_properties(dy)
  1138.   end
  1139.  
  1140.   #--------------------------------------------------------------------------
  1141.   # draw_obj_name
  1142.   #--------------------------------------------------------------------------
  1143.   def draw_obj_name
  1144.     draw_icon(@skill.icon_index, 0, 0)
  1145.     self.contents.font.size = Font.default_size
  1146.     self.contents.font.color = normal_color
  1147.     self.contents.draw_text(24, 0, contents.width-28, WLH, @skill.name)
  1148.   end
  1149.  
  1150.   #--------------------------------------------------------------------------
  1151.   # draw_properties
  1152.   #--------------------------------------------------------------------------
  1153.   def draw_requirements(dy)
  1154.     dy = draw_requirement_title(dy)
  1155.     dy = draw_jp_cost(dy)
  1156.     dy = draw_level_req(dy)
  1157.     dy = draw_skill_req(dy)
  1158.     dy = draw_passive_req(dy)
  1159.     return dy
  1160.   end
  1161.  
  1162.   #--------------------------------------------------------------------------
  1163.   # draw_requirement_title
  1164.   #--------------------------------------------------------------------------
  1165.   def draw_requirement_title(dy)
  1166.     return dy if dy + WLH > contents.height
  1167.     return dy if @actor.skill_learn?(@skill)
  1168.     self.contents.font.size = YEM::SKILL::LEARN_DATA[:fontsize]
  1169.     self.contents.font.color = system_color
  1170.     text = YEM::SKILL::LEARN_DATA[:require]
  1171.     self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1); dy += WLH
  1172.     return dy
  1173.   end
  1174.  
  1175.   #--------------------------------------------------------------------------
  1176.   # draw_jp_cost
  1177.   #--------------------------------------------------------------------------
  1178.   def draw_jp_cost(dy)
  1179.     return dy if dy + WLH > contents.height
  1180.     return dy if @actor.skill_learn?(@skill)
  1181.     return dy if @skill.jp_cost <= 0
  1182.     self.contents.font.color = system_color
  1183.     draw_icon(Icon.jp, 0, dy)
  1184.     text = YEM::SKILL::LEARN_DATA[:jp_cost]
  1185.     self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1186.     text = @skill.jp_cost
  1187.     enabled = @actor.jp(@class_id) >= @skill.jp_cost
  1188.     self.contents.font.color = enabled ? normal_color : power_down_color
  1189.     self.contents.draw_text(4, dy, contents.width-8, WLH, text, 2); dy += WLH
  1190.     return dy
  1191.   end
  1192.  
  1193.   #--------------------------------------------------------------------------
  1194.   # draw_level_req
  1195.   #--------------------------------------------------------------------------
  1196.   def draw_level_req(dy)
  1197.     return dy if dy + WLH > contents.height
  1198.     return dy if @actor.skill_learn?(@skill)
  1199.     return dy if @skill.jp_require[:level] == nil
  1200.     self.contents.font.color = system_color
  1201.     draw_icon(Icon.level, 0, dy)
  1202.     text = Vocab.level
  1203.     self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1204.     text = @skill.jp_require[:level][0]
  1205.     enabled = @actor.level >= @skill.jp_require[:level][0]
  1206.     self.contents.font.color = enabled ? normal_color : power_down_color
  1207.     self.contents.draw_text(4, dy, contents.width-8, WLH, text, 2); dy += WLH
  1208.     return dy
  1209.   end
  1210.  
  1211.   #--------------------------------------------------------------------------
  1212.   # draw_skill_req
  1213.   #--------------------------------------------------------------------------
  1214.   def draw_skill_req(dy)
  1215.     return dy if dy + WLH > contents.height
  1216.     return dy if @actor.skill_learn?(@skill)
  1217.     return dy if @skill.jp_require[:skills] == nil
  1218.     for skill_id in @skill.jp_require[:skills]
  1219.       skill = $data_skills[skill_id]
  1220.       next if skill == nil
  1221.       draw_icon(skill.icon_index, 0, dy)
  1222.       enabled = @actor.skill_learn?(skill)
  1223.       self.contents.font.color = enabled ? normal_color : power_down_color
  1224.       text = skill.name
  1225.       self.contents.draw_text(24, dy, contents.width-8, WLH, text, 0)
  1226.       dy += WLH
  1227.     end
  1228.     return dy
  1229.   end
  1230.  
  1231.   #--------------------------------------------------------------------------
  1232.   # draw_passive_req
  1233.   #--------------------------------------------------------------------------
  1234.   def draw_passive_req(dy)
  1235.     return dy if dy + WLH > contents.height
  1236.     return dy if @actor.skill_learn?(@skill)
  1237.     return dy if @skill.jp_require[:passives] == nil
  1238.     for state_id in @skill.jp_require[:passives]
  1239.       state = $data_states[state_id]
  1240.       next if state == nil
  1241.       draw_icon(state.icon_index, 0, dy)
  1242.       enabled = @actor.passive_learn?(state)
  1243.       self.contents.font.color = enabled ? normal_color : power_down_color
  1244.       text = state.name
  1245.       self.contents.draw_text(24, dy, contents.width-8, WLH, text, 0)
  1246.       dy += WLH
  1247.     end
  1248.     return dy
  1249.   end
  1250.  
  1251.   #--------------------------------------------------------------------------
  1252.   # draw_properties
  1253.   #--------------------------------------------------------------------------
  1254.   def draw_properties(dy)
  1255.     dy = draw_properties_title(dy)
  1256.     dy = draw_skill_cost(dy)
  1257.     dy = draw_base_damage(dy)
  1258.     dy = draw_multipliers(dy)
  1259.     dy = draw_elements(dy)
  1260.     dy = draw_plus_states(dy)
  1261.     dy = draw_minus_states(dy)
  1262.     dy = draw_custom_data(dy)
  1263.     return dy
  1264.   end
  1265.  
  1266.   #--------------------------------------------------------------------------
  1267.   # draw_properties_title
  1268.   #--------------------------------------------------------------------------
  1269.   def draw_properties_title(dy)
  1270.     return dy if dy + WLH > contents.height
  1271.     self.contents.font.size = YEM::SKILL::LEARN_DATA[:fontsize]
  1272.     self.contents.font.color = system_color
  1273.     text = YEM::SKILL::LEARN_DATA[:properties]
  1274.     self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1); dy += WLH
  1275.     return dy
  1276.   end
  1277.  
  1278.   #--------------------------------------------------------------------------
  1279.   # draw_skill_cost
  1280.   #--------------------------------------------------------------------------
  1281.   def draw_skill_cost(dy)
  1282.     return dy if dy + WLH > contents.height
  1283.     if $imported["BattleEngineMelody"]
  1284.       return dy if @actor.custom_skill_costs(@skill, :calc_cost) <= 0
  1285.       icon = @actor.custom_skill_costs(@skill, :use_icon)
  1286.       draw_icon(icon, 0, dy)
  1287.       text = YEM::SKILL::LEARN_DATA[:skill_cost]
  1288.       self.contents.font.color = system_color
  1289.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1290.       self.contents.font.color = normal_color
  1291.       text = @actor.custom_skill_costs(@skill, :text_cost)
  1292.       text = sprintf(@actor.custom_skill_costs(@skill, :suffix), text)
  1293.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1294.     else
  1295.       return dy if @skill.mp_cost <= 0
  1296.       icon = Icon.jp
  1297.       draw_icon(icon, 0, dy)
  1298.       text = YEM::SKILL::LEARN_DATA[:skill_cost]
  1299.       self.contents.font.color = system_color
  1300.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1301.       self.contents.font.color = normal_color
  1302.       text = sprintf("%d%s", @skill.mp_cost, Vocab.mp)
  1303.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1304.     end
  1305.     dy += WLH
  1306.     return dy
  1307.   end
  1308.  
  1309.   #--------------------------------------------------------------------------
  1310.   # draw_base_damage
  1311.   #--------------------------------------------------------------------------
  1312.   def draw_base_damage(dy)
  1313.     return dy if dy + WLH > contents.height
  1314.     return dy if (-5..5) === @skill.base_damage
  1315.     if @skill.base_damage > 0
  1316.       draw_icon(Icon.base_damage, 0, dy)
  1317.       text = YEM::SKILL::LEARN_DATA[:base_dmg]
  1318.     else
  1319.       draw_icon(Icon.base_healing, 0, dy)
  1320.       text = YEM::SKILL::LEARN_DATA[:base_heal]
  1321.     end
  1322.     self.contents.font.color = system_color
  1323.     self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1324.     self.contents.font.color = normal_color
  1325.     text = (@skill.base_damage).abs
  1326.     self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2); dy += WLH
  1327.     return dy
  1328.   end
  1329.  
  1330.   #--------------------------------------------------------------------------
  1331.   # draw_multipliers
  1332.   #--------------------------------------------------------------------------
  1333.   def draw_multipliers(dy)
  1334.     return dy if dy + WLH > contents.height
  1335.     return dy if @skill.base_damage == 0
  1336.     icon = @skill.base_damage > 0 ? Icon.base_damage : Icon.base_healing
  1337.     #---
  1338.     if @skill.atk_f > 0
  1339.       draw_icon(icon, 0, dy)
  1340.       text = sprintf(YEM::SKILL::LEARN_DATA[:multiplier], Vocab.atk)
  1341.       self.contents.font.color = system_color
  1342.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1343.       text = sprintf("%s%%", @skill.atk_f)
  1344.       self.contents.font.color = normal_color
  1345.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1346.       dy += WLH
  1347.     end
  1348.     #---
  1349.     return dy if dy + WLH > contents.height
  1350.     #---
  1351.     if $imported["BattleEngineMelody"] and @skill.def_f > 0
  1352.       draw_icon(icon, 0, dy)
  1353.       text = sprintf(YEM::SKILL::LEARN_DATA[:multiplier], Vocab.def)
  1354.       self.contents.font.color = system_color
  1355.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1356.       text = sprintf("%s%%", @skill.def_f)
  1357.       self.contents.font.color = normal_color
  1358.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1359.       dy += WLH
  1360.     end
  1361.     #---
  1362.     return dy if dy + WLH > contents.height
  1363.     #---
  1364.     if @skill.spi_f > 0
  1365.       draw_icon(icon, 0, dy)
  1366.       text = sprintf(YEM::SKILL::LEARN_DATA[:multiplier], Vocab.spi)
  1367.       self.contents.font.color = system_color
  1368.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1369.       text = sprintf("%s%%", @skill.spi_f)
  1370.       self.contents.font.color = normal_color
  1371.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1372.       dy += WLH
  1373.     end
  1374.     #---
  1375.     return dy if dy + WLH > contents.height
  1376.     #---
  1377.     if $imported["BattleEngineMelody"] and $imported["RES Stat"] and
  1378.     @skill.res_f > 0
  1379.       draw_icon(icon, 0, dy)
  1380.       text = sprintf(YEM::SKILL::LEARN_DATA[:multiplier], Vocab.res)
  1381.       self.contents.font.color = system_color
  1382.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1383.       text = sprintf("%s%%", @skill.res_f)
  1384.       self.contents.font.color = normal_color
  1385.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1386.       dy += WLH
  1387.     end
  1388.     #---
  1389.     return dy if dy + WLH > contents.height
  1390.     #---
  1391.     if $imported["BattleEngineMelody"] and $imported["DEX Stat"] and
  1392.     @skill.dex_f > 0
  1393.       draw_icon(icon, 0, dy)
  1394.       text = sprintf(YEM::SKILL::LEARN_DATA[:multiplier], Vocab.dex)
  1395.       self.contents.font.color = system_color
  1396.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1397.       text = sprintf("%s%%", @skill.dex_f)
  1398.       self.contents.font.color = normal_color
  1399.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1400.       dy += WLH
  1401.     end
  1402.     #---
  1403.     return dy if dy + WLH > contents.height
  1404.     #---
  1405.     if $imported["BattleEngineMelody"] and @skill.agi_f > 0
  1406.       draw_icon(icon, 0, dy)
  1407.       text = sprintf(YEM::SKILL::LEARN_DATA[:multiplier], Vocab.agi)
  1408.       self.contents.font.color = system_color
  1409.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1410.       text = sprintf("%s%%", @skill.agi_f)
  1411.       self.contents.font.color = normal_color
  1412.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1413.       dy += WLH
  1414.     end
  1415.     #---
  1416.     return dy
  1417.   end
  1418.  
  1419.   #--------------------------------------------------------------------------
  1420.   # draw_elements
  1421.   #--------------------------------------------------------------------------
  1422.   def draw_elements(dy)
  1423.     return dy if @skill.element_set == []
  1424.     for element_id in YEM::SKILL::SHOWN_ELEMENTS
  1425.       break if dy + WLH > contents.height
  1426.       next unless @skill.element_set.include?(element_id)
  1427.       draw_icon(Icon.element(element_id), 0, dy)
  1428.       text = YEM::SKILL::LEARN_DATA[:element]
  1429.       self.contents.font.color = system_color
  1430.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1431.       text = $data_system.elements[element_id]
  1432.       self.contents.font.color = normal_color
  1433.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1434.       dy += WLH
  1435.     end
  1436.     return dy
  1437.   end
  1438.  
  1439.   #--------------------------------------------------------------------------
  1440.   # total_drawn_states
  1441.   #--------------------------------------------------------------------------
  1442.   def total_drawn_states(array)
  1443.     result = 0
  1444.     for state_id in array
  1445.       next if $data_states[state_id] == nil
  1446.       next if $data_states[state_id].icon_index == 0
  1447.       result += 1
  1448.     end
  1449.     return [result, 8].min
  1450.   end
  1451.  
  1452.   #--------------------------------------------------------------------------
  1453.   # draw_plus_states
  1454.   #--------------------------------------------------------------------------
  1455.   def draw_plus_states(dy)
  1456.     return dy if @skill.plus_state_set == []
  1457.     total = total_drawn_states(@skill.plus_state_set)
  1458.     if total == 1
  1459.       return dy if dy + WLH > contents.height
  1460.       state = $data_states[@skill.plus_state_set[0]]
  1461.       draw_icon(state.icon_index, 0, dy)
  1462.       text = YEM::SKILL::LEARN_DATA[:add_state]
  1463.       self.contents.font.color = system_color
  1464.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1465.       text = state.name
  1466.       self.contents.font.color = normal_color
  1467.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1468.     else
  1469.       return dy if dy + WLH*2 > contents.height
  1470.       text = YEM::SKILL::LEARN_DATA[:add_state]
  1471.       self.contents.font.color = system_color
  1472.       self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1)
  1473.       dy += WLH
  1474.       dx = (contents.width - total*24)/2
  1475.       for state_id in @skill.plus_state_set
  1476.         break if dx + 24 > contents.width
  1477.         state = $data_states[state_id]
  1478.         next if state.icon_index == 0
  1479.         draw_icon(state.icon_index, dx, dy)
  1480.         dx += 24
  1481.       end
  1482.     end
  1483.     dy += WLH
  1484.     return dy
  1485.   end
  1486.  
  1487.   #--------------------------------------------------------------------------
  1488.   # draw_minus_states
  1489.   #--------------------------------------------------------------------------
  1490.   def draw_minus_states(dy)
  1491.     return dy if @skill.minus_state_set == []
  1492.     total = total_drawn_states(@skill.minus_state_set)
  1493.     if total == 1
  1494.       return dy if dy + WLH > contents.height
  1495.       state = $data_states[@skill.minus_state_set[0]]
  1496.       draw_icon(state.icon_index, 0, dy)
  1497.       text = YEM::SKILL::LEARN_DATA[:rem_state]
  1498.       self.contents.font.color = system_color
  1499.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1500.       text = state.name
  1501.       self.contents.font.color = normal_color
  1502.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1503.     else
  1504.       return dy if dy + WLH*2 > contents.height
  1505.       text = YEM::SKILL::LEARN_DATA[:rem_state]
  1506.       self.contents.font.color = system_color
  1507.       self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1)
  1508.       dy += WLH
  1509.       dx = (contents.width - total*24)/2
  1510.       for state_id in @skill.minus_state_set
  1511.         break if dx + 24 > contents.width
  1512.         state = $data_states[state_id]
  1513.         next if state.icon_index == 0
  1514.         draw_icon(state.icon_index, dx, dy)
  1515.         dx += 24
  1516.       end
  1517.     end
  1518.     dy += WLH
  1519.     return dy
  1520.   end
  1521.  
  1522.   #--------------------------------------------------------------------------
  1523.   # draw_custom_data
  1524.   #--------------------------------------------------------------------------
  1525.   def draw_custom_data(dy)
  1526.     return dy if @skill.custom_data == []
  1527.     for array in @skill.custom_data
  1528.       break if dy + WLH > contents.height
  1529.       draw_icon(array[0], 0, dy)
  1530.       text = array[1]
  1531.       self.contents.font.color = system_color
  1532.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1533.       text = array[2]
  1534.       self.contents.font.color = normal_color
  1535.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1536.       dy += WLH
  1537.     end
  1538.     return dy
  1539.   end
  1540.  
  1541. end # Window_LearnData
  1542.  
  1543. #===============================================================================
  1544. # Window_LearnPassive
  1545. #===============================================================================
  1546.  
  1547. class Window_LearnPassive < Window_LearnSkill
  1548.  
  1549.   #--------------------------------------------------------------------------
  1550.   # passive
  1551.   #--------------------------------------------------------------------------
  1552.   def passive; return @data[self.index]; end
  1553.  
  1554.   #--------------------------------------------------------------------------
  1555.   # refresh
  1556.   #--------------------------------------------------------------------------
  1557.   def refresh
  1558.     if @cache_class != @class_id
  1559.       @cache_class = @class_id
  1560.       array = YEM::SKILL::CLASS_PASSIVES[0]
  1561.       if YEM::SKILL::CLASS_PASSIVES.include?(@class_id)
  1562.         array |= YEM::SKILL::CLASS_PASSIVES[@class_id]
  1563.         array.sort!
  1564.       end
  1565.       @data = []
  1566.       for state_id in array
  1567.         state = $data_states[state_id]
  1568.         next unless include?(state)
  1569.         @data.push(state)
  1570.       end
  1571.     end
  1572.     @item_max = @data.size
  1573.     self.index = [[self.index, @item_max-1].min, 0].max
  1574.     create_contents
  1575.     for i in 0...@item_max; draw_item(i); end
  1576.   end
  1577.  
  1578.   #--------------------------------------------------------------------------
  1579.   # enabled?
  1580.   #--------------------------------------------------------------------------
  1581.   def enabled?(passive)
  1582.     return false if passive == nil
  1583.     return true if @actor.passive_learn?(passive)
  1584.     #---
  1585.     if passive.jp_require[:level] != nil
  1586.       return false if passive.jp_require[:level][0] > @actor.level
  1587.     end
  1588.     #---
  1589.     if passive.jp_require[:skills] != nil
  1590.       for skill_id in skill.jp_require[:skills]
  1591.         next if $data_skills[skill_id] == nil
  1592.         return false unless @actor.skill_learn?($data_skills[skill_id])
  1593.       end
  1594.     end
  1595.     #---
  1596.     if passive.jp_require[:passives] != nil
  1597.       for state_id in passive.jp_require[:passives]
  1598.         next if $data_states[state_id] == nil
  1599.         return false unless @actor.passive_learn?($data_states[state_id])
  1600.       end
  1601.     end
  1602.     #---
  1603.     return @actor.jp(@class_id) >= passive.jp_cost
  1604.   end
  1605.  
  1606.   #--------------------------------------------------------------------------
  1607.   # new method: draw_obj_cost
  1608.   #--------------------------------------------------------------------------
  1609.   def draw_obj_cost(obj, rect, enabled)
  1610.     if @actor.passive_learn?(obj)
  1611.       self.contents.font.size = YEM::SKILL::JP_SIZE
  1612.       self.contents.font.color = normal_color
  1613.       self.contents.font.color.alpha = enabled ? 255 : 128
  1614.       text = YEM::SKILL::LEARNED_TEXT
  1615.       self.contents.draw_text(rect.x, rect.y, rect.width-4, WLH, text, 2)
  1616.     else
  1617.       draw_icon(Icon.jp, rect.x + rect.width - 24, rect.y, enabled)
  1618.       self.contents.font.size = YEM::SKILL::JP_SIZE
  1619.       self.contents.font.color = normal_color
  1620.       self.contents.font.color.alpha = enabled ? 255 : 128
  1621.       cost = obj.jp_cost
  1622.       self.contents.draw_text(rect.x, rect.y, rect.width-24, WLH, cost, 2)
  1623.     end
  1624.   end
  1625.  
  1626.   #--------------------------------------------------------------------------
  1627.   # update_help
  1628.   #--------------------------------------------------------------------------
  1629.   def update_help
  1630.     @help_window.set_text(passive == nil ? "" : passive.passive_description)
  1631.   end
  1632.  
  1633. end # Window_LearnPassive
  1634.  
  1635. #===============================================================================
  1636. # Window_PassiveData
  1637. #===============================================================================
  1638.  
  1639. class Window_PassiveData < Window_LearnData
  1640.  
  1641.   #--------------------------------------------------------------------------
  1642.   # initialize
  1643.   #--------------------------------------------------------------------------
  1644.   def initialize(actor, main_window)
  1645.     @anti_update = true
  1646.     super(actor, main_window)
  1647.   end
  1648.  
  1649.   #--------------------------------------------------------------------------
  1650.   # update
  1651.   #--------------------------------------------------------------------------
  1652.   def update
  1653.     super
  1654.     refresh if @passive != @main_window.passive
  1655.   end
  1656.  
  1657.   #--------------------------------------------------------------------------
  1658.   # refresh
  1659.   #--------------------------------------------------------------------------
  1660.   def refresh
  1661.     self.contents.clear
  1662.     @passive = @main_window.passive
  1663.     return if @passive == nil
  1664.     draw_obj_name
  1665.     dy = WLH
  1666.     dy = draw_requirements(dy)
  1667.     dy = draw_properties(dy)
  1668.   end
  1669.  
  1670.   #--------------------------------------------------------------------------
  1671.   # draw_obj_name
  1672.   #--------------------------------------------------------------------------
  1673.   def draw_obj_name
  1674.     draw_icon(@passive.icon_index, 0, 0)
  1675.     self.contents.font.size = Font.default_size
  1676.     self.contents.font.color = normal_color
  1677.     self.contents.draw_text(24, 0, contents.width-28, WLH, @passive.name)
  1678.   end
  1679.  
  1680.   #--------------------------------------------------------------------------
  1681.   # draw_properties
  1682.   #--------------------------------------------------------------------------
  1683.   def draw_requirements(dy)
  1684.     dy = draw_requirement_title(dy)
  1685.     dy = draw_jp_cost(dy)
  1686.     dy = draw_level_req(dy)
  1687.     dy = draw_skill_req(dy)
  1688.     dy = draw_passive_req(dy)
  1689.     return dy
  1690.   end
  1691.  
  1692.   #--------------------------------------------------------------------------
  1693.   # draw_requirement_title
  1694.   #--------------------------------------------------------------------------
  1695.   def draw_requirement_title(dy)
  1696.     return dy if dy + WLH > contents.height
  1697.     return dy if @actor.passive_learn?(@passive)
  1698.     self.contents.font.size = YEM::SKILL::LEARN_DATA[:fontsize]
  1699.     self.contents.font.color = system_color
  1700.     text = YEM::SKILL::LEARN_DATA[:require]
  1701.     self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1); dy += WLH
  1702.     return dy
  1703.   end
  1704.  
  1705.   #--------------------------------------------------------------------------
  1706.   # draw_jp_cost
  1707.   #--------------------------------------------------------------------------
  1708.   def draw_jp_cost(dy)
  1709.     return dy if dy + WLH > contents.height
  1710.     return dy if @actor.passive_learn?(@passive)
  1711.     return dy if @passive.jp_cost <= 0
  1712.     self.contents.font.color = system_color
  1713.     draw_icon(Icon.jp, 0, dy)
  1714.     text = YEM::SKILL::LEARN_DATA[:jp_cost]
  1715.     self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1716.     text = @passive.jp_cost
  1717.     enabled = @actor.jp(@class_id) >= @passive.jp_cost
  1718.     self.contents.font.color = enabled ? normal_color : power_down_color
  1719.     self.contents.draw_text(4, dy, contents.width-8, WLH, text, 2); dy += WLH
  1720.     return dy
  1721.   end
  1722.  
  1723.   #--------------------------------------------------------------------------
  1724.   # draw_level_req
  1725.   #--------------------------------------------------------------------------
  1726.   def draw_level_req(dy)
  1727.     return dy if dy + WLH > contents.height
  1728.     return dy if @actor.passive_learn?(@passive)
  1729.     return dy if @passive.jp_require[:level] == nil
  1730.     self.contents.font.color = system_color
  1731.     draw_icon(Icon.level, 0, dy)
  1732.     text = Vocab.level
  1733.     self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1734.     text = @passive.jp_require[:level][0]
  1735.     enabled = @actor.level >= @passive.jp_require[:level][0]
  1736.     self.contents.font.color = enabled ? normal_color : power_down_color
  1737.     self.contents.draw_text(4, dy, contents.width-8, WLH, text, 2); dy += WLH
  1738.     return dy
  1739.   end
  1740.  
  1741.   #--------------------------------------------------------------------------
  1742.   # draw_skill_req
  1743.   #--------------------------------------------------------------------------
  1744.   def draw_skill_req(dy)
  1745.     return dy if dy + WLH > contents.height
  1746.     return dy if @actor.passive_learn?(@passive)
  1747.     return dy if @passive.jp_require[:skills] == nil
  1748.     for skill_id in @passive.jp_require[:skills]
  1749.       skill = $data_skills[skill_id]
  1750.       next if skill == nil
  1751.       draw_icon(skill.icon_index, 0, dy)
  1752.       enabled = @actor.skill_learn?(skill)
  1753.       self.contents.font.color = enabled ? normal_color : power_down_color
  1754.       text = skill.name
  1755.       self.contents.draw_text(24, dy, contents.width-8, WLH, text, 0)
  1756.       dy += WLH
  1757.     end
  1758.     return dy
  1759.   end
  1760.  
  1761.   #--------------------------------------------------------------------------
  1762.   # draw_passive_req
  1763.   #--------------------------------------------------------------------------
  1764.   def draw_passive_req(dy)
  1765.     return dy if dy + WLH > contents.height
  1766.     return dy if @actor.passive_learn?(@passive)
  1767.     return dy if @passive.jp_require[:passives] == nil
  1768.     for state_id in @passive.jp_require[:passives]
  1769.       state = $data_states[state_id]
  1770.       next if state == nil
  1771.       draw_icon(state.icon_index, 0, dy)
  1772.       enabled = @actor.passive_learn?(state)
  1773.       self.contents.font.color = enabled ? normal_color : power_down_color
  1774.       text = state.name
  1775.       self.contents.draw_text(24, dy, contents.width-8, WLH, text, 0)
  1776.       dy += WLH
  1777.     end
  1778.     return dy
  1779.   end
  1780.  
  1781.   #--------------------------------------------------------------------------
  1782.   # draw_properties
  1783.   #--------------------------------------------------------------------------
  1784.   def draw_properties(dy)
  1785.     dy = draw_properties_title(dy)
  1786.     dy = draw_parameter_rates(dy)
  1787.     dy = draw_parameter_sets(dy)
  1788.     dy = draw_jp_rate(dy)
  1789.     dy = draw_custom_data(dy)
  1790.     return dy
  1791.   end
  1792.  
  1793.   #--------------------------------------------------------------------------
  1794.   # draw_properties_title
  1795.   #--------------------------------------------------------------------------
  1796.   def draw_properties_title(dy)
  1797.     return dy if dy + WLH > contents.height
  1798.     self.contents.font.size = YEM::SKILL::LEARN_DATA[:fontsize]
  1799.     self.contents.font.color = system_color
  1800.     text = YEM::SKILL::LEARN_DATA[:properties]
  1801.     self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1); dy += WLH
  1802.     return dy
  1803.   end
  1804.  
  1805.   #--------------------------------------------------------------------------
  1806.   # draw_parameter_rates
  1807.   #--------------------------------------------------------------------------
  1808.   def draw_parameter_rates(dy)
  1809.     return dy if dy + WLH > contents.height
  1810.     icon = @passive.icon_index
  1811.     #---
  1812.     if $imported["BattleEngineMelody"] and @passive.maxhp_rate != 100
  1813.       draw_icon(icon, 0, dy)
  1814.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_rate], Vocab.hp)
  1815.       self.contents.font.color = system_color
  1816.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1817.       text = sprintf("%+d%%", @passive.maxhp_rate - 100)
  1818.       self.contents.font.color = normal_color
  1819.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1820.       dy += WLH
  1821.     end
  1822.     return dy if dy + WLH > contents.height
  1823.     #---
  1824.     if $imported["BattleEngineMelody"] and @passive.maxmp_rate != 100
  1825.       draw_icon(icon, 0, dy)
  1826.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_rate], Vocab.mp)
  1827.       self.contents.font.color = system_color
  1828.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1829.       text = sprintf("%+d%%", @passive.maxmp_rate - 100)
  1830.       self.contents.font.color = normal_color
  1831.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1832.       dy += WLH
  1833.     end
  1834.     return dy if dy + WLH > contents.height
  1835.     #---
  1836.     if @passive.atk_rate != 100
  1837.       draw_icon(icon, 0, dy)
  1838.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_rate], Vocab.atk)
  1839.       self.contents.font.color = system_color
  1840.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1841.       text = sprintf("%+d%%", @passive.atk_rate - 100)
  1842.       self.contents.font.color = normal_color
  1843.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1844.       dy += WLH
  1845.     end
  1846.     return dy if dy + WLH > contents.height
  1847.     #---
  1848.     if @passive.def_rate != 100
  1849.       draw_icon(icon, 0, dy)
  1850.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_rate], Vocab.def)
  1851.       self.contents.font.color = system_color
  1852.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1853.       text = sprintf("%+d%%", @passive.def_rate - 100)
  1854.       self.contents.font.color = normal_color
  1855.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1856.       dy += WLH
  1857.     end
  1858.     return dy if dy + WLH > contents.height
  1859.     #---
  1860.     if @passive.spi_rate != 100
  1861.       draw_icon(icon, 0, dy)
  1862.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_rate], Vocab.spi)
  1863.       self.contents.font.color = system_color
  1864.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1865.       text = sprintf("%+d%%", @passive.spi_rate - 100)
  1866.       self.contents.font.color = normal_color
  1867.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1868.       dy += WLH
  1869.     end
  1870.     return dy if dy + WLH > contents.height
  1871.     #---
  1872.     if $imported["RES Stat"] and @passive.res_rate != 100
  1873.       draw_icon(icon, 0, dy)
  1874.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_rate], Vocab.res)
  1875.       self.contents.font.color = system_color
  1876.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1877.       text = sprintf("%+d%%", @passive.res_rate - 100)
  1878.       self.contents.font.color = normal_color
  1879.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1880.       dy += WLH
  1881.     end
  1882.     return dy if dy + WLH > contents.height
  1883.     #---
  1884.     if $imported["DEX Stat"] and @passive.dex_rate != 100
  1885.       draw_icon(icon, 0, dy)
  1886.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_rate], Vocab.dex)
  1887.       self.contents.font.color = system_color
  1888.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1889.       text = sprintf("%+d%%", @passive.dex_rate - 100)
  1890.       self.contents.font.color = normal_color
  1891.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1892.       dy += WLH
  1893.     end
  1894.     return dy if dy + WLH > contents.height
  1895.     #---
  1896.     if @passive.agi_rate != 100
  1897.       draw_icon(icon, 0, dy)
  1898.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_rate], Vocab.agi)
  1899.       self.contents.font.color = system_color
  1900.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1901.       text = sprintf("%+d%%", @passive.agi_rate - 100)
  1902.       self.contents.font.color = normal_color
  1903.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1904.       dy += WLH
  1905.     end
  1906.     return dy if dy + WLH > contents.height
  1907.     #---
  1908.     if $imported["BattleEngineMelody"] and @passive.hit_rate != 100
  1909.       draw_icon(icon, 0, dy)
  1910.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_rate], Vocab.hit)
  1911.       self.contents.font.color = system_color
  1912.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1913.       text = sprintf("%+d%%", @passive.hit_rate - 100)
  1914.       self.contents.font.color = normal_color
  1915.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1916.       dy += WLH
  1917.     end
  1918.     return dy if dy + WLH > contents.height
  1919.     #---
  1920.     if $imported["BattleEngineMelody"] and @passive.eva_rate != 100
  1921.       draw_icon(icon, 0, dy)
  1922.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_rate], Vocab.eva)
  1923.       self.contents.font.color = system_color
  1924.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1925.       text = sprintf("%+d%%", @passive.eva_rate - 100)
  1926.       self.contents.font.color = normal_color
  1927.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1928.       dy += WLH
  1929.     end
  1930.     return dy if dy + WLH > contents.height
  1931.     #---
  1932.     if $imported["BattleEngineMelody"] and @passive.cri_rate != 100
  1933.       draw_icon(icon, 0, dy)
  1934.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_rate], Vocab.cri)
  1935.       self.contents.font.color = system_color
  1936.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1937.       text = sprintf("%+d%%", @passive.cri_rate - 100)
  1938.       self.contents.font.color = normal_color
  1939.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1940.       dy += WLH
  1941.     end
  1942.     return dy if dy + WLH > contents.height
  1943.     #---
  1944.     if $imported["BattleEngineMelody"] and @passive.odds_rate != 100
  1945.       draw_icon(icon, 0, dy)
  1946.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_rate], Vocab.odds)
  1947.       self.contents.font.color = system_color
  1948.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1949.       text = sprintf("%+d%%", @passive.odds_rate - 100)
  1950.       self.contents.font.color = normal_color
  1951.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1952.       dy += WLH
  1953.     end
  1954.     #---
  1955.     return dy
  1956.   end
  1957.  
  1958.   #--------------------------------------------------------------------------
  1959.   # draw_parameter_sets
  1960.   #--------------------------------------------------------------------------
  1961.   def draw_parameter_sets(dy)
  1962.     return dy unless $imported["BattleEngineMelody"]
  1963.     return dy if dy + WLH > contents.height
  1964.     icon = @passive.icon_index
  1965.     #---
  1966.     if @passive.maxhp_set != 0
  1967.       draw_icon(icon, 0, dy)
  1968.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_set], Vocab.hp)
  1969.       self.contents.font.color = system_color
  1970.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1971.       text = sprintf("%+d", @passive.maxhp_set)
  1972.       self.contents.font.color = normal_color
  1973.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1974.       dy += WLH
  1975.     end
  1976.     return dy if dy + WLH > contents.height
  1977.     #---
  1978.     if @passive.maxmp_set != 0
  1979.       draw_icon(icon, 0, dy)
  1980.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_set], Vocab.mp)
  1981.       self.contents.font.color = system_color
  1982.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1983.       text = sprintf("%+d", @passive.maxmp_set)
  1984.       self.contents.font.color = normal_color
  1985.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1986.       dy += WLH
  1987.     end
  1988.     return dy if dy + WLH > contents.height
  1989.     #---
  1990.     if @passive.atk_set != 0
  1991.       draw_icon(icon, 0, dy)
  1992.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_set], Vocab.atk)
  1993.       self.contents.font.color = system_color
  1994.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1995.       text = sprintf("%+d", @passive.atk_set)
  1996.       self.contents.font.color = normal_color
  1997.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1998.       dy += WLH
  1999.     end
  2000.     return dy if dy + WLH > contents.height
  2001.     #---
  2002.     if @passive.def_set != 0
  2003.       draw_icon(icon, 0, dy)
  2004.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_set], Vocab.def)
  2005.       self.contents.font.color = system_color
  2006.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  2007.       text = sprintf("%+d", @passive.def_set)
  2008.       self.contents.font.color = normal_color
  2009.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  2010.       dy += WLH
  2011.     end
  2012.     return dy if dy + WLH > contents.height
  2013.     #---
  2014.     if @passive.spi_set != 0
  2015.       draw_icon(icon, 0, dy)
  2016.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_set], Vocab.spi)
  2017.       self.contents.font.color = system_color
  2018.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  2019.       text = sprintf("%+d", @passive.spi_set)
  2020.       self.contents.font.color = normal_color
  2021.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  2022.       dy += WLH
  2023.     end
  2024.     return dy if dy + WLH > contents.height
  2025.     #---
  2026.     if $imported["RES Stat"] and @passive.res_set != 0
  2027.       draw_icon(icon, 0, dy)
  2028.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_set], Vocab.res)
  2029.       self.contents.font.color = system_color
  2030.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  2031.       text = sprintf("%+d", @passive.res_set)
  2032.       self.contents.font.color = normal_color
  2033.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  2034.       dy += WLH
  2035.     end
  2036.     return dy if dy + WLH > contents.height
  2037.     #---
  2038.     if $imported["DEX Stat"] and @passive.dex_set != 0
  2039.       draw_icon(icon, 0, dy)
  2040.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_set], Vocab.dex)
  2041.       self.contents.font.color = system_color
  2042.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  2043.       text = sprintf("%+d", @passive.dex_set)
  2044.       self.contents.font.color = normal_color
  2045.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  2046.       dy += WLH
  2047.     end
  2048.     return dy if dy + WLH > contents.height
  2049.     #---
  2050.     if @passive.agi_set != 0
  2051.       draw_icon(icon, 0, dy)
  2052.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_set], Vocab.agi)
  2053.       self.contents.font.color = system_color
  2054.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  2055.       text = sprintf("%+d", @passive.agi_set)
  2056.       self.contents.font.color = normal_color
  2057.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  2058.       dy += WLH
  2059.     end
  2060.     return dy if dy + WLH > contents.height
  2061.     #---
  2062.     if @passive.hit_set != 0
  2063.       draw_icon(icon, 0, dy)
  2064.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_set], Vocab.hit)
  2065.       self.contents.font.color = system_color
  2066.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  2067.       text = sprintf("%+d%%", @passive.hit_set)
  2068.       self.contents.font.color = normal_color
  2069.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  2070.       dy += WLH
  2071.     end
  2072.     return dy if dy + WLH > contents.height
  2073.     #---
  2074.     if @passive.eva_set != 0
  2075.       draw_icon(icon, 0, dy)
  2076.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_set], Vocab.eva)
  2077.       self.contents.font.color = system_color
  2078.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  2079.       text = sprintf("%+d%%", @passive.eva_set)
  2080.       self.contents.font.color = normal_color
  2081.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  2082.       dy += WLH
  2083.     end
  2084.     return dy if dy + WLH > contents.height
  2085.     #---
  2086.     if @passive.cri_set != 0
  2087.       draw_icon(icon, 0, dy)
  2088.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_set], Vocab.cri)
  2089.       self.contents.font.color = system_color
  2090.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  2091.       text = sprintf("%+d%%", @passive.cri_set)
  2092.       self.contents.font.color = normal_color
  2093.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  2094.       dy += WLH
  2095.     end
  2096.     return dy if dy + WLH > contents.height
  2097.     #---
  2098.     if @passive.odds_set != 0
  2099.       draw_icon(icon, 0, dy)
  2100.       text = sprintf(YEM::SKILL::LEARN_DATA[:stat_set], Vocab.odds)
  2101.       self.contents.font.color = system_color
  2102.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  2103.       text = sprintf("%+d%%", @passive.odds_set)
  2104.       self.contents.font.color = normal_color
  2105.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  2106.       dy += WLH
  2107.     end
  2108.     return dy if dy + WLH > contents.height
  2109.     #---
  2110.     return dy
  2111.   end
  2112.  
  2113.   #--------------------------------------------------------------------------
  2114.   # draw_jp_rate
  2115.   #--------------------------------------------------------------------------
  2116.   def draw_jp_rate(dy)
  2117.     return dy if dy + WLH > contents.height
  2118.     return dy if @passive.jp_rate == 100
  2119.     draw_icon(Icon.jp, 0, dy)
  2120.     text = sprintf(YEM::SKILL::LEARN_DATA[:stat_rate], Vocab.jp)
  2121.     self.contents.font.color = system_color
  2122.     self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  2123.     text = sprintf("%+d%%", @passive.jp_rate - 100)
  2124.     self.contents.font.color = normal_color
  2125.     self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  2126.     dy += WLH
  2127.     return dy
  2128.   end
  2129.  
  2130.   #--------------------------------------------------------------------------
  2131.   # draw_custom_data
  2132.   #--------------------------------------------------------------------------
  2133.   def draw_custom_data(dy)
  2134.     return dy if @passive.custom_data == []
  2135.     for array in @passive.custom_data
  2136.       break if dy + WLH > contents.height
  2137.       draw_icon(array[0], 0, dy)
  2138.       text = array[1]
  2139.       self.contents.font.color = system_color
  2140.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  2141.       text = array[2]
  2142.       self.contents.font.color = normal_color
  2143.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  2144.       dy += WLH
  2145.     end
  2146.   end
  2147.  
  2148. end # Window_PassiveData
  2149.  
  2150. #===============================================================================
  2151. # Scene_Battle
  2152. #===============================================================================
  2153.  
  2154. class Scene_Battle < Scene_Base
  2155.  
  2156.   #--------------------------------------------------------------------------
  2157.   # new method: perform_earn_jp
  2158.   #--------------------------------------------------------------------------
  2159.   def perform_earn_jp(type = :attack)
  2160.     return if @active_battler == nil
  2161.     return unless @active_battler.actor?
  2162.     eval("@jp_set = YEM::SKILL::EARN_JP[:" + type.to_s + "_set]")
  2163.     eval("@jp_rand = YEM::SKILL::EARN_JP[:" + type.to_s + "_rand]")
  2164.     @jp_set += rand(@jp_rand) if @jp_rand > 0
  2165.     @active_battler.earn_jp(@jp_set)
  2166.   end
  2167.  
  2168.   unless $imported["BattleEngineMelody"]
  2169.   #--------------------------------------------------------------------------
  2170.   # alias method: execute_action_attack
  2171.   #--------------------------------------------------------------------------
  2172.   alias execute_action_attack_so execute_action_attack unless $@
  2173.   def execute_action_attack
  2174.     execute_action_attack_so
  2175.     perform_earn_jp(:attack)
  2176.   end
  2177.  
  2178.   #--------------------------------------------------------------------------
  2179.   # alias method: execute_action_guard
  2180.   #--------------------------------------------------------------------------
  2181.   alias execute_action_guard_so execute_action_guard unless $@
  2182.   def execute_action_guard
  2183.     execute_action_guard_so
  2184.     perform_earn_jp(:guard)
  2185.   end
  2186.  
  2187.   #--------------------------------------------------------------------------
  2188.   # alias method: execute_action_skill
  2189.   #--------------------------------------------------------------------------
  2190.   alias execute_action_skill_so execute_action_skill unless $@
  2191.   def execute_action_skill
  2192.     execute_action_skill_so
  2193.     perform_earn_jp(:skill)
  2194.   end
  2195.  
  2196.   #--------------------------------------------------------------------------
  2197.   # alias method: execute_action_item
  2198.   #--------------------------------------------------------------------------
  2199.   alias execute_action_item_so execute_action_item unless $@
  2200.   def execute_action_item
  2201.     execute_action_item_so
  2202.     perform_earn_jp(:item)
  2203.   end
  2204.  
  2205.   #--------------------------------------------------------------------------
  2206.   # overwrite method: battle_end
  2207.   #--------------------------------------------------------------------------
  2208.   alias battle_end_so battle_end unless $@
  2209.   def battle_end(result)
  2210.     $game_troop.distribute_jp
  2211.     battle_end_so(result)
  2212.   end
  2213.   end # $imported["BattleEngineMelody"]
  2214.  
  2215. end # Scene_Battle
  2216.  
  2217. #===============================================================================
  2218. # Scene_Skill
  2219. #===============================================================================
  2220.  
  2221. class Scene_Skill < Scene_Base
  2222.  
  2223.   #--------------------------------------------------------------------------
  2224.   # public instance variables
  2225.   #--------------------------------------------------------------------------
  2226.   attr_accessor :actor
  2227.  
  2228.   #--------------------------------------------------------------------------
  2229.   # overwrite method: start
  2230.   #--------------------------------------------------------------------------
  2231.   def start
  2232.     super
  2233.     create_menu_background
  2234.     @actor = $game_party.members[@actor_index]
  2235.     @class_id = @actor.class_id
  2236.     @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  2237.     @help_window = Window_Help.new
  2238.     @help_window.viewport = @viewport
  2239.     @help_window.y = 128
  2240.     @windows = []
  2241.     @target_window = Window_MenuStatus.new(0, 0)
  2242.     @target_window.visible = false
  2243.     @target_window.active = false
  2244.     create_command_window
  2245.     @status_window = Window_Actor_Skill_Status.new(@actor)
  2246.     @status_window.viewport = @viewport
  2247.     update_windows
  2248.   end
  2249.  
  2250.   #--------------------------------------------------------------------------
  2251.   # overwrite method: next_actor
  2252.   #--------------------------------------------------------------------------
  2253.   def next_actor
  2254.     @actor_index += 1
  2255.     @actor_index %= $game_party.members.size
  2256.     set_new_actor
  2257.   end
  2258.  
  2259.   #--------------------------------------------------------------------------
  2260.   # overwrite method: prev_actor
  2261.   #--------------------------------------------------------------------------
  2262.   def prev_actor
  2263.     @actor_index += $game_party.members.size - 1
  2264.     @actor_index %= $game_party.members.size
  2265.     set_new_actor
  2266.   end
  2267.  
  2268.   #--------------------------------------------------------------------------
  2269.   # new method: set_new_actor
  2270.   #--------------------------------------------------------------------------
  2271.   def set_new_actor
  2272.     $game_party.last_actor_index = @actor_index
  2273.     @actor = $game_party.members[@actor_index]
  2274.     @class_id = @actor.class_id
  2275.     @status_window.actor = @actor
  2276.     for window in @windows; window.actor = @actor; end
  2277.     update_windows
  2278.   end
  2279.  
  2280.   #--------------------------------------------------------------------------
  2281.   # new method: create_command_window
  2282.   #--------------------------------------------------------------------------
  2283.   def create_command_window
  2284.     commands = []; @data = []
  2285.     for command in YEM::SKILL::COMMANDS
  2286.       case command
  2287.       when :view_skills
  2288.         dy = @help_window.y + @help_window.height
  2289.         dh = Graphics.height - dy
  2290.         @skill_window = Window_Skill.new(0, dy, Graphics.width, dh, @actor)
  2291.         @skill_window.index = 0
  2292.         @windows.push(@skill_window)
  2293.       when :learn_skill
  2294.         next unless $game_switches[YEM::SKILL::LEARN_SKILL_SWITCH]
  2295.         @learn_window = Window_LearnSkill.new(@actor, @help_window)
  2296.         @learn_data = Window_LearnData.new(@actor, @learn_window)
  2297.         @windows.push(@learn_window)
  2298.         @windows.push(@learn_data)
  2299.       when :learn_passive
  2300.         next unless $game_switches[YEM::SKILL::LEARN_PASSIVE_SWITCH]
  2301.         @passive_window = Window_LearnPassive.new(@actor, @help_window)
  2302.         @passive_data = Window_PassiveData.new(@actor, @passive_window)
  2303.         @windows.push(@passive_window)
  2304.         @windows.push(@passive_data)
  2305.       when :equip_skill
  2306.         next unless $imported["SkillEquipSystem"]
  2307.         next unless $game_switches[YEM::SKILL_EQUIP::EQUIP_SKILL_SWITCH]
  2308.         create_equip_skill_windows
  2309.         commands.push(YEM::SKILL_EQUIP::TITLE)
  2310.       else; next
  2311.       end
  2312.       @data.push(command)
  2313.       if YEM::SKILL::VOCAB[command] != nil
  2314.         commands.push(YEM::SKILL::VOCAB[command])
  2315.       end
  2316.     end
  2317.     for window in @windows
  2318.       next if window == nil?
  2319.       window.active = false
  2320.       window.viewport = @viewport
  2321.       window.help_window = @help_window if window.is_a?(Window_Selectable)
  2322.     end
  2323.     @command_window = Window_Command_Centered.new(160, commands)
  2324.     @command_window.viewport = @viewport
  2325.     @command_window.height = 128
  2326.     @command_window.active = true
  2327.   end
  2328.  
  2329.   #--------------------------------------------------------------------------
  2330.   # new method: update_windows
  2331.   #--------------------------------------------------------------------------
  2332.   def update_windows
  2333.     @last_command_index = @command_window.index
  2334.     @help_window.y = Graphics.height*8
  2335.     for window in @windows
  2336.       next if window == nil
  2337.       window.y = Graphics.height*8
  2338.     end
  2339.     #---
  2340.     case @data[@command_window.index]
  2341.     when :view_skills
  2342.       show_view_skills
  2343.     when :learn_skill
  2344.       show_learn_skill
  2345.     when :learn_passive
  2346.       show_learn_passive
  2347.     when :equip_skill
  2348.       next unless $imported["SkillEquipSystem"]
  2349.       show_equip_skill_windows
  2350.     end
  2351.   end
  2352.  
  2353.   #--------------------------------------------------------------------------
  2354.   # new method: show_view_skills
  2355.   #--------------------------------------------------------------------------
  2356.   def show_view_skills
  2357.     @help_window.y = 128
  2358.     @skill_window.y = @help_window.y + @help_window.height
  2359.     @skill_window.update_help
  2360.   end
  2361.  
  2362.   #--------------------------------------------------------------------------
  2363.   # new method: show_learn_skill
  2364.   #--------------------------------------------------------------------------
  2365.   def show_learn_skill
  2366.     @help_window.y = 128
  2367.     @learn_window.y = @help_window.y + @help_window.height
  2368.     @learn_data.y = @learn_window.y
  2369.     @learn_window.update_help
  2370.   end
  2371.  
  2372.   #--------------------------------------------------------------------------
  2373.   # new method: show_learn_passive
  2374.   #--------------------------------------------------------------------------
  2375.   def show_learn_passive
  2376.     @help_window.y = 128
  2377.     @passive_window.y = @help_window.y + @help_window.height
  2378.     @passive_data.y = @passive_window.y
  2379.     @passive_window.update_help
  2380.   end
  2381.  
  2382.   #--------------------------------------------------------------------------
  2383.   # overwrite method: terminate
  2384.   #--------------------------------------------------------------------------
  2385.   def terminate
  2386.     super
  2387.     dispose_menu_background
  2388.     @help_window.dispose
  2389.     for window in @windows
  2390.       next if window == nil
  2391.       next if window.disposed?
  2392.       window.dispose
  2393.     end
  2394.     @command_window.dispose
  2395.     @status_window.dispose
  2396.     @target_window.dispose
  2397.     @viewport.dispose
  2398.   end
  2399.  
  2400.   #--------------------------------------------------------------------------
  2401.   # overwrite method: update
  2402.   #--------------------------------------------------------------------------
  2403.   def update
  2404.     super
  2405.     update_menu_background
  2406.     @viewport.update
  2407.     if @command_window.active
  2408.       update_command_selection
  2409.     elsif @skill_window != nil and @skill_window.active
  2410.       update_skill_selection
  2411.     elsif @target_window != nil and @target_window.active
  2412.       update_target_selection
  2413.     elsif @learn_window != nil and @learn_window.active
  2414.       update_learn_selection
  2415.     elsif @passive_window != nil and @passive_window.active
  2416.       update_passive_selection
  2417.     #---
  2418.     elsif @equip_skill_window != nil and @equip_skill_window.active
  2419.       update_skill_equip_selection
  2420.     elsif @equip_skill_replace != nil and @equip_skill_replace.active
  2421.       update_skill_equip_replacement
  2422.     end
  2423.   end
  2424.  
  2425.   #--------------------------------------------------------------------------
  2426.   # new method: update_command_selection
  2427.   #--------------------------------------------------------------------------
  2428.   def update_command_selection
  2429.     @command_window.update
  2430.     update_windows if @last_command_index != @command_window.index
  2431.     if Input.trigger?(Input::B)
  2432.       Sound.play_cancel
  2433.       return_scene
  2434.     elsif Input.repeat?(Input::RIGHT)
  2435.       Sound.play_cursor
  2436.       next_actor
  2437.     elsif Input.repeat?(Input::LEFT)
  2438.       Sound.play_cursor
  2439.       prev_actor
  2440.     #--- Debug Commands ---
  2441.     elsif $TEST and Input.trigger?(Input::F5)
  2442.       Sound.play_recovery
  2443.       @actor.mp = @actor.maxhp
  2444.       @status_window.refresh
  2445.       @skill_window.refresh if @skill_window != nil
  2446.     #--- Debug Commands ---
  2447.     elsif Input.trigger?(Input::C)
  2448.       Sound.play_decision
  2449.       case @data[@command_window.index]
  2450.       when :view_skills
  2451.         @command_window.active = false
  2452.         @skill_window.active = true
  2453.       when :learn_skill
  2454.         @command_window.active = false
  2455.         @learn_window.active = true
  2456.       when :learn_passive
  2457.         @command_window.active = false
  2458.         @passive_window.active = true
  2459.       when :equip_skill
  2460.         next unless $imported["SkillEquipSystem"]
  2461.         @command_window.active = false
  2462.         @equip_skill_window.active = true
  2463.       end
  2464.     end
  2465.   end
  2466.  
  2467.   #--------------------------------------------------------------------------
  2468.   # overwrite method: update_skill_selection
  2469.   #--------------------------------------------------------------------------
  2470.   def update_skill_selection
  2471.     @skill_window.update
  2472.     if Input.trigger?(Input::B)
  2473.       Sound.play_cancel
  2474.       @command_window.active = true
  2475.       @skill_window.active = false
  2476.     elsif Input.trigger?(Input::C)
  2477.       @skill = @skill_window.skill
  2478.       if @skill != nil
  2479.         @actor.last_skill_id = @skill.id
  2480.       end
  2481.       if @actor.skill_can_use?(@skill)
  2482.         Sound.play_decision
  2483.         determine_skill
  2484.       else
  2485.         Sound.play_buzzer
  2486.       end
  2487.     end
  2488.   end
  2489.  
  2490.   #--------------------------------------------------------------------------
  2491.   # alias method: update_target_selection
  2492.   #--------------------------------------------------------------------------
  2493.   alias update_target_selection_so update_target_selection unless $@
  2494.   def update_target_selection
  2495.     @target_window.update
  2496.     update_target_selection_so
  2497.   end
  2498.  
  2499.   #--------------------------------------------------------------------------
  2500.   # new method: update_learn_selection
  2501.   #--------------------------------------------------------------------------
  2502.   def update_learn_selection
  2503.     @learn_window.update
  2504.     @learn_data.update
  2505.     if Input.trigger?(Input::B)
  2506.       Sound.play_cancel
  2507.       @command_window.active = true
  2508.       @learn_window.active = false
  2509.       @skill_window.refresh if @skill_window != nil
  2510.       @passive_window.refresh if @passive_window != nil
  2511.     elsif Input.repeat?(Input::RIGHT)
  2512.       Sound.play_cursor
  2513.       next_actor
  2514.       @learn_window.index = 0
  2515.     elsif Input.repeat?(Input::LEFT)
  2516.       Sound.play_cursor
  2517.       prev_actor
  2518.       @learn_window.index = 0
  2519.     #--- Debug Commands ---
  2520.     elsif $TEST and Input.repeat?(Input::F8) # Increase JP
  2521.       Sound.play_equip
  2522.       var = YEM::SKILL::MAXIMUM_JP / 10
  2523.       jp = Input.press?(Input::SHIFT) ? rand(var) + var : rand(100) +100
  2524.       @actor.change_jp(@class_id, jp)
  2525.       @status_window.refresh
  2526.     elsif $TEST and Input.repeat?(Input::F7) # Decrease JP
  2527.       Sound.play_equip
  2528.       var = YEM::SKILL::MAXIMUM_JP / 10
  2529.       jp = Input.press?(Input::SHIFT) ? rand(var) + var : rand(100) +100
  2530.       @actor.change_jp(@class_id, -jp)
  2531.       @status_window.refresh
  2532.     elsif $TEST and Input.trigger?(Input::F6) # Refresh Windows
  2533.       Sound.play_load
  2534.       @status_window.refresh
  2535.       @learn_window.refresh
  2536.       @learn_data.refresh
  2537.     elsif $TEST and Input.trigger?(Input::F5) # Learn/Forget Skill
  2538.       skill = @learn_window.skill
  2539.       learn_skill(skill, Input.press?(Input::SHIFT))
  2540.     #--- Debug Commands ---
  2541.     elsif Input.trigger?(Input::C)
  2542.       skill = @learn_window.skill
  2543.       if @learn_window.enabled?(skill) and !@actor.skill_learn?(skill)
  2544.         learn_skill(skill)
  2545.       else
  2546.         Sound.play_buzzer
  2547.       end
  2548.     end
  2549.   end
  2550.  
  2551.   #--------------------------------------------------------------------------
  2552.   # new method: learn_skill
  2553.   #--------------------------------------------------------------------------
  2554.   def learn_skill(skill, forget = false)
  2555.     Sound.play_shop
  2556.     @actor.learn_skill(skill.id) unless forget
  2557.     @actor.forget_skill(skill.id) if forget
  2558.     @actor.change_jp(@class_id, -skill.jp_cost)
  2559.     @learn_window.refresh
  2560.     @learn_data.refresh
  2561.     @status_window.refresh
  2562.     @equip_skill_window.refresh if @equip_skill_window != nil
  2563.     end
  2564.   end
  2565.  
  2566.   #--------------------------------------------------------------------------
  2567.   # new method: update_passive_selection
  2568.   #--------------------------------------------------------------------------
  2569.   def update_passive_selection
  2570.     @passive_window.update
  2571.     @passive_data.update
  2572.     if Input.trigger?(Input::B)
  2573.       Sound.play_cancel
  2574.       @command_window.active = true
  2575.       @passive_window.active = false
  2576.       @skill_window.refresh if @skill_window != nil
  2577.       @learn_window.refresh if @learn_window != nil
  2578.     elsif Input.repeat?(Input::RIGHT)
  2579.       Sound.play_cursor
  2580.       next_actor
  2581.       @passive_window.index = 0
  2582.     elsif Input.repeat?(Input::LEFT)
  2583.       Sound.play_cursor
  2584.       prev_actor
  2585.       @passive_window.index = 0
  2586.     #--- Debug Commands ---
  2587.     elsif $TEST and Input.repeat?(Input::F8) # Increase JP
  2588.       Sound.play_equip
  2589.       var = YEM::SKILL::MAXIMUM_JP / 10
  2590.       jp = Input.press?(Input::SHIFT) ? rand(var) + var : rand(100) +100
  2591.       @actor.change_jp(@class_id, jp)
  2592.       @status_window.refresh
  2593.     elsif $TEST and Input.repeat?(Input::F7) # Decrease JP
  2594.       Sound.play_equip
  2595.       var = YEM::SKILL::MAXIMUM_JP / 10
  2596.       jp = Input.press?(Input::SHIFT) ? rand(var) + var : rand(100) +100
  2597.       @actor.change_jp(@class_id, -jp)
  2598.       @status_window.refresh
  2599.     elsif $TEST and Input.trigger?(Input::F6) # Refresh Windows
  2600.       Sound.play_load
  2601.       @status_window.refresh
  2602.       @passive_window.refresh
  2603.       @passive_data.refresh
  2604.     elsif $TEST and Input.trigger?(Input::F5) # Learn/Forget Passive
  2605.       passive = @passive_window.passive
  2606.       learn_passive(passive, Input.press?(Input::SHIFT))
  2607.     #--- Debug Commands ---
  2608.     elsif Input.trigger?(Input::C)
  2609.       passive = @passive_window.passive
  2610.       if @passive_window.enabled?(passive) and !@actor.passive_learn?(passive)
  2611.         learn_passive(passive)
  2612.       else
  2613.         Sound.play_buzzer
  2614.       end
  2615.     end
  2616.   end
  2617.  
  2618.   #--------------------------------------------------------------------------
  2619.   # new method: learn_passive
  2620.   #--------------------------------------------------------------------------
  2621.   def learn_passive(passive, forget = false)
  2622.     Sound.play_shop
  2623.     @actor.learn_passive(passive.id) unless forget
  2624.     @actor.forget_passive(passive.id) if forget
  2625.     @actor.change_jp(@class_id, -passive.jp_cost)
  2626.     @passive_window.refresh
  2627.     @passive_data.refresh
  2628.     @status_window.refresh
  2629. end # Scene_Skill
  2630.  
  2631. #===============================================================================
  2632. #
  2633. # END OF FILE
  2634. #
  2635. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement