• 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?".
  • Forum moderator applications are now open! Click here for details.
  • 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.

Flags, Vars, & Script Tiles

252
Posts
10
Years
  • Age 27
  • Seen Jul 6, 2019
You say only these vars x-y are safe, yet you say they can be any value upto 65000, does that mean every other one is used, or am I missing something major here?
You are missing something lol. You have to distinguish between the var itself and the var value. What happens with a variable is that you assign a value to the variable itself. Think of it like algebra where you say x or y is equal to 1 or something like that. You can assign a value up to 0xFFFF, which is why there can be 65000 values for a variable. But you have limits on the variables themselves. Some are safe, some are not.
 

karatekid552

What happens if I push it?....
1,771
Posts
11
Years
Yes, that is what I mean.

Let me explain it slightly differently using a rice and cup analogy: each var is a cup. That cup is pretty big as it can hold ~65000 pieces of rice (0xFFFF, 2 bytes). Now, just because it can hold that many pieces, doesn't mean it has to. The cup could be empty, it could have just 2 pieces of rice, or it could have 30,000. It all depends on how many you put in it. Vars are like that cup of rice, each one can hold a number between 0x0 and 0xFFFF (~65,000 or 256*256). So when you use set var, you are filling the cup with that number after first dumping it out. If you use addvar and subvar, you will be adding that much rice to the cup or taking away that much rice, respectively.

More clear?
 
55
Posts
10
Years
  • Age 27
  • Seen Oct 18, 2014
Yes, that is what I mean.

Let me explain it slightly differently using a rice and cup analogy: each var is a cup. That cup is pretty big as it can hold ~65000 pieces of rice (0xFFFF, 2 bytes). Now, just because it can hold that many pieces, doesn't mean it has to. The cup could be empty, it could have just 2 pieces of rice, or it could have 30,000. It all depends on how many you put in it. Vars are like that cup of rice, each one can hold a number between 0x0 and 0xFFFF (~65,000 or 256*256). So when you use set var, you are filling the cup with that number after first dumping it out. If you use addvar and subvar, you will be adding that much rice to the cup or taking away that much rice, respectively.

More clear?

So say I want to set a variable for the starters... I will use 0x4011 as the variable. Would it be like this: "0x4011 0x1" for Bulba, "0x4011 0x2" for Char, and "0x4011 0x3" for Squirt? Or would I use three different variables (4011-4013) respectively?
 

karatekid552

What happens if I push it?....
1,771
Posts
11
Years
So say I want to set a variable for the starters... I will use 0x4011 as the variable. Would it be like this: "0x4011 0x1" for Bulba, "0x4011 0x2" for Char, and "0x4011 0x3" for Squirt? Or would I use three different variables (4011-4013) respectively?

1. Don't use that var, it is temporary.

2. Why use 3 vars when it can be done with 1? Less is more bro, less is more. If you use 3, you may as well use flags instead since those can only be turned on and off.
 
4
Posts
9
Years
  • Age 27
  • Seen Jul 12, 2014
Thank you so much for this guide!

I was stuck with tiles scripting, but thanks to you I finally got around making it work! :D
 
10
Posts
9
Years
Hey there the tutorial was great but I still seem to be having some problems. I'm trying to create a script where the player takes a step back if he hasn't completed a certain requirement (Or activated a flag). However when I try it in game nothing winds up happening and I really don't know why. I'm fairly new to hacking pokemon so I would really appreciate some help I'll put the script here if you'd like to take a look at it.
Spoiler:
 
146
Posts
11
Years
  • CO
  • Seen Mar 16, 2023
Hey there the tutorial was great but I still seem to be having some problems. I'm trying to create a script where the player takes a step back if he hasn't completed a certain requirement (Or activated a flag). However when I try it in game nothing winds up happening and I really don't know why. I'm fairly new to hacking pokemon so I would really appreciate some help I'll put the script here if you'd like to take a look at it.
Spoiler:








Hello let me see if I may be able to help... Now I am not the best but I have done this one before...
Try this,

Code:
#dynamic 0x800000
#org @start
checkitem 0x4 0x1
compare LASTRESULT 0x1
if 0x1 call @yes
msgbox @nomsg 0x2
end
#org @yes
msgbox @yesmsg 0x6
applymovement 0x03 @move1
waitmovement 0x0
pause 0x30
end
#org @nomsg
= Nope, you don't have a Pokemon or\npokeballs. Tall grass is\ldangerous!
#org @yesmsg
= Aha, thanks for showing it to us.\nPlease proceed
#org @move1
#raw 0x13
#raw 0x11
#raw 0xFE

Now this script would have to be messed with for you to get it to work for you.
For instance the applymovements would differ and also this would move a Npc that is standing in the way of a door or something similar.. You can very easily change this to fit what you are wanting to do but in order to do so I really think it would do you wonders to read this tutorial
http://www.pokecommunity.com/showthread.php?t=164276
and really try to understand it by practicing everything at least 2 or 3 times. You will be a master scripter in no time ^_^
 
Last edited:

karatekid552

What happens if I push it?....
1,771
Posts
11
Years
Hey there the tutorial was great but I still seem to be having some problems. I'm trying to create a script where the player takes a step back if he hasn't completed a certain requirement (Or activated a flag). However when I try it in game nothing winds up happening and I really don't know why. I'm fairly new to hacking pokemon so I would really appreciate some help I'll put the script here if you'd like to take a look at it.
Spoiler:


Do you ever actually setflag 0x213??? If you don't then nothing will happen, just like you are getting right now.:P
 
10
Posts
9
Years
I did set the flag in a different script and it seemed to work, but I don't know why do anything in this one. I'll also put that script if you'd like to take a look at it.
Spoiler:
 

karatekid552

What happens if I push it?....
1,771
Posts
11
Years
I did set the flag in a different script and it seemed to work, but I don't know why do anything in this one. I'll also put that script if you'd like to take a look at it.
Spoiler:

What results do you get from this script?

Flag 0x213 is not known for any use. It may not exist and therefore result in reseting each time it is used by overwrite from other data.
 
35
Posts
10
Years
  • Age 37
  • Seen Jul 27, 2016
as you know, this flags/varibles have to be safe in the .sav, where are the offset for this, or where can i see for it on the ram
 

karatekid552

What happens if I push it?....
1,771
Posts
11
Years
as you know, this flags/varibles have to be safe in the .sav, where are the offset for this, or where can i see for it on the ram

In the ram, flags are shifted around by DMA every cycle of the mainloop. Using ASM and dumping the offset found by the flag return function is the only way to locate a flag at a specific cycle. I have long lost the offset of said function but it is labeled in Knizz's IDB file if I remember right.
 
88
Posts
14
Years
What are the flags in LeafGreen that are safe. I'm making a hack through Blue's perspective (and later Leaf's) and I think it'd be easier to use LeafGreen for the names at the beginning. There are multiple instances of the names when I look for them in A-text, so I don't want to screw anything up.
 
21
Posts
8
Years
  • Age 28
  • Seen Oct 27, 2015
This guide opens more questions than it gives answers. So, how many flags are you able to use then? And how do i know what specific flag to use? Also, if Im using Emerald 650 ROM Base, then how do I know what variables and flags to use?

Cant I just make up a flag number? like 569456 or something?
 
417
Posts
9
Years
  • Age 33
  • Seen Nov 20, 2016
This guide opens more questions than it gives answers.
Each question that you say this guide "opens" is addressed in the guide itself.

So, how many flags are you able to use then? And how do i know what specific flag to use?
Nearly the entire guide is a list of flags and vars, what they are for, and how to know whether or not they are safe to use. There are even lines in bold at the end saying:
Safe Flags:
->200-2FF
->Flags from events or OWs that have been removed

Safe Vars:
->0x4011-0x40FF
->Make sure you check the list! Some vars have specific functions!


Also, if Im using Emerald 650 ROM Base, then how do I know what variables and flags to use?
As the guide says, this is for FireRed. You'll have to look for/create an emerald list, though I'm pretty sure that there is currently at least flag list out there.

Cant I just make up a flag number? like 569456 or something?
From the guide:
So, let's explain the reasons why flags outside of those ranges aren't safe:

-Many are temporary. Meaning they get reset every time the map changes.
-500-700 are used for Trainer Flags.
-Flags over 900 take up the same space as variables.

That is pretty much it. Fairly simple, huh?
 
21
Posts
8
Years
  • Age 28
  • Seen Oct 27, 2015
Each question that you say this guide "opens" is addressed in the guide itself.
Obviously, but what you fail to realize is that noobs may read this, and a higher level of explanation may not register with people who don't quite grasp the concept but are looking to.

Nearly the entire guide is a list of flags and vars, what they are for, and how to know whether or not they are safe to use. There are even lines in bold at the end saying:
Numbers are nice. and saying 200-2FF and 0x4011-0x40FF is a list of flags and/or variables isn't quite illuminating. How do you choose one. How do you count from 200 to 2FF? Like I said, people may not know how numbers or variables increase, because letters are thrown into the mix, and i doubt all the letters cycle through Z before starting again (though i could be wrong).

As the guide says, this is for FireRed. You'll have to look for/create an emerald list, though I'm pretty sure that there is currently at least flag list out there.
Yes but why Im asking is because I don't know if information added (not scripts) could take up variables. Alot of information has been added into the Emerald 650, so I was inquiring how to figure this out or if you could explain to me that added pokemon, etc. does and does not take up variable space.

Thanks
 
3,830
Posts
14
Years
  • Age 26
  • OH
  • Seen Feb 26, 2024
Each question that you say this guide "opens" is addressed in the guide itself.
Obviously, but what you fail to realize is that noobs may read this, and a higher level of explanation may not register with people who don't quite grasp the concept but are looking to.

If you (or anyone else) are unable to understand the material contained here, it would be best to first read tutorials on such topics as basic hacking skills and in particular scripting.

Nearly the entire guide is a list of flags and vars, what they are for, and how to know whether or not they are safe to use. There are even lines in bold at the end saying:
Numbers are nice. and saying 200-2FF and 0x4011-0x40FF is a list of flags and/or variables isn't quite illuminating. How do you choose one. How do you count from 200 to 2FF? Like I said, people may not know how numbers or variables increase, because letters are thrown into the mix, and i doubt all the letters cycle through Z before starting again (though i could be wrong).

Numbers for flags/variables are counted in hexadecimal. https://en.wikipedia.org/wiki/Hexadecimal.
It's pretty much used all the time in hacking, so it's very important to know.

As the guide says, this is for FireRed. You'll have to look for/create an emerald list, though I'm pretty sure that there is currently at least flag list out there.
Yes but why Im asking is because I don't know if information added (not scripts) could take up variables. Alot of information has been added into the Emerald 650, so I was inquiring how to figure this out or if you could explain to me that added pokemon, etc. does and does not take up variable space.

Thanks

You're best off asking this question to the creator of the patch. Variables are stored in the GBA's/emulator's memory, while the changes we make when ROM hacking are stored in the ROM file. This means that unless the patch maker made changes (like events) that make use of specific variables/flags, then you'll need to know. Most likely there were very few if any flags/variables taken by the patch.
 
21
Posts
8
Years
  • Age 28
  • Seen Oct 27, 2015
If you (or anyone else) are unable to understand the material contained here, it would be best to first read tutorials on such topics as basic hacking skills and in particular scripting.



Numbers for flags/variables are counted in hexadecimal. https://en.wikipedia.org/wiki/Hexadecimal.
It's pretty much used all the time in hacking, so it's very important to know.



You're best off asking this question to the creator of the patch. Variables are stored in the GBA's/emulator's memory, while the changes we make when ROM hacking are stored in the ROM file. This means that unless the patch maker made changes (like events) that make use of specific variables/flags, then you'll need to know. Most likely there were very few if any flags/variables taken by the patch.

Thank you for not being sarcastic with me. I will message him/her eventually and check on that. I will also attempt to understand hexadecimal. It sounds really complicated but im sure its fairly simple once the concept is understood.
 
417
Posts
9
Years
  • Age 33
  • Seen Nov 20, 2016
Each question that you say this guide "opens" is addressed in the guide itself.
Obviously, but what you fail to realize is that noobs may read this, and a higher level of explanation may not register with people who don't quite grasp the concept but are looking to.

Nearly the entire guide is a list of flags and vars, what they are for, and how to know whether or not they are safe to use. There are even lines in bold at the end saying:
Numbers are nice. and saying 200-2FF and 0x4011-0x40FF is a list of flags and/or variables isn't quite illuminating. How do you choose one. How do you count from 200 to 2FF? Like I said, people may not know how numbers or variables increase, because letters are thrown into the mix, and i doubt all the letters cycle through Z before starting again (though i could be wrong).

As the guide says, this is for FireRed. You'll have to look for/create an emerald list, though I'm pretty sure that there is currently at least flag list out there.
Yes but why Im asking is because I don't know if information added (not scripts) could take up variables. Alot of information has been added into the Emerald 650, so I was inquiring how to figure this out or if you could explain to me that added pokemon, etc. does and does not take up variable space.

Thanks
You should understand that I was in no way being "sarcastic." The thing is, most people here will know how to count from 0x200 to 0x2FF. To most people, 0x4011-0x40FF is extremely illuminating. If they don't know it? That's fine, they can learn. But no one is a mind reader. Rather than ask about it, you made a list of questions that, from the perspective of most people reading the tutorial, were directly addressed. Without specifying what you didn't understand about it, it came across as you lazily skimming through the post. It looked like you hadn't even read everything, so I pointed you directly to where they were answered.

As for your question, Lost Heart pretty much answered it. I'll add that a quick glance at that Emerald 650 thread shows that the creator didn't change any events, so it seems unlikely, and also would be inexplicably irresponsible, for them to have changed around any in game flags for no reason.

Adding Pokemon to the game does take up caught/seen flags, but I would think they would have used an extra "save block" for those flags that shouldn't affect the normal flags you'd want to use for scripting.
 
Back
Top