• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Custom Feature Question] Lvl capping to 50

  • 25
    Posts
    8
    Years
    • Seen Feb 19, 2020
    So I have a postgame battle in which I want both the player and the opponent's Pokemon to all be scaled up or down to lvl 50. lvl 100 would work too, I just need to know how to set this so that all Pokemon temporarily become the same, preset level
     
    So I have a postgame battle in which I want both the player and the opponent's Pokemon to all be scaled up or down to lvl 50. lvl 100 would work too, I just need to know how to set this so that all Pokemon temporarily become the same, preset level

    Hi, I moved this thread to the Pokémon Essentials forum because it's a question.

    Guess you could store the party in a variable and set the levels to 50, then restore the old party after the fact.

    Before the battle
    Code:
    $game_variables[XXX]=$Trainer.party.clone
    $Trainer.party.each{|pkmn|pkmn.level=50}
    After the battle
    Code:
    $Trainer.party=$game_variables[XXX]
    $game_variables[XXX]=0

    I didn't really test it though so it might not work as is.
     
    Last edited:
    "$Trainer.party.clone" creates what is called a "shallow copy" of the array, meaning that the Pokemon themselves don't actually get copied. What you'll want to do is store an array of the player's Pokemons' information first, then restore that after battle.

    Before the battle:
    Code:
    tempParty = []
    for i in $Trainer.party
      clonepoke = i.clone
      clonepoke.ev = i.ev.clone
      clonepoke.iv = i.iv.clone
      for j in 0...6
        clonepoke.ev[j] = i.ev[j]
        clonepoke.iv[j] = i.iv[j]
      end
      clonepoke.level = 50 # Set this to whatever preset level you want
      clonepoke.calcStats
      tempParty.push(clonepoke)
    end
    $game_variables[xxx] = $Trainer.party
    $Trainer.party = tempParty

    After the battle:
    Code:
    $Trainer.party = $game_variables[xxx]
    $game_variables[xxx] = 0
     
    Last edited:
    thanks so much! Starting the battle works but something about the code that runs afterwards is broken.
    The error message I get is the following:

    ---------------------------
    Pokemon Hollandia
    ---------------------------
    Exception: RuntimeError
    Message: Script error within event 13, map 112 (Sprite testing facility):
    Exception: NoMethodError
    Message: Section197:11:in `restoreteam'undefined method `length' for #<Game_Variables:0x11b28e88>
    ---------------------------------
    I should note that I defined both scripts as functions named saveteam and restoreteam respectively since the latter was too long to fit within a script box.
    Any help would be greatly appreciated!
     
    Thanks so much for your help. However when I try to use the updated one (with the x's changed to variable 37) I get the follow error:

    ---------------------------
    Exception: RuntimeError

    Message: Script error within event 13, map 112 (Sprite testing facility):

    Exception: NoMethodError

    Message: Section197:17:in `restoreteam'undefined method `totalhp=' for #<PokeBattle_Pokemon:0x11b7e588>
    -----------------------

    I've tried switching around the order in which the values are restored but it's always the first stat after level that causes an error.

    this is my full code:
    -----------
    def saveteam
    $game_variables[37] = []
    for i in $Trainer.party
    $game_variables[37].push(i.clone)
    i.level = 50 # Set this to whatever preset level you want
    i.calcStats
    end
    end

    def restoreteam
    for i in 0...$game_variables[37].length
    poke = $Trainer.party
    clonepoke = $game_variables[37]
    # Need to set all these variables because the calcStats from before the battle changed them
    poke.level = clonepoke.level
    poke.hp = clonepoke.hp
    poke.attack = clonepoke.attack
    poke.defense = clonepoke.defense
    poke.speed = clonepoke.speed
    poke.spatk = clonepoke.spatk
    poke.spdef = clonepoke.spdef
    poke.totalhp = clonepoke.totalhp
    end
    $game_variables[37] = 0
    end
    --------------
     
    Last edited:
    Back
    Top