• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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.

[Script] Any info on scripting time based events?

23
Posts
11
Years
  • Seen Aug 29, 2019
I am learning to hack emerald and wish to script an event that calls on the in game time to allow certain events/maps to be accessible at certain times of the day, I have scoured the internet, and thus far my efforts have returned empty handed.

I, therefore, turned to reverse engineering existing time-based events, my study was the Shoal Cave tide events, however, I feel my knowledge is still a little too poor to understand how to manipulate this. Looking at the Level scripts in XSE it seems it It calls on a special 0xD5, which sets/clears a flag 0x89A. This flag is used to set the map footer for Shoal Cave as either the flooded or low tide variant.

I therefore quickly concluded that there is likely no simple way to just 'call on the time' and see if it matches my desired value, and set events to appear accordingly, so I did some further digging and found some research by someone else on the 0xD5 Special script https://sites.google.com/site/hackroms/documents-researchs/shoal-cave

In his research, he concluded that there is a table that dictates at which hours the tide is high, leaving the map flooded. The structure of that table is 24 bytes (24 hours), and if a certain hour byte is 1, the script will set the flag, and we get a high tide.

Ideally, I could use the RTC data to just call on the current time, but it doesn't look that simple for event creation, so it appears that setting flags are the way forward here. So my idea is that I suppose it could be possible to manipulate the table for tide times somehow (may be too limiting) or write a new special script in a similar fashion to set 24 individual flags for each hour of the day, and use those to check the time and only allow my scripts to activate if the desired flags are set, but I don't understand where this information was actually decompiled from or how I would go about changing it (I've only been using Advanced Map and XSE so far)

So my questions are:

-Is there any info on creating time-Based Events already I simply haven't found yet that can save me all this hassle?
-If not, where was this info about the special script decompiled from so I may access and study the tables myself?
-Is there a way I can edit this or create a new script to have the desired effect?

Thank you for you advice
 

Deokishisu

Mr. Magius
990
Posts
18
Years
The XSE script command resetvars is erroneously named for RSE. It dumps the current hour into variable 0x8000, the current minute into 0x8001, and the current second into 0x8002. I've been using this in combination with compare to script some of my simpler time based events.

I believe there was research into extending the amount of daily flags (flags that are reset automatically at midnight), but I read about it so long ago that I'm not sure where it is. You may want to check the Quick R&D Thread. I didn't do this because I just reused the existing ones and when I ran out I started using variables and resetting them manually.

It appears to reset those variables to 0 in FRLG because there is no clock; this is likely why HackMew named it resetvars.
 
23
Posts
11
Years
  • Seen Aug 29, 2019
Oh wow, so if they are dumped into a variable like that, then this should be easy enough to manipulate without flags or tables. Thankyou.


So if I use compare Var for x8000, I assume it's value 0 for midnight then incrementing up to 23 for 11pm?

So if I wanted an event to only be accessible at 2 am I'd write something like this below, or is there more to it?

#dynamic 0x800000

#org @start
resetvars
compare 0x8000 0x2
if 0x1 goto @script
end

EDIT:apparently it said I clicked report instead of reply by accident. My appologies, I'm on mobile.
 
Last edited:

Deokishisu

Mr. Magius
990
Posts
18
Years
Oh wow, so if they are dumped into a variable like that, then this should be easy enough to manipulate without flags or tables. Thankyou.


So if I use compare Var for x8000, I assume it's value 0 for midnight then incrementing up to 23 for 11pm?

So if I wanted an event to only be accessible at 2 am I'd write something like this below, or is there more to it?

#dynamic 0x800000

#org @start
resetvars
compare 0x8000 0x2
if 0x1 goto @script
end

EDIT:apparently it said I clicked report instead of reply by accident. My appologies, I'm on mobile.

Yes, that would be your basic script skeleton if you wanted an event to happen from 2am to 2:59am. Just remember to call a fresh resetvars whenever you want to check the time again, because the variable contents don't "tick" with the clock and will not update on their own.
 
23
Posts
11
Years
  • Seen Aug 29, 2019
Yes, that would be your basic script skeleton if you wanted an event to happen from 2am to 2:59am. Just remember to call a fresh resetvars whenever you want to check the time again, because the variable contents don't "tick" with the clock and will not update on their own.

Well at first it didn't work, then it sort of worked and bugged out, but I think I cracked it now. I love you man! This is gonna go so far!

My Test Script
#dynamic 0x800000
#org @start
lock
faceplayer
msgbox @time 0x6
resetvars
compare 0x8000 0x6
if 0x1 goto @6am
release
end

#org @6am
lock
faceplayer
msgbox @talk2 0x6

#org @time
= Do you know the time?

#org @talk2
= Janus: It's 6 O'clock! whooppee!

7AbkKQP.png
 
Back
Top