Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2011
773
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 16.03 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Shanghai Simple Script - Temporary Stat Boosts
  4. # Last Date Updated: 2010.05.22
  5. # Level: Normal
  6. #
  7. # Temporary stat boosts only last during battle. After battle, they're cleared
  8. # and everything returns back to normal.
  9. #===============================================================================
  10. # Instructions
  11. # -----------------------------------------------------------------------------
  12. # To install this script, open up your script editor and copy/paste this script
  13. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  14. #
  15. # These are for items and skills.
  16. #
  17. # <target temp stat: +x>
  18. # <target temp stat: -x>
  19. # Gives a temporary boost of x for the stat to target of skill. Replace "stat"
  20. #   maxhp, maxmp, atk, def, spi, agi, hit, eva, cri, odds, dex, or res
  21. #
  22. # <user temp stat: +x>
  23. # <user temp stat: -x>
  24. # Gives a temporary boost of x for the stat to user of skill. Replace "stat"
  25. #   maxhp, maxmp, atk, def, spi, agi, hit, eva, cri, odds, dex, or res
  26. #
  27. # <clear temp stats: user>
  28. # <clear temp stats: target>
  29. # Will clear the temp stats for the user or target.
  30. #===============================================================================
  31.  
  32. $imported = {} if $imported == nil
  33. $imported["TemporaryStatBoosts"] = true
  34.  
  35. #==============================================================================
  36. # RPG::BaseItem
  37. #==============================================================================
  38.  
  39. class RPG::BaseItem
  40.   #--------------------------------------------------------------------------
  41.   # target_temp_boost
  42.   #--------------------------------------------------------------------------
  43.   def target_temp_boost
  44.     return @target_temp_boost if @target_temp_boost != nil
  45.     @target_temp_boost = {:maxhp => 0, :maxmp => 0, :atk => 0, :def => 0,
  46.       :spi => 0, :agi => 0, :hit => 0, :eva => 0, :cri => 0, :odds => 0,
  47.       :dex => 0, :res => 0}
  48.     self.note.split(/[\r\n]+/).each { |line|
  49.       case line
  50.       when /<(?:TARGET TEMPORARY|target temp)[ ](.*):[ ]([\+\-]\d+)>/i
  51.         case $1.upcase
  52.         when "MAXHP"
  53.           @target_temp_boost[:maxhp] = $2.to_i
  54.         when "MAXMP"
  55.           @target_temp_boost[:maxmp] = $2.to_i
  56.         when "ATK"
  57.           @target_temp_boost[:atk] = $2.to_i
  58.         when "DEF"
  59.           @target_temp_boost[:def] = $2.to_i
  60.         when "SPI"
  61.           @target_temp_boost[:spi] = $2.to_i
  62.         when "AGI"
  63.           @target_temp_boost[:agi] = $2.to_i
  64.         when "HIT"
  65.           @target_temp_boost[:hit] = $2.to_i
  66.         when "EVA"
  67.           @target_temp_boost[:eva] = $2.to_i
  68.         when "CRI"
  69.           @target_temp_boost[:cri] = $2.to_i
  70.         when "ODDS"
  71.           @target_temp_boost[:odds] = $2.to_i
  72.         when "DEX"
  73.           @target_temp_boost[:dex] = $2.to_i
  74.         when "RES"
  75.           @target_temp_boost[:res] = $2.to_i
  76.         end
  77.       end
  78.     }
  79.     return @target_temp_boost
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # user_temp_boost
  83.   #--------------------------------------------------------------------------
  84.   def user_temp_boost
  85.     return @user_temp_boost if @user_temp_boost != nil
  86.     @user_temp_boost = {:maxhp => 0, :maxmp => 0, :atk => 0, :def => 0,
  87.       :spi => 0, :agi => 0, :hit => 0, :eva => 0, :cri => 0, :odds => 0,
  88.       :dex => 0, :res => 0}
  89.     self.note.split(/[\r\n]+/).each { |line|
  90.       case line
  91.       when /<(?:USER TEMPORARY|user temp)[ ](.*):[ ]([\+\-]\d+)>/i
  92.         case $1.upcase
  93.         when "MAXHP"
  94.           @user_temp_boost[:maxhp] = $2.to_i
  95.         when "MAXMP"
  96.           @user_temp_boost[:maxmp] = $2.to_i
  97.         when "ATK"
  98.           @user_temp_boost[:atk] = $2.to_i
  99.         when "DEF"
  100.           @user_temp_boost[:def] = $2.to_i
  101.         when "SPI"
  102.           @user_temp_boost[:spi] = $2.to_i
  103.         when "AGI"
  104.           @user_temp_boost[:agi] = $2.to_i
  105.         when "HIT"
  106.           @user_temp_boost[:hit] = $2.to_i
  107.         when "EVA"
  108.           @user_temp_boost[:eva] = $2.to_i
  109.         when "CRI"
  110.           @user_temp_boost[:cri] = $2.to_i
  111.         when "ODDS"
  112.           @user_temp_boost[:odds] = $2.to_i
  113.         when "DEX"
  114.           @user_temp_boost[:dex] = $2.to_i
  115.         when "RES"
  116.           @user_temp_boost[:res] = $2.to_i
  117.         end
  118.       end
  119.     }
  120.     return @user_temp_boost
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # clear_temp_stats
  124.   #--------------------------------------------------------------------------
  125.   def clear_temp_stats
  126.     return @clear_temp_stats if @clear_temp_stats != nil
  127.     @clear_temp_stats = {:user => false, :target => false}
  128.     self.note.split(/[\r\n]+/).each { |line|
  129.       case line
  130.       when /<(?:CLEAR TEMP STATS|clear temp boosts)[ ](.*)>/i
  131.         case $1.upcase
  132.         when "USER"
  133.           @clear_temp_stats[:user] = true
  134.         when "TARGET", "TARGETS"
  135.           @clear_temp_stats[:target] = true
  136.         end
  137.       end
  138.     }
  139.     return @clear_temp_stats
  140.   end
  141. end
  142.  
  143. #==============================================================================
  144. # ** Game_Battler
  145. #==============================================================================
  146.  
  147. class Game_Battler
  148.   #--------------------------------------------------------------------------
  149.   # * Object Initialization
  150.   #--------------------------------------------------------------------------
  151.   alias initialize_sss_temp_stat_boosts initialize unless $@
  152.   def initialize
  153.     initialize_sss_temp_stat_boosts
  154.     clear_temp_stat_boosts
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # * Clear Temp Stat Boosts
  158.   #--------------------------------------------------------------------------
  159.   def clear_temp_stat_boosts
  160.     @temp_maxhp_boost = 0
  161.     @temp_maxmp_boost = 0
  162.     @temp_atk_boost = 0
  163.     @temp_def_boost = 0
  164.     @temp_spi_boost = 0
  165.     @temp_agi_boost = 0
  166.     @temp_hit_boost = 0
  167.     @temp_eva_boost = 0
  168.     @temp_cri_boost = 0
  169.     @temp_odds_boost = 0
  170.     @temp_dex_boost = 0
  171.     @temp_res_boost = 0
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # * Apply Temp Boost
  175.   #--------------------------------------------------------------------------
  176.   def apply_temp_boost(hash)
  177.     @temp_maxhp_boost += hash[:maxhp]
  178.     @temp_maxmp_boost += hash[:maxmp]
  179.     @temp_atk_boost += hash[:atk]
  180.     @temp_def_boost += hash[:def]
  181.     @temp_spi_boost += hash[:spi]
  182.     @temp_agi_boost += hash[:agi]
  183.     @temp_hit_boost += hash[:hit]
  184.     @temp_eva_boost += hash[:eva]
  185.     @temp_cri_boost += hash[:cri]
  186.     @temp_odds_boost += hash[:odds]
  187.     @temp_dex_boost += hash[:dex]
  188.     @temp_res_boost += hash[:res]
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # * Apply Skill Effects
  192.   #--------------------------------------------------------------------------
  193.   alias skill_effect_sss_temp_boosts skill_effect unless $@
  194.   def skill_effect(user, skill)
  195.     skill_effect_sss_temp_boosts(user, skill)
  196.     return unless $game_temp.in_battle
  197.     return if @skipped or @missed or @evaded
  198.     clear_temp_stat_boosts if skill.clear_temp_stats[:target]
  199.     user.clear_temp_stat_boosts if skill.clear_temp_stats[:user]
  200.     apply_temp_boost(skill.target_temp_boost)
  201.     user.apply_temp_boost(skill.user_temp_boost)
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # * Apply Item Effects
  205.   #--------------------------------------------------------------------------
  206.   alias item_effect_sss_temp_boosts item_effect unless $@
  207.   def item_effect(user, item)
  208.     item_effect_sss_temp_boosts(user, item)
  209.     return unless $game_temp.in_battle
  210.     return if @skipped or @missed or @evaded
  211.     clear_temp_stat_boosts if item.clear_temp_stats[:target]
  212.     user.clear_temp_stat_boosts if item.clear_temp_stats[:user]
  213.     apply_temp_boost(item.target_temp_boost)
  214.     user.apply_temp_boost(item.user_temp_boost)
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # * Maxmp Limit
  218.   #--------------------------------------------------------------------------
  219.   unless method_defined?(:maxmp_limit)
  220.   def maxmp_limit; return 9999; end
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # * Parameter Limit
  224.   #--------------------------------------------------------------------------
  225.   unless method_defined?(:parameter_limit)
  226.   def parameter_limit; return 999; end
  227.   end
  228.   #--------------------------------------------------------------------------
  229.   # * Get Maximum HP
  230.   #--------------------------------------------------------------------------
  231.   alias maxhp_sss_temp_boosts maxhp unless $@
  232.   def maxhp
  233.     clear_temp_stat_boosts if @temp_maxhp_boost.nil?
  234.     return [[maxhp_sss_temp_boosts + @temp_maxhp_boost, 1].max, maxhp_limit].min
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # * Get Maximum MP
  238.   #--------------------------------------------------------------------------
  239.   alias maxmp_sss_temp_boosts maxmp unless $@
  240.   def maxmp
  241.     clear_temp_stat_boosts if @temp_maxmp_boost.nil?
  242.     return [[maxmp_sss_temp_boosts + @temp_maxmp_boost, 0].max, maxmp_limit].min
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # * Get Attack
  246.   #--------------------------------------------------------------------------
  247.   alias atk_sss_temp_boosts atk unless $@
  248.   def atk
  249.     clear_temp_stat_boosts if @temp_atk_boost.nil?
  250.     return [[atk_sss_temp_boosts + @temp_atk_boost, 1].max, parameter_limit].min
  251.   end
  252.   #--------------------------------------------------------------------------
  253.   # * Get Defense
  254.   #--------------------------------------------------------------------------
  255.   alias def_sss_temp_boosts def unless $@
  256.   def def
  257.     clear_temp_stat_boosts if @temp_def_boost.nil?
  258.     return [[def_sss_temp_boosts + @temp_def_boost, 1].max, parameter_limit].min
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # * Get Spirit
  262.   #--------------------------------------------------------------------------
  263.   alias spi_sss_temp_boosts spi unless $@
  264.   def spi
  265.     clear_temp_stat_boosts if @temp_spi_boost.nil?
  266.     return [[spi_sss_temp_boosts + @temp_spi_boost, 1].max, parameter_limit].min
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # * Get Agility
  270.   #--------------------------------------------------------------------------
  271.   alias agi_sss_temp_boosts agi unless $@
  272.   def agi
  273.     clear_temp_stat_boosts if @temp_agi_boost.nil?
  274.     return [[agi_sss_temp_boosts + @temp_agi_boost, 1].max, parameter_limit].min
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # * Get Dexterity
  278.   #--------------------------------------------------------------------------
  279.   if $imported["DEX Stat"]
  280.   alias dex_sss_temp_boosts dex unless $@
  281.   def dex
  282.     clear_temp_stat_boosts if @temp_dex_boost.nil?
  283.     return [[dex_sss_temp_boosts + @temp_dex_boost, 1].max, parameter_limit].min
  284.   end
  285.   end
  286.   #--------------------------------------------------------------------------
  287.   # * Get Resist
  288.   #--------------------------------------------------------------------------
  289.   if $imported["RES Stat"]
  290.   alias res_sss_temp_boosts res unless $@
  291.   def res
  292.     clear_temp_stat_boosts if @temp_res_boost.nil?
  293.     return [[res_sss_temp_boosts + @temp_res_boost, 1].max, parameter_limit].min
  294.   end
  295.   end
  296. end
  297.  
  298. #==============================================================================
  299. # ** Game_Actor
  300. #==============================================================================
  301.  
  302. class Game_Actor < Game_Battler
  303.   #--------------------------------------------------------------------------
  304.   # * Get Hit Rate
  305.   #--------------------------------------------------------------------------
  306.   alias hit_sss_temp_boosts_actor hit unless $@
  307.   def hit
  308.     clear_temp_stat_boosts if @temp_hit_boost.nil?
  309.     return [hit_sss_temp_boosts_actor + @temp_hit_boost, 0].max
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   # * Get Evasion Rate
  313.   #--------------------------------------------------------------------------
  314.   alias eva_sss_temp_boosts_actor eva unless $@
  315.   def eva
  316.     clear_temp_stat_boosts if @temp_eva_boost.nil?
  317.     return [eva_sss_temp_boosts_actor + @temp_eva_boost, 0].max
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # * Get Critical Ratio
  321.   #--------------------------------------------------------------------------
  322.   alias cri_sss_temp_boosts_actor cri unless $@
  323.   def cri
  324.     clear_temp_stat_boosts if @temp_cri_boost.nil?
  325.     return [cri_sss_temp_boosts_actor + @temp_cri_boost, 0].max
  326.   end
  327.   #--------------------------------------------------------------------------
  328.   # * Get Ease of Hitting
  329.   #--------------------------------------------------------------------------
  330.   alias odds_sss_temp_boosts_actor odds unless $@
  331.   def odds
  332.     clear_temp_stat_boosts if @temp_odds_boost.nil?
  333.     return [odds_sss_temp_boosts_actor + @temp_odds_boost, 0].max
  334.   end
  335. end
  336.  
  337. #==============================================================================
  338. # ** Game_Enemy
  339. #==============================================================================
  340.  
  341. class Game_Enemy < Game_Battler
  342.   #--------------------------------------------------------------------------
  343.   # * Get Hit Rate
  344.   #--------------------------------------------------------------------------
  345.   alias hit_sss_temp_boosts_enemy hit unless $@
  346.   def hit
  347.     clear_temp_stat_boosts if @temp_hit_boost.nil?
  348.     return [hit_sss_temp_boosts_enemy + @temp_hit_boost, 0].max
  349.   end
  350.   #--------------------------------------------------------------------------
  351.   # * Get Evasion Rate
  352.   #--------------------------------------------------------------------------
  353.   alias eva_sss_temp_boosts_enemy eva unless $@
  354.   def eva
  355.     clear_temp_stat_boosts if @temp_eva_boost.nil?
  356.     return [eva_sss_temp_boosts_enemy + @temp_eva_boost, 0].max
  357.   end
  358.   #--------------------------------------------------------------------------
  359.   # * Get Critical Ratio
  360.   #--------------------------------------------------------------------------
  361.   alias cri_sss_temp_boosts_enemy cri unless $@
  362.   def cri
  363.     clear_temp_stat_boosts if @temp_cri_boost.nil?
  364.     return [cri_sss_temp_boosts_enemy + @temp_cri_boost, 0].max
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # * Get Ease of Hitting
  368.   #--------------------------------------------------------------------------
  369.   alias odds_sss_temp_boosts_enemy odds unless $@
  370.   def odds
  371.     clear_temp_stat_boosts if @temp_odds_boost.nil?
  372.     return [odds_sss_temp_boosts_enemy + @temp_odds_boost, 0].max
  373.   end
  374. end
  375.  
  376. #==============================================================================
  377. # ** Scene_Battle
  378. #==============================================================================
  379.  
  380. class Scene_Battle < Scene_Base
  381.   #--------------------------------------------------------------------------
  382.   # * Battle Start Processing
  383.   #--------------------------------------------------------------------------
  384.   alias process_battle_start_sss_temp_boosts process_battle_start unless $@
  385.   def process_battle_start
  386.     for member in $game_party.members
  387.       member.clear_temp_stat_boosts
  388.     end
  389.     process_battle_start_sss_temp_boosts
  390.   end
  391.   #--------------------------------------------------------------------------
  392.   # * End Battle
  393.   #--------------------------------------------------------------------------
  394.   alias battle_end_sss_temp_boosts battle_end unless $@
  395.   def battle_end(result)
  396.     battle_end_sss_temp_boosts(result)
  397.     for member in $game_party.members
  398.       member.clear_temp_stat_boosts
  399.     end
  400.   end
  401. end
  402.  
  403. #===============================================================================
  404. #
  405. # END OF FILE
  406. #
  407. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement