Tie a variable to party lead?

Imagine a game where there is no main character, but three. You can change the leader of the party at will. However, how come whenever you interact with other people or objects, it's always Ralph that speaks, even when he's at the back of the party? Since Ulrika is currently the leader, shouldn't she be the one that's speaking?

Well it sounds easy enough. I can just make each of the interactions that rely on the leader to be split into separate text boxes. Say ralph is the leader, then the variable is set to 1, so the game knows to show Ralph speaking it, face art and personality all intact.

TLDR: Is there a way to tie a variable to whoever is leading? Or will this require a script? My goal is to have three different characters all be the main character, and the player can switch between them being the leader at will. Or maybe for certain parts, I'll need to force change who the leader is, and it would be pretty convenient to just adjust the variable too, but I understand I can event that. The real goal is to have this variable change as soon as the built-in formation tool changes the leader, that way if the player changes it, I know who's the leader, and I can make sure that the player sees the leader's speech reflecting primarily. This would also allow me to have characters take different positions in scenes and reset the party formation after a scene.
There are several ways to do it.

You can use Control Variables > Game Data to put the ID of the first party member into a variable. Then you can use conditional branches to check who is leading and alter the Show Text command for each. This would be the approach to take if you want to change the dialogue depending on the leader. You would have to set the variable before each Show Text command.

If you want them all to say the same thing and just change the face (and maybe the name) to the party leader, you will need a plugin. I wrote the More Escape Codes plugin that ships with the engine - in the DLC plugins folder, under my name - but I'm not sure that allows you to specify "the leader" or if it requires an actor id - you could probably put the leader id into a variable and use the code \f[\v[#]] code.

If you don't want to set the variable manually, you can use my Linked Variables plugin to set a variable to be $gameParty.leader().actorId() - check that formula, I don't have MV with me so it may not be correct. This will let you use the variable in conditional branches or escape codes in Show Text, but you should not use it for event page conditions as it's only evaluated when you want to see what's in it, not when the condition actually changes (ie - it updates when you use the variable in a conditional branch, not when the player changes the lineup).
Thanks Shaz! I'll try it out when I get home and report on problems I have.
IT WORKS! Thanks for your help!

Is anyone else happens to stumble across this topic, here's a screenshot of how I got it to work.

KH2cNgn.png


Thanks again!

EDIT: I'd also liek to mention this could also be done with multiple pages for the event and it might actually be better if it's done that way. Just have the first page set the variable and then have the other pages set to work for each variable. It would keep it all much cleaner.
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/tie-a-variable-to-party-lead.82428/