How To Keep Events from Moving When You Change Maps.

If you set an events location with "Set Event Location" how do you get it to stay there after you've switched maps? I found this in an old post:

If you want the NPC to stay in the same spot when you leave and come back then on the last page of events add, Set event location: This event. (x,y) and set it to parallel process, set your graphic to w/e direction you want the character to be facing.

I don't know how to set up this parallel event.
I know how to set up a parallel event to check if a player steps into a certain region of the map, but I don't get how to check if an event has moved.
I don't see how that advice could possibly work.

An event belongs where you place it in the editor. You can move it around as much as you want, but when you leave the map, it's unloaded from memory. When you return to the map, it's loaded from the settings you see in the editor - all events back to their original location. Set Event Location only works while you remain on the map - as soon as you leave, its new location is lost.


There are 3 ways to do what you want:

1: If your event moves to a specific location (it's blocking something, you move it out the way to reveal what it was blocking, and you want it to stay where you've moved it to), use 2 events and a switch. The first event is the one you see before it moves. It has the command to move (and wait for the move to complete) or the Set Event Location, followed by turning the switch on. It also has a second page, conditioned by that switch, that has no sprite and no commands. The second event sits in the new location (where you're moving the first event to). Its first page is blank, and the second page, which has the sprite, is conditioned by the same switch. So you enter the map, move the event, the switch turns on and one event hides and the other becomes visible, but the player can't see that happening. Next time you return to the map, the first event is no longer visible, but the second one is, in the new location.

2: Same scenario as above, still using 2 events. The first event has 2 pages, and both pages have the same sprite. The first page has the command to turn on a switch and the second page is conditioned by the switch but has no commands. A second event, in a position where the player won't walk, has no sprite, and is conditioned by the same switch. It is set to parallel process, and has 2 commands: Set Event Location (to move the FIRST event to the new spot), and Erase Event. So you enter the map, interact with the visible event, it turns on a switch that causes the OTHER event to move the first event and then erase itself. When you leave the map and return, the parallel process event will move the other event and erase itself again. This all happens before the player sees the map. As long as you want the event to be in the new location, you leave the switch on.

3: Use a plugin. This is handy if you don't know where the event is going to end up but you still want it to remember its location, or if you just don't want to use two events. I'm sure there's at least one for MZ.
caethyril's map effects plugin has a <save> notetag for events that retains their location when you switch maps and stores it in the save data. I wouldn't recommend using it for everything though as each one increases the amount of data being stored.
Unlike Yep_SaveEventLocation, it has some disadvantage it, and yet powerfull,
while I use TSR_SaveEvent, it does a slightly different than most plugins,
as it can retain the direction of the event when switching maps and saved
to the savefile.

I dont know how Caetrytils works like Trihan said, but it might work still
different from TSR and YEP, it's depends on the amount of plugins you use,
comfortable with and compability.
Unlike Yep_SaveEventLocation, it has some disadvantage it, and yet powerfull,
while I use TSR_SaveEvent, it does a slightly different than most plugins,
as it can retain the direction of the event when switching maps and saved
to the savefile.

I dont know how Caetrytils works like Trihan said, but it might work still
different from TSR and YEP, it's depends on the amount of plugins you use,
comfortable with and compability.
caethyril's retains event direction and its position in its move route if it has one.
I would definitely recommend just using Caethyril's plugin like Trihan suggested.

It's much easier and simpler to use then say, eventing it all via common events and/or a few scripts. Especially since it retains Facing Direction and position in it's move route (this is the biggest reason honestly).
My Cae_MapEvents plugin (link to thread) literally saves/restores the entire state of the Game_Event for tagged events. It might result in a bit of save bloat, but it stands a high chance of compatibility with other plugins. In case you're already using VisuStella, I think their Events & Movement Core plugin has something similar?

If you want the NPC to stay in the same spot when you leave and come back then on the last page of events add, Set event location: This event. (x,y) and set it to parallel process, set your graphic to w/e direction you want the character to be facing.
This approach is pretty simple: you make a Parallel event that does Set Event Location or whatever, then have an Erase Event at the end. Erase Event deactivates the event until you leave and re-enter its map. So the event basically runs once per map visit, as soon as you enter the map. (Autorun would typically have to wait for the transfer to complete first.) E.g. if you've positioned the event at coordinates stored in the variables "NPC X" and "NPC Y", the event might look like this:

◆Set Event Location:The NPC, ({NPC X},{NPC Y}) (Direction: Retain) ◆Erase Event
To remember direction, you could store the direction in another variable and check that before calling Set Event Location, e.g.
Spoiler: example with direction check
◆If:NPC Direction = 2 ◆Set Event Location:The NPC, ({NPC X},{NPC Y}) (Direction: Down) ◆ :Else ◆If:NPC Direction = 4 ◆Set Event Location:The NPC, ({NPC X},{NPC Y}) (Direction: Left) ◆ :Else ◆If:NPC Direction = 6 ◆Set Event Location:The NPC, ({NPC X},{NPC Y}) (Direction: Right) ◆ :Else ◆Set Event Location:The NPC, ({NPC X},{NPC Y}) (Direction: Up) ◆ :End ◆ :End ◆ :End ◆Erase Event
As you can see, with this method you have to manually remember/restore things. You can use Control Variables -> Game Data -> Character to get a character's position, direction, etc.

You can use "do once" Parallel events for other things, too, e.g. weather effects and screen tints.
Events have pages. They probably meant to have the event start on a page 1 parallel process. Setting the events location followed by a self-switch to resume the expected event behavior on a different page.

The processes should happen instantaneously. But if you're not using a fade-in transition you might see the event blink into position on frame 1 as you enter the map.
Holy cats! Thanks for all the help everyone!

I have a very small project with only 3 maps. There are only two NPC (events) that move so I think I'll do the parallel event that erases itself. I get it now!

If I make anything larger I will definitely check out Caethryil's plugin.

Thanks again for the help <3
Correct me if I'm wrong, but doesn't using a parallel event have the issue of an 'ever moving' event?
For instance, let's say I have an event that walks down 5 tiles and walks up 5 tiles. It does this on repeat.
If I were to make it so that upon leaving the map, the 'warp event' writes down all X,Y,Facing information, and have it also move all events to their last location upon re-entering the map. Then the problem kicks in.
If I leave when the event has only walked 4 tiles down, upon reentering, its position will be 4 tiles down, but it's move route will still retain all 5 tiles down to go, along with all 5 tiles up. Eventually the event will either be really far down or really far up, because it'll try to take 5 steps down then up from the point it was moved to.

Like this would work fine for doors and other static events that only need a 'facing direction' to remain the same, but walking events will have this issue.
Are either of the events using a move route? In the initial post, the OP said they were using Set Event Location. That's not a move route.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-keep-events-from-moving-when-you-change-maps.154959/