Archeia

Yanfly Engine Ace - Skill Cost Manager v1.03

Mar 30th, 2014
408
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Skill Cost Manager v1.03
  4. # -- Last Updated: 2012.01.23
  5. # -- Level: Normal, Hard, Lunatic
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-SkillCostManager"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.08.06 - Restore SP-Paramater: TCR
  17. # 2012.01.23 - Compatibility Update: Doppelganger
  18. # 2011.12.11 - Started Script and Finished.
  19. #            - Added max and min notetags.
  20. #
  21. #==============================================================================
  22. # ▼ Introduction
  23. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  24. # This script adds more functionality towards skill costs. Skills can now cost
  25. # HP, more MP, more TP, gold, and even have custom costs. The way the skill
  26. # costs are drawn in the display windows are changed to deliver more effective
  27. # and reliable information to the player. And if four skill costs aren't enough
  28. # to satisfy you, you can even make your own custom skill costs.
  29. #
  30. #==============================================================================
  31. # ▼ Instructions
  32. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  33. # To install this script, open up your script editor and copy/paste this script
  34. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  35. #
  36. # -----------------------------------------------------------------------------
  37. # Actor Notetags - These notetags go in the actors notebox in the database.
  38. # -----------------------------------------------------------------------------
  39. # <hp cost rate: x%>
  40. # Allows the actor to drop the HP cost of skills to x%.
  41. #
  42. # <tp cost rate: x%>
  43. # Allows the actor to drop the TP cost of skills to x%.
  44. #
  45. # <gold cost rate: x%>
  46. # Allows the actor to drop the Gold cost of skills to x%.
  47. #
  48. # -----------------------------------------------------------------------------
  49. # Class Notetags - These notetags go in the class notebox in the database.
  50. # -----------------------------------------------------------------------------
  51. # <hp cost rate: x%>
  52. # Allows the class to drop the HP cost of skills to x%.
  53. #
  54. # <tp cost rate: x%>
  55. # Allows the class to drop the TP cost of skills to x%.
  56. #
  57. # <gold cost rate: x%>
  58. # Allows the class to drop the Gold cost of skills to x%.
  59. #
  60. # -----------------------------------------------------------------------------
  61. # Skill Notetags - These notetags go in the skills notebox in the database.
  62. # -----------------------------------------------------------------------------
  63. # <hp cost: x>
  64. # Sets the skill's HP cost to x. This function did not exist by default in
  65. # RPG Maker VX Ace.
  66. #
  67. # <hp cost: x%>
  68. # Sets the HP cost to a percentage of the actor's MaxHP. If a normal HP cost is
  69. # present on the skill, too, then this value is added to the HP cost.
  70. #
  71. # <hp cost max: x>
  72. # <hp cost min: x>
  73. # Sets the maximum and minimum range of the HP Cost of the skill. If you do not
  74. # use this tag, there will be no maximum and/or minimum range.
  75. #
  76. # <mp cost: x>
  77. # Sets the skill's MP cost to x. Allows MP cost to exceed 9999, which is RPG
  78. # Maker VX Ace's database editor's maximum limit.
  79. #
  80. # <mp cost: x%>
  81. # Sets the MP cost to a percentage of the actor's MaxMP. If a normal MP cost is
  82. # present on the skill, too, then this value is added to the MP cost.
  83. #
  84. # <mp cost max: x>
  85. # <mp cost min: x>
  86. # Sets the maximum and minimum range of the MP Cost of the skill. If you do not
  87. # use this tag, there will be no maximum and/or minimum range.
  88. #
  89. # <tp cost: x>
  90. # Sets the skill's TP cost to x. Allows TP cost to exceed 100, which is RPG
  91. # Maker VX Ace's database editor's maximum limit.
  92. #
  93. # <tp cost: x%>
  94. # Sets the TP cost to a percentage of the actor's MaxTP. If a normal TP cost is
  95. # present on the skill, too, then this value is added to the TP cost.
  96. #
  97. # <tp cost max: x>
  98. # <tp cost min: x>
  99. # Sets the maximum and minimum range of the TP Cost of the skill. If you do not
  100. # use this tag, there will be no maximum and/or minimum range.
  101. #
  102. # <gold cost: x>
  103. # Sets the skill's gold cost to x. Enemies with skills that cost gold do not
  104. # use gold. If the player does not have enough gold, the skill can't be used.
  105. #
  106. # <gold cost: x%>
  107. # Sets the skill's gold cost equal to a percentage of the party's total gold.
  108. # If both a regular gold cost and a percentile gold cost is used, the total of
  109. # both values will be the skill's gold cost.
  110. #
  111. # <gold cost max: x>
  112. # <gold cost min: x>
  113. # Sets the maximum and minimum range of the Gold Cost of the skill. If you do
  114. # not use this tag, there will be no maximum and/or minimum range.
  115. #
  116. # --- Making Your Own Custom Costs ---
  117. #
  118. # <custom cost: string>
  119. # If you decide to have a custom cost for your game, insert this notetag to
  120. # change what displays in the skill menu visually.
  121. #
  122. # <custom cost colour: x>
  123. # This is the "Window" skin text colour used for the custom cost. By default,
  124. # it is text colour 0, which is the white colour.
  125. #
  126. # <custom cost size: x>
  127. # This is the text font size used for the custom cost in the display windows.
  128. # By default, it is font size 20.
  129. #
  130. # <custom cost icon: x>
  131. # If you wish to use an icon for your custom cost, replace x with the icon ID
  132. # you wish to show in display windows. By default, it is 0 (and not shown).
  133. #
  134. # <custom cost requirement>
  135. #  string
  136. #  string
  137. # </custom cost requirement>
  138. # Sets the custom cost requirement of the skill with an eval function using the
  139. # strings in between. The strings are a part of one line even if in the notebox
  140. # they are on separate lines.
  141. #
  142. # <custom cost perform>
  143. #  string
  144. #  string
  145. # </custom cost perform>
  146. # Sets how the custom cost payment is done with an eval function using the
  147. # strings in between. The strings are a part of one line even if in the notebox
  148. # they are on separate lines.
  149. #
  150. # -----------------------------------------------------------------------------
  151. # Weapon Notetags - These notetags go in the weapons notebox in the database.
  152. # -----------------------------------------------------------------------------
  153. # <hp cost rate: x%>
  154. # Allows the weapon to drop the HP cost of skills to x% when worn.
  155. #
  156. # <tp cost rate: x%>
  157. # Allows the weapon to drop the TP cost of skills to x% when worn.
  158. #
  159. # <gold cost rate: x%>
  160. # Allows the weapon to drop the Gold cost of skills to x% when worn.
  161. #
  162. # -----------------------------------------------------------------------------
  163. # Armour Notetags - These notetags go in the armours notebox in the database.
  164. # -----------------------------------------------------------------------------
  165. # <hp cost rate: x%>
  166. # Allows the armour to drop the HP cost of skills to x% when worn.
  167. #
  168. # <tp cost rate: x%>
  169. # Allows the armour to drop the TP cost of skills to x% when worn.
  170. #
  171. # <gold cost rate: x%>
  172. # Allows the armour to drop the TP cost of skills to x% when worn.
  173. #
  174. # -----------------------------------------------------------------------------
  175. # Enemy Notetags - These notetags go in the enemies notebox in the database.
  176. # -----------------------------------------------------------------------------
  177. # <hp cost rate: x%>
  178. # Allows the enemy to drop the HP cost of skills to x%.
  179. #
  180. # <tp cost rate: x%>
  181. # Allows the enemy to drop the TP cost of skills to x%.
  182. #
  183. # -----------------------------------------------------------------------------
  184. # State Notetags - These notetags go in the states notebox in the database.
  185. # -----------------------------------------------------------------------------
  186. # <hp cost rate: x%>
  187. # Allows the state to drop the HP cost of skills to x% when afflicted.
  188. #
  189. # <tp cost rate: x%>
  190. # Allows the state to drop the TP cost of skills to x% when afflicted.
  191. #
  192. # <gold cost rate: x%>
  193. # Allows the state to drop the Gold cost of skills to x% when afflicted.
  194. #
  195. #==============================================================================
  196. # ▼ Compatibility
  197. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  198. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  199. # it will run with RPG Maker VX without adjusting.
  200. #
  201. #==============================================================================
  202.  
  203. module YEA
  204.   module SKILL_COST
  205.    
  206.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  207.     # - HP Cost Settings -
  208.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  209.     # New to this script are HP costs. HP costs require the battler to have
  210.     # sufficient HP before being able to use the skill. The text colour that's
  211.     # used, the suffix, or whether or not to use an icon. If you do not wish
  212.     # to use an icon, set the icon to 0.
  213.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  214.     HP_COST_COLOUR = 21         # Colour used from "Window" skin.
  215.     HP_COST_SIZE   = 20         # Font size used for HP costs.
  216.     HP_COST_SUFFIX = "%sHP"     # Suffix used for HP costs.
  217.     HP_COST_ICON   = 0          # Icon used for HP costs. Set 0 to disable.
  218.    
  219.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  220.     # - MP Cost Settings -
  221.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  222.     # Here, you can change the settings for MP costs: the text colour that's
  223.     # used, the suffix, or whether or not to use an icon. If you do not wish
  224.     # to use an icon, set the icon to 0.
  225.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  226.     MP_COST_COLOUR = 23         # Colour used from "Window" skin. Default: 23
  227.     MP_COST_SIZE   = 20         # Font size used for MP costs. Default: 24
  228.     MP_COST_SUFFIX = "%sMP"     # Suffix used for MP costs. No suffix default.
  229.     MP_COST_ICON   = 0          # Icon used for MP costs. Set 0 to disable.
  230.    
  231.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  232.     # - TP Cost Settings -
  233.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  234.     # Here, you can change the settings for TP costs: the text colour that's
  235.     # used, the suffix, or whether or not to use an icon. If you do not wish
  236.     # to use an icon, set the icon to 0.
  237.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  238.     TP_COST_COLOUR = 2          # Colour used from "Window" skin. Default: 29
  239.     TP_COST_SIZE   = 20         # Font size used for TP costs. Default: 24
  240.     TP_COST_SUFFIX = "%sTP"     # Suffix used for TP costs. No suffix default.
  241.     TP_COST_ICON   = 0          # Icon used for TP costs. Set 0 to disable.
  242.    
  243.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  244.     # - Gold Cost Settings -
  245.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  246.     # New to this script are Gold costs. Gold costs require the party to have
  247.     # enough gold before being able to use the skill. The text colour that's
  248.     # used, the suffix, or whether or not to use an icon. If you do not wish
  249.     # to use an icon, set the icon to 0.
  250.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  251.     GOLD_COST_COLOUR = 6          # Colour used from "Window" skin.
  252.     GOLD_COST_SIZE   = 20         # Font size used for Gold costs.
  253.     GOLD_COST_SUFFIX = "%sGold"   # Suffix used for Gold costs.
  254.     GOLD_COST_ICON   = 0          # Icon used for Gold costs. Set 0 to disable.
  255.    
  256.   end # SKILL_COST
  257. end # YEA
  258.  
  259. #==============================================================================
  260. # ▼ Editting anything past this point may potentially result in causing
  261. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  262. # halitosis so edit at your own risk.
  263. #==============================================================================
  264.  
  265. module YEA
  266.   module REGEXP
  267.   module BASEITEM
  268.    
  269.     HP_COST_RATE = /<(?:HP_COST_RATE|hp cost rate):[ ](\d+)([%])>/i
  270.     TP_COST_RATE = /<(?:TP_COST_RATE|tp cost rate):[ ](\d+)([%])>/i
  271.     GOLD_COST_RATE = /<(?:GOLD_COST_RATE|gold cost rate):[ ](\d+)([%])>/i
  272.    
  273.   end # BASEITEM
  274.   module SKILL
  275.    
  276.     HP_COST_SET = /<(?:HP_COST|hp cost):[ ](\d+)>/i
  277.     HP_COST_PER = /<(?:HP_COST|hp cost):[ ](\d+)([%])>/i
  278.     MP_COST_SET = /<(?:MP_COST|mp cost):[ ](\d+)>/i
  279.     MP_COST_PER = /<(?:MP_COST|mp cost):[ ](\d+)([%])>/i
  280.     TP_COST_SET = /<(?:TP_COST|tp cost):[ ](\d+)>/i
  281.     TP_COST_PER = /<(?:TP_COST|tp cost):[ ](\d+)([%])>/i
  282.     GOLD_COST_SET = /<(?:GOLD_COST|gold cost):[ ](\d+)>/i
  283.     GOLD_COST_PER = /<(?:GOLD_COST|gold cost):[ ](\d+)([%])>/i
  284.    
  285.     CUSTOM_COST_TEXT = /<(?:CUSTOM_COST|custom cost):[ ](.*)>/i
  286.     CUSTOM_COST_COLOUR =
  287.       /<(?:CUSTOM_COST_COLOUR|custom cost colour|custom cost color):[ ](\d+)>/i
  288.     CUSTOM_COST_SIZE = /<(?:CUSTOM_COST_SIZE|custom cost size):[ ](\d+)>/i
  289.     CUSTOM_COST_ICON = /<(?:CUSTOM_COST_ICON|custom cost icon):[ ](\d+)>/i
  290.     CUSTOM_COST_REQUIREMENT_ON =
  291.       /<(?:CUSTOM_COST_REQUIREMENT|custom cost requirement)>/i
  292.     CUSTOM_COST_REQUIREMENT_OFF =
  293.       /<\/(?:CUSTOM_COST_REQUIREMENT|custom cost requirement)>/i
  294.     CUSTOM_COST_PERFORM_ON =
  295.       /<(?:CUSTOM_COST_PERFORM|custom cost perform)>/i
  296.     CUSTOM_COST_PERFORM_OFF =
  297.       /<\/(?:CUSTOM_COST_PERFORM|custom cost perform)>/i
  298.    
  299.     HP_COST_MIN = /<(?:HP_COST_MIN|hp cost min):[ ](\d+)>/i
  300.     HP_COST_MAX = /<(?:HP_COST_MIN|hp cost max):[ ](\d+)>/i
  301.     MP_COST_MIN = /<(?:MP_COST_MIN|mp cost min):[ ](\d+)>/i
  302.     MP_COST_MAX = /<(?:MP_COST_MIN|mp cost max):[ ](\d+)>/i
  303.     TP_COST_MIN = /<(?:TP_COST_MIN|tp cost min):[ ](\d+)>/i
  304.     TP_COST_MAX = /<(?:TP_COST_MIN|tp cost max):[ ](\d+)>/i
  305.     GOLD_COST_MIN = /<(?:GOLD_COST_MIN|gold cost min):[ ](\d+)>/i
  306.     GOLD_COST_MAX = /<(?:GOLD_COST_MIN|gold cost max):[ ](\d+)>/i
  307.    
  308.   end # SKILL
  309.   end # REGEXP
  310. end # YEA
  311.  
  312. #==============================================================================
  313. # ■ Icon
  314. #==============================================================================
  315.  
  316. module Icon
  317.  
  318.   #--------------------------------------------------------------------------
  319.   # self.mp_cost
  320.   #--------------------------------------------------------------------------
  321.   def self.mp_cost; return YEA::SKILL_COST::MP_COST_ICON; end
  322.  
  323.   #--------------------------------------------------------------------------
  324.   # self.tp_cost
  325.   #--------------------------------------------------------------------------
  326.   def self.tp_cost; return YEA::SKILL_COST::TP_COST_ICON; end
  327.  
  328.   #--------------------------------------------------------------------------
  329.   # self.hp_cost
  330.   #--------------------------------------------------------------------------
  331.   def self.hp_cost; return YEA::SKILL_COST::HP_COST_ICON; end
  332.  
  333.   #--------------------------------------------------------------------------
  334.   # self.gold_cost
  335.   #--------------------------------------------------------------------------
  336.   def self.gold_cost; return YEA::SKILL_COST::GOLD_COST_ICON; end
  337.    
  338. end # Icon
  339.  
  340. #==============================================================================
  341. # ■ Numeric
  342. #==============================================================================
  343.  
  344. class Numeric
  345.  
  346.   #--------------------------------------------------------------------------
  347.   # new method: group_digits
  348.   #--------------------------------------------------------------------------
  349.   unless $imported["YEA-CoreEngine"]
  350.   def group; return self.to_s; end
  351.   end # $imported["YEA-CoreEngine"]
  352.    
  353. end # Numeric
  354.  
  355. #==============================================================================
  356. # ■ DataManager
  357. #==============================================================================
  358.  
  359. module DataManager
  360.  
  361.   #--------------------------------------------------------------------------
  362.   # alias method: load_database
  363.   #--------------------------------------------------------------------------
  364.   class <<self; alias load_database_scm load_database; end
  365.   def self.load_database
  366.     load_database_scm
  367.     load_notetags_scm
  368.   end
  369.  
  370.   #--------------------------------------------------------------------------
  371.   # new method: load_notetags_scm
  372.   #--------------------------------------------------------------------------
  373.   def self.load_notetags_scm
  374.     groups = [$data_actors, $data_classes, $data_skills, $data_weapons,
  375.       $data_armors, $data_enemies, $data_states]
  376.     for group in groups
  377.       for obj in group
  378.         next if obj.nil?
  379.         obj.load_notetags_scm
  380.       end
  381.     end
  382.   end
  383.  
  384. end # DataManager
  385.  
  386. #==============================================================================
  387. # ■ RPG::BaseItem
  388. #==============================================================================
  389.  
  390. class RPG::BaseItem
  391.  
  392.   #--------------------------------------------------------------------------
  393.   # public instance variables
  394.   #--------------------------------------------------------------------------
  395.   attr_accessor :tp_cost_rate
  396.   attr_accessor :hp_cost_rate
  397.   attr_accessor :gold_cost_rate
  398.  
  399.   #--------------------------------------------------------------------------
  400.   # common cache: load_notetags_scm
  401.   #--------------------------------------------------------------------------
  402.   def load_notetags_scm
  403.     @tp_cost_rate = 1.0
  404.     @hp_cost_rate = 1.0
  405.     @gold_cost_rate = 1.0
  406.     #---
  407.     self.note.split(/[\r\n]+/).each { |line|
  408.       case line
  409.       #---
  410.       when YEA::REGEXP::BASEITEM::TP_COST_RATE
  411.         @tp_cost_rate = $1.to_i * 0.01
  412.       when YEA::REGEXP::BASEITEM::HP_COST_RATE
  413.         @hp_cost_rate = $1.to_i * 0.01
  414.       when YEA::REGEXP::BASEITEM::GOLD_COST_RATE
  415.         @gold_cost_rate = $1.to_i * 0.01
  416.       #---
  417.       end
  418.     } # self.note.split
  419.     #---
  420.   end
  421.  
  422. end # RPG::BaseItem
  423.  
  424. #==============================================================================
  425. # ■ RPG::Skill
  426. #==============================================================================
  427.  
  428. class RPG::Skill < RPG::UsableItem
  429.  
  430.   #--------------------------------------------------------------------------
  431.   # public instance variables
  432.   #--------------------------------------------------------------------------
  433.   attr_accessor :hp_cost
  434.   attr_accessor :hp_cost_percent
  435.   attr_accessor :mp_cost_percent
  436.   attr_accessor :tp_cost_percent
  437.   attr_accessor :gold_cost
  438.   attr_accessor :gold_cost_percent
  439.  
  440.   attr_accessor :hp_cost_min
  441.   attr_accessor :hp_cost_max
  442.   attr_accessor :mp_cost_min
  443.   attr_accessor :mp_cost_max
  444.   attr_accessor :tp_cost_min
  445.   attr_accessor :tp_cost_max
  446.   attr_accessor :gold_cost_min
  447.   attr_accessor :gold_cost_max
  448.  
  449.   attr_accessor :use_custom_cost
  450.   attr_accessor :custom_cost_text
  451.   attr_accessor :custom_cost_colour
  452.   attr_accessor :custom_cost_size
  453.   attr_accessor :custom_cost_icon
  454.   attr_accessor :custom_cost_requirement
  455.   attr_accessor :custom_cost_perform
  456.  
  457.   #--------------------------------------------------------------------------
  458.   # common cache: load_notetags_scm
  459.   #--------------------------------------------------------------------------
  460.   def load_notetags_scm
  461.     @hp_cost = 0
  462.     @gold_cost = 0
  463.     @hp_cost_percent = 0.0
  464.     @mp_cost_percent = 0.0
  465.     @tp_cost_percent = 0.0
  466.     @gold_cost_percent = 0.0
  467.    
  468.     @custom_cost_text = "0"
  469.     @custom_cost_colour = 0
  470.     @custom_cost_size = 20
  471.     @custom_cost_icon = 0
  472.     @custom_cost_requirement = ""
  473.     @custom_cost_perform = ""
  474.    
  475.     @use_custom_cost = false
  476.     @custom_cost_req_on = false
  477.     @custom_cost_per_on = false
  478.     #---
  479.     self.note.split(/[\r\n]+/).each { |line|
  480.       case line
  481.       #---
  482.       when YEA::REGEXP::SKILL::MP_COST_SET
  483.         @mp_cost = $1.to_i
  484.       when YEA::REGEXP::SKILL::MP_COST_PER
  485.         @mp_cost_percent = $1.to_i * 0.01
  486.       when YEA::REGEXP::SKILL::TP_COST_SET
  487.         @tp_cost = $1.to_i
  488.       when YEA::REGEXP::SKILL::TP_COST_PER
  489.         @tp_cost_percent = $1.to_i * 0.01
  490.       when YEA::REGEXP::SKILL::HP_COST_SET
  491.         @hp_cost = $1.to_i
  492.       when YEA::REGEXP::SKILL::HP_COST_PER
  493.         @hp_cost_percent = $1.to_i * 0.01
  494.       when YEA::REGEXP::SKILL::GOLD_COST_SET
  495.         @gold_cost = $1.to_i
  496.       when YEA::REGEXP::SKILL::GOLD_COST_PER
  497.         @gold_cost_percent = $1.to_i * 0.01
  498.       #---
  499.       when YEA::REGEXP::SKILL::HP_COST_MIN
  500.         @hp_cost_min = $1.to_i
  501.       when YEA::REGEXP::SKILL::HP_COST_MAX
  502.         @hp_cost_max = $1.to_i
  503.       when YEA::REGEXP::SKILL::MP_COST_MIN
  504.         @mp_cost_min = $1.to_i
  505.       when YEA::REGEXP::SKILL::MP_COST_MAX
  506.         @mp_cost_max = $1.to_i
  507.       when YEA::REGEXP::SKILL::TP_COST_MIN
  508.         @tp_cost_min = $1.to_i
  509.       when YEA::REGEXP::SKILL::TP_COST_MAX
  510.         @tp_cost_max = $1.to_i
  511.       when YEA::REGEXP::SKILL::GOLD_COST_MIN
  512.         @gold_cost_min = $1.to_i
  513.       when YEA::REGEXP::SKILL::GOLD_COST_MAX
  514.         @gold_cost_max = $1.to_i
  515.       #---
  516.       when YEA::REGEXP::SKILL::CUSTOM_COST_TEXT
  517.         @custom_cost_text = $1.to_s
  518.       when YEA::REGEXP::SKILL::CUSTOM_COST_COLOUR
  519.         @custom_cost_colour = $1.to_i
  520.       when YEA::REGEXP::SKILL::CUSTOM_COST_SIZE
  521.         @custom_cost_size = $1.to_i
  522.       when YEA::REGEXP::SKILL::CUSTOM_COST_ICON
  523.         @custom_cost_icon = $1.to_i
  524.       when YEA::REGEXP::SKILL::CUSTOM_COST_REQUIREMENT_ON
  525.         @custom_cost_req_on = true
  526.         @use_custom_cost = true
  527.       when YEA::REGEXP::SKILL::CUSTOM_COST_REQUIREMENT_OFF
  528.         @custom_cost_req_on = false
  529.         @use_custom_cost = true
  530.       when YEA::REGEXP::SKILL::CUSTOM_COST_PERFORM_ON
  531.         @custom_cost_per_on = true
  532.         @use_custom_cost = true
  533.       when YEA::REGEXP::SKILL::CUSTOM_COST_PERFORM_OFF
  534.         @custom_cost_per_on = false
  535.         @use_custom_cost = true
  536.       else
  537.         @custom_cost_requirement += line.to_s if @custom_cost_req_on
  538.         @custom_cost_perform += line.to_s if @custom_cost_per_on
  539.       #---
  540.       end
  541.     } # self.note.split
  542.     #---
  543.   end
  544.  
  545. end # RPG::Skill
  546.  
  547. #==============================================================================
  548. # ■ Game_BattlerBase
  549. #==============================================================================
  550.  
  551. class Game_BattlerBase
  552.  
  553.   #--------------------------------------------------------------------------
  554.   # alias method: skill_cost_payable?
  555.   #--------------------------------------------------------------------------
  556.   alias game_battlerbase_skill_cost_payable_scm skill_cost_payable?
  557.   def skill_cost_payable?(skill)
  558.     return false if hp <= skill_hp_cost(skill)
  559.     return false unless gold_cost_met?(skill)
  560.     return false unless custom_cost_met?(skill)
  561.     return game_battlerbase_skill_cost_payable_scm(skill)
  562.   end
  563.  
  564.   #--------------------------------------------------------------------------
  565.   # new method: gold_cost_met?
  566.   #--------------------------------------------------------------------------
  567.   def gold_cost_met?(skill)
  568.     return true unless actor?
  569.     return $game_party.gold >= skill_gold_cost(skill)
  570.   end
  571.  
  572.   #--------------------------------------------------------------------------
  573.   # new method: custom_cost_met?
  574.   #--------------------------------------------------------------------------
  575.   def custom_cost_met?(skill)
  576.     return true unless skill.use_custom_cost
  577.     return eval(skill.custom_cost_requirement)
  578.   end
  579.  
  580.   #--------------------------------------------------------------------------
  581.   # alias method: pay_skill_cost
  582.   #--------------------------------------------------------------------------
  583.   alias game_battlerbase_pay_skill_cost_scm pay_skill_cost
  584.   def pay_skill_cost(skill)
  585.     game_battlerbase_pay_skill_cost_scm(skill)
  586.     self.hp -= skill_hp_cost(skill)
  587.     $game_party.lose_gold(skill_gold_cost(skill)) if actor?
  588.     pay_custom_cost(skill)
  589.   end
  590.  
  591.   #--------------------------------------------------------------------------
  592.   # new method: pay_custom_cost
  593.   #--------------------------------------------------------------------------
  594.   def pay_custom_cost(skill)
  595.     return unless skill.use_custom_cost
  596.     eval(skill.custom_cost_perform)
  597.   end
  598.  
  599.   #--------------------------------------------------------------------------
  600.   # alias method: skill_mp_cost
  601.   #--------------------------------------------------------------------------
  602.   alias game_battlerbase_skill_mp_cost_scm skill_mp_cost
  603.   def skill_mp_cost(skill)
  604.     n = game_battlerbase_skill_mp_cost_scm(skill)
  605.     n += skill.mp_cost_percent * mmp * mcr
  606.     n = [n.to_i, skill.mp_cost_max].min unless skill.mp_cost_max.nil?
  607.     n = [n.to_i, skill.mp_cost_min].max unless skill.mp_cost_min.nil?
  608.     return n.to_i
  609.   end
  610.  
  611.   #--------------------------------------------------------------------------
  612.   # alias method: skill_tp_cost
  613.   #--------------------------------------------------------------------------
  614.   alias game_battlerbase_skill_tp_cost_scm skill_tp_cost
  615.   def skill_tp_cost(skill)
  616.     n = game_battlerbase_skill_tp_cost_scm(skill) * tcr_y
  617.     n += skill.tp_cost_percent * max_tp * tcr_y
  618.     n = [n.to_i, skill.tp_cost_max].min unless skill.tp_cost_max.nil?
  619.     n = [n.to_i, skill.tp_cost_min].max unless skill.tp_cost_min.nil?
  620.     return n.to_i
  621.   end
  622.  
  623.   #--------------------------------------------------------------------------
  624.   # new method: tcr_y
  625.   #--------------------------------------------------------------------------
  626.   def tcr_y
  627.     n = 1.0
  628.     if actor?
  629.       n *= self.actor.tp_cost_rate
  630.       n *= self.class.tp_cost_rate
  631.       for equip in equips
  632.         next if equip.nil?
  633.         n *= equip.tp_cost_rate
  634.       end
  635.     else
  636.       n *= self.enemy.tp_cost_rate
  637.       if $imported["YEA-Doppelganger"] && !self.class.nil?
  638.         n *= self.class.tp_cost_rate
  639.       end
  640.     end
  641.     for state in states
  642.       next if state.nil?
  643.       n *= state.tp_cost_rate
  644.     end
  645.     return n
  646.   end
  647.  
  648.   #--------------------------------------------------------------------------
  649.   # new method: skill_hp_cost
  650.   #--------------------------------------------------------------------------
  651.   def skill_hp_cost(skill)
  652.     n = skill.hp_cost * hcr
  653.     n += skill.hp_cost_percent * mhp * hcr
  654.     n = [n.to_i, skill.hp_cost_max].min unless skill.hp_cost_max.nil?
  655.     n = [n.to_i, skill.hp_cost_min].max unless skill.hp_cost_min.nil?
  656.     return n.to_i
  657.   end
  658.  
  659.   #--------------------------------------------------------------------------
  660.   # new method: hcr
  661.   #--------------------------------------------------------------------------
  662.   def hcr
  663.     n = 1.0
  664.     if actor?
  665.       n *= self.actor.hp_cost_rate
  666.       n *= self.class.hp_cost_rate
  667.       for equip in equips
  668.         next if equip.nil?
  669.         n *= equip.hp_cost_rate
  670.       end
  671.     else
  672.       n *= self.enemy.hp_cost_rate
  673.       if $imported["YEA-Doppelganger"] && !self.class.nil?
  674.         n *= self.class.hp_cost_rate
  675.       end
  676.     end
  677.     for state in states
  678.       next if state.nil?
  679.       n *= state.hp_cost_rate
  680.     end
  681.     return n
  682.   end
  683.  
  684.   #--------------------------------------------------------------------------
  685.   # new method: skill_gold_cost
  686.   #--------------------------------------------------------------------------
  687.   def skill_gold_cost(skill)
  688.     n = skill.gold_cost * gcr
  689.     n += skill.gold_cost_percent * $game_party.gold * gcr
  690.     n = [n.to_i, skill.gold_cost_max].min unless skill.gold_cost_max.nil?
  691.     n = [n.to_i, skill.gold_cost_min].max unless skill.gold_cost_min.nil?
  692.     return n.to_i
  693.   end
  694.  
  695.   #--------------------------------------------------------------------------
  696.   # new method: gcr
  697.   #--------------------------------------------------------------------------
  698.   def gcr
  699.     n = 1.0
  700.     n *= self.actor.gold_cost_rate
  701.     n *= self.class.gold_cost_rate
  702.     for equip in equips
  703.       next if equip.nil?
  704.       n *= equip.gold_cost_rate
  705.     end
  706.     for state in states
  707.       next if state.nil?
  708.       n *= state.gold_cost_rate
  709.     end
  710.     return n
  711.   end
  712.  
  713. end # Game_BattlerBase
  714.  
  715. #==============================================================================
  716. # ■ Window_Base
  717. #==============================================================================
  718.  
  719. class Window_Base < Window
  720.  
  721.   #--------------------------------------------------------------------------
  722.   # overwrite methods: cost_colours
  723.   #--------------------------------------------------------------------------
  724.   def mp_cost_color; text_color(YEA::SKILL_COST::MP_COST_COLOUR); end;
  725.   def tp_cost_color; text_color(YEA::SKILL_COST::TP_COST_COLOUR); end;
  726.   def hp_cost_color; text_color(YEA::SKILL_COST::HP_COST_COLOUR); end;
  727.   def gold_cost_color; text_color(YEA::SKILL_COST::GOLD_COST_COLOUR); end;
  728.  
  729. end # Window_Base
  730.  
  731. #==============================================================================
  732. # ■ Window_SkillList
  733. #==============================================================================
  734.  
  735. class Window_SkillList < Window_Selectable
  736.  
  737.   #--------------------------------------------------------------------------
  738.   # overwrite method: draw_skill_cost
  739.   #--------------------------------------------------------------------------
  740.   def draw_skill_cost(rect, skill)
  741.     draw_tp_skill_cost(rect, skill) unless $imported["YEA-BattleEngine"]
  742.     draw_mp_skill_cost(rect, skill)
  743.     draw_tp_skill_cost(rect, skill) if $imported["YEA-BattleEngine"]
  744.     draw_hp_skill_cost(rect, skill)
  745.     draw_gold_skill_cost(rect, skill)
  746.     draw_custom_skill_cost(rect, skill)
  747.   end
  748.  
  749.   #--------------------------------------------------------------------------
  750.   # new method: draw_mp_skill_cost
  751.   #--------------------------------------------------------------------------
  752.   def draw_mp_skill_cost(rect, skill)
  753.     return unless @actor.skill_mp_cost(skill) > 0
  754.     change_color(mp_cost_color, enable?(skill))
  755.     #---
  756.     icon = Icon.mp_cost
  757.     if icon > 0
  758.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  759.       rect.width -= 24
  760.     end
  761.     #---
  762.     contents.font.size = YEA::SKILL_COST::MP_COST_SIZE
  763.     cost = @actor.skill_mp_cost(skill)
  764.     text = sprintf(YEA::SKILL_COST::MP_COST_SUFFIX, cost.group)
  765.     draw_text(rect, text, 2)
  766.     cx = text_size(text).width + 4
  767.     rect.width -= cx
  768.     reset_font_settings
  769.   end
  770.  
  771.   #--------------------------------------------------------------------------
  772.   # new method: draw_tp_skill_cost
  773.   #--------------------------------------------------------------------------
  774.   def draw_tp_skill_cost(rect, skill)
  775.     return unless @actor.skill_tp_cost(skill) > 0
  776.     change_color(tp_cost_color, enable?(skill))
  777.     #---
  778.     icon = Icon.tp_cost
  779.     if icon > 0
  780.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  781.       rect.width -= 24
  782.     end
  783.     #---
  784.     contents.font.size = YEA::SKILL_COST::TP_COST_SIZE
  785.     cost = @actor.skill_tp_cost(skill)
  786.     text = sprintf(YEA::SKILL_COST::TP_COST_SUFFIX, cost.group)
  787.     draw_text(rect, text, 2)
  788.     cx = text_size(text).width + 4
  789.     rect.width -= cx
  790.     reset_font_settings
  791.   end
  792.  
  793.   #--------------------------------------------------------------------------
  794.   # new method: draw_hp_skill_cost
  795.   #--------------------------------------------------------------------------
  796.   def draw_hp_skill_cost(rect, skill)
  797.     return unless @actor.skill_hp_cost(skill) > 0
  798.     change_color(hp_cost_color, enable?(skill))
  799.     #---
  800.     icon = Icon.hp_cost
  801.     if icon > 0
  802.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  803.       rect.width -= 24
  804.     end
  805.     #---
  806.     contents.font.size = YEA::SKILL_COST::HP_COST_SIZE
  807.     cost = @actor.skill_hp_cost(skill)
  808.     text = sprintf(YEA::SKILL_COST::HP_COST_SUFFIX, cost.group)
  809.     draw_text(rect, text, 2)
  810.     cx = text_size(text).width + 4
  811.     rect.width -= cx
  812.     reset_font_settings
  813.   end
  814.  
  815.   #--------------------------------------------------------------------------
  816.   # new method: draw_gold_skill_cost
  817.   #--------------------------------------------------------------------------
  818.   def draw_gold_skill_cost(rect, skill)
  819.     return unless @actor.skill_gold_cost(skill) > 0
  820.     change_color(gold_cost_color, enable?(skill))
  821.     #---
  822.     icon = Icon.gold_cost
  823.     if icon > 0
  824.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  825.       rect.width -= 24
  826.     end
  827.     #---
  828.     contents.font.size = YEA::SKILL_COST::GOLD_COST_SIZE
  829.     cost = @actor.skill_gold_cost(skill)
  830.     text = sprintf(YEA::SKILL_COST::GOLD_COST_SUFFIX, cost.group)
  831.     draw_text(rect, text, 2)
  832.     cx = text_size(text).width + 4
  833.     rect.width -= cx
  834.     reset_font_settings
  835.   end
  836.  
  837.   #--------------------------------------------------------------------------
  838.   # new method: draw_custom_skill_cost
  839.   #--------------------------------------------------------------------------
  840.   def draw_custom_skill_cost(rect, skill)
  841.     return unless skill.use_custom_cost
  842.     change_color(text_color(skill.custom_cost_colour), enable?(skill))
  843.     icon = skill.custom_cost_icon
  844.     if icon > 0
  845.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  846.       rect.width -= 24
  847.     end
  848.     contents.font.size = skill.custom_cost_size
  849.     text = skill.custom_cost_text
  850.     draw_text(rect, text, 2)
  851.     cx = text_size(text).width + 4
  852.     rect.width -= cx
  853.     reset_font_settings
  854.   end
  855.  
  856. end # Window_SkillList
  857.  
  858. #==============================================================================
  859. #
  860. # ▼ End of File
  861. #
  862. #==============================================================================
RAW Paste Data