How do you safely interrupt autonomous movement?

Say you've got an event that's a guard for example. His event is set up with an autonomous custom movement path, maybe patrolling around in a square path.

If you want to interrupt his movements with a custom move route: turn towards player (called in the guard's or another event) it messes with the original autonomous move path. The guard event resumes its square path, but now it can be one or two squares off and starts bumping into things.

This must be a common situation, an npc is following an autonomous path then joins in a conversation or something with the player. How do you get the npc to stop and look in a specific direction during the conversation, then go back to his/her original movement path?

I understand 'set movement route' briefly overwrites 'autonomous movement', is there a trick to getting the autonomous movement to pick up exactly where it left off?
If it's only one NPC and that's the one you're interrupting, it's easy, as you don't need to do an override move route to make him face the player - it just happens by default, and when the conversation is over, he just resumes his path.

But if you've got two guards who each have their own move routes, and the player can interrupt either of them at any point in their paths, and you want them both to stop ... then it's a problem because you don't want them to start over, and they don't remember where they were up to. I'm not sure anyone has developed an easy fix for that.
Shaz means in auto mouveroute, dont mark "skip if cannot move" thatway the npc continues its moveroute after talking.
Like shaz said the other way needs some fitting more complex workaround depending on the situation.
That's not what I meant 😉

I meant if you don't put another move route on the NPC, he will stop and face you when you interact with him, then he will continue his move route, because you haven't caused him to lose his place. Easy if there's only one NPC and that's the one the player interacts with.
There's person A who is walking around on her autonomous route (with skip if cannot move unchecked). There's also person B standing still. Then the player talks to person B. In the middle of the conversation between the player and B, person A stops, looks towards the player, adds her two cents to the conversation, then goes back to her route.

Lots of similar situations come up with the same problem, like the guard on patrol who shouts 'hey, don't touch that' if the player picks up a sword or something. My scenes all work fine, but depending on where the NPCs are on their route, they may or may not be looking at the player when their text window is called up. If I put a 'set movement route: face player' command in, the auto route is slightly off when they go back to it.

I thought this might be a common situation with an easy fix that I'm overlooking, because I don't fully understand how/when/why the autonomous and set movement routes are started/restarted.

Like Shaz said, if the player just interacts with the NPC directly, they pause then pick up the route exactly where they left off. But apparently not so if they're interrupted with a brief 'set movement route' command.
If the Eventpage is changing or if the Event is getting a new Moveroute with Eventcommand, than the Old one is overwritten, even if it has not finished yet.
I have one Idea for a Workaround which seems to work.
Put an event onto a Map Tile where it cant move, now when the time has come use teleport eventcommand and choose switch event with other event. But its important that the moving event gets switched to a place where he cant move, than the npc will continue his moveroute as soon he gets switched with that event again. i hope this wasnt to much chineese^^ dont have much time right now.

Ah the event that we switch to will look the same like the npc.

Edit:
A = Event to talk with
B = Moving NPC
C = Event that looks like B somewhere on a spot where events cant Move.

B is moving around
player talks with A
A will make that event b and C swap positions
A will continue to control C
Now A will swap b and c again.

In my little test this works properly. No hidden bugs discovered yet.
One of the rare times this event swap feature comes in handy.
Hi Bex,
When you say 'teleport event command' do you mean the 'set event location' on page two of 'event commands? Or is there a 'swap event' command somewhere that I haven't found?
OK, I've been experimenting. If you interrupt an event following an autonomous custom route, it DOESN'T start from the beginning again, it skips exactly one step and then continues on from there. It actually looks like the intended behaviour is the same as when an NPC event on a route path is talked to normally by the the player, i.e. pick up exactly where it left off when the route was interrupted.

This might even be a bug, does anyone know where the autonomous route is called in the RPG Maker MV code?
It's not a bug. Implementing what you are asking for would require a full fledged pathfinding script, as the engine would have to have a way to get from point A to B with no knowledge of what is in the path just so it can resume it's route. Pathfinding is very tasking on CPU process too (even some AAA games like Mass Effect and Dragon Age and such can hang briefly as it calculates the path for your party), so as a result you get what you see instead.

If you wish to avoid this happening, you'll have to look for a pathfinding plug-in for starters. I know there was one made for ACE, but not sure one exists yet for MV.
Really? I don't think any pathfinding is necessary, but I could be wrong.

At the moment, the autonomous custom route is being paused, remembering what step it's up to (call it step n), doing some other movements (with the set event movement route command) then going back to step (n+2) in the autonomous custom route list. All I want is it to resume at step n+1 instead of n+2.

But yeah, I'm just guessing the mechanics of what's going on by observing behaviour of events in the game.
Whew, I've just had a look through the code governing movement for the first time ever, and here's what I discovered...

My original problem was that using the 'set movement route' command would cause an event with an autonomous custom movement route to skip one step when resuming the autonomous route.

Adding this line:

this._moveRouteIndex--;

to the end of the Game_Character.prototype.restoreMoveRoute method fixes my problem.

This is a quick and dirty fix, the underlying problem is likely the order in which certain methods are called, but this was my first look at this code and I'm a looooooong way from understanding all that's going on.

However, it does lead me to suspect that there really is a bug, and the intended behaviour was that the autonomous custom route would be resumed without change, after being interrupted with a 'set movement route' command.

I'm sorry if this thread now probably belongs in the Javascript section, I started off thinking there was just some command I should use in the editor or something.
It depends. What I was referring to was how it would work if you had it say patrol in a circle, then you had it go up 2 due to an event. How would it know to go back to where it was for the circle? And what if an event was now in the way? That was what I meant by pathfinding would be needed.

PS: Also don't double post please. Next time just edit your previous post.
Ah yes, that would need pathfinding. Luckily all of the the in-game problems I was having revolved (slight pun) around the NPC's changing facing only. If I had to move an event with 'set movement route' I'd have to put it back where it started.

Sorry for breaching forum etiquette, concepts like 'double posting' and 'necro posting' are new to me. I did read the forum rules carefully when signing up, but that document has been edited since then. I assumed 'double posting' meant accidentally posting the same thing twice, or continuing the same point in the next post and kinda using it like you'd use paragraphs in regular writing. In my case I was posting about completely different ideas because a lot had changed in the hours between the posts. Anyway, I'll always just edit the prior post from now on, if those are the rules.

While I'm at it, I'm unclear on the circumstances under which necro posting is permissible. Is it OK if the thread hasn't been solved and you can help solve it, even if 30 days have passed?

So in this particular thread, what's the etiquette from here on? My initial problem ('set movement route' causes 'autonomous custom route' to skip one place in its list of commands) can be solved by adding one line of code, but it's more of a 'band-aid' fix than addressing the underlying problem.

Should I leave it like this, knowing people who read this thread could then solve the same problem the same way?

Should I write a plugin that anyone could use? Seems a lot for one line of code.

Should I submit a bug report? I found Archeia's rules for that and it looks... daunting.

Anyway, my thanks to everyone who posted here. The back-and-forth got my brain thinking about things from new angles and helped me progress. Bex's work-around was an especially intriguing solution!
Thanks for your words.
Yes i ment "set event location" eventcommand.
And i tested it for vx-ace, it worked seemingly fine so what exactly does not work in mv?

Edit:
After changing the events the new event could move like this:

Turn towards player, move 2 steps forward, do textboxes.
Turn event by 180°, move 2 steps forward.
Change the Events again and the normal one continues his moveroute.

If you want or need more precise movement, you maybe need a pathfinding script.

Edit2: Hmm strange why it skips one command. maybe someone else with mv can rebuild it? i dont own MV.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-you-safely-interrupt-autonomous-movement.86340/