Guest User

Untitled

a guest
Apr 22nd, 2011
1,035
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.30 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Shanghai Simple Script - Break Max Stats
  4. # Last Date Updated: 2010.06.18
  5. # Level: Normal
  6. #
  7. # By default, there's maximum HP and MP of 9999 and for regular stats, a growth
  8. # of 999. This kinda sucks for big, long games that extend their HP and MP
  9. # growth past 9999 and their regular stats past 999. You can set what you want
  10. # with them. This script looks through all of an actor's equipment and sees if
  11. # they have any stat limit breaking properties.
  12. #===============================================================================
  13. # Instructions
  14. # -----------------------------------------------------------------------------
  15. # To install this script, open up your script editor and copy/paste this script
  16. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  17. #
  18. # <break maxhp: x>
  19. # <break maxmp: x>
  20. # <break param: x>
  21. # Place these note tags into the noteboxes of your equipment to make them have
  22. # the stat limit breaking properties. x is the new max limit. If multiple equips
  23. # are worn with stat limit breaking properties, then the one with the highest
  24. # max limit will be used.
  25. #
  26. # To ensure better compatibility between this script with others, place this
  27. # script above most of your scripts, but under anything like KGC's Limit Breaker
  28. # or Yanfly's Core Fixes and Upgrades.
  29. #===============================================================================
  30.  
  31. $imported = {} if $imported == nil
  32. $imported["BreakMaxStats"] = true
  33.  
  34. module SSS
  35.   # These set the default limits for each of the following stats.
  36.   DEFAULT_MAXHP_LIMIT = 9999
  37.   DEFAULT_MAXMP_LIMIT = 9999
  38.   DEFAULT_PARAM_LIMIT = 999
  39. end
  40.  
  41. #==============================================================================
  42. # RPG::BaseItem
  43. #==============================================================================
  44.  
  45. class RPG::BaseItem
  46.   #--------------------------------------------------------------------------
  47.   # break_limits
  48.   #--------------------------------------------------------------------------
  49.   def break_limits
  50.     return @break_limits if @break_limits != nil
  51.     @break_limits = {
  52.       :maxhp => SSS::DEFAULT_MAXHP_LIMIT,
  53.       :maxmp => SSS::DEFAULT_MAXMP_LIMIT,
  54.       :param => SSS::DEFAULT_PARAM_LIMIT,
  55.     }
  56.     self.note.split(/[\r\n]+/).each { |line|
  57.       case line
  58.       when /<(?:BREAK|break)[ ](.*):[ ](\d+)>/i
  59.         case $1.upcase
  60.         when "HP", "MAXHP"
  61.           @break_limits[:maxhp] = $2.to_i
  62.         when "MP", "MAXMP"
  63.           @break_limits[:maxmp] = $2.to_i
  64.         when "STATS", "PARAMETERS", "STAT", "PARAM"
  65.           @break_limits[:param] = $2.to_i
  66.         end
  67.       end
  68.     }
  69.     return @break_limits
  70.   end
  71. end
  72.  
  73. #==============================================================================
  74. # ** Game_Temp
  75. #==============================================================================
  76.  
  77. class Game_Temp
  78.   #--------------------------------------------------------------------------
  79.   # * Public Instance Variables
  80.   #--------------------------------------------------------------------------
  81.   attr_accessor :calcd_limits
  82. end
  83.  
  84. #==============================================================================
  85. # ** Game_Battler
  86. #==============================================================================
  87.  
  88. class Game_Battler
  89.   #--------------------------------------------------------------------------
  90.   # * Get Maximum MP
  91.   #--------------------------------------------------------------------------
  92.   unless method_defined?(:maxmp_limit)
  93.   def maxmp
  94.     return [[base_maxmp + @maxmp_plus, 0].max, maxmp_limit].min
  95.   end
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # * Get Maximum STATS
  99.   #--------------------------------------------------------------------------
  100.   unless method_defined?(:parameter_limit)
  101.   def atk
  102.     n = [[base_atk + @atk_plus, 1].max, parameter_limit].min
  103.     for state in states do n *= state.atk_rate / 100.0 end
  104.     n = [[Integer(n), 1].max, parameter_limit].min
  105.     return n
  106.   end
  107.   def def
  108.     n = [[base_def + @def_plus, 1].max, parameter_limit].min
  109.     for state in states do n *= state.def_rate / 100.0 end
  110.     n = [[Integer(n), 1].max, parameter_limit].min
  111.     return n
  112.   end
  113.   def spi
  114.     n = [[base_spi + @spi_plus, 1].max, parameter_limit].min
  115.     for state in states do n *= state.spi_rate / 100.0 end
  116.     n = [[Integer(n), 1].max, parameter_limit].min
  117.     return n
  118.   end
  119.   def agi
  120.     n = [[base_agi + @agi_plus, 1].max, parameter_limit].min
  121.     for state in states do n *= state.agi_rate / 100.0 end
  122.     n = [[Integer(n), 1].max, parameter_limit].min
  123.     return n
  124.   end
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # * Get Maximum MP Limit
  128.   #--------------------------------------------------------------------------
  129.   def maxmp_limit
  130.     return SSS::DEFAULT_MAXMP_LIMIT
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # * Get Maximum Parameter Limit
  134.   #--------------------------------------------------------------------------
  135.   def parameter_limit
  136.     return SSS::DEFAULT_PARAM_LIMIT
  137.   end
  138. end
  139.  
  140. #==============================================================================
  141. # ** Game_Actor
  142. #==============================================================================
  143.  
  144. class Game_Actor < Game_Battler
  145.   #--------------------------------------------------------------------------
  146.   # * Get Maximum HP Limit
  147.   #--------------------------------------------------------------------------
  148.   def maxhp_limit
  149.     return @new_maxhp_limit unless @new_maxhp_limit.nil?
  150.     return SSS::DEFAULT_MAXHP_LIMIT
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # * Get Maximum MP Limit
  154.   #--------------------------------------------------------------------------
  155.   def maxmp_limit
  156.     return @new_maxmp_limit unless @new_maxmp_limit.nil?
  157.     return SSS::DEFAULT_MAXMP_LIMIT
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # * Get Maximum Parameter Limit
  161.   #--------------------------------------------------------------------------
  162.   def parameter_limit
  163.     return @new_param_limit unless @new_param_limit.nil?
  164.     return SSS::DEFAULT_PARAM_LIMIT
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # * Calculate New Limits
  168.   #--------------------------------------------------------------------------
  169.   def calculate_new_limits
  170.     @new_maxhp_limit = SSS::DEFAULT_MAXHP_LIMIT
  171.     @new_maxmp_limit = SSS::DEFAULT_MAXMP_LIMIT
  172.     @new_param_limit = SSS::DEFAULT_PARAM_LIMIT
  173.     for equip in equips.compact
  174.       @new_maxhp_limit = [@new_maxhp_limit, equip.break_limits[:maxhp]].max
  175.       @new_maxmp_limit = [@new_maxmp_limit, equip.break_limits[:maxmp]].max
  176.       @new_param_limit = [@new_param_limit, equip.break_limits[:param]].max
  177.     end
  178.     clear_battle_cache if $imported["BattleEngineMelody"]
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # * Change Equipment (designate object)
  182.   #--------------------------------------------------------------------------
  183.   alias change_equip_sss_break_max_stats change_equip unless $@
  184.   def change_equip(equip_type, item, test = false)
  185.     change_equip_sss_break_max_stats(equip_type, item, test)
  186.     calculate_new_limits
  187.   end
  188. end
  189.  
  190. #==============================================================================
  191. # ** Scene_Map
  192. #==============================================================================
  193.  
  194. class Scene_Map < Scene_Base
  195.   #--------------------------------------------------------------------------
  196.   # * Start processing
  197.   #--------------------------------------------------------------------------
  198.   alias start_sss_break_max_stats start unless $@
  199.   def start
  200.     start_sss_break_max_stats
  201.     return if $game_temp.calcd_limits
  202.     $game_temp.calcd_limits = true
  203.     for i in 0..$data_actors.size
  204.       actor = $game_actors[i]
  205.       next if actor.nil?
  206.       actor.calculate_new_limits
  207.     end
  208.   end
  209. end
  210.  
  211. #===============================================================================
  212. #
  213. # END OF FILE
  214. #
  215. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment