'Time Limit' Roaming

Hello guys! I've been using VX Ace for three days straight now and I'm loving this program :] Along the way, I've faced some troubles here and there but was able to find alternative solutions to them...however, it's this one specific cutscene that I reeaallyy want to execute:

So I wanted my character to kind of roam around in the new location that he was spawned in for a limited time (20 secs) before he gets abruptly approached by an NPC.

>My original plan was to set up a Control Timer of 20 seconds
>before turning on a self-switch which activates another event where it controls an NPC towards him.

I'm not quite sure whether this is a correct use of the Control Timer or whether I needed to add more codes to the event
Please help!
I believe it would work but with more code, only like that it wouldn't, I think.
Is it all on the same map?
Because if it is, and this is how I would do it, not sure if it is the right way, but I would do it with a parallel event.
43866-6c4816873c8f755642ac51c64e21ad7c.jpg

On my game I have the event(npc) already on map. But you can make it appear whenever you want(have it there but transparent).
The wait command allows you to create the time you want the characters to walk freely, then, when the 1200 frames (20 secs) are reached, the npc walks towards the character.
Have the cutscene, and then control self switch A (or a switch, whatever works for you) on the end. On a second page, have the event triggered by action button and the condition self switch A is ON. This will prevent the event loop, but I'm sure you already know it.
Does this work for you?

With the control timer, you would need to set a separate auto run event(or a parallel one as well) with the conditional branch "if timer is 0:00 or less" to make the event approach your character. Be careful with auto run, not done correctly may "freeze" your game.
Edit: Here is one I made quickly to help you.
Spoiler: Eventing with timer
43867-5ccc67069f6d0c76361bdb52eb1f97a3.jpg

43868-7cb9c584c050edff2353e39947e253f2.jpg

That switch 81 is not necessary, but I added it to a 3rd page of the timer event, just to be sure. I'm sure it can be done without it.
Both work, but you need more eventing.
This is my understanding, it's how I would approach an event like this. Not 100% sure if it is the right solution. I hope it helps and good luck with your project!!
This is how I would do it:

  1. Create a parallel process event and add a script command. Then type this in your script:
    Code:
    time = seconds * 60
    # Change seconds to be the number of seconds you want to wait
    time.times { Fiber.yield }
    $game_self_switches[[your_map, your_event_id, 'A']] = true
  2. Create a second page with your NPC graphic and with trigger set to Autorun. Your page condition should be Self Switch A is ON. As in the previous page, add a script command and type this:
    Code:
    x = $game_player.x
    y = $game_player.y
    while (($game_map.events[@event_id].x - x + $game_map.events[@event_id].y - y) > 1)
    $game_map.events[@event_id].move_toward_character($game_player)
    Fiber.yield while $game_map.events[@event_id].moving?
    end
    $game_self_switches[[your_map, your_event_id, 'B']] = true
    # You don't have to change things in this code.
  3. Add everyting you need in the second page after the script command then create a third page with Self Switch B is ON as a condition and with the priority, trigger and graphics you need. Keep in mind thatwhen the player enters the map after complething this sequence this 3rd page will be active unless you do something to prevent it.
Autorun has few pros compared to parallel process: first of all it prevents the player from walking while your NPC is approaching (so it doesn't have to chase the player), second it keeps running until it ends so you can actually add map transfer command followed by other commands and they will be executed even if the player is in another map. Besides that, using a script to move your event is better than using the Set Move Route command because it allows you to iterate the movement until the event actually reaches the player. It doesn't matter how far the player is.

I hope this helps.

Original thread: https://forums.rpgmakerweb.com/threads/time-limit-roaming.79160/