Advertisement
Feldherren

VXAce - Minimum/Maximum TP Requirements for Skills

Aug 31st, 2013
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.09 KB | None | 0 0
  1. # Minimum/Maximum TP Requirements for Skills v1.0
  2. # by Feldherren (with plenty of help from GubiD)
  3. #
  4. # For VXAce
  5. #
  6. # Ever played Super Robot Wars or Battle of the Youstrass?
  7. # Sometimes, in these games, attack usability depends on the pilot's will, or
  8. # morale, which fluctuates over the course of the battle; if the character's
  9. # in too much of a bad mood, they can't bust out their Super Ultra Finishing
  10. # Move, even if they meet all other costs
  11. # This is an attempt at implementing this for VX Ace, allowing skills to have
  12. # minimum and maximum TP requirements; if TP is lower than or higher than a
  13. # given value specified in the skill notebox, the skill will be unusable.
  14. # This is independent of skill TP cost; it only determines whether a skill is
  15. # available for use.
  16. #
  17. # Usage
  18. # Add <tpmin=[value]> or <tpmax=[value]> to a skill's notebox; this will be the
  19. # minimum or maximum TP value required to use the skill.
  20. #
  21. # Alternatively, you can use the script command [skill].tpmax=[value] to
  22. # change the requirement for the skill in-game.
  23.  
  24. class Game_BattlerBase
  25.   alias skill_conditions_met_tp_min skill_conditions_met?
  26.   #--------------------------------------------------------------------------
  27.   # * Check TP Conditions for Skill
  28.   #--------------------------------------------------------------------------
  29.   def skill_conditions_met?(skill)
  30.     result = skill_conditions_met_tp_min(skill)
  31.     if result && skill.min_tp_cost?
  32.       result = self.tp >= skill.tpmin
  33.     end
  34.     if result && skill.max_tp_cost?
  35.       result = self.tp <= skill.tpmax
  36.     end
  37.     result
  38.   end
  39. end
  40.  
  41. class RPG::Skill < RPG::UsableItem
  42.   def min_tp_cost?
  43.     tpmin != nil
  44.   end
  45.   def max_tp_cost?
  46.     tpmax != nil
  47.   end
  48.   def tpmin
  49.     return @tpmin if @tpmin
  50.     if (match = self.note.match( /^<mintp\s*=\s*(\d+)>/i ))
  51.       return match[1].to_i
  52.     end
  53.   end
  54.   def tpmax
  55.     return @tpmax if @tpmax
  56.     if (match = self.note.match( /^<maxtp\s*=\s*(\d+)>/i ))
  57.       return match[1].to_i
  58.     end
  59.   end
  60.   def tpmin=(val)
  61.     @tpmin=val
  62.   end
  63.   def tpmax=(val)
  64.     @tpmax=val
  65.   end
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement