The PokéCommunity Forums Fan Games ROM Hacking Tools, Tutorials & Resources
Tutorial Time-Based Events

Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.

Reply
 
Thread Tools
  #1    
Old April 3rd, 2013 (7:01 PM). Edited May 22nd, 2014 by GoGoJJTech.
GoGoJJTech's Avatar
GoGoJJTech GoGoJJTech is offline
(☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)
  • Gold Tier
 
Join Date: Nov 2012
Location: Earth
Age: 18
Gender: Female
Nature: Jolly
Posts: 2,477
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:
Code:
'---------------
#org 0x75E186
lock
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/

'---------------
#org 0x75E1AA
msgbox 0x875E1B6 MSG_NORMAL '"The TV still has an odd feel to\ni..."
end

'---------------
#org 0x75E166
msgbox 0x875E0E9 MSG_YESNO '"Inside the TV...\nThere appears to..."
compare LASTRESULT 0x1
if 0x1 goto 0x875E06C
closeonkeypress
end

'---------------
#org 0x75DFC7
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

'---------------
#org 0x75E06C
msgbox 0x875E08B MSG_NORMAL '"[player] thumped the TV set!"
setflag 0x1001
setvar 0x6000 0x12A
setvar 0x6002 0x148
wildbattle 0x97 0x14 0x0
release
end

'---------------
#org 0x75E02A
msgbox 0x875E0A4 MSG_NORMAL '"The TV has an oddly malevolent\nfe..."
end


'---------
' Strings
'---------
#org 0x75E1B6
= The TV still has an odd feel to\nit...

#org 0x75E0E9
= 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?

#org 0x75E08B
= [player] thumped the TV set!

#org 0x75E0A4
= 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.
__________________
I believe in Jesus Christ my Savior. If you do too, and aren't scared to admit it, then copy and paste this into your signature.
The HGSS Music Patch - The BW/2 Music Patch - ASM: Switch Music Based on Seasons
Romhack.me Profile - Pokecommunity Profile - Youtube Channel

Support me at my site!
Pokémon Platinum Red and Blue
Reply With Quote

Relevant Advertising!

  #2    
Old April 5th, 2013 (5:05 AM).
Jambo51's Avatar
Jambo51 Jambo51 is offline
Glory To Arstotzka
     
    Join Date: Jun 2009
    Gender: Male
    Nature: Quiet
    Posts: 732
    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).

    Spoiler:
    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!
    Reply With Quote
      #3    
    Old April 5th, 2013 (5:09 AM).
    BlackWhiteRobin's Avatar
    BlackWhiteRobin BlackWhiteRobin is offline
       
      Join Date: Sep 2012
      Age: 19
      Gender: Male
      Nature: Quirky
      Posts: 529
      Here's another sample I made: This one warps to the Rivals House so I suggest removing the Warp, make a signpost event, put it on the door, and compile this.
      Code:
      #dynamic 0x800000
      
      #org @start
      lock
      faceplayer
      Comparefarbytetobyte 0x3005542 0x06
      if B_>= jump @opened?
      goto @closed
      end
      
      #org @opened?
      comparefarbytetobyte 0x3005542 0x14
      if B_>= jump @closed
      goto @open
      end
      
      #org @open
      msgbox @this_shop_is_open 0x2
      warp 0x4 0x2 0x1 0x4 0x8
      waitstate
      end
      
      #org @close
      msgbox @this_store_is_closed 0x2
      end
      
      #org @this_shop_is_open
      = Come in, we're open!
      
      #org @this_store_is_closed
      = Sorry we're closed!
      Credits to me and karatekid552 if you can but not so necessary.
      __________________

      Reply With Quote
        #4    
      Old September 28th, 2013 (7:31 PM).
      superluke's Avatar
      superluke superluke is offline
         
        Join Date: Sep 2013
        Posts: 8
        How do I make it to Where at 2 PM Hoothoot can appear in the grass, and then dissappear at 5 PM?
        Reply With Quote
          #5    
        Old September 29th, 2013 (8:35 AM).
        GoGoJJTech's Avatar
        GoGoJJTech GoGoJJTech is offline
        (☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)
        • Gold Tier
         
        Join Date: Nov 2012
        Location: Earth
        Age: 18
        Gender: Female
        Nature: Jolly
        Posts: 2,477
        Quote:
        Originally Posted by superluke View Post
        How do I make it to Where at 2 PM Hoothoot can appear in the grass, and then disappear at 5 PM?
        In the grass? You would need to use this ASM: http://www.pokecommunity.com/showthread.php?t=237951
        In an event like a script or signpost or whatever, you could just change the checks of hours.
        __________________
        I believe in Jesus Christ my Savior. If you do too, and aren't scared to admit it, then copy and paste this into your signature.
        The HGSS Music Patch - The BW/2 Music Patch - ASM: Switch Music Based on Seasons
        Romhack.me Profile - Pokecommunity Profile - Youtube Channel

        Support me at my site!
        Pokémon Platinum Red and Blue
        Reply With Quote
          #6    
        Old September 30th, 2013 (9:24 AM).
        exidia exidia is offline
           
          Join Date: Sep 2013
          Gender: Male
          Posts: 27
          Do you happen to know how to add pokemon from other regions to emerald? I really need it.
          Also adding them all at the same time would be awesome.
          Reply With Quote
            #7    
          Old September 30th, 2013 (11:39 AM).
          GoGoJJTech's Avatar
          GoGoJJTech GoGoJJTech is offline
          (☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)
          • Gold Tier
           
          Join Date: Nov 2012
          Location: Earth
          Age: 18
          Gender: Female
          Nature: Jolly
          Posts: 2,477
          Quote:
          Originally Posted by exidia View Post
          Do you happen to know how to add pokemon from other regions to emerald? I really need it.
          Also adding them all at the same time would be awesome.
          This is a thread about time-based events, so this question does not belong here, it goes in the simple questions thread.
          __________________
          I believe in Jesus Christ my Savior. If you do too, and aren't scared to admit it, then copy and paste this into your signature.
          The HGSS Music Patch - The BW/2 Music Patch - ASM: Switch Music Based on Seasons
          Romhack.me Profile - Pokecommunity Profile - Youtube Channel

          Support me at my site!
          Pokémon Platinum Red and Blue
          Reply With Quote
            #8    
          Old November 2nd, 2013 (5:48 PM).
          chrunch chrunch is offline
          • Gold Tier
           
          Join Date: Oct 2009
          Gender: Male
          Posts: 1,348
          How would I go about making events on a timer? Like for example, I want an event that can only happen once a day.
          __________________
          Reply With Quote
            #9    
          Old November 2nd, 2013 (5:54 PM).
          GoGoJJTech's Avatar
          GoGoJJTech GoGoJJTech is offline
          (☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)
          • Gold Tier
           
          Join Date: Nov 2012
          Location: Earth
          Age: 18
          Gender: Female
          Nature: Jolly
          Posts: 2,477
          Quote:
          Originally Posted by chrunch View Post
          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:
          DDAA
          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.
          __________________
          I believe in Jesus Christ my Savior. If you do too, and aren't scared to admit it, then copy and paste this into your signature.
          The HGSS Music Patch - The BW/2 Music Patch - ASM: Switch Music Based on Seasons
          Romhack.me Profile - Pokecommunity Profile - Youtube Channel

          Support me at my site!
          Pokémon Platinum Red and Blue
          Reply With Quote
            #10    
          Old November 29th, 2014 (6:58 AM).
          ~SAGE's Avatar
          ~SAGE ~SAGE is offline
          Spanish Rom Hacker
             
            Join Date: Jul 2014
            Location: Italia
            Age: 21
            Gender: Male
            Nature: Lonely
            Posts: 35
            where is stored the other data, like day and month?
            please respond
            __________________

            El inteligente no es aquel que lo sabe todo

            Si no aquel que sabe utilizar lo poco que sabe
            Reply With Quote
              #11    
            Old November 29th, 2014 (6:59 AM).
            GoGoJJTech's Avatar
            GoGoJJTech GoGoJJTech is offline
            (☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)
            • Gold Tier
             
            Join Date: Nov 2012
            Location: Earth
            Age: 18
            Gender: Female
            Nature: Jolly
            Posts: 2,477
            Quote:
            Originally Posted by laflacapkm View Post
            where is stored the other data, like day and month?
            please respond
            This image right here shows the locations and corresponding bytes for what they are:



            Just make sure to follow the colors lol
            __________________
            I believe in Jesus Christ my Savior. If you do too, and aren't scared to admit it, then copy and paste this into your signature.
            The HGSS Music Patch - The BW/2 Music Patch - ASM: Switch Music Based on Seasons
            Romhack.me Profile - Pokecommunity Profile - Youtube Channel

            Support me at my site!
            Pokémon Platinum Red and Blue
            Reply With Quote
            Reply
            Quick Reply

            Sponsored Links
            Thread Tools

            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 10:01 PM.