How to move an event back on the tile it starts from?

(I'm testing an idea so please bear with me) An event begins on Map tile say 11,10 and it is set to randomly wander the map. And with certain trigger activated, a condition branch checks to see where the event currently is and sends the event back to 11,10 where it initially began.

I'm running a separate parallel event on map to check where this event's location currently is. I'm not sure how to get the location of an event that's not the player. Or how to send it straight back to it's initial starting tile.

I was using conditional branches where if the event is not on tile 11,10 (after triggered event) the event heads back to 11,10. But I don't believe I have set up the variables correctly. The part where the variables can tell where the event currently is.

So my question is: Using a parallel event on map, how do I get the location of other events, how to check where the event currently is and with conditions to where if the event is not on 11,10, it heads back to 11,10?
What I'd do, and not sure if it's the most effective, but here goes:

On the map, have a Parallel event running the moment it's entered. This event stores the individual starting X and Y positions of all events that need to be tracked into separate variables, then have the event turn itself off.
After that, you can just run an event with the return trigger, that uses Set Event Location, and set it according to the stored X and Y values to place it back on the start position.

You don't need to know where the moving event currently is (unless it's one of the return triggers, I guess...), you only need the starting position.
I'm not sure how to get the location of an event that's not the player.
the same way as with the player: with the game data section of the control variable command.
(that is the way it has always worked without any scripts)

however as far as the way back to the starting position is concerned, there are only two options:

either jump/set to that position (ignoring the path and time required to go there), or (no matter how much you are against it) you'll add a pathfinding plugin to get the pathing to the position back.

sorry, there is no other way after random movement on a complex map. The engine has absolutely no pathfinding capacity by itself, and that means that if you want to go back by path without knowing the exact way, a pathfinding plugin is the only way.

or you could make a few hundreds of move routes based on all possible map positions to go from there back to the start...
Someone once shared a script that moved events directly to a certain tile. Could that work?
Your signature says "I don't use plugins so don't suggest them."

Are you wanting the event to just jump back to the tile it started on, immediately, or are you wanting it to walk back?

Without plugins, there is a way you can get the original location of the event, and you can then use that in variables with the Set Event Location to jump it back, or you can do a script call.

If you want it to walk back to the original location, you can only do it with plugins. I wrote a plugin for event pathfinding but I'm not sure if it would conflict with the random movement. You could use it, but if that causes an issue you'd have to add a workaround, which I won't go into unless you decide to use plugins, use that one, and encounter that issue.
Your signature says you don't use plugins so don't suggest them.

Are you wanting the event to just jump back to the tile it started on, immediately, or are you wanting it to walk back?

Without plugins, there is a way you can get the original location of the event, and you can then use that in variables with the Set Event Location to jump it back, or you can do a script call.

If you want it to walk back to the original location, you can only do it with plugins. I wrote a plugin for event pathfinding but I'm not sure if it would conflict with the random movement. You could use it, but if that causes an issue you'd have to add a workaround, which I won't go into unless you decide to use plugins, use that one, and encounter that issue.



I'm confused. I haven't downloaded any plugins. I don't have any installed actually. A user once shared this copy and paste script

◆Set Movement Route:npc (Repeat, Wait)
: :◇Script:this.moveStraight(this.findDirectionTo(3, 3));
: :◇Script:if (this.pos(3, 3)) { this._moveRoute.repeat = false; };

and I used the game's own engine, Rpg Maker's Event command window in order to use it?

Could you please clarify? I thought plugins were something you had to download?
Moderator note: I have reinstated your previous posts. Please do not delete what you have said, as it makes the conversation unreadable.

You said someone shared a script that moved events directly to a certain tile.

What you've posted above is a script call for the movement route, which is different to a script (which is also called a plugin in MV/MZ terms).

Alright, so using that script call, if you decide you want to send the event back to where it started, this is what you should put into your movement route:

Code:
Set Movement Route: npc (Repeat, Wait)
                    Script: this.moveStraight(this.findDirectionTo(this.event().x, this.event().y));
                    Script: if (this.pos(this.event().x, this.event().y)) { this._moveRoute.repeat = false; };

This should make the event move back to its starting position.

What I'm not sure about is what will happen at the end - will it just stay there? Or will it start its random movement again?

If you get the above working, and you want it to stay but it starts moving randomly, or you want it to move randomly but it stays, post again saying what it's doing and what you want it to do, and we'll go to the next step.

Also, if it has strayed a fair way from its starting location and the destination is off the screen, you might have to follow it to make sure it keeps moving, as events will usually not process movements or commands once they stray to far from the visible part of the map.
Someone once shared a script that moved events directly to a certain tile. Could that work?
only on certain maps.

if there are obstacles on a map and a random movement happens often and long enough, the event can go around the obstacles. But the move route script call is basically a direct pointer to the original position - if there is an obstacle between current and original position, then the move route will fail at the obstacle.

that is the moment where you need a pathfinding function, to find a non-direct way around the obstacle.
and such a function does not exist in the default engine, you'll need a plugin or script (depending on engine) to add that option.
Good point. The findDirectionTo does do path finding, but will only look at the next 12 or so tiles. So it would get you around an obstacle, but if your map is done in a certain way that creates some dead-end areas, and the event gets on the other side of that area, the path finding could take you into the dead end.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-move-an-event-back-on-the-tile-it-starts-from.131411/