Advertisement
kurashi

[RGSS3] Stat Allocation Upon Leveling v 1.1

Mar 16th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.84 KB | None | 0 0
  1. =begin
  2. Stat Allocation Upon Leveling v 1.1
  3. Created by Kio Kurashi
  4. Version History:
  5. 1.0 = Initial Version
  6. 1.1 = Rather breaking bug fixed (Cannot yield from root Fiber.)
  7.  
  8. Free for commercial and personal use. Credit is not required, but appreciated.
  9.  
  10. Known bugs: None.
  11. =end
  12.  
  13.  
  14. module STAT_MODULE
  15.   VAR_CHOOSE_STAT_LEVEL = 10 #CHANGE THIS TO VARIABLE YOU WANT
  16. end
  17.  
  18. class Game_Actor
  19.   alias kurashi_level_up_stat_choice level_up
  20.   def level_up
  21.     @loop_count = 3
  22.     $game_message.add("#{name} Leveled Up!!")
  23.     while @loop_count > 0
  24.       $game_message.add("Pick a stat to increase.\n Points to spend: #{@loop_count}")
  25.       params = []
  26.       choices = []
  27.       choices.push("Strength   (Current: #{self.atk})")
  28.       choices.push("Endurance  (Current: #{self.def})")
  29.       choices.push("Speed      (Current: #{self.agi})")
  30.       choices.push("Resistance (Current: #{self.luk})")
  31.       params.push(choices)
  32.       params.push(0)
  33.       setup_choices(params)
  34.       Fiber.yield while $game_message.choice? if SceneManager.scene.is_a?(Scene_Map)
  35.       SceneManager.scene.wait_for_message while $game_message.choice? if SceneManager.scene.is_a?(Scene_Battle)
  36.       choice_result = $game_variables[STAT_MODULE::VAR_CHOOSE_STAT_LEVEL]
  37.       case choice_result
  38.         when 1
  39.           add_param(2, 1)
  40.         when 2
  41.           add_param(3, 1)      
  42.         when 3
  43.           add_param(6, 1)      
  44.         when 4
  45.           add_param(7, 1)  
  46.       end
  47.     @loop_count -= 1
  48.     end
  49.     kurashi_level_up_stat_choice
  50.     refresh
  51.   end
  52.  
  53.   def setup_choices(params)
  54.     params[0].each {|s| $game_message.choices.push(s) }
  55.     $game_message.choice_cancel_type = params[1]
  56.     $game_message.choice_proc = Proc.new {|n|
  57.     begin; @branch[@indent] = n;rescue;end
  58.     $game_variables[STAT_MODULE::VAR_CHOOSE_STAT_LEVEL] = n + 1
  59.     }
  60.   end
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement