TheoAllen

Critical Modifier

Jan 28th, 2013
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.86 KB | None | 0 0
  1. # =============================================================================
  2. # ~ Critical modifier by TheoAllen ~
  3. # Version : 1.1
  4. # Contact : www.rpgmakerid.com
  5. # =============================================================================
  6. # Description :
  7. # This script allow you to configure critical damage.
  8. # -----------------------------------------------------------------------------
  9.  
  10. # Instruction :
  11. # Insert this script above main and below Material.
  12. # -----------------------------------------------------------------------------
  13.  
  14. # Terms of use :
  15. # You may use and edit this script both for commercial and non-commercial.  
  16. # Credit isn't necessary. But if you wish to, you can put "TheoAllen" in your
  17. # credit list.
  18.  
  19. # And also thanks to Heartbreak61, Rei_Fan49 and gabokun88 for the inspiration.
  20. # -----------------------------------------------------------------------------
  21.  
  22. # Change log :
  23. # 1.0 -> 1.1 => Custom critical formula, Fix formula
  24. # =============================================================================
  25. # Configuration :
  26. # =============================================================================
  27. module THEOLIZED
  28.  
  29.   # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30.   # There're 3 types of critical calculation
  31.   # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  32.   # 0 = Default RMVXAce   => (damage * 3)
  33.   # 1 = Custom percentage => (damage * (input/100)
  34.   # 2 = By user's luck    => (damage * (user.luk + 100) / 100)
  35.   # 3 = Custom formula    => (formula)
  36.   # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  37.   CRIT_TYPE = 2
  38.  
  39. # =============================================================================
  40.   # This option only valid when you choose 1 in critical type
  41.   CRIT_MOD = 100 # percentage
  42.  
  43. # =============================================================================
  44.   # This option only valid when you choose 3 in critical type
  45.   # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  46.   # Usable formulas
  47.   # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  48.   # - damage  => Normal damage value
  49.   # - self    => Refers to target
  50.   # - user    => Refers to user
  51.   # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  52.   # Examples :
  53.   # Ex : "damage * user.luk"
  54.   # Ex : "damage * user.agi"
  55.   # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  56.   CRIT_FORMULA = "damage * 3"
  57.  
  58. end
  59. # =============================================================================
  60. # Do not edit unless you know what to do ~
  61. # =============================================================================
  62. class Game_Battler < Game_BattlerBase
  63.   #--------------------------------------------------------------------------
  64.   # ~ Redefine Calculate Damage
  65.   #--------------------------------------------------------------------------
  66.   def make_damage_value(user, item)
  67.     value = item.damage.eval(user, self, $game_variables)
  68.     value *= item_element_rate(user, item)
  69.     value *= pdr if item.physical?
  70.     value *= mdr if item.magical?
  71.     value *= rec if item.damage.recover?
  72.     value = apply_critical(value, user) if @result.critical
  73.     value = apply_variance(value, item.damage.variance)
  74.     value = apply_guard(value)
  75.     @result.make_damage(value.to_i, item)
  76.   end
  77.  
  78.   #--------------------------------------------------------------------------
  79.   # ~ Redefine apply critical
  80.   #--------------------------------------------------------------------------
  81.   def apply_critical(damage, user)
  82.     case THEOLIZED::CRIT_TYPE
  83.     when 1
  84.       damage * ((THEOLIZED::CRIT_MOD).abs/100)
  85.     when 2
  86.       damage * ((user.luk + 100)/100)
  87.     when 3
  88.       eval(THEOLIZED::CRIT_FORMULA) rescue 0
  89.     else
  90.       damage * 3
  91.     end        
  92.   end
  93. end
  94. # =============================================================================
  95. # End of script
  96. # =============================================================================
Advertisement
Add Comment
Please, Sign In to add comment