Trigger map event at destination after teleporting player?

Say there are two map events, Event 1 at grid [0,0], and Event 2 at [2,2]. When the player touches Event 1, a "transfer player" command moves them to [2,2]. Is there a way to automatically trigger Event 2 after this teleport?

I've been playing with trigger condition of Event 2, but it seems that "Player Touch" or "Event Touch" can only be triggered by walking to the event location and not teleporting?
Just put the commands into event 1 after the transfer command.
if you want it to automatically trigger, how about a parallel or autorun? Just make sure to toggle the event off when you're done, especially in the case of autorun.
Depending on what your needs are, turn off "wait for completion" and have the transporting event have a movement command onto the on touch event.
If the transfer destination is always the same, then the solution, like Shaz mentioned, is simple.

Alternatively you can manually trigger an event (that isn't Same as characters priority) at the player's current location using this in a Script command:
JavaScript:
$gamePlayer.checkEventTriggerHere([1, 2]);
[1, 2] are the Player Touch and Event Touch triggers. Usual restrictions apply.

[Edit: oops, this has problems! For details see my follow-up post #14.]
If the transfer destination is always the same, then the solution, like Shaz mentioned, is simple.

Alternatively you can manually trigger an event (that isn't Same as characters priority) at the player's current location using this in a Script command:
JavaScript:
$gamePlayer.checkEventTriggerHere([1, 2]);
[1, 2] are the Player Touch and Event Touch triggers. Usual restrictions apply.
Thx for the help! The destination does change, so I can't put everything in one single map event.

I tried out the manual trigger but couldn't get it to work. I couldn't find this command in the script call Google Sheets so maybe I'm using it wrong? Do I need to replace the [1,2] with something?

Screenshot 2023-05-24 190747.png


This is the map event at grid [1,3] (it just shows text for testing). Ideally I would want the text to appear automatically after the teleportation to [1,3], but right now nothing happens.

Screenshot 2023-05-24 190747 2.png
Well you can try to have "event 2" autorun with an item condition and have "event 1" give the player said item.

Example:

Make an item preferably with a hidden item type called "trigger".

Set the condition of "event 2" to item and select "trigger" as the item.

Then activate "event 1" and at the end of the event before the transfer
command you give the player the "trigger" item, so that when you transfer
to event 2 it will autorun with the item in your inventory.

Maybe this is what you need?
I still don't see why you can't put all the commands into the transferring event. It's not like it's using a variable for the destination or anything.

If that's too hard, you could have a switch for each event you want the player to land on (a different switch for each one). Put that as the event condition, and the trigger as Autorun. Then on the event that does the transfer, after the transfer turn on that switch. Then on each event, do whatever needs to be done and turn the switch off again.

Perhaps you should explain a bit more about the different transfer destinations and what you want to happen on each one?
Touch events trigger on movement only, neither on teleport or on jumps. It is part of why you can have only one event trigger per any action or why a random encounter cannot happen on a tile where an event is triggered.

You cannot change that without a big rewrite of the entire system and several side-effects.

So as many others already suggested I think you need to explain what you want to do instead of how you want to do an unkown something, because your "how" cannot happen and we need to know the what and why before we can point you to an alternative.
I still don't see why you can't put all the commands into the transferring event. It's not like it's using a variable for the destination or anything.

If that's too hard, you could have a switch for each event you want the player to land on (a different switch for each one). Put that as the event condition, and the trigger as Autorun. Then on the event that does the transfer, after the transfer turn on that switch. Then on each event, do whatever needs to be done and turn the switch off again.

Perhaps you should explain a bit more about the different transfer destinations and what you want to happen on each one?

It's a bit hard to explain, but essentially I'm testing if I can set up a Monopoly (board game) style system where the player moves along a set route. The # of steps you can take each turn is random, and the actions you can take after moving are also different (like buy a property or a random Chance event in Monopoly). I can't figure out a way to cram them all into one map event.

My original plan was to just move the player using moveStraight() by a random # of times. But if the player is taking more than one step, they're not supposed to trigger every map event along the way, just the one at the destination (again, like Monopoly). So I thought it's probably easier to just teleport the player directly to the destination.

Another reason I want to use direct teleport is that the "route" I'm using are towns and villages along a winding highway. If I use moveStraight() then I'll have to change directions all the time; and if I use jump() then the player just fly straight from A to B ignoring the highway, which looks a bit dumb. I like the "fade to black effect" of direct teleport.
Touch events trigger on movement only, neither on teleport or on jumps.
During my testing, jump() does trigger the map event at the destination. It's just teleporting that doesn't seem to trigger the event...

3.png

4.png

5.png
Have you considered letting the player move manually, using a parallel process to count steps and keep the player through-on until the final step?
It will be a bit tricky to prevent a manual change of directions in the count (prevent going back anf forth to use up steps), but it can be an alternative
Have you considered letting the player move manually, using a parallel process to count steps and keep the player through-on until the final step?
It will be a bit tricky to prevent a manual change of directions in the count (prevent going back anf forth to use up steps), but it can be an alternative
I did try that approach a little; I used .setDirectionFix(true) to lock the facing, but couldn't figure out how to restrict the direction of movement to only one like you said.

Also, is there a way to disable the function where you can click on a tile with your mouse cursor and the player will walk towards the tile? That messed up my setup quite often when I was testing...
For a board/card/non-RPG game I would suggest using 1 Autorun event to handle everything, like a custom game loop. The result can be based on player location, e.g. a variable. Normal player controls are disabled while a non-Parallel event is running, giving you complete control over movement (including touch movement). Also, with this method you don't need to know the specifics of how the engine handles events. I imagine you'd need a complete rework to do it like that, though...just thought I'd mention it.

Alternatively you can manually trigger an event (that isn't Same as characters priority) at the player's current location using this in a Script command:
JavaScript:
$gamePlayer.checkEventTriggerHere([1, 2]);
[1, 2] are the Player Touch and Event Touch triggers. Usual restrictions apply.
Oops. This script call will only work if there is no non-Parallel event currently running. E.g. it can be used in a player move route or a Parallel event, but not in a Player Touch or Autorun event. 😴

I forgot it had that check in there. I'm guessing it's to prevent situations like "move route (wait) -> walk over some on-touch events -> end event -> on-touch events process, one after another". MZ doesn't have any trouble starting multiple events at once; when appropriate it simply gets the next "starting" event and sets it up in its interpreter.

You could manually bypass it with a slightly longer script call, but I don't know if that would have any side-effects. Note that the engine will only process 1 non-Parallel event's commands at a time, so this may not even solve the problem depending on your exact setup:
Spoiler: script call
JavaScript:
for (const event of $gameMap.eventsXy($gamePlayer.x, $gamePlayer.y)) {
    if (
        event.isTriggerIn([1, 2]) &&
        event.isNormalPriority() === false
    ) {
        event.start();
    }
}
(This is just the startMapEvent method without the isEventRunning check.)
Note that the engine will only process 1 non-Parallel event's commands at a time, so this may not even solve the problem depending on your exact setup:
I noticed that if I put "moveStraight()" or "jump()" as THE LAST command in a non-Parallel event (call it Event #1), then after the movement the player will automatically trigger the map event at the destination (Event #2, set to Player Touch). So I assume Event #1 is considered "finished" before the movement is actually executed, so when the player hits the destination, there is no non-Parallel event running and Event #2 can be processed. I'm curious if there's a way to force this behavior for "reserveTransfer()" teleport as well, but looks like it's not possible?
For a board/card/non-RPG game I would suggest using 1 Autorun event to handle everything, like a custom game loop.
I was having trouble storing the dataset of what to do on each location as a variable, but I just learned that you can check what tile type you're standing on by "tileId()". I'll try to use conditional branches depending on the tile type to link to different events, which actually might be even easier to handle than putting map events on each tile. Thx for the suggestion!
then after the movement the player will automatically trigger the map event at the destination (Event #2, set to Player Touch).
Yes, much like it would work (as I mentioned) in a player move route...assuming you don't use the "Wait for Completion" option, otherwise the interpreter will wait until the move is complete, which defeats the whole purpose.

I just learned that you can check what tile type you're standing on by "tileId()".
You don't even need a script call for that: you can use the Get Location Info event command. 👋

I'm curious if there's a way to force this behavior for "reserveTransfer()" teleport as well, but looks like it's not possible?
By default, collisions (e.g. Player Touch) are only processed on movement, and relocation does not count as movement. Also, the interpreter pauses during Transfer Player, so it runs into the same issue as above.

It's certainly possible, though. Plugins can change the default behaviour, e.g. (untested):
Spoiler: plugin code
JavaScript:
/*:
 * @target MZ
 * @plugindesc Trigger below/above events after the player relocates.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/157787/
 * @help Triggered events can run after the relocation event ends.
 * 
 * Free to use and/or modify for any project, no credit required.
 */
;void (alias => {
  Game_Player.prototype.locate = function(x, y) {
    alias.apply(this, arguments);
    for (const event of $gameMap.eventsXy(this.x, this.y))
      if (event.isTriggerIn([1, 2]) && !event.isNormalPriority())
        event.start();
  };
})(Game_Player.prototype.locate);
(Technically this patches the player's locate method, but I think the only event command that uses that is Transfer Player, i.e. reserveTransfer/performTransfer.)

Original thread: https://forums.rpgmakerweb.com/threads/trigger-map-event-at-destination-after-teleporting-player.157787/