• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Scripting Nicknames for New Pokemon (XSE) (FireRed/LeafGreen)

78
Posts
15
Years
I'm fairly average when it comes to my knowledge of scripting, and one thing that caused me some difficulty was successfully writing a script that allowed me to nickname a Pokemon that an NPC had given me after I already had Pokemon in my party. Time and time again I found myself staring at the "????????" on the nickname screen or nicknaming the Pokemon that was in the first position in my party instead of the one I had just received. After finally discovering the answer by dissecting different posts of different threads, I understand perfectly how it works.

Before we get started, here are the two main tutorials that I used to learn how to script using XSE:
diegoisawesome's Scripting Tutorial
tajaros's Scripting Tutorial
Please use these if you don't have a basic knowledge of scripting, as I will not be going over the fundamentals.

The two topics I'll be addressing:

  • Nickname Script for the First Pokemon You Receive
  • Nickname Script for a Pokemon You Receive in the Middle of the Game

First Pokemon You Receive
If you have a basic knowledge of scripting, you should have no difficulty writing a script that includes a nickname option for, say, the starter Pokemon in your hack. That being said, I might as well go over it a little bit.

Spoiler:


Firstly we see the flag 0x828. For Fire Red/Leaf Green hackers, this is the flag for enabling the Pokemon menu. You can find the flags for other games in the above tutorials I mentioned.

compare 0x800D 0x1 follows. 0x800D is the variable for LASTRESULT, and 0x1 means true or yes. So what the script is telling the game here is basically this: Compare the last result to the answer "Yes."

The next line says if 0x1 call @nickname. So the script is telling the game: If the answer was "Yes" (0x1), call the pointer @nickname. If the answer was not "Yes," the script releases the player and ends.

Now we call the @nickname pointer and setvar 0x8004 0x0, which is needed in order to tell the game the position of a Pokemon in our party. The rule for the value that describes a Pokemon's place in the party will be explained a bit later. Then we see the generic fadescreen 0x1 effect, and then special 0x9E. Once again, this is the command for the nickname event in Fire Red/Leaf Green. waitstate will make the game wait until you're done with the nickname, and return should be obvious to those who know the basics of scripting.

So there you have it. That's all there is to nicknaming the first Pokemon to arrive in your party. Now comes the part that gave me so much grief.

Pokemon You Receive in the Middle of the Game
The key commands we'll be going over are countpokemon, subvar and copyvar.

Spoiler:


The first difference we see here is that I entered the command countpokemon. Obviously this tells the game to count the number of Pokemon in my party. The command after that in the script is compare 0x800D 0x6, which just tells the game to compare the LASTRESULT (which is the number of Pokemon in our party) to the number 6. This little portion isn't relevant to the nickname business I'm covering. This is simply telling the game that, if you have 6 Pokemon in your party already, you will not receive the Pokemon and a message will be displayed that says, "You have no room for it!"

Okay, now we'll go on to the nickname stuff.

Spoiler:


Later on down in the script, after we call the pointer @nickname, we see countpokemon again, and then we see subvar 0x800D 0x1. This command tells the game to subtract 1 from the LASTRESULT observed, which is simply the number of Pokemon in our party (because of countpokemon). So, say for example, we have 4 Pokemon in our party (including the one we just received and want to nickname - in this case, ELECTABUZZ). The command countpokemon tells the game that we do indeed have 4 Pokemon in our party. Then, subvar 0x800D 0x1 subtracts 1 from that number, so the game has now stored the value of 3. This is relevant because a Pokemon's position in the party lineup is actually equal to [Position] - 1. diegoisawesome pointed this out in his tutorial.

Now, the Pokemon we just received and want to nickname is indeed the 4th Pokemon in our party. However, because of the rule [Position] - 1, its actual position in our party is read by the game as 0x3, not 0x4.

Because of this, we use copyvar 0x8004 0x800D. This copies the value of 0x3 and essentially "pastes" it into the variable 0x8004. So now the game knows that we will be nicknaming the Pokemon in position 0x3 of our party.

After all that, the script proceeds to use special 0x9E. The nickname command should run smoothly and you should be able to nickname the Pokemon you just received instead of something else, like "?????" or the first Pokemon in your party.

I do hope this helped some newbies like me understand how to efficiently write a full givepokemon script with a smooth nickname command and all. If you have questions feel free to ask, of course. This was my first tutorial so I'm sure it was very rough around the edges.
 
Last edited:

Astraea

The Storm of Friendship
2,107
Posts
10
Years
  • Age 25
  • IDK
  • Seen Jan 23, 2022
I didn't understand copy var and can you give a script by which an event will trigger when you'll have a bulbasaur with you and will not if you dont? And a script- Suppose if i have a bulbasaur then a bulbasaur OW will appear and if i have an ivysaur then ivysaur OW will appear!
 
78
Posts
15
Years
I didn't understand copy var and can you give a script by which an event will trigger when you'll have a bulbasaur with you and will not if you dont? And a script- Suppose if i have a bulbasaur then a bulbasaur OW will appear and if i have an ivysaur then ivysaur OW will appear!

Okay, I will try to explain it more.

In truth, the simplest way to describe copyvar is that it tells the game to make a variable equal to the value of another variable. So, when we tell the game copyvar 0x8004 0x800D, we are telling it to make the value of 0x8004 equal to the value of 0x800D, which is the LASTRESULT. Again, this is crucial to understand - the variable 0x800D is the LASTRESULT.

So, in our script, what is the LASTRESULT? Since we used the command countpokemon, the LASTRESULT that the game acquired is simply the number of Pokemon in our party (in my example, I said I had 4 Pokemon in my party). Therefore, the game now knows that 4 is the value of the LASTRESULT, also known as 0x800D.

Remember, I said that a Pokemon's position in the party is equal to [Position] - 1. This can be confusing, I understand. Say I have a Pokemon in the 4th spot of my party. What does that mean? It means that, to the game, its actual position is 0x3, because [4] - 1 = 3, and 3 in hex is 0x3.

Now, when using copyvar, it must be written like this:
copyvar [variable you want to insert a value into] [variable from which you are copying a value].

So, knowing this, we use copyvar 0x8004 0x800D because we are telling the game to copy the value of 0x800D (LASTRESULT) and insert it into 0x8004. This is because 0x8004 is the variable used by the game when dealing with certain Pokemon in the party.

I hope that made things more clear. If not, I will continue to try to help. I am a patient person. It may also help to check out diegoisawesome's tutorial (the link can be found in my original post). He talks about copyvar as well.

Now, moving on to your other questions.

In order to do what you asked, you have to make the game check if you have Bulbasaur in your party.

This is done by first telling the game to set the variable 0x8004 equal to the value of Bulbasaur himself. What is Bulbasaur's value? It is his Pokemon number in hex. His Pokemon number is 1, so in hex it's 0x1. So, we would write: setvar 0x8004 0x1.


After this, we will use the command special2 0x800D 0x17C. This tells the game to check if the LASTRESULT (0x800D) is in your party. What is the LASTRESULT? It's 0x1. What is 0x1? It's Bulbasaur! 0x1 is the LASTRESULT observed by the game because we set the variable 0x8004 to the value of 0x1 in our last command.

Then, we use compare 0x800D 0x1. This, once again, tells the game to check if the LASTRESULT is true (remember, 0x1 when dealing with compare means true or yes).

Here is the full script that I wrote:
Spoiler:


So, if we have a Bulbasaur in our party, a message will be displayed that says "Yes! I have a BULBASAUR!" If not, nothing will happen. (At the end of the script I wrote setvar 0x4039 0x2 so that the script would not repeat itself.) Obviously, you could change the script to be much more than a simple message appearing. If you wanted you could make it a lot more complex, like including a trainerbattle or whatever.

As for making an OW sprite of Bulbasaur appear, you would have to import a Bulbasaur OW sprite into the game and then place it on a map in Advance Map. Then you'd have to make him invisible by either using a level script or strategically placed script tile(s) that hides the sprite and sets a flag. Then, when you would want Bulbasaur's sprite to show up, you would use the commands clearflag and showsprite.

Ask if you have more questions.
 
Last edited:

Astraea

The Storm of Friendship
2,107
Posts
10
Years
  • Age 25
  • IDK
  • Seen Jan 23, 2022
Okay, I will try to explain it more. In truth, the simplest way to describe copyvar is that it tells the game to make a variable equal to the value of another variable. So, when we tell the game copyvar 0x8004 0x800D, we are telling it to make the value of 0x8004 equal to the value of 0x800D, which is the LASTRESULT. Again, this is crucial to understand - the variable 0x800D is the LASTRESULT. So, in our script, what is the LASTRESULT? Since we used the command countpokemon, the LASTRESULT that the game acquired is simply the number of Pokemon in our party (in my example, I said I had 4 Pokemon in my party). Therefore, the game now knows that 4 is the value of the LASTRESULT, also known as 0x800D. Remember, I said that a Pokemon's position in the party is equal to [Position] - 1. This can be confusing, I understand. Say I have a Pokemon in the 4th spot of my party. What does that mean? It means that, to the game, its actual position is 0x3, because [4] - 1 = 3, and 3 in hex is 0x3. Now, when using copyvar, it must be written like this: copyvar [variable you want to insert a value into] [variable from which you are copying a value]. So, knowing this, we use copyvar 0x8004 0x800D because we are telling the game to copy the value of 0x800D (LASTRESULT) and insert it into 0x8004. This is because 0x8004 is the variable used by the game when dealing with certain Pokemon in the party. I hope that made things more clear. If not, I will continue to try to help. I am a patient person. It may also help to check out diegoisawesome's tutorial (the link can be found in my original post). He talks about copyvar as well. Now, moving on to your other questions. In order to do what you asked, you have to make the game check if you have Bulbasaur in your party. This is done by first telling the game to set the variable 0x8004 equal to the value of Bulbasaur himself. What is Bulbasaur's value? It is his Pokemon number in hex. His Pokemon number is 1, so in hex it's 0x1. So, we would write: setvar 0x8004 0x1. After this, we will use the command special2 0x800D 0x17C. This tells the game to check if the LASTRESULT (0x800D) is in your party. What is the LASTRESULT? It's 0x1. What is 0x1? It's Bulbasaur! 0x1 is the LASTRESULT observed by the game because we set the variable 0x8004 to the value of 0x1 in our last command. Then, we use compare 0x800D 0x1. This, once again, tells the game to check if the LASTRESULT is true (remember, 0x1 when dealing with compare means true or yes). Here is the full script that I wrote:
Spoiler:
So, if we have a Bulbasaur in our party, a message will be displayed that says "Yes! I have a BULBASAUR!" If not, nothing will happen. (At the end of the script I wrote setvar 0x4039 0x2 so that the script would not repeat itself.) Obviously, you could change the script to be much more than a simple message appearing. If you wanted you could make it a lot more complex, like including a trainerbattle or whatever. As for making an OW sprite of Bulbasaur appear, you would have to import a Bulbasaur OW sprite into the game and then place it on a map in Advance Map. Then you'd have to make him invisible by either using a level script or strategically placed script tile(s) that hides the sprite and sets a flag. Then, when you would want Bulbasaur's sprite to show up, you would use the commands clearflag and showsprite. Ask if you have more questions.
Well that enough info, i wanted but i'll contact you in the future for help.
 
Back
Top