How to switch the main character with one button?

Hey 😍

I'm using RPG Maker MV. I have all of yanfly plugins and a few others, so I can do this with "button common event". But the eventing part is what I don't really know how to do. I have this party of 4-6 characters, and in specific maps (like before a level ou a challenge) I want the player to be able to press a button and choose which character will "lead" the level. For example: there's a trivia challenge, so I'd like to change from the pirate to the all-knowing robot before entering the contest.

So far I did it in a way the party only has one character - so each time the player chooses, all the non-chosen characters are excluded from the party and the chosen is added. Also, everytime it happens, the event changes the Actor#01 name to the chosen character's name, so conversations may sound more natural and it appears the right name above the chat (with yanfly messages plugin).
Just changing the formation won't help, because I'd like to create specific triggers to each character (but only if he's leading) and I believe there isn't a way to do this only by checking which character occupies the first slot (or is there? If so, this could be half of a solution - the other half would be doing it pressing only one button).

The only way I've thought of it would be changing name/class/sprite of Actor01 for every character, then excluding him of the party. That would also require maybe a switch or variable that tells me what character was Actor01 before, so this character can be reinserted to the party. But it seems a lot of work and maybe it wouldn't work well, because it wouldn't transfer the equipped items from actor to character and vice versa. Any ideas?
What I did in some older RM (either 2k or XP) was have the action check who is at the front, then move them to the back of the party so a button press would just cycle the party around. MV does allow it to go the other way around, but sadly I've forgotten what call you have to do to move someone to the front.

Just changing the formation won't help, because I'd like to create specific triggers to each character (but only if he's leading) and I believe there isn't a way to do this only by checking which character occupies the first slot (or is there? If so, this could be half of a solution - the other half would be doing it pressing only one button).
You just need a script call for the conditional branch.



$gameParty.leader().actorId() == ID

That link is a massive script call database for MV. For the above, you just replace the ID with the actor's ID to see if that actor is the leader.
MV does allow it to go the other way around, but sadly I've forgotten what call you have to do to move someone to the front.

Omg, it sounds perfect for what I need 😐

$gameParty.leader().actorId() == ID

That link is a massive script call database for MV. For the above, you just replace the ID with the actor's ID to see if that actor is the leader.

Oh, thank you so much! I've been looking for this for ages now, but I didn't know exactly what to look for, so I'd never found it.
in a common event, i would add a conditional branch if down arrow is pressed then a scriptcall remove party member [x] add party member [x] and so on for each button...i think you can do better with common button event or something like that from yanfly library...
in a common event, i would add a conditional branch if down arrow is pressed then a scriptcall remove party member [x] add party member [x] and so on for each button...i think you can do better with common button event or something like that from yanfly library...

I've been trying for a few minutes now but it doesn't seem to work. Here's what I did so far:

$gameVariables.setValue(321, $gameParty.members()[0]._actorId) --- So the variable 321 holds the deleted actor id; this seems to work fine

$gameParty.removeActor($gameVariables.value(321)) --- Removing this actor (also tried changing $gamevariables for $gameParty.members, none of them worked)

$gameParty.addActor($gameVariables.value(321)) --- Adding the removed actor back

Absolutely nothing happens. The party leader stays there.

I've moved this thread to MV Support. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-switch-the-main-character-with-one-button.126194/