Scripting Tutorial
For Pokescript
Hey everyone!
I've been on the community for a few months now, and I've learned many things about scripting, thanks to people like Irish
Witch, Zel, and Christos.
But....
Some of their stuff is pretty hard to understand, so I'm going to try making an easy-to-understand-tutorial.
All of this will be done on POKESCRIPT,
the program created by Irish Witch.
Now then, let's begin.
Starting Off
The first thing needed to know about scripting is how to write text.
It can't simply be written as "blah blah blah",
It needs to be written in a special format.
Let's just say for all intentional purposes, we want to say this text.
Now, we need to write it using slashes (\) and a certain character to indicate where that is in the talking. Observe.
[SPOILER]"Hello,\n my name is Joe.\pI am a pokemon trainer from Pallet\nTown. /SPOILER]
You can see the "\n" and the "\p". \n represents something like
"continues on next half of box".
For example, it would look like:
\p represents "new box"
There is also "\l" which is kind of the same as \p, but you will notice the difference when you actually make a script.
Now then, we seem to be done with that. Moving on.
Simple Script
For this tutorial, when I say simple script, I mean something not too compicated, but still includes a little bit
complication. (For beginners)
Okay, when I say simple script, I always think of the professor Oak's aid script.
It works like this:
-when you talk to the aid, he will say hello, and give you an item (potion)
Now then, on to your first script.
To begin, we must open notepad, and type the following:
That small bit of code represents the beginning of a script.
ALWAYS PUT THAT!
After that, place an offset.
It really does not matter what you write there, but I usually say something like that.
Okay, so we want the aid to talk to you, so we have it say a message. But before that, we need to put the following:
The lock means that the character will not move around while they're talking to you.
Faceplayer is self-explanitary. (Face the player)
So, on to the message.
(again, the offset does not matter.)
We shall have the aid say:
[PLAYER] shows the name of the player.
HOWEVER
Only use [PLAYER] in a program called advance text.
When making an actual script, we use the offset "\v\h01" That will make the name show up.
So, this is what it will look like:
Okay, the "$aidtalk 1 = " is to represent that that offset is this text.
The
boxset 6 means that it is a normal text box.
(If you wanted a yes\no script, use boxset5)
Now, for the potion.
We will use the
giveitem command to give it.
The offset for the item
potion is
.
before using an offset for an item, song, pokemon, character, or warp, use
0x.
So, we use
The 1 just tells that we're getting 1 potion.
But there is one more thing we need. To prevent this event from being repeated, we must use
flags. Flags
basicly tell whether or not this has happened.
A flag is written in the form of: < 0xFLAG > Where it says FLAG, we must replace it with a number. The numbers between 200-
299, and 800-899 are okay to use.
EG. 0x200
But we can't simple write "flag 0x200", we need to say what about it we want. Setflag, Clearflag, and Checkflag are the only
things we can do. (so far as I know) Setflag means that the player has done the event.
And, this is our complete script:
The reason we put the aidtalk at the bottom is becuase it compiles better, and there usually aren't any glitches. Do that
with all of your scripts. EVERYTHING WITH AN OFFSET $ GOES AT THE BOTTOM.
And that, is a simple script!
Now you can write it to your rom using pokescript.
(See Irish Witch's tutorial for explanation)
I don't know if I mentioned this, but the reason for the 1 after the 0xD is for
the quantity of the item. For this example,
we want to recieve one potion.
Now then, you have made your first simple script!
Now, let's get a little more complex.
We'll use this same script, just edit it.
Now, let's say we want the aid to be activated by instead of being talked to, when the player steps in a certain spot. The
way we will do this is by adding "Applymovement" to our script. So, instead of putting "Faceplayer" we will put
"Applymovement".
Like this:
Now, the fist thing you may notice is that we no longer have the Lock command. The reason being is that is we lock the
person, well, really he can't move if we lock him.
Next, you'll notice that we put an 0x01 after applymovement. That indicates that the person with the people number 1 in
advance map will move.
Then we have our offset. It's just a randomly defined thing, as usual.
And last, we have our Pause 0x30. That represents that the script will wait for the aid to take three steps before
continuing. Use 0x10 to represent one step, 0x20 for two, and 0x30 for three.
As usual, we have Release. Like any script, end it with release. If I haven't already said it, END EVERY SCRIPT WITH
release
end
But just "Applymovement" won't do everything. We need to fill it in.
Here is a list of all the movements in fire red.
These are the offsets for basic movement:
UP = 0x11
DOWN = 0x10
LEFT = 0x12
RIGHT = 0x13
So, for this script, we'll have the aid move three steps right over to the player.
And since we'll be using items, we'll need a list of them.
As we see, potion is 0xD
It will look like this:
At this point, you may be a little confused. We put the 1 for the same reason that we do in a text script.
The simicolon (;) is the same thing as and equals. (=) We just use simicolons in movement scripts.
The #binary is just how we begin a list of movements. EG. 0x13 0x13 0x13
And last, the 0xFE. That's how we end a list of movements. 0x13 0x13 0x13 0xfe
IT MUST BE AT THE END OF EVERY LIST OF MOVEMENTS.
You may aso be wondering why we changed the $done sequence to just a release end.
The reason for that is because now, we're not talking to the aid. We're stepping on a certain point on the map that will
activate the script. And we don't want for it to be that we step in the spot and all of the sudden, the text "Hello" shows up
on the screen! So, we just replace it with release, and end. That will make it so nothing happens when we step there.
Now it's done! The event with the number 1 will move. Just set this script in advance map, and for the var values, put 03 in
the fist one, 50 in the third one, and 40 in the fourth one. That will make your script run correctly.
Follow me Script
Those simple commands are nice and all, but a game gets boring when you use all simple scripts. So, let's get a little more
difficult.
Let's take for example, one of the fist scripts in gold & silver. The one where if you try to leave, the lady, Mary I think,
will walk over to you and stop you and make you come with her back to her original location until you see the professor. And
when this script happens, the follow me song plays.
The way that this is done, would look kinda like this.
So, there's our music script. Applymovement 0xFF will move the player. We have $mw2 for the player's move because we want the
player to follow mary, so we give it the same movement. The #raw 0x33 after playsound is there just to prevent the game from
freezing. And just for your knowledge, 'fadesound' makes the song fade to the map's original song. If you don't put
fadesound, the song will continue playing even when the script ends.
For everyone reading the tutorial, if you want an actual follow me script, you can use this.
You can compile that into your game, and it will work.
Just take out the 'right's and 'left's
.......well..... what now?........ I guess a really complex script.... But, what else is there to cover?.....
Have I mentioned giving pokemon?.....
No, I don't think I have.
Very well,
Giving Pokemon
First, we need our list of pokemon.
Okay, whew! There's our list.
So, if we want the player to recieve a pokemon from a certain pokemon, we need to do it like this.
givepokemon 0x[pokemon] 0x[level] 0x[held item]
of course you need to fill in what I put in []
HOWEVER, IF YOU PUT 0x BEFORE YOUR NUMBER, YOUR RESULT MAY BE SOMETHING OTHER THAN YOU EXPECTED.
I RECOMMEND JUST PUTTING THE PLAIN NUMBER OF THE POKEMON.
givepokemon 394 50 8B
That will give me a level 50 gardevoir that's holding an oran berry.
And that's how you do a givepokemon script.
Note: Generally, you will want to put the command 'givepokemon' towards the end of the script to ensure success.
Also: When you get the pokemon, there will not be a small message saying "You obtained a Squirtle" or anything like that. If
you want that, you should make a message saying that.
And for now, I suppose that's it.
I already have a tutorial on trainer battles, so maybe I don't need it here.
Well, I guess.
Trainer Battles
Sample:
That script would be a perfect trainerbattle script. The '1' after trainerbattle I just always put there. 0x001 is for the
PET ID of the trainer. $before is what the trainer says before the fight, and $after is what they say when they lose. If you
want the script to continue after the battle, do this:
You can pretty much do anything you want with the after sequence. Of course, it does NOT NEED to be "further". It could be
anything you want.
So for now, that's my whole tutorial. If there's something I missed, let me know, and I'll cover it.
Hope this helps!
Warping
To warp the player to another location, simply put the command:
warp 0x[map bank] 0x[map] 0x[warp]
However, the script will usually end after a warp is done.