Advertisement
AngryPacman

[VXA] Custom EXP Formula

Jun 18th, 2014
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.85 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Custom EXP Formula
  4. # 19/06/2014
  5. # By Pacman
  6. #
  7. #===============================================================================
  8. #
  9. # This script allows you to give custom EXP formulae to each class. I advise
  10. # that the faint of heart stay away from this script, as creating formulae can
  11. # be complicated and headache-inducing.
  12. #
  13. #===============================================================================
  14. #
  15. #   ~! INSTALLATION !~
  16. # Paste above Main, below Materials.
  17. # To configure the script, write your desired formula for any particular class
  18. # in the array below. To do this, simply write:
  19. #    Custom_Formula[n] = "formula"
  20. # Where n is the ID of the class and "formula" is the formula you wish to have
  21. # calculating the EXP curve.
  22. # In creating your formula, there are 5 variables you can use. These are the
  23. # level, base value, extra value, accelaration A and accelaration B. The level
  24. # refers to the current level of the actor, and the other four values correspond
  25. # to those set in the EXP curve in the database. You must refer to them thusly:
  26. #    Level - lv
  27. #    Base Value - base
  28. #    Extra Value - extra
  29. #    Accelaration A - acc_a
  30. #    Accelaration B - acc_b
  31. # You could also not use any of these fancy variables. Nobody will laugh at you.
  32. # The writing of the formula must be done inside quotation marks ("") and can
  33. # use all basic mathematical proceedings. Exponents must be denoted with **
  34. # instead of ^.
  35. #
  36. #===============================================================================
  37.  
  38. module Custom_Formula   # Woah woah woah don't touch that man
  39.   Custom_Formula = []   # Don't even think about it
  40.   #--------------------------------------------------------------------------
  41.   Custom_Formula[1] = "(basis**lv - (basis * lv))"
  42.   Custom_Formula[2] = "(basis*((lv-1)**(0.9+acc_a/150))*lv*(lv+1)/
  43.      (6+lv**2/50/acc_b)+(lv-1)*2*extra)"
  44.   #--------------------------------------------------------------------------
  45. end                     # Okay you can just go home now.
  46.  
  47. #===============================================================================
  48. #
  49. # Just... don't touch this stuff. This is my stuff.
  50. #
  51. #===============================================================================
  52. # ** RPG::Class
  53. #------------------------------------------------------------------------------
  54. #  The data class for class. Yo dawg, I heard you like class.
  55. #==============================================================================
  56.  
  57. class RPG::Class < RPG::BaseItem
  58.   #--------------------------------------------------------------------------
  59.   # * Get Total EXP Required for Rising to Specified Level
  60.   #--------------------------------------------------------------------------
  61.   def exp_for_level(level)
  62.     lv = level.to_f
  63.     basis = @exp_params[0].to_f
  64.     extra = @exp_params[1].to_f
  65.     acc_a = @exp_params[2].to_f
  66.     acc_b = @exp_params[3].to_f
  67.     return (basis*((lv-1)**(0.9+acc_a/250))*lv*(lv+1)/
  68.       (6+lv**2/50/acc_b)+(lv-1)*extra).round.to_i
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # * Get Total EXP Required for Rising to Specified Level, but cool this time.
  72.   #--------------------------------------------------------------------------
  73.   def exp_for_level_custom(level, id)
  74.     lv = level.to_f
  75.     basis = @exp_params[0].to_f
  76.     extra = @exp_params[1].to_f
  77.     acc_a = @exp_params[2].to_f
  78.     acc_b = @exp_params[3].to_f
  79.     return eval(Custom_Formula::Custom_Formula[id]).round.to_i rescue 0
  80.   end
  81. end
  82.  
  83. #==============================================================================
  84. # ** Game_Actor
  85. #------------------------------------------------------------------------------
  86. #  This class handles actors. It is used within the Game_Actors class
  87. # ($game_actors) and is also referenced from the Game_Party class ($game_party).
  88. #==============================================================================
  89.  
  90. class Game_Actor < Game_Battler
  91.   #--------------------------------------------------------------------------
  92.   #  Alias Method
  93.   #--------------------------------------------------------------------------
  94.   alias pac_custom_formula_expflvl exp_for_level
  95.   #--------------------------------------------------------------------------
  96.   # * Get Total EXP Required for Rising to Specified Level
  97.   #--------------------------------------------------------------------------
  98.   def exp_for_level(level, *args)
  99.     if Custom_Formula::Custom_Formula[@class_id]
  100.       self.class.exp_for_level_custom(level, id, *args)
  101.     else
  102.       self.class.exp_for_level(level, *args)
  103.     end
  104.   end
  105. end
  106.  
  107. #===============================================================================
  108. #
  109. # END OF SCRIPT
  110. #
  111. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement