IceDragon200

[IEX2]Randomize Battle Skills[VXA]

Mar 25th, 2012
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.99 KB | None | 0 0
  1. #==============================================================================#
  2. # ● IEX2 - Randomize Battle Skills [VXA]
  3. #==============================================================================#
  4. # // • Created By    : IceDragon
  5. # // • Data Created  : 03/25/2012
  6. # // • Data Modified : 03/25/2012
  7. # // • Version       : 1.0
  8. # // • RGSS.design   : 3 (VXA-Default)
  9. #==============================================================================#
  10. # ● Installation
  11. #     Below
  12. #       Material
  13. #       Scripts that make changes to actor.skills
  14. #     Above
  15. #       Main
  16. #==============================================================================#
  17. # ● How to Modify
  18. #    set_rand_skills(n=4)
  19. #     In the Game_Actor class, set_rand_skills, creates an array of 'n' size
  20. #     And selects skills until its full (there will be no duplicates)
  21. #     If the number of available skills falls under the array size, it will
  22. #     be ignored.
  23. #     If you wish to change the number of random skills, simply change the value
  24. #     of 'n'
  25. #
  26. #    reset_rand_turn_count()
  27. #     This will set the number of turns till the next randomization
  28. #     By default:
  29. #      @rand_turn_count = 3 + rand(2)
  30. #      The number of turns will be 3 or 4
  31. #==============================================================================#
  32. # ● Change Log
  33. #     ♣ 03/25/2012 V1.0
  34. #         Completed Script
  35. #==============================================================================#
  36. class Array
  37.   def pick()
  38.     self[rand(self.size)]
  39.   end unless(method_defined?(:pick))
  40.   def pick!()
  41.     self.delete(pick())
  42.   end unless(method_defined?(:pick!))
  43. end
  44. # // VXA
  45. class Game_Battler
  46.   def all_skills() ; [] ; end
  47.   def random_skills()
  48.     set_rand_skills() unless(@random_skills)
  49.     @random_skills
  50.   end  
  51.   def set_rand_skills(n=4)
  52.     sks = all_skills().compact().collect{|s|s.id}
  53.     (@random_skills ||=[]).replace(Array.new(n){sks.pick!()}.compact)
  54.   end
  55.   def randomize_skills?()
  56.     @randomize_skills = true if(@randomize_skills.nil?())
  57.     @randomize_skills
  58.   end
  59.   attr_writer :randomize_skills
  60.   def rand_turn_count()
  61.     reset_rand_turn_count() unless(@rand_turn_count)
  62.     @rand_turn_count
  63.   end  
  64.   def reset_rand_turn_count()
  65.     @rand_turn_count = 3 + rand(2)
  66.   end  
  67.   alias :iex2_rbs_on_turn_end :on_turn_end
  68.   def on_turn_end(*args,&block)
  69.     iex2_rbs_on_turn_end(*args,&block)
  70.     @rand_turn_count = rand_turn_count.pred
  71.     if(@rand_turn_count <= 0)
  72.       set_rand_skills() if(randomize_skills?())
  73.       reset_rand_turn_count()
  74.     end
  75.   end  
  76. end
  77. class Game_Actor
  78.   alias :all_skills :skills
  79.   def skills()
  80.     $game_party.in_battle ? random_skills.collect{|id|$data_skills[id]} : all_skills()
  81.   end
  82. end  
  83. #=■==========================================================================■=#
  84. #                           // ● End of File ● //                              #
  85. #=■==========================================================================■=#
Advertisement
Add Comment
Please, Sign In to add comment