- 230
- Posts
- 17
- Years
- Seen Jan 3, 2010
Scripting Guide for Beginner Hackers
Yep, that's what beginners were waiting for.
Introduction
Some welcome stuff...
Welcome to this guide!
What will we do here? We will learn basic scripting and maybe, only maybe, advanced bits. This is a document to help you create more complex hacks, not only plain map or graphics changing ones. You know, we all have seen them and they aren't good. It's now your turn to change it. Every part of this guide will be in spoiler. If you need to e.g. go to bed cause it's too late, it's easier to just open a spoiler containing the desired section than scrolling whole page ;)
Contents
What will you learn here?
Introduction to scripting, basic message commands etc.
Our "Hello World!" tutorial ;)
Yep, that's what beginners were waiting for.
Introduction
Some welcome stuff...
Welcome to this guide!
What will we do here? We will learn basic scripting and maybe, only maybe, advanced bits. This is a document to help you create more complex hacks, not only plain map or graphics changing ones. You know, we all have seen them and they aren't good. It's now your turn to change it. Every part of this guide will be in spoiler. If you need to e.g. go to bed cause it's too late, it's easier to just open a spoiler containing the desired section than scrolling whole page ;)
Contents
What will you learn here?
- We will start with basic message displaying commands and later on we will progress to displaying player's and rival's name. We will learn to compare results in a YES/NO script. And we shall do a checkgender thingy, just for fun ;) This will be divided into two parts.
- After that, we will start messing a bit with movement commands, meaning by explaining each and we will make a movement script.
- As we want to make complex scripts we will start combinig our knowledge.
- We will continue with flags. We will explain all three commands around flags. You will find out which ones they are down in the tutorial. We will also explain some pre-defined flags we will use in later scripts, as they will be unnecessary till you have Pokémon - we will use those flags when messing with giving a Pokémon.
- We are almost in the giving item/Pokémon part, but we are still not there yet. Now we will play with special commands (and we will explain the national Pokédex trick) and then continue at the most anticipated part.
- No, I won't let you go to giving Pokémon/item yet. We will have one feature not related to scripting before. Y ou will have the ability to test yourself after each section. You will get a task to make a script combining your current knowledge. You can complete each task and divide scripts into spoilers. I will check them later and tell you if you have the script correct. You may choose any of tthese tasks and let only one be reviewed. This is recommended.
- Now you will learn about the part you've been waiting for: Giving a Pokémon. This is self explanatory, so I will give you further information in prper section.
- We have the giving item part in fromt of us, we will mess with them a bit just for fun.
- Now we will play with playing sounds. It will be fun and useful for a radio concept.
- Now we will learn about changing weather. It will look dramatic ;) At least we should hope so :laugh:
- Now you know everything you need for start, here is the final scripting task. It will be pretty hard, so you should be well-prepared and you will pass. I ask each of you who read this to make the script as a test after learning. If you complete the task well, you might earn a certificate of a well-trained beginner scripter. I will decide if I issue these as it may take more time than I planned, so I might only write it.
Introduction to scripting, basic message commands etc.
Our "Hello World!" tutorial ;)
Spoiler:
Let's start!
We all know that each and every tutorial needs to start with completely primitive things. And this tutorial ...will have a little exception. We will leasrn some advance bits in the very start of the tutorial. But first, we will say something about the first and most important line in the script. The offset.
Offsets and pointers
When making a script, the data needs to be stored in a free space of a ROM. The location of each and every byte is marked by an offset. It's a hex value representing the byte itself. It marks its position in the "row" For example a byte number 255 will have an offset 0x0000FF in common Pokémon Advance ROM.
That 0x tells the script parser that the offset isn't just random combination of letters and numbers, it's a specific number, unique in whole ROM. You cannot find two same offsets in a ROM, just many offests pointing to other one multiple times. These are called pointers. They are usually used when you need a separate offset for a part of script.
To let you understand better, I will show you in-game example. No video, though. It's recommended to look at it, but it's not needed, really.
Example
You suddenly become a very advanced scripter - use your imagination.
Now, you need to make a movement script - we will talk about these more deeply in the next section. You need to make a person move 3 steps left and one down. You need every single byte and so you search for the specific movement data... BINGO!
You found the data at offset 0x425FAC - this, in reality, contains completely different data and is used here only for demonstrational purposes.
So you point the command saying "Move a sprite XY using data at offset..." to the specified offset.
Defining an offset
We went too far when speaking about the first line. But it's good for something, anyway...
The very first command standing before the script offset is #org. How the whole line 1 looks like??
#org 0x******
Asterisks are representing the hex values. If you need some free offsets, I would recommend to move around the 800000 and higher. For your first script, we will use the offset 0x800000.
Sometimes, you need to lock moving person and make it face the player. You will do this with these two commands:
lock
faceplayer
That was easy, wasn't it? Well... you should only use these commands when interacting with moving people. You define the movement (like walking etc.) in your desired mapping program - AdvanceMap for example. I won't explain an furter cause it will be in my tutorial for absolute beginners, this one expects you to know the basic operations with AdvanceMap.
Message command
I won't explain that much as before. Just to warn you, we will start using the "pointer" term regularly, along with "offset". The command makes the game display text. The text will be stored at separate offset. The command uses a pointer to display the text stored in the other place. Basically, the script can start at offset 0x800000 and the message command points to the offset e.g. 0x100000 - again, it doesn't contain text data in real ROM. Back to the topic.
msgbox 0x******
Asterisks represent the offset. We will use 800100, as 800000 is the script start. It's space-wasting, but still, better than overwriting the data. Now, every message needs a boxset. We will use two or three types of boxset.
0x2 is normal boxset that closes after the text ends and you press a key. I think the boxset 0x6 does the pretty same thing. And 0x5 is the YES/NO boxset, we will talk about it in the last parts of this section.
We can use the boxset 0x* variant for the command, but I want you to know the older command name (I think). So the one mentioned above, or
callstd 0x*
Asterisk represents the boxset type. We will use 2 or 5 now, cause I have them tested and we will need no more. You will need to put only one thing if you want a simple script with oxset 0x2 or 0x6:
Now, when we know the basic things, we shall advance to 0x5 boxset and
comparing the answer. But, if you want this simple script, you should put in only one more command.
release
end
Now that it's nice! We have a script! But if you want the person speaking to be locked - not moving - and facing player, you should put in lock and faceplayer commands right after the #org command and release command right before end, as mentioned before. This is optional, so don't need to worry.
Now, when you define the offset of the message, you need to put one there. You do it this way:
#org 0x******
= Text goes here.
Don't forget to put a space between "=" and the text itself, or the message won't display. Change asterisks into the desired offset.
Scripting task 1
Create a simple message script. Use the lock, faceplayer and release commands.
21.12. 2007 - A little update!
Hey kids, we didn't finish yet ;) I am here to explain the 0x5 boxset a bit. It's the typical Yes/No boxset. To let the game recognize what did the player choose, you need to compare results.
We start with the boxset:
callstd 0x5
Now we add the comparing command:
compare LASTRESULT 0x*
LASTRESULT is a pre-defined command stating the last result to be compared to the value written in the script. Yes is 0x1, No is 0x0. You can replace the asterisk with 0 or 1 respectively then.
We have it compared, but now, what to do? We will put in a if and goto command. There is another command that you can use to return into the script, but we will learn about it later. So, now you need to put in:
if 0x* goto 0x******
The first hex value should state if yes or no. It means that if you compare the script to the Yes choice and want the script to go to another location if Yes wasn't chosen, you need to put 0 here. If you want to redirect the script after the player chose Yes, put in 0x1. And the 6 asterisks after the second hex value mean offset, as always.
Now, you know everything you need to successfully make a nice script with speaking and player interaction.
Almost everything. You need to know how to display player's name and rival's name with a variable. Scizz's Advance Text uses [PLAYER] and [RIVAL] command. As none of the compilers work with these (maybe PokéScript does, but I recommend not to use it although it might seem user-friendly) currently - HackMew's XSE should work with these, if my information is correct - we will need to use standard variables for now.
\v\h01 for player and \v\h06 for rival.
If you don't know how to put in the "\" sign, go to the character map or just copy it from here. Not confirmed on all keyboard sets, but Ctrl+Alt+Q might work. It does on Slovak keyboard I am using. I am from there and so I don't use naturally all English glyphs and signs such as apostrophes, so these shortcuts can be handy. Not working on English keyboard settings, tho. Maybe a useful thingy for non-English dudes and gals here at PC.
Okay, now we are really done with this tut, please wait till the holiday time ends (around 8th of January) and then, some more content might appear. Check this thread regularly for updates in the holiday time ;) The checkgender part will be here soon, maybe today evening ;) For now, a little scripting should be done from your side:
Scripting task 2
Create a Yes/No script. Use the lock, faceplayer and release commands.
We all know that each and every tutorial needs to start with completely primitive things. And this tutorial ...will have a little exception. We will leasrn some advance bits in the very start of the tutorial. But first, we will say something about the first and most important line in the script. The offset.
Offsets and pointers
When making a script, the data needs to be stored in a free space of a ROM. The location of each and every byte is marked by an offset. It's a hex value representing the byte itself. It marks its position in the "row" For example a byte number 255 will have an offset 0x0000FF in common Pokémon Advance ROM.
That 0x tells the script parser that the offset isn't just random combination of letters and numbers, it's a specific number, unique in whole ROM. You cannot find two same offsets in a ROM, just many offests pointing to other one multiple times. These are called pointers. They are usually used when you need a separate offset for a part of script.
To let you understand better, I will show you in-game example. No video, though. It's recommended to look at it, but it's not needed, really.
Example
You suddenly become a very advanced scripter - use your imagination.
Now, you need to make a movement script - we will talk about these more deeply in the next section. You need to make a person move 3 steps left and one down. You need every single byte and so you search for the specific movement data... BINGO!
You found the data at offset 0x425FAC - this, in reality, contains completely different data and is used here only for demonstrational purposes.
So you point the command saying "Move a sprite XY using data at offset..." to the specified offset.
Defining an offset
We went too far when speaking about the first line. But it's good for something, anyway...
The very first command standing before the script offset is #org. How the whole line 1 looks like??
#org 0x******
Asterisks are representing the hex values. If you need some free offsets, I would recommend to move around the 800000 and higher. For your first script, we will use the offset 0x800000.
Sometimes, you need to lock moving person and make it face the player. You will do this with these two commands:
lock
faceplayer
That was easy, wasn't it? Well... you should only use these commands when interacting with moving people. You define the movement (like walking etc.) in your desired mapping program - AdvanceMap for example. I won't explain an furter cause it will be in my tutorial for absolute beginners, this one expects you to know the basic operations with AdvanceMap.
Message command
I won't explain that much as before. Just to warn you, we will start using the "pointer" term regularly, along with "offset". The command makes the game display text. The text will be stored at separate offset. The command uses a pointer to display the text stored in the other place. Basically, the script can start at offset 0x800000 and the message command points to the offset e.g. 0x100000 - again, it doesn't contain text data in real ROM. Back to the topic.
msgbox 0x******
Asterisks represent the offset. We will use 800100, as 800000 is the script start. It's space-wasting, but still, better than overwriting the data. Now, every message needs a boxset. We will use two or three types of boxset.
0x2 is normal boxset that closes after the text ends and you press a key. I think the boxset 0x6 does the pretty same thing. And 0x5 is the YES/NO boxset, we will talk about it in the last parts of this section.
We can use the boxset 0x* variant for the command, but I want you to know the older command name (I think). So the one mentioned above, or
callstd 0x*
Asterisk represents the boxset type. We will use 2 or 5 now, cause I have them tested and we will need no more. You will need to put only one thing if you want a simple script with oxset 0x2 or 0x6:
Now, when we know the basic things, we shall advance to 0x5 boxset and
comparing the answer. But, if you want this simple script, you should put in only one more command.
release
end
Now that it's nice! We have a script! But if you want the person speaking to be locked - not moving - and facing player, you should put in lock and faceplayer commands right after the #org command and release command right before end, as mentioned before. This is optional, so don't need to worry.
Now, when you define the offset of the message, you need to put one there. You do it this way:
#org 0x******
= Text goes here.
Don't forget to put a space between "=" and the text itself, or the message won't display. Change asterisks into the desired offset.
Scripting task 1
Create a simple message script. Use the lock, faceplayer and release commands.
21.12. 2007 - A little update!
Hey kids, we didn't finish yet ;) I am here to explain the 0x5 boxset a bit. It's the typical Yes/No boxset. To let the game recognize what did the player choose, you need to compare results.
We start with the boxset:
callstd 0x5
Now we add the comparing command:
compare LASTRESULT 0x*
LASTRESULT is a pre-defined command stating the last result to be compared to the value written in the script. Yes is 0x1, No is 0x0. You can replace the asterisk with 0 or 1 respectively then.
We have it compared, but now, what to do? We will put in a if and goto command. There is another command that you can use to return into the script, but we will learn about it later. So, now you need to put in:
if 0x* goto 0x******
The first hex value should state if yes or no. It means that if you compare the script to the Yes choice and want the script to go to another location if Yes wasn't chosen, you need to put 0 here. If you want to redirect the script after the player chose Yes, put in 0x1. And the 6 asterisks after the second hex value mean offset, as always.
Now, you know everything you need to successfully make a nice script with speaking and player interaction.
Almost everything. You need to know how to display player's name and rival's name with a variable. Scizz's Advance Text uses [PLAYER] and [RIVAL] command. As none of the compilers work with these (maybe PokéScript does, but I recommend not to use it although it might seem user-friendly) currently - HackMew's XSE should work with these, if my information is correct - we will need to use standard variables for now.
\v\h01 for player and \v\h06 for rival.
If you don't know how to put in the "\" sign, go to the character map or just copy it from here. Not confirmed on all keyboard sets, but Ctrl+Alt+Q might work. It does on Slovak keyboard I am using. I am from there and so I don't use naturally all English glyphs and signs such as apostrophes, so these shortcuts can be handy. Not working on English keyboard settings, tho. Maybe a useful thingy for non-English dudes and gals here at PC.
Okay, now we are really done with this tut, please wait till the holiday time ends (around 8th of January) and then, some more content might appear. Check this thread regularly for updates in the holiday time ;) The checkgender part will be here soon, maybe today evening ;) For now, a little scripting should be done from your side:
Scripting task 2
Create a Yes/No script. Use the lock, faceplayer and release commands.
Last edited: