• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • 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