• 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?".
  • 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.

Advanced Scripting Tutorial

Status
Not open for further replies.
6,355
Posts
18
Years
  • Seen Apr 16, 2020
Yeah, people ask how to learn to script and stuff so here's a tutorial.

Basic scripting commands:

message
#org 0x800000
message 0x800100
boxset 0x6
release
end

#org 0x800100
= Hi.


Put an offset after the message, then at the end of the script put the same offset and the text with the "=" like in the example.
Release closes the textbox.


Put "lock" and "faceplayer" after the "#org" command to make the event face the player.

#org 0x800000
lock
faceplayer
message 0x800100
boxset 0x6
release
end

#org 0x800100
= Hi.


boxset 0x5 Yes/No
boxset 0x6 close after button press


compare
An example with "compare" in a yes/no script.

#org 0x800000
message 0x800100
boxset 0x5
compare LASTRESULT 0x1 Compares if it's yes or no (0x1 = yes; 0x0 = no)
if 0x1 goto 0x800200 It's "if 0x1" so if you chose yes you go to that offset, if you chose "No" the script continues.
message 0x800300
boxset 0x6
release
end

#org 0x800200 In front of the script always put "#org" and an offset. Put that offset on the event you want to have it.
message 0x800400
boxset 0x6
release
end

#org 0x800100
Hello.

#org 0x800300
= You picked "NO".

#org 0x800400
= You picked "YES".

setflag
setflag 0x(flag)
#org 0x800000
checkflag 0x10A
compare LASTRESULT 0x1
if 0x1 goto 0x800100
setflag 0x10A
end

#org 0x800100
end

Flags are set so that events won't be repeated again. The script must first check a flag, if you don't have it the script goes on and the flag is set. When you talk to the event again then the script will go to the offset after the compare (in this script "800100") and do the commands there.
To clear a flag use "clearflag 0x(flag)"


applymovement
applymovement 0x(people's number) 0x(offset)


#org 0x800000
applymovement 0x3 0x800100 The steps the event will take will be the ones in the offset next to the event's index number.
pause 0x30 The "pause" commands is for how long to wait before the script goes on, 0x10 for one step
end

#org 0x800100 The steps the event will make are here. In this script, two steps down, one left.
#raw 0x8
#raw 0x8
#raw 0xA
#raw 0xFE After the steps always put "FE" at the end. If you don't, the event won't move.

You can find movement raws to use here.
To move the player use "applymovement 0xFF" or "APPLYMOVE_PLAYER"

Other scripting commands:

giveitem
giveitem 0x(item) 0x(quantity) Item in hex numbers and quantity in hexadecimal

#org 0x800000
giveitem 0x45 0x1
release Put release after "giveitem" or the textbox won't be removed after you get the item.
end

checkitem
checkitem 0x(item)
Use it like "checkflag".

#org 0x800000
checkitem 0x16
compare LASTRESULT 0x1
if 0x1 goto 0x800100
end

#org 0x800100
= You carry a SUPER POTION.

givepokemon
givepokemon 0x(pkmn) 0x(level) 0x(item)

#org 0x800000
givepokemon 0x78 0x5 0x3 In givepokemon scripts set flags should be used.
end

wildbattle
wildbattle 0x(pkmn) 0x(level) 0x(Battle style)
Legendary battle example:

#org 0x800000
cry PKMN_MEW This plays the pokemon's cry, it can be used in any script but it's mostly used in wildbattles ones.
wildbattle 0x97 0x46 0x3 There are 4 battle styles, put 0, 1, 2, 3
end

setweather
setweather 0x(weather)

0 = Normal
3 = Rain
4 = Snowflakes
5 = Thunderstorm
6 = Fog
7 = Ash
8 = Sandstorm
9 = Fog 2
A = Fog
B = Dark
C = Hot sun
D = Thunderstorm 2
E = Underwater


#org 0x800000
setweather 0xB
doweather Put "doweather" after the "setweather" command to make the weather change that moment.
end

checkgender
Like "checkflag", 0 if the player is male and 1 if it the player is female

#org 0x800000
checkgender
compare LASTRESULT 0x1
if 0x1 goto 0x800100 If the player's male (1) the script goes to offset "800100".
message 0x800200
boxset 0x6
release
end

#org 0x800100
message 0x800300
boxset 0x6
release
end

#org 0x800200
= Hello madam.

#org 0x800300
= Hello sir.

movesprite
movesprite 0x(event's index number) 0x(horizontal location) 0x(vertical location)

#org 0x800000
movesprite 0x4 0xA 0x16
end

special
special 0x(number)

#org 0x800000
special 0x0 "special 0x0" heals the pokemon in the player's party
end

trainerbattle
trainerbattle 0x(Kind) 0x(Trainer) 0x(ptrIntro) 0x(ptrDefeat)

0x(Kind) is 0x00 for normal battles, 0x04 for 2-on-2 and 0x05 for rematches.


#org 0x800000
trainerbattle 0x00 0x1A 0x800100 0x800200 If you put another offset here then after you beat the trainer the script will continue from the offset you put.
end

#org 0x800100
= Bring it on!

#org 0x800200
= I lost...

warp
warp 0x(Bank) 0x(Map) 0x(Warp's number)

#org 0x800000
warp 0x0 0xA 0x3
end
 
Last edited:

Martin Yiu

disappeared... forever
493
Posts
18
Years
  • Seen Feb 8, 2008
Hi Christos, great to see you making this tutorial. Please can you re-upload the movements file, or at least tell me the movement to right? And can you please tell me how to make ! appear above the player?
 
19
Posts
17
Years
  • Seen Sep 5, 2008
compiling

how do ya get it into the game sause im usin script ed, if there are any better can u tell me plz
 

martijn

HeartGold & Collosseum
133
Posts
17
Years
  • Age 35
  • Seen Jun 28, 2016
Handy info, but could you explain how to change the path Oak takes when you attempt to leave Pallet and which script it is for FireRed?
 
6,355
Posts
18
Years
  • Seen Apr 16, 2020
Hi Christos, great to see you making this tutorial. Please can you re-upload the movements file, or at least tell me the movement to right? And can you please tell me how to make ! appear above the player?

Okay, I'll reupload it. The "!" is in the movements file.
Download it and find it.

how do ya get it into the game sause im usin script ed, if there are any better can u tell me plz

Save your script with no spaces in the name in ScriptED's folder, put your ROM in there too with no spaces and open the script with ScriptED, click compile and done.

Handy info, but could you explain how to change the path Oak takes when you attempt to leave Pallet and which script it is for FireRed?

I don't think that script would load with ScriptED so you have to hex edit to edit Oak's movements.

Other scripting commands:

giveitem
giveitem 0x(item) 0x(quantity) Item in hex numbers and quantity in hexadecimal

#org 0x800000
giveitem 0x45 0x1
release Put release after "giveitem" or the textbox won't be removed after you get the item.
end

checkitem
checkitem 0x(item)
Use it like "checkflag".

#org 0x800000
checkitem 0x16
compare LASTRESULT 0x1
if 0x1 goto 0x800100
end

#org 0x800100
= You carry a SUPER POTION.

givepokemon
givepokemon 0x(pkmn) 0x(level) 0x(item)

#org 0x800000
givepokemon 0x78 0x5 0x3 In givepokemon scripts set flags should be used.
end

wildbattle
wildbattle 0x(pkmn) 0x(level) 0x(Battle style)
Legendary battle example:

#org 0x800000
cry PKMN_MEW This plays the pokemon's cry, it can be used in any script but it's mostly used in wildbattles ones.
wildbattle 0x97 0x46 0x3 There are 4 battle styles, put 0, 1, 2, 3
end

setweather
setweather 0x(weather)

0 = Normal
3 = Rain
4 = Snowflakes
5 = Thunderstorm
6 = Fog
7 = Ash
8 = Sandstorm
9 = Fog 2
A = Fog
B = Dark
C = Hot sun
D = Thunderstorm 2
E = Underwater


#org 0x800000
setweather 0xB
doweather Put "doweather" after the "setweather" command to make the weather change that moment.
end

checkgender
Like "checkflag", 0 if the player is male and 1 if it the player is female

#org 0x800000
checkgender
compare LASTRESULT 0x1
if 0x1 goto 0x800100 If the player's male (1) the script goes to offset "800100".
message 0x800200
boxset 0x6
release
end

#org 0x800100
message 0x800300
boxset 0x6
release
end

#org 0x800200
= Hello madam.

#org 0x800300
= Hello sir.

movesprite
movesprite 0x(event's index number) 0x(horizontal location) 0x(vertical location)

#org 0x800000
movesprite 0x4 0xA 0x16
end

special
special 0x(number)

#org 0x800000
special 0x0 "special 0x0" heals the pokemon in the player's party
end

trainerbattle
trainerbattle 0x(Kind) 0x(Trainer) 0x(ptrIntro) 0x(ptrDefeat)

0x(Kind) is 0x00 for normal battles, 0x04 for 2-on-2 and 0x05 for rematches.


#org 0x800000
trainerbattle 0x00 0x1A 0x800100 0x800200 If you put another offset here then after you beat the trainer the script will continue from the offset you put.
end

#org 0x800100
= Bring it on!

#org 0x800200
= I lost...

warp
warp 0x(Bank) 0x(Map) 0x(Warp's number)

#org 0x800000
warp 0x0 0xA 0x3
end
 

Green Charizard

pɹɐzıɹɐɥɔ uǝǝɹƃ
251
Posts
19
Years
Really nice tutorial Christos, I know you've said over making this for a while, it should help ALOT of people.
 

D-Trogh

Dead
439
Posts
18
Years
Nice tutorial Christos ^^
I think I'm gonna start hacking again, because now (I think) I'm able to script..
Just 1 (2) question(s)..
The FF's in your ROM are free space right ? And the 00's too ? OK..
But.. can you tell me how I need to count the offsets for the scripts..
How do you know that 800100 is safe after the 800000 ?
Do you still need to count 100 more ?
 
6,355
Posts
18
Years
  • Seen Apr 16, 2020
Nice tutorial Christos ^^
I think I'm gonna start hacking again, because now (I think) I'm able to script..
Just 1 (2) question(s)..
The FF's in your ROM are free space right ? And the 00's too ? OK..
But.. can you tell me how I need to count the offsets for the scripts..
How do you know that 800100 is safe after the 800000 ?
Do you still need to count 100 more ?

Find your empty offset and when you want an offset for an other command don't put the offset that's right after the one you used before. Try 100 more or something.
 

martijn

HeartGold & Collosseum
133
Posts
17
Years
  • Age 35
  • Seen Jun 28, 2016
@Christos: I found it:
Code:
'-----------------------
#org 0x1655ED
jingle
setvar 0x4001 0x0
goto 0x8165605 
end

'-----------------------
#org 0x165605
setvar 0x8004 0x0
setvar 0x8005 0x2
special 0x174
#raw 0xC7
nop
pause 0x1E
playsound 0x12E
nop
#raw 0x67
#raw 0x2C
#raw 0xD7
#raw 0x17
jumpstd 0x66
pause 0x55
#raw 0x68
applymovement APPLYMOVE_PLAYER 0x81A75ED
pause 0x0
#raw 0x2F
copybyte 0xFF4F00 0xDB
#raw 0x75
copyvarifnotzero 0x5108 0x0
pause 0x1E
#raw 0x55
return


'-----------
' Movements
'-----------
#raw 2D 'Down4
#raw FE 'Exit
I understand part of it but not fully :S
 
150
Posts
17
Years
Three questions.
- When using movesprite, will the selected sprite IMMEDIATELY warp to the desired location?
- When using movesprite, will the selected sprite go back to its original position if you DIDN'T set a flag and reload the map?
- When using trainerbattle, what 0x(Kind) do I have to use to make the rival battle music play in the background, instead of the normal trainer battle music?
 
252
Posts
19
Years
  • Age 59
  • Seen Aug 3, 2019
This is such a comprehensive tutorial. ^^ Kudos to you, Christos.

I have only one question that hasn't been answered yet: How can we change the battle music that plays when we fight wild Pokemon, trainers etc.? Does it change by changing the battle type? And if I want to use the battle themes of R/S in Fire Red, what do I have to do?
 
6,355
Posts
18
Years
  • Seen Apr 16, 2020
@Christos: I found it:
Code:
'-----------------------
#org 0x1655ED
jingle
setvar 0x4001 0x0
goto 0x8165605 
end

'-----------------------
#org 0x165605
setvar 0x8004 0x0
setvar 0x8005 0x2
special 0x174
#raw 0xC7
nop
pause 0x1E
playsound 0x12E
nop
#raw 0x67
#raw 0x2C
#raw 0xD7
#raw 0x17
jumpstd 0x66
pause 0x55
#raw 0x68
applymovement APPLYMOVE_PLAYER 0x81A75ED
pause 0x0
#raw 0x2F
copybyte 0xFF4F00 0xDB
#raw 0x75
copyvarifnotzero 0x5108 0x0
pause 0x1E
#raw 0x55
return


'-----------
' Movements
'-----------
#raw 2D 'Down4
#raw FE 'Exit
I understand part of it but not fully :S

I think you'll have to edit it with hex.

Three questions.
- When using movesprite, will the selected sprite IMMEDIATELY warp to the desired location?
- When using movesprite, will the selected sprite go back to its original position if you DIDN'T set a flag and reload the map?
- When using trainerbattle, what 0x(Kind) do I have to use to make the rival battle music play in the background, instead of the normal trainer battle music?

1. The sprite will warp in some place in the map and stay there.

2. It's not with "0x(Kind)", you can edit the music with PET.

This is such a comprehensive tutorial. ^^ Kudos to you, Christos.

I have only one question that hasn't been answered yet: How can we change the battle music that plays when we fight wild Pokemon, trainers etc.? Does it change by changing the battle type? And if I want to use the battle themes of R/S in Fire Red, what do I have to do?

You can do both with PET.
 
150
Posts
17
Years
I think you'll have to edit it with hex.



1. The sprite will warp in some place in the map and stay there.

2. It's not with "0x(Kind)", you can edit the music with PET.



You can do both with PET.

Oh... to which number do I have to change it, then, cuz it seems like every trainer's got its own music...

And I thought that, for example, if you used the 0x(Kind) for Gym Leader battles, the Gym Leader battle music plays in the background during the battle...
 
6,355
Posts
18
Years
  • Seen Apr 16, 2020
Oh... to which number do I have to change it, then, cuz it seems like every trainer's got its own music...

And I thought that, for example, if you used the 0x(Kind) for Gym Leader battles, the Gym Leader battle music plays in the background during the battle...

Look for the Rival's battle in PET to see the music number.
 

BlackRainbow*

Pokemon Coralo Version ?
519
Posts
17
Years
The applymovement script don't work for me :/
when i go to the script nothing happned
anyway im hacking EMERALD

p.s. sry for my bad enhlish
 
Status
Not open for further replies.
Back
Top