Go Back   The PokéCommunity Forums > ROM Hacking > Tools, Tutorials & Resources
Reload this Page [Tutorial] Advanced Scripting Tutorial

Notices
For all updates, view the main page.

Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.
New threads in this forum are to be approved by a moderator before they are displayed.



Closed Thread
 
Thread Tools
  #1    
Old February 8th, 2007 (12:57 PM). Edited February 9th, 2007 by Christos.
Christos's Avatar
Christos Christos is offline
chase is my favourite
ModeratorBSCS
 
Join Date: Feb 2006
Gender: Male
Nature: Serious
Posts: 4,341
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
__________________
  #2    
Old February 8th, 2007 (11:54 PM).
Martin Yiu Martin Yiu is offline
disappeared... forever
 
Join Date: Jan 2006
Posts: 493
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?
__________________

  #3    
Old February 9th, 2007 (03:17 AM).
BlackRainbow*'s Avatar
BlackRainbow* BlackRainbow* is offline
Pokemon Coralo Version ?
 
Join Date: Oct 2006
Location: Yiushu
Gender:
Nature: Bold
Posts: 518
Great finally there's a advance scropting tutorial
that's awesome Christos
__________________
Pokemon Coralo Version...New Pokemon Petal.
Shyrika Region
  #4    
Old February 9th, 2007 (03:17 AM).
ChaosKing ChaosKing is offline
 
Join Date: Jan 2007
Gender:
Nature: Adamant
Posts: 19
how do ya get it into the game sause im usin script ed, if there are any better can u tell me plz
  #5    
Old February 9th, 2007 (06:58 AM).
martijn's Avatar
martijn martijn is offline
HeartGold & Collosseum
 
Join Date: Jul 2006
Age: 26
Nature: Calm
Posts: 133
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'm available if you'd like to exchange Friend Codes! Please check my profile and PM me if you're interested
Name: Wes



Diamond team: Rhydon - Infernape - Pachirisu - Pidgeot - Dewgong - Bellossom
Pearl team, pre-Nat. Dex 2nd Gym beaten: Espeon - Prinplup - Grovyle - Quillava - Staravia - Larvitar
  #6    
Old February 9th, 2007 (08:27 AM).
Christos's Avatar
Christos Christos is offline
chase is my favourite
ModeratorBSCS
 
Join Date: Feb 2006
Gender: Male
Nature: Serious
Posts: 4,341
Quote originally posted by |Matt|:
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.

Quote originally posted by ChaosKing:
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.

Quote originally posted by martijn:
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
__________________
  #7    
Old February 9th, 2007 (08:43 AM).
Green Charizard's Avatar
Green Charizard Green Charizard is offline
pɹɐzıɹɐɥɔ uǝǝɹƃ
 
Join Date: Nov 2004
Location: the UK
Gender:
Nature: Quiet
Posts: 252
Send a message via Windows Live Messenger to Green Charizard
Really nice tutorial Christos, I know you've said over making this for a while, it should help ALOT of people.
__________________


  #8    
Old February 9th, 2007 (11:12 AM).
ash2000's Avatar
ash2000 ash2000 is offline
Beginning Trainner/Hacker
 
Join Date: May 2006
Location: South Pacific
Gender:
Nature: Calm
Posts: 116
Great tutorial Christos, i really just need the how to script.
__________________
  #9    
Old February 9th, 2007 (11:40 AM).
D-Trogh's Avatar
D-Trogh D-Trogh is offline
Dead
 
Join Date: Jul 2005
Location: Belgium
Age: 23
Gender: Male
Posts: 439
Send a message via Windows Live Messenger to D-Trogh
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 ?
__________________
[NTME | WPEDS | HTPE | SGPE | TGPE | PDEDS]
  #10    
Old February 9th, 2007 (12:10 PM).
Christos's Avatar
Christos Christos is offline
chase is my favourite
ModeratorBSCS
 
Join Date: Feb 2006
Gender: Male
Nature: Serious
Posts: 4,341
Quote originally posted by D-Trogh:
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.
__________________
  #11    
Old February 9th, 2007 (05:06 PM).
Matt Silver's Avatar
Matt Silver Matt Silver is offline
Who Do You Think?
 
Join Date: Oct 2005
Location: Where Giving Up Is Not An Option
Age: 23
Gender: Male
Nature: Adamant
Posts: 948
The tutorial is awesome (Super awesome) but I'm confused with inserting scripts. Any help here?
  #12    
Old February 9th, 2007 (05:10 PM).
foofatron foofatron is offline
Banned
 
Join Date: Jan 2007
Age: 13
Gender:
Nature: Adamant
Posts: 309
Send a message via Windows Live Messenger to foofatron
Me too.Do this on Diamond Cutter right?
  #13    
Old February 9th, 2007 (11:14 PM).
martijn's Avatar
martijn martijn is offline
HeartGold & Collosseum
 
Join Date: Jul 2006
Age: 26
Nature: Calm
Posts: 133
@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
__________________
I'm available if you'd like to exchange Friend Codes! Please check my profile and PM me if you're interested
Name: Wes



Diamond team: Rhydon - Infernape - Pachirisu - Pidgeot - Dewgong - Bellossom
Pearl team, pre-Nat. Dex 2nd Gym beaten: Espeon - Prinplup - Grovyle - Quillava - Staravia - Larvitar
  #14    
Old February 9th, 2007 (11:23 PM).
Prof. 9 Prof. 9 is offline
 
Join Date: Jun 2006
Location: Netherlands
Gender: Male
Posts: 151
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?
  #15    
Old February 9th, 2007 (11:37 PM).
Arashi Arashi is offline
 
Join Date: Jul 2004
Age: 50
Posts: 251
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?
  #16    
Old February 10th, 2007 (12:13 AM).
Christos's Avatar
Christos Christos is offline
chase is my favourite
ModeratorBSCS
 
Join Date: Feb 2006
Gender: Male
Nature: Serious
Posts: 4,341
Quote originally posted by martijn:
@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
I think you'll have to edit it with hex.

Quote originally posted by Prof. 9:
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.

Quote originally posted by Kallen-san:
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.
__________________
  #17    
Old February 10th, 2007 (12:45 AM).
Prof. 9 Prof. 9 is offline
 
Join Date: Jun 2006
Location: Netherlands
Gender: Male
Posts: 151
Quote originally posted by Christos:
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...
  #18    
Old February 10th, 2007 (01:10 AM).
Christos's Avatar
Christos Christos is offline
chase is my favourite
ModeratorBSCS
 
Join Date: Feb 2006
Gender: Male
Nature: Serious
Posts: 4,341
Quote originally posted by Prof. 9:
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.
__________________
  #19    
Old February 12th, 2007 (10:47 AM).
BlackRainbow*'s Avatar
BlackRainbow* BlackRainbow* is offline
Pokemon Coralo Version ?
 
Join Date: Oct 2006
Location: Yiushu
Gender:
Nature: Bold
Posts: 518
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
__________________
Pokemon Coralo Version...New Pokemon Petal.
Shyrika Region
  #20    
Old February 12th, 2007 (10:51 AM).
Christos's Avatar
Christos Christos is offline
chase is my favourite
ModeratorBSCS
 
Join Date: Feb 2006
Gender: Male
Nature: Serious
Posts: 4,341
Quote originally posted by KebaSun:
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
Can you show me the script you inserted?
__________________
  #21    
Old February 12th, 2007 (10:54 AM).
BlackRainbow*'s Avatar
BlackRainbow* BlackRainbow* is offline
Pokemon Coralo Version ?
 
Join Date: Oct 2006
Location: Yiushu
Gender:
Nature: Bold
Posts: 518
i inserted the script that you have in tutorial


#org 0x800000
applymovement 0x3 0x800100
pause 0x30
end

#org 0x800100
#raw 0x8
#raw 0x8
#raw 0xA
#raw 0xFE
__________________
Pokemon Coralo Version...New Pokemon Petal.
Shyrika Region
  #22    
Old February 12th, 2007 (12:27 PM).
Christos's Avatar
Christos Christos is offline
chase is my favourite
ModeratorBSCS
 
Join Date: Feb 2006
Gender: Male
Nature: Serious
Posts: 4,341
Quote originally posted by KebaSun:
i inserted the script that you have in tutorial


#org 0x800000
applymovement 0x3 0x800100
pause 0x30
end

#org 0x800100
#raw 0x8
#raw 0x8
#raw 0xA
#raw 0xFE
The event with "People's number" 3 should move.
__________________
  #23    
Old February 12th, 2007 (12:30 PM).
Andrew McKenzie's Avatar
Andrew McKenzie Andrew McKenzie is offline
Meh.
 
Join Date: Feb 2007
Location: Ireland
Age: 24
Gender: Male
Nature: Relaxed
Posts: 354
I'm using a rom that's us-pokemon firered....
i'm wondering if someone can write me a script?...
i need it as an example...
I need a trainer.....rocket grunt preferably
i need him/he to battle me
in my new city
Battle city
the city's offset is $71CC08
the trainer can have just one pokémon
please do this so i can use it in an example
position X:20 Y:20 for the events position and PM it to me please...

Please explain how to add events as I am having trouble understanding the scripting tutorial....please reply ASAP...
  #24    
Old February 12th, 2007 (12:36 PM).
Christos's Avatar
Christos Christos is offline
chase is my favourite
ModeratorBSCS
 
Join Date: Feb 2006
Gender: Male
Nature: Serious
Posts: 4,341
All you need is a trainerbattle command for this script. Put it in a script with the messages and edit the trainer's data with PET.
__________________
  #25    
Old February 12th, 2007 (12:39 PM).
Andrew McKenzie's Avatar
Andrew McKenzie Andrew McKenzie is offline
Meh.
 
Join Date: Feb 2007
Location: Ireland
Age: 24
Gender: Male
Nature: Relaxed
Posts: 354
but i don't understand how to do dis...even wit ur tut....please dumb it down for me or explain it differently...reply ASAP
Closed Thread
Quick Reply

Sponsored Links

You may also like.. (Beta)
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are UTC -8. The time now is 08:06 AM.