View Single Post
Old 11th July 2013, 02:55 AM   #2
Diegoisawesome
Oh god the bees
Ex-Staff
 
Diegoisawesome's Avatar
 
Join Date: Jul 2013
Location: :noitacoL
Age: 22
Posts: 60
Diegoisawesome
Default

Applymovement


Code:
#dynamic 0x800000

#org @start
checkflag 0x828
if 0x1 goto @done
msgbox @1 0x6
applymovement 0x04 @move
waitmovement 0x0
applymovement 0xFF @move2
pause 0x30
msgbox @2 0x6
playsong 0x13E 0x0
applymovement 0x04 @move3
applymovement 0xFF @move3
waitmovement 0x0
fadesong 0x12C
release
end

#org @done
release
end

#org @move
#raw 0x62
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0xFE

#org @move2
#raw 0x03
#raw 0xFE

#org @move3
#raw 0x13
#raw 0x13
#raw 0x13
#raw 0x13
#raw 0xFE
#org @1
= Waaaiiiitttt!!!
#org @2
= You can't go out there\nwithout your own Pokemon.\pWild Pokemon will hurt you.
What's new here? Applymovement, waitmovement, pause, playsong and fadesong. I guess I'll explain them all in that order.
Applymovement is a very useful command that allows to show an overworld walking or running depending on what we want.
When we use applymovement, it has to be followed by a People Number, which is found here:



It also needs a pointer to where our movements are. An overworld with a people number of "4" seems normal, doesn't it? But what about one with 0xFF (255). There's almost never 255 overworlds on one map. 0xFF is the “hero's” people number.
Now, let's look at this movements list: (credit to HackMew for finding them and including them in XSE)
Ruby/Sapphire/Emerald
Spoiler:
#raw 0x00 = Face Down
#raw 0x01 = Face Up
#raw 0x02 = Face Left
#raw 0x03 = Face Right
#raw 0x04 = Step Down (Slow)
#raw 0x05 = Step Up (Slow)
#raw 0x06 = Step Left (Slow)
#raw 0x07 = Step Right (Slow)
#raw 0x08 = Step Down (Normal)
#raw 0x09 = Step Up (Normal)
#raw 0x0A = Step Left (Normal)
#raw 0x0B = Step Right (Normal)
#raw 0x0C = Jump2 Down
#raw 0x0D = Jump2 Up
#raw 0x0E = Jump2 Left
#raw 0x0F = Jump2 Right
#raw 0x10 = Delay1
#raw 0x11 = Delay2
#raw 0x12 = Delay3
#raw 0x13 = Delay4
#raw 0x14 = Delay5
#raw 0x15 =
Step Down (Fast)
#raw 0x16 = Step Up (Fast)
#raw 0x17 = Step Left (Fast)
#raw 0x18 = Step Right (Fast)
#raw 0x19 = Step on the Spot Down (Slow)
#raw 0x1A = Step on the Spot Up (Slow)
#raw 0x1B = Step on the Spot Left (Slow)
#raw 0x1C = Step on the Spot Right (Slow)
#raw 0x1D = Step on the Spot Down (Normal)
#raw 0x1E = Step on the Spot Up (Normal)
#raw 0x1F = Step on the Spot Left (Normal)
#raw 0x20 = Step on the Spot Right (Normal)
#raw 0x21 = Step on the Spot Down (Faster)
#raw 0x22 = Step on the Spot Up (Faster)
#raw 0x23 = Step on the Spot Left (Faster)
#raw 0x24 = Step on the Spot Right (Faster)
#raw 0x25 = Step on the Spot Down (Fastest)
#raw 0x26 = Step on the Spot Up (Fastest)
#raw 0x27 = Step on the Spot Left (Fastest)
#raw 0x28 = Step on the Spot Right (Fastest)
#raw 0x29 = Slide Down
#raw 0x2A = Slide Up
#raw 0x2B = Slide Left
#raw 0x2C = Slide Right
#raw 0x2D = Slide Down
#raw 0x2E = Slide Up
#raw 0x2F = Slide Left
#raw 0x30 = Slide Right
#raw 0x31 = Slide Down
#raw 0x32 = Slide Up
#raw 0x33 = Slide Left
#raw 0x34 = Slide Right
#raw 0x35 = Slide Running Down
#raw 0x36 = Slide Running Up
#raw 0x37 = Slide Running Left
#raw 0x38 = Slide Running Right
#raw 0x3A = Jump Facing Left (Down)
#raw 0x3B = Jump Facing Down (Up)
#raw 0x3C = Jump Facing Up (Left)
#raw 0x3D = Jump Facing Left (Right)
#raw 0x3E = Face Player
#raw 0x3F = Face Against Player
#raw 0x40 = Lock Sprite Facing
#raw 0x41 = Release Sprite Facing
#raw 0x42 = Jump Down
#raw 0x43 = Jump Up
#raw 0x44 = Jump Left
#raw 0x45 = Jump Right
#raw 0x46 = Jump in Place (Facing Down)
#raw 0x47 = Jump in Place (Facing Up)
#raw 0x48 = Jump in Place (Facing Left)
#raw 0x49 = Jump in Place (Facing Right)
#raw 0x4A = Jump in Place (Facing Down/Up)
#raw 0x4B = Jump in Place (Facing Up/Down)
#raw 0x4C = Jump in Place (Facing Left/Right)
#raw 0x4D = Jump in Place (Facing Right/Left)
#raw 0x4E = Face Left
#raw 0x54 = Hide Sprite
#raw 0x55 = Show Sprite
#raw 0x56 = Exclamation Mark (!)
#raw 0x57 = Question Mark (?)
#raw 0x58 = Love (<3)
#raw 0x62 = Walk Down
#raw 0x63 = Walk Down
#raw 0x64 = Face Down (Delayed)
#raw 0x65 = Face Up (Delayed)
#raw 0x66 = Face Left (Delayed)
#raw 0x67 = Face Right (Delayed)
#raw 0x70 = Jump in Place (Facing Down)
#raw 0x71 = Jump in Place (Facing Up)
#raw 0x72 = Jump in Place (Facing Left)
#raw 0x73 = Jump in Place (Facing Right)
#raw 0x74 = Jump Down Running
#raw 0x75 = Jump Up Running
#raw 0x76 = Jump Left Running
#raw 0x77 = Jump Right Running
#raw 0x78 = Jump2 Down Running
#raw 0x79 = Jump2 Up Running
#raw 0x7A = Jump2 Left Running
#raw 0x7B = Jump2 Right Running
#raw 0x7C = Walk on the Spot (Down)
#raw 0x7D = Walk on the Spot (Up)
#raw 0x7E = Walk on the Spot (Left)
#raw 0x7F = Walk on the Spot (Right)
#raw 0x80 = Slide Down Running
#raw 0x81 = Slide Up Running
#raw 0x82 = Slide Left Running
#raw 0x83 = Slide Right Running
#raw 0x84 = Slide Down
#raw 0x85 = Slide Up
#raw 0x86 = Slide Left
#raw 0x87 = Slide Right
#raw 0x88 = Slide Down on Left Foot
#raw 0x89 = Slide Up on Left Foot
#raw 0x8A = Slide Left on Left Foot
#raw 0x8B = Slide Right on Left Foot
#raw 0x8C = Slide Left diagonally (Facing Up)
#raw 0x8D = Slide Right diagonally (Facing Up)
#raw 0x8E = Slide Left diagonally (Facing Down)
#raw 0x8F = Slide Right diagonally (Facing Down)
#raw 0x90 = Slide2 Left diagonally (Facing Up)
#raw 0x91 = Slide2 Right diagonally (Facing Up)
#raw 0x92 = Slide2 Left diagonally (Facing Down)
#raw 0x93 = Slide2 Right diagonally (Facing Down)
#raw 0x96 = Walk Left
#raw 0x97 = Walk Right
#raw 0x98 = Levitate
#raw 0x99 = Stop Levitating
#raw 0x9C = Fly Up Vertically
#raw 0x9D = Land
#raw 0xFE = End of Movements



Fire Red/Leaf Green
Spoiler:
#raw 0x0 = Face Down
#raw 0x1 = Face Up
#raw 0x2 = Face Left
#raw 0x3 = Face Right
#raw 0x4 = Face Down (Faster)
#raw 0x5 = Face Up (Faster)
#raw 0x6 = Face Left (Faster)
#raw 0x7 = Face Right (Faster)
#raw 0x8 = Step Down (Very Slow)
#raw 0x9 = Step Up (Very Slow)
#raw 0xA = Step Left (Very Slow)
#raw 0xB = Step Right (Very Slow)
#raw 0xC = Step Down (Slow)
#raw 0xD = Step Up (Slow)
#raw 0xE = Step Left (Slow)
#raw 0xF = Step Right (Slow)
#raw 0x10 = Step Down (Normal)
#raw 0x11 = Step Up (Normal)
#raw 0x12 = Step Left (Normal)
#raw 0x13 = Step Right (Normal)
#raw 0x14 = Jump2 Down
#raw 0x15 = Jump2 Up
#raw 0x16 = Jump2 Left
#raw 0x17 = Jump2 Right
#raw 0x18 = Delay1
#raw 0x19 = Delay2
#raw 0x1A = Delay3
#raw 0x1B = Delay4
#raw 0x1C = Delay5
#raw 0x1D = Step Down (Fast)
#raw 0x1E = Step Up (Fast)
#raw 0x1F = Step Left (Fast)
#raw 0x20 = Step Right (Fast)
#raw 0x21 = Step on the Spot Down (Normal)
#raw 0x22 = Step on the Spot Up (Normal)
#raw 0x23 = Step on the Spot Left (Normal)
#raw 0x24 = Step on the Spot Right (Normal)
#raw 0x25 = Step on the Spot Down (Faster)
#raw 0x26 = Step on the Spot Up (Faster)
#raw 0x27 = Step on the Spot Left (Faster)
#raw 0x28 = Step on the Spot Right (Faster)
#raw 0x29 = Step on the Spot Down (Fastest)
#raw 0x2A = Step on the Spot Up (Fastest)
#raw 0x2B = Step on the Spot Left (Fastest)
#raw 0x2C = Step on the Spot Right (Fastest)
#raw 0x2D = Face Down (Delayed)
#raw 0x2E = Face Up (Delayed)
#raw 0x2F = Face Left (Delayed)
#raw 0x30 = Face Right (Delayed)
#raw 0x31 = Slide Down (Slow)
#raw 0x32 = Slide Up (Slow)
#raw 0x33 = Slide Left (Slow)
#raw 0x34 = Slide Right (Slow)
#raw 0x35 = Slide Down (Normal)
#raw 0x36 = Slide Up (Normal)
#raw 0x37 = Slide Left (Normal)
#raw 0x38 = Slide Right (Normal)
#raw 0x39 = Slide Down (Fast)
#raw 0x3A = Slide Up (Fast)
#raw 0x3B = Slide Left (Fast)
#raw 0x3C = Slide Right (Fast)
#raw 0x3D = Slide Running on Right Foot (Down)
#raw 0x3E = Slide Running on Right Foot (Up)
#raw 0x3F = Slide Running on Right Foot (Left)
#raw 0x40 = Slide Running on Right Foot (Right)
#raw 0x41 = Slide Running on Left Foot (Down)
#raw 0x42 = Slide Running on Left Foot (Up)
#raw 0x43 = Slide Running on Left Foot (Left)
#raw 0x44 = Slide Running on Left Foot (Right)
#raw 0x46 = Jump Facing Left (Down)
#raw 0x47 = Jump Facing Down (Up)
#raw 0x48 = Jump Facing Up (Left)
#raw 0x49 = Jump Facing Left (Right)
#raw 0x4A = Face Player
#raw 0x4B = Face Against Player

#raw 0x4C = Lock Sprite Facing
#raw 0x4D = Release Sprite Facing

#raw 0x4E = Jump Down
#raw 0x4F = Jump Up
#raw 0x50 = Jump Left
#raw 0x51 = Jump Right
#raw 0x52 = Jump in Place (Facing Down)
#raw 0x53 = Jump in Place (Facing Up)
#raw 0x54 = Jump in Place (Facing Left)
#raw 0x55 = Jump in Place (Facing Right)
#raw 0x56 = Jump in Place (Facing Down/Up)
#raw 0x57 = Jump in Place (Facing Up/Down)
#raw 0x58 = Jump in Place (Facing Left/Right)
#raw 0x59 = Jump in Place (Facing Right/Left)
#raw 0x60 = Hide Sprite
#raw 0x61 = Show Sprite
#raw 0x62 = Exclamation Mark (!)
#raw 0x63 = Question Mark (?)
#raw 0x64 = Cross (X)
#raw 0x65 = Double Exclamation Mark (!!)
#raw 0x66 = Happy (^_^)
#raw 0xFE = End of Movements



Before we look at the movements in a different view, I should explain the layout of the movements at the pointer. It's set out in a similar way to a message. We have #org @pointer first and what's being written to the ROM below that. You put #raw, then the movement that you want. You have to put #raw 0xFE at the end of the movements, or else the movements won't work.
Now, we're going to look at waitmovement and pause.
waitmovement is one of the best commands that you will ever find. It's the "perfect pause"! When used as waitmovement 0x0, it will wait for the exact amount of time that it takes for the movements to move the sprite. Really helpful, isn't it?
Now, we have pause. pause will wait for a set amount of time. You have to add the amount that it will wait for. If you want to calculate pause time vs. seconds, here's a (not very good) conversion thingy:
0x20 Pause time = approx. 1 sec. real time
I don't use this very often. I prefer to use waitmovement almost all of the time.

Okay now, no more sidetracking. Let's look at the movements. Let's look at the script without anything but the applymovements, pause and waitmovements. This leaves us with this:
Code:
#dynamic 0x800000

#org @start
applymovement 0x04 @move
waitmovement 0x0
applymovement 0xFF @move2
pause 0x30
applymovement 0x04 @move3
applymovement 0xFF @move3
waitmovement 0x0
release
end

#org @move
#raw 0x62
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0xFE

#org @move2
#raw 0x03
#raw 0xFE

#org @move3
#raw 0x13
#raw 0x13
#raw 0x13
#raw 0x13
#raw 0xFE
The first two applymovements are in a completely normal setup.
ie. applymovement 0xXX @YYYYYY
waitmovement
/pause
But let's look at the next set of movements. It's set up differently. We have two applymovements before we have some sort of pause. What would happen if I did that? They would both move at the same time. This is sometimes referred to as "follow-me." With a "follow-me", we can use as many applymovements before the pause as we want. This can be useful if we wanted a "group" to walk together. We can have three, four, five, six, or however many you want in a "group". I think that's all there is to the applymovement command.

Now we can move onto that playsong.
When we script playsong, we need a few bytes to get it to work. Here's a short summary of what we need:
playsong [song #] 0x0
That 0x0 is a buffer. We need it in order for the command to work.
Whatever game you're hacking, you can find the song numbers in A-Map.

Now we have fadesong. What's that do? It's set up similar to playsong and will fade into the sound displayed. If you want more detail on how it works, just refer back to playsong. The only thing different is that it does not need that extra buffer.

I thought I might point out something about the checkflag in this script. We actually have no setflag in this script. So why do I have a checkflag? In one script, we can check if a flag was set in a different script. In this section, we check if the Pokemon menu has been activated before the script will end (@done).

Okay. Compile the script, assign it to a script tile (green with an S) and not a person.
Now test it in the ROM. Then look at this spoiler.
Spoiler:
Didn't work, did it? Froze on the spot. You're going to need to change this...



to this....



Try it now. Worked perfectly, didn't it?


So, what's next?
Countpokemon

I'm not going to show just one script. There's too much to explain in just one script.
Here's the most basic example.
Code:
countpokemon
compare 0x800D 0x6
if 0x1 goto @continue
This is the most basic form.
Before I explain this fragment of a script, I should go into a little more detail on the command countpokemon itself.
countpokemon checks how many Pokemon are in your party and assigns the value to 0x800D. If we have six Pokemon in our party, it would assign 0x06 to 0x800D, and if we had 3 Pokemon in our party, it would assign 0x03 to 0x800D.
Now back to that part of a script.
compare 0x800D 0x6 checks to see if there are six Pokemon in the player's party. Then, with if 0x1 goto @continue, it says, "if there are six Pokemon in your party, go to @continue".
That's the simplest and easiest form of countpokemon.

I'll add one more example just to help the information sink in.
Code:
countpokemon
compare 0x800D 0x2
if 0x1 goto @continue
In this example, it checks if you have two Pokemon. If you have a number of Pokemon other than two, the script won't continue to @continue.
Trainerbattle 0x0

Just a simple trainerbattle script:
Code:
#dynamic 0x800000

#org @start
trainerbattle 0x0 0x001 0x0 @before @after
msgbox @beaten 0x6
release
end

#org @before
= Go, all my PIKACHUs!

#org @after
= Nooo! My PIKACHUs!!!!!

#org @beaten
= My PIKACHUs can be used to\ncharge my Nintendo DS Lite.
t
rainerbattle
is a battle with a trainer. trainerbattle is great because the game keeps track of whether you have beaten a trainer or not. In this script, we have no need for a checkflag/setflag situation.
Now to explaining these values after the trainerbattle. These are:
trainerbattle 0x0 [Type of battle] 0x001 [Trainer ID] 0x0 [Reserved Byte (normally 0x0)] @before [Pointer to Message When Seen] @after [Pointer to Winning Message]
I guess I'll explain the type of battle. This byte determines whether it's a double battle, Gym Leader Battle, or another type. A normal trainerbattle is 0x0. The trainer will "see you", then go to the beginning message, then the battle, and then goes to the message when you win.
Now we'll move onto the Trainer ID. This is the ID of a trainer that's found in PET. For example, Brock can be found with with a Trainer ID of 0x19E, and Blaine can be found with 0x1A3.
Now, there are two pointers, @before & @after. I've labeled these to help display what they are used for. The first pointer, @before, shows the pointer to the message displayed before the battle.
Now onto @after. It's the pointer to the message after the battle, obviously! This message appears while we are still in the battle itself. Remember the colors that were mentioned towards the beginning of this tutorial? Well, we can use colors with this too! They're different, though. Sadly, I don't have a list for those values.

Now, if I were to test it in a ROM, what would happen after the trainerbattle? Nothing. The script ends. So why do I have a msgbox after it?
Remember how I talked about trainerbattle keeping track of whether you have beaten them or not? Well, once you beat the trainer, the trainerbattle will be skipped, so when you speak to them after beating them in a battle, it'll be treated like a normal message script.
Wait! Why don't I have a lock and faceplayer after the trainerbattle? The reason is that once you have beaten that trainer, trainerbattle will also act as the lock/faceplayer combo, and you don't have to worry about them in this script.
That's the scripting side of this command done. Now the A-Map side. Now compile this script, and test it in a ROM. Did it work like a normal in-game trainer battle? I bet your answer is no.
You'll need to fill in these boxes:


Trainerbattle 0x1

Code:
#dynamic 0x800000

#org @start
lock
faceplayer
checkflag 0x820
if 0x1 goto @done
msgbox @2 0x6
trainerbattle 0x1 0x001 0x0 @before @after @later
end

#org @before
= Show me what ya got!

#org @after
= What the-?

#org @later
msgbox @3 0x6
fanfare 0x13E
msgbox @4 0x4
waitfanfare
closeonkeypress
msgbox @5 0x6
giveitem 0x147 0x1
setflag 0x820
release
end

#org @done
msgbox @1 0x6
release
end

#org @1
= You should travel to Cerulean City\nto get your next badge.

#org @2
= Welcome to Pewter City Gym.\nYou want to challenge me?

#org @3
= Congratulations!\pFor beating me, you get\nthis badge!

#org @4
= \v\h01 recieved a badge!

#org @5
= Oh, and please take this.
Remember that image that was used with the previous script? Ignore that. For this kind of script, the "Trainer" box doesn't need to be checked and the “View radius” box doesn't need to have a value in it.
This script is a little longer than the previous trainerbattle script.
You'll see that the "0x0" from the previous script has become a "0x1." There's also a third pointer.
If the “Battle type” box says "0x1", it means that it needs three pointers after the trainerbattle command. The first two are the same as in the previous script: one for before the battle, and one for after the battle. But the third pointer doesn't go to a message! It points to @later. It's a separate part of the script. This is where the script continues after you've won the battle.
If you refer to the flag section, you'll be able to see what the setflag 0x820 is.
Spoiler:
It's to activate the first badge on the trainer card.

I think that's about all I need to add on trainerbattles.
Warp

I think I'm at the stage in this tutorial where I don't need to show an example script for every command. This is one of those cases.
So now we have warp. warp is there to allow the player to warp to a different map or location. warp is used like this:
warp [map bank] [map number] [warp number] [extra, for now] [extra, for now]
Let's say we wanted to warp to the door of Oak's Lab in Pallet Town.
Open a Fire Red/Leaf Green Rom in Advance-Map and open the Pallet Town map. To the far left of the program's window, you should see an orange box next to the current open map. If you've clicked Pallet Town, it should say “Pallet Town (3.0)”.
The "3" is the map bank and the "0" is the map number. Now, we need to click on the Warp on the door of Oak's Lab. It should say "Event Number: 2" on an unmodified Pallet Town. Now, we have our three values.
Now, we write our warp command.
Code:
warp 0x3 0x0 0x2 0x0 0x0
There's our warp! The only thing is, there's a problem with warping. Once you use warp, the script ends. You're probably saying, "How come when Prof. Oak takes you to his lab in Fire Red, the script still continues?" That involves some of the more difficult parts of scripting, Level Scripts. Since these are a little difficult, I'll explain these towards the end of the tutorial.
Warp to Position


Code:
#dynamic 0x800000

#org @start
msgbox @1 0x6
warp 0x4 0x1 0xFF 0x02 0x06
end

#org @1
= I'm going to teleport you\nto your bed.
This is something that quite a few people don't know about. It's something that a lot of scripters were 'in the dark' about.
Well, this should warp you straight to your bed in your room. This is in map PALLET TOWN (4.1). So, what's the 0xFF for? The 0xFF is what tells the command that it's going to warp to a certain position. What are the last values for?

Let's look at the locations of the bed in your room. The values are: (X=2) (Y=6). They are actually 02 & 06. Now, just plug the numbers into the script.
It's that simple! We can now warp to a certain position.
Weather Commands

When we want to change the weather in a script, there are two commands that we need to know about: setweather and doweather.
setweather will set a certain type of weather to be activated by doweather.
This is how we set up our setweather command:
setweather [weather type, 2 bytes]
A list of the different weather types is in A-Map.
If we wanted to have rainy weather, we would have:
Code:
setweather 0x3

doweather
is used to activate the weather. So let's show a script to display these in use:
Code:
#dynamic 0x800000

#org @start
checkflag 0x200
if 0x1 goto @next
setweather 0x3
doweather
setflag 0x200
release
end

#org @next
setweather 0x2
doweather
clearflag 0x200
release
end
There is also one more somewhat useful command: resetweather.
This command will prepare the game to return back to its default map weather. Since this only prepares the ROM for it, it still must be followed by doweather.
Pokemart

Here's a basic script showing the pokemart command. By now, you should be able to add to it pretty easily:
Code:
#dynamic 0x800000

#org @start
lock
faceplayer
pokemart @values
release
end

#org @values
#raw word 0x1
#raw word 0x2
#raw word 0x3
#raw word 0x4
#raw word 0x5
#raw word 0x6
#raw word 0x7
#raw word 0x8
#raw word 0x9
#raw word 0xA
#raw word 0xB
#raw word 0xC
#raw word 0x13
#raw word 0x14
#raw word 0x0
Well, here we have the pokemart command. It's simply followed by a pointer. This will point to the values of the items that will appear in the PokeMart screen. The #raw words are set up differently. They're set up like this:
#raw word 0x(value)
In this case, we have the these items, respectively:

  • Master Ball 0x1
  • Ultra Ball 0x2
  • Great Ball 0x3
  • Poké Ball 0x4
  • Safari Ball 0x5
  • Net Ball 0x6
  • Dive Ball 0x7
  • Nest Ball 0x8
  • Repeat Ball 0x9
  • Timer Ball 0xA
  • Luxury Ball 0xB
  • Premier Ball 0xC
  • Parlyz Heal 0x13
  • Full Restore 0x14

But why did I put #raw word 0x0 at the end if there isn't an 0x0 item? 0x0 marks the end of the item line. Without this, the command will NOT work.
#raw's

I think I should go into a little detail on these. When we script in #raw, we're just scripting in hex. Here's an example script:
Code:
#dynamic 0x800000

#org @start
#raw 0x6A
#raw 0x5A
#raw 0xA4 0x01 0x00
#raw 0xA5
#raw 0x6C
#raw 0x02
This script in XSE language would appear like this:
Code:
#dynamic 0x800000

#org @start
lock
faceplayer
setweather 0x1
doweather
release
end

Hidesprite and Showsprite

hidesprite is the command that we covered a little in detail earlier. We used it like this: hidesprite 0x800F . It makes the last person we talked to disappear. But what if we wanted a certain person to disappear?
A common mistake is confusing the People ID with the Event ID. Make sure you get the People ID. This is how you set out the command:
hidesprite 0x(people no.)
So let's use an example: People ID. = 4. Here's how it will appear:
hidesprite 0x04
One more: People ID = 12.
hidesprite
0x0C
By now, you should have a pretty good understanding of the hidesprite command, so let's move onto showsprite.

showsprite can make an OW re-appear once it has been hidden with hidesprite.
showsprite is set out in the exact same way as hidesprite.
Here's some complimentary examples from when I explained hidesprite:
Example 1. People No. = 4.
showsprite 0x04
Example 2. People No = 12.
showsprite 0x0C
If you remember back to wildbattle, you'll see that you need to use setflag to keep the person hidden. If we wanted to keep them viewable after using showsprite, we would need to use clearflag.



Giveegg

giveegg is a relatively simple command to use. All we need is to add the Pokemon species number after it.
As an example, let's give a Pikachu Egg. Pikachu's Pokemon number is 25. Converting that to hex gives us 0x19.
Our giveegg command would appear like this:
Code:
giveegg 0x19
Just in case you need some more explanation, let's use Treecko as an extra example. Treecko is number 277. Converting it to hex gives us 0x115. Our line appears like this:
Code:
giveegg 0x115
Pretty easy, huh?
Textcolor
We have three useful colors here:

  • Blue = 0x00
  • Red = 0x01
  • Black = 0x02

Since they're short, I'll show examples of all three of them:
Black Text
Code:
#dynamic 0x800000

#org @start
lock
faceplayer
textcolor 0x02
msgbox @1 0x6
release
end

#org @1
= This is black text.


Blue Text

Code:
#dynamic 0x800000

#org @start
lock
faceplayer
textcolor 0x00
msgbox @1 0x6
release
end
#org @1
= This is blue text.
Red Text
Code:
#dynamic 0x800000

#org @start
lock
faceplayer
textcolor 0x01
msgbox @1 0x6
release
end

#org @1
= This is red text.
Setmaptile

I'll show a script and explain it for this one:
Code:
#dynamic 0x800000

#org @start
setmaptile 0xA 0xD 0x1 0x0
special 0x8E
release
end
Nice and short. setmaptile is set out like this:
setmaptile [X Coordinate] [Y Coordinate] [Tile Number] [Movement allowed?]
So in my short script, we have:
X Co-ordinate = 10 or 0xA
Y-Co-ordinate = 13 or 0xD
Tile = Normal Grass (in tileset 0 [Fire Red]) or 0x1
Movement Allowed = Yes or 0x0

We can find our X and Y coordinates in Advance-Map, which has been shown earlier. We can also find our tile number in Advance-Map. The number also depends on what tileset we are using. Hold your mouse over a tile in the right pane. In the little status bar at the bottom on the far left, you should have Block: XX Offset: XXXXXX
Movement allowed has two possible options:

  • 0x0 = Passable
  • 0x1 = Blocked off

So, what's the special there for?
This special will reset the map so that it allows the tile to set. Without this, you'll have to leave the screen and come back before it will actually work.
Special Trainer Commands

We've got three commands here, all #raw's.
First is checktrainerflag.
Second is cleartrainerflag.
Last is is settrainerflag.
All three commands are set out in the same way:
[command] [PET ID]
For all three examples, I'm going to use the trainer "Leader Brock", with a PET ID of 0x19E.
Now let's work with checktrainerflag. Since we're checking for something, the answer or result is going to have to be stored somewhere. Like most commands, the result is stored into 0x800D. Here's an example:
Code:
checktrainerflag 0x19E
compare 0x800D 0x1
if 0x1 goto @alreadybattled
Pretty straightforward, isn't it? It's simply followed by the compare and if statements. If you thought this was easy, the next two are even easier.
Here's cleartrainerflag. Again, we'll be using Brock for the example:
Code:
cleartrainerflag 0x19E
That's it. If were supposed to battle Brock, we couldn't battle him anymore. The trainerbattle is disabled.
But if we want to re-enable the trainerbattle what command do we use? settrainerflag! I'm still using Brock.
Code:
settrainerflag 0x19E
The trainerbattle 0x19E has now been re-enabled.
Checkitem/removeitem

These are probably easier to view through an example:
Code:
#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @1
boxset 0x5
compare 0x800D 0x1
if 0x1 goto @check
msgbox @2 0x6
release
end

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

#org @got
removeitem 0xD 0x1
giveitem 0x4 0x1
msgbox @3 0x6
release
end

#org @1
= Would you like to trade this\nPOKE BALL for your POTION?

#org @2
= Oh. That's too bad.
#org @3
= Yay! Thanks a lot!
We've got a few new things here. We've got:

  • checkitem 0xD 0x1
  • if 0x4 goto @pointer
  • removeitem 0x4 0x1

I'll start at the top of my list.

if 0x4 goto @pointer
is different. Why have I used 0x4 instead of 0x1?
Other than what we have here, we can also use values, like 0x1, 0x2, 0x3 etc. I'll propose a "table".
Code:
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)
Now we can see what each value represents.

Pretty useful, huh? From this point on, I'll only be using 0xX with the if line. I thought I'd warn you just so it doesn't look like I've totally changed the way I script without notice.

Now checkitem. checkitem is scripted like this:
Code:
checkitem [item number] [amount of     item]
As an example, let's say we want to check for 10 MASTERBALLs. It would appear like this:
Code:
checkitem 0x1 0xA
compare 0x800D 0x1
if 0x4 goto @got
I haven't explained the compare yet, have I? This compare checks for "Yes, you've got the item (0x1)" or "No, you don't have the item (0x0)"
By now, you should be able to tell what the if should do.

Now, we go into removeitem. Obviously, it removes an item from your bag. It's set out in the same way as giveitem and checkitem.
Code:
removeitem [item number] [amount to     remove]
Do I need to give any more explanation? This should be enough info on it.
Copyvar

A little command that's pretty easy to explain. It just copies what's stored in one variable to another. We will use this more and more often as we progress through the tutorial.
Here's the explanation:
Let 0x8008 be "A" and 0x800D be "B"
Code:
copyvar 0x8008 0x800D
Variable "B" copies onto variable "A".
I know that it's backwards, but that's just the way that copyvar is.
Pretty easy, don't you think?
Copyvarifnotzero

This is what some might call a little "add-on" to the copyvar command. The name says it all, doesn't it? It says, “copy variables, if not equal to zero”.
Code:
copyvarifnotzero 0x800D 0x8004
That's about it. Pretty basic, don't you think?
Setvar

This is a pretty complicated command and has a lot of uses, so I'm just going to give an explanation of the command but not give examples of the different ways to use it. In the following few sections, you'll see some ways of using it.
Setvar is pretty simple naming. It says “set to variable”. It sets a certain value, ranging from 0x0 to 0xFFFF, to a certain valuable. It's set out like this:
Code:
setvar     [variable] [value]
Here's just a sample view of how the command appears:
Code:
setvar 0x8008 0x1
If it's still hard to think about, try thinking of it as a msgbox @(text) 0x5. Depending on whether or not we choose "Yes" or "No", it assigns a certain value to 0x800D. With setvar, we can choose the variable and the value that is assigned.
You'll see more of this from this point on.
Random

With this command, the ROM will choose a random number within the range of 0x0 to the value you set with the argument, and then assign it to 0x800D. Here's a little example:
Code:
random 0x03
compare 0x800D 0x0
if 0x1 goto @option1
compare 0x800D 0x1
if 0x1 goto @option2
compare 0x800D 0x2
if 0x1 goto @option3
That should be about it. I'll show an extra example if you need it, but I shouldn't need to explain any more:
Code:
random 0x0A
compare 0x800D 0x0
if 0x1 goto @1
compare 0x800D 0x1
if 0x1 goto @2
compare 0x800D 0x2
if 0x1 goto @3
compare 0x800D 0x3
if 0x1 goto @4
compare 0x800D 0x4
if 0x1 goto @5
compare 0x800D 0x5
if 0x1 goto @6
compare 0x800D 0x6
if 0x1 goto @7
compare 0x800D 0x7
if 0x1 goto @8
compare 0x800D 0x8
if 0x1 goto @9
compare 0x800D 0x9
if 0x1 goto @10
That should be about it.
Special2

I'll show an example script fragment. This is a "checkpokemon" only usable for Fire Red.
Code:
setvar 0x8004 0x19
special2 0x800D 0x17C
compare 0x800D 0x1
if 0x1 goto @have
First, we assign the value to the variable 0x8004. Using this command, the value is the Pokemon we want to check for. In this case, it's Pikachu.
Now, we have special2. special2 is set out like this:
Code:
special2 [Variable to store value]     [event to call]
The event we use is 0x17C; this checks if the Pokemon that we have set to 0x8004 is in our party. If it is in our party, 0x1 is assigned to the variable, which in this case is 0x800D. If it's not in our party, 0x0 is assigned to the variable.
The following compare and if act in the same way as the compare and if used with the checkitem. If you've forgotten, here's a quote of myself to help you:
Quote:
Originally Posted by diegoisawesome
This compare checks for "Yes, you've got the item (0x1)" or "No, you don't have the item (0x0)"
By now, you should be able to tell what the if should do.
There you go. Lesson 1 on setvar and special2 under your belt.
Special, Part 2

We're adding to the special command. Well, not really. I'm just going to tell you about the waitstate command.
Let's just use special 0x9D, which in Fire Red, shows the "Old Man Catches Weedle" scene. Look at how we're going to use it:
Code:
special 0x9D
waitstate
Simple as that. No arguments, just waitstate.
Movesprite

This will obviously move a sprite from one place to another instantaneously.
It's set out like this:
Code:
movesprite [People Number] [X coordinate to move     sprite to] [Y coordinate to move sprite to]
The people number is the same as it has been since the beginning of this tutorial.
The X coordinate is the X coordinate of the tile that we want to move the overworld sprite to.
Obviously, the Y coordinate is the Y coordinate of the tile that we want to move the overworld sprite to.
Here's just a simple example of the command. We'll use People number = 4; X co-ordinate = 12; Y co-ordinate = 5.
Code:
movesprite 0x4 0xC 0x5
If you want another example, here's one with People Number = 9; X coordinate = 3; Y coordinate = 10.
Code:
movesprite 0x9 0x3 0xA
That's all there is to it!
Setvar Lesson 2

I'll show an example of this command that thethethethe used in his hack, Legend of Dragons. It's actually three scripts.
Script 1, right tile
Code:
#dynamic 0x800000

#org @start
setvar 0x4003 0x2
goto 0x8017CC
end

#org @script
checkflag 0x20A
if 0x1 goto @done
compare 0x4003 0x0
if 0x1 goto @left
compare 0x4003 0x1
if 0x1 goto @middle
compare 0x4003 0x2
if 0x1 goto @right
end

#org @left
applymovement 0xFF @move
applymovement 0x08 @move4
waitmovement 0x0
applymovement 0xFF @move3
goto @cont
end

#org @middle
applymovement 0xFF @move
applymovement 0x08 @move5
waitmovement 0x0
applymovement 0xFF @move3
goto @cont
end

#org @right
applymovement 0xFF @move
applymovement 0x08 @move2
waitmovement 0x0
applymovement 0xFF @move3
goto @cont
end

#org @cont
msgbox @1 0x5
compare 0x800D 0x1
if 0x1 goto @100
msgbox @2 0x6
goto @100
end

#org @100
msgbox @3 0x5
compare 0x800D 0x1
if 0x1 goto @101
msgbox @4 0x6
goto @102
end

#org @101
msgbox @5 0x6
goto @102
end

#org @102
setflag 0x20A
setflag 0x20B
applymovement 0x08 @move6
waitmovement 0x0
hidesprite 0x08
release
end

#org @done
release
end

#org @move
#raw 0x62
#raw 0x03
#raw 0xFE

#org @move2
#raw 0x62
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x10
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x01
#raw 0xFE

#org @move3
#raw 0x04
#raw 0xFE

#org @move4
#raw 0x62
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x10
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x01
#raw 0xFE

#org @move5
#raw 0x62
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x10
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x12
#raw 0x01
#raw 0xFE

#org @move6
#raw 0x13
#raw 0x13
#raw 0x13
#raw 0x13
#raw 0x13 
#raw 0x13
#raw 0x13
#raw 0x13
#raw 0x13
#raw 0x11
#raw 0x13
#raw 0x13
#raw 0x13
#raw 0xFE

#org @1
= [blue_fr]I see you're up early this\nmorning. I guess this means\lyou're excited.\pI need to tell you something.\nIs that okay?

#org @2
= [blue_fr]Too bad. I'm going to tell\nyou anyway.

#org @3
= [blue_fr]Unfortunately, I'm going to be a\nbit late.\pI need to take care of a few\nthings before I can go to the\lthe Dragon's Den.\pWhy don't you go ahead\nand I'll meet you there?

#org @4
= [blue_fr]Well, you have no choice\nin this.

#org @5
= [blue_fr]I'll meet you at the front\nof the room.


Script 2, middle tile

Code:
#dynamic 0x800000

#org @start
setvar 0x4003 0x1
goto 8017CC
end


Script 3, left tile

Code:
#dynamic 0x800000

#org @start
setvar 0x4003 0x0
goto 0x8017CC
end
You'll see that at the beginning of every script is this:
Code:
#dynamic 0x800000

#org @start
setvar 0x4003 0x[value]
goto @pointer
end
What we're doing here is we are assigning a certain value depending on which tile we stand on that we will be able to call upon later.
I'll explain the goto a little later. But for now, let's look at what's in Script 1 under @script. We've got the usual checkflag 0x[flag] to prevent the event from repeating itself.
Now, we've got some compare lines:
Code:
compare 0x4003 0x0
if 0x1 goto @left
compare 0x4003 0x1
if 0x1 goto @middle
compare 0x4003 0x2
if 0x1 goto @right
The pointers give away what they're there for, don't they? They're saying, “depending on which value was set, go to a different set of movements”. This is a great way to save space, and instead of compiling that big ugly script 3 times, with slightly altered movements, we can compile that jumbo script once, and then we have two clean scripts. Also, a variable's value will not change until you set a different value to that variable. The rest of Script 1 is pretty straightforward. Let's get back to that goto.
I haven't actually explained goto yet, have I? We've only seen it with if. Well, at this point, if you've followed the rest of this tutorial, it should be obvious what the command does. It will goto a specified point, whether is be a @pointer or a 0x[hex address]. The command is set out like this:
Code:
goto     [pointer]
Now we've covered that, let's get back to what we were looking at, which were the beginnings of scripts 1, 2 and 3.
Look at the similarities between each one:
Code:
#dynamic 0x800000

#org @start
setvar 0x4003 0x0
goto 0x8017CC
end
Code:
#dynamic 0x800000

#org @start
setvar 0x4003 0x1
goto 0x8017CC
end
Code:
#dynamic 0x800000

#org @start
setvar 0x4003 0x2
goto 0x8017CC
end
Obviously, 0x8017CC is @script. How did I get that pointer?
Let's compile Script 1 into the ROM. After it's been burnt to the ROM, we should see a list of the different names of the pointers.
We should have something like this:
Quote:
Originally Posted by XSE
@start 8007E6
@script 80083C
@done 80086D
@left 80089E
@middle 8008CF
...etc....
We need to take that pointer that is after @script. That is our pointer that we will use with Scripts 2 and 3.
If I were to use these pointers as an example, my Script 2 would be something like this:
Code:
#dynamic 0x800000

#org @start
setvar 0x4003 0x2
goto 0x80083C
end
I'd say that's all on setvar.... for now.
Resetvars

This command doesn't reset every variable, just 0x8000, 0x8001 and 0x8002.
It's just command resetvars. It doesn't need any extra arguments. All it needs it this:
Code:
resetvars

Last edited by Diegoisawesome; 27th July 2014 at 07:43 AM.
Diegoisawesome is offline   Reply With Quote