The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking
Reload this Page Script Any info on scripting time based events?

Notices
For all updates, view the main page.

Binary ROM Hacking Need a helping hand or just want to talk about binary ROM hacks? Get comments and answers to any ROM Hacking-related problems, questions or thoughts you have here.

Ad Content
Reply
 
Thread Tools
  #1   Link to this post, but load the entire thread.  
Old August 11th, 2017 (4:00 PM).
Auroran's Avatar
Auroran Auroran is offline
 
Join Date: Feb 2013
Gender: Male
Posts: 23
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
Reply With Quote
  #2   Link to this post, but load the entire thread.  
Old August 13th, 2017 (5:04 PM).
NewDenverCity's Avatar
NewDenverCity NewDenverCity is offline
 
Join Date: Apr 2014
Location: Antarctica
Gender: Male
Nature: Calm
Posts: 326
https://pastebin.com/4UJg4KTD

I wrote this for FR, change the labels at the bottom and you'll probably be good. It uses two vars for every event so yeah.
Reply With Quote
  #3   Link to this post, but load the entire thread.  
Old August 13th, 2017 (10:35 PM).
Deokishisu's Avatar
Deokishisu Deokishisu is offline
Mr. Magius
 
Join Date: Feb 2006
Location: If I'm online, it's a safe bet I'm at a computer.
Gender: Male
Nature: Relaxed
Posts: 984
Quote:
Originally Posted by Auroran View Post
snip...
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.
Reply With Quote
  #4   Link to this post, but load the entire thread.  
Old August 14th, 2017 (1:01 AM). Edited August 14th, 2017 by Auroran.
Auroran's Avatar
Auroran Auroran is offline
 
Join Date: Feb 2013
Gender: Male
Posts: 23
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.
Reply With Quote
  #5   Link to this post, but load the entire thread.  
Old August 14th, 2017 (11:48 AM).
Deokishisu's Avatar
Deokishisu Deokishisu is offline
Mr. Magius
 
Join Date: Feb 2006
Location: If I'm online, it's a safe bet I'm at a computer.
Gender: Male
Nature: Relaxed
Posts: 984
Quote:
Originally Posted by Auroran View Post
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.
Reply With Quote
  #6   Link to this post, but load the entire thread.  
Old August 14th, 2017 (1:43 PM).
Auroran's Avatar
Auroran Auroran is offline
 
Join Date: Feb 2013
Gender: Male
Posts: 23
Quote:
Originally Posted by Deokishisu View Post
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
Quote:
#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!
Reply With Quote
Reply

Quick Reply

Join the conversation!

Create an account to post a reply in this thread, participate in other discussions, and more!

Create a PokéCommunity Account
Ad Content

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 9:16 AM.