|
  |
[VX] Rei Random Stat on Levelup! [UPDATED], Randomize stat gain for actors when gain a level |
|
|
|
|
Apr 26 2009, 09:53 PM
|

It's been awhile lol

Group: Revolutionary
Posts: 168
Type: Artist
RM Skill: Advanced

|
Rei Random Stat on Levelup!v.1.1a (April 30th 2009)by reijubvThis script will modify an actor's stats gain on level up by a random number between maximum and minimum amount that you can specify for each actors. For example, you set an actor's minimum AGI stat to 1 and maximum AGI stat to 5, when that actor gains a level, he/she'll gains AGI by random number between 1 to 5! I suggest you set actor's stats in database to the same from his/her starting level to 99, so if in database your actor's HP at starting level is 100, from that level to 99 the HP should not be changed! This's just a suggestion anyway.... Note : You must setup max and min value for EVERY actors that you used in your game! Download script here :CODE #=============================================================================== # > [VX] Rei Levelup Stat Randomizer #------------------------------------------------------------------------------- # > by reijubv [aruyasoft@comic.com] # > RPG RPG Revolution # > Released on: 27/04/2009 # > Version: 1.1 (April 25th 2009) #------------------------------------------------------------------------------- # > Changelog: # V.1.0 (25-04-09) = Initial release # V.1.1 (29-04-09) = Added a function to restore HP/MP to max when level up # V.1.1a (30-04-09) = Fixed a small bug wich I forgot to write something in # the script that can makes the game crashes..... #------------------------------------------------------------------------------- # > Information: # This script will modify an actor's stats gain on level up by a random number # between maximum and minimum amount that you can specify for each actors. # For example, you set an actor's minimum AGI stat to 1 and maximum AGI stat to 5, # when that actor gains a level, he/she'll gains AGI by random number between 1 to 5! # I suggest you set actor's stats in database to the same from his/her starting level # to 99, so if in database your actor's HP at starting level is 100, from that level # to 99 the HP should not be changed! This's just a suggestion anyway.... #------------------------------------------------------------------------------- # > Compatibility : # # * Aliases : # class Game_Actor # def setup # def base_maxhp # def base_maxmp # def base_atk # def base_def # def base_spi # def base_agi # def hit # def eva # def cri # * Rewrites : # class Game_Actor # def level_up # def level_down #------------------------------------------------------------------------------- # Credit reijubv if you use this script.... # Credit woratana for his recover HP/MP/States when Level Up script #------------------------------------------------------------------------------- # > Installation: # Put this script above main, setup script below. #========================================================================== ===== module Rei module RandStat #---------------------------------------------------------------------------- # * Create Arrays #----------------------------------------------- ---------------------------- Actor_MaxInc = Array.new Actor_MinInc = Array.new #---------------------------------------------------------------------------- # * HP/MP/STATE Restoration Setting (CREDIT TO WORATANA FOR THIS FUNCTIONS) #---------------------------------------------------------------------------- RECOVER_HP = true # Recover HP when level up? (true/false) RECOVER_MP = true # Recover MP when level up? REMOVE_STATES = true # Cure all states when level up? #--------------------Setup each actors below---------------------------------- # Use this template : # # Actor_MaxInc[#] = [maxHP,maxMP,maxATK,maxDEF,maxSPI,maxAGI,maxHIT,maxEVA,maxCRI] # > This setup actor #'s each stats' maximum increments # # Actor_MinInc[#] = [minHP,minMP,minATK,minDEF,minSPI,minAGI,minHIT,minEVA,minCRI] # > This setup actor #'s each stats' minimum increments # # Use 0 if you don't want to increase any stat on level up # # Note : >Actor_MaxInc should be higher than Actor_MinInc! # >Don't use negative values, or your actor's stats would be messed up! # >Don't forget to setup max and min value for EVERY actors that you used # in your game! # # Just in case that you don't know : # # HP = Hit Points DEF = Defense HIT = Hit rate # MP = Magic Points SPI = Spirit EVA = Evasion rate # ATK = Attack AGI = Agility CRI = Critical rate #---------------------------------------------------------------------------- #Samples : # actorId HP MP ATK DEF SPI AGI HIT EVA CRI Actor_MaxInc[1] = [ 5 , 3 ,4 , 3 , 1 , 1 , 0 , 0 , 0] #Maximum increment Actor_MinInc[1] = [ 3 , 1 ,1 , 1 , 0 , 1 , 0 , 0 , 0] #Minimum increment Actor_MaxInc[2] = [ 3 , 4 ,3 , 2 , 2 , 2 , 1 , 1 , 0] #Maximum increment Actor_MinInc[2] = [ 2 , 2 ,1 , 1 , 0 , 1 , 0 , 0 , 0] #Minimum increment Actor_MaxInc[8] = [ 3 , 4 ,2 , 2 , 3 , 3 , 1 , 1 , 0] #Maximum increment Actor_MinInc[8] = [ 1 , 1 ,1 , 1 , 1 , 1 , 0 , 0 , 0] #Minimum increment Actor_MaxInc[9] = [ 5 , 3 ,4 , 3 , 1 , 2 , 0 , 0 , 0] #Maximum increment Actor_MinInc[9] = [ 2 , 0 ,1 , 1 , 0 , 1 , 0 , 0 , 0] #Minimum increment Actor_MaxInc[10]= [ 4 , 4 ,4 , 3 , 3 , 1 , 0 , 0 , 0] #Maximum increment Actor_MinInc[10]= [ 2 , 1 ,1 , 1 , 1 , 1 , 0 , 0 , 0] #Minimum increment Actor_MaxInc[11]= [ 5 , 2 ,5 , 3 , 1 , 1 , 0 , 0 , 0] #Maximum increment Actor_MinInc[11]= [ 2 , 1 ,2 , 2 , 1 , 1 , 0 , 0 , 0] #Minimum increment end end #========================================================================== ==== # ** Game_Actor #------------------------------------------------------------------------------ # This class handles actors. Its used within the Game_Actors class # ($game_actors) and referenced by the Game_Party class ($game_party). #========================================================================== ==== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Setup # actor_id : actor ID #-------------------------------------------------------------------------- alias reisetup setup def setup(actor_id) @stat_gains = {} for i in 0..8 @stat_gains[i] = [] end reisetup(actor_id) end #-------------------------------------------------------------------------- # * Get Basic Maximum HP #-------------------------------------------------------------------------- alias reibasemaxhp base_maxhp def base_maxhp n = reibasemaxhp n+= @stat_gains[0].sum return n end #-------------------------------------------------------------------------- # * Get basic Maximum MP #-------------------------------------------------------------------------- alias reibasemaxmp base_maxmp def base_maxmp n = reibasemaxmp n+= @stat_gains[1].sum return n end #-------------------------------------------------------------------------- # * Get Basic Attack #-------------------------------------------------------------------------- alias reibaseatk base_atk def base_atk n = reibaseatk n+= @stat_gains[2].sum return n end #-------------------------------------------------------------------------- # * Get Basic Defense #-------------------------------------------------------------------------- alias reibasedef base_def def base_def n = reibasedef n+= @stat_gains[3].sum return n end #-------------------------------------------------------------------------- # * Get Basic Spirit #-------------------------------------------------------------------------- alias reibasespi base_spi def base_spi n = reibasespi n+= @stat_gains[4].sum return n end #-------------------------------------------------------------------------- # * Get Basic Agility #-------------------------------------------------------------------------- alias reibaseagi base_agi def base_agi n = reibaseagi n+= @stat_gains[5].sum return n end #-------------------------------------------------------------------------- # * Get Hit Rate #-------------------------------------------------------------------------- alias reihit hit def hit n = reihit n+= @stat_gains[6].sum return n end #-------------------------------------------------------------------------- # * Get Evasion Rate #-------------------------------------------------------------------------- alias reieva eva def eva n = reieva n+= @stat_gains[7].sum return n end #-------------------------------------------------------------------------- # * Get Critical Ratio #-------------------------------------------------------------------------- alias reicri cri def cri n = reicri n+= @stat_gains[8].sum return n end #-------------------------------------------------------------------------- # * Level Up #-------------------------------------------------------------------------- def level_up r = {} a = {} b = {} @level += 1 for i in 0..8 a[i] = Rei::RandStat::Actor_MaxInc[@actor_id][i] b[i] = Rei::RandStat::Actor_MinInc[@actor_id][i] r[i] = b[i]+rand(a[i]-b[i]+1) if r[i] <= Rei::RandStat::Actor_MinInc[@actor_id][i] then r[i] = Rei::RandStat::Actor_MinInc[@actor_id][i] end if r[i] >= Rei::RandStat::Actor_MaxInc[@actor_id][i] then r[i] = Rei::RandStat::Actor_MaxInc[@actor_id][i] end @stat_gains[i] << r[i] end #from woratana's script v @hp = maxhp if Rei::RandStat::RECOVER_HP @mp = maxmp if Rei::RandStat::RECOVER_MP if Rei::RandStat::REMOVE_STATES @states.clone.each {|i| remove_state(i) } end #from woratana's script ^ for learning in self.class.learnings learn_skill(learning.skill_id) if learning.level == @level end end #-------------------------------------------------------------------------- # * Level Down #-------------------------------------------------------------------------- def level_down @level-= 1 for i in 0..8 @stat_gains[i].pop end end end #========================================================================== ==== # ** Array #------------------------------------------------------------------------------ # This hidden class handles arrays. It is used within many other # classes to store data for future retrieval. #========================================================================== ==== class Array #--------------------------------------------------------------------------- # * Name : Sum # Info : Sums all values in the array # Author : Trickster # Call Info : No Arguments #--------------------------------------------------------------------------- def sum # Initialize local variable n n = 0 # Sum Up Values in Array each {|num| n += num} # Return number return n end end Setup this script like this :CODE Actor_MaxInc[#] = [maxHP,maxMP,maxATK,maxDEF,maxSPI,maxAGI,maxHIT,maxEVA,maxCRI] This setup actor #'s each stats' maximum increments Actor_MinInc[#] = [minHP,minMP,minATK,minDEF,minSPI,minAGI,minHIT,minEVA,minCRI] This setup actor #'s each stats' minimum increments Examples : # Actor 1's stats Actor_MaxInc[1] = [ 5 , 3 ,4 , 3 , 1 , 1 , 0 , 0 , 0] Actor_MinInc[1] = [ 3 , 1 ,1 , 1 , 0 , 1 , 0 , 0 , 0] # Actor 2's stats Actor_MaxInc[2] = [ 3 , 4 ,3 , 2 , 2 , 2 , 1 , 1 , 0] Actor_MinInc[2] = [ 2 , 2 ,1 , 1 , 0 , 1 , 0 , 0 , 0] # Actor 8's stats Actor_MaxInc[8] = [ 3 , 4 ,2 , 2 , 3 , 3 , 1 , 1 , 0] Actor_MinInc[8] = [ 1 , 1 ,1 , 1 , 1 , 1 , 0 , 0 , 0] # Actor 9's stats Actor_MaxInc[9] = [ 5 , 3 ,4 , 3 , 1 , 2 , 0 , 0 , 0] Actor_MinInc[9] = [ 2 , 0 ,1 , 1 , 0 , 1 , 0 , 0 , 0] # Actor 10's stats Actor_MaxInc[10]= [ 4 , 4 ,4 , 3 , 3 , 1 , 0 , 0 , 0] Actor_MinInc[10]= [ 2 , 1 ,1 , 1 , 1 , 1 , 0 , 0 , 0] Installation :Put this script above main Credit and Thanks :Credit reijubv if you use this script! Thanks to Woratana his recover HP/MP/States when Level Up script!
This post has been edited by reijubv: Apr 30 2009, 02:16 AM
__________________________
|
|
|
|
|
|
|
|
|
Apr 27 2009, 11:49 PM
|


Group: Member
Posts: 2
Type: Mapper
RM Skill: Skilled

|
Very nice, I was wondering if there was a way to display the stat increases when the character levels up? Also just an fyi, probably not that big of a deal but if you want to add the restore Hp/Mp when leveling up add it to lines 215 and 216. CODE #-------------------------------------------------------------------------- # * Level Up #-------------------------------------------------------------------------- def level_up r = {} a = {} b = {} @level += 1 for i in 0..8 a[i] = Rei::RandStat::Actor_MaxInc[@actor_id][i] b[i] = Rei::RandStat::Actor_MinInc[@actor_id][i] r[i] = b[i]+rand(a[i]-b[i]+1) if r[i] <= Rei::RandStat::Actor_MinInc[@actor_id][i] then r[i] = Rei::RandStat::Actor_MinInc[@actor_id][i] end if r[i] >= Rei::RandStat::Actor_MaxInc[@actor_id][i] then r[i] = Rei::RandStat::Actor_MaxInc[@actor_id][i] end @stat_gains[i] << r[i] end self.hp += maxhp #Add this, It gives you full HP on level up. self.mp += maxmp #Add this, It gives you full MP on level up. for learning in self.class.learnings learn_skill(learning.skill_id) if learning.level == @level end end
|
|
|
|
|
|
|
|
  |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
RPG RPG Revolution is an Privacy
Policy and Legal
|
|