fix potential to perfect ivs
This commit is contained in:
parent
9c4d5743d8
commit
6b360ac249
1 changed files with 16 additions and 15 deletions
31
src/dexnav.c
31
src/dexnav.c
|
@ -1212,7 +1212,7 @@ static void DexNavUpdateSearchWindow(u8 proximity, u8 searchLevel)
|
||||||
static void CreateDexNavWildMon(u16 species, u8 potential, u8 level, u8 abilityNum, u16 item, u16* moves)
|
static void CreateDexNavWildMon(u16 species, u8 potential, u8 level, u8 abilityNum, u16 item, u16* moves)
|
||||||
{
|
{
|
||||||
struct Pokemon* mon = &gEnemyParty[0];
|
struct Pokemon* mon = &gEnemyParty[0];
|
||||||
u8 iv[3];
|
u8 iv[3] = {NUM_STATS};
|
||||||
u8 i;
|
u8 i;
|
||||||
u8 perfectIv = 31;
|
u8 perfectIv = 31;
|
||||||
|
|
||||||
|
@ -1221,20 +1221,21 @@ static void CreateDexNavWildMon(u16 species, u8 potential, u8 level, u8 abilityN
|
||||||
|
|
||||||
CreateWildMon(species, level); // shiny rate bonus handled in CreateBoxMon
|
CreateWildMon(species, level); // shiny rate bonus handled in CreateBoxMon
|
||||||
|
|
||||||
//Pick potential unique ivs to set to 31
|
// Pick random, unique IVs to set to 31. The number of perfect IVs that are assigned is equal to the potential
|
||||||
iv[0] = Random() % 6;
|
iv[0] = Random() % NUM_STATS; // choose 1st perfect stat
|
||||||
do {iv[1] = Random() % 6;} while (iv[1] == iv[0]);
|
do {
|
||||||
do {iv[2] = Random() % 6;} while (iv[2] == iv[0] || iv[2] == iv[1]);
|
iv[1] = Random() % NUM_STATS;
|
||||||
if ((iv[0] != iv[1]) && (iv[0] != iv[2]) && (iv[1] != iv[2]))
|
iv[2] = Random() % NUM_STATS;
|
||||||
{
|
} while ((iv[1] == iv[0]) // unique 2nd perfect stat
|
||||||
if (potential > 2)
|
|| (iv[2] == iv[0] || iv[2] == iv[1])); // unique 3rd perfect stat
|
||||||
SetMonData(mon, MON_DATA_HP_IV + iv[2], &perfectIv);
|
|
||||||
else if (potential > 1)
|
if (potential > 2 && iv[2] != NUM_STATS)
|
||||||
SetMonData(mon, MON_DATA_HP_IV + iv[1], &perfectIv);
|
SetMonData(mon, MON_DATA_HP_IV + iv[2], &perfectIv);
|
||||||
else if (potential)
|
if (potential > 1 && iv[1] != NUM_STATS)
|
||||||
SetMonData(mon, MON_DATA_HP_IV + iv[0], &perfectIv);
|
SetMonData(mon, MON_DATA_HP_IV + iv[1], &perfectIv);
|
||||||
}
|
if (potential > 0 && iv[0] != NUM_STATS)
|
||||||
|
SetMonData(mon, MON_DATA_HP_IV + iv[0], &perfectIv);
|
||||||
|
|
||||||
//Set ability
|
//Set ability
|
||||||
SetMonData(mon, MON_DATA_ABILITY_NUM, &abilityNum);
|
SetMonData(mon, MON_DATA_ABILITY_NUM, &abilityNum);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue