• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

tajaros Xtreme Scripting Tutorial

tajaros

Hi I'm dawg
855
Posts
11
Years
tajaros' Xtreme Scripting Tutorial

First update to the latest version of XSE some commands may not work in the old versions of it. Here's a download link for the latest version. LINK

First of all I like to thank the following people for helping me learn how to script.

1. Foullump
2. thethethethe
3. diegoisawesome
4. Hackmew
5. Mastermind_X

For my opinion XSE is the best scripting program there is. XSE stands for Xtreme Script Editor (Not really extreme don't mind the title xD).

There are many features XSE covers that other scripting programs don't. Like Pokescript, PKSV, Diamond Cutter, and Easy Script Maker.

All of the scripts here are tested and working.

Some Feature's XSE has:
1. Dynamic Offsets
2. Use Of Hex Values
3. Less than a second script compiling.
4. Decompiling and can open scripts with Advance Map.
5. A Text Adjuster to adjust the text to align properly.
6. Can be use to shrink or expand the Rom.
7. Has a Free-Space Finder.
8. Has a Hex Viewer.
9. A calculator.
10. A mini-notepad to keep codes.

Firstly I'll teach everyone how to compile scripts.

First of all you must load your Rom. And then script! After scripting click the Compile or the gear Icon on top of XSE. Then copy the very first offset and paste it on Advance Map where your event is.

That is all. :)

Now to start things.

Pointers

Dynamic offsets are great additions to it. In every script you must type first the dynamic offset you are going to use.

For safe scripting it will be best if you use an offset greater than 0x800000 it has a lot Free Space on it. XSE will automatically find free-space in a matter of less than a second.

For pointers you have to put the Character "@" Then your pointer name. The name could be anything just make sure it doesn't include spaces. So here's an example pointer, "@pointer".

@Pokemon - Proper Pointer
@Pokemon Hacking - Improper

Pointer are things that label your script they will be useful when using goto and call commands which will be explained later in the Tutorial.

And don't worry if you have made a typo or something XSE will automatically check errors in your script when you compile them. There will be a warning box that says the specific code line location.

Now for the real deal.

Message Scripts

I'll put an example at first and explain it later.

#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @hi 0x6
release
end

#org @hi
= Hello everyone!/nHappy Hacking.

Ok, time to explain.

#dynamic 0x800000 - Finds Free-Space around offset 0x800000. Always type this before anything.
#org @start - Starts the script. Remember the pointer can be anything just don't use spaces.
lock - Locks the player.
faceplayer - Makes the NPC face the player.
msgbox @hi 0x6 - Loads a normal text box. I will explain how they are used later.
#org @hi - Loads the text to be displayed in the text box.
release - releases the player.
end - ends the script.

The textbox message will be like this.
Hello everyone!
Happy Hacking.

Extra Message Commands:
\c - refers to the color.
\h - used with hex values.
\l - makes a new line after /n.
\p - use to continue the script to a new box.
\n - makes a new line.
\v - used for stored text.

\c is used for colors. Here's an example script.

#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @hi 0x6
release
end

#org @hi
= \c\h01\h04Hello!

The textbox will appear like this.

Color Commands: Firered and Leafgreen Only.
Spoiler:


But, those are made easier by the use of XSE. Here are much easier commands for colors.

Color Commands:

Fire Red/Leaf Green
Spoiler:


Ruby/Sapphire
Spoiler:


Emerald
Spoiler:


Now for \h.

It's used for symbols that the game cannot display and some alternative method to make a text appear. This things are in hex.

So \h1B displays é

Here are the the Hex Codes.

Spoiler:


\n is used for a new line.

So if your text is like this, Happy Birthday!\nFriend!

It will appear like this.
Happy Birthday!
Friend!

\l is used for a new line too. But, it can only be used after \n is used.

So if your text is like this, Happy Birthday!\nTo You!\lFriend!

It will appear like this.
Happy Birthday!
To You!
Friend!

\p is used for a new textbox.

So if it's like this, Pokemon is...\pthe best!

Pokemon is...
the best!

And finally \v It's used for text that are already stored in the Rom.

Here are some codes using \v.

\v\h01 - Player Name
\v\h06 - Rival Name

Or it could be like this too in XSE.

[player] - Player Name
[rival] - Rival Name

And that's it for extra message commands.

Message Box Numbers

0x2

- Like a normal textbox but, already includes the lock, faceplayer and release commands.

#dynamic 0x800000

#org @start
msgbox @hi 0x2
end

#org @hi
= I'm looking at you.

In-Game Screenshot:
1-1.png


0x3

- Used for signpost scripts. It doesn't Include the Lock and Faceplayer command. It only shows the sign textbox when used in a sign.

#dynamic 0x800000

#org @start
msgbox @earth 0x3
end

#org @earth
= You are here on Earth.

In-Game Screenshot:
2.png


0x4

- A normal text box as well. The thing is it doesn't close until the closeonkeypress command is used. It's used right after the msgbox command.

#dynamic 0x800000

#org @start
msgbox @cantclose 0x4
end

#org @cantclose
= I'm stuck for being fat.

In-Game Screenshots:
3.png


4.png


0x5

- Used for yes/no questions. It will automatically show the multichoice box for the yes/no question. This would be useful in hacks that requires the player's decision. More things, and commands for this would be explained later.

#dynamic 0x800000

#org @start
msgbox @question 0x5
end

#org @question
= Are you human?

In-Game Screenshot:
5-1.png


0x6

- Just another normal textbox. No lock and faceplayer command on it.

#dynamic 0x800000

#org @start
msgbox @hello 0x6
end

#org @hello
= Hello, \v\h01!

In-Game Screenshot:
6.png


Flags

- Flags are like bookmarks they can be placed, they can be checked, and can be removed. They are also used to a person event and be placed in the person ID and be set so it will disappear without even using the hidesprite command. The hidesprite command will be explained later in the Tutorial.

There are also many flags that are being used in the game. Luckily in Fire Red Jpan made a patch that makes it clean. So that mean there will be no flags that are already set.

Here are some flags that are already being used in the game. Note: Please refrain from using these flags they can make your hack buggy.

Fire Red/ Leaf Green:
Spoiler:


Ruby/Sapphire:
Spoiler:


Emerald:
Spoiler:


So here's a script I'll explain it later on.

#dynamic 0x800000

#org @start
lock
faceplayer
checkflag 0x500
if 0x1 goto @dont
msgbox @i 0x6
setflag 0x500
release
end

#org @dont
msgbox @said 0x6
end

#org @i
= I don't want to talk to you\nanymore.

#org @said
= I said I don't want to!

checkflag 0x500 - Checks if flag 0x500 is already been set. If it isn't it continues the script.
if 0x1 goto @dont - Checks if true, and if true it goes to pointer @dont. If you put 0x0 it checks if it is false, then goes to pointer @don't
setflag 0x500 - Set's the flag 0x500.

Remember:
0x1 - True
0x0 - False

And now to explain clearflag scripts. I will still be using flag 0x500.

#dynamic 0x800000

#org @start
lock
checkflag 0x500
if 0x0 goto @apologize
msgbox @phone 0x6
clearflag 0x500
release
end

#org @apologize
msgbox @sorry 0x6
release
end

#org @phone
= Friend: What? You have some\nproblems with your other Friend?\pHere's my phone so you can\napologize to your other friend.

#org @sorry
= Friend: Hello Friend! :)

clearflag 0x500 - Clears flag 0x500, or removes the flag.
checkflag 0x500 - Checks if flag 0x500 has already been set.
if 0x0 goto @apologize - Checks if false and goes to pointer @apologize

Note: You can use the text adjuster when typing text so it will be properly adjusted. You can go to tools then Text Adjuster. Or simple Ctrl+T. :)

And here's a list of special flags in the games.

Fire Red:
Spoiler:


Ruby/Sapphire:
Spoiler:


Emerald:
Spoiler:


And that's all for Flags.

Yes/No Scripts

- Scripts that uses the msgbox 0x5 command. It let's you pick between two choices.

I'll explain this later. First here's a script.

#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @are 0x5
compare 0x800D 0x1
if 0x1 goto @yes
compare 0x800D 0x0
if 0x0 goto @no
end

#org @yes
msgbox @blurry 0x6
release
end

#org @no
msgbox @alien 0x6
release
end

#org @are
= Are you human?

#org @blurry
= Oh, sorry to judge you lad.\pIt's just that I have poor\neyesight.

#org @alien
= You're an alien!

msgbox @are 0x5 - Makes a textbox with the yes or no function.
compare 0x800D 0x1 - Get's the lastresult and the 0x1 beside it means yes.
if 0x1 goto @yes - Checks if true and if Yes is selected the script continues to pointer @yes.
compare 0x800D 0x1 - Get's the lastresult and the 0x0 beside it means no.
if 0x1 goto @no - Checks if true and if No is selected the script continues to pointer @no.

Note: Lastresult and 0x800D are the same. It's just that Lastresult isn't used in the latest version of XSE. And remember also that;

0x1 - Yes
0x0 - No

And that covers Yes/No scripts.

Giveitem

- This is the command so you can give Items. You can use this too to give Rare Candies and Master Balls for free! xD

Pretty easy to do the command goes like this. giveitem 0x(Item No.) 0x(Quantity) 0x0 (Remember to put 0x0 at the end.) Remember to have them in hex.

Here's an example script. I'm also going to make a flag so the person can only give you once.

#dynamic 0x800000

#org @start
lock
faceplayer
checkflag 0x510
if 0x1 goto @already
msgbox @hi 0x6
giveitem 0x1 0x1 0x0
setlfag 0x510
release
end

#org @already
msgbox @igave 0x6
release
end

#org @hi
= Hello there Trainer.\pHere's a present from me to you.\pSo kindly leave me alone.

#org @igave
= Didn't I already gave you an Item?\pScram!

giveitem 0x1 0x1 0x0 - Gives one Masterball. (Oh yeah!)
It also has the auto receive message and a jingle too.

And here the Item List in Hex.

Item List:
Spoiler:


And that pretty much does it for the GiveItem Command.

GivePokemon

- This is the command that give's you a Pokemon. but In order to access them in the Main Menu you have to set the flag to activate the Pokemon Menu. The flag is 0x828 in FireRed.

The Command goes like this;

givepokemon 0x(Pokemon No.) 0x(Level) 0x(Held Item) 0x0 0x0 0x0. Remember to put those 3 0x0 i the end.

Here's an example script. I will also explain how to give proper nicknames . Of course I'll have the Pokemon Menu enabled.

#dynamic 0x800000

#org @start
lock
faceplayer
checkflag 0x828
if 0x1 goto @how
msgbox @give 0x5
compare 0x800D 0x1
if 0x1 goto @get
compare 0x800D 0x0
if 0x1 goto @ok
end

#org @get
givepokemon 0x19 0x5 0x44 0x0 0x0 0x0
fanfare 0x13E
msgbox @receive 0x4
waitfanfare
closeonkeypress
setflag 0x828
msgbox @givenickname 0x5
compare 0x800D 0x1
if 0x1 goto @name
compare 0x800D 0x0
if 0x1 goto @go
end

#org @ok
msgbox @oh 0x6
release
end

#org @name
setvar 0x8004 0x0
call @nickname
goto @takecare

#org @nickname
fadescreen 0x1
special 0x9E
waitstate
return

#org @go
closeonkeypress
goto @takecare

#org @takecare
msgbox @please 0x6
release
end

#org @how
msgbox @check 0x6
release
end

#org @give
= Hello there.\pBy any chance would you want to\nhave this Pikachu?

#org @oh
= Oh, I see...

#org @receive
= [black_fr]\v\h01 received a Pikachu from the\nOld Man.

#org @givenickname
= [black_fr]Would you like to give your\nPokémon a nickname?

#org @please
= Please take care of my dear\nPikachu.

#org @check
= How's my old Pokémon?

Now with this you will get a level 5 Pikachu holding a Rare Candy. ^_^ And you will get to nickname it.

In-Game Screenshot:
7.png


8.png


9.png


You can also just call offset 0x1A74EB. But, in case your using Jpan's engine you should do it like this.

checkflag 0x828 - Checks if the flag for the Pokemon Menu is set. I used this flag because this is the player's first Pokemon.
if 0x1 goto @how - If true goes to pointer @how.
givepokemon 0x19 0x5 0x44 0x0 0x0 0x0 - Give's a level 5 Pikachu holding a Rare Candy.
fanfare 0x13E - Plays the fanfare when receiving a Pokemon. (The Fanfare list is also found in Advance Map) I'll give the fanfare list later in the tutorial
waitfanfare - Is a command that ways for the fanfare to be finish so the script will continue.
setflag 0x828 - Set's the flag for the Pokemon Menu.
call @nickname - Call is a command to call scripts which in this case is pointer @nickname
goto @takecare - Same as call it goes to the script which is pointer @takecare
fadescreen 0x1 - An effect to make the screen black. More about this will be explained later.
special 0x9E - Is a command that is needed for the nickname event to be done. More things about specials will be explained later.
waitstate - Wait's for the special to be finished. This is put always after a special command.
return - Is a command to return to the list script it was called upon in this case. The one that called it is pointer @name and continues to the rest of the script.

And of course the Pokemon List.

Pokemon List:
Spoiler:

Note: This is for Fire Red mainly all the scripts here are for Fire Red.

And that's it for Givepokemon.

Fanfare, Sound, and Playsong.

- Are things sounds and fanfares that can be called upon in a script. Pretty useful in events it would be much better.

Here how the commands go;

fanfare 0x(Fanfare no.) - Plays a fanfare.

waitfanfare - Wait's for the fanfare to finish.

sound 0x(sound no.) - Plays a sound.

playsong 0x(song no.) 0x0 - Uses the same list with Fanfare.

This 4 commands below are used with the playsong command to make the song stop.

fadedefault - used for the current music to the maps default music.

fadesong - Gently fades to another song.

fadeout - Fades out the currently playing song.

fadein - Fades the currently playing song back in.

Here are the list of the musics... :)

For Fanfares and Songs: (For Fire Red Only.)
Spoiler:

Sound List:
Spoiler:


And that pretty much explains for fanfares, sounds, and songs. :)

Specials

- This are used for special events that can help a lot when making hacks.

Here are the Special Lists.

Specials:
Spoiler:


So with this I'm gonna make a healing script.

#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @rest 0x4
closeonkeypress
fadescreen 0x1
fanfare 0x100
special 0x0
waitfanfare
fadescreen 0x0
msgbox @there 0x6
release
end

#org @rest
= Oh, \v\h01 you seem tired.\pYou should take some rest.

#org @there
= There you and your Pokémon look\ngreat.

fanfare 0x100 - Is the healing jingle.
special 0x0 - The special command to heal Pokemon.

And if you want your Earthquake special to work perfectly. Input this before special 0x136.
setvar 0x8004 0xF
setvar 0x8005 0xF
setvar 0x8006 0xF
setvar 0x8007 0xF

And that's it for Specials.

RemoveItem

- A command to used to remove Items in the bag. This command will be great for delivery quests.

Here's how the command works;

removeitem 0x(Item no.) 0x(Quantity)

And here's a script that takes your 5 Pokeballs from your bag.

#dynamic 0x800000

#org @start
lock
faceplayer
checkflag 0x545
if 0x1 goto @haha
msgbox @hello 0x6
removeitem 0x4 0x5
msgbox @alakazam 0x6
setlflag 0x545
release
end

#org @haha
msgbox @cant 0x6
release
end

#org @hello
= Hello there Trainer!\pI am a Magician and will make your\n5 Pokeballs in your bag disappear.\p\v\h01: O...k...?\pOk, get ready!\pAbra!\pKadabra!\pAlakazam!

#org @alakazam
= See they're gone now!\pIt's magic.

#org @cant
= What?!\pYou want your Poke Balls back?\pThey're gone so SCRAM!

removeitem 0x4 0x5 - This will remove 5 poke Balls from your bag.

And that pretty much explains things about the Removeitem Command.

CheckItem

- This command checks for a certain Item in your bag before the script continues. It's good for checkpoints and some other things for your Rom Hacks.

Here's how the command goes;

checkitem 0x(Item No.) 0x(Quantity)

Now this script is kinda tricky cause I will check if the Item is greater than 1.

#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @doyou 0x5
compare 0x800D 0x1
if 0x1 goto @check
compare 0x800D 0x0
if 0x0 goto @understand
end

#org @check
checkitem 0xD 0x1
compare 0x800D 0x1
if 0x4 goto @wow
msgbox @liar 0x6
release
end

#org @understand
msgbox @ok 0x6
release
end

#org @wow
msgbox @use 0x6
release
end

#org @doyou
= Hello there do you have a Potion\nwith you?

#org @liar
= Your a liar.

#org @ok
= Oh, ok...

#org @use
= Wow, you can use that to heal\nPokémon.

checkitem 0xD 0x1 - Checks if you have one potion with you.
if 0x4 goto @wow - Checks if you have one or more Potions, if true goes to pointer @wow.

You might ask how did you know that? If you need values to be checked this things can be useful. I made a table for them.

Lower Than (0x0)
Equals (0x1)
Greater Than (0x2)
Lower than or Equal to (0x3)
Greater than or Equal to (0x4)
Not exactly equal to (0x5)

Pretty useful huh? Use it in Checkitem or some other value relating scripts.

And that's it for CheckItem.

WildBattle

- Ever wanted to have your own WildBattle script? Then you can use this command. You can use this to make Legendaries appear and capture em! xD

Here's how the command works;

wildbattle 0x(Pokemon no.) 0x(Level) 0x(Held Item)

And for an add on you can use these commands as well to make it realistic.

cry 0x(Pokemon No.) 0x0 - This will play a cry of a certain Pokemon.

waitcry - This command is set after the cry command. It waits for the cry to finish.

And Fadescreen's can be great after the battle here are fadescreens in a table.
0x0 - Black To Normal
0x1 – Normal To Black
0x2 – White To Normal
0x3 – Normal To White

Anyway, here's an example script.
#dynamic 0x800000

#org @start
lock
faceplayer
cry 0x19 0x0
msgbox @roar 0x6
waitcry
wildbattle 0x19 0x5 0xCA
fadescreen 0x0
hidesprite 0x800F
fadescreen 0x1
setflag 0x300
release
end

#org @roar
= PIKACHU: PIKA!

cry 0x19 0x0 - Plays Pikachu's Cry.
waitcry - Waits for the cry to finish.
wildbattle 0x19 0x5 0xCA - Makes a Wild battle with a Level 5 Pikachu holding a Light Ball.
hidesprite 0x800F - Makes the sprite of the last person talked to disappear. More about Hidesprite will be xplained later.

300 must be input in the person ID in A-map so that Pikachu's Sprite will be gone forever.

Reminder: If you are using Jpan's Engine you can put special 0x25 to make the Pokemon shiny.

And that's all for WildBattle.

Checkgender

- This command checks you gender in the game. Pretty useful in genderbending sotrylines... xD

Just a simple checkgender command followed by the decision part of the script. Here's an example script for everyone to understand better.

#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @hmm 0x4
checkgender
compare 0x800D 0x1
if 0x1 goto @female
compare 0x800D 0x0
if 0x1 goto @male
end

#org @female
closeonkeypress
msgbox @yourf 0x6
release
end

#org @male
closeonkeypress
msgbox @yourm 0x6
release
end

#org @hmm
= Hmm...

#org @yourf
= Your a Female!

#org @yourm
= Your a Male!

checkgender - The command that checks your gender in the game.
compare 0x800D 0x1 - Checks if the player is female.
if 0x1 goto @female - If female, goes to pointer @female.
compare 0x800D 0x0 - Checks if the player is male.
if 0x1 goto @male - If male, goes to pointer @male.

And that covers things about Checkgender.

Applymovement

- Ever wanted to make someone move? :) Then you can, with the Applymovement command. This makes a specific sprite move in the game with a script.

Here's how the command works;

applymovement 0x(person event no.) @pointer <- This is the pointer for the Raw commands so moving will be possible. And if you don't know what Person event no. is. Here is where you can see it.
10.png


If you want your player to move use 0xFF as your person event no. And if you the camera/screen to move use 0x7F as your person event no.

And here's another command after the applymovement.

waitmovement 0x0 - Practically just waits for the movement to be finished and keep it on 0x0. :)

And if you want a follow me script or a script that can make people move at the same time. Your script must be set like this.

applymovement 0x(Person Event no.) @pointer
applymovement 0x(Person Event no.) @pointer
waitmovement 0x0

Just make it like that. :)

And to make commands for movements you will need this.

Fire Red/ Leaf Green:
Spoiler:


Ruby/Sapphire/Emerald:
Spoiler:


Ok, let's do it in a script. :) I'm gonna have the player move at the same time with another person.
#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @hello 0x6
applymovement 0xff @move
applymovement 0x1 @move
waitmvoement 0x0
msgbox @yay 0x6
release
end

#org @hello
= Hey, there!\pLet's walk three steps up!

#org @move
#raw 0x11
#raw 0x11
#raw 0x11
#raw 0xfe

#org @yay
= Yay!\pWe look so romantic.

applymovement 0xff @move - Makes the player move with the raw's at pointer @move.
applymovement 0x1 @move - Makes the sprite with Person Event #1 move with the raw's at pointer @move.
waitmovement 0x0 - Waits for the movement to be finished.
#raw 0x11
#raw 0x11 - Step Up (Normal)
#raw 0x11
#raw 0xfe - End of movements. (Remember to put this at the end of movement raws.)

Some things to remember:

Person Event # FF - is the players person event no.
Person Event # 7F - is the camera/screen's person event no.
#raw 0xfe - Ends movements must be put at the end of movement raws.
waitmovement 0x0 - Always put after the applymovement command.
Remember to have the person event no. in hex. You can convert decimal to hex by using XSE as well.

And that's all for Applymovement's.

Hidesprite and Showsprite

- This two commands can be used for major/minor events. Hidesprite is used to make a person event no. to vanish/disappear. And Showsprite makes them appear again. However to make a person vanish permanently you have to use a flag and input it on the person ID no.

Here's how the commands work;

Hidesprite 0x(Person Event no.)

Showsprite 0x(Person Event no.)


Here's a script to make it easier to understand.
#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @hey 0x6
fadescreen 0x1
hidesprite 0x1
fadescreen 0x0
sound 0x15
applymovement 0xff @pop
waitmovement 0x0
msgbox @haha 0x6
fadescreen 0x1
showsprite 0x1
fadescreen 0x0
sound 0x15
applymovement 0xff @pop
waitmovement 0x0
msgbox @now 0x6
fadescreen 0x1
hidesprite 0x1
setflag 0x750
fadescreen 0x0
msgbox @ok 0x6
release
end

#org @hey
= Hey, hey!\pI just discovered a new trick\nlook, look!

#org @pop
#raw 0x62
#raw 0xfe

#org @haha
= Haha, you can't see me.\pBut, I can see you!\pOk, I'll go back to normal.

#org @now
= Haha, unbelievable right?\pLet me do it again.\pDissapear!

#org @ok
= Ok, time to go back now.\pHuh?\pI can't go back to normal!\pHELP!

hidesprite 0x1 - Makes person event no.1 disappear
showsprite 0x1 - Makes person event no. 1 appear again.

I used a flag to make him disappear completely hehe...

Remember:
If you want to make a person disappear completely use a flag and input it in the person ID in Advance-Map.

And please do not use #raw 0x60 so you can make sprites disappear it will appear again after you move again.

And that's all for Hidesprite and Showsprite commands.

SetVars

- This is quite complicated in scripting. This are used for script boxes and level scripts. More about Level scripts will be explained later in the Tutorial. SetVars are somewhat like flags but the difference is that scripts that need setvars doesn't work without them. They will either freeze or crash. They are also used in the script so that the script will not happen again.

This is how they work.

setvar 0x(variable) 0x(value)

You have to set them up in A-map. The variable in the Var Number and the value in the unknown.

So here's an example variable.

setvar 0x5000 0x1

It should be like this in A-map.

11.png


You have to -1 in the value so 1-1=0 so I recommend everyone to just use 1 as your value in script boxes and level scripts so it will just be 0. :)

There will be further things about setvars later on the tutorial.

For now this will be the things that Setvar covers. :)

Trainerbattles

- This is a command that makes you battle a trainer. Since Trainerbattles covers a wide area I'll explain this one by one. You can edit the trainers using A-Trainer the best Trainer Editor out there.

Ok first let's start with trainerbattle 0x0.

Trainerbattle 0x0
This is just a normal trainer battle command. Used by Normal trainer in the game.

This is how the command works in trainerbattle 0x0;

trainerbattle 0x0 0x(Trainer ID) 0x0 @see @win <- You need these two pointer for the messages that the trainer will say when you see the trainer before the battle and when you win the battle.

And make a msgbox @pointer 0x6 after it. It will be the message that it will say after losing the battle.

Here's an example script.
#dynamic 0x800000

#org @start
trainerbattle 0x0 0x1 0x0 @see @win
msgbox @after 0x6
end

#org @see
= Haha, our eyes meet!\pWe must battle!

#org @win
= Your strong!

#org @after
= I should train my Pokémon more.

It should already been explained so I'll go to the next one.

Trainerbattle 0x1

Trainerbattle 0x1 is used by Gym Leaders in the game.

This is how trainerbattle 0x1 works in the game.

trainerbattle 0x1 0x(Trainer ID) 0x0 @see @win @later <- Later is the pointer to the script that it will do after the battle like giving a badge an Item or talking about something. And you can just use a flag so you can point it to a script after defeating the trainer.

Here's an example script.
#dynamic 0x800000

#org @start
lock
faceplayer
checkflag 0x828
if 0x1 goto @finish
msgbox @hello 0x6
trainerbattle 0x1 0x1 0x0 @see @win @later
end

#org @finish
msgbox @good 0x6
release
end

#org @later
msgbox @congrats 0x6
fanfare 0x13E
msgbox @receive 0x4
waitfanfare
closeonkeypress
setlfag 0x820
msgbox @take 0x6
giveitem 0x121 0x1
release
end

#org @hello
= Hello there Trainer.\pWelcome to my Gym!\pSo you want a battle?\pOf course you want!

#org @see
= Let's do this!

#org @win
= I accept my defeat.

#org @good
= You must travel to the next Gym.\pThere you will meet another Gym\nLeader who's stronger than me.

#org @congrats
= Congratulations!\pYou have successfully defeated me!\pHere have this badge!

#org @receive
= \v\h01 received a Gym Badge!

#org @take
= Here take this as well.

Reminder: flag 0x820 is the flag for the Boulderbadge in Fire Red and Leaf Green.

And that explains things about trainerbattle 0x1.

Trainerbattle 0x3

- This command is like the others but unlike 0x1 it automatically continues through the script. Use for long event battles.

Here's how the command works;

trainerbattle 0x3 0x(Trainer ID) 0x0 @win <- It's only the win text because it will continue through the script.

Here's an example script.
#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @what 0x6
trainerbattle 0x3 0x1 0x0 @win
msgbox @after 0x6
fadescreen 0x1
hidesprite 0x1
fadescreen 0x0
setflag 0x642
release
end

#org @what
= What do you want KID?!

#org @win
= Hmph!

#org @after
= Your one annoying KID.\pYou know that?\pDon't talk to me again.

You can see that it continues through the script.

And that's all for Trainerbattle 0x3.

Trainerbattle 0x4

- Now this command is used for Double Battles you can edit the Double Battle setting in A-trainer.

Here's how the command works;

trainerbattle 0x4 0x(Trainer ID) 0x0 @see @win @2Pokemon <- This is a text that will be said if you don't have 2 Pokemon with you. It automatically uses the countpokemon command to check if you have two or more Pokemon with you. I will explain things about countpokemon later on.

Here's an example script.
#dynamic 0x800000

#org @start
trainerbattle 0x4 0x1 0x0 @see @win @2Pokemon
msgbox @after 0x6
end

#org @see
= James: We can do this Jessie!

#org @win
= James: Oh, no Jessie are you ok?

#org @2Pokemon
= James: You don't have 2 Pokémon\nwith you.\pDo you want us to defeat you\neasily?

That's pretty much it for trainerbattle 0x4.

Trainerbattle 0x5

- is used for single rematch battles. Used outdoors so this will be the battle when you use the VS SEEKER.

Here's how the command works;

The script for this command has two trainerbattles the other one is 0x0 And after that command you have to put this.
special2 0x800D 0x39
compare 0x800D 0x1
if 0x1 goto @(pointer for the script which has trainerbattle 0x5.)

trainerbattle 0x5 0x(Trainer ID) 0x0 @saw @win <- I put saw because I wanted a new message when rematching the trainer. But, the win message is still the same.

Here's an example script to put more understanding to it.

#dynamic 0x800000

#org @start
trainerbattle 0x0 0x1 0x0 @see @win
special2 0x800D 0x39
compare 0x800D 0x1
if 0x1 goto @rematch
msgbox @after
end

#org @remeatch
trainerbattle 0x5 0x1 0x0 @saw @win
msgbox @after 0x6
end

#org @see
= Hello there!\pLet's Battle our Pokémon!

#org @win
= Your good!

#org @after
= Some Pokémon evolve by using Items\nand some through Trades.

#org @saw
= I won't back down from a\nchallenge!

Here you can see how the command was used. special2 will be explained later on. So if you have defeated the Trainer and used your VS SEEKER after that then you will have a rematch with the trainer which is the sole purpose of trainerbattle 0x5.

And that's all for Trainerbattle 0x5.

Trainerbattle 0x7

- Just like 0x5 this is used for rematches. But, this time it's for 0x4 or for a Double Battle.

Here's how the command work;

Same as 0x5 you need this after the trainerbattle for 0x4.

special2 0x800D 0x39
compare 0x800D 0x1
if 0x1 goto @(pointer to rematch script.)

trainerbattle 0x7 0x(Trainer ID) 0x0 @saw @win @2Pokemon

Here's an example script.
#dynamic 0x800000

#org @start
trainerbattle 0x4 0x1 0x0 @see @win @2Pokemon
special2 0x800D 0x39
compare 0x800D 0x1
if 0x1 goto @rematch
msgbox @after 0x6
end

#org @rematch
trainerbattle 0x7 0x1 0x0 @saw @win @2Pokemon
msgbox @after 0x6
end

#org @see
= Spongebob: Can you defeat me and\nPatrick?

#org @win
= Spongebob: What? We lost?

#org @2Pokemon
= Spongebob: There will be no fun if\nyou don't have enough Pokémon to\lbattle.

#org @after
= Spongebob: We'll win next time\nright Patrick?\pPatrick: ...

#org @saw
= Spongebob: It's payback time.

And that's it for Trainerbattle 0x7.

Trainerbattle 0x9

The same as 0x3 but it has a text when you lose.

Here's how the command works;

trainerbattle 0x9 0x(Trainer ID) 0x0 @win @lose <- This is the pointer for the text when you lose the battle.

Here's an example script for everyone.
#dynamic 0x800000

#org @start
lock
faceplayer
checkflag 0x310
if 0x1 goto @done
msgbox @hi 0x6
trainerbattle 0x9 0x1 0x0 @win @lose
msgbox @after 0x6
setflag 0x310
release
end

#org @done
msgbox @after 0x6
release
end

#org @hi
= Hi there, care for a battle?

#org @win
= Your stronger than me.

#org @lose
= It seems that I'm much stronger\nthan you.

#org @after
= You have what it takes to become\nthe next CHAMPION.

Well that explains things for Trainerbattle 0x9.

And that's all for Trainerbattle commands.

CountPokemon

- This command is used for counting the amount of Pokemon in your party and goes through a decision in the script for a certain use.

Here's how the command works;

Countpokemon <- Just that and use the decision script.

Ex.
Checks 1 Pokemon.
countpokemon
compare 0x800D 0x1
if 0x1 goto @resume

Checks for 2 Pokemon
countpokemon
compare 0x800D 0x2
if 0x1 goto @resume

Checks for 3 Pokemon
countpokemon
compare 0x800D 0x3
if 0x1 goto @resume

Checks for 4 Pokemon
countpokemon
compare 0x800D 0x4
if 0x1 goto @resume

Checks for 5 Pokemon
countpokemon
compare 0x800D 0x5
if 0x1 goto @resume

Checks for 6 Pokemon
countpokemon
compare 0x800D 0x6
if 0x1 goto @resume

Remember this table is helpful for decision scripts.
Lower Than (0x0)
Equals (0x1)
Greater Than (0x2)
Lower than or Equal to (0x3)
Greater than or Equal to (0x4)
Not exactly equal to (0x5)

And here's an example script.
#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @can't 0x4
countpokemon
compare 0x800D 0x2
if 0x4 goto @proceed
closeonkeypress
msgbox @sorry 0x6
release
end

#org @proceed
closeonkeypress
msgbox @oh 0x6
fadescreen 0x1
hidesprite 0x1
fadescren 0x0
setflag 0x555
release
end

#org @can't
= Guard: You can't proceed further\nif you don't have at least 2\lPokémon with you.\pHmm...

#org @sorry
= Guard: Sorry you don't have 2\nPokémon with you.\pI suggest capturing more so you\ncan enter.

#org @oh
= Guard: Oh, you have 2 Pokémon with\nyou.\pYou may proceed.

countpokemon - Counts your current Pokemon in your party.
compare 0x800D 0x2 - Checks for 2 Pokemon.
if 0x4 goto @proceed - Checks if the result is greater than or equal to 2. If true goes to pointer @proceed.

And that's all for CountPokemon.

Giveegg

- This is a command like the Givepokemon command the only difference is it gives an egg of a specific Pokemon.

Here's how the command works;

giveegg 0x(Pokemon no.)

Pretty easy right?

Here's a script to put more understanding to it.
#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @would 0x5
compare 0x800D 0x1
if 0x1 goto @give
compare 0x800D 0x0
if 0x1 goto @ok
end

#org @give
countpokemon
compare 0x800D 0x6
if 0x1 goto @deposit
msgbox @here 0x6
giveegg 0x196
fanfare 0x13E
msgbox @receive 0x6
waitfanfare
msgbox @legendary 0x6
fadescreen 0x1
hidesprite 0x1
fadescreen 0x0
setflag 0x200
release
end

#org @ok
msgbox @oh 0x6
release
end

#org @deposit
msgbox @seems 0x6
release
end

#org @would
= Hello there young Trainer!\pWould you care to have this egg?

#org @here
= Here.\pPlease take care of it it's a very\nspecial egg.

#org @receive
= [black_fr]\v\h01 received an EGG!

#org @legendary
= That egg belongs to a Legendary\nPokémon.\pThat only lays an egg every 10,000\nyears.\pPlease take good care of it. I'll\nbe going now.

#org @oh
= Oh, ok I understand.

#org @seems
= It seems you don't have anymore\nspace in your party you better\ldeposit a Pokémon in a nearby\lPokémon Center.

giveegg 0x196 - Gives you an egg of a Rayquaza! ^_^

That's all for giveegg.

Weather Commands

- If you can manipulate the weather you can make an epic hack. xD

Here's how the command works;

setweather 0x(Weather no.)
- Set's the weather to be called upon.

doweather
- Does the weather that you have set. Must be used after the weather has been set.

Here's the weather list.

Weather List:
Spoiler:

You can view them in A-map as well.

Here's an example script.
#dynamic 0x800000

#org @start
lock
msgbox @i'm 0x6
setweather 0x3
doweather
msgbox @great
release
end

#org @i'm
= I'm on a lucky streak today.\pWhat could possibly go wrong?

#org @great
= GREAT!\pJust my luck.

setweather 0x3 - Set's a rainy weather.
doweather - Does the weather.

And that's all for Weather Commands.

Pokemart


- Do you want to have your own items in A-map or maybe put the Masterball and Rare Candy there? xD Well you can do that with the Pokemart command.

The command goes like this;

pokemart @(pointer to the raw's)

The raw's work like this, #raw 0x(Item no.) Pretty easy right? And remember to put #raw 0x0 at the end. Just like in applymovement you have to put #raw 0xfe at the end of the movements. But, in pokemart you'll use #raw 0x0.

Here's an example script for that.
#dynamic 0x800000

#org @start
lock
faceplayer
preparemsg @hi
waitmsg
pokemart @mart
msgbox @come 0x6
release
end

#org @hi
= Hi there, Trainer!\pMay I help you?

#org @come
= Please come again.

#org @mart
#raw 0xD
#raw 0xE
#raw 0xF
#raw 0x10
#raw 0x11
#raw 0x12
#raw 0x0

It will let me choose from Potion, Antidote, Burn Heal, Ice Heal, Awakening, Paralyz heal.

The preparemsg command will be explained later.

And that's all for Pokemart.

Lockall and Releaseall

- same as the normal lock and release functions. But, this lock's all, and releases all.

Just put, lockall and releaseall. That's all in to it pretty much easy.

Preparemsg and Waitmsg


Same as the normal text box the only difference is it doesn't have a variable next to it. Just the pointer. And waitmsg is just like closeonkeypress the command is to close the message.

Here's how the command works;

preparemsg @(pointer to your message)


Pretty much easy if you already read through the tutorial so I'll leave it that way so that's all for Preparemsg and Waitmsg.

Warps

- warps are used in doors. They are pretty much useful for travelling scripts. :) Warps have many kinds but, I'll explain them all one by one.

This is how warps work;

warp 0x(map bank) 0x(map no.) 0x(warp no.) 0x0 0x0

Pretty easy right?

Now for warp to position.

Warp To Position

- Just like the normal warp command but the last 3 values are changed. The warp number is changed into 0xFF it let's the script know that we're warping the player to a certain position.

warp 0x(map bank) 0x(map no.) 0xFF 0x(X Coordinate) 0x(Y Coordinate)

The coordinates can be viewed in A-map.

That's it for warp to position.

Warpmuted

- Just like the normal warp instead it doesn't include the warp sound.

Here's how the command works;

warpmuted 0x(map bank) 0x(map no.) 0x(warp no.) 0x0 0x0

And that's for Warpmuted.

Warpwalk

- Also like the normal warp but, it includes the walking effect or sound.

Here's how the command works;

warpwalk 0x(map bank) 0x(map no.) 0x(warp no.) 0x0 0x0

That's it for warpwalk.

Warphole

Same as the others but only uses two values. Has the hole effect.

Here's how the command work;

warphole 0x(map bank) 0x(map no.)

That's it for warphole now on to the next one.

Warpteleport

- Just like the other warps but has the teleport effect.

Here's how the command works;

warpteleport 0x(map bank) 0x(map no.) 0x(warp no.) 0x0 0x0

That's it for warps!

Showpokepic and Hidepokepic

- used to make sprites appear in a box. Can only be used to make Pokemon Sprites appear.

The command goes like this;

showpokepic 0x(Pokemon no.) 0x(X Coordinate) 0x(Y Coordinate)

Remember that (10/A, 3) is the center of the screen. 10/A is X and 3 is Y.

and hidepokepic is just simply used to hide the Pokepic. :P

Here's an example script.
#dynamic 0x800000

#org @start
lock
faceplayer
showpokepic 0xFA 0xA 0x3
msgbox @have 0x5
compare 0x800D 0x1
if 0x1 goto @yes
compare 0x800D 0x0
if 0x1 goto @no
end

#org @yes
hidepokepic
msgbox @lucky 0x6
release
end

#org @no
hidepokepic
msgbox @oh 0x6
release
end

#org @have
= Have you seen this magnificent\nPokémon before?

#org @lucky
= Wow, your lucky.

#org @oh
= Oh, me too...

This just shows a pokepic of Ho-oh in the center of the screen.

In-Game Screenshot:
22.png


And that's all for showpokepic and hidepokepic.

MoveSprite

- This command is used to move a sprite instantly.

Here's how the command works;

movesprite 0x(Person Event No.) 0x(X Coordinate) 0x(Y Coordinate)

You can view the X and Y coordinates in A-map. If you read through the Tutorial I think this will not require anymore further explanation.

Reminder: Do not try to move the player or use 0xFF as your person event. The screen will not be properly adjusted and you'll end up getting trapped. (Even with Walk Through Wall Codes and editing their Movement Permission in A-map).

And that's all for Movesprite.

SetMapTile

- This is a command in a script to edit the tiles of the specific tileset you have in the map in-game.

Here's how it works.

setmaptile 0x(X Coordinate) 0x(Y Coordinate) 0x(Tile No.) 0x(Movement Permission.)

You can view the X,Y and Tile No. in A-map.

And if you want to make that block passable put 0x0, If not put 0x1.

0x0 - Passable
0x1 - Blocked

And that's all for SetMaptile.

$Money Commands$

- This is used to update your money, remove, and view it. Used in Pokemarts and such.

Givemoney

- Pretty much like any give scripts it just gives money in hex of course.

Here's how it works for example we want $500 Poke Dollars so it would be 500 and if you convert 500 into hex it will be 1F4 so here's a command to explain it.

givemoney 0x(Amount of Money in hex) 0x0

That's all for Givemoney.

Paymoney

- Same as remove commands just removes a certain amount of money from the player so for example you have received 500 Poke Dollars and you want to take it back then I'll use this.

paymoney 0x1F4 0x0

That's all for Paymoney.

Callasm

- This is a command to call asm routines in the game. Very useful in major events.

This is how the command works;

callasm 0x(offset +1)

You should use so you can call asm routines, you must first insert the routine using a hex editor. But, I won't get any further about that since it will make more complicated explanation's.

That's all for Callasm.

Level Scripts

- You may have already noticed but Script Boxes in front of doors doesn't work when you enter. In that case you don't need a script box but, you need a level script. A level script can be edited in the header in A-map.

First we need a script make sure it ha a setvar in the end of it. :)

#dynamic 0x800000

#org @start
lock
sound 0x15
applymovement 0xff @pop
waitmovement 0x0
msgbox @realize 0x6
setvar 0x4000 0x1
release
end

#org @pop
#raw 0x62
#raw 0xfe

#org @realize
= \v\h01: Woah, I just realised that\nI'm outside the house.

Now do what I say.

Go to A-map and open your map then go to Header you should see there Map Script. It looks like this. Then press add.

12.png


And then click the drop-down menu list in script type and select script type 2.

13.png


There are many types of level script and you must pick the appropriate one for your script.

First of all.

"setmaptile" script [01] - It's mainly used for setmaptile commands and weather commands.

Validates values, loads handler to 0x03000EB0 (playback) [02] - The most often used script type. All things are can be done in this script type, applymovement, trainerbattles, give scripts, flags, wildbattles, etc. But it's better to use this command when you warp into a house or building. You can just use a script box if you didn't warp it will be much easier and will save up some time.

On entering map/not on menu close [03] - This is used for flags, var comparing, and some other things.

Validates values, loads handler to 0x03000F28 [04] - Same as #2 used when you warp into a house or building.

Ok, you should now compile your script. Then put the offset in script offset 2;

14.png


Now remember I made a setvar in the end of the script so I have to put the variable in flag and value in value. And since our value is 1 you have to subtract it by 1 so you don't need to input anything in the value box. Just put 4000 on the flag box.

15.png


After that click save Map scripts and your done. Now to test it out.


It worked, but look... It's somewhat messed up.

16.png


To fix this go to header in A-map again. Then press Ctrl+H then copy the Map Script Offset.

17.png


Now decompile that in XSE. First click the Level Script next to decompile then press decompile.

18.png


Next is find the 0xFFFF in the script.

19.png


Now delete those F's and replace it with a zero.

20.png


Now Compile it then press save in A-map

Test it out.

21.png


Ta Daa! Your very first Level script.

And that covers everything about Level Scripts.

END

The Tutorial may be updated from time to time(mostly when I feel like it), in the meantime enjoy hacking! :)

And that concludes tajaros' Xtreme Scripting Tutorial. If you have any questions you can ask me, or simply post here on the thread.

Downloads:
XSE
A-trainer
Jpan's Firered Hacked Engine
 
Last edited:
3,830
Posts
14
Years
  • Age 26
  • OH
  • Seen Feb 26, 2024
No. Why teach beginners to use pokescript?
It is horribly outdated, and doesn't even have all of the commands!
Plus, it is known to have lots of bugs.

Why continue to use a horse when you have a car?
 

droomph

weeb
4,285
Posts
12
Years
Just for fun what else....
:)
If that's the case, foullump and thethethethe have great Pokéscript tutorials, and diegoisawesome has a great XSE tutorial.

We've already covered these, and if anyone wanted to they could ask in those threads instead.

It's not that I want to say that that tutorial was bad, but...we don't really need it...
 

Renegade

Time for real life...
995
Posts
12
Years
Great tutorial! I will be sure to come to this thread if I need any help in the future.

I didn't see this command in your tutorial and is a working one.

Movesprite

Here it is:

#org $script
lock
faceplayer
message $t1
$t1 1 = Someone on your screen will\nnow be instantly moved.
boxset 6

Then comes the moving part of the script:

movesprite 0x01 0x02 0x04 (The sprite # to move, X Coords, Y Coords)

Then the ending:

release
end

NOTE: This is a bad command to use for 0xFF because it will make the player become off-center with the screen. You won't be able to get back to the middle.

*Sorry if this was already in the tutorial, I didn't see it :P*
 
Last edited:

tajaros

Hi I'm dawg
855
Posts
11
Years
Ok, sorry for the double post but, I have made the tut to be primarily for XSE.

Hope, this tutorial would be helpful.
 
78
Posts
11
Years
  • Seen Mar 16, 2014
This is the wild battle command, as if obvious from it's name(I ripped this from Moltres' code): setwildbattle 0x91 0x32 0x0. Anyway, I was wondering which of those values next to it decides what Pokemon you are battling, if any of them do. I need to know this stuff because I'm currently unsure of how to set up my own legendary battles.
 

tajaros

Hi I'm dawg
855
Posts
11
Years
This is the wild battle command, as if obvious from it's name(I ripped this from Moltres' code): setwildbattle 0x91 0x32 0x0. Anyway, I was wondering which of those values next to it decides what Pokemon you are battling, if any of them do. I need to know this stuff because I'm currently unsure of how to set up my own legendary battles.

Here's the answer for that:

Setwildbattle is just like the normal wildbattle command.

setwildbattle 0x(Pokemon no.) 0x(Level) 0x(Held item)

And you can use the dowildbattle command to trigger the command. You can still use the wildbattle command for Legendaries the only difference is in legendary wild pokemon battle there's this music that's going to be played.

Hope this helps.
 
78
Posts
11
Years
  • Seen Mar 16, 2014
Here's the answer for that:

Setwildbattle is just like the normal wildbattle command.



And you can use the dowildbattle command to trigger the command. You can still use the wildbattle command for Legendaries the only difference is in legendary wild pokemon battle there's this music that's going to be played.

Hope this helps.

But, isn't Moltres' no. way above 91?
 
6
Posts
13
Years
  • Seen Nov 7, 2012
Thanks for this tutorial, just wanna ask if you can give an example of a script for a legendary battle that takes only once if you captured that legendary pokemon, thanks in advance,
 

tajaros

Hi I'm dawg
855
Posts
11
Years
Thanks for this tutorial, just wanna ask if you can give an example of a script for a legendary battle that takes only once if you captured that legendary pokemon, thanks in advance,

What do you mean? Like a Legendary battle and disappears after battle? You can just use my Wildbattle script and set a flag it should work well.

Or you can use the setwildbattle command like how other legendaries are battled. I'll provide an example later on.
 
Back
Top