Guest User

Yanfly's Cost Manager Update / Change

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