diff options
Diffstat (limited to 'src/pokemon.c')
-rw-r--r-- | src/pokemon.c | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/src/pokemon.c b/src/pokemon.c index fc9a0843f..2485caa50 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1879,14 +1879,14 @@ static const u16 sDeoxysBaseStats[] = 90, // Sp.Defense }; -const u16 gUnknown_08329D54[] = +const u16 gLinkPlayerFacilityClasses[] = { FACILITY_CLASS_COOLTRAINER_M, FACILITY_CLASS_BLACK_BELT, FACILITY_CLASS_CAMPER, FACILITY_CLASS_YOUNGSTER, FACILITY_CLASS_PSYCHIC_M, FACILITY_CLASS_BUG_CATCHER, - FACILITY_CLASS_PKMN_BREEDER_M, FACILITY_CLASS_GUITARIST, FACILITY_CLASS_COOLTRAINER_F, - FACILITY_CLASS_HEX_MANIAC, FACILITY_CLASS_PICNICKER, FACILITY_CLASS_LASS, - FACILITY_CLASS_PSYCHIC_F, FACILITY_CLASS_BATTLE_GIRL, FACILITY_CLASS_POKEMON_BREEDER_F, - FACILITY_CLASS_BEAUTY + FACILITY_CLASS_PKMN_BREEDER_M, FACILITY_CLASS_GUITARIST, + FACILITY_CLASS_COOLTRAINER_F, FACILITY_CLASS_HEX_MANIAC, FACILITY_CLASS_PICNICKER, + FACILITY_CLASS_LASS, FACILITY_CLASS_PSYCHIC_F, FACILITY_CLASS_BATTLE_GIRL, + FACILITY_CLASS_POKEMON_BREEDER_F, FACILITY_CLASS_BEAUTY }; static const u8 sHoldEffectToType[][2] = @@ -2183,7 +2183,7 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, { value = Random32(); shinyValue = HIHALF(value) ^ LOHALF(value) ^ HIHALF(personality) ^ LOHALF(personality); - } while (shinyValue < 8); + } while (shinyValue < SHINY_ODDS); } else if (otIdType == OT_ID_PRESET) //Pokemon has a preset OT ID { @@ -2248,10 +2248,10 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, SetBoxMonData(boxMon, MON_DATA_SPDEF_IV, &iv); } - if (gBaseStats[species].ability2) + if (gBaseStats[species].abilities[1]) { value = personality & 1; - SetBoxMonData(boxMon, MON_DATA_ALT_ABILITY, &value); + SetBoxMonData(boxMon, MON_DATA_ABILITY_NUM, &value); } GiveBoxMonInitialMoveset(boxMon); @@ -2402,8 +2402,8 @@ void CreateBattleTowerMon(struct Pokemon *mon, struct BattleTowerPokemon *src) SetMonData(mon, MON_DATA_SPEED_EV, &src->speedEV); SetMonData(mon, MON_DATA_SPATK_EV, &src->spAttackEV); SetMonData(mon, MON_DATA_SPDEF_EV, &src->spDefenseEV); - value = src->altAbility; - SetMonData(mon, MON_DATA_ALT_ABILITY, &value); + value = src->abilityNum; + SetMonData(mon, MON_DATA_ABILITY_NUM, &value); value = src->hpIV; SetMonData(mon, MON_DATA_HP_IV, &value); value = src->attackIV; @@ -2464,8 +2464,8 @@ void CreateBattleTowerMon2(struct Pokemon *mon, struct BattleTowerPokemon *src, SetMonData(mon, MON_DATA_SPEED_EV, &src->speedEV); SetMonData(mon, MON_DATA_SPATK_EV, &src->spAttackEV); SetMonData(mon, MON_DATA_SPDEF_EV, &src->spDefenseEV); - value = src->altAbility; - SetMonData(mon, MON_DATA_ALT_ABILITY, &value); + value = src->abilityNum; + SetMonData(mon, MON_DATA_ABILITY_NUM, &value); value = src->hpIV; SetMonData(mon, MON_DATA_HP_IV, &value); value = src->attackIV; @@ -2580,7 +2580,7 @@ void sub_80686FC(struct Pokemon *mon, struct BattleTowerPokemon *dest) dest->speedIV = GetMonData(mon, MON_DATA_SPEED_IV, NULL); dest->spAttackIV = GetMonData(mon, MON_DATA_SPATK_IV, NULL); dest->spDefenseIV = GetMonData(mon, MON_DATA_SPDEF_IV, NULL); - dest->altAbility = GetMonData(mon, MON_DATA_ALT_ABILITY, NULL); + dest->abilityNum = GetMonData(mon, MON_DATA_ABILITY_NUM, NULL); dest->personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); GetMonData(mon, MON_DATA_NICKNAME, dest->nickname); } @@ -2711,7 +2711,7 @@ u16 sub_8068B48(void) arrId = gLinkPlayers[linkId].trainerId & 7; arrId |= gLinkPlayers[linkId].gender << 3; - return FacilityClassToPicIndex(gUnknown_08329D54[arrId]); + return FacilityClassToPicIndex(gLinkPlayerFacilityClasses[arrId]); } u16 sub_8068BB0(void) @@ -2726,7 +2726,7 @@ u16 sub_8068BB0(void) arrId = gLinkPlayers[linkId].trainerId & 7; arrId |= gLinkPlayers[linkId].gender << 3; - return gFacilityClassToTrainerClass[gUnknown_08329D54[arrId]]; + return gFacilityClassToTrainerClass[gLinkPlayerFacilityClasses[arrId]]; } void CreateObedientEnemyMon(void) @@ -3642,7 +3642,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); @@ -3736,7 +3737,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: @@ -3841,8 +3842,8 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data) case MON_DATA_IS_EGG: retVal = substruct3->isEgg; break; - case MON_DATA_ALT_ABILITY: - retVal = substruct3->altAbility; + case MON_DATA_ABILITY_NUM: + retVal = substruct3->abilityNum; break; case MON_DATA_COOL_RIBBON: retVal = substruct3->coolRibbon; @@ -3977,7 +3978,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; @@ -4040,7 +4041,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); @@ -4099,7 +4100,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: @@ -4220,8 +4221,8 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) else boxMon->isEgg = 0; break; - case MON_DATA_ALT_ABILITY: - SET8(substruct3->altAbility); + case MON_DATA_ABILITY_NUM: + SET8(substruct3->abilityNum); break; case MON_DATA_COOL_RIBBON: SET8(substruct3->coolRibbon); @@ -4295,7 +4296,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); @@ -4428,12 +4429,12 @@ u8 GetMonsStateToDoubles_2(void) return (aliveCount > 1) ? PLAYER_HAS_TWO_USABLE_MONS : PLAYER_HAS_ONE_USABLE_MON; } -u8 GetAbilityBySpecies(u16 species, bool8 altAbility) +u8 GetAbilityBySpecies(u16 species, bool8 abilityNum) { - if (altAbility) - gLastUsedAbility = gBaseStats[species].ability2; + if (abilityNum) + gLastUsedAbility = gBaseStats[species].abilities[1]; else - gLastUsedAbility = gBaseStats[species].ability1; + gLastUsedAbility = gBaseStats[species].abilities[0]; return gLastUsedAbility; } @@ -4441,8 +4442,8 @@ u8 GetAbilityBySpecies(u16 species, bool8 altAbility) u8 GetMonAbility(struct Pokemon *mon) { u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL); - u8 altAbility = GetMonData(mon, MON_DATA_ALT_ABILITY, NULL); - return GetAbilityBySpecies(species, altAbility); + u8 abilityNum = GetMonData(mon, MON_DATA_ABILITY_NUM, NULL); + return GetAbilityBySpecies(species, abilityNum); } void CreateSecretBaseEnemyParty(struct SecretBase *secretBaseRecord) @@ -4585,11 +4586,11 @@ void CopyPlayerPartyMonToBattleData(u8 battlerId, u8 partyIndex) gBattleMons[battlerId].spAttack = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPATK, NULL); gBattleMons[battlerId].spDefense = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPDEF, NULL); gBattleMons[battlerId].isEgg = GetMonData(&gPlayerParty[partyIndex], MON_DATA_IS_EGG, NULL); - gBattleMons[battlerId].altAbility = GetMonData(&gPlayerParty[partyIndex], MON_DATA_ALT_ABILITY, NULL); + gBattleMons[battlerId].abilityNum = GetMonData(&gPlayerParty[partyIndex], MON_DATA_ABILITY_NUM, NULL); gBattleMons[battlerId].otId = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_ID, NULL); gBattleMons[battlerId].type1 = gBaseStats[gBattleMons[battlerId].species].type1; gBattleMons[battlerId].type2 = gBaseStats[gBattleMons[battlerId].species].type2; - gBattleMons[battlerId].ability = GetAbilityBySpecies(gBattleMons[battlerId].species, gBattleMons[battlerId].altAbility); + gBattleMons[battlerId].ability = GetAbilityBySpecies(gBattleMons[battlerId].species, gBattleMons[battlerId].abilityNum); GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, nickname); StringCopy10(gBattleMons[battlerId].nickname, nickname); GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_NAME, gBattleMons[battlerId].otName); @@ -6320,10 +6321,10 @@ const u32 *GetMonFrontSpritePal(struct Pokemon *mon) u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0); u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, 0); - return GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality); + return GetMonSpritePalFromSpeciesAndPersonality(species, otId, personality); } -const u32 *GetFrontSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 personality) +const u32 *GetMonSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 personality) { u32 shinyValue; @@ -6331,7 +6332,7 @@ const u32 *GetFrontSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 return gMonPaletteTable[0].data; shinyValue = HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality); - if (shinyValue < 8) + if (shinyValue < SHINY_ODDS) return gMonShinyPaletteTable[species].data; else return gMonPaletteTable[species].data; @@ -6350,7 +6351,7 @@ const struct CompressedSpritePalette *GetMonSpritePalStructFromOtIdPersonality(u u32 shinyValue; shinyValue = HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality); - if (shinyValue < 8) + if (shinyValue < SHINY_ODDS) return &gMonShinyPaletteTable[species]; else return &gMonPaletteTable[species]; @@ -6524,7 +6525,7 @@ bool8 IsShinyOtIdPersonality(u32 otId, u32 personality) { bool8 retVal = FALSE; u32 shinyValue = HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality); - if (shinyValue < 8) + if (shinyValue < SHINY_ODDS) retVal = TRUE; return retVal; } |