Trading pokemon was a mighty difficult thing to figure out. However, it is quite interesting. This script uses many special commands and var value transferring. There are some weaknesses to this script.
1. Trading pokemon isn't a "free-style" feature in Pokemon FR/LG (I didn't check R/S/E yet). This means that the game built some commands for this feature, and only these commands work. To explain in more simpler terms, you can't choose which pokemon to trade/receive, but are only allowed to use what the game decides.
2. The restriction stated above would probably make any person not want to learn how to do this. Why learn trading pokemon when you can only use the pokemon the game has set? You're better off just copy/pasting or implementing the scripts the game already uses, since the scripts I rewrote from scratch will be an exact replica.
However, don't feel discouraged. Even though trading pokemon is probably a disappointment, there are many new commands that I've learned from this script. I would still like to show you guys their uses, as it might come handy in the future.
Now, you guys are all familiar with how trading pokemon works, correct? If not, I will briefly describe the process. A person will ask if you have a certain pokemon, and if you would like to trade the pokemon. You may pick "yes", or "no". If you pick yes, you will go into your party, and be able to select a pokemon. If you pick no, the NPC will say something, and the script will end. Now, after you select a pokemon from the 'yes' branch, the game checks to see if the value of the pokemon matches the value of the pokemon the NPC wants. If it does, a special event will trigger showing a "trading" process. If it doesn't, the NPC will say that the pokemon you selected is not what he/she wants, and the event will end. If the trade was a success, after you talk to this NPC, the NPC will ask about his/her pokemon's condition in your hands.
1. Trading pokemon isn't a "free-style" feature in Pokemon FR/LG (I didn't check R/S/E yet). This means that the game built some commands for this feature, and only these commands work. To explain in more simpler terms, you can't choose which pokemon to trade/receive, but are only allowed to use what the game decides.
2. The restriction stated above would probably make any person not want to learn how to do this. Why learn trading pokemon when you can only use the pokemon the game has set? You're better off just copy/pasting or implementing the scripts the game already uses, since the scripts I rewrote from scratch will be an exact replica.
However, don't feel discouraged. Even though trading pokemon is probably a disappointment, there are many new commands that I've learned from this script. I would still like to show you guys their uses, as it might come handy in the future.
Now, you guys are all familiar with how trading pokemon works, correct? If not, I will briefly describe the process. A person will ask if you have a certain pokemon, and if you would like to trade the pokemon. You may pick "yes", or "no". If you pick yes, you will go into your party, and be able to select a pokemon. If you pick no, the NPC will say something, and the script will end. Now, after you select a pokemon from the 'yes' branch, the game checks to see if the value of the pokemon matches the value of the pokemon the NPC wants. If it does, a special event will trigger showing a "trading" process. If it doesn't, the NPC will say that the pokemon you selected is not what he/she wants, and the event will end. If the trade was a success, after you talk to this NPC, the NPC will ask about his/her pokemon's condition in your hands.
trade_pokemon_example.pks | |
File Size: | 2 kb |
File Type: | pks |
The script above is a script the game used. I believe it is in the house just south of Pewter City, next to the Diglett Cave. The person wants an Abra, and will trade you a Mr. Mime. Now, this is a compiled script from the game, so it doesn't look very pretty. I will write my own version of the trade pokemon script, but it will be very similar to the ones the game uses. My purpose is to provide a script that looks neater than the ugly compiled script.
New commands:
copyvar - copies the value of one var to a new var.
copyvar 0x(var # 1) 0x(var # 2) is the format. Var #2 will be the var that gets its value copied, and var #1 will have the value of var #2 as it's new value. This will override the old var value of var #1.
Ex. Say I have var 0x5563 with a value of 5 (0x5), and a var 0x8432 with a value of 7 (0x7). If I use 'copyvar 0x5563 0x8432', the game will replace the old value of 0x5563, which was 5, with the value of 0x8432. Now, 0x5563 has a var value of 7.
special2 - This command, as I have seen used so far, plays with the "LASTRESULT". It will "transform" regular data into a new language, for events, and save that "transformed" data into the LASTRESULT. There are 2 times where this script uses this command. I will explain them both.
special2 LASTRESULT (usually) 0x(something) is the format. I mention usually for the first value because I have only seen LASTRESULT as the first value. I don't know if other values can substitute LASTRESULT for different effects. The second value depends on the situation you are in.
0xFC - This is used only for trading pokemon. If you guys notice, a var is set at the beginning of the script. After that, you will jump to one offset that copies the set var's value to another var. Then, you see the special2 line used. Using 0xFC, the game will transform the value of the var to correspond to a special situation. In trading pokemon, a value will correspond to 2 different variables. The variables are set into \v\h02 and \v\h03. special2 LASTRESULT 0xFC will "translate" the identified variable value to use for trading pokemon. Each value will result in 2 different pokemon, one requested pokemon and one pokemon to be traded.
0x0 will make the requested pokemon an ABRA. The traded pokemon will be MR MIME.
0x1 will make the requested pokemon a POLYWHIRL. The traded pokemon will be JYNX.
0x2 will make the requested pokemon a male NIDORAN. The traded pokemon will be a female NIDORAN.
0x3 will make the requested pokemon a SPEAROW. The traded pokemon will be a FARFETCH'D.
0x4 will make the requested pokemon a NIDORINO. The traded pokemon will be NIDORINA.
0x5 will make the requested pokemon a GOLDUCK. The traded pokemon will be a LICKITUNG.
0x6 will make the requested pokemon a RAICHU. The traded pokemon will be a ELECTRODE.
0x7 will make the requested pokemon a VENONAT. The traded pokemon will be a TANGULA.
0x8 will make the requested pokemon a PONYTA. The traded pokemon will be a SEEL.
NOTE: You should use the vars the game uses. I tried different vars, and they came out with different results.
0xFF - I don't know too much about this one. However, I think it does the opposite of 0xFC. 0xFC translates a hex number value into 2 corresponding pokemons. I believe 0xFF will translate the pokmon you selected into a hex number value. This command is used after you select your pokemon from the party. I do not know what the values of each pokemon will translate to, nor do I know if this is how the game uses this command. Sorry, this is still an enigma to me.
comparevars2 - This will compare the var values of 2 vars.
comparevars2 0x(var #1) 0x(var #2) is the format. Very straightforward.
special - This allows special events to occur in the game. They are built into the game, so they are known as "special". The ones this script uses are "select from your party", and "trading the pokemon". If you looked at my setmaptile tutorial, you will find another special command to allow setmaptile to work.
special 0x(something) is the format.
0x9F - This will pull up your party. In this menu, you can select one pokemon from your party. If you continue to look down the script below "special 0x9F", the lines below will basically save the pokemon you selected to a var.
0xFD and 0xFE - I put these 2 together because they are always used together. I don't know what each does separately. However, I know that these 2 are responsible for the "trading pokemon sequence" to occur. Possibly, 0xFD will show the "cutscene" where you trade the pokemon, and 0xFE will replace the requested pokemon in your party with the traded pokemon.
storepokemon - This will store the value of a pokemon into the adaptable variable \v\h02. This script uses this line because after you select a pokemon, the pokemon you select will be stored in \v\h02. When the NPC says that the pokemon you selected is not the one he/she wants, you use a storepokemon command to store the desired pokemon back into \v\h02.
storepokemon 0x(something) 0x(var) is the format.
Now we shall write a script. I want to use the trade where you can get a Jynx.
#dyn 0x740000
#org @main
lock
faceplayer
Since I want to get a Jynx, I will use a var with the value of 1. Find which pair you want, and use the corresponding value.
setvar 0x8008 0x1
Now, we must tell the game we want to use a special2 to allowing pokemon trading. Beforehand, we should save the original to a new var as well. Afterwards, we'll save the translated version of the var value to another var.
copyvar 0x8004 0x8008
special2 LASTRESULT 0xFC
copyvar 0x8009 LASTRESULT
checkflag 0xABCD
if == jump @alreadydone
message @ask
callstd MSG_YESNO
compare LASTRESULT NO
if == jump @endscript
This is where we add in the menu selection part.
special 0x9F
waitspecial
lock
faceplayer
copyvar 0x800A 0x8004
This part will check if the player clicked "B" when in the pokemon selection menu.
compare 0x8004 0x6
if >= jump @playerclickedB
Now it's time to convert the pokemon value into a hex value. This allows us to compare, to see if the selected pokemon is indeed the pokemon the NPC is requesting. To do that, we require another special2 command.
copyvar 0x8005 0x800A
special2 LASTRESULT 0xFF
copyvar 0x800B LASTRESULT
Now we compare to see if the selected pokemon is the desired pokemon. If it is, we allow the trade. If now, we do not allow it.
comparevars2 LASTRESULT 0x8009
if != jump @notrightpokemon
What we will continue shall be the main offset (not going to the "notrightpokemon"). We now writing the 'trading' part. What we do is switch the values of the pokemon you selected and the pokemon you are getting. We also trigger a cut scene to show you the trade.
copyvar 0x8004 0x8008
copyvar 0x8005 0x800A
special 0xFD
special 0xFE
waitspecial
lock
faceplayer
message @thankyou
callstd MSG_NORMAL
release
end
We are done with the main body. Finish the other bodies.
#org @alreadydone
message @howisit
callstd MSG_NORMAL
release
end
#org @endscript
message @notrade
callstd MSG_NORMAL
release
end
#org @playerclickedB
message @nevermind
callstd MSG_NORMAL
release
end
#org @notrightpokemon
storepokemon 0x0 0x800
message @notit
callstd MSG_NORMAL
release
end
After everything, the ending result should look something like this.
New commands:
copyvar - copies the value of one var to a new var.
copyvar 0x(var # 1) 0x(var # 2) is the format. Var #2 will be the var that gets its value copied, and var #1 will have the value of var #2 as it's new value. This will override the old var value of var #1.
Ex. Say I have var 0x5563 with a value of 5 (0x5), and a var 0x8432 with a value of 7 (0x7). If I use 'copyvar 0x5563 0x8432', the game will replace the old value of 0x5563, which was 5, with the value of 0x8432. Now, 0x5563 has a var value of 7.
special2 - This command, as I have seen used so far, plays with the "LASTRESULT". It will "transform" regular data into a new language, for events, and save that "transformed" data into the LASTRESULT. There are 2 times where this script uses this command. I will explain them both.
special2 LASTRESULT (usually) 0x(something) is the format. I mention usually for the first value because I have only seen LASTRESULT as the first value. I don't know if other values can substitute LASTRESULT for different effects. The second value depends on the situation you are in.
0xFC - This is used only for trading pokemon. If you guys notice, a var is set at the beginning of the script. After that, you will jump to one offset that copies the set var's value to another var. Then, you see the special2 line used. Using 0xFC, the game will transform the value of the var to correspond to a special situation. In trading pokemon, a value will correspond to 2 different variables. The variables are set into \v\h02 and \v\h03. special2 LASTRESULT 0xFC will "translate" the identified variable value to use for trading pokemon. Each value will result in 2 different pokemon, one requested pokemon and one pokemon to be traded.
0x0 will make the requested pokemon an ABRA. The traded pokemon will be MR MIME.
0x1 will make the requested pokemon a POLYWHIRL. The traded pokemon will be JYNX.
0x2 will make the requested pokemon a male NIDORAN. The traded pokemon will be a female NIDORAN.
0x3 will make the requested pokemon a SPEAROW. The traded pokemon will be a FARFETCH'D.
0x4 will make the requested pokemon a NIDORINO. The traded pokemon will be NIDORINA.
0x5 will make the requested pokemon a GOLDUCK. The traded pokemon will be a LICKITUNG.
0x6 will make the requested pokemon a RAICHU. The traded pokemon will be a ELECTRODE.
0x7 will make the requested pokemon a VENONAT. The traded pokemon will be a TANGULA.
0x8 will make the requested pokemon a PONYTA. The traded pokemon will be a SEEL.
NOTE: You should use the vars the game uses. I tried different vars, and they came out with different results.
0xFF - I don't know too much about this one. However, I think it does the opposite of 0xFC. 0xFC translates a hex number value into 2 corresponding pokemons. I believe 0xFF will translate the pokmon you selected into a hex number value. This command is used after you select your pokemon from the party. I do not know what the values of each pokemon will translate to, nor do I know if this is how the game uses this command. Sorry, this is still an enigma to me.
comparevars2 - This will compare the var values of 2 vars.
comparevars2 0x(var #1) 0x(var #2) is the format. Very straightforward.
special - This allows special events to occur in the game. They are built into the game, so they are known as "special". The ones this script uses are "select from your party", and "trading the pokemon". If you looked at my setmaptile tutorial, you will find another special command to allow setmaptile to work.
special 0x(something) is the format.
0x9F - This will pull up your party. In this menu, you can select one pokemon from your party. If you continue to look down the script below "special 0x9F", the lines below will basically save the pokemon you selected to a var.
0xFD and 0xFE - I put these 2 together because they are always used together. I don't know what each does separately. However, I know that these 2 are responsible for the "trading pokemon sequence" to occur. Possibly, 0xFD will show the "cutscene" where you trade the pokemon, and 0xFE will replace the requested pokemon in your party with the traded pokemon.
storepokemon - This will store the value of a pokemon into the adaptable variable \v\h02. This script uses this line because after you select a pokemon, the pokemon you select will be stored in \v\h02. When the NPC says that the pokemon you selected is not the one he/she wants, you use a storepokemon command to store the desired pokemon back into \v\h02.
storepokemon 0x(something) 0x(var) is the format.
Now we shall write a script. I want to use the trade where you can get a Jynx.
#dyn 0x740000
#org @main
lock
faceplayer
Since I want to get a Jynx, I will use a var with the value of 1. Find which pair you want, and use the corresponding value.
setvar 0x8008 0x1
Now, we must tell the game we want to use a special2 to allowing pokemon trading. Beforehand, we should save the original to a new var as well. Afterwards, we'll save the translated version of the var value to another var.
copyvar 0x8004 0x8008
special2 LASTRESULT 0xFC
copyvar 0x8009 LASTRESULT
checkflag 0xABCD
if == jump @alreadydone
message @ask
callstd MSG_YESNO
compare LASTRESULT NO
if == jump @endscript
This is where we add in the menu selection part.
special 0x9F
waitspecial
lock
faceplayer
copyvar 0x800A 0x8004
This part will check if the player clicked "B" when in the pokemon selection menu.
compare 0x8004 0x6
if >= jump @playerclickedB
Now it's time to convert the pokemon value into a hex value. This allows us to compare, to see if the selected pokemon is indeed the pokemon the NPC is requesting. To do that, we require another special2 command.
copyvar 0x8005 0x800A
special2 LASTRESULT 0xFF
copyvar 0x800B LASTRESULT
Now we compare to see if the selected pokemon is the desired pokemon. If it is, we allow the trade. If now, we do not allow it.
comparevars2 LASTRESULT 0x8009
if != jump @notrightpokemon
What we will continue shall be the main offset (not going to the "notrightpokemon"). We now writing the 'trading' part. What we do is switch the values of the pokemon you selected and the pokemon you are getting. We also trigger a cut scene to show you the trade.
copyvar 0x8004 0x8008
copyvar 0x8005 0x800A
special 0xFD
special 0xFE
waitspecial
lock
faceplayer
message @thankyou
callstd MSG_NORMAL
release
end
We are done with the main body. Finish the other bodies.
#org @alreadydone
message @howisit
callstd MSG_NORMAL
release
end
#org @endscript
message @notrade
callstd MSG_NORMAL
release
end
#org @playerclickedB
message @nevermind
callstd MSG_NORMAL
release
end
#org @notrightpokemon
storepokemon 0x0 0x800
message @notit
callstd MSG_NORMAL
release
end
After everything, the ending result should look something like this.
finished_script.pks | |
File Size: | 1 kb |
File Type: | pks |
Here, we are at the end. This lesson was probably a huge disappointment. I wanted to add my own pokemon to trade and receive, and you guys probably did too. However, I couldn't find a way. If anyone does find a way to do this, please tell me. Anyways, thanks for reading as always. Go and check out the other stuff I posted.