In the core script for both MV and MZ, it seems the Transfer Player command is deliberately programmed to lock the event interpreter indefinitely if used in battle: it returns
false ("unsuccessful") and offers no way to advance to the next command, meaning the event retries that command every frame - endless loop!
👋
I can't see why it's written like that, since the map data (
$gameMap) certainly does still exist when in battle. I'm guessing it's a bug. You're not seeing the game lock up in your case because the successful Abort Battle command takes precedence: it moves the battle into the
"aborting" phase, which causes it to change scene next frame regardless of what the event interpreter is doing. The troop interpreter doesn't get updated on the map scene, and gets cleared if/when the next battle starts.
It's probably safest to just work around it as suggested, but another option is to transfer via a script call, e.g.
var mapId = 2;
var x = 3;
var y = 4;
var d = 0; // 0 = Retain, 2 = Down, 4 = Left, 6 = Right, 8 = Up
var fadeType = 0; // 0 = Black, 1 = White, 2 = None
$gamePlayer.reserveTransfer(mapId, x, y, d, fadeType);
Or you could try loading this as a plugin, to let the Transfer Player command work in battle:
Spoiler: plugin code
JavaScript:
/*:
* @target MV
* @plugindesc Allow Transfer Player in troop events.
* @help Free to use and/or modify for any project, no credit required.
*/
// Override!
Game_Interpreter.prototype.command201 = function() {
if (!$gameMessage.isBusy()) { // <- edit 1 of 2
var mapId, x, y;
if (this._params[0] === 0) { // Direct designation
mapId = this._params[1];
x = this._params[2];
y = this._params[3];
} else { // Designation with variables
mapId = $gameVariables.value(this._params[1]);
x = $gameVariables.value(this._params[2]);
y = $gameVariables.value(this._params[3]);
}
$gamePlayer.reserveTransfer(mapId, x, y, this._params[4], this._params[5]);
if (!$gameParty.inBattle()) this.setWaitMode('transfer'); // <- edit 2 of 2
this._index++;
}
return false;
};
This moves the "in battle?" check so it only excludes the wait mode. It's an override, so for maximum compatibility with other plugins, put it near the top of your load order.