diff --git a/include/pokemon.h b/include/pokemon.h index b07100fb0..3f8344c23 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -14,7 +14,7 @@ #define MON_DATA_OT_NAME 7 #define MON_DATA_MARKINGS 8 #define MON_DATA_CHECKSUM 9 -#define MON_DATA_10 10 +#define MON_DATA_ENCRYPT_SEPARATOR 10 #define MON_DATA_SPECIES 11 #define MON_DATA_HELD_ITEM 12 #define MON_DATA_MOVE1 13 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 8e113c3d4..9dce6b061 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1406,8 +1406,8 @@ s32 CalcCritChanceStage(u8 battlerAtk, u8 battlerDef, u32 move, bool32 recordAbi + (abilityAtk == ABILITY_SUPER_LUCK); } - if (critChance > 4) - critChance = 4; + if (critChance >= ARRAY_COUNT(sCriticalHitChance)) + critChance = ARRAY_COUNT(sCriticalHitChance) - 1; return critChance; } diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 1e120bc90..96ca2ed1c 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -556,7 +556,7 @@ static void CreateShedinja(u16 preEvoSpecies, struct Pokemon* mon) SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_NICKNAME, (gSpeciesNames[gEvolutionTable[preEvoSpecies][1].targetSpecies])); SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_HELD_ITEM, (&data)); SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_MARKINGS, (&data)); - SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_10, (&data)); + SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_ENCRYPT_SEPARATOR, (&data)); for (i = MON_DATA_COOL_RIBBON; i < MON_DATA_COOL_RIBBON + 5; i++) SetMonData(&gPlayerParty[gPlayerPartyCount], i, (&data)); diff --git a/src/pokemon.c b/src/pokemon.c index 4fd98ff99..502240d8b 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3357,7 +3357,8 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data) struct PokemonSubstruct2 *substruct2 = NULL; struct PokemonSubstruct3 *substruct3 = NULL; - if (field > MON_DATA_10) + // Any field greater than MON_DATA_ENCRYPT_SEPARATOR is encrypted and must be treated as such + if (field > MON_DATA_ENCRYPT_SEPARATOR) { substruct0 = &(GetSubstruct(boxMon, boxMon->personality, 0)->type0); substruct1 = &(GetSubstruct(boxMon, boxMon->personality, 1)->type1); @@ -3451,7 +3452,7 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data) case MON_DATA_CHECKSUM: retVal = boxMon->checksum; break; - case MON_DATA_10: + case MON_DATA_ENCRYPT_SEPARATOR: retVal = boxMon->unknown; break; case MON_DATA_SPECIES: @@ -3692,7 +3693,7 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data) break; } - if (field > MON_DATA_10) + if (field > MON_DATA_ENCRYPT_SEPARATOR) EncryptBoxMon(boxMon); return retVal; @@ -3755,7 +3756,7 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) struct PokemonSubstruct2 *substruct2 = NULL; struct PokemonSubstruct3 *substruct3 = NULL; - if (field > MON_DATA_10) + if (field > MON_DATA_ENCRYPT_SEPARATOR) { substruct0 = &(GetSubstruct(boxMon, boxMon->personality, 0)->type0); substruct1 = &(GetSubstruct(boxMon, boxMon->personality, 1)->type1); @@ -3814,7 +3815,7 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) case MON_DATA_CHECKSUM: SET16(boxMon->checksum); break; - case MON_DATA_10: + case MON_DATA_ENCRYPT_SEPARATOR: SET16(boxMon->unknown); break; case MON_DATA_SPECIES: @@ -4010,7 +4011,7 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) break; } - if (field > MON_DATA_10) + if (field > MON_DATA_ENCRYPT_SEPARATOR) { boxMon->checksum = CalculateBoxMonChecksum(boxMon); EncryptBoxMon(boxMon);