Advertiser Content

Custom Feature Question Lvl capping to 50

Started by Plapla0301 April 28th, 2019 1:41 PM
  • 381 views
  • 8 replies

Vendily

Female
Online now
Posted 5 Days Ago
971 posts
4.3 Years
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
$game_variables[XXX]=$Trainer.party.clone
$Trainer.party.each{|pkmn|pkmn.level=50}
After the battle
$Trainer.party=$game_variables[XXX]
$game_variables[XXX]=0
I didn't really test it though so it might not work as is.

Male
Seen 2 Weeks Ago
Posted 3 Weeks Ago
38 posts
316 Days
"$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:
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:
$Trainer.party = $game_variables[xxx]
$game_variables[xxx] = 0
Male
Seen June 17th, 2019
Posted May 8th, 2019
24 posts
3.5 Years
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!
Male
Seen June 17th, 2019
Posted May 8th, 2019
24 posts
3.5 Years
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[i]
clonepoke = $game_variables[37][i]
# 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
--------------
Advertiser Content