The PokéCommunity Forums Fan Games Game Development Scripts, Tutorials & Tools
Essentials Script Pokemon Level Balance Script

Scripts, Tutorials & Tools This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.

Reply
 
Thread Tools
  #1    
Old June 8th, 2014 (3:28 PM).
☆Rei☆'s Avatar
☆Rei☆ ☆Rei☆ is offline
 
Join Date: Aug 2009
Location: Nearby my feet.
Age: 21
Gender: Female
Nature: Calm
Posts: 1,746
As the title suggests it balances the level of Pokemon. Well to be more precisely; it balances pokemon that the player does not own.

For this script to work you'll need to activate a switch. (Read the comments on how to change the Switch ID)

Code:
################################################################################
# Pokemon Level Balancing
# By Umbreon
################################################################################
# Balances any and all pokemon's levels towards the player's party level.
#
# NOTE: This won't affect any pokemon the player owns.
#
# To use: simply activate Switch Number X
#  (X = the number listed After "Switch = ", default is switch number 37.)
#
#
################################################################################


module LevelBalance
  Switch = 37 # The switch used to activate/deactivate the level balancing
end

class PokeBattle_Pokemon
  
  alias balanced_level_init initialize
  
  def initialize(species,level,player=nil,withMoves=true)
    
    if $game_switches && $game_switches[LevelBalance::Switch] && $Trainer &&
      $Trainer.party.length > 0
      level = pbBalancedLevel($Trainer.party)
    end
    
    balanced_level_init(species, level, player, withMoves)
  end
end
Reply With Quote
  #2    
Old June 8th, 2014 (3:39 PM).
Radical Raptr's Avatar
Radical Raptr Radical Raptr is offline
#BAMFPokemonNerd
     
    Join Date: Mar 2011
    Location: everywhere
    Age: 24
    Gender: Male
    Nature: Sassy
    Posts: 1,118
    So you're saying that trainers will have pokemon that will change evolutionary lines and moves when this switch is activated?
    __________________

    ~My Deviantart - Litharreon Wiki - Litharreon Game Download~

    Reply With Quote
      #3    
    Old June 8th, 2014 (3:44 PM).
    ☆Rei☆'s Avatar
    ☆Rei☆ ☆Rei☆ is offline
     
    Join Date: Aug 2009
    Location: Nearby my feet.
    Age: 21
    Gender: Female
    Nature: Calm
    Posts: 1,746
    Quote:
    Originally Posted by Saving Raven View Post
    So you're saying that trainers will have pokemon that will change evolutionary lines and moves when this switch is activated?
    No, I'm saying that any Wild/Trainer pokemon you encounter will have a balanced out level of your party.

    So basically if you have a party of level 1s your enemy will also have a party of level 1 pokemon.

    Pokemon like charizard will not turn into charmander.

    But the same logic goes as a charmander will never turn into a charizard from this script.
    Reply With Quote
      #4    
    Old June 8th, 2014 (3:45 PM).
    Radical Raptr's Avatar
    Radical Raptr Radical Raptr is offline
    #BAMFPokemonNerd
       
      Join Date: Mar 2011
      Location: everywhere
      Age: 24
      Gender: Male
      Nature: Sassy
      Posts: 1,118
      Quote:
      Originally Posted by Umbreon View Post
      No, I'm saying that any Wild/Trainer pokemon you encounter will have a balanced out level of your party.

      So basically if you have a party of level 1s your enemy will also have a party of level 1 pokemon.

      Pokemon like charizard will not turn into charmander.

      But the same logic goes as a charmander will never turn into a charizard from this script.
      Ah, I thought so, but I saw species and level, and got my hopes up
      __________________

      ~My Deviantart - Litharreon Wiki - Litharreon Game Download~

      Reply With Quote
        #5    
      Old June 8th, 2014 (3:49 PM).
      ☆Rei☆'s Avatar
      ☆Rei☆ ☆Rei☆ is offline
       
      Join Date: Aug 2009
      Location: Nearby my feet.
      Age: 21
      Gender: Female
      Nature: Calm
      Posts: 1,746
      Quote:
      Originally Posted by Saving Raven View Post
      Ah, I thought so, but I saw species and level, and got my hopes up
      You see species there because I made an override onto the initialize script of PokeBattle_Pokemon. (which the initialization takes species, level, trainer, and a bool determining whether or not to add moves to the pokemon)
      Reply With Quote
        #6    
      Old June 8th, 2014 (8:07 PM).
      mej71's Avatar
      mej71 mej71 is offline
         
        Join Date: Mar 2014
        Location: Omnipresence
        Gender: Male
        Posts: 1,219
        You could make the species change accordingly using a script you already made :P . I used part of it for something similar, works like a charm.
        Reply With Quote
          #7    
        Old June 9th, 2014 (12:10 PM).
        ☆Rei☆'s Avatar
        ☆Rei☆ ☆Rei☆ is offline
         
        Join Date: Aug 2009
        Location: Nearby my feet.
        Age: 21
        Gender: Female
        Nature: Calm
        Posts: 1,746
        I may just add that actually.
        Reply With Quote
          #8    
        Old June 30th, 2014 (11:20 PM).
        FrostJackP FrostJackP is offline
           
          Join Date: Jun 2014
          Gender: Other
          Nature: Modest
          Posts: 19
          I'm not great at scripting so this may be a question with an obvious answer but could I modify this to just affect wild Pokémon and not trainers?
          Reply With Quote
            #9    
          Old August 24th, 2014 (4:06 PM). Edited September 5th, 2014 by DekuSamurai.
          DekuSamurai's Avatar
          DekuSamurai DekuSamurai is offline
             
            Join Date: Aug 2014
            Gender: Male
            Posts: 14
            This is a late reply, but...

            Quote:
            Originally Posted by FrostJackP View Post
            I'm not great at scripting so this may be a question with an obvious answer but could I modify this to just affect wild Pokémon and not trainers?
            You can actually already do this in version 13 without adding a new script. Look in PokemonEncounterModifiers, and find the following code, in the bottom of the script section:

            Code:
            #Events.onWildPokemonCreate+=proc {|sender,e|
               pokemon=e[0]
               if $game_map.map_id==51
                 pokemon.level=pbBalancedLevel($Trainer.party) - 4 + rand(5)   # For variety
                 pokemon.calcStats
                 pokemon.resetMoves
               end
            }
            Change map_id (in this case "51") to any map number where you want the script to apply.

            You could use an array to make it apply to multiple maps, for example:
            Code:
               if $game_map.map_id==[22,33,51]
            Or, of course, you could just make it apply to all wild pokémon everywhere.

            Anyway, you can also change "pbBalancedLevel" to "pbTopLevel" if you want the wild pokémon to be based the highest level in the player's party, and not the average level. That works better, in my opinion. (You'd need to have a little more setup to make that work right, though.)
            Reply With Quote
              #10    
            Old September 8th, 2014 (6:14 PM).
            FrostJackP FrostJackP is offline
               
              Join Date: Jun 2014
              Gender: Other
              Nature: Modest
              Posts: 19
              Quote:
              Originally Posted by DekuSamurai View Post
              This is a late reply, but...


              You can actually already do this in version 13 without adding a new script. Look in PokemonEncounterModifiers, and find the following code, in the bottom of the script section:

              Code:
              #Events.onWildPokemonCreate+=proc {|sender,e|
                 pokemon=e[0]
                 if $game_map.map_id==51
                   pokemon.level=pbBalancedLevel($Trainer.party) - 4 + rand(5)   # For variety
                   pokemon.calcStats
                   pokemon.resetMoves
                 end
              }
              Change map_id (in this case "51") to any map number where you want the script to apply.

              You could use an array to make it apply to multiple maps, for example:
              Code:
                 if $game_map.map_id==[22,33,51]
              Or, of course, you could just make it apply to all wild pokémon everywhere.

              Anyway, you can also change "pbBalancedLevel" to "pbTopLevel" if you want the wild pokémon to be based the highest level in the player's party, and not the average level. That works better, in my opinion. (You'd need to have a little more setup to make that work right, though.)
              Could I make it depend on a variable? The game I'm making allows you to challenge any of the gym leaders in any order, and the game should balance itself around how many badges you have. Is there any way I can achieve this without too much modification to the scripts?
              Reply With Quote
                #11    
              Old September 9th, 2014 (4:04 AM). Edited February 27th, 2015 by Bowlstir.
              Bowlstir's Avatar
              Bowlstir Bowlstir is online now
              Media Arts and Game Development
                 
                Join Date: Apr 2008
                Location: USA
                Gender: Male
                Nature: Adamant
                Posts: 198
                Thanks a lot mate.

                Works great.
                =====
                __________________


                Reply With Quote
                  #12    
                Old December 15th, 2015 (9:10 AM).
                roby_kof's Avatar
                roby_kof roby_kof is offline
                   
                  Join Date: Dec 2015
                  Gender: Male
                  Posts: 10
                  thanks for the script! i've created this version:
                  Code:
                  module LevelBalance
                    Switch = 81 # The switch used to activate/deactivate the level balancing
                  end
                  
                  class PokeBattle_Pokemon
                    
                    alias balanced_level_init initialize
                    
                    def initialize(species,level,player=nil,withMoves=true)
                      
                      if $game_switches && $game_switches[LevelBalance::Switch] && $Trainer &&
                        $Trainer.party.length > 0
                        #level = pbBalancedLevel($Trainer.party) #original version
                        level = $Trainer.numbadges*10+ rand(5)
                      end
                      
                      balanced_level_init(species, level, player, withMoves)
                    end
                  end
                  levels are balanced around the number of badges!
                  Reply With Quote
                    #13    
                  Old February 28th, 2018 (11:36 AM).
                  fralixdudetheguy93850stuff fralixdudetheguy93850stuff is offline
                     
                    Join Date: Jan 2018
                    Posts: 1
                    Hey there, if you dont mind, where exactly do I add this piece of script? Do i plug it in above "main", add it in with "pfield_encountermodifiers", or somewhere in "NPC_Trainers"?
                    Reply With Quote
                      #14    
                    Old 4 Weeks Ago (12:55 PM).
                    Nessis Nessis is offline
                       
                      Join Date: Jan 2017
                      Gender: Male
                      Posts: 6
                      Is it also possible to balance your party to your encounter? Like i have a charizard lvl 55 but i fight a trainer with a lvl5 pokemon my char izard will be lvl 5 also?
                      Reply With Quote
                        #15    
                      Old 4 Weeks Ago (1:48 PM). Edited 4 Weeks Ago by WolfPP.
                      WolfPP's Avatar
                      WolfPP WolfPP is offline
                         
                        Join Date: Aug 2018
                        Location: Brazil
                        Gender: Male
                        Nature: Jolly
                        Posts: 146
                        Quote:
                        Originally Posted by Nessis View Post
                        Is it also possible to balance your party to your encounter? Like i have a charizard lvl 55 but i fight a trainer with a lvl5 pokemon my char izard will be lvl 5 also?
                        No. If you have a charizard lvl 55 and fight to a trainer with a lvl 5 pokemon, that pokemon will be a lvl 50~60.

                        Your PT lvl dont be affect by that script. Only lvl to wild encounter and trainers battle.

                        EDIT:

                        So, take a look to that script, its a little better:
                        https://www.pokecommunity.com/showthread.php?t=409828
                        Reply With Quote
                        Reply

                        Quick Reply

                        Join the conversation!

                        Create an account to post a reply in this thread, participate in other discussions, and more!

                        Create a PokéCommunity Account
                        Thread Tools

                        Posting Rules
                        You may not post new threads
                        You may not post replies
                        You may not post attachments
                        You may not edit your posts

                        BB code is On
                        Smilies are On
                        [IMG] code is On
                        HTML code is Off

                        Forum Jump


                        All times are GMT -8. The time now is 12:17 AM.