The PokéCommunity Forums

The PokéCommunity Forums (https://www.pokecommunity.com/index.php)
-   Binary ROM Hacking (https://www.pokecommunity.com/forumdisplay.php?f=284)
-   -   Script SOLVED [FireRed] Questions: Comparing & National Dex (https://www.pokecommunity.com/showthread.php?t=408440)

dot hash May 2nd, 2018 12:36 PM

SOLVED [FireRed] Questions: Comparing & National Dex
 
I am trying to make a script:
Check if the player has seen at least 10 PKMN in the national dex.
Then if they have, give them an Old Rod.
It seems to work.

Script:
Spoiler:

'---------------
#org 0x106473C
lock
faceplayer
checkflag 0x1011
if 0x1 goto 0x9064253
msgbox 0x9064269 MSG_FACE '"Ah... yes! Don't say a word! I can..."
setvar 0x8005 0x1
special 0xD4
compare 0x8005 0xA
if 0x0 goto 0x906425E
msgbox 0x90642BF MSG_FACE '"Crawling through caves...\pRunning..."
giveitem 0x106 0x1 MSG_OBTAIN
setflag 0x1011
msgbox 0x9064400 MSG_FACE '"That's my Old Rod, from when I\nfi..."
release
end

'---------------
#org 0x1064253
msgbox 0x90644F9 MSG_FACE '"Ah, yes. I hope that Old Rod will\..."
release
end

'---------------
#org 0x106425E
msgbox 0x9064559 MSG_FACE '"Hmm... Or maybe not...\nListen, co..."
release
end


'---------
' Strings
'---------
#org 0x1064269
= Ah... yes! Don't say a word! I can\ntell you are the kind of kid who\lgets around!...

#org 0x10642BF
= Crawling through caves...\pRunning through fields...\pClimbing great mountains...\pCrossing huge oceans!\pSneaking into secret hideouts!\pSeeking out hidden temples and\nancient ruins!\pBusting into the houses of\ninnocent civilians and running\laround their rooms searching for\litems! Haha! I love a good\ladventure! Listen up!

#org 0x1064400
= That's my Old Rod, from when I\nfirst went out to study and catch\lPokémon. Now I know some people\lsay Old Rods can't catch anything\lgood! But listen, kid! I've caught\lplenty of baby Water type Pokémon\lwith that rod, and raised them to\lbe powerful!

#org 0x10644F9
= Ah, yes. I hope that Old Rod will\nhelp you out! Remember, there are\lother types of Rods, too!

#org 0x1064559
= Hmm... Or maybe not...\nListen, come see me after you have\lseen at least 10 kinds of Pokémon,\lI'll give you something to help\lyour adventuring! You don't have\lto catch them, just collect 10 in\lyour Pokédex as seen!


Two things I am not 100% sure about:

-Is this the right way to check if it is 10 or greater?
Or will this only allow it if it is exactly 10?
So there is another way to compare to 10 or greater than 10?

-Secondly, I had a bug in one test where even if I had seen 10, it did not work.
Am I correctly checking the 8005 variable?
I think special D4 writes national dex seen PKMN data there?
Is it affected by something else?

Thanks. :)

DrFuji May 2nd, 2018 2:34 PM

Quote:

Originally Posted by dot hash (Post 9871996)
-Is this the right way to check if it is 10 or greater?
Or will this only allow it if it is exactly 10?
So there is another way to compare to 10 or greater than 10?

The 'if' command has a number of mathematical operations it can use when comparing a variables value. diegoisawesome's XSE tutorial lists them so I'll quote them here:

Code:

Lower Than (0x0)
Equals (0x1)
Greater Than (0x2)
Lower than or Equal to (0x3)
Greater than or Equal to (0x4)
Not exactly equal to (0x5)


So while you used 'if 0x0' correctly in your script, there are other ways to achieve the same result if you have the syntax right.

Quote:

Originally Posted by dot hash (Post 9871996)
Secondly, I had a bug in one test where even if I had seen 10, it did not work.
Am I correctly checking the 8005 variable?
I think special D4 writes national dex seen PKMN data there?
Is it affected by something else?

Yep, you're checking 0x8005 correctly. Special 0xD4 doesn't automatically check the National Dex though. If 0x8004 is equal to 0x0 it will check the Regional Dex, if it is any other value it will check the National Dex.

I'm pretty sure that line nine of your script (setvar 0x8005 0x1) is meant to be altering 0x8004 to check the National Dex instead. Perhaps that's why it didn't work one time? You saw too many post-151 Pokemon so you didn't see 10 in the regional Dex.

As an aside, as you're hacking FR, you're using some pretty dangerous flags. Flags above 0x900 start interferring with variables and that can cause a lot of problems. I'd strongly suggest reading this thread to learn which flags you should be using.

dot hash May 2nd, 2018 3:20 PM

Quote:

Originally Posted by DrFuji (Post 9872020)

Thankyou, this is very helpful.
I had read about the flags, but forgot, there is a lot for me to take in the last couple of weeks of learning. :)
All questions answered really great!


All times are GMT -8. The time now is 9:14 AM.


Like our Facebook Page Follow us on Twitter © 2002 - 2018 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2016 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.

Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.