Advertisement
neutale

Damage Formula Extension

Jan 2nd, 2020
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.95 KB | None | 0 0
  1. #==============================================================================
  2. # ■ Damage Formula Extension
  3. #  FormulaExtend.rb
  4. #------------------------------------------------------------------------------
  5. #  More functions that can be used for damage formula calculation.
  6. #
  7. # ●How to usea
  8. # 1. Input function for skill damage formula in database. Example(a.plus_atk)
  9. #
  10. # ●Formula functions list
  11. #  1. plus_atk(percent, value)
  12. #   [percent]Calculate by value to original attack power with a chance of.
  13. #  ex:a.plus_atk(50, 100) # 50% chance to add 100 to the attacker's attack power.
  14. #
  15. #  2. plus_def(percent, value)
  16. #   [percent]Calculate by value to original defense with a chance of.
  17. #  ex:b.plus_def(30, -100) # 30% chance to subtract 100 from the target's def.
  18. #
  19. #  3. plus_mat(percent, value)
  20. #   [percent]Calculate by value to original magic attack with a chance of.
  21. #
  22. #  4. plus_mdf(percent, value)
  23. #   [percent]Calculate by value to original magic defense power with a chance of.
  24. #
  25. #  5. plus_agi(percent, value)
  26. #   [percent]Calculate by value to original agility with a chance of.
  27. #
  28. #  6. plus_luk(percent, value)
  29. #   [percent]Calculate by value to original luck with a chance of.
  30. #
  31. # ●Terms of use
  32. #  It can be modified and redistributed without permission from the author.
  33. #  Free for commercial and non-commercial use.
  34. #-----------------------------------------------------------------------------
  35. # Copyright (c) 2017 Triacontane
  36. # This software is released under the MIT License.
  37. # http://opensource.org/licenses/mit-license.php
  38. #-----------------------------------------------------------------------------
  39. # Version
  40. # 1.0.0 2017/01/28 initial release
  41. # ----------------------------------------------------------------------------
  42. # [Blog]   : http://triacontane.blogspot.jp/
  43. # [Twitter]: https://twitter.com/triacontane/
  44. # [GitHub] : https://github.com/triacontane/
  45. #=============================================================================
  46.  
  47. class Game_Battler < Game_BattlerBase
  48.   #--------------------------------------------------------------------------
  49.   # ● extra parameter
  50.   #--------------------------------------------------------------------------
  51.   def plus_param(original, percent, adjustment)
  52.     return [original + (rand(100) < percent ? adjustment : 0), 0].max
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● add attack
  56.   #--------------------------------------------------------------------------
  57.   def plus_atk(percent, adjustment)
  58.     return plus_param(self.atk, percent, adjustment)
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ● add defense
  62.   #--------------------------------------------------------------------------
  63.   def plus_def(percent, adjustment)
  64.     return plus_param(self.def, percent, adjustment)
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ● add magic attack
  68.   #--------------------------------------------------------------------------
  69.   def plus_mat(percent, adjustment)
  70.     return plus_param(self.mat, percent, adjustment)
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # ● add magic defense
  74.   #--------------------------------------------------------------------------
  75.   def plus_mdf(percent, adjustment)
  76.     return plus_param(self.mdf, percent, adjustment)
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● add agility
  80.   #--------------------------------------------------------------------------
  81.   def plus_agi(percent, adjustment)
  82.     return plus_param(self.agi, percent, adjustment)
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● add luck
  86.   #--------------------------------------------------------------------------
  87.   def plus_luk(percent, adjustment)
  88.     return plus_param(self.luk, percent, adjustment)
  89.   end
  90. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement