MZ Character swapping problem

I've implemented a party switching ability for my game based on this thread https://forums.rpgmakerweb.com/index.php?threads/concept-mid-battle-party-switch.147025/. The problem is, I want the actor I switch to to be able to act immediately.

Here are some screenshots and the script I used.



Help2.png
Help1.png


Spoiler: Full Script
$gameMessage.setChoices($gameParty.allMembers().slice($gameParty.maxBattleMembers()).filter(actor => actor.isAppeared()).map(a => a._name), 0, -1);
$gameMessage.setChoicePositionType(1);
$gameMessage.setChoiceCallback(n => {
var userId = $gameParty._actors.indexOf($gameTemp._user._actorId);
var reservedId = ($gameParty.maxBattleMembers()+n);
var temp = $gameParty._actors[userId];
$gameParty._actors[userId] = $gameParty._actors[reservedId];
$gameParty._actors[reservedId] = temp;
SceneManager._scene._statusWindow.refresh();$gamePlayer.refresh();});
this.setWaitMode("message");
I think the way you have it implemented is: you are making the switch not only mid-battle, but mid-turn, no? If you wish the character to be able to act, it would need to be at the start of the turn, during command entry.

I played around with this quite a while ago, but IIRC I did manage to swap in party members with the battle members without too much trouble. I can try digging it up, but I don't want to waste your time either so please explain how exactly you want it implemented.
I want it so that when I change out an ally, that character I switch to has a full gauge, and the command goes straight to that character.
Oh wait, so you're using a time-progress battle system?
Yeah. I should have mentioned that.
Hmmm, store the id of the dude you swapped and then set their tpb charge to 1 with a script. Like after the "user id = reserve id" line put $gameVariables.setValue(X, $gameParty._actors[userId]); Then make a new script box and put $gameActors.actor($gameVariables.value(X))._tpbChargeTime = 1; But you'll run into that problem where the other dudes' gauges fill by a little during the actions, so sometimes another dude with a full gauge will take their turn first. You'll need some other modifications if you want to get rid of that, like fully stopping the other gauges or a script that throws the current dude in the beginning of some queue with all the 100% charge gauge dudes.

EDIT: Replace X with variable of your choice.
But you'll run into that problem where the other dudes' gauges fill by a little during the actions
Was thinking that it might be an option to cycle through the other actors and just knock off a point of charge time when it's 100. I don't have a clean environment with TPB to test this, but have confirmed it works by assigning the actor swap to some key (like left or right).
Hmmm, I tried checking if there's some kind of queue, but didn't quite get the mechanics. Does it just select the first index actor that has full gauge?

Also, tested your solution, but for me it sometimes resulted in a situation where the actor who had their gauge lowered got a turn regardless (with the gauge less than full filled). Don't know if you'd have to change their "state" from fully charged to charging or whatever they were called. Anyway, a bit too complicated for me.

EDIT: Actually not 100% sure if I tried the same thing as you. I just tried lowering the other members charge gauge in the script box.
Sorry for being unclear, I hadn't tested cycling through the actors and knocking off a point from the TPB gauges; it was just a theory.

I've only prototyped it as follows in a parallel common event, using a plugin that allows battle parallels:
1747728698015.png

Switching characters when their turn comes up works, and commands will be executed correctly when actions are selected right after the character swap. So I think in principle it should be doable. The funny thing is that even when placing the TPB on "wait" during the switch the TPB gauge of the other members fills up an inch... so just knocking a point (1%) off might not be enough.

There being some tradeoff for insta-switching is warranted, so I guess it's okay to just knock 10% off from the other actors is fair, but naturally it's quite the ducktaped battle system.

This is in a test environment with Visustella Battle Core.
Hmmm, I tried checking if there's some kind of queue, but didn't quite get the mechanics. Does it just select the first index actor that has full gauge?

Also, tested your solution, but for me it sometimes resulted in a situation where the actor who had their gauge lowered got a turn regardless (with the gauge less than full filled). Don't know if you'd have to change their "state" from fully charged to charging or whatever they were called. Anyway, a bit too complicated for me.

EDIT: Actually not 100% sure if I tried the same thing as you. I just tried lowering the other members charge gauge in the script box.
Hmmm, I tried checking if there's some kind of queue, but didn't quite get the mechanics. Does it just select the first index actor that has full gauge?

Also, tested your solution, but for me it sometimes resulted in a situation where the actor who had their gauge lowered got a turn regardless (with the gauge less than full filled). Don't know if you'd have to change their "state" from fully charged to charging or whatever they were called. Anyway, a bit too complicated for me.

EDIT: Actually not 100% sure if I tried the same thing as you. I just tried lowering the other members charge gauge in the script box.
What happens is that after I choose the swap command, the character has to perform the ability before I get the screen to switch with my reserve party. That and the character I switch to starts at around 25% ATB gauge. So, when I choose someone to switch to, it goes to the next character with a full gauge.
When I tried taking away the n in this line of the script I posted,
$gameMessage.setChoiceCallback(n => {
it did it the way I want, but it didn't let me choose a reserve ally. It just went black for a short time, then went to the next character. I've tried other letters, even replacing all the n's with alternate letters. I think this might be the key, it's just that I don't have too much knowledge about scripting.
What happens is that after I choose the swap command, the character has to perform the ability before I get the screen to switch with my reserve party.
So, I think it would be better if you just described what you want in detail. The talk about how it’s currently implemented is probably not useful at this point, since, well, it doesn’t work.

As you saw from @rpgLord69 and my post, it just seems to work when prototyping (albeit the tpb of other actors as well as the UI stuff being slightly janky).
I want it where it goes straight to the reserve menu as soon as you choose the swap command and the ally you switch to has a full gauge. I'm open to other ways of achieving this. I know I can do this with certain Visustella plugins, but that requires Battle Core which I don't like.
I guess if Visustella is off the table, you might want to try a combination of these two plugins:

Plugin to add a "Swap Battle Members" scene:

And a plugin to make said scene available in battle:

Original thread: https://forums.rpgmakerweb.com/threads/character-swapping-problem.177651/