Advertisement
Archeia

Yanfly Engine Ace - Skill Restrictions v1.03

Mar 30th, 2014
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 38.98 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ¥ Yanfly Engine Ace - Skill Restrictions v1.03
  4. # -- Last Updated: 2012.07.21
  5. # -- Level: Normal, Hard, Lunatic
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-SkillRestrictions"] = true
  12.  
  13. #==============================================================================
  14. # ¥ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.07.21 - Fixed cooldown issue with Normal Attack and Defend.
  17. # 2012.01.23 - Compatibility Update: Doppelganger
  18. # 2011.12.12 - Started Script and Finished.
  19. #            - Added cooldown altering notetags for items.
  20. #
  21. #==============================================================================
  22. # ¥ Introduction
  23. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  24. # Sometimes good game balance depends on restriction mechanics. Of these
  25. # mechanics include skill cooldowns, warmups, and the amount of times a skill
  26. # can be used (limited uses). Included in this script are features also to
  27. # lock cooldowns, reduce cooldown rates, change cooldown values for skills,
  28. # skill types, and more. If this isn't enough restriction power, switches may
  29. # be used to restrict skills from being used as well as even code.
  30. #
  31. #==============================================================================
  32. # ¥ Instructions
  33. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  34. # To install this script, open up your script editor and copy/paste this script
  35. # to an open slot below ¥ Materials/‘fÞ but above ¥ Main. Remember to save.
  36. #
  37. # -----------------------------------------------------------------------------
  38. # Actor Notetags - These notetags go in the actors notebox in the database.
  39. # -----------------------------------------------------------------------------
  40. # <cooldown lock>
  41. # A battler afflicted with cooldown lock will not have cooldowns count down
  42. # every turn until the cooldown lock is removed.
  43. #
  44. # <cooldown rate: x%>
  45. # When cooldowns are applied from using skills in battle, the cooldown rate can
  46. # reduce or increase the finalized amount of turns a battler would need to wait
  47. # before being able to use that skill again.
  48. #
  49. # <warmup rate: x%>
  50. # Lowers/Raises the amount of turns needed to pass in battle before the warmup
  51. # skills become available for usage.
  52. #
  53. # -----------------------------------------------------------------------------
  54. # Class Notetags - These notetags go in the class notebox in the database.
  55. # -----------------------------------------------------------------------------
  56. # <cooldown lock>
  57. # A battler afflicted with cooldown lock will not have cooldowns count down
  58. # every turn until the cooldown lock is removed.
  59. #
  60. # <cooldown rate: x%>
  61. # When cooldowns are applied from using skills in battle, the cooldown rate can
  62. # reduce or increase the finalized amount of turns a battler would need to wait
  63. # before being able to use that skill again.
  64. #
  65. # <warmup rate: x%>
  66. # Lowers/Raises the amount of turns needed to pass in battle before the warmup
  67. # skills become available for usage.
  68. #
  69. # -----------------------------------------------------------------------------
  70. # Skill Notetags - These notetags go in the skills notebox in the database.
  71. # -----------------------------------------------------------------------------
  72. # <cooldown: x>
  73. # Causes the skill to have a cooldown of x once it's used in battle. Skills
  74. # with cooldowns cannot be used again until cooldown reaches 0 or until the
  75. # battle is over.
  76. #
  77. # <change cooldown: +x>
  78. # <change cooldown: -x>
  79. # This will cause the target's cooldowns for every skill to increase by x or
  80. # decrease by x. This selects skills indiscriminately.
  81. #
  82. # <skill cooldown x: +y>
  83. # <skill cooldown x: -y>
  84. # This will cause the target's specific skill x to receive a change in cooldown
  85. # by either an increase or decrease of y amount.
  86. #
  87. # <stype cooldown x: +y>
  88. # <stype cooldown x: -y>
  89. # This will cause all of the skills with skill type x to have its cooldowns
  90. # changed by y amount. +y increases cooldown turns while -y decreases turns.
  91. #
  92. # <limited uses: x>
  93. # This will allow the skill to only be usable x times throughout the course of
  94. # battle. Once the skill is used x times, it is disabled until the battle is
  95. # over. This effect only takes place during battle.
  96. #
  97. # <warmup: x>
  98. # Causes the skill to be sealed until the x turns pass in battle. There's no
  99. # way to speed up a warmup manually with the exception of warmup rates.
  100. #
  101. # <restrict if switch: x>
  102. # This will restrict the skill if switch x is ON. If switch x is OFF, this
  103. # skill will no longer be restricted.
  104. #
  105. # <restrict any switch: x>
  106. # <restrict any switch: x, x>
  107. # This will restrict the skill if any of the x switches are ON. If all of them
  108. # are off, then the skill will not be restricted.
  109. #
  110. # <restrict all switch: x>
  111. # <restrict all switch: x, x>
  112. # This will restrict the skill if all of the x switches are ON. If any of them
  113. # are off, then the skill will not be restricted.
  114. #
  115. # <restrict eval>
  116. #  string
  117. #  string
  118. # </restrict eval>
  119. # For the more advanced users, replace string with code to determine whether
  120. # or not the skill is restricted. If multiple lines are used, they are all
  121. # considered part of the same line.
  122. #
  123. # -----------------------------------------------------------------------------
  124. # Item Notetags - These notetags go in the items notebox in the database.
  125. # -----------------------------------------------------------------------------
  126. # <change cooldown: +x>
  127. # <change cooldown: -x>
  128. # This will cause the target's cooldowns for every skill to increase by x or
  129. # decrease by x. This selects skills indiscriminately.
  130. #
  131. # <skill cooldown x: +y>
  132. # <skill cooldown x: -y>
  133. # This will cause the target's specific skill x to receive a change in cooldown
  134. # by either an increase or decrease of y amount.
  135. #
  136. # <stype cooldown x: +y>
  137. # <stype cooldown x: -y>
  138. # This will cause all of the skills with skill type x to have its cooldowns
  139. # changed by y amount. +y increases cooldown turns while -y decreases turns.
  140. #
  141. # -----------------------------------------------------------------------------
  142. # Weapon Notetags - These notetags go in the weapons notebox in the database.
  143. # -----------------------------------------------------------------------------
  144. # <cooldown lock>
  145. # A battler afflicted with cooldown lock will not have cooldowns count down
  146. # every turn until the cooldown lock is removed.
  147. #
  148. # <cooldown rate: x%>
  149. # When cooldowns are applied from using skills in battle, the cooldown rate can
  150. # reduce or increase the finalized amount of turns a battler would need to wait
  151. # before being able to use that skill again.
  152. #
  153. # <warmup rate: x%>
  154. # Lowers/Raises the amount of turns needed to pass in battle before the warmup
  155. # skills become available for usage.
  156. #
  157. # -----------------------------------------------------------------------------
  158. # Armour Notetags - These notetags go in the armours notebox in the database.
  159. # -----------------------------------------------------------------------------
  160. # <cooldown lock>
  161. # A battler afflicted with cooldown lock will not have cooldowns count down
  162. # every turn until the cooldown lock is removed.
  163. #
  164. # <cooldown rate: x%>
  165. # When cooldowns are applied from using skills in battle, the cooldown rate can
  166. # reduce or increase the finalized amount of turns a battler would need to wait
  167. # before being able to use that skill again.
  168. #
  169. # <warmup rate: x%>
  170. # Lowers/Raises the amount of turns needed to pass in battle before the warmup
  171. # skills become available for usage.
  172. #
  173. # -----------------------------------------------------------------------------
  174. # Enemy Notetags - These notetags go in the enemies notebox in the database.
  175. # -----------------------------------------------------------------------------
  176. # <cooldown lock>
  177. # A battler afflicted with cooldown lock will not have cooldowns count down
  178. # every turn until the cooldown lock is removed.
  179. #
  180. # <cooldown rate: x%>
  181. # When cooldowns are applied from using skills in battle, the cooldown rate can
  182. # reduce or increase the finalized amount of turns a battler would need to wait
  183. # before being able to use that skill again.
  184. #
  185. # <warmup rate: x%>
  186. # Lowers/Raises the amount of turns needed to pass in battle before the warmup
  187. # skills become available for usage.
  188. #
  189. # -----------------------------------------------------------------------------
  190. # State Notetags - These notetags go in the states notebox in the database.
  191. # -----------------------------------------------------------------------------
  192. # <cooldown lock>
  193. # A battler afflicted with cooldown lock will not have cooldowns count down
  194. # every turn until the cooldown lock is removed.
  195. #
  196. # <cooldown rate: x%>
  197. # When cooldowns are applied from using skills in battle, the cooldown rate can
  198. # reduce or increase the finalized amount of turns a battler would need to wait
  199. # before being able to use that skill again.
  200. #
  201. # <warmup rate: x%>
  202. # Lowers/Raises the amount of turns needed to pass in battle before the warmup
  203. # skills become available for usage.
  204. #
  205. #==============================================================================
  206. # ¥ Compatibility
  207. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  208. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  209. # it will run with RPG Maker VX without adjusting.
  210. #
  211. #==============================================================================
  212.  
  213. module YEA
  214.   module SKILL_RESTRICT
  215.    
  216.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  217.     # - Cooldown Settings -
  218.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  219.     # Skills with cooldowns cannot be used for some number of turns. Adjust the
  220.     # settings here on how cooldowns appear in the menu. Cooldowns are only
  221.     # applied in battle.
  222.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  223.     COOLDOWN_COLOUR = 6          # Colour used from "Window" skin.
  224.     COOLDOWN_SIZE   = 20         # Font size used for cooldowns.
  225.     COOLDOWN_SUFFIX = "%sCD"     # Suffix used for cooldowns.
  226.     COOLDOWN_ICON   = 0          # Icon used for cooldowns. Set 0 to disable.
  227.    
  228.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  229.     # - Warmup Settings -
  230.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  231.     # Skills with warmups are unaffected by cooldowns. They become available to
  232.     # use after a certain number of turns have passed. Warmups are only applied
  233.     # in battle. Cooldown Rates do not affect warmups but Warmup Rates do.
  234.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  235.     WARMUP_COLOUR   = 5          # Colour used from "Window" skin.
  236.     WARMUP_SIZE     = 20         # Font size used for warmups.
  237.     WARMUP_SUFFIX   = "%sWU"     # Suffix used for warmups.
  238.     WARMUP_ICON     = 0          # Icon used for warmups. Set 0 to disable.
  239.    
  240.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  241.     # - Limited Use Settings -
  242.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  243.     # Some skills have limited uses per battle. These limited uses are reset
  244.     # at the start and end of each battle and do not apply when used outside of
  245.     # battle. There are no effects that can affect limited uses.
  246.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  247.     LIMITED_COLOUR  = 8          # Colour used from "Window" skin.
  248.     LIMITED_SIZE    = 16         # Font size used for used up.
  249.     LIMITED_TEXT    = "Used"     # Text used for used up.
  250.     LIMITED_ICON    = 0          # Icon used for used up. Set 0 to disable.
  251.    
  252.   end # SKILL_RESTRICT
  253. end # YEA
  254.  
  255. #==============================================================================
  256. # ¥ Editting anything past this point may potentially result in causing
  257. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  258. # halitosis so edit at your own risk.
  259. #==============================================================================
  260.  
  261. module YEA
  262.   module REGEXP
  263.   module BASEITEM
  264.    
  265.     COOLDOWN_RATE = /<(?:COOL_DOWN_RATE|cooldown rate):[ ](\d+)([%“])>/i
  266.     COOLDOWN_LOCK = /<(?:COOL_DOWN_LOCK|cooldown lock)>/i
  267.     WARMUP_RATE   = /<(?:WARM_UP_RATE|warmup rate):[ ](\d+)([%“])>/i
  268.    
  269.   end # BASEITEM
  270.   module SKILL
  271.    
  272.     COOLDOWN = /<(?:COOL_DOWN|cooldown):[ ](\d+)>/i
  273.     WARMUP   = /<(?:WARM_UP|warmup):[ ](\d+)>/i
  274.     LIMITED_USES = /<(?:LIMITED_USES|limited uses):[ ](\d+)>/i
  275.    
  276.     CHANGE_COOLDOWN = /<(?:CHANGE_COOL_DOWN|change cooldown):[ ]([\+\-]\d+)>/i
  277.     STYPE_COOLDOWN =
  278.       /<(?:STYPE_COOL_DOWN|stype cooldown)[ ](\d+):[ ]([\+\-]\d+)>/i
  279.     SKILL_COOLDOWN =
  280.       /<(?:SKILL_COOL_DOWN|skill cooldown)[ ](\d+):[ ]([\+\-]\d+)>/i
  281.      
  282.     RESTRICT_IF_SWITCH  =
  283.       /<(?:RESTRICT_IF_SWITCH|restrict if switch):[ ](\d+)>/i
  284.     RESTRICT_ANY_SWITCH =
  285.       /<(?:RESTRICT_ANY_SWITCH|restrict any switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  286.     RESTRICT_ALL_SWITCH =
  287.       /<(?:RESTRICT_ALL_SWITCH|restrict all switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  288.    
  289.     RESTRICT_EVAL_ON  = /<(?:RESTRICT_EVAL|restrict eval)>/i
  290.     RESTRICT_EVAL_OFF = /<\/(?:RESTRICT_EVAL|restrict eval)>/i
  291.    
  292.   end # SKILL
  293.   module ITEM
  294.    
  295.     CHANGE_COOLDOWN = /<(?:CHANGE_COOL_DOWN|change cooldown):[ ]([\+\-]\d+)>/i
  296.     STYPE_COOLDOWN =
  297.       /<(?:STYPE_COOL_DOWN|stype cooldown)[ ](\d+):[ ]([\+\-]\d+)>/i
  298.     SKILL_COOLDOWN =
  299.       /<(?:SKILL_COOL_DOWN|skill cooldown)[ ](\d+):[ ]([\+\-]\d+)>/i
  300.    
  301.   end # ITEM
  302.   end # REGEXP
  303. end # YEA
  304.  
  305. #==============================================================================
  306. # ¡ Icon
  307. #==============================================================================
  308.  
  309. module Icon
  310.  
  311.   #--------------------------------------------------------------------------
  312.   # self.cooldown
  313.   #--------------------------------------------------------------------------
  314.   def self.cooldown; return YEA::SKILL_RESTRICT::COOLDOWN_ICON; end
  315.  
  316.   #--------------------------------------------------------------------------
  317.   # self.warmup
  318.   #--------------------------------------------------------------------------
  319.   def self.warmup; return YEA::SKILL_RESTRICT::WARMUP_ICON; end
  320.  
  321.   #--------------------------------------------------------------------------
  322.   # self.limited
  323.   #--------------------------------------------------------------------------
  324.   def self.limited; return YEA::SKILL_RESTRICT::LIMITED_ICON; end
  325.    
  326. end # Icon
  327.  
  328. #==============================================================================
  329. # ¡ Numeric
  330. #==============================================================================
  331.  
  332. class Numeric
  333.  
  334.   #--------------------------------------------------------------------------
  335.   # new method: group_digits
  336.   #--------------------------------------------------------------------------
  337.   unless $imported["YEA-CoreEngine"]
  338.   def group; return self.to_s; end
  339.   end # $imported["YEA-CoreEngine"]
  340.    
  341. end # Numeric
  342.  
  343. #==============================================================================
  344. # ¡ DataManager
  345. #==============================================================================
  346.  
  347. module DataManager
  348.  
  349.   #--------------------------------------------------------------------------
  350.   # alias method: load_database
  351.   #--------------------------------------------------------------------------
  352.   class <<self; alias load_database_srs load_database; end
  353.   def self.load_database
  354.     load_database_srs
  355.     load_notetags_srs
  356.   end
  357.  
  358.   #--------------------------------------------------------------------------
  359.   # new method: load_notetags_srs
  360.   #--------------------------------------------------------------------------
  361.   def self.load_notetags_srs
  362.     groups = [$data_actors, $data_classes, $data_skills, $data_weapons,
  363.       $data_armors, $data_enemies, $data_states, $data_items]
  364.     for group in groups
  365.       for obj in group
  366.         next if obj.nil?
  367.         obj.load_notetags_srs
  368.       end
  369.     end
  370.   end
  371.  
  372. end # DataManager
  373.  
  374. #==============================================================================
  375. # ¡ RPG::BaseItem
  376. #==============================================================================
  377.  
  378. class RPG::BaseItem
  379.  
  380.   #--------------------------------------------------------------------------
  381.   # public instance variables
  382.   #--------------------------------------------------------------------------
  383.   attr_accessor :cooldown_rate
  384.   attr_accessor :cooldown_lock
  385.   attr_accessor :warmup_rate
  386.  
  387.   #--------------------------------------------------------------------------
  388.   # common cache: load_notetags_srs
  389.   #--------------------------------------------------------------------------
  390.   def load_notetags_srs
  391.     @cooldown_rate = 1.0
  392.     @warmup_rate = 1.0
  393.     #---
  394.     self.note.split(/[\r\n]+/).each { |line|
  395.       case line
  396.       #---
  397.       when YEA::REGEXP::BASEITEM::COOLDOWN_RATE
  398.         @cooldown_rate = $1.to_i * 0.01
  399.       when YEA::REGEXP::BASEITEM::COOLDOWN_LOCK
  400.         @cooldown_lock = true
  401.       when YEA::REGEXP::BASEITEM::WARMUP_RATE
  402.         @warmup_rate = $1.to_i * 0.01
  403.       #---
  404.       end
  405.     } # self.note.split
  406.     #---
  407.   end
  408.  
  409. end # RPG::BaseItem
  410.  
  411. #==============================================================================
  412. # ¡ RPG::Skill
  413. #==============================================================================
  414.  
  415. class RPG::Skill < RPG::UsableItem
  416.  
  417.   #--------------------------------------------------------------------------
  418.   # public instance variables
  419.   #--------------------------------------------------------------------------
  420.   attr_accessor :cooldown
  421.   attr_accessor :warmup
  422.   attr_accessor :limited_uses
  423.   attr_accessor :change_cooldown
  424.   attr_accessor :skill_cooldown
  425.   attr_accessor :restrict_any_switch
  426.   attr_accessor :restrict_all_switch
  427.   attr_accessor :restrict_eval
  428.  
  429.   #--------------------------------------------------------------------------
  430.   # common cache: load_notetags_srs
  431.   #--------------------------------------------------------------------------
  432.   def load_notetags_srs
  433.     @cooldown = 0
  434.     @warmup = 0
  435.     @limited_uses = 0
  436.     @change_cooldown = {}
  437.     @skill_cooldown = {}
  438.     @restrict_any_switch = []
  439.     @restrict_all_switch = []
  440.     @restrict_eval = ""
  441.     @restrict_eval_on = false
  442.     #---
  443.     self.note.split(/[\r\n]+/).each { |line|
  444.       case line
  445.       #---
  446.       when YEA::REGEXP::SKILL::COOLDOWN
  447.         @cooldown = $1.to_i
  448.       when YEA::REGEXP::SKILL::WARMUP
  449.         @warmup = $1.to_i
  450.       when YEA::REGEXP::SKILL::LIMITED_USES
  451.         @limited_uses = $1.to_i
  452.       #---
  453.       when YEA::REGEXP::SKILL::CHANGE_COOLDOWN
  454.         @change_cooldown[0] = $1.to_i
  455.       when YEA::REGEXP::SKILL::STYPE_COOLDOWN
  456.         @change_cooldown[$1.to_i] = $2.to_i
  457.       when YEA::REGEXP::SKILL::SKILL_COOLDOWN
  458.         @skill_cooldown[$1.to_i] = $2.to_i
  459.       #---
  460.       when YEA::REGEXP::SKILL::RESTRICT_IF_SWITCH
  461.         @restrict_any_switch.push($1.to_i)
  462.       when YEA::REGEXP::SKILL::RESTRICT_ANY_SWITCH
  463.         $1.scan(/\d+/).each { |num|
  464.         @restrict_any_switch.push(num.to_i) if num.to_i > 0 }
  465.       when YEA::REGEXP::SKILL::RESTRICT_ALL_SWITCH
  466.         $1.scan(/\d+/).each { |num|
  467.         @restrict_all_switch.push(num.to_i) if num.to_i > 0 }
  468.       #---
  469.       when YEA::REGEXP::SKILL::RESTRICT_EVAL_ON
  470.         @restrict_eval_on = true
  471.       when YEA::REGEXP::SKILL::RESTRICT_EVAL_OFF
  472.         @restrict_eval_off = true
  473.       else
  474.         @restrict_eval += line.to_s if @restrict_eval_on
  475.       #---
  476.       end
  477.     } # self.note.split
  478.     #---
  479.   end
  480.  
  481. end # RPG::Skill
  482.  
  483. #==============================================================================
  484. # ¡ RPG::Item
  485. #==============================================================================
  486.  
  487. class RPG::Item < RPG::UsableItem
  488.  
  489.   #--------------------------------------------------------------------------
  490.   # public instance variables
  491.   #--------------------------------------------------------------------------
  492.   attr_accessor :change_cooldown
  493.   attr_accessor :skill_cooldown
  494.  
  495.   #--------------------------------------------------------------------------
  496.   # common cache: load_notetags_srs
  497.   #--------------------------------------------------------------------------
  498.   def load_notetags_srs
  499.     @change_cooldown = {}
  500.     @skill_cooldown = {}
  501.     #---
  502.     self.note.split(/[\r\n]+/).each { |line|
  503.       case line
  504.       #---
  505.       when YEA::REGEXP::ITEM::CHANGE_COOLDOWN
  506.         @change_cooldown[0] = $1.to_i
  507.       when YEA::REGEXP::ITEM::STYPE_COOLDOWN
  508.         @change_cooldown[$1.to_i] = $2.to_i
  509.       when YEA::REGEXP::ITEM::SKILL_COOLDOWN
  510.         @skill_cooldown[$1.to_i] = $2.to_i
  511.       #---
  512.       end
  513.     } # self.note.split
  514.     #---
  515.   end
  516.  
  517. end # RPG::Item
  518.  
  519. #==============================================================================
  520. # ¡ Game_BattlerBase
  521. #==============================================================================
  522.  
  523. class Game_BattlerBase
  524.  
  525.   #--------------------------------------------------------------------------
  526.   # alias method: initialize
  527.   #--------------------------------------------------------------------------
  528.   alias game_battlerbase_initialize_srs initialize
  529.   def initialize
  530.     game_battlerbase_initialize_srs
  531.     reset_cooldowns
  532.     reset_times_used
  533.   end
  534.  
  535.   #--------------------------------------------------------------------------
  536.   # new method: reset_cooldowns
  537.   #--------------------------------------------------------------------------
  538.   def reset_cooldowns
  539.     @cooldown = {}
  540.   end
  541.  
  542.   #--------------------------------------------------------------------------
  543.   # new method: reset_times_used
  544.   #--------------------------------------------------------------------------
  545.   def reset_times_used
  546.     @times_used = {}
  547.   end
  548.  
  549.   #--------------------------------------------------------------------------
  550.   # alias method: skill_conditions_met?
  551.   #--------------------------------------------------------------------------
  552.   alias game_battlerbase_skill_conditions_met_srs skill_conditions_met?
  553.   def skill_conditions_met?(skill)
  554.     return false if skill_restriction?(skill)
  555.     return game_battlerbase_skill_conditions_met_srs(skill)
  556.   end
  557.  
  558.   #--------------------------------------------------------------------------
  559.   # alias method: pay_skill_cost
  560.   #--------------------------------------------------------------------------
  561.   alias game_battlerbase_pay_skill_cost_srs pay_skill_cost
  562.   def pay_skill_cost(skill)
  563.     game_battlerbase_pay_skill_cost_srs(skill)
  564.     pay_skill_cooldown(skill)
  565.   end
  566.  
  567.   #--------------------------------------------------------------------------
  568.   # new method: skill_restriction?
  569.   #--------------------------------------------------------------------------
  570.   def skill_restriction?(skill)
  571.     if $game_party.in_battle
  572.       return true if cooldown?(skill) > 0
  573.       return true if warmup?(skill) > $game_troop.turn_count
  574.       return true if limit_restricted?(skill)
  575.     end
  576.     return true if switch_restricted?(skill)
  577.     return true if restrict_eval?(skill)
  578.     return false
  579.   end
  580.  
  581.   #--------------------------------------------------------------------------
  582.   # new method: cooldown?
  583.   #--------------------------------------------------------------------------
  584.   def cooldown?(skill)
  585.     skill = skill.id if skill.is_a?(RPG::Skill)
  586.     return @cooldown[skill].nil? ? 0 : @cooldown[skill]
  587.   end
  588.  
  589.   #--------------------------------------------------------------------------
  590.   # new method: warmup?(skill)
  591.   #--------------------------------------------------------------------------
  592.   def warmup?(skill)
  593.     skill = skill.id if skill.is_a?(RPG::Skill)
  594.     return [$data_skills[skill].warmup * wur, 0].max.to_i
  595.   end
  596.  
  597.   #--------------------------------------------------------------------------
  598.   # new method: limit_restricted?
  599.   #--------------------------------------------------------------------------
  600.   def limit_restricted?(skill)
  601.     return false if skill.limited_uses <= 0
  602.     return times_used?(skill) >= skill.limited_uses
  603.   end
  604.  
  605.   #--------------------------------------------------------------------------
  606.   # new method: times_used?
  607.   #--------------------------------------------------------------------------
  608.   def times_used?(skill)
  609.     skill = skill.id if skill.is_a?(RPG::Skill)
  610.     return @times_used[skill].nil? ? 0 : @times_used[skill]
  611.   end
  612.  
  613.   #--------------------------------------------------------------------------
  614.   # new method: update_times_used
  615.   #--------------------------------------------------------------------------
  616.   def update_times_used(skill)
  617.     skill = skill.id if skill.is_a?(RPG::Skill)
  618.     reset_times_used if @times_used.nil?
  619.     @times_used[skill] = 0 if @times_used[skill].nil?
  620.     @times_used[skill] += 1
  621.   end
  622.  
  623.   #--------------------------------------------------------------------------
  624.   # new method: cdr
  625.   #--------------------------------------------------------------------------
  626.   def cdr
  627.     n = 1.0
  628.     if actor?
  629.       n *= self.actor.cooldown_rate
  630.       n *= self.class.cooldown_rate
  631.       for equip in equips
  632.         next if equip.nil?
  633.         n *= equip.cooldown_rate
  634.       end
  635.     else
  636.       n *= self.enemy.cooldown_rate
  637.       if $imported["YEA-Doppelganger"] && !self.class.nil?
  638.         n *= self.class.cooldown_rate
  639.       end
  640.     end
  641.     for state in states
  642.       next if state.nil?
  643.       n *= state.cooldown_rate
  644.     end
  645.     return n
  646.   end
  647.  
  648.   #--------------------------------------------------------------------------
  649.   # new method: pay_skill_cooldown
  650.   #--------------------------------------------------------------------------
  651.   def pay_skill_cooldown(skill)
  652.     return unless $game_party.in_battle
  653.     skill = skill.id if skill.is_a?(RPG::Skill)
  654.     set_cooldown(skill, $data_skills[skill].cooldown * cdr)
  655.   end
  656.  
  657.   #--------------------------------------------------------------------------
  658.   # new method: set_cooldown
  659.   #--------------------------------------------------------------------------
  660.   def set_cooldown(skill, amount = 0)
  661.     return unless $game_party.in_battle
  662.     skill = skill.id if skill.is_a?(RPG::Skill)
  663.     @cooldown[skill] = [amount, 0].max.to_i
  664.   end
  665.  
  666.   #--------------------------------------------------------------------------
  667.   # new method: cooldown_lock?
  668.   #--------------------------------------------------------------------------
  669.   def cooldown_lock?
  670.     if actor?
  671.       return true if self.actor.cooldown_lock
  672.       return true if self.class.cooldown_lock
  673.       for equip in equips
  674.         next if equip.nil?
  675.         return true if equip.cooldown_lock
  676.       end
  677.     else
  678.       return true if self.enemy.cooldown_lock
  679.     end
  680.     for state in states
  681.       next if state.nil?
  682.       return true if state.cooldown_lock
  683.     end
  684.     return false
  685.   end
  686.  
  687.   #--------------------------------------------------------------------------
  688.   # new method: update_cooldowns
  689.   #--------------------------------------------------------------------------
  690.   def update_cooldowns(amount = -1, stype_id = 0, skill_id = 0)
  691.     return if cooldown_lock?
  692.     reset_cooldowns if @cooldown.nil?
  693.     data_array = skills + [1, 2]
  694.     for skill in data_array
  695.       skill = $data_skills[skill] if !skill.is_a?(RPG::Skill)
  696.       next if stype_id != 0 && skill.stype_id != stype_id
  697.       next if skill_id != 0 && skill.id != skill_id
  698.       set_cooldown(skill, cooldown?(skill) + amount)
  699.     end
  700.   end
  701.  
  702.   #--------------------------------------------------------------------------
  703.   # new method: wur
  704.   #--------------------------------------------------------------------------
  705.   def wur
  706.     n = 1.0
  707.     if actor?
  708.       n *= self.actor.warmup_rate
  709.       n *= self.class.warmup_rate
  710.       for equip in equips
  711.         next if equip.nil?
  712.         n *= equip.warmup_rate
  713.       end
  714.     else
  715.       n *= self.enemy.warmup_rate
  716.       if $imported["YEA-Doppelganger"] && !self.class.nil?
  717.         n *= self.class.warmup_rate
  718.       end
  719.     end
  720.     for state in states
  721.       next if state.nil?
  722.       n *= state.warmup_rate
  723.     end
  724.     return n
  725.   end
  726.  
  727.   #--------------------------------------------------------------------------
  728.   # new method: switch_restricted?
  729.   #--------------------------------------------------------------------------
  730.   def switch_restricted?(skill)
  731.     return true if restrict_any_switch?(skill)
  732.     return true if restrict_all_switch?(skill)
  733.     return false
  734.   end
  735.  
  736.   #--------------------------------------------------------------------------
  737.   # new method: restrict_any_switch?
  738.   #--------------------------------------------------------------------------
  739.   def restrict_any_switch?(skill)
  740.     for switch_id in skill.restrict_any_switch
  741.       return true if $game_switches[switch_id]
  742.     end
  743.     return false
  744.   end
  745.  
  746.   #--------------------------------------------------------------------------
  747.   # new method: restrict_all_switch?
  748.   #--------------------------------------------------------------------------
  749.   def restrict_all_switch?(skill)
  750.     return false if skill.restrict_all_switch == []
  751.     for switch_id in skill.restrict_all_switch
  752.       return false unless $game_switches[switch_id]
  753.     end
  754.     return true
  755.   end
  756.  
  757.   #--------------------------------------------------------------------------
  758.   # new method: restrict_eval?
  759.   #--------------------------------------------------------------------------
  760.   def restrict_eval?(skill)
  761.     return false if skill.restrict_eval == ""
  762.     return eval(skill.restrict_eval)
  763.   end
  764.  
  765. end # Game_BattlerBase
  766.  
  767. #==============================================================================
  768. # ¡ Game_Battler
  769. #==============================================================================
  770.  
  771. class Game_Battler < Game_BattlerBase
  772.  
  773.   #--------------------------------------------------------------------------
  774.   # alias method: on_battle_start
  775.   #--------------------------------------------------------------------------
  776.   alias game_battler_on_battle_start_srs on_battle_start
  777.   def on_battle_start
  778.     game_battler_on_battle_start_srs
  779.     reset_cooldowns
  780.     reset_times_used
  781.   end
  782.  
  783.   #--------------------------------------------------------------------------
  784.   # alias method: on_battle_end
  785.   #--------------------------------------------------------------------------
  786.   alias game_battler_on_battle_end_srs on_battle_end
  787.   def on_battle_end
  788.     game_battler_on_battle_end_srs
  789.     reset_cooldowns
  790.     reset_times_used
  791.   end
  792.  
  793.   #--------------------------------------------------------------------------
  794.   # alias method: item_apply
  795.   #--------------------------------------------------------------------------
  796.   alias game_battler_item_apply_srs item_apply
  797.   def item_apply(user, item)
  798.     game_battler_item_apply_srs(user, item)
  799.     updated_limited_uses(user, item)
  800.   end
  801.  
  802.   #--------------------------------------------------------------------------
  803.   # new method: updated_limited_uses
  804.   #--------------------------------------------------------------------------
  805.   def updated_limited_uses(user, item)
  806.     return unless $game_party.in_battle
  807.     return if item.nil?
  808.     return unless item.is_a?(RPG::Skill)
  809.     user.update_times_used(item)
  810.   end
  811.  
  812.   #--------------------------------------------------------------------------
  813.   # alias method: item_user_effect
  814.   #--------------------------------------------------------------------------
  815.   alias game_battler_item_user_effect_srs item_user_effect
  816.   def item_user_effect(user, item)
  817.     game_battler_item_user_effect_srs(user, item)
  818.     apply_cooldown_changes(user, item)
  819.   end
  820.  
  821.   #--------------------------------------------------------------------------
  822.   # new method: apply_cooldown_changes
  823.   #--------------------------------------------------------------------------
  824.   def apply_cooldown_changes(user, item)
  825.     return unless $game_party.in_battle
  826.     return if item.nil?
  827.     #---
  828.     if item.change_cooldown != {}
  829.       for key in item.change_cooldown
  830.         stype_id = key[0]
  831.         update_cooldowns(item.change_cooldown[stype_id], stype_id)
  832.       end
  833.       @result.success = true
  834.     end
  835.     #---
  836.     if item.skill_cooldown != {}
  837.       for key in item.skill_cooldown
  838.         skill_id = key[0]
  839.         update_cooldowns(item.skill_cooldown[skill_id], 0, skill_id)
  840.       end
  841.       @result.success = true
  842.     end
  843.   end
  844.  
  845. end # Game_Battler
  846.  
  847. #==============================================================================
  848. # ¡ Game_Enemy
  849. #==============================================================================
  850.  
  851. class Game_Enemy < Game_Battler
  852.  
  853.   #--------------------------------------------------------------------------
  854.   # new method: skills
  855.   #--------------------------------------------------------------------------
  856.   def skills
  857.     data = []
  858.     for action in enemy.actions
  859.       next if data.include?(action.skill_id)
  860.       data.push(action.skill_id)
  861.     end
  862.     return data
  863.   end
  864.  
  865. end # Game_Enemy
  866.  
  867. #==============================================================================
  868. # ¡ Game_Unit
  869. #==============================================================================
  870.  
  871. class Game_Unit
  872.  
  873.   #--------------------------------------------------------------------------
  874.   # new method: update_restrictions
  875.   #--------------------------------------------------------------------------
  876.   def update_restrictions
  877.     for member in members; member.update_cooldowns; end
  878.   end
  879.  
  880. end # Game_Unit
  881.  
  882. #==============================================================================
  883. # ¡ Window_Base
  884. #==============================================================================
  885.  
  886. class Window_Base < Window
  887.  
  888.   #--------------------------------------------------------------------------
  889.   # new methods: restrict_colours
  890.   #--------------------------------------------------------------------------
  891.   def cooldown_colour; text_color(YEA::SKILL_RESTRICT::COOLDOWN_COLOUR); end;
  892.   def warmup_colour; text_color(YEA::SKILL_RESTRICT::WARMUP_COLOUR); end;
  893.   def limited_colour; text_color(YEA::SKILL_RESTRICT::LIMITED_COLOUR); end;
  894.  
  895. end # Window_Base
  896.  
  897. #==============================================================================
  898. # ¡ Window_SkillList
  899. #==============================================================================
  900.  
  901. class Window_SkillList < Window_Selectable
  902.  
  903.   #--------------------------------------------------------------------------
  904.   # alias method: draw_item
  905.   #--------------------------------------------------------------------------
  906.   alias window_skilllist_draw_item_srs draw_item
  907.   def draw_item(index)
  908.     if skill_restriction?(index)
  909.       draw_skill_restriction(index)
  910.     else
  911.       window_skilllist_draw_item_srs(index)
  912.     end
  913.   end
  914.  
  915.   #--------------------------------------------------------------------------
  916.   # new method: skill_restriction?
  917.   #--------------------------------------------------------------------------
  918.   def skill_restriction?(index)
  919.     skill = @data[index]
  920.     return false if @actor.nil?
  921.     return @actor.skill_restriction?(skill)
  922.   end
  923.  
  924.   #--------------------------------------------------------------------------
  925.   # new method: draw_item
  926.   #--------------------------------------------------------------------------
  927.   def draw_skill_restriction(index)
  928.     skill = @data[index]
  929.     rect = item_rect(index)
  930.     rect.width -= 4
  931.     draw_item_name(skill, rect.x, rect.y, enable?(skill))
  932.     if @actor.limit_restricted?(skill)
  933.       draw_skill_limited(rect, skill)
  934.     elsif @actor.cooldown?(skill) > 0
  935.       draw_skill_cooldown(rect, skill)
  936.     elsif warmup_restriction?(skill)
  937.       draw_skill_warmup(rect, skill)
  938.     else
  939.       draw_skill_cost(rect, skill)
  940.     end
  941.   end
  942.  
  943.   #--------------------------------------------------------------------------
  944.   # new method: draw_skill_limited
  945.   #--------------------------------------------------------------------------
  946.   def draw_skill_limited(rect, skill)
  947.     change_color(limited_colour, enable?(skill))
  948.     icon = Icon.limited
  949.     if icon > 0
  950.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  951.       rect.width -= 24
  952.     end
  953.     contents.font.size = YEA::SKILL_RESTRICT::LIMITED_SIZE
  954.     text = YEA::SKILL_RESTRICT::LIMITED_TEXT
  955.     draw_text(rect, text, 2)
  956.     reset_font_settings
  957.   end
  958.  
  959.   #--------------------------------------------------------------------------
  960.   # new method: draw_skill_cooldown
  961.   #--------------------------------------------------------------------------
  962.   def draw_skill_cooldown(rect, skill)
  963.     change_color(cooldown_colour, enable?(skill))
  964.     icon = Icon.cooldown
  965.     if icon > 0
  966.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  967.       rect.width -= 24
  968.     end
  969.     contents.font.size = YEA::SKILL_RESTRICT::COOLDOWN_SIZE
  970.     value = @actor.cooldown?(skill)
  971.     text = sprintf(YEA::SKILL_RESTRICT::COOLDOWN_SUFFIX, value.group)
  972.     draw_text(rect, text, 2)
  973.     reset_font_settings
  974.   end
  975.  
  976.   #--------------------------------------------------------------------------
  977.   # new method: warmup_restriction?
  978.   #--------------------------------------------------------------------------
  979.   def warmup_restriction?(skill)
  980.     return false unless $game_party.in_battle
  981.     return @actor.warmup?(skill) > $game_troop.turn_count
  982.   end
  983.  
  984.   #--------------------------------------------------------------------------
  985.   # new method: draw_skill_warmup
  986.   #--------------------------------------------------------------------------
  987.   def draw_skill_warmup(rect, skill)
  988.     change_color(warmup_colour, enable?(skill))
  989.     icon = Icon.warmup
  990.     if icon > 0
  991.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  992.       rect.width -= 24
  993.     end
  994.     contents.font.size = YEA::SKILL_RESTRICT::WARMUP_SIZE
  995.     value = @actor.warmup?(skill) - $game_troop.turn_count
  996.     text = sprintf(YEA::SKILL_RESTRICT::WARMUP_SUFFIX, value.group)
  997.     draw_text(rect, text, 2)
  998.     reset_font_settings
  999.   end
  1000.  
  1001. end # Window_SkillList
  1002.  
  1003. #==============================================================================
  1004. # ¡ Scene_Battle
  1005. #==============================================================================
  1006.  
  1007. class Scene_Battle < Scene_Base
  1008.  
  1009.   #--------------------------------------------------------------------------
  1010.   # alias method: turn_start
  1011.   #--------------------------------------------------------------------------
  1012.   alias scene_battle_turn_start_srs turn_start
  1013.   def turn_start
  1014.     $game_party.update_restrictions
  1015.     $game_troop.update_restrictions
  1016.     scene_battle_turn_start_srs
  1017.   end
  1018.  
  1019. end # Scene_Battle
  1020.  
  1021. #==============================================================================
  1022. #
  1023. # ¥ End of File
  1024. #
  1025. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement