• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Timer-Based Events

Derxwna Kapsyla

Derxwna "The Badman" Kapsyla
  • 437
    Posts
    13
    Years
    Before you tell me to go "Read the Wiki" (Which I've already done quite a dozen times, especially in regards to what I'm about to ask), hear out my question please.

    In my game that I'm working on, I'm doing a Gym where the gimmick is: If you step on more than 5 flowers, the Gym Leader will deny your challenge for 24 hours. During that transitioning period, she will repeat the same line until the 24 hours have passed.
    Spoiler:

    Each of the flowers in the gym (Save for a few, but this post doesn't concern those flowers) is marked with an event which, if stepped on, adds +1 to the variable "Flowers Stepped On". Once the variable hits 5, it triggers the timer (Or so I would hope it does) and the specific line by the Gym Leader.
    Spoiler:

    However, the problem I ran into is, since you don't physically interact with the Gym Leader to make the variable hit 5, and thus make the timer start, I wasn't sure where to put the timer. According to the Time Based events page on the Wiki, the timer normally attaches to the event that it gets triggered by (In the case of a Digging Mini-game, it would attach itself to a Dig spot, and when the player was done digging, it would activate the timer and not allow the player to use that spot for 24 hours).
    Spoiler:

    So, I attempted to place the event which triggers the timer elsewhere on the map. This event contains the three pages needed, like it said on the wiki. However, it added the additional line of resetting the variable to 0.
    Spoiler:

    I'm assuming I did it wrong, because when I came back 24 hours later, and reloaded the map, the Gym Leader was still saying the line from when the Variable was at 5, instead of saying what she should if the variable was less than 5. Might anyone be able to help me understand how to make this work properly? It'd be very appreciated!
     
    A key piece of information, which probably isn't written down anywhere, is that you can add parameters to pbSetEventTime. These parameters are one or more numbers, and are the IDs of events on the same map whose time should also be set along with the current event's.

    Let's say that your Gym Leader's event ID is 1. Their event is a typical time delay event, with the battle on the first (default) page and the refusal on the "wait some time" second page. Because it's a trainer, there'll also be a fourth page for having defeated them. The third page also resets the flower count variable to 0.

    Each flower event should look like this:
    "image removed"
    The flower count variable starts at 0, and is increased by 1 each time a flower event is stepped on. Upon the fifth step, pbSetEventTime(1) is called and the flower count is set to -1. This second part is important, because it prevents the time from being reset by stepping on flowers while the 24 hour refusal period is already under way. The outer Conditional Branch makes sure that you can't change the -1 to something else, so you're free to stand on all the flowers you want during that time.

    You'll see that key piece of information I mentioned earlier. The flower event's time will be set, but that's okay because it doesn't do anything with it and can be ignored. The relevant part is that event 1's time is also set, which is the Gym Leader's event, which is what we want.

    There's no need for any other events.
     
    Alright, I think I understand it now. I'll have to wait 24 hours to run the check though, because I have no idea how I can actually force the check (Without changing my computer clock). In the meanwhile, though, is this how the third page for the event should look?
    [PokeCommunity.com] Timer-Based Events

    The wiki said that the second two lines there always had to be there, But I wasn't sure how it would reset the counter back to 0 so I left the Control Variable event there to go off when the timer hit 0. I'm also not sure what the setTempSwitchOn("A") will do here, and I don't see why I'd still need "Control Self Switch A = OFF".
     
    For testing's sake, you could use a switch with the name s:cooledDown?(10) in the Gym Leader's third page instead of the one you have, and it'll cool down in 10 seconds. Remember that you'll need to leave and re-enter the map to get it to refresh (or I think there's a debug function to do that).

    Yes, that third page looks fine to me.

    setTempSwitchOn does just that: it turns on one of the event's temporary self switches. These are different to the actual Self Switches, which permanently remember which state they're in. The temporary self switches only remember their state while the event is still loaded, and reset to false each time the map is entered. Note the capitalisation - that's how I distinguish between them.

    It works by combining itself with the cooledDown? switch. Part of that cooledDown? method is to see whether the event's temporary self switch A is off. If it's on, then the method will return false, and the page which uses the cooledDown? switch in its conditions will not be used because its conditions are not met.

    The event's Self Switch A is on while the event is cooling down. It's used to distinguish between the first and second pages, and makes sure the third page (checking whether it's cooled down enough) only happens if it was supposed to be cooling down in the first place. Part of what the method pbSetEventTime does is turn the event's Self Switch A on.



    When you enter a map, each event on that map is checked through to decide which page it wants to use. When it looks at the Gym Leader, it checks the third page first, because that's how event pages are used. Hmm, it says. Does the cooledDown? method return true? If enough time has passed, it will (because the temporary self switch A is off by definition because it's been freshly loaded), so the third page is used because its conditions are met (i.e. they're all true).

    Because the third page is set to Autorun, its contents will be performed immediately. One of these contents is the setTempSwitchOn method. This method sets the event's temporary self switch A to on, and then forces the event to refresh itself to decide again which page it wants to use. This time the third page's conditions are not met, because the temporary self switch A is on, so the third page will not be used. The second page won't be used either, because it required Self Switch A to be on but it was turned off in the third page when it autoran. Therefore it'll use the first page.

    What happens if not enough time has passed? Well, the third page won't be used at all, not even briefly, because it hasn't cooled down enough yet. Part of setting the event's time is that the event's Self Switch A was turned on, which means the conditions for the second page are met. Therefore the second page will be used.

    Hopefully that explains what happens.
     
    Back
    Top