Resetting Move Route After Event Page Change Problem

So I have this boss character in my game. I used GALV_MapProjectiles to set it so when you hit him with your sword, a self switch turns on, going to the event page which calculates damage and shows a damage effect. The problem is, after the self switch turns off again, the boss’s move route starts from the beginning, which means if you just spam attacked the boss, he couldn't perform any attacks.

I also have a similar problem where the context of my game matters. You have the ability to travel back or forward in time. One of the boss’s attacks is to go to the center of the map and charge up a shockwave attack. To avoid it, you must travel to the past, where 4 pillars surround the boss, blocking the attack. A map transfer for the time travel wouldn’t work, seeing as even if a saved the coordinates of everything and loaded them during transfer, the boss’s movement route would again reset, and he would never actually perform the attack.

One more thing, I’m wondering if there’s a plug-in for branching custom move routes, where it chooses randomly from 3 options for the movement route when it reaches a certain point. This would make it easier for the boss to have random attacks. Sorry this is so long. Any suggestions to fix this will be appreciated.
I got as fix in my full base, Caethyril also have a fix for this (smaller plugin)
as its a common issue that it resets.

this was mostly during interaction, unsure about selfswitches and pages
how this behave if its not differently found [here] under patches/fixes
CaeF_restoreMoveIndex is the name you look for.

if it still persist after that using the plugin, than it may work differently,
so we can try to patch that.
I glanced at Caethyril's thread, but it looks like that patch is for a different circumstance than described here.

You could try this out as a plugin:
JavaScript:
// When switching pages, if both have the same move route, maintain the index.
const old_setMoveRoute = Game_Character.prototype.setMoveRoute;
Game_Character.prototype.setMoveRoute = function(moveRoute) {
	var newIndex = 0;
	if(JSON.stringify(moveRoute) == JSON.stringify(this._moveRoute)) {
		newIndex = this._moveRouteIndex;
	}
	old_setMoveRoute.call(this, moveRoute);
	this._moveRouteIndex = newIndex;
};
const old_restoreMoveRoute = Game_Character.prototype.restoreMoveRoute;
Game_Character.prototype.restoreMoveRoute = function() {
	old_restoreMoveRoute.call(this);
	// Prevent it from being incremented on this tick.
	this._movementSuccess = false;
};

Save that as a js file, add it as a plugin, and copy-paste the move route from the boss's main page to the "boss is attacked" page. If that causes problems (because the move route is still running while the boss is being attacked), you can probably also use Caethyril's patch and add a Set Movement Route command to the attack page to temporarily cancel out the official route.
This could be a little annoying, but you can do this with events.

The idea is to make the page with the boss' movement a parallel event and save the current state of their movement route. Then, after coming back from the page responsible for taking damage, the event can resume it's route from where it got interrupted. Naturally, this can also be extended to allow for branching movement routes, as it's all events anyway.
スクリーンショット_2026-05-26_19-42-10.png
スクリーンショット_2026-05-26_19-42-17.png

I used a regular switch, instead of a self-switch, just to make testing easier.
I'll use that approach, and use a parallel event to hurt the player when the event touches you.

Original thread: https://forums.rpgmakerweb.com/threads/resetting-move-route-after-event-page-change-problem.183816/