Solved Temporarily change party Level

bassplayer

Rookie
Member
Posts
7
#1
Hello,

I'm trying to do a tournament system in my fangame, but I couldn't figure out how to set temporarily the player's party levem to 100.

I used an approach based on saving the party on a variable, after that, raising it's level and after the battles, clearing the modified party and reestabilish the older party saved on the variable.
But it seens that changing the party level also changes the pokemon stocked in the Variable. So I couldnt reset the Pokémon to their original levels.

Am I loosing something or it isn't the correct method?

Thx, and sorry for bad english.
 

bassplayer

Rookie
Member
Posts
7
#3
You might want to check out this thread about temporarily replacing the player's party.;it's pretty similar since you want to capture what the player's party is like and restore it later.
I Just did exactly what is proposed in this thread, what led me to the outcomes I've described earlier. Seens like altering the party also makes the pokémon stored in the variable change.
 
Posts
13
#4
What were the specific Pokémon in your party before you tried to change their levels, and what did the Pokémon change into after you tried to change their levels? For example, did you store a Pikachu into a global variable, and it turned into a Marill after you retrieved it from the variable? What were the levels of the Pokémon before you changed them, and what levels did you set them to? Did anything else about the Pokémon change (moves, stats, etc.) after you retrieved them?
 
Last edited:

bassplayer

Rookie
Member
Posts
7
#5
What were the specific Pokémon in your party before you tried to change their levels, and what did the Pokémon change into after you tried to change their levels? For example, did you store a Pikachu into a global variable, and it turned into a Marill after you retrieved it from the variable? What were the levels of the Pokémon before you changed them, and what levels did you set them to? Did anything else about the Pokémon change (moves, stats, etc.) after you retrieved them?

I'm on my phone, so I'll tell you step by step what I did.

1- stored the party data at a variable
2- changed their level to level 100 via script
3- recalcstats to chance their stats.

Until here, everything working wonderfuly. after that, they should come back as their level before, so there's what I did.

4- cleared the party.
5- restabilished the party from the variable.

But when I do this last step, the party is lvl 100 again. Like I set them AFTER storing them on a variable.

I just used the same codes that were suggested at the other thread.

So, am I missing something?

PS: I was using the essentials demo party, but with a charizard replacing pikachu. All sightly leveled up (30~ish).
 

MGriffin

Trainer
Member
Posts
74
#6
1- stored the party data at a variable
You're probably storing references to the Pokémon, instead of copies. You might have better luck storing just their exp values in that variable, and then restoring just the exp, if that would work? Something a bit like:
Code:
# Save
party_exp = {}
party.each do |pkmn|
  party_exp[pkmn] = pkmn.experience
  pkmn.level = 100
  pkmn.calcStats
end

# Load
party_exp.each do |pkmn, exp|
  pkmn.experience = exp
  pkmn.calcStats
end
(Note, I've just guessed what experience and level are called on Pokémon, you'll need to look it up)

Of course you could also work out how to clone Pokémon. This is probably much easier, and less likely to have subtle bugs? Might swallow and/or duplicate held items, depending on exactly what the player can do while the Pokémon are leveled-up.
 
Posts
13
#7
But when I do this last step, the party is lvl 100 again. Like I set them AFTER storing them on a variable.

I just used the same codes that were suggested at the other thread.
Thanks for the added information. So after you tried to restore your party to its previous state from the variable, was it like as if no restoration occurred at all?

Of course you could also work out how to clone Pokémon. This is probably much easier, and less likely to have subtle bugs? Might swallow and/or duplicate held items, depending on exactly what the player can do while the Pokémon are leveled-up.
The linked thread seemed to provide an option to clone Pokémon instead, which would in theory completely restore the party to its previous state (any changes to held items, HP, PP, status, etc. would be erased). @bassplayer, does your code to store the party look like
Ruby:
$game_variables[100] = $Trainer.party.clone
(with the “.clone” part) as in the other thread?

Edit: What if instead of party.clone, you individually cloned each Pokémon in your party, in a loop? Try cloning, storing, and restoring each party member one by one.
 
Last edited:

bassplayer

Rookie
Member
Posts
7
#8
Thanks for the added information. So after you tried to restore your party to its previous state from the variable, was it like as if no restoration occurred at all?


The linked thread seemed to provide an option to clone Pokémon instead, which would in theory completely restore the party to its previous state (any changes to held items, HP, PP, status, etc. would be erased). @bassplayer, does your code to store the party look like
Ruby:
$game_variables[100] = $Trainer.party.clone
(with the “.clone” part) as in the other thread?

Edit: What if instead of party.clone, you individually cloned each Pokémon in your party, in a loop? Try cloning, storing, and restoring each party member one by one.
Was $Trainer.party.clone the code I was using. I tried very quickly to clone the party into 2 variables, but changing the party level sill mess with the Pokémon stored in both Variables.
 
Posts
13
#9
Was $Trainer.party.clone the code I was using. I tried very quickly to clone the party into 2 variables, but changing the party level sill mess with the Pokémon stored in both Variables.
How about something like this? Borrowing @MGriffin's formatting:
Ruby:
# Save
$game_variables[100] = []
$Trainer.party.each do |pkmn|
  $game_variables[100].push(pkmn.clone)
end

# Set levels and do anything else here until you need to restore the party

# Load
$Trainer.party.clear
$game_variables[100].each do |pkmn|
  $Trainer.party.push(pkmn)
end
$game_variables[100] = nil
 

bassplayer

Rookie
Member
Posts
7
#10
How about something like this? Borrowing @MGriffin's formatting:
Ruby:
# Save
$game_variables[100] = []
$Trainer.party.each do |pkmn|
  $game_variables[100].push(pkmn.clone)
end

# Set levels and do anything else here until you need to restore the party

# Load
$Trainer.party.clear
$game_variables[100].each do |pkmn|
  $Trainer.party.push(pkmn)
end
$game_variables[100] = nil
https://www.imagemhost.com.br/image/3QW3M

got this error with the second code.
 
Posts
13
#13
It gets this change when compiled.
Hm, what if you put each part of the code into a script section instead of directly into an event? So you could have one function that performs the saving operation, and another function that performs the load. Then have a saving event call the saving function, and have a loading event call the loading function.

I'll test out this, and other solutions I can think of, sometime when I can sit down and work on my fangame. I plan to create a similar effect in my own game too.
 

bassplayer

Rookie
Member
Posts
7
#14
Hm, what if you put each part of the code into a script section instead of directly into an event? So you could have one function that performs the saving operation, and another function that performs the load. Then have a saving event call the saving function, and have a loading event call the loading function.

I'll test out this, and other solutions I can think of, sometime when I can sit down and work on my fangame. I plan to create a similar effect in my own game too.
Let me say that you nailed it. Actually I mistyped something, thats whats giving that last error.

Thank you very much!
 
Top