• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • 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.

[Script] Flags and checkflags

Hi. I am making a Rom hack and I don't really understand what are flags and checkflags. Please give an example also

Flags are one of the ways the game uses to mark your progression. If an event is only meant to happen once, a flag is set in that script so that on subsequent interactions the script will do something different. Here's an example for a script in XSE:

Code:
#dynamic 0x800000

#org @start
checkflag 0x200
if 0x1 goto @skip
msgbox @hello 0x2
setflag 0x200
release
end

#org @skip
msgbox @goodbye 0x2
clearflag 0x200
release
end

#org @hello
= Hello.

#org @goodbye
= Goodbye.

If you were to compile the above script and apply it to an NPC they will cycle between saying hello and goodbye each time you talk to them. I'm telling the game to check if a flag has been set - if it has been set, it will go to @goodbye, while if it hasn't it will continue the rest of the first script block as usual. Furthermore, I've either set or cleared the flag in both instances to have the script continuously flip between hello and goodbye. If I only wanted the NPC to say hello once and then say goodbye forever I would delete the cleaflag command.

There are a few other things that flags can do, namely:
  • Make NPCs appear and disappear
  • Allow you to fly to locations you've visited on the world map
  • Activate the National Dex
  • Get special items such as the Running Shoes and Pokedex

I'd suggest reading this thread if you would like some more detailed information on flags (especially if you're hacking Fire Red) or just generally read scripting tutorials as some have good introductions to how flags work. Hopefully this has been helpful~
 
Back
Top