PSDK multi-protagonist system

TL;DR

For now, the basic usage is the function switchplayersafe(id_player).

By having "switch_player_safe(2)" in an event,  you switch to player 2 (by default, you are player 1). At first, the player has no appearance, money or anything, but once you have set those (see how the start event define the player 1 for example), the data is kept in memory for all the futur switches. The number of players is not limited.


Details of the implementation and the possibilities

All the switches are based on the same function architecture. For exemple, regarding the party, the switch uses

* empty_and_save_party(from_player_id)

* retrieve_saved_party(to_player_id)

Note : The current player_id is kept in the variable 51, to prevent the maker from doing the mistake of switch an player id with itself, which would result in erasing all the data. This is the "safe" in switch_player_safe, you're welcome, my pleasure.

In detail, the switch currently adresses :

  • bag
  • party
  • trainer
  • appearance
  • money
  • pokedex

By default, every category is switched. However, you can decide not to switch some of these by using the options switch_X and set them to false.

For exemple, if your scenario imposes that the money and pokedex is shared among your protagonist, to go from the current player to the player 2, you can use :

switch_player_safe(2, switch_pokedex: false, switch_money: false)

Note that by default, a player has no money, no appearance, etc... It is mandatory to initialize a player the first time it is used. A example could be in an event :

switch_player_safe(2)
$pokemon_party.trainer.set_gender(true)
$game_player.set_appearance_set('hero_01_white')
$game_player.update_appearance
$trainer.name = 'White'