#dynamic 0x800000
#org @start
checkflag 0x200 // This isn't really needed, but since I was trying to copy the Emerald rater as closely as possible I left it in. The rater will display a different opening text after you've talked to him once
if 0x0 goto @FirstTime
msgbox @SubsequentVisits 0x2
goto @Continue
#org @FirstTime
msgbox @FirstVisit 0x2
setflag 0x200 // Setting the flag to display different dialogue the next time you speak to the rater
goto @Continue
#org @Continue
special 0x9F // Opens up the Pokemon menu to select a Pokemon. Result is stored in variable 0x8004
waitstate
special2 0x800D 0x147 // Checks the number of the Pokemon in variable 0x8004, chosen above via special 0x9F. Number is to be store in variable 0x800D
compare 0x800D 0x19C // Checking if the Pokemon chosen is an egg. All eggs have the number 0x19C assigned to them, regardless of what's inside.
if 0x1 goto @EggSkip // If the Pokemon is an egg, skip to a premature ending
compare 0x8004 0x6 // Checking the party position of the Pokemon chosen by special 0x9F. Values 0x0 - 0x5 indicate that a Pokemon is chosen.
if 0x4 goto @Skip // If the value of 0x8006 is greater than or equal to 0x6 the script will skip to a premature ending. This is in case the player pressed B or cancelled out of special 0x9F's party screen
special 0x6 // JPAN's engine special. Decrypts the party Pokemon indicated by the value of 0x8004
setvar 0x8000 0x0 // These next few lines are clearing variables that will be used during the script so there aren't any lingering values associated with them. 0x8000 will hold the value of the IV currently being examined
setvar 0x8001 0x0 // 0x8001 will hold the value of the total sum of the Pokemon's IVs
setvar 0x8002 0x0 // 0x8002 will hold the value of the highest IV checked so far
setvar 0x8003 0x0 // 0x8003 will hold a value identifying the stat that highest IV is associated with. 0 = HP, 1 = Attack, 2 = Defense, 3 = Speed, 4 = Sp Attack, 5 = Sp Defense
setvar 0x8005 0x0 // 0x8005 will hold a value identifying the stat that is currently being compared. Same values as above. 0x8004 will hold the IV value of the stat being compared
writebytetooffset 0x01 0x0203f4d8 // These few lines are preparing the variable mathematic specials that are in JPAN's hack
writebytetooffset 0x80 0x0203f4d9 // I need to add two variables together, namely 0x8000 and 0x8001, with the result being stored in 0x8001
writebytetooffset 0x00 0x0203f4da // The variable mathematics specials (0x3E - 0x44) are probably the most underrated specials in JPAN's engine so I hope to bring more attention to the power they can wield
writebytetooffset 0x80 0x0203f4db
goto @IVLoop // All of the preparations have been made so it is time to start getting IV values
#org @EggSkip
msgbox @Egg 0x2
release
end
#org @Skip
msgbox @NoTime 0x2
release
end
#org @IVLoop // This part of the script will loop, getting the values of the Pokemon's IVs sequentially, remembering the one with the highest value and adding the total sum together
special2 0x8000 0x8 // JPAN's engine special. Can only be used after decrypting a Pokemon's data (special 0x6). Checks the value of the IV as determined by the value of variable 0x8005
special 0x3E // JPAN's engine special. Adds 0x8000 (Current IV value) and 0x8001 (Total IV value) and stores the result in 0x8001
comparevars 0x8000 0x8002 // Compares values 0x8000 and 0x8002 (Highest recorded IV value)
if 0x2 call @NewHighestIV // If the value of 0x8000 is larger than 0x8002's value, call @NewHighestIV
addvar 0x8005 0x1 // Add 1 to 0x8005 (Indicator of which stat should be checked)
compare 0x8005 0x6 // Checks if all of the stats have been compared. SpDef is the last stat and its number is 0x5. Anything greater is useless
if 0x4 goto @Results // Will exit the loop
goto @IVLoop // If there are more values to be checked, the loop continues, now checking a different stat due to the 'addvar 0x8005 0x1' command used earlier
#org @NewHighestIV
copyvar 0x8002 0x8000 // Copies 0x8000 (Current IV value) into 0x8002 (Highest IV value)
copyvar 0x8003 0x8005 // Copies 0x8005 (Current IV identifier) into 0x8002 (Highest IV identifer)
return // Return to where the script jumped to this segment and continues from there
#org @Results
special 0x6 // Re-encrypts the Pokemon, making sure nothing funny happens to its data later on
compare 0x8001 0x5A // Comparing the total of the Pokemon's IVs to 0x5A (90)
if 0x3 goto @TotalAverage // If the total is less than 90, the Pokemon will be deemed Average. This continues for the rest of this segment
compare 0x8001 0x78
if 0x3 call @TotalBetterThanAverage
compare 0x8001 0x96
if 0x3 call @TotalQuiteImpressive
compare 0x8001 0x97
msgbox @Outstanding 0x2 // No need to branch off to a new segment. If the Pokemon has an IV total of over 150 they will be deemed Outstanding
goto @ContinueResults // All other branches from this segment go to @ContinueResults
#org @ContinueResults
compare 0x8003 0x0 // Checking if 0x8003 (The Highest IV stat identifier) is equal to 0x0 (HP)
if 0x1 call @BufferHP // Branches off to a part of the script that will use a command that will buffer the string HP
compare 0x8003 0x1 // Continues like this for a bit
if 0x1 call @BufferAttack
compare 0x8003 0x2
if 0x1 call @BufferDefense
compare 0x8003 0x3
if 0x1 call @BufferSpeed
compare 0x8003 0x4
if 0x1 call @BufferSpAttack
compare 0x8003 0x5
if 0x1 call @BufferSpDefense
msgbox @BestStat 0x2 // Displays a msgbox that indicates the best stat.
compare 0x8002 0xF // Compares 0x8002 (The value of the highest IV) to 0xF (15)
if 0x3 goto @IndividualRelativelyGood // If the value is less than 0xF, it will be deemed 'relatively good'
compare 0x8002 0x19 // Compares 0x8002 to 0x19 (25)
if 0x3 goto @IndividualQuiteImpressive
compare 0x8002 0x1E // Compares 0x8002 to 0x1E (30)
if 0x3 goto @IndividualOutstanding
msgbox @Flawless 0x2 // No need to branch off to a new segment. If the value of the highest IV is 31 it will be deemed 'flawless'
release
end
#org @TotalAverage
msgbox @Average 0x2
goto @ContinueResults
#org @TotalBetterThanAverage
msgbox @BetterThanAverage 0x2
goto @ContinueResults
#org @TotalQuiteImpressive
msgbox @QuiteImpressive 0x2
goto @ContinueResults
#org @BufferHP
bufferstring 0x0 @HP
return
#org @BufferAttack
bufferstring 0x0 @Attack
return
#org @BufferDefense
bufferstring 0x0 @Defense
return
#org @BufferSpeed
bufferstring 0x0 @Speed
return
#org @BufferSpAttack
bufferstring 0x0 @SpAttack
return
#org @BufferSpDefense
bufferstring 0x0 @SpDefense
return
#org @IndividualRelativelyGood
msgbox @RelativelyGood 0x2
release
end
#org @IndividualQuiteImpressive
msgbox @QuiteImpressive2 0x2
release
end
#org @IndividualOutstanding
msgbox @Outstanding2 0x2
release
end
#org @FirstVisit
= For 70 years I have raised POKéMON!\nI am the man they revere as\lthe legendary top POKéMON BREEDER!\pIf you ever become as seasoned as me,\nyou'll see the abilities of POKéMON\lat a glance.\pYou're a TRAINER. Doesn't it interest\nyou to know your own POKéMON's\labilities?\pHere!\nLet's have a look at your POKéMON!
#org @SubsequentVisits
= Ah, youngster! Do your POKéMON's\nabilities intrigue you?\pHere, here!\nLet's have a look at your POKéMON!
#org @Egg
= An expert I am, but even I can't tell\nanything about an unhatched POKéMON!\pShow me a POKéMON!\nA POKéMON is what I need to see!
#org @NoTime
= What?\nYou have no time for my advice?\pYou should always be eager to learn\nfrom the experiences of your elders!
#org @Average
= [.]Hmm[.]\pThis one, overall, I would describe\nas being of average ability.
#org @BetterThanAverage
= [.]Hmm[.]\pThis one, overall, I would describe as\nhaving better-than-average ability.
#org @QuiteImpressive
= [.]Hmm[.]\pThis one, overall, I would say is\nquite impressive in ability!
#org @Outstanding
= [.]Hmm[.]\pThis one, overall, I would say is\nwonderfully outstanding in ability!
#org @HP
= HP
#org @Attack
= ATTACK
#org @Defense
= DEFENSE
#org @Speed
= SPEED
#org @SpAttack
= SPECIAL ATTACK
#org @SpDefense
= SPECIAL DEFENSE
#org @BestStat
= Incidentally, the best aspect of it,\nI would say, is its [buffer1][.]
#org @RelativelyGood
= That stat is relatively good.\n[.]Hm[.] That's how I call it.
#org @QuiteImpressive2
= That stat is quite impressive.\n[.]Hm[.] That's how I call it.
#org @Outstanding2
= That stat is outstanding!\n[.]Hm[.] That's how I call it.
#org @Flawless
= It's flawless! A thing of perfection!\n[.]Hm[.] That's how I call it.