Store party data, delete and retrieving party

Jephed

Trainer
Member
Joined
Apr 1, 2017
Posts
98
I haven't seen this question elsewhere and I've been stuck on this for quite a while now.

I'll cut straight to the point.

The Bug Catching Contest in Pokémon Essentials' Default MAP029 has a neat little gimmick where you choose one Pokémon to go into the contest with, while the rest of your party is temporarely removed and given back after the contest.
I want to replicate this and tinker with the party Pokémon data in a number of different scenario's.

1. Make a pokémon be choosable to take to a contest (all the other pokémon being temporarely removed and restored later) and have this be triggered via commands within the script editor instead of via an event.

2. Store the party data, temporarely remove the entire party, and restore the party with script commands. (with the entire party this time, so without choosing a Pokémon first)

I've messed with this feature for a couple of months now, and I can't seem to make it work.
I know that the script section PBattle_BugContest holds a lot of useful information, but I couldn't seem to bend it more to my liking.

If anybody is able to help me out with this or at least point me further in the right direction that would be greatly appreciated!
 

Marin

Administrator
Administrator
I hope I understand the question correctly:

You first need to store the party somewhere. First choice to come to mind is then global variables. Storing the party in there would look a bit like this:
Code:
$game_variables[100] = $Trainer.party.clone
If this throws an error, remove the .clone part. Added it for safety reasons.

You the need to clear the party array, which would be:
Code:
$Trainer.party.clear
<Array>.clear just clears the array.

You can now do whatever you need to do.
If you need to access the old party, you can simply refer to the global variable.
For example, if you want to get the name of the first Pokémon in the old party, that would be:
Code:
$game_variables[100][0].name

When you want to restore the old party, you simply do the opposite of how we stored it (without the .clone):
Code:
$Trainer.party = $game_variables[100]
We may as well set that variable to nil now so it won't cause any issues in the future by doing
Code:
$game_variables[100] = nil

In one block:
Code:
$game_variables[100] = $Trainer.party.clone
$Trainer.party.clear
# You can now do your logic.
$Trainer.party = $game_variables[100]
$game_variables[100] = nil
 

Jephed

Trainer
Member
Joined
Apr 1, 2017
Posts
98
[@Marin I´ve tried it out with a number of events and it works very well! This solved one of the problems I had, so thanks a bunch for that!!!

I do want to mention that the line $Trainer.party = $game_variables[100] changed to $Trainer.party = pbGet[100] when I refreshed my RPG Maker Project. Just a minor thing, (just saying in case someone else wants to try this out.)


Also, if I want to clone and store data for one Pokémon rather than the entire party I asume it´ll be something along the lines of $game_variables[101] = $Trainer.pokemon(0).Clone ?
Don't know if I'm correct there.


My final question: (perhaps very obvious) Do these commands also work if you were to use them from within the script editor?
I'm currently adjusting a script section that will require these commands to occur with the press of an input trigger (i.e. the ctrl button), instead of an event. (I should've been more clear about this in my initial post)
Will these commands also work in a script section, or will I need to change something when writing them down there?


Thanks again for your help!! :)
 

Marin

Administrator
Administrator
[@Marin I´ve tried it out with a number of events and it works very well! This solved one of the problems I had, so thanks a bunch for that!!!

I do want to mention that the line $Trainer.party = $game_variables[100] changed to $Trainer.party = pbGet[100] when I refreshed my RPG Maker Project. Just a minor thing, (just saying in case someone else wants to try this out.)


Also, if I want to clone and store data for one Pokémon rather than the entire party I asume it´ll be something along the lines of $game_variables[101] = $Trainer.pokemon(0).Clone ?
Don't know if I'm correct there.


My final question: (perhaps very obvious) Do these commands also work if you were to use them from within the script editor?
I'm currently adjusting a script section that will require these commands to occur with the press of an input trigger (i.e. the ctrl button), instead of an event. (I should've been more clear about this in my initial post)
Will these commands also work in a script section, or will I need to change something when writing them down there?


Thanks again for your help!! :)

Alternatives to get/set global variables is by using pbGet and pbSet (I personally never use them), so pbGet(100) should be fine.

If you want to store just one Pokémon, you'd do:
Code:
$global_variables[100] = $Trainer.party[0].clone
You could also use pbSet for this.

And yep, these will all work in the scripts as well.
 

Jephed

Trainer
Member
Joined
Apr 1, 2017
Posts
98
It seems to work fine! Thanks man! I did find another problem in the script editor, while testing this out, but I'll try to fix that myself for now, otherwise I'll make a new post some time in the future.
 

kmb

dabbling in game design
Member
Joined
Jul 7, 2018
Posts
62
I'm sorry. I'm not following this. I want to create two events that are like this, one where the player captures a certain Pokemon and then gets that Pokemon taken away, and one where the the player gets all of their Pokemon in their party stolen. So far, none of the codes I've tried have worked.
 
Top