MV Force actor switch in battle.

I'm hoping this is the correct place to put this.
I already have the yanfly party switch plugin and am able to switch party members in battle. However, I would like to make a battle where an additional party member will come to the rescue mid battle. Is there any way to force one of the actors to change out to a waiting party member.
Basically I after the battle starts, and there is a bit of dialogue, I would like whoever was leading at the time to be swapped out into another teammate who is not on the field at the time.

I should note that my game is setup so that actors enter battle based on the formation they were in in the overworld, so they could literally be placed anywhere players chose before entering battle.

Thanks in advance!
These suggestions are meant for use in a Script command (e.g. in a troop event)~
  • This changes the party order, like "Formation" from the pause menu:
    JavaScript:
    $gameParty.swapOrder(indexA, indexB)
    Index = 0 for the leader, 1 for the next member, etc. So if your battle party size is 4, this should swap the leader and the first reserve member:
    JavaScript:
    $gameParty.swapOrder(0, 4)

  • If the battle status window (the one showing actor HP, MP, etc) doesn't update correctly, try adding this line after the swap:
    JavaScript:
    SceneManager._scene._statusWindow.refresh();
    That seems to work for the default status layout. If your battle status is using actor images like faces, then you may need something like this for the refresh instead (untested):
    JavaScript:
    ImageManager.requestFace($gameParty.members()[4].faceName())
                .addLoadListener(function(bmp) {
                  var w = SceneManager._scene._statusWindow;
                  if (w) w.refresh();
                });
    I.e. "load the face image for party member #5 (index 4); when it is loaded, refresh the battle status window".
Hopefully these will play nice with the plugins you're using! 😅
there is one additional point that should be mentioned:

depending on your exact battleplugins, summoning or switching actors may have a problem.

some battle plugins need additional data to work, and in a lot of cases that additional data is generated on battle initialisation.
if you add an actor at a later time, that new actor is often missing that additional data.
and it depends on the plugin and the type of data if the plugin can handle it or crashes the battle with "of null" or "no method" errors.

that is why each of the more complex battle systems has their own summoning plugin. These plugins basically make sure that all the required new data is added on summoning - but they have to know what data is missing to do that, and are incompatible otherwise.

So depending on your battleplugins you might get errors when using the functions listed above, that is what the last sentence above refers to.
but the reason for these errors is not that the functions give are wrong, but that they are missing the info from you other battle plugins.
These suggestions are meant for use in a Script command (e.g. in a troop event)~
  • This changes the party order, like "Formation" from the pause menu:
    JavaScript:
    $gameParty.swapOrder(indexA, indexB)
    Index = 0 for the leader, 1 for the next member, etc. So if your battle party size is 4, this should swap the leader and the first reserve member:
    JavaScript:
    $gameParty.swapOrder(0, 4)

  • If the battle status window (the one showing actor HP, MP, etc) doesn't update correctly, try adding this line after the swap:
    JavaScript:
    SceneManager._scene._statusWindow.refresh();
    That seems to work for the default status layout. If your battle status is using actor images like faces, then you may need something like this for the refresh instead (untested):
    JavaScript:
    ImageManager.requestFace($gameParty.members()[4].faceName())
                .addLoadListener(function(bmp) {
                  var w = SceneManager._scene._statusWindow;
                  if (w) w.refresh();
                });
    I.e. "load the face image for party member #5 (index 4); when it is loaded, refresh the battle status window".
Hopefully these will play nice with the plugins you're using! 😅
This worked! Thanks a bunch! Now I can play out my fight scene the way I wanted it to! I only needed to do the first part. By which I mean-
  • This changes the party order, like "Formation" from the pause menu:
    JavaScript:
    $gameParty.swapOrder(indexA, indexB)
    Index = 0 for the leader, 1 for the next member, etc. So if your battle party size is 4, this should swap the leader and the first reserve member:
    JavaScript:
    $gameParty.swapOrder(0, 4)

there is one additional point that should be mentioned:

depending on your exact battleplugins, summoning or switching actors may have a problem.

some battle plugins need additional data to work, and in a lot of cases that additional data is generated on battle initialisation.
if you add an actor at a later time, that new actor is often missing that additional data.
and it depends on the plugin and the type of data if the plugin can handle it or crashes the battle with "of null" or "no method" errors.

that is why each of the more complex battle systems has their own summoning plugin. These plugins basically make sure that all the required new data is added on summoning - but they have to know what data is missing to do that, and are incompatible otherwise.

So depending on your battleplugins you might get errors when using the functions listed above, that is what the last sentence above refers to.
but the reason for these errors is not that the functions give are wrong, but that they are missing the info from you other battle plugins.

Thanks, but luckily the advice had worked.

Original thread: https://forums.rpgmakerweb.com/threads/force-actor-switch-in-battle.147544/