Fandom

Pokémon Essentials Wiki

Time-sensitive events

227pages on
this wiki
Add New Page
Talk1 Share

This article describes time-sensitive events. These are events that are either only usable during a certain period of time (e.g. an NPC appearing only on Fridays), or reset themselves at a certain time (e.g. midnight every day) or have a delay after being used (e.g. wait 24 hours).

Script switches

Main article: Events

All time-sensitive events will need to decide when they should do their special action, and when they should not. You can do this by using Global Switches (see the main article for more information).

As this article describes time-sensitive events, it will use the Global Switches that depend on the time/day/etc. You can of course create new switches to cover the periods of time you want an event to behave differently in.

Time period only

These events will only be active during a certain period of time (e.g. only between 6pm and 8pm every day, or on Fridays only).

Typical uses for this kind of time-sensitive event are:

  • A set Pokémon encounter that can only be triggered at night.
  • An NPC that appears only on a certain day of the week.
  • A trainer that only battles at night.
  • A prize give-away that is only available during a certain time.

Events like this should be set up as follows:

  • Page 1 - The event as it appears at all other times. This may be blank, or an NPC reciting a line of dialogue, whatever is appropriate.
  • Page 2 - The event as it appears during the special period of time (e.g. the NPC challenges the player to a battle). This page will depend on one or more script switches (see above).
  • Optional other pages - The event as it appears during another special period of time, or the secondary "talking to the NPC after defeating them" page, etc.

Time delay

Once triggered, these events will begin counting time, and will not allow the primary interaction again until a certain amount of time has passed (e.g. 24 hours). If interacted with before the time has elapsed, a different string of events can occur (e.g. a message saying "Sorry, come back tomorrow.").

Typical uses for this kind of time-sensitive event are:

  • An NPC that gives out a gift once every 24 hours.
  • A lottery which you can only enter once every 24 hours.
  • A berry/apricorn tree that only flowers every 24 hours.
  • A tree that can be Headbutted, but which will only produce an encounter if left alone for an hour.
  • A switch that will open a door for only a certain amount of time.
  • A set Pokémon encounter that occurs once every 24 hours.

Event page 1

Headbutt1

Page 1 of a time delay event.

The first event page describes the primary interaction, and something in this interaction will start the event to begin counting time. To make the event start counting time, use the following method:

pbSetEventTime

This method sets the event's personal variable to the current time, and also sets the event's Self Switch A to ON. Once this method has been used, the event's processing should end.

You can use the above method to affect multiple events at once (e.g. a switch affecting a timed door). To do this, simply include the event IDs of those other events as arguments, like so:

pbSetEventTime(2,3)

This example will set the current event's personal variable to the current time and set its Self Switch A, and will also do the same for events 2 and 3 on the same map. Note that this method can only affect events on the same map.

Event page 2

Headbutt2

Page 2 of a time delay event.

The second event page describes the "intermediate" interaction, which is what happens if the player interacts with the event while it is counting. This is typically just a message saying "Try again tomorrow" or something to that effect.

This page must have the condition of Self Switch A being ON.

Event page 3

Headbutt3

Page 3 of a time delay event.

The third event page checks whether the desired amount of time has elapsed. It will check this automatically each time the player enters the map that the event is in, but not while the player remains on the map - they must leave and return in order for the event to reset itself.

This page must have the condition of Self Switch A being ON (like the second page), it must have the Autorun trigger, and it must have the condition of a Global Switch (e.g. 23: s:cooledDown?(86400)) being ON.

The content of this page are as follows:

@>Control Self Switch: A =OFF
@>Script: setTempSwitchOn("A")
@>

This page contains only these two lines, and it must contain both of them.

The Global Switch used as one of the conditions of this page determines what length of time the event counts down for. It is typically a script switch of the following form:

s:cooledDown?(86400)

The number is the length of time in seconds (86400 seconds = 24 hours). You can create your own script switches with different lengths of time.

Reset at midnight

This kind of event is similar to the time delay event above, except it counts days rather than seconds. More accurately, it counts the number of midnights that have passed between uses. That is, if the event was made to count 1 day, then it could be used just before and just after midnight and be the regular interaction each time.

Typical uses for this kind of time-sensitive event are:

  • An NPC that gives out a gift once every day.
  • A lottery which you can only enter once a day.
  • A plot device that triggers at midnight.
  • A puzzle that resets/changes at midnight.

The event's layout will be the same as described above for a time delay event. The only difference is which Global Switch to use as a condition for page 3. The Switch you should use instead will typically a script switch of the following form:

s:expiredDays?(1)&&tsOff?("A")

The number is how many days to wait between regular interactions (i.e. the number of midnights that need to elapse). A number of 1 means the event can be used once each day, 2 means every other day, and so on.

Reset at another time

This kind of event is the same as the "reset at midnight" event above, except the checkpoint time is not midnight but a different time (e.g. 4pm). To create this kind of event, begin by making a tile delay event (not a "reset at midnight" event).

This event will calculate how many seconds need to pass after the current time before the event will have "cooled down". This length of time will need to be stored in a Global Variable specifically used for this purpose (number 42 in this example). Each event or set of events will need its own Global Variable.

Page 3 of the event will need to have a new Global Switch as its condition. This Global Switch should have the following name:

s:cooledDown?(pbGet(42))

The number is that of the Global Variable mentioned above. Each event or set of events will need its own Global Switch whose number of that of their own Global Variable.

The only other change to the event will be in page 1, where pbSetEventTime appears. In addition to that line of code, you will also need to include the following:

checkpoint=16; number=1
t=0; tnow=pbGetTimeNow
t+=(checkpoint-tnow.hour-1)*3600
t+=3600-tnow.min*60-tnow.sec
t+=24*3600 if tnow.hour>=checkpoint
t+=24*3600*(number-1)
pbSet(42,t)

The two highlighted numbers are the only things you will need to change. The first is the hour you want the checkpoint time to be (4pm in this example), and the second is the number of those checkpoints you want to pass before the event resets (1 means every day, 2 means every other day, etc.).

This code will only allow checkpoints to be on the hour, but that should be more than sufficient for most users.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.