diff options
author | hondew <pokehondew@gmail.com> | 2020-08-30 14:14:38 -0400 |
---|---|---|
committer | hondew <pokehondew@gmail.com> | 2020-08-30 14:14:38 -0400 |
commit | e46b35455d1e2af8c8c2d291ce1cc28e682d9095 (patch) | |
tree | 76855f3dedad94ba34a8f8b40811a1005107b5ae /src/pokemon.c | |
parent | 328aecc96e690c437e52663a1445417e8aa78df6 (diff) | |
parent | a9719c92bfa4c6b6dcf57e9516f184721152ad80 (diff) |
Merge branch 'master' into pokeball-doc
Diffstat (limited to 'src/pokemon.c')
-rw-r--r-- | src/pokemon.c | 124 |
1 files changed, 63 insertions, 61 deletions
diff --git a/src/pokemon.c b/src/pokemon.c index 80e93c568..188624d6a 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1868,21 +1868,21 @@ const u8 gPPUpGetMask[] = {0x03, 0x0c, 0x30, 0xc0}; // Masks for getting PP Up c const u8 gPPUpSetMask[] = {0xfc, 0xf3, 0xcf, 0x3f}; // Masks for setting PP Up count const u8 gPPUpAddMask[] = {0x01, 0x04, 0x10, 0x40}; // Values added to PP Up count -const u8 gStatStageRatios[][2] = +const u8 gStatStageRatios[MAX_STAT_STAGE + 1][2] = { - {10, 40}, // -6 + {10, 40}, // -6, MIN_STAT_STAGE {10, 35}, // -5 {10, 30}, // -4 {10, 25}, // -3 {10, 20}, // -2 {10, 15}, // -1 - {10, 10}, // 0 + {10, 10}, // 0, DEFAULT_STAT_STAGE {15, 10}, // +1 {20, 10}, // +2 {25, 10}, // +3 {30, 10}, // +4 {35, 10}, // +5 - {40, 10}, // +6 + {40, 10}, // +6, MAX_STAT_STAGE }; static const u16 sDeoxysBaseStats[] = @@ -1898,22 +1898,22 @@ static const u16 sDeoxysBaseStats[] = const u16 gLinkPlayerFacilityClasses[NUM_MALE_LINK_FACILITY_CLASSES + NUM_FEMALE_LINK_FACILITY_CLASSES] = { // Male classes - FACILITY_CLASS_COOLTRAINER_M, - FACILITY_CLASS_BLACK_BELT, + FACILITY_CLASS_COOLTRAINER_M, + FACILITY_CLASS_BLACK_BELT, FACILITY_CLASS_CAMPER, - FACILITY_CLASS_YOUNGSTER, - FACILITY_CLASS_PSYCHIC_M, + FACILITY_CLASS_YOUNGSTER, + FACILITY_CLASS_PSYCHIC_M, FACILITY_CLASS_BUG_CATCHER, - FACILITY_CLASS_PKMN_BREEDER_M, + FACILITY_CLASS_PKMN_BREEDER_M, FACILITY_CLASS_GUITARIST, // Female Classes - FACILITY_CLASS_COOLTRAINER_F, - FACILITY_CLASS_HEX_MANIAC, + FACILITY_CLASS_COOLTRAINER_F, + FACILITY_CLASS_HEX_MANIAC, FACILITY_CLASS_PICNICKER, - FACILITY_CLASS_LASS, - FACILITY_CLASS_PSYCHIC_F, + FACILITY_CLASS_LASS, + FACILITY_CLASS_PSYCHIC_F, FACILITY_CLASS_BATTLE_GIRL, - FACILITY_CLASS_PKMN_BREEDER_F, + FACILITY_CLASS_PKMN_BREEDER_F, FACILITY_CLASS_BEAUTY }; @@ -3199,7 +3199,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de { if (gCritMultiplier == 2) { - if (attacker->statStages[STAT_ATK] > 6) + if (attacker->statStages[STAT_ATK] > DEFAULT_STAT_STAGE) APPLY_STAT_MOD(damage, attacker, attack, STAT_ATK) else damage = attack; @@ -3212,7 +3212,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de if (gCritMultiplier == 2) { - if (defender->statStages[STAT_DEF] < 6) + if (defender->statStages[STAT_DEF] < DEFAULT_STAT_STAGE) APPLY_STAT_MOD(damageHelper, defender, defense, STAT_DEF) else damageHelper = defense; @@ -3249,7 +3249,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de { if (gCritMultiplier == 2) { - if (attacker->statStages[STAT_SPATK] > 6) + if (attacker->statStages[STAT_SPATK] > DEFAULT_STAT_STAGE) APPLY_STAT_MOD(damage, attacker, spAttack, STAT_SPATK) else damage = spAttack; @@ -3262,7 +3262,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de if (gCritMultiplier == 2) { - if (defender->statStages[STAT_SPDEF] < 6) + if (defender->statStages[STAT_SPDEF] < DEFAULT_STAT_STAGE) APPLY_STAT_MOD(damageHelper, defender, spDefense, STAT_SPDEF) else damageHelper = spDefense; @@ -4499,8 +4499,8 @@ void CreateSecretBaseEnemyParty(struct SecretBase *secretBaseRecord) for (j = 0; j < MAX_MON_MOVES; j++) { - SetMonData(&gEnemyParty[i], MON_DATA_MOVE1 + j, &gBattleResources->secretBase->party.moves[i * 4 + j]); - SetMonData(&gEnemyParty[i], MON_DATA_PP1 + j, &gBattleMoves[gBattleResources->secretBase->party.moves[i * 4 + j]].pp); + SetMonData(&gEnemyParty[i], MON_DATA_MOVE1 + j, &gBattleResources->secretBase->party.moves[i * MAX_MON_MOVES + j]); + SetMonData(&gEnemyParty[i], MON_DATA_PP1 + j, &gBattleMoves[gBattleResources->secretBase->party.moves[i * MAX_MON_MOVES + j]].pp); } } } @@ -4624,11 +4624,11 @@ void CopyPlayerPartyMonToBattleData(u8 battlerId, u8 partyIndex) hpSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(battlerId)]; *hpSwitchout = gBattleMons[battlerId].hp; - for (i = 0; i < 8; i++) - gBattleMons[battlerId].statStages[i] = 6; + for (i = 0; i < NUM_BATTLE_STATS; i++) + gBattleMons[battlerId].statStages[i] = DEFAULT_STAT_STAGE; gBattleMons[battlerId].status2 = 0; - sub_803FA70(battlerId); + UpdateSentPokesToOpponentValue(battlerId); ClearTemporarySpeciesSpriteData(battlerId, FALSE); } @@ -4728,49 +4728,49 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov retVal = FALSE; } if ((itemEffect[cmdIndex] & ITEM0_X_ATTACK) - && gBattleMons[gActiveBattler].statStages[STAT_ATK] < 12) + && gBattleMons[gActiveBattler].statStages[STAT_ATK] < MAX_STAT_STAGE) { gBattleMons[gActiveBattler].statStages[STAT_ATK] += itemEffect[cmdIndex] & ITEM0_X_ATTACK; - if (gBattleMons[gActiveBattler].statStages[STAT_ATK] > 12) - gBattleMons[gActiveBattler].statStages[STAT_ATK] = 12; + if (gBattleMons[gActiveBattler].statStages[STAT_ATK] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_ATK] = MAX_STAT_STAGE; retVal = FALSE; } break; // in-battle stat boosting effects case 1: if ((itemEffect[cmdIndex] & ITEM1_X_DEFEND) - && gBattleMons[gActiveBattler].statStages[STAT_DEF] < 12) + && gBattleMons[gActiveBattler].statStages[STAT_DEF] < MAX_STAT_STAGE) { gBattleMons[gActiveBattler].statStages[STAT_DEF] += (itemEffect[cmdIndex] & ITEM1_X_DEFEND) >> 4; - if (gBattleMons[gActiveBattler].statStages[STAT_DEF] > 12) - gBattleMons[gActiveBattler].statStages[STAT_DEF] = 12; + if (gBattleMons[gActiveBattler].statStages[STAT_DEF] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_DEF] = MAX_STAT_STAGE; retVal = FALSE; } if ((itemEffect[cmdIndex] & ITEM1_X_SPEED) - && gBattleMons[gActiveBattler].statStages[STAT_SPEED] < 12) + && gBattleMons[gActiveBattler].statStages[STAT_SPEED] < MAX_STAT_STAGE) { gBattleMons[gActiveBattler].statStages[STAT_SPEED] += itemEffect[cmdIndex] & ITEM1_X_SPEED; - if (gBattleMons[gActiveBattler].statStages[STAT_SPEED] > 12) - gBattleMons[gActiveBattler].statStages[STAT_SPEED] = 12; + if (gBattleMons[gActiveBattler].statStages[STAT_SPEED] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_SPEED] = MAX_STAT_STAGE; retVal = FALSE; } break; // more stat boosting effects case 2: if ((itemEffect[cmdIndex] & ITEM2_X_ACCURACY) - && gBattleMons[gActiveBattler].statStages[STAT_ACC] < 12) + && gBattleMons[gActiveBattler].statStages[STAT_ACC] < MAX_STAT_STAGE) { gBattleMons[gActiveBattler].statStages[STAT_ACC] += (itemEffect[cmdIndex] & ITEM2_X_ACCURACY) >> 4; - if (gBattleMons[gActiveBattler].statStages[STAT_ACC] > 12) - gBattleMons[gActiveBattler].statStages[STAT_ACC] = 12; + if (gBattleMons[gActiveBattler].statStages[STAT_ACC] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_ACC] = MAX_STAT_STAGE; retVal = FALSE; } if ((itemEffect[cmdIndex] & ITEM2_X_SPATK) - && gBattleMons[gActiveBattler].statStages[STAT_SPATK] < 12) + && gBattleMons[gActiveBattler].statStages[STAT_SPATK] < MAX_STAT_STAGE) { gBattleMons[gActiveBattler].statStages[STAT_SPATK] += itemEffect[cmdIndex] & ITEM2_X_SPATK; - if (gBattleMons[gActiveBattler].statStages[STAT_SPATK] > 12) - gBattleMons[gActiveBattler].statStages[STAT_SPATK] = 12; + if (gBattleMons[gActiveBattler].statStages[STAT_SPATK] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_SPATK] = MAX_STAT_STAGE; retVal = FALSE; } break; @@ -5806,7 +5806,7 @@ void AdjustFriendship(struct Pokemon *mon, u8 event) if (friendship > 199) friendshipLevel++; - if ((event != FRIENDSHIP_EVENT_WALKING || !(Random() & 1)) + if ((event != FRIENDSHIP_EVENT_WALKING || !(Random() & 1)) && (event != FRIENDSHIP_EVENT_LEAGUE_BATTLE || IS_LEAGUE_BATTLE)) { s8 mod = sFriendshipEventModifiers[event][friendshipLevel]; @@ -5848,7 +5848,7 @@ void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies) { if (totalEVs >= MAX_TOTAL_EVS) break; - + if (CheckPartyHasHadPokerus(mon, 0)) multiplier = 2; else @@ -5895,9 +5895,9 @@ void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies) if (totalEVs + (s16)evIncrease > MAX_TOTAL_EVS) evIncrease = ((s16)evIncrease + MAX_TOTAL_EVS) - (totalEVs + evIncrease); - if (evs[i] + (s16)evIncrease > 255) + if (evs[i] + (s16)evIncrease > MAX_PER_STAT_EVS) { - int val1 = (s16)evIncrease + 255; + int val1 = (s16)evIncrease + MAX_PER_STAT_EVS; int val2 = evs[i] + evIncrease; evIncrease = val1 - val2; } @@ -6138,7 +6138,7 @@ u8 GetMoveRelearnerMoves(struct Pokemon *mon, u16 *moves) for (i = 0; i < MAX_MON_MOVES; i++) learnedMoves[i] = GetMonData(mon, MON_DATA_MOVE1 + i, 0); - for (i = 0; i < 20; i++) + for (i = 0; i < MAX_LEVEL_UP_MOVES; i++) { u16 moveLevel; @@ -6171,7 +6171,7 @@ u8 GetLevelUpMovesBySpecies(u16 species, u16 *moves) u8 numMoves = 0; int i; - for (i = 0; i < 20 && gLevelUpLearnsets[species][i] != LEVEL_UP_END; i++) + for (i = 0; i < MAX_LEVEL_UP_MOVES && gLevelUpLearnsets[species][i] != LEVEL_UP_END; i++) moves[numMoves++] = gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID; return numMoves; @@ -6180,7 +6180,7 @@ u8 GetLevelUpMovesBySpecies(u16 species, u16 *moves) u8 GetNumberOfRelearnableMoves(struct Pokemon *mon) { u16 learnedMoves[MAX_MON_MOVES]; - u16 moves[20]; + u16 moves[MAX_LEVEL_UP_MOVES]; u8 numMoves = 0; u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); u8 level = GetMonData(mon, MON_DATA_LEVEL, 0); @@ -6192,7 +6192,7 @@ u8 GetNumberOfRelearnableMoves(struct Pokemon *mon) for (i = 0; i < MAX_MON_MOVES; i++) learnedMoves[i] = GetMonData(mon, MON_DATA_MOVE1 + i, 0); - for (i = 0; i < 20; i++) + for (i = 0; i < MAX_LEVEL_UP_MOVES; i++) { u16 moveLevel; @@ -6253,11 +6253,11 @@ void ClearBattleMonForms(void) u16 GetBattleBGM(void) { if (gBattleTypeFlags & BATTLE_TYPE_KYOGRE_GROUDON) - return MUS_BATTLE34; + return MUS_VS_KYOGRE_GROUDON; else if (gBattleTypeFlags & BATTLE_TYPE_REGI) - return MUS_BATTLE36; + return MUS_VS_REGI; else if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) - return MUS_BATTLE20; + return MUS_VS_TRAINER; else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) { u8 trainerClass; @@ -6273,24 +6273,24 @@ u16 GetBattleBGM(void) { case TRAINER_CLASS_AQUA_LEADER: case TRAINER_CLASS_MAGMA_LEADER: - return MUS_BATTLE30; + return MUS_VS_AQUA_MAGMA_LEADER; case TRAINER_CLASS_TEAM_AQUA: case TRAINER_CLASS_TEAM_MAGMA: case TRAINER_CLASS_AQUA_ADMIN: case TRAINER_CLASS_MAGMA_ADMIN: - return MUS_BATTLE31; + return MUS_VS_AQUA_MAGMA; case TRAINER_CLASS_LEADER: - return MUS_BATTLE32; + return MUS_VS_GYM_LEADER; case TRAINER_CLASS_CHAMPION: - return MUS_BATTLE33; + return MUS_VS_CHAMPION; case TRAINER_CLASS_PKMN_TRAINER_3: if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) - return MUS_BATTLE35; + return MUS_VS_RIVAL; if (!StringCompare(gTrainers[gTrainerBattleOpponent_A].trainerName, gText_BattleWallyName)) - return MUS_BATTLE20; - return MUS_BATTLE35; + return MUS_VS_TRAINER; + return MUS_VS_RIVAL; case TRAINER_CLASS_ELITE_FOUR: - return MUS_BATTLE38; + return MUS_VS_ELITE_FOUR; case TRAINER_CLASS_SALON_MAIDEN: case TRAINER_CLASS_DOME_ACE: case TRAINER_CLASS_PALACE_MAVEN: @@ -6298,13 +6298,13 @@ u16 GetBattleBGM(void) case TRAINER_CLASS_FACTORY_HEAD: case TRAINER_CLASS_PIKE_QUEEN: case TRAINER_CLASS_PYRAMID_KING: - return MUS_VS_FRONT; + return MUS_VS_FRONTIER_BRAIN; default: - return MUS_BATTLE20; + return MUS_VS_TRAINER; } } else - return MUS_BATTLE27; + return MUS_VS_WILD; } void PlayBattleBGM(void) @@ -6814,7 +6814,9 @@ static void sub_806F160(struct Unknown_806F160_Struct* structPtr) structPtr->templates[i] = gUnknown_08329D98[i]; for (j = 0; j < structPtr->field_1; j++) { - asm(""); + #ifndef NONMATCHING + asm(""); + #endif structPtr->frameImages[i * structPtr->field_1 + j].data = &structPtr->byteArrays[i][j * 0x800]; } structPtr->templates[i].images = &structPtr->frameImages[i * structPtr->field_1]; |