This Covering A lot Important for hacking Lets go
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
This one can you make a lot of options Numbers in range. Cool
if i want to make 1 more ill do this
compare 0x800D 0x3
if 0x1 goto @option4
Thats it i think
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.
Thats it Took Long Time to me to convert it from legends of dragon.
I know Diego have done it Kinda!
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
See again Thats Alot!
Thank to diegoisawesome For learning me to script.
And remeber Hackmew For Xse!
Preety Cool!
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
This one can you make a lot of options Numbers in range. Cool
if i want to make 1 more ill do this
compare 0x800D 0x3
if 0x1 goto @option4
Thats it i think
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.
Thats it Took Long Time to me to convert it from legends of dragon.
I know Diego have done it Kinda!
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
See again Thats Alot!
Thank to diegoisawesome For learning me to script.
And remeber Hackmew For Xse!
Preety Cool!