Making a script behavior byte
View Single Post
March 20th, 2010 (04:56 PM). Edited April 15th, 2010 by hashtag.
Starting Pokémon Obsidian
Join Date: Feb 2010
Location: Michigan, USA
Unfortunately I'm not 1337 enough to completely create a new behavior byte, so this will show you how to modify the behavior byte that displays the questionnaire in order to make it run a script.
This is for FireRed US version.
back up your ROM before doing these types of edits, because if a mistake is made, bad problems could pop up.
Hex editor(I use Hex Workshop, google it)
AdvanceMap(To set the behavior byte to tiles)
VBA(or any other emulator. If you don't have an emulator you probably shouldn't be hacking)
XSE (Optional, but will make text insertion much simpler)
First, you need to go to the offset of behavior byte 8F (the byte we'll be changing) in a hex editor. Because I'm not sure what the function of some of the bytes are I can't determine the exact starting position of the data, but the beginning portions don't matter with this method. Go to offset 1A7707. This is a pointer for text to display before the script runs.
Now, either write down 1A7707 somewhere, or just refer back here later. You're going to want to modify this text. Find a free offset with Free Space Finder, you don't need many bytes. 100 will probably be more than enough. Now come up with some text that can be displayed before your script executes. (I couldn't find a way to just get rid of this text box, so be creative) Go to the free offset you just got.
Ignore this next portion if you want to do things the easy way. Open your ROM in XSE and create a dynamic script in this format:
#dynamic 0x(start offset, I use 740000)
= (Just insert your text straight-up here)
Now compile that script, and use the offset it was compiled to for your text pointer.
Now you're going to need to translate your text into hex, if you didn't use the easy XSE method. Here's a table of translations:
Make sure your text code ends in an FF byte. Now, find the offset of where your text starts. You're going to need to flip the order around. For example, if the offset was 123456, you'd use 563412. Now return to offset 1A7707. There are 3 bytes here, followed by a 08 byte. This is the pointer to the text. Replace the 3 bytes before the 08 with the offset you just wrote your text to, in flipped order as I mentioned earlier. If you were to save and test now, your inserted text would be displayed, then you'd see a yes/no box and the questionnaire.
Now, you're not going to want that yes/no box there. Look after the pointer, there's a 09 byte and a 05 byte. Don't touch the 09. The 05 is the type of message, which is indicating it as a yes/no message. Replace the 05 with either 04 or 06, it doesn't matter which. I use 04 because it looks just a tiny bit nicer, since the box won't close between that text and your script, but if your script doesn't immediately have another text box, use 06.
Now, there are 2 more pointers to edit. One is for if you said yes, one is for no, but without a yes/no choice we want the script to run no matter what, and strangely without the yes/no it alternates every other time. They look the same as the other, 3 bytes followed by a 08. The first is at 1A7714, the second is at 1A771E. Now take the offset of whatever script you're writing to the behavior byte and flip it like you did with the offset of your text earlier. Insert those 3 bytes over the old 3, and leave the 08. (as well as everything else around) Do this for both pointers.
(The image isn't cut off at the right, that's the end of the line, that pointer has 2 bytes on one line and one on the next)
Now, save your ROM and open it up in VBA, and go interact with a tile with the behavior byte 8F (set in AdvanceMap's tile editor; by default the questionnaire pad in the pokemart has this byte) If you did everything properly, your script will run on this tile without any script placed on it. Congratulations, you just made a behavior byte of your script!
Note that the yes/no box above is part of my script, the one stored in the behavior byte is eliminated. Before this box, it displays the text "A POKéMON could be in this tree.", which is what I wrote to the byte's text display, then it compares the move headbutt and if no Pokemon knows it, the script just ends there without showing more text. You need to be a bit creative to make the script byte run seamlessly.
POKéMON AQUA SAPPHIRE
View Public Profile
Send a private message to PeregrineFig
Find all posts by PeregrineFig
Find threads started by PeregrineFig
Ignore Posts by PeregrineFig