• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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
7
Years
  • Age 22
  • 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
 
1,680
Posts
8
Years
  • Age 24
  • Seen today
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:
233
Posts
5
Years
  • Age 33
  • Seen Oct 9, 2023
"$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:
25
Posts
7
Years
  • Age 22
  • Seen Feb 19, 2020
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!
 
233
Posts
5
Years
  • Age 33
  • Seen Oct 9, 2023
My bad! You'll need to change two things in restoreteam: Change "$game_variables.length" to "$game_variables[xxx].length", and change "$game_variables" to "$game_variables[xxx]". I also updated my previous reply with the correct code, so updating restoreteam should do it.
 
25
Posts
7
Years
  • Age 22
  • Seen Feb 19, 2020
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:
233
Posts
5
Years
  • Age 33
  • Seen Oct 9, 2023
Oh, it seems the Pokemon's stats are "read only", so they can't be changed... okay, I'm gonna update my previous reply again, taking a slightly different approach this time. I should've actually tested the code before, so I'm sorry about not doing that earlier.
 
Back
Top