bgillisp

Parameter Points Script (alpha version, no graphics)

Sep 3rd, 2014
24
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Parameter Points Script, version 0.1
  2. # Author: bgillisp
  3. # Released 9/3/2014
  4.  
  5. # This script allows you to earn parameter points upon level up, which
  6. # you can then spend to increase your stats. The standard level-up
  7. # process is still present, so you can either have these as bonuses,
  8. # or you can set the database to give no reward on level up, then
  9. # these points have to increase your parameters
  10.  
  11. # To use:
  12. # Place in the materials folder, but above main
  13. #
  14. # Currently there is no graphical interface for the points. This means
  15. # you will never know how many points you have short of a script call.
  16.  
  17. # To check points, call $game_actors[x].parameter_points in a script call in an
  18. # event. Replace x with the name of the actor (remember the database starts at 1)
  19.  
  20. # To spend points, call $game_actors[x].spend_parameter_points(y), replacing
  21. # x with the actor's id, and y with value of the stat you wish to spent a point
  22. # to increase. The values to pass are as follows
  23. # 0 - MHP
  24. # 1 - MMP
  25. # 2 - ATK
  26. # 3 - DEF
  27. # 4 - MAT
  28. # 5 - MDF
  29. # 6 - AGL
  30. # 7 - LUK
  31.  
  32. # If, for some reason, you accidentally pass a number less than 0, the point will
  33. # be spent to increase MHP.
  34. # If, for some reason, you accidentally pass a number more than 7, the point
  35. # will be spent to increase LUK.
  36. #
  37. # If you call the command, but do not have the points to spend, it will do
  38. # nothing.
  39.  
  40. # Terms of use:
  41. # Free for use in commercial and non-commercial games, with credit
  42. # given.
  43.  
  44.  
  45. #----------------------------------------------------------------------------
  46. # Editable region
  47.  
  48. module BG_Parameter_points
  49.  
  50. #Edit this array to determine how many paramter points a character has
  51. #Do not erase the commas or the [ or ] or you will get an error!
  52.  
  53. Points_per_level = [0, 1, 1, 1, 1, 2, 1, 1, 1, 1, #Levels 0 - 9
  54. 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, #Levels 10 - 19
  55. 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, #Levels 20 - 29
  56. 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, #Levels 30 - 39
  57. 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, #Levels 40 - 49
  58. 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, #Levels 50 - 59
  59. 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, #Levels 60 - 69
  60. 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, #Levels 70 - 79
  61. 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, #Levels 80 - 89
  62. 2, 1, 1, 1, 1, 2, 1, 1, 1, 1] #Levels 90 - 99
  63.  
  64. #Edit these to change what the actor gains for spending a point
  65. #on that stat. These refer to, in order, assuming default names
  66. #HP, MP, ATK, DEF, MAT, MDF< AGL, and LUK
  67. Amount_to_increase = [10, 5, 1, 1, 1, 1, 1, 1]
  68.  
  69. end
  70.  
  71. #End of Editable Region
  72. #--------------------------------------------------------------------------
  73.  
  74.  
  75. #Do not edit anything below here unless you know what you are doing.
  76. #Failure to ahead to this warning may result in unpredictable behavior in
  77. #your game. Consider yourself warned
  78. #__________________________________________________________________________
  79.  
  80. class Game_Actor < Game_Battler
  81.  
  82. attr_accessor :parameter_points
  83.  
  84. alias bg_parameter_points_initialize initialize
  85. alias bg_paramater_points_level_up level_up
  86.  
  87. #Aliased method, initialize
  88. def initialize(actor_id)
  89.  
  90. #Call aliased method
  91. bg_parameter_points_initialize(actor_id)
  92.  
  93. #Set our parameter points to zero (for now)
  94. self.parameter_points = 0
  95.  
  96. end #End initiliaze
  97.  
  98. #Alias method, level_up
  99. def level_up
  100.  
  101. #Call aliased method
  102. bg_paramater_points_level_up
  103.  
  104. #Add (or subtract) the desired number of points.
  105. self.parameter_points += BG_Parameter_points::Points_per_level[@level]
  106.  
  107. end #End level_up
  108.  
  109. #Original Method, spend point
  110. def spend_point(stat_to_increase)
  111.  
  112. #Error catching, to avoid crashes
  113. if(stat_to_increase < 0)
  114. stat_to_increase = 0
  115. end
  116.  
  117. if(stat_to_increase > 7)
  118. stat_to_increase = 7
  119. end
  120.  
  121. #If we have no points to spend, abort
  122. if(self.parameter_points <= 0)
  123. return
  124. end
  125.  
  126. self.parameter_points -= 1
  127. add_param(stat_to_increase, BG_Parameter_points::Amount_to_increase[stat_to_increase])
  128.  
  129. end #End spend_point
  130.  
  131. #Original method, give parameter points
  132. def give_parameter_points(amount)
  133. self.parameter_points += amount
  134.  
  135. #Set the parameter points to the maximum of 0 and whatever we set it at.
  136. self.parameter_points = [0, self.parameter_points].max
  137. end
  138.  
  139. end
RAW Paste Data