How to swap multiple characters?

In my game characters can switch between them to resolve puzzles. At the start it's two characters and it switches just fine....
sw.PNG


But when it comes to 3 characters I can't make it work to make them switch correctly. Is there a way to make it work? Or it's not possible in Rpg Maker?

sw2.PNG
How do you want them to switch - just put the leader at the end each time? That means if you want the 3rd party member to lead, they'd have to switch twice. Can you translate some of those commands to English?
since it's a parallel process, it could be that the effect happens so fast you're not seeing it.
it needs to be redesigned, from "spinning the wheel" to "single-shot trigger"

there's three things you need to solve: the taking one actor out and replacing for a new one, the going in and out of that process without the variables messing up, and the listening for the button push.

(I might have solved this years ago in my end... let me dig up the routine)

EDIT: here.
it can't be made with variables, it needs to be done by code because the "change party member" command only works by direct ID, not "whatever this variable says"
this needs to be tied to a button push... I run it as part of a sequence.
Spoiler
nuevo-1.jpg

nuevo-2.JPG

nuevo-3.jpg

if you're only ever shifting the party around, removing/adding characters through the commands won't work, because with 2 characters, if 1 is not chosen, then 2 is the only option, but with 3 or more, if 1 is not chosen, then the next option could be either 2 or 3, and it's a mess of nested conditionals.
use this block instead... it'll always shift the party around, but lock the button press from looping.

Code:
pr=$game_party
ld=pr.members[0]
pr.remove_actor(ld.id)
pr.add_actor(ld.id)
Since you just need to SWAP the party members, what you need is a script call to this method:

Ruby:
$game_party.swap_order(Pos1, Pos2)

Where Pos stands for position starting from 0, never forget that!

There's a catch. The conditional branch looks for a button being triggered but the truth is that it should be pressed. So there pulsado gotta be translated as pressed, even if it'd normally be fine to say it was triggered. This fact changes the whole thing because it'll keep changing your party members like crazy as long as you keep pressing the button. It'd be better to use a custom scene script or use an additional event to make the change by just selecting a member from a list.
Tried to add variables with the actors's ID, but no, the problem is still there. It swaps characters once and then nothing.
How do you want them to switch - just put the leader at the end each time? That means if you want the 3rd party member to lead, they'd have to switch twice. Can you translate some of those commands to English?
By pressing A, I swap by put the leader at the front. I managed to do it with 2 charas, but not with 3.
And sure, I translated some of them.
sw0.png
There are several script to rotate the formation. Have you tried any of those?
Otherwise there is also a script for swapping actors. Kyonides gave you the command, the script just makes it a little easier.
There are several script to rotate the formation. Have you tried any of those?
Otherwise there is also a script for swapping actors. Kyonides gave you the command, the script just makes it a little easier.
I tried Tsukihime's rotate formation, but the swap can't be disabled at cutscenes....and to be honest I didn't understood what Kyonides was trying to say, much less the Pos thing.
If you look here in my small script the command Kyonides mentioned is there.
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Actor Swap For Conversation  ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║                                     ╠════════════════════╣
# ║   Swap actor positions              ║    14 Apr 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Allows to change actors to make a specific actor first   ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║   Set the variable below for this script                 ║
# ║                                                          ║
# ║   Use script call to swap actors                         ║
# ║      swap_actor_convo(X)                                 ║
# ║        X = actor id to be at the front of the party      ║
# ║   Then use swap_actor_convo($game_variables[X])          ║
# ║        X = the variable number used below                ║
# ║     to change the actor back to original position        ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

module R2_Swap_Actor_Conversation
  Variable = 1
end
class Game_Interpreter
  def swap_actor_convo(aid)
    for i in 0..$game_party.members.size - 1
      swap = i if $game_party.members[i].id == aid
    end
    return if swap == 0
    $game_variables[R2_Swap_Actor_Conversation::Variable] = $game_party.members[0].id
    $game_party.swap_order(0, swap)
  end
end

You can use this or just use the command.
So it's basically $game_party.swap_order(actor_id1, actor_id2)
Swap actor 1 with actor 2. The numbers are the actor id number from the database.
$game_party.swap_order(1, 3)
In the editor you use the script command. Page 3 of the event commands
@SakuraMiya ahem... *points to earlier post*
@SakuraMiya ahem... *points to earlier post*
I saw it, looks too convoluted. And my project is not a fighting game anyway, just switching characters to solve certain puzzles.
By pressing A, I swap by put the leader at the front. I managed to do it with 2 charas, but not with 3.
This does not explain what you are trying to do. The leader is always at the front.

If you have actor 1 then 2 and 1 is the leader, when you press A you obviously want to change the order to 2 then 1.

But what if your actors are in this order: 1 2 3
When you press A, do you want actor 1 to move to the end and actor 2 will become the leader (2 3 1)?
Then when you press A again, the same will happen (3 1 2)?
And when you press A a third time, the same will happen, bringing you back to the original order (1 2 3)?
Are you just moving the leader to the end each time?

If the above is what you want, then your entire event needs to be this:
Code:
Conditional Branch: if Button A is Pressed
  Script: $game_party.actors.push($game_party.actors.shift)
End

and insert the following script above Main:
Code:
class Game_Party < Game_Unit
  attr_accessor   :actors
end


If this is not what you are trying to do, then you need to explain how, in a party of 3 or 4, you determine who is going to be the next leader, and whether they just move to the front and everyone else stays in the same order, or if the old leader actually swaps places with the new leader.


I'm afraid your translation wasn't very helpful. What are these?
1679006089817.png
I'm afraid your translation wasn't very helpful. What are these?
View attachment 256158
Yeah, you're not asked to speak Spanish in a English speaking forum so it gotta be confusing for you. Let me lend you a hand here.

Botón = Button, Pulsado = Pressed, Cambiar Miembros = Change Members, Mostrar Animación = Show Animation.
Code:
Code:
If Button A is Pressed
  $game_party.actors.push($game_party.actors.shift)
End
I don't think I would have thought of that on my own, but seeing it now... that's genius.
Based on previous suggestions, I'd recommend copying this:

Ruby:
class Game_Party
  def first2last
    @actors << @actors.shift
    $game_player.refresh
  end
end

Then paste it in a new script section.

That would allow Miya to shorten the call to:

Ruby:
$game_party.first2last

That piece of code's specially convenient because there's no actors method by default for the Game_Party class, but there's one called members. Adding an actors method by hand isn't as helpful as it might look like at first.

The problem with members is that it'd convert ID's to actors and only then do the shift...
So that's exactly the reason why the short script call comes in handy here!
It also takes care of refreshing the sprites on the map!
*AHEM!*

if you're only ever shifting the party around, removing/adding characters through the commands won't work, because with 2 characters, if 1 is not chosen, then 2 is the only option, but with 3 or more, if 1 is not chosen, then the next option could be either 2 or 3, and it's a mess of nested conditionals.
use this block instead... it'll always shift the party around, but lock the button press from looping.

Code:
pr=$game_party
ld=pr.members[0]
pr.remove_actor(ld.id)
pr.add_actor(ld.id)

can you read?
*AHEM!*



can you read?
Yet, it doesn't refresh the sprites or at least their character_name's.
Plus, it's highly like Miya never could.
Yet, it doesn't refresh the sprites or at least their character_name's.
Plus, it's highly like Miya never could.
Which is why I didn't go with it....
Yet, it doesn't refresh the sprites or at least their character_name's.
Plus, it's highly like Miya never could.
if you use add/remove actor like that, those calls have the required refresh calls in them.
I did say to change the loop event to a single trigger... when the loop breaks, focus is returned to the map, and the refresh takes care of that.

if you use push/shift, you'll be operating directly on the actors array within the party object, bypassing the refresh.
@SakuraMiya So what you want is to swap characters on the map at the press of a button?

I have a method of doing this that works very well for me, in case that is what you want.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-swap-multiple-characters.155825/