Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================#
- # ● IEX2 - Randomize Battle Skills [VX]
- #==============================================================================#
- # // • Created By : IceDragon
- # // • Data Created : 03/25/2012
- # // • Data Modified : 03/25/2012
- # // • Version : 1.0
- # // • RGSS.design : 2 (VX-Default)
- #==============================================================================#
- # ● Installation
- # Below
- # Material
- # Scripts that make changes to actor.skills
- # Above
- # Main
- #==============================================================================#
- # ● How to Modify
- # set_rand_skills(n=4)
- # In the Game_Actor class, set_rand_skills, creates an array of 'n' size
- # And selects skills until its full (there will be no duplicates)
- # If the number of available skills falls under the array size, it will
- # be ignored.
- # If you wish to change the number of random skills, simply change the value
- # of 'n'
- #
- # reset_rand_turn_count()
- # This will set the number of turns till the next randomization
- # By default:
- # @rand_turn_count = 3 + rand(2)
- # The number of turns will be 3 or 4
- #==============================================================================#
- # ● Change Log
- # ♣ 03/25/2012 V1.0
- # Completed Script
- #==============================================================================#
- # // 1.9 Functions
- class Array
- def shuffle()
- self.sort_by{rand}
- end unless(method_defined?(:shuffle))
- def shuffle!()
- self.replace(shuffle())
- end unless(method_defined?(:shuffle!))
- def pick()
- self[rand(self.size)]
- end unless(method_defined?(:pick))
- def pick!()
- self.delete(pick())
- end unless(method_defined?(:pick!))
- end
- class Integer
- def pred()
- self - 1
- end unless method_defined?(:pred)
- def succ()
- self + 1
- end unless method_defined?(:succ)
- end
- # // VX
- class Game_Battler
- def all_skills()
- []
- end
- def random_skills()
- set_rand_skills() unless(@random_skills)
- @random_skills
- end
- def set_rand_skills(n=4)
- sks = all_skills().compact().collect{|s|s.id}
- (@random_skills ||=[]).replace(Array.new(n){sks.pick!()}.compact)
- end
- def randomize_skills?()
- @randomize_skills = true if(@randomize_skills.nil?())
- @randomize_skills
- end
- attr_writer :randomize_skills
- def rand_turn_count()
- reset_rand_turn_count() unless(@rand_turn_count)
- @rand_turn_count
- end
- def reset_rand_turn_count()
- @rand_turn_count = 3 + rand(2)
- end
- def at_turn_end()
- @rand_turn_count = rand_turn_count.pred
- if(@rand_turn_count <= 0)
- set_rand_skills() if(randomize_skills?())
- reset_rand_turn_count()
- end
- end
- end
- class Game_Actor
- alias :all_skills :skills unless($@)
- def skills()
- $game_temp.in_battle ? random_skills.collect{|id|$data_skills[id]} : all_skills()
- end
- end
- class Game_Unit
- def at_turn_end()
- members.each{|m|m.at_turn_end()}
- end
- end
- class Scene_Battle
- alias :at_turn_end :turn_end unless($@)
- def turn_end(*args,&block)
- $game_party.at_turn_end()
- $game_troop.at_turn_end()
- at_turn_end(*args,&block)
- end
- end
- #=■==========================================================================■=#
- # // ● End of File ● // #
- #=■==========================================================================■=#
Advertisement
Add Comment
Please, Sign In to add comment