Guest User

Yanfly's Cost Manager Update / Change

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