👋 I'll use these phrases:
Bug:
- "Passive route" = an event's autonomous movement route.
- "Active route" = a forced move route; a move route applied via, for example, the Set Movement Route command.
Bug:
- When an active move route ends, the passive route (if any) is restored. However, the passive route's index is immediately incremented, meaning that one move command is always skipped. This can result in unreliable behaviour.
- restoreMoveIndexBugDemo.zip - RMMV v1.6.2 (Google Drive) [3 MB]
The NPC will walk round in a 4-step loop; talk to them to assign them an active move route. Note that the move command skip occurs when the active route ends, regardless of the move commands (if any) in the active route.
processMoveCommandis unconditionally followed byadvanceMoveRouteIndex:
The memorize/restore routines simply take the current index value:JavaScript:Game_Character.prototype.updateRoutineMove = function() { if (this._waitCount > 0) { this._waitCount--; } else { this.setMovementSuccess(true); var command = this._moveRoute.list[this._moveRouteIndex]; if (command) { this.processMoveCommand(command); this.advanceMoveRouteIndex(); } } }; Game_Character.prototype.advanceMoveRouteIndex = function() { var moveRoute = this._moveRoute; if (moveRoute && (this.isMovementSucceeded() || moveRoute.skippable)) { var numCommands = moveRoute.list.length - 1; this._moveRouteIndex++; if (moveRoute.repeat && this._moveRouteIndex >= numCommands) { this._moveRouteIndex = 0; } } };
Thus when the passive route is restored, its index is effectively set to "original + 1". However, at that point the original index has not been processed, because it was replaced by the first command of the active route.JavaScript:Game_Character.prototype.memorizeMoveRoute = function() { this._originalMoveRoute = this._moveRoute; this._originalMoveRouteIndex = this._moveRouteIndex; }; Game_Character.prototype.restoreMoveRoute = function() { this._moveRoute = this._originalMoveRoute; this._moveRouteIndex = this._originalMoveRouteIndex; this._originalMoveRoute = null; };
- Subtract one from the original move route index on memorisation:
JavaScript:Game_Character.prototype.memorizeMoveRoute = function() { this._originalMoveRoute = this._moveRoute; this._originalMoveRouteIndex = this._moveRouteIndex - 1; // <- edit 1 of 1 }; - Alternatively, subtract one from the index on restore:
JavaScript:Game_Character.prototype.restoreMoveRoute = function() { this._moveRoute = this._originalMoveRoute; this._moveRouteIndex = this._originalMoveRouteIndex - 1; // <- edit 1 of 1 this._originalMoveRoute = null; };