Hello Pokecommunity today I will show you how to do time-based events into your hacks. :D
Here is an example of what I mean: http://www.youtube.com/watch?v=h98OV4W1ZsU
Please ignore the noobishness, still was starting out when this tutorial was made.
First, apply the DNS to your ROM (any ROM type).
0x0300553C TIME IS WRITTEN HERE
Pay close attention to WHERE the time is REALLY stored.
In VBA go to the memory viewer and jump to 0x0300553C and you will
If you are like me, you will most likely want to check only for the hours, which is stored at 0x3005542, NOT 0x0300553C.
My script is based on the mysterious TV that Rotom lived in Platinum Version. Tested and works 100%.
We will be using the comparefarbytetobyte command which is like the compare command, but instead of checking variables, it checks the bytes in the specified RAM location.
Here it goes:
checkflag 0x1001 /Checks if the script occurred before/
if 0x1 goto 0x875E1AA
comparefarbytetobyte 0x3005542 0x4 /Checks the hour if it is 4:00 AM/
if 0x0 goto 0x875E166 /If it is less than 4:00AM (3:59, etc.) go to the "now" message/
goto 0x875DFC7 /jumps to part 2/
msgbox 0x875E1B6 MSG_NORMAL '"The TV still has an odd feel to\ni..."
msgbox 0x875E0E9 MSG_YESNO '"Inside the TV...\nThere appears to..."
compare LASTRESULT 0x1
if 0x1 goto 0x875E06C
comparefarbytetobyte 0x3005542 0x14 /Checks the hour again (14 in HEX is 20:00 or 8:00PM)
if 0x4 goto 0x875E166 /If greater than or equal to 8:00PM go to the "now" message
goto 0x875E02A /Jumps to the "not time yet" message
msgbox 0x875E08B MSG_NORMAL '"[player] thumped the TV set!"
setvar 0x6000 0x12A
setvar 0x6002 0x148
wildbattle 0x97 0x14 0x0
msgbox 0x875E0A4 MSG_NORMAL '"The TV has an oddly malevolent\nfe..."
= The TV still has an odd feel to\nit...
= Inside the TV...\nThere appears to be a Pokémon?...\pThe Pokémon appears as if it will\ncome out. Want to thump the TV?
= [player] thumped the TV set!
= The TV has an oddly malevolent\nfeel...\pIt's as if it is staring...
This is simple enough, and you CAN check for minutes and seconds and days and months and years and all that.
For the comparefarbytetobyte command, refer to this list:
0x0 means less than
0x1 means equal to
0x2 means greater than
0x3 means less than or equal to
0x4 means greater than or equal to
Please credit karatekid552 for creating it, and robin22gongon for testing it, and me for finalizing it.
Firstly, please put your script in [ CODE ] brackets (without the spaces obviously) to improve readability.
Secondly, did you know that the DNS actually has a byte held elsewhere in memory which tells you far more simply what time of day it is?
In the DNS, it asks you for a RAM Offset for the "Status Byte". That status byte can tell you, at a glance, what time of day it is, and it's defined by the times you entered when adding the DNS to your ROM.
Just saying, it's quicker and easier to check that status byte than to check the hours, minutes and seconds (or even just the hours).
Consider, you want to check a range of times to see if it's a specific period, which requires a minimum of 2 checks, except for times at the extreme ends of the scale.
The status byte checks requires one check and you know straight away.
It never fails to surprise me how few people make use of this great little inclusion in the DNS.
Hey guys, please check out my recreations of the gen 1 and 2 music on my custom engine at my SoundCloud! - Here!
How would I go about making events on a timer? Like for example, I want an event that can only happen once a day.
Easy. The first time the event happens check the day. Then copy the byte to a var. The first half will be the day it is now. The second half will be the day after. So the var is set up like so:
DD is the current day, AA is tomorrow.
When the event is going to happen, check if the current day is equal to the After day. If so, re-do the whole thing, and you get a repeating event as the days go by.