From 620e69945d1dea0f5429e7fd1e3330704711a10b Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 20 Oct 2022 13:14:32 -0300 Subject: [PATCH 01/37] Form change for starting and ending battles. Adjusted PP for Iron Head/Behemoth moves --- include/battle_util.h | 1 + include/pokemon.h | 2 +- src/battle_main.c | 20 +---- src/battle_script_commands.c | 4 +- src/battle_util.c | 20 +++-- src/data/pokemon/form_change_table_pointers.h | 33 ++++++++ src/data/pokemon/form_change_tables.h | 75 +++++++++++++++++++ src/pokemon.c | 35 ++++----- 8 files changed, 146 insertions(+), 44 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index a456cc1e6..59ddad940 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -150,6 +150,7 @@ u16 GetWishMegaEvolutionSpecies(u16 preEvoSpecies, u16 moveId1, u16 moveId2, u16 bool32 CanMegaEvolve(u8 battlerId); void UndoMegaEvolution(u32 monId); void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut); +void BattleFormChange(u32 monId, u32 side, u16 method); bool32 DoBattlersShareType(u32 battler1, u32 battler2); bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId); struct Pokemon *GetIllusionMonPtr(u32 battlerId); diff --git a/include/pokemon.h b/include/pokemon.h index c4015d562..fa5bfc663 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -564,7 +564,7 @@ u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg); u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *mon, u16 method, u32 arg); u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove); bool32 ShouldShowFemaleDifferences(u16 species, u32 personality); -void TryToSetBattleFormChangeMoves(struct Pokemon *mon); +void TryToSetBattleFormChangeMoves(struct Pokemon *mon, u16 method); u32 GetMonFriendshipScore(struct Pokemon *pokemon); #endif // GUARD_POKEMON_H diff --git a/src/battle_main.c b/src/battle_main.c index 5b6e724c9..9d75e901c 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -602,21 +602,9 @@ static void CB2_InitBattleInternal(void) for (i = 0; i < PARTY_SIZE; i++) { // Player's side - targetSpecies = GetFormChangeTargetSpecies(&gPlayerParty[i], FORM_BATTLE_BEGIN, 0); - if (targetSpecies != SPECIES_NONE) - { - SetMonData(&gPlayerParty[i], MON_DATA_SPECIES, &targetSpecies); - CalculateMonStats(&gPlayerParty[i]); - TryToSetBattleFormChangeMoves(&gPlayerParty[i]); - } + BattleFormChange(i, B_SIDE_PLAYER, FORM_BATTLE_BEGIN); // Opponent's side - targetSpecies = GetFormChangeTargetSpecies(&gEnemyParty[i], FORM_BATTLE_BEGIN, 0); - if (targetSpecies != SPECIES_NONE) - { - SetMonData(&gEnemyParty[i], MON_DATA_SPECIES, &targetSpecies); - CalculateMonStats(&gEnemyParty[i]); - TryToSetBattleFormChangeMoves(&gEnemyParty[i]); - } + BattleFormChange(i, B_SIDE_OPPONENT, FORM_BATTLE_BEGIN); } gBattleCommunication[MULTIUSE_STATE] = 0; @@ -3264,7 +3252,7 @@ void FaintClearSetData(void) UndoMegaEvolution(gBattlerPartyIndexes[gActiveBattler]); gBattleStruct->overwrittenAbilities[gActiveBattler] = ABILITY_NONE; - + // If the fainted mon was involved in a Sky Drop if (gBattleStruct->skyDropTargets[gActiveBattler] != 0xFF) { @@ -5219,7 +5207,7 @@ static void HandleEndTurn_FinishBattle(void) for (i = 0; i < PARTY_SIZE; i++) { UndoMegaEvolution(i); - UndoFormChange(i, B_SIDE_PLAYER, FALSE); + BattleFormChange(i, B_SIDE_PLAYER, FORM_BATTLE_END); DoBurmyFormChange(i); } #if B_RECALCULATE_STATS >= GEN_5 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index eaa7bbde1..bfc9bfc42 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -14109,7 +14109,7 @@ static void Cmd_handleballthrow(void) { BtlController_EmitBallThrowAnim(BUFFER_A, BALL_3_SHAKES_SUCCESS); MarkBattlerForControllerExec(gActiveBattler); - UndoFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FALSE); + BattleFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FORM_BATTLE_END), gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); @@ -14163,7 +14163,7 @@ static void Cmd_handleballthrow(void) if (IsCriticalCapture()) gBattleSpritesDataPtr->animationData->criticalCaptureSuccess = TRUE; - UndoFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FALSE); + BattleFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FORM_BATTLE_END), gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); diff --git a/src/battle_util.c b/src/battle_util.c index 9dbdb1abf..92f79cd8d 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -9726,15 +9726,19 @@ void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut) break; } } - if (!isSwitchingOut) +} + +void BattleFormChange(u32 monId, u32 side, u16 method) +{ + u32 targetSpecies; + struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + + targetSpecies = GetFormChangeTargetSpecies(&party[monId], method, 0); + if (targetSpecies != SPECIES_NONE) { - targetSpecies = GetFormChangeTargetSpecies(&party[monId], FORM_BATTLE_END, 0); - if (targetSpecies != SPECIES_NONE) - { - SetMonData(&party[monId], MON_DATA_SPECIES, &targetSpecies); - CalculateMonStats(&party[monId]); - TryToSetBattleFormChangeMoves(&party[monId]); - } + TryToSetBattleFormChangeMoves(&party[monId], method); + SetMonData(&party[monId], MON_DATA_SPECIES, &targetSpecies); + CalculateMonStats(&party[monId]); } } diff --git a/src/data/pokemon/form_change_table_pointers.h b/src/data/pokemon/form_change_table_pointers.h index 90be7112b..63971f132 100644 --- a/src/data/pokemon/form_change_table_pointers.h +++ b/src/data/pokemon/form_change_table_pointers.h @@ -25,6 +25,10 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] = [SPECIES_ARCEUS_FAIRY] = sArceusFormChangeTable, #endif #if P_GEN_5_POKEMON == TRUE + [SPECIES_DARMANITAN] = sDarmanitanFormChangeTable, + [SPECIES_DARMANITAN_ZEN_MODE] = sDarmanitanFormChangeTable, + [SPECIES_DARMANITAN_GALARIAN] = sDarmanitanGalarianFormChangeTable, + [SPECIES_DARMANITAN_ZEN_MODE_GALARIAN] = sDarmanitanGalarianFormChangeTable, [SPECIES_TORNADUS] = sTornadusFormChangeTable, [SPECIES_TORNADUS_THERIAN] = sTornadusFormChangeTable, [SPECIES_THUNDURUS] = sThundurusFormChangeTable, @@ -33,6 +37,8 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] = [SPECIES_LANDORUS_THERIAN] = sLandorusFormChangeTable, [SPECIES_KELDEO] = sKeldeoFormChangeTable, [SPECIES_KELDEO_RESOLUTE] = sKeldeoFormChangeTable, + [SPECIES_MELOETTA] = sMeloettaFormChangeTable, + [SPECIES_MELOETTA_PIROUETTE] = sMeloettaFormChangeTable, [SPECIES_GENESECT] = sGenesectFormChangeTable, [SPECIES_GENESECT_DOUSE_DRIVE] = sGenesectFormChangeTable, [SPECIES_GENESECT_SHOCK_DRIVE] = sGenesectFormChangeTable, @@ -40,6 +46,10 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] = [SPECIES_GENESECT_CHILL_DRIVE] = sGenesectFormChangeTable, #endif #if P_GEN_6_POKEMON == TRUE + [SPECIES_GRENINJA_BATTLE_BOND] = sGreninjaBattleBondFormChangeTable, + [SPECIES_GRENINJA_ASH] = sGreninjaBattleBondFormChangeTable, + [SPECIES_AEGISLASH] = sAegislashFormChangeTable, + [SPECIES_AEGISLASH_BLADE] = sAegislashFormChangeTable, [SPECIES_XERNEAS] = sXerneasFormChangeTable, [SPECIES_XERNEAS_ACTIVE] = sXerneasFormChangeTable, [SPECIES_HOOPA] = sHoopaFormChangeTable, @@ -50,6 +60,8 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] = [SPECIES_ORICORIO_POM_POM] = sOricorioFormChangeTable, [SPECIES_ORICORIO_PAU] = sOricorioFormChangeTable, [SPECIES_ORICORIO_SENSU] = sOricorioFormChangeTable, + [SPECIES_WISHIWASHI] = sWishiwashiFormChangeTable, + [SPECIES_WISHIWASHI_SCHOOL] = sWishiwashiFormChangeTable, [SPECIES_SILVALLY] = sSilvallyFormChangeTable, [SPECIES_SILVALLY_BUG] = sSilvallyFormChangeTable, [SPECIES_SILVALLY_DARK] = sSilvallyFormChangeTable, @@ -68,8 +80,29 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] = [SPECIES_SILVALLY_ROCK] = sSilvallyFormChangeTable, [SPECIES_SILVALLY_STEEL] = sSilvallyFormChangeTable, [SPECIES_SILVALLY_WATER] = sSilvallyFormChangeTable, + [SPECIES_MIMIKYU] = sMimikyuFormChangeTable, + [SPECIES_MIMIKYU_BUSTED] = sMimikyuFormChangeTable, + [SPECIES_MINIOR] = sMiniorRedFormChangeTable, + [SPECIES_MINIOR_CORE_RED] = sMiniorRedFormChangeTable, + [SPECIES_MINIOR_METEOR_BLUE] = sMiniorBlueFormChangeTable, + [SPECIES_MINIOR_CORE_BLUE] = sMiniorBlueFormChangeTable, + [SPECIES_MINIOR_METEOR_GREEN] = sMiniorGreenFormChangeTable, + [SPECIES_MINIOR_CORE_GREEN] = sMiniorGreenFormChangeTable, + [SPECIES_MINIOR_METEOR_INDIGO] = sMiniorIndigoFormChangeTable, + [SPECIES_MINIOR_CORE_INDIGO] = sMiniorIndigoFormChangeTable, + [SPECIES_MINIOR_METEOR_ORANGE] = sMiniorOrangeFormChangeTable, + [SPECIES_MINIOR_CORE_ORANGE] = sMiniorOrangeFormChangeTable, + [SPECIES_MINIOR_METEOR_VIOLET] = sMiniorVioletFormChangeTable, + [SPECIES_MINIOR_CORE_VIOLET] = sMiniorVioletFormChangeTable, + [SPECIES_MINIOR_METEOR_YELLOW] = sMiniorYellowFormChangeTable, + [SPECIES_MINIOR_CORE_YELLOW] = sMiniorYellowFormChangeTable, #endif #if P_GEN_8_POKEMON == TRUE + [SPECIES_CRAMORANT] = sCramorantFormChangeTable, + [SPECIES_CRAMORANT_GULPING] = sCramorantFormChangeTable, + [SPECIES_CRAMORANT_GORGING] = sCramorantFormChangeTable, + [SPECIES_MORPEKO] = sMorpekoFormChangeTable, + [SPECIES_MORPEKO_HANGRY] = sMorpekoFormChangeTable, [SPECIES_ZACIAN] = sZacianFormChangeTable, [SPECIES_ZACIAN_CROWNED_SWORD] = sZacianFormChangeTable, [SPECIES_ZAMAZENTA] = sZamazentaFormChangeTable, diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 94da0add3..551b7484d 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -97,6 +97,22 @@ static const struct FormChange sArceusFormChangeTable[] = { #endif #if P_GEN_5_POKEMON == TRUE + +static const struct FormChange sDarmanitanFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_DARMANITAN}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sDarmanitanGalarianFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_DARMANITAN_GALARIAN}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sMeloettaFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_MELOETTA}, + {FORM_CHANGE_END}, +}; + static const struct FormChange sTornadusFormChangeTable[] = { {FORM_ITEM_USE, SPECIES_TORNADUS_THERIAN, ITEM_REVEAL_GLASS}, {FORM_ITEM_USE, SPECIES_TORNADUS, ITEM_REVEAL_GLASS}, @@ -132,6 +148,16 @@ static const struct FormChange sGenesectFormChangeTable[] = { #endif #if P_GEN_6_POKEMON == TRUE +static const struct FormChange sGreninjaBattleBondFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_GRENINJA_BATTLE_BOND}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sAegislashFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_AEGISLASH}, + {FORM_CHANGE_END}, +}; + static const struct FormChange sXerneasFormChangeTable[] = { {FORM_BATTLE_BEGIN, SPECIES_XERNEAS_ACTIVE}, {FORM_BATTLE_END, SPECIES_XERNEAS, }, @@ -153,6 +179,10 @@ static const struct FormChange sOricorioFormChangeTable[] = { {FORM_ITEM_USE, SPECIES_ORICORIO_SENSU, ITEM_PURPLE_NECTAR}, {FORM_CHANGE_END}, }; +static const struct FormChange sWishiwashiFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_WISHIWASHI}, + {FORM_CHANGE_END}, +}; static const struct FormChange sSilvallyFormChangeTable[] = { {FORM_ITEM_HOLD, SPECIES_SILVALLY, ITEM_NONE, ABILITY_RKS_SYSTEM}, @@ -175,9 +205,54 @@ static const struct FormChange sSilvallyFormChangeTable[] = { {FORM_ITEM_HOLD, SPECIES_SILVALLY_FAIRY, ITEM_FAIRY_MEMORY, ABILITY_RKS_SYSTEM}, {FORM_CHANGE_END}, }; + +static const struct FormChange sMimikyuFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_MIMIKYU}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sMiniorRedFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_MINIOR_CORE_RED}, + {FORM_CHANGE_END}, +}; +static const struct FormChange sMiniorBlueFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_MINIOR_CORE_BLUE}, + {FORM_CHANGE_END}, +}; +static const struct FormChange sMiniorGreenFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_MINIOR_CORE_GREEN}, + {FORM_CHANGE_END}, +}; +static const struct FormChange sMiniorIndigoFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_MINIOR_CORE_INDIGO}, + {FORM_CHANGE_END}, +}; +static const struct FormChange sMiniorOrangeFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_MINIOR_CORE_ORANGE}, + {FORM_CHANGE_END}, +}; +static const struct FormChange sMiniorVioletFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_MINIOR_CORE_VIOLET}, + {FORM_CHANGE_END}, +}; +static const struct FormChange sMiniorYellowFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_MINIOR_CORE_YELLOW}, + {FORM_CHANGE_END}, +}; + #endif #if P_GEN_8_POKEMON == TRUE +static const struct FormChange sCramorantFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_CRAMORANT}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sMorpekoFormChangeTable[] = { + {FORM_BATTLE_END, SPECIES_MORPEKO}, + {FORM_CHANGE_END}, +}; + static const struct FormChange sZacianFormChangeTable[] = { {FORM_BATTLE_BEGIN, SPECIES_ZACIAN_CROWNED_SWORD, ITEM_RUSTED_SWORD, MOVE_IRON_HEAD, MOVE_BEHEMOTH_BLADE}, {FORM_BATTLE_END, SPECIES_ZACIAN, ITEM_RUSTED_SWORD, MOVE_BEHEMOTH_BLADE, MOVE_IRON_HEAD}, diff --git a/src/pokemon.c b/src/pokemon.c index 98ac99256..1a748fb24 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4096,6 +4096,17 @@ void SetMonMoveSlot(struct Pokemon *mon, u16 move, u8 slot) SetMonData(mon, MON_DATA_PP1 + slot, &gBattleMoves[move].pp); } +static void SetMonMoveSlot_KeepPP(struct Pokemon *mon, u16 move, u8 slot) +{ + u8 ppBonuses = GetMonData(mon, MON_DATA_PP_BONUSES, NULL); + u8 currPP = GetMonData(mon, MON_DATA_PP1 + slot, NULL); + u8 newPP = CalculatePPWithBonus(move, ppBonuses, slot); + u8 finalPP = min(currPP, newPP); + + SetMonData(mon, MON_DATA_MOVE1 + slot, &move); + SetMonData(mon, MON_DATA_PP1 + slot, &finalPP); +} + void SetBattleMonMoveSlot(struct BattlePokemon *mon, u16 move, u8 slot) { mon->moves[slot] = move; @@ -8474,20 +8485,21 @@ bool32 ShouldShowFemaleDifferences(u16 species, u32 personality) return (gBaseStats[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE; } -void TryToSetBattleFormChangeMoves(struct Pokemon *mon) +void TryToSetBattleFormChangeMoves(struct Pokemon *mon, u16 method) { int i, j; u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL); const struct FormChange *formChanges = gFormChangeTablePointers[species]; - u8 ppBonuses = GetMonData(mon, MON_DATA_PP_BONUSES, NULL); - if (formChanges == NULL) + if (formChanges == NULL || (method != FORM_BATTLE_BEGIN && method != FORM_BATTLE_END)) return; for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) { - if ((formChanges[i].method == FORM_BATTLE_BEGIN || formChanges[i].method == FORM_BATTLE_END) - && formChanges[i].param2 && formChanges[i].param3 && formChanges[i].targetSpecies == species) + if (formChanges[i].method == method + && formChanges[i].param2 + && formChanges[i].param3 + && formChanges[i].targetSpecies != species) { u16 originalMove = formChanges[i].param2; u16 newMove = formChanges[i].param3; @@ -8495,20 +8507,9 @@ void TryToSetBattleFormChangeMoves(struct Pokemon *mon) for (j = 0; j < MAX_MON_MOVES; j++) { u16 currMove = GetMonData(mon, MON_DATA_MOVE1 + j, NULL); - u8 totalPp = gBattleMoves[currMove].pp; // Get current move's max PP - u8 currPp = GetMonData(mon, MON_DATA_PP1 + j, NULL); // Get current move's remaining PP - u8 diffPp = totalPp - currPp; // Current move's PP difference - u8 finalPp = gBattleMoves[newMove].pp - diffPp; // Apply the PP difference to the new move - if (currMove == originalMove) - { - if (finalPp > gBattleMoves[newMove].pp) - finalPp = 0; - SetMonMoveSlot(mon, newMove, j); - SetMonData(mon, MON_DATA_PP1 + j, &finalPp); - } + SetMonMoveSlot_KeepPP(mon, newMove, j); } - SetMonData(mon, MON_DATA_PP_BONUSES, &ppBonuses); break; } } From ff494edb85ce17bec2b1ecb2163305b195678566 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 20 Oct 2022 16:57:34 -0300 Subject: [PATCH 02/37] Refactored ItemUseOutOfBattle_FormChange to not use secondaryId --- src/data/items.h | 27 ++++++++------------------- src/party_menu.c | 2 +- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/data/items.h b/src/data/items.h index b0b53c31f..78d2e72ab 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -3193,7 +3193,6 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_FormChange_ConsumedOnUse, - .secondaryId = FORM_ITEM_USE, .flingPower = 10, }, @@ -3207,7 +3206,6 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_FormChange_ConsumedOnUse, - .secondaryId = FORM_ITEM_USE, .flingPower = 10, }, @@ -3221,7 +3219,6 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_FormChange_ConsumedOnUse, - .secondaryId = FORM_ITEM_USE, .flingPower = 10, }, @@ -3235,7 +3232,6 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_FormChange_ConsumedOnUse, - .secondaryId = FORM_ITEM_USE, .flingPower = 10, }, @@ -9071,7 +9067,6 @@ const struct Item gItems[] = .pocket = POCKET_KEY_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_FormChange, - .secondaryId = FORM_ITEM_USE, }, [ITEM_REVEAL_GLASS] = @@ -9083,7 +9078,6 @@ const struct Item gItems[] = .pocket = POCKET_KEY_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_FormChange, - .secondaryId = FORM_ITEM_USE, }, [ITEM_DNA_SPLICERS] = @@ -9093,9 +9087,8 @@ const struct Item gItems[] = .price = 0, .description = sDNASplicersDesc, .pocket = POCKET_KEY_ITEMS, - .type = ITEM_USE_PARTY_MENU, - .fieldUseFunc = ItemUseOutOfBattle_FormChange, - .secondaryId = FORM_ITEM_USE, + .type = ITEM_USE_BAG_MENU, + .fieldUseFunc = ItemUseOutOfBattle_CannotUse, // Todo: ItemUseOutOfBattle_FormChange_Fusion }, [ITEM_ZYGARDE_CUBE] = @@ -9119,7 +9112,6 @@ const struct Item gItems[] = .pocket = POCKET_KEY_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_FormChange, - .secondaryId = FORM_ITEM_USE, }, [ITEM_N_SOLARIZER] = @@ -9129,9 +9121,8 @@ const struct Item gItems[] = .price = 0, .description = sNSolarizerDesc, .pocket = POCKET_KEY_ITEMS, - .type = ITEM_USE_PARTY_MENU, - .fieldUseFunc = ItemUseOutOfBattle_FormChange, - .secondaryId = FORM_ITEM_USE, + .type = ITEM_USE_BAG_MENU, + .fieldUseFunc = ItemUseOutOfBattle_CannotUse, // Todo: ItemUseOutOfBattle_FormChange_Fusion }, [ITEM_N_LUNARIZER] = @@ -9141,9 +9132,8 @@ const struct Item gItems[] = .price = 0, .description = sNLunarizerDesc, .pocket = POCKET_KEY_ITEMS, - .type = ITEM_USE_PARTY_MENU, - .fieldUseFunc = ItemUseOutOfBattle_FormChange, - .secondaryId = FORM_ITEM_USE, + .type = ITEM_USE_BAG_MENU, + .fieldUseFunc = ItemUseOutOfBattle_CannotUse, // Todo: ItemUseOutOfBattle_FormChange_Fusion }, [ITEM_REINS_OF_UNITY] = @@ -9153,9 +9143,8 @@ const struct Item gItems[] = .price = 0, .description = sReinsOfUnityDesc, .pocket = POCKET_KEY_ITEMS, - .type = ITEM_USE_PARTY_MENU, - .fieldUseFunc = ItemUseOutOfBattle_FormChange, - .secondaryId = FORM_ITEM_USE, + .type = ITEM_USE_BAG_MENU, + .fieldUseFunc = ItemUseOutOfBattle_CannotUse, // Todo: ItemUseOutOfBattle_FormChange_Fusion }, // Battle Mechanic Key Items diff --git a/src/party_menu.c b/src/party_menu.c index eaeadabab..3c8b163c5 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -5591,7 +5591,7 @@ static void Task_TryItemUseFormChange(u8 taskId) bool32 TryItemUseFormChange(u8 taskId, TaskFunc task) { struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; - u16 targetSpecies = GetFormChangeTargetSpecies(mon, ItemId_GetSecondaryId(gSpecialVar_ItemId), gSpecialVar_ItemId); + u16 targetSpecies = GetFormChangeTargetSpecies(mon, FORM_ITEM_USE, gSpecialVar_ItemId); if (targetSpecies != SPECIES_NONE) { From b74f0777daf19a01fa4892000bab55a6f6285403 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 20 Oct 2022 17:22:58 -0300 Subject: [PATCH 03/37] Renamed form change constants --- include/constants/pokemon.h | 14 +- src/battle_main.c | 6 +- src/battle_script_commands.c | 4 +- src/data/pokemon/form_change_tables.h | 216 +++++++++++++------------- src/daycare.c | 2 +- src/party_menu.c | 4 +- src/pokemon.c | 12 +- src/pokemon_storage_system.c | 2 +- src/script_pokemon_util.c | 2 +- 9 files changed, 131 insertions(+), 131 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 5167f5f55..cacbdc55c 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -317,13 +317,13 @@ #define EVO_MODE_OVERWORLD_SPECIAL 5 // Form change types -#define FORM_CHANGE_END 0 -#define FORM_ITEM_HOLD 1 -#define FORM_ITEM_USE 2 -#define FORM_MOVE 3 -#define FORM_WITHDRAW 4 -#define FORM_BATTLE_BEGIN 5 -#define FORM_BATTLE_END 6 +#define FORM_CHANGE_END 0 +#define FORM_CHANGE_ITEM_HOLD 1 +#define FORM_CHANGE_ITEM_USE 2 +#define FORM_CHANGE_MOVE 3 +#define FORM_CHANGE_WITHDRAW 4 +#define FORM_CHANGE_BATTLE_BEGIN 5 +#define FORM_CHANGE_BATTLE_END 6 #define MON_PIC_WIDTH 64 #define MON_PIC_HEIGHT 64 diff --git a/src/battle_main.c b/src/battle_main.c index 9d75e901c..8a3cbcfcd 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -602,9 +602,9 @@ static void CB2_InitBattleInternal(void) for (i = 0; i < PARTY_SIZE; i++) { // Player's side - BattleFormChange(i, B_SIDE_PLAYER, FORM_BATTLE_BEGIN); + BattleFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_BATTLE_BEGIN); // Opponent's side - BattleFormChange(i, B_SIDE_OPPONENT, FORM_BATTLE_BEGIN); + BattleFormChange(i, B_SIDE_OPPONENT, FORM_CHANGE_BATTLE_BEGIN); } gBattleCommunication[MULTIUSE_STATE] = 0; @@ -5207,7 +5207,7 @@ static void HandleEndTurn_FinishBattle(void) for (i = 0; i < PARTY_SIZE; i++) { UndoMegaEvolution(i); - BattleFormChange(i, B_SIDE_PLAYER, FORM_BATTLE_END); + BattleFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_BATTLE_END); DoBurmyFormChange(i); } #if B_RECALCULATE_STATS >= GEN_5 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index bfc9bfc42..060a9e717 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -14109,7 +14109,7 @@ static void Cmd_handleballthrow(void) { BtlController_EmitBallThrowAnim(BUFFER_A, BALL_3_SHAKES_SUCCESS); MarkBattlerForControllerExec(gActiveBattler); - BattleFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FORM_BATTLE_END), + BattleFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FORM_CHANGE_BATTLE_END), gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); @@ -14163,7 +14163,7 @@ static void Cmd_handleballthrow(void) if (IsCriticalCapture()) gBattleSpritesDataPtr->animationData->criticalCaptureSuccess = TRUE; - BattleFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FORM_BATTLE_END), + BattleFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FORM_CHANGE_BATTLE_END), gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 551b7484d..1f2e926bb 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -1,97 +1,97 @@ /* -FORM_ITEM_HOLD: +FORM_CHANGE_ITEM_HOLD: Form change activates when the specified item is given to or taken from the selected Pokémon. Alternatively, form change activates when the specified item is is given to or taken from the selected Pokémon that has a particular ability. param1 = item to hold param2 = ability to check for, optional -FORM_ITEM_USE: +FORM_CHANGE_ITEM_USE: Form change activates when the item is used on the selected Pokémon. param1 = item to use param2 = DAY if form change activates in the daytime, optional NIGHT if form change activates at nighttime, optional -FORM_MOVE: +FORM_CHANGE_MOVE: Form change activates when the Pokémon learns or forgets the move. param1 = move to check for param2 = WHEN_LEARNED if form change activates when move is forgotten WHEN_FORGOTTEN if form change activates when move is learned -FORM_WITHDRAW: +FORM_CHANGE_WITHDRAW: Form change activates when the Pokémon is withdrawn from the PC or Daycare. no parameters -FORM_BATTLE_BEGIN: +FORM_CHANGE_BATTLE_BEGIN: Form change activates when the Pokémon is sent out at the beginning of a battle param1 = item to hold, optional param2 = a move that will be replaced, optional param3 = a new move to replace it with, optional -FORM_BATTLE_END: +FORM_CHANGE_BATTLE_END: Form change activates at the end of a battle param1 = item to hold, optional param2 = a move that will be replaced, optional param3 = a new move to replace it with, optional */ -// FORM_MOVE param2 Arguments +// FORM_CHANGE_MOVE param2 Arguments #define WHEN_LEARNED 0 #define WHEN_FORGOTTEN 1 -// FORM_ITEM_USE param2 Arguments +// FORM_CHANGE_ITEM_USE param2 Arguments #define DAY 1 #define NIGHT 2 #if P_GEN_4_POKEMON == TRUE static const struct FormChange sGiratinaFormChangeTable[] = { - {FORM_ITEM_HOLD, SPECIES_GIRATINA, ITEM_NONE}, - {FORM_ITEM_HOLD, SPECIES_GIRATINA_ORIGIN, ITEM_GRISEOUS_ORB}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_GIRATINA, ITEM_NONE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_GIRATINA_ORIGIN, ITEM_GRISEOUS_ORB}, {FORM_CHANGE_END}, }; static const struct FormChange sShayminFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, DAY}, - // {FORM_WITHDRAW, SPECIES_SHAYMIN}, + {FORM_CHANGE_ITEM_USE, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, DAY}, + // {FORM_CHANGE_WITHDRAW, SPECIES_SHAYMIN}, {FORM_CHANGE_END}, }; static const struct FormChange sArceusFormChangeTable[] = { - {FORM_ITEM_HOLD, SPECIES_ARCEUS, ITEM_NONE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIGHTING, ITEM_FIST_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIGHTING, ITEM_FIGHTINIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FLYING, ITEM_SKY_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FLYING, ITEM_FLYINIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_POISON, ITEM_TOXIC_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_POISON, ITEM_POISONIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_ROCK, ITEM_STONE_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_ROCK, ITEM_ROCKIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_GROUND, ITEM_EARTH_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_GROUND, ITEM_GROUNDIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_BUG, ITEM_INSECT_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_BUG, ITEM_BUGINIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_GHOST, ITEM_SPOOKY_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_GHOST, ITEM_GHOSTIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_STEEL, ITEM_IRON_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_STEEL, ITEM_STEELIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIRE, ITEM_FLAME_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FIRE, ITEM_FIRIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_WATER, ITEM_SPLASH_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_WATER, ITEM_WATERIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_GRASS, ITEM_MEADOW_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_GRASS, ITEM_GRASSIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_ELECTRIC, ITEM_ZAP_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_ELECTRIC, ITEM_ELECTRIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_PSYCHIC, ITEM_MIND_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_PSYCHIC, ITEM_PSYCHIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_ICE, ITEM_ICICLE_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_ICE, ITEM_ICIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_DRAGON, ITEM_DRACO_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_DRAGON, ITEM_DRAGONIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_DARK, ITEM_DREAD_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_DARK, ITEM_DARKINIUM_Z, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FAIRY, ITEM_PIXIE_PLATE, ABILITY_MULTITYPE}, - {FORM_ITEM_HOLD, SPECIES_ARCEUS_FAIRY, ITEM_FAIRIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS, ITEM_NONE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_FIGHTING, ITEM_FIST_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_FIGHTING, ITEM_FIGHTINIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_FLYING, ITEM_SKY_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_FLYING, ITEM_FLYINIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_POISON, ITEM_TOXIC_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_POISON, ITEM_POISONIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_ROCK, ITEM_STONE_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_ROCK, ITEM_ROCKIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_GROUND, ITEM_EARTH_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_GROUND, ITEM_GROUNDIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_BUG, ITEM_INSECT_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_BUG, ITEM_BUGINIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_GHOST, ITEM_SPOOKY_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_GHOST, ITEM_GHOSTIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_STEEL, ITEM_IRON_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_STEEL, ITEM_STEELIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_FIRE, ITEM_FLAME_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_FIRE, ITEM_FIRIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_WATER, ITEM_SPLASH_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_WATER, ITEM_WATERIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_GRASS, ITEM_MEADOW_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_GRASS, ITEM_GRASSIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_ELECTRIC, ITEM_ZAP_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_ELECTRIC, ITEM_ELECTRIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_PSYCHIC, ITEM_MIND_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_PSYCHIC, ITEM_PSYCHIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_ICE, ITEM_ICICLE_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_ICE, ITEM_ICIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_DRAGON, ITEM_DRACO_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_DRAGON, ITEM_DRAGONIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_DARK, ITEM_DREAD_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_DARK, ITEM_DARKINIUM_Z, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_FAIRY, ITEM_PIXIE_PLATE, ABILITY_MULTITYPE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_FAIRY, ITEM_FAIRIUM_Z, ABILITY_MULTITYPE}, {FORM_CHANGE_END}, }; #endif @@ -99,144 +99,144 @@ static const struct FormChange sArceusFormChangeTable[] = { #if P_GEN_5_POKEMON == TRUE static const struct FormChange sDarmanitanFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_DARMANITAN}, + {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN}, {FORM_CHANGE_END}, }; static const struct FormChange sDarmanitanGalarianFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_DARMANITAN_GALARIAN}, + {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN_GALARIAN}, {FORM_CHANGE_END}, }; static const struct FormChange sMeloettaFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_MELOETTA}, + {FORM_CHANGE_BATTLE_END, SPECIES_MELOETTA}, {FORM_CHANGE_END}, }; static const struct FormChange sTornadusFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_TORNADUS_THERIAN, ITEM_REVEAL_GLASS}, - {FORM_ITEM_USE, SPECIES_TORNADUS, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_ITEM_USE, SPECIES_TORNADUS_THERIAN, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_ITEM_USE, SPECIES_TORNADUS, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; static const struct FormChange sThundurusFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_THUNDURUS_THERIAN, ITEM_REVEAL_GLASS}, - {FORM_ITEM_USE, SPECIES_THUNDURUS, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_ITEM_USE, SPECIES_THUNDURUS_THERIAN, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_ITEM_USE, SPECIES_THUNDURUS, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; static const struct FormChange sLandorusFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_LANDORUS_THERIAN, ITEM_REVEAL_GLASS}, - {FORM_ITEM_USE, SPECIES_LANDORUS, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_ITEM_USE, SPECIES_LANDORUS_THERIAN, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_ITEM_USE, SPECIES_LANDORUS, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; static const struct FormChange sKeldeoFormChangeTable[] = { - // {FORM_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD, WHEN_LEARNED}, - // {FORM_MOVE, SPECIES_KELDEO, MOVE_SECRET_SWORD, WHEN_FORGOTTEN}, + // {FORM_CHANGE_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD, WHEN_LEARNED}, + // {FORM_CHANGE_MOVE, SPECIES_KELDEO, MOVE_SECRET_SWORD, WHEN_FORGOTTEN}, {FORM_CHANGE_END}, }; static const struct FormChange sGenesectFormChangeTable[] = { - {FORM_ITEM_HOLD, SPECIES_GENESECT, ITEM_NONE}, - {FORM_ITEM_HOLD, SPECIES_GENESECT_DOUSE_DRIVE, ITEM_DOUSE_DRIVE}, - {FORM_ITEM_HOLD, SPECIES_GENESECT_SHOCK_DRIVE, ITEM_SHOCK_DRIVE}, - {FORM_ITEM_HOLD, SPECIES_GENESECT_BURN_DRIVE, ITEM_BURN_DRIVE}, - {FORM_ITEM_HOLD, SPECIES_GENESECT_CHILL_DRIVE, ITEM_CHILL_DRIVE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_GENESECT, ITEM_NONE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_GENESECT_DOUSE_DRIVE, ITEM_DOUSE_DRIVE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_GENESECT_SHOCK_DRIVE, ITEM_SHOCK_DRIVE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_GENESECT_BURN_DRIVE, ITEM_BURN_DRIVE}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_GENESECT_CHILL_DRIVE, ITEM_CHILL_DRIVE}, {FORM_CHANGE_END}, }; #endif #if P_GEN_6_POKEMON == TRUE static const struct FormChange sGreninjaBattleBondFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_GRENINJA_BATTLE_BOND}, + {FORM_CHANGE_BATTLE_END, SPECIES_GRENINJA_BATTLE_BOND}, {FORM_CHANGE_END}, }; static const struct FormChange sAegislashFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_AEGISLASH}, + {FORM_CHANGE_BATTLE_END, SPECIES_AEGISLASH}, {FORM_CHANGE_END}, }; static const struct FormChange sXerneasFormChangeTable[] = { - {FORM_BATTLE_BEGIN, SPECIES_XERNEAS_ACTIVE}, - {FORM_BATTLE_END, SPECIES_XERNEAS, }, + {FORM_CHANGE_BATTLE_BEGIN, SPECIES_XERNEAS_ACTIVE}, + {FORM_CHANGE_BATTLE_END, SPECIES_XERNEAS, }, {FORM_CHANGE_END}, }; static const struct FormChange sHoopaFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA}, - // {FORM_WITHDRAW, SPECIES_HOOPA}, + {FORM_CHANGE_ITEM_USE, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA}, + // {FORM_CHANGE_WITHDRAW, SPECIES_HOOPA}, {FORM_CHANGE_END}, }; #endif #if P_GEN_7_POKEMON == TRUE static const struct FormChange sOricorioFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_ORICORIO, ITEM_RED_NECTAR}, - {FORM_ITEM_USE, SPECIES_ORICORIO_POM_POM, ITEM_YELLOW_NECTAR}, - {FORM_ITEM_USE, SPECIES_ORICORIO_PAU, ITEM_PINK_NECTAR}, - {FORM_ITEM_USE, SPECIES_ORICORIO_SENSU, ITEM_PURPLE_NECTAR}, + {FORM_CHANGE_ITEM_USE, SPECIES_ORICORIO, ITEM_RED_NECTAR}, + {FORM_CHANGE_ITEM_USE, SPECIES_ORICORIO_POM_POM, ITEM_YELLOW_NECTAR}, + {FORM_CHANGE_ITEM_USE, SPECIES_ORICORIO_PAU, ITEM_PINK_NECTAR}, + {FORM_CHANGE_ITEM_USE, SPECIES_ORICORIO_SENSU, ITEM_PURPLE_NECTAR}, {FORM_CHANGE_END}, }; static const struct FormChange sWishiwashiFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_WISHIWASHI}, + {FORM_CHANGE_BATTLE_END, SPECIES_WISHIWASHI}, {FORM_CHANGE_END}, }; static const struct FormChange sSilvallyFormChangeTable[] = { - {FORM_ITEM_HOLD, SPECIES_SILVALLY, ITEM_NONE, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_FIGHTING, ITEM_FIGHTING_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_FLYING, ITEM_FLYING_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_POISON, ITEM_POISON_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_GROUND, ITEM_GROUND_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_ROCK, ITEM_ROCK_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_BUG, ITEM_BUG_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_GHOST, ITEM_GHOST_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_STEEL, ITEM_STEEL_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_FIRE, ITEM_FIRE_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_WATER, ITEM_WATER_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_GRASS, ITEM_GRASS_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_ELECTRIC, ITEM_ELECTRIC_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_PSYCHIC, ITEM_PSYCHIC_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_ICE, ITEM_ICE_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_DRAGON, ITEM_DRAGON_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_DARK, ITEM_DARK_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_ITEM_HOLD, SPECIES_SILVALLY_FAIRY, ITEM_FAIRY_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY, ITEM_NONE, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_FIGHTING, ITEM_FIGHTING_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_FLYING, ITEM_FLYING_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_POISON, ITEM_POISON_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_GROUND, ITEM_GROUND_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_ROCK, ITEM_ROCK_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_BUG, ITEM_BUG_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_GHOST, ITEM_GHOST_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_STEEL, ITEM_STEEL_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_FIRE, ITEM_FIRE_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_WATER, ITEM_WATER_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_GRASS, ITEM_GRASS_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_ELECTRIC, ITEM_ELECTRIC_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_PSYCHIC, ITEM_PSYCHIC_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_ICE, ITEM_ICE_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_DRAGON, ITEM_DRAGON_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_DARK, ITEM_DARK_MEMORY, ABILITY_RKS_SYSTEM}, + {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_FAIRY, ITEM_FAIRY_MEMORY, ABILITY_RKS_SYSTEM}, {FORM_CHANGE_END}, }; static const struct FormChange sMimikyuFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_MIMIKYU}, + {FORM_CHANGE_BATTLE_END, SPECIES_MIMIKYU}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorRedFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_MINIOR_CORE_RED}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_RED}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorBlueFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_MINIOR_CORE_BLUE}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_BLUE}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorGreenFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_MINIOR_CORE_GREEN}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_GREEN}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorIndigoFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_MINIOR_CORE_INDIGO}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_INDIGO}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorOrangeFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_MINIOR_CORE_ORANGE}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_ORANGE}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorVioletFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_MINIOR_CORE_VIOLET}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_VIOLET}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorYellowFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_MINIOR_CORE_YELLOW}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_YELLOW}, {FORM_CHANGE_END}, }; @@ -244,30 +244,30 @@ static const struct FormChange sMiniorYellowFormChangeTable[] = { #if P_GEN_8_POKEMON == TRUE static const struct FormChange sCramorantFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_CRAMORANT}, + {FORM_CHANGE_BATTLE_END, SPECIES_CRAMORANT}, {FORM_CHANGE_END}, }; static const struct FormChange sMorpekoFormChangeTable[] = { - {FORM_BATTLE_END, SPECIES_MORPEKO}, + {FORM_CHANGE_BATTLE_END, SPECIES_MORPEKO}, {FORM_CHANGE_END}, }; static const struct FormChange sZacianFormChangeTable[] = { - {FORM_BATTLE_BEGIN, SPECIES_ZACIAN_CROWNED_SWORD, ITEM_RUSTED_SWORD, MOVE_IRON_HEAD, MOVE_BEHEMOTH_BLADE}, - {FORM_BATTLE_END, SPECIES_ZACIAN, ITEM_RUSTED_SWORD, MOVE_BEHEMOTH_BLADE, MOVE_IRON_HEAD}, + {FORM_CHANGE_BATTLE_BEGIN, SPECIES_ZACIAN_CROWNED_SWORD, ITEM_RUSTED_SWORD, MOVE_IRON_HEAD, MOVE_BEHEMOTH_BLADE}, + {FORM_CHANGE_BATTLE_END, SPECIES_ZACIAN, ITEM_RUSTED_SWORD, MOVE_BEHEMOTH_BLADE, MOVE_IRON_HEAD}, {FORM_CHANGE_END}, }; static const struct FormChange sZamazentaFormChangeTable[] = { - {FORM_BATTLE_BEGIN, SPECIES_ZAMAZENTA_CROWNED_SHIELD, ITEM_RUSTED_SHIELD, MOVE_IRON_HEAD, MOVE_BEHEMOTH_BASH}, - {FORM_BATTLE_END, SPECIES_ZAMAZENTA, ITEM_RUSTED_SHIELD, MOVE_BEHEMOTH_BASH, MOVE_IRON_HEAD}, + {FORM_CHANGE_BATTLE_BEGIN, SPECIES_ZAMAZENTA_CROWNED_SHIELD, ITEM_RUSTED_SHIELD, MOVE_IRON_HEAD, MOVE_BEHEMOTH_BASH}, + {FORM_CHANGE_BATTLE_END, SPECIES_ZAMAZENTA, ITEM_RUSTED_SHIELD, MOVE_BEHEMOTH_BASH, MOVE_IRON_HEAD}, {FORM_CHANGE_END}, }; static const struct FormChange sEnamorusFormChangeTable[] = { - {FORM_ITEM_USE, SPECIES_ENAMORUS, ITEM_REVEAL_GLASS}, - {FORM_ITEM_USE, SPECIES_ENAMORUS_THERIAN, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_ITEM_USE, SPECIES_ENAMORUS, ITEM_REVEAL_GLASS}, + {FORM_CHANGE_ITEM_USE, SPECIES_ENAMORUS_THERIAN, ITEM_REVEAL_GLASS}, {FORM_CHANGE_END}, }; #endif diff --git a/src/daycare.c b/src/daycare.c index 18bc45eb0..fc44e200e 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -255,7 +255,7 @@ static u16 TakeSelectedPokemonFromDaycare(struct DaycareMon *daycareMon) species = GetBoxMonData(&daycareMon->mon, MON_DATA_SPECIES); BoxMonToMon(&daycareMon->mon, &pokemon); - newSpecies = GetFormChangeTargetSpecies(&pokemon, FORM_WITHDRAW, 0); + newSpecies = GetFormChangeTargetSpecies(&pokemon, FORM_CHANGE_WITHDRAW, 0); if (newSpecies != SPECIES_NONE) { SetMonData(&pokemon, MON_DATA_SPECIES, &newSpecies); CalculateMonStats(&pokemon); diff --git a/src/party_menu.c b/src/party_menu.c index 3c8b163c5..1071825a6 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -5591,7 +5591,7 @@ static void Task_TryItemUseFormChange(u8 taskId) bool32 TryItemUseFormChange(u8 taskId, TaskFunc task) { struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; - u16 targetSpecies = GetFormChangeTargetSpecies(mon, FORM_ITEM_USE, gSpecialVar_ItemId); + u16 targetSpecies = GetFormChangeTargetSpecies(mon, FORM_CHANGE_ITEM_USE, gSpecialVar_ItemId); if (targetSpecies != SPECIES_NONE) { @@ -5626,7 +5626,7 @@ void ItemUseCB_FormChange_ConsumedOnUse(u8 taskId, TaskFunc task) } void TryItemHoldFormChange(struct Pokemon *mon) { - u16 targetSpecies = GetFormChangeTargetSpecies(mon, FORM_ITEM_HOLD, 0); + u16 targetSpecies = GetFormChangeTargetSpecies(mon, FORM_CHANGE_ITEM_HOLD, 0); if (targetSpecies != SPECIES_NONE) { PlayCry_NormalNoDucking(targetSpecies, 0, CRY_VOLUME_RS, CRY_VOLUME_RS); diff --git a/src/pokemon.c b/src/pokemon.c index 1a748fb24..b60e5a30e 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8363,12 +8363,12 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 { switch (method) { - case FORM_ITEM_HOLD: + case FORM_CHANGE_ITEM_HOLD: if ((heldItem == formChanges[i].param1 || formChanges[i].param1 == ITEM_NONE) && (ability == formChanges[i].param2 || formChanges[i].param2 == ABILITY_NONE)) targetSpecies = formChanges[i].targetSpecies; break; - case FORM_ITEM_USE: + case FORM_CHANGE_ITEM_USE: if (arg == formChanges[i].param1) { switch (formChanges[i].param2) @@ -8389,12 +8389,12 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 } } break; - case FORM_MOVE: + case FORM_CHANGE_MOVE: if (BoxMonKnowsMove(boxMon, formChanges[i].param1) != formChanges[i].param2) targetSpecies = formChanges[i].targetSpecies; break; - case FORM_BATTLE_BEGIN: - case FORM_BATTLE_END: + case FORM_CHANGE_BATTLE_BEGIN: + case FORM_CHANGE_BATTLE_END: if (heldItem == formChanges[i].param1 || formChanges[i].param1 == ITEM_NONE) targetSpecies = formChanges[i].targetSpecies; } @@ -8491,7 +8491,7 @@ void TryToSetBattleFormChangeMoves(struct Pokemon *mon, u16 method) u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL); const struct FormChange *formChanges = gFormChangeTablePointers[species]; - if (formChanges == NULL || (method != FORM_BATTLE_BEGIN && method != FORM_BATTLE_END)) + if (formChanges == NULL || (method != FORM_CHANGE_BATTLE_BEGIN && method != FORM_CHANGE_BATTLE_END)) return; for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 3f58daa86..4cce36a93 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -6900,7 +6900,7 @@ static void ReshowDisplayMon(void) void SetMonFormPSS(struct BoxPokemon *boxMon) { - u16 targetSpecies = GetFormChangeTargetSpeciesBoxMon(boxMon, FORM_ITEM_HOLD, 0); + u16 targetSpecies = GetFormChangeTargetSpeciesBoxMon(boxMon, FORM_CHANGE_ITEM_HOLD, 0); if (targetSpecies != SPECIES_NONE) { SetBoxMonData(boxMon, MON_DATA_SPECIES, &targetSpecies); diff --git a/src/script_pokemon_util.c b/src/script_pokemon_util.c index e33c8ffca..d95079b4d 100755 --- a/src/script_pokemon_util.c +++ b/src/script_pokemon_util.c @@ -72,7 +72,7 @@ u8 ScriptGiveMon(u16 species, u8 level, u16 item, u32 unused1, u32 unused2, u8 u SetMonData(&mon, MON_DATA_HELD_ITEM, heldItem); // In case a mon with a form changing item is given. Eg: SPECIES_ARCEUS with ITEM_SPLASH_PLATE will transform into SPECIES_ARCEUS_WATER upon gifted. - targetSpecies = GetFormChangeTargetSpecies(&mon, FORM_ITEM_HOLD, 0); + targetSpecies = GetFormChangeTargetSpecies(&mon, FORM_CHANGE_ITEM_HOLD, 0); if (targetSpecies != SPECIES_NONE) { SetMonData(&mon, MON_DATA_SPECIES, &targetSpecies); From d8cc7f7abe5e151ca0473585ec68e632e5979693 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 20 Oct 2022 17:56:56 -0300 Subject: [PATCH 04/37] Form change when switching out --- include/constants/pokemon.h | 3 +- src/battle_util.c | 2 +- src/data/pokemon/form_change_tables.h | 43 +++++++++++++++++++-------- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index cacbdc55c..01bc755cd 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -323,7 +323,8 @@ #define FORM_CHANGE_MOVE 3 #define FORM_CHANGE_WITHDRAW 4 #define FORM_CHANGE_BATTLE_BEGIN 5 -#define FORM_CHANGE_BATTLE_END 6 +#define FORM_CHANGE_BATTLE_SWITCH 6 +#define FORM_CHANGE_BATTLE_END 7 #define MON_PIC_WIDTH 64 #define MON_PIC_HEIGHT 64 diff --git a/src/battle_util.c b/src/battle_util.c index 92f79cd8d..003b8b272 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -518,7 +518,7 @@ void HandleAction_Switch(void) if (gBattleResults.playerSwitchesCounter < 255) gBattleResults.playerSwitchesCounter++; - UndoFormChange(gBattlerPartyIndexes[gBattlerAttacker], GetBattlerSide(gBattlerAttacker), TRUE); + BattleFormChange(gBattlerPartyIndexes[gBattlerAttacker], GetBattlerSide(gBattlerAttacker), FORM_CHANGE_BATTLE_SWITCH); } void HandleAction_UseItem(void) diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 1f2e926bb..e043fa462 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -22,6 +22,10 @@ FORM_CHANGE_WITHDRAW: Form change activates when the Pokémon is withdrawn from the PC or Daycare. no parameters +FORM_CHANGE_SWITCH: + Form change activates when the Pokémon is switched out in battle. + no parameters + FORM_CHANGE_BATTLE_BEGIN: Form change activates when the Pokémon is sent out at the beginning of a battle param1 = item to hold, optional @@ -99,12 +103,14 @@ static const struct FormChange sArceusFormChangeTable[] = { #if P_GEN_5_POKEMON == TRUE static const struct FormChange sDarmanitanFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_DARMANITAN}, + {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN}, {FORM_CHANGE_END}, }; static const struct FormChange sDarmanitanGalarianFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN_GALARIAN}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_DARMANITAN_GALARIAN}, + {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN_GALARIAN}, {FORM_CHANGE_END}, }; @@ -154,7 +160,8 @@ static const struct FormChange sGreninjaBattleBondFormChangeTable[] = { }; static const struct FormChange sAegislashFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_AEGISLASH}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_AEGISLASH}, + {FORM_CHANGE_BATTLE_END, SPECIES_AEGISLASH}, {FORM_CHANGE_END}, }; @@ -180,7 +187,8 @@ static const struct FormChange sOricorioFormChangeTable[] = { {FORM_CHANGE_END}, }; static const struct FormChange sWishiwashiFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_WISHIWASHI}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_WISHIWASHI}, + {FORM_CHANGE_BATTLE_END, SPECIES_WISHIWASHI}, {FORM_CHANGE_END}, }; @@ -212,31 +220,38 @@ static const struct FormChange sMimikyuFormChangeTable[] = { }; static const struct FormChange sMiniorRedFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_RED}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_RED}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_RED}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorBlueFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_BLUE}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_BLUE}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_BLUE}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorGreenFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_GREEN}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_GREEN}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_GREEN}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorIndigoFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_INDIGO}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_INDIGO}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_INDIGO}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorOrangeFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_ORANGE}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_ORANGE}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_ORANGE}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorVioletFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_VIOLET}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_VIOLET}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_VIOLET}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorYellowFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_YELLOW}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_YELLOW}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_YELLOW}, {FORM_CHANGE_END}, }; @@ -244,12 +259,14 @@ static const struct FormChange sMiniorYellowFormChangeTable[] = { #if P_GEN_8_POKEMON == TRUE static const struct FormChange sCramorantFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_CRAMORANT}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_CRAMORANT}, + {FORM_CHANGE_BATTLE_END, SPECIES_CRAMORANT}, {FORM_CHANGE_END}, }; static const struct FormChange sMorpekoFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_MORPEKO}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MORPEKO}, + {FORM_CHANGE_BATTLE_END, SPECIES_MORPEKO}, {FORM_CHANGE_END}, }; From 861590f747b7f43022f257980c7abb0f29953cf9 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 20 Oct 2022 18:53:12 -0300 Subject: [PATCH 05/37] Form change when fainting. Goodbye UndoFormChange! --- include/battle_util.h | 1 - include/constants/pokemon.h | 3 ++- src/battle_main.c | 2 +- src/battle_util.c | 38 --------------------------- src/data/pokemon/form_change_tables.h | 22 +++++++++++++--- 5 files changed, 22 insertions(+), 44 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index 59ddad940..fb5090f34 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -149,7 +149,6 @@ u16 GetPrimalReversionSpecies(u16 preEvoSpecies, u16 heldItemId); u16 GetWishMegaEvolutionSpecies(u16 preEvoSpecies, u16 moveId1, u16 moveId2, u16 moveId3, u16 moveId4); bool32 CanMegaEvolve(u8 battlerId); void UndoMegaEvolution(u32 monId); -void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut); void BattleFormChange(u32 monId, u32 side, u16 method); bool32 DoBattlersShareType(u32 battler1, u32 battler2); bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId); diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 01bc755cd..bb77398dd 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -324,7 +324,8 @@ #define FORM_CHANGE_WITHDRAW 4 #define FORM_CHANGE_BATTLE_BEGIN 5 #define FORM_CHANGE_BATTLE_SWITCH 6 -#define FORM_CHANGE_BATTLE_END 7 +#define FORM_CHANGE_BATTLE_FAINT 7 +#define FORM_CHANGE_BATTLE_END 8 #define MON_PIC_WIDTH 64 #define MON_PIC_HEIGHT 64 diff --git a/src/battle_main.c b/src/battle_main.c index 8a3cbcfcd..71d263860 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3247,7 +3247,7 @@ void FaintClearSetData(void) gBattleMons[gActiveBattler].type3 = TYPE_MYSTERY; Ai_UpdateFaintData(gActiveBattler); - UndoFormChange(gBattlerPartyIndexes[gActiveBattler], GET_BATTLER_SIDE(gActiveBattler), FALSE); + BattleFormChange(gBattlerPartyIndexes[gActiveBattler], GET_BATTLER_SIDE(gActiveBattler), FORM_CHANGE_BATTLE_FAINT); if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) UndoMegaEvolution(gBattlerPartyIndexes[gActiveBattler]); diff --git a/src/battle_util.c b/src/battle_util.c index 003b8b272..f39d2a03e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -9690,44 +9690,6 @@ void UndoMegaEvolution(u32 monId) } } -void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut) -{ - u32 i, currSpecies, targetSpecies; - struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; - static const u16 species[][3] = - { - // Changed Form ID Default Form ID Should change on switch - {SPECIES_MIMIKYU_BUSTED, SPECIES_MIMIKYU, FALSE}, - {SPECIES_GRENINJA_ASH, SPECIES_GRENINJA_BATTLE_BOND, FALSE}, - {SPECIES_MELOETTA_PIROUETTE, SPECIES_MELOETTA, FALSE}, - {SPECIES_AEGISLASH_BLADE, SPECIES_AEGISLASH, TRUE}, - {SPECIES_DARMANITAN_ZEN_MODE, SPECIES_DARMANITAN, TRUE}, - {SPECIES_MINIOR, SPECIES_MINIOR_CORE_RED, TRUE}, - {SPECIES_MINIOR_METEOR_BLUE, SPECIES_MINIOR_CORE_BLUE, TRUE}, - {SPECIES_MINIOR_METEOR_GREEN, SPECIES_MINIOR_CORE_GREEN, TRUE}, - {SPECIES_MINIOR_METEOR_INDIGO, SPECIES_MINIOR_CORE_INDIGO, TRUE}, - {SPECIES_MINIOR_METEOR_ORANGE, SPECIES_MINIOR_CORE_ORANGE, TRUE}, - {SPECIES_MINIOR_METEOR_VIOLET, SPECIES_MINIOR_CORE_VIOLET, TRUE}, - {SPECIES_MINIOR_METEOR_YELLOW, SPECIES_MINIOR_CORE_YELLOW, TRUE}, - {SPECIES_WISHIWASHI_SCHOOL, SPECIES_WISHIWASHI, TRUE}, - {SPECIES_CRAMORANT_GORGING, SPECIES_CRAMORANT, TRUE}, - {SPECIES_CRAMORANT_GULPING, SPECIES_CRAMORANT, TRUE}, - {SPECIES_MORPEKO_HANGRY, SPECIES_MORPEKO, TRUE}, - {SPECIES_DARMANITAN_ZEN_MODE_GALARIAN, SPECIES_DARMANITAN_GALARIAN, TRUE}, - }; - - currSpecies = GetMonData(&party[monId], MON_DATA_SPECIES, NULL); - for (i = 0; i < ARRAY_COUNT(species); i++) - { - if (currSpecies == species[i][0] && (!isSwitchingOut || species[i][2] == TRUE)) - { - SetMonData(&party[monId], MON_DATA_SPECIES, &species[i][1]); - CalculateMonStats(&party[monId]); - break; - } - } -} - void BattleFormChange(u32 monId, u32 side, u16 method) { u32 targetSpecies; diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index e043fa462..0586c8ac8 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -104,18 +104,21 @@ static const struct FormChange sArceusFormChangeTable[] = { static const struct FormChange sDarmanitanFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_DARMANITAN}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_DARMANITAN}, {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN}, {FORM_CHANGE_END}, }; static const struct FormChange sDarmanitanGalarianFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_DARMANITAN_GALARIAN}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_DARMANITAN_GALARIAN}, {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN_GALARIAN}, {FORM_CHANGE_END}, }; static const struct FormChange sMeloettaFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_MELOETTA}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_MELOETTA}, + {FORM_CHANGE_BATTLE_END, SPECIES_MELOETTA}, {FORM_CHANGE_END}, }; @@ -155,12 +158,14 @@ static const struct FormChange sGenesectFormChangeTable[] = { #if P_GEN_6_POKEMON == TRUE static const struct FormChange sGreninjaBattleBondFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_GRENINJA_BATTLE_BOND}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_GRENINJA_BATTLE_BOND}, + {FORM_CHANGE_BATTLE_END, SPECIES_GRENINJA_BATTLE_BOND}, {FORM_CHANGE_END}, }; static const struct FormChange sAegislashFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_AEGISLASH}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_AEGISLASH}, {FORM_CHANGE_BATTLE_END, SPECIES_AEGISLASH}, {FORM_CHANGE_END}, }; @@ -188,6 +193,7 @@ static const struct FormChange sOricorioFormChangeTable[] = { }; static const struct FormChange sWishiwashiFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_WISHIWASHI}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_WISHIWASHI}, {FORM_CHANGE_BATTLE_END, SPECIES_WISHIWASHI}, {FORM_CHANGE_END}, }; @@ -215,42 +221,50 @@ static const struct FormChange sSilvallyFormChangeTable[] = { }; static const struct FormChange sMimikyuFormChangeTable[] = { - {FORM_CHANGE_BATTLE_END, SPECIES_MIMIKYU}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_MIMIKYU}, + {FORM_CHANGE_BATTLE_END, SPECIES_MIMIKYU}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorRedFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_RED}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_RED}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_RED}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorBlueFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_BLUE}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_BLUE}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_BLUE}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorGreenFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_GREEN}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_GREEN}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_GREEN}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorIndigoFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_INDIGO}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_INDIGO}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_INDIGO}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorOrangeFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_ORANGE}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_ORANGE}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_ORANGE}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorVioletFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_VIOLET}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_VIOLET}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_VIOLET}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorYellowFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_YELLOW}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_YELLOW}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_YELLOW}, {FORM_CHANGE_END}, }; @@ -260,12 +274,14 @@ static const struct FormChange sMiniorYellowFormChangeTable[] = { #if P_GEN_8_POKEMON == TRUE static const struct FormChange sCramorantFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_CRAMORANT}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_CRAMORANT}, {FORM_CHANGE_BATTLE_END, SPECIES_CRAMORANT}, {FORM_CHANGE_END}, }; static const struct FormChange sMorpekoFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MORPEKO}, + {FORM_CHANGE_BATTLE_FAINT, SPECIES_MORPEKO}, {FORM_CHANGE_BATTLE_END, SPECIES_MORPEKO}, {FORM_CHANGE_END}, }; From 0a79390ec00e982240edb8513b59b440e7218a45 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 21 Oct 2022 02:08:37 -0300 Subject: [PATCH 06/37] Primal Reversion in Form Change tables --- include/battle.h | 3 - include/battle_util.h | 6 +- include/constants/pokemon.h | 37 ++++++------ include/pokemon.h | 2 + src/battle_interface.c | 16 +++--- src/battle_main.c | 31 +++++----- src/battle_script_commands.c | 43 ++------------ src/battle_util.c | 56 +++++++++++++------ src/data/pokemon/base_stats.h | 4 +- src/data/pokemon/evolution.h | 2 - src/data/pokemon/form_change_table_pointers.h | 4 ++ src/data/pokemon/form_change_tables.h | 14 ++++- src/pokemon.c | 27 ++++++++- 13 files changed, 136 insertions(+), 109 deletions(-) diff --git a/include/battle.h b/include/battle.h index b328b46bb..ff5d698ab 100644 --- a/include/battle.h +++ b/include/battle.h @@ -472,9 +472,6 @@ struct MegaEvolutionData bool8 alreadyEvolved[4]; // Array id is used for mon position. u16 evolvedSpecies[MAX_BATTLERS_COUNT]; u16 playerEvolvedSpecies; - u8 primalRevertedPartyIds[2]; // As flags using gBitTable; - u16 primalRevertedSpecies[MAX_BATTLERS_COUNT]; - u16 playerPrimalRevertedSpecies; u8 battlerId; bool8 playerSelect; u8 triggerSpriteId; diff --git a/include/battle_util.h b/include/battle_util.h index fb5090f34..5a0990950 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -145,11 +145,12 @@ u16 CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, u16 abilit u16 GetTypeModifier(u8 atkType, u8 defType); s32 GetStealthHazardDamage(u8 hazardType, u8 battlerId); u16 GetMegaEvolutionSpecies(u16 preEvoSpecies, u16 heldItemId); -u16 GetPrimalReversionSpecies(u16 preEvoSpecies, u16 heldItemId); +u16 GetPrimalReversionSpecies(u16 preSpecies, u16 heldItemId); u16 GetWishMegaEvolutionSpecies(u16 preEvoSpecies, u16 moveId1, u16 moveId2, u16 moveId3, u16 moveId4); bool32 CanMegaEvolve(u8 battlerId); void UndoMegaEvolution(u32 monId); -void BattleFormChange(u32 monId, u32 side, u16 method); +bool32 IsBattlerPrimalReverted(u8 battlerId); +void TryBattleFormChange(u8 battlerId, u16 method); bool32 DoBattlersShareType(u32 battler1, u32 battler2); bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId); struct Pokemon *GetIllusionMonPtr(u32 battlerId); @@ -186,6 +187,7 @@ void TryToRevertMimicry(void); void RestoreBattlerOriginalTypes(u8 battlerId); u32 GetBattlerMoveTargetType(u8 battlerId, u16 move); bool32 CanTargetBattler(u8 battlerAtk, u8 battlerDef, u16 move); +void RecalcBattlerStats(u32 battler, struct Pokemon *mon); // Ability checks bool32 IsRolePlayBannedAbilityAtk(u16 ability); bool32 IsRolePlayBannedAbility(u16 ability); diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index bb77398dd..7dc250834 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -266,7 +266,6 @@ // Evolution types #define EVO_MEGA_EVOLUTION 0xffff // Not an actual evolution, used to temporarily mega evolve in battle. #define EVO_MOVE_MEGA_EVOLUTION 0xfffe // Mega Evolution that checks for a move instead of held item. -#define EVO_PRIMAL_REVERSION 0xfffd // Not an actual evolution, used to undergo primal reversion in battle. #define EVO_FRIENDSHIP 1 // Pokémon levels up with friendship ≥ 220 #define EVO_FRIENDSHIP_DAY 2 // Pokémon levels up during the day with friendship ≥ 220 #define EVO_FRIENDSHIP_NIGHT 3 // Pokémon levels up at night with friendship ≥ 220 @@ -317,15 +316,16 @@ #define EVO_MODE_OVERWORLD_SPECIAL 5 // Form change types -#define FORM_CHANGE_END 0 -#define FORM_CHANGE_ITEM_HOLD 1 -#define FORM_CHANGE_ITEM_USE 2 -#define FORM_CHANGE_MOVE 3 -#define FORM_CHANGE_WITHDRAW 4 -#define FORM_CHANGE_BATTLE_BEGIN 5 -#define FORM_CHANGE_BATTLE_SWITCH 6 -#define FORM_CHANGE_BATTLE_FAINT 7 -#define FORM_CHANGE_BATTLE_END 8 +#define FORM_CHANGE_END 0 // Form table terminator +#define FORM_CHANGE_ITEM_HOLD 1 +#define FORM_CHANGE_ITEM_USE 2 +#define FORM_CHANGE_MOVE 3 // Todo +#define FORM_CHANGE_WITHDRAW 4 // +#define FORM_CHANGE_BATTLE_BEGIN 5 +#define FORM_CHANGE_BATTLE_END 6 +#define FORM_CHANGE_BATTLE_SWITCH 7 +#define FORM_CHANGE_BATTLE_FAINT 8 +#define FORM_CHANGE_PRIMAL_REVERSION 9 #define MON_PIC_WIDTH 64 #define MON_PIC_HEIGHT 64 @@ -345,14 +345,15 @@ #define SPECIES_FLAG_LEGENDARY (1 << 0) #define SPECIES_FLAG_MYTHICAL (1 << 1) #define SPECIES_FLAG_MEGA_EVOLUTION (1 << 2) -#define SPECIES_FLAG_ULTRA_BEAST (1 << 3) -#define SPECIES_FLAG_ALOLAN_FORM (1 << 4) -#define SPECIES_FLAG_GALARIAN_FORM (1 << 5) -#define SPECIES_FLAG_HISUIAN_FORM (1 << 6) -#define SPECIES_FLAG_GENDER_DIFFERENCE (1 << 7) -#define SPECIES_FLAG_ALL_PERFECT_IVS (1 << 8) -#define SPECIES_FLAG_SHINY_LOCKED (1 << 9) -#define SPECIES_FLAG_CANNOT_BE_TRADED (1 << 10) +#define SPECIES_FLAG_PRIMAL_REVERSION (1 << 3) +#define SPECIES_FLAG_ULTRA_BEAST (1 << 4) +#define SPECIES_FLAG_ALOLAN_FORM (1 << 5) +#define SPECIES_FLAG_GALARIAN_FORM (1 << 6) +#define SPECIES_FLAG_HISUIAN_FORM (1 << 7) +#define SPECIES_FLAG_GENDER_DIFFERENCE (1 << 8) +#define SPECIES_FLAG_ALL_PERFECT_IVS (1 << 9) +#define SPECIES_FLAG_SHINY_LOCKED (1 << 10) +#define SPECIES_FLAG_CANNOT_BE_TRADED (1 << 11) #define LEGENDARY_PERFECT_IV_COUNT 3 diff --git a/include/pokemon.h b/include/pokemon.h index fa5bfc663..134991b95 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -409,6 +409,7 @@ extern const u16 gUnionRoomFacilityClasses[]; extern const struct SpriteTemplate gBattlerSpriteTemplates[]; extern const s8 gNatureStatTable[][5]; extern const u16 *const gFormSpeciesIdTables[NUM_SPECIES]; +extern const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES]; extern const u32 sExpCandyExperienceTable[]; void ZeroBoxMonData(struct BoxPokemon *boxMon); @@ -564,6 +565,7 @@ u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg); u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *mon, u16 method, u32 arg); u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove); bool32 ShouldShowFemaleDifferences(u16 species, u32 personality); +void TryFormChange(u32 monId, u32 side, u16 method); void TryToSetBattleFormChangeMoves(struct Pokemon *mon, u16 method); u32 GetMonFriendshipScore(struct Pokemon *pokemon); diff --git a/src/battle_interface.c b/src/battle_interface.c index 3039c65b6..ed756592f 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -871,8 +871,8 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId) healthBarSpritePtr->invisible = TRUE; // Create mega indicator sprite if is a mega evolved or a primal reverted mon. - if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]] - || gBattleStruct->mega.primalRevertedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + if ((gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + || IsBattlerPrimalReverted(battlerId)) { megaIndicatorSpriteId = CreateMegaIndicatorSprite(battlerId, 0); gSprites[megaIndicatorSpriteId].invisible = TRUE; @@ -979,8 +979,8 @@ void SetHealthboxSpriteVisible(u8 healthboxSpriteId) gSprites[healthboxSpriteId].invisible = FALSE; gSprites[gSprites[healthboxSpriteId].hMain_HealthBarSpriteId].invisible = FALSE; gSprites[gSprites[healthboxSpriteId].oam.affineParam].invisible = FALSE; - if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]] - || gBattleStruct->mega.primalRevertedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + if ((gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + || IsBattlerPrimalReverted(battlerId)) { u8 spriteId = GetMegaIndicatorSpriteId(healthboxSpriteId); if (spriteId != 0xFF) @@ -1104,8 +1104,8 @@ static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl) u8 battler = gSprites[healthboxSpriteId].hMain_Battler; // Don't print Lv char if mon is mega evolved or primal reverted. - if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]] - || gBattleStruct->mega.primalRevertedPartyIds[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]]) + if ((gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]]) + || IsBattlerPrimalReverted(battler)) { objVram = ConvertIntToDecimalStringN(text, lvl, STR_CONV_MODE_LEFT_ALIGN, 3); xPos = 5 * (3 - (objVram - (text + 2))) - 1; @@ -1561,7 +1561,7 @@ u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which) LoadSpritePalette(&sSpritePalette_MegaIndicator); LoadSpriteSheet(&sSpriteSheet_MegaIndicator); } - else if (gBattleStruct->mega.primalRevertedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + else if (IsBattlerPrimalReverted(battlerId)) { if (GET_BASE_SPECIES_ID(gBattleMons[battlerId].species) == SPECIES_GROUDON) { @@ -1590,7 +1590,7 @@ u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which) { spriteId = CreateSpriteAtEnd(&sSpriteTemplate_MegaIndicator, x, y, 0); } - else if (gBattleStruct->mega.primalRevertedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + else if (IsBattlerPrimalReverted(battlerId)) { if (GET_BASE_SPECIES_ID(gBattleMons[battlerId].species) == SPECIES_GROUDON) spriteId = CreateSpriteAtEnd(&sSpriteTemplate_OmegaIndicator, x, y, 0); diff --git a/src/battle_main.c b/src/battle_main.c index 71d263860..f58c0d43b 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -602,9 +602,9 @@ static void CB2_InitBattleInternal(void) for (i = 0; i < PARTY_SIZE; i++) { // Player's side - BattleFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_BATTLE_BEGIN); + TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_BATTLE_BEGIN); // Opponent's side - BattleFormChange(i, B_SIDE_OPPONENT, FORM_CHANGE_BATTLE_BEGIN); + TryFormChange(i, B_SIDE_OPPONENT, FORM_CHANGE_BATTLE_BEGIN); } gBattleCommunication[MULTIUSE_STATE] = 0; @@ -3247,7 +3247,7 @@ void FaintClearSetData(void) gBattleMons[gActiveBattler].type3 = TYPE_MYSTERY; Ai_UpdateFaintData(gActiveBattler); - BattleFormChange(gBattlerPartyIndexes[gActiveBattler], GET_BATTLER_SIDE(gActiveBattler), FORM_CHANGE_BATTLE_FAINT); + TryFormChange(gBattlerPartyIndexes[gActiveBattler], GET_BATTLER_SIDE(gActiveBattler), FORM_CHANGE_BATTLE_FAINT); if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) UndoMegaEvolution(gBattlerPartyIndexes[gActiveBattler]); @@ -3682,18 +3682,12 @@ static void TryDoEventsBeforeFirstTurn(void) // Primal Reversion for (i = 0; i < gBattlersCount; i++) { - if (GetBattlerHoldEffect(i, TRUE) == HOLD_EFFECT_PRIMAL_ORB) + if (GetBattlerHoldEffect(i, TRUE) == HOLD_EFFECT_PRIMAL_ORB + && GetPrimalReversionSpecies(gBattleMons[i].species, gBattleMons[i].item) != SPECIES_NONE) { - for (j = 0; j < EVOS_PER_MON; j++) - { - if (gEvolutionTable[gBattleMons[i].species][j].targetSpecies != SPECIES_NONE - && gEvolutionTable[gBattleMons[i].species][j].method == EVO_PRIMAL_REVERSION) - { - gBattlerAttacker = i; - BattleScriptExecute(BattleScript_PrimalReversion); - return; - } - } + gBattlerAttacker = i; + BattleScriptExecute(BattleScript_PrimalReversion); + return; } } @@ -5207,7 +5201,7 @@ static void HandleEndTurn_FinishBattle(void) for (i = 0; i < PARTY_SIZE; i++) { UndoMegaEvolution(i); - BattleFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_BATTLE_END); + TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_BATTLE_END); DoBurmyFormChange(i); } #if B_RECALCULATE_STATS >= GEN_5 @@ -5221,6 +5215,13 @@ static void HandleEndTurn_FinishBattle(void) } } #endif + // Clear battle mon species to avoid a bug on the next battle that causes + // healthboxes loading incorrectly due to it trying to create a Mega Indicator + // if the previous battler would've had. + for (i = 0; i < MAX_BATTLERS_COUNT; i++) + { + gBattleMons[i].species = SPECIES_NONE; + } gBattleMainFunc = FreeResetData_ReturnToOvOrDoEvolutions; gCB2_AfterEvolution = BattleMainCB2; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 060a9e717..51d3cfbe1 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7914,22 +7914,6 @@ u32 IsAbilityStatusProtected(u32 battler) || IsShieldsDownProtected(battler); } -static void RecalcBattlerStats(u32 battler, struct Pokemon *mon) -{ - CalculateMonStats(mon); - gBattleMons[battler].level = GetMonData(mon, MON_DATA_LEVEL); - gBattleMons[battler].hp = GetMonData(mon, MON_DATA_HP); - gBattleMons[battler].maxHP = GetMonData(mon, MON_DATA_MAX_HP); - gBattleMons[battler].attack = GetMonData(mon, MON_DATA_ATK); - gBattleMons[battler].defense = GetMonData(mon, MON_DATA_DEF); - gBattleMons[battler].speed = GetMonData(mon, MON_DATA_SPEED); - gBattleMons[battler].spAttack = GetMonData(mon, MON_DATA_SPATK); - gBattleMons[battler].spDefense = GetMonData(mon, MON_DATA_SPDEF); - gBattleMons[battler].ability = GetMonAbility(mon); - gBattleMons[battler].type1 = gBaseStats[gBattleMons[battler].species].type1; - gBattleMons[battler].type2 = gBaseStats[gBattleMons[battler].species].type2; -} - static u32 GetHighestStatId(u32 battlerId) { u32 i, highestId = STAT_ATK, highestStat = gBattleMons[battlerId].attack; @@ -8870,17 +8854,7 @@ static void Cmd_various(void) // Change species. if (gBattlescriptCurrInstr[3] == 0) { - u16 primalSpecies; - gBattleStruct->mega.primalRevertedSpecies[gActiveBattler] = gBattleMons[gActiveBattler].species; - if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT - || (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT && !(gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER)))) - { - gBattleStruct->mega.playerPrimalRevertedSpecies = gBattleStruct->mega.primalRevertedSpecies[gActiveBattler]; - } - // Checks Primal Reversion - primalSpecies = GetPrimalReversionSpecies(gBattleStruct->mega.primalRevertedSpecies[gActiveBattler], gBattleMons[gActiveBattler].item); - - gBattleMons[gActiveBattler].species = primalSpecies; + gBattleMons[gActiveBattler].species = GetPrimalReversionSpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].item); PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gActiveBattler].species); BtlController_EmitSetMonData(BUFFER_A, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[gActiveBattler]], sizeof(gBattleMons[gActiveBattler].species), &gBattleMons[gActiveBattler].species); @@ -8890,7 +8864,6 @@ static void Cmd_various(void) else if (gBattlescriptCurrInstr[3] == 1) { RecalcBattlerStats(gActiveBattler, mon); - gBattleStruct->mega.primalRevertedPartyIds[GetBattlerSide(gActiveBattler)] |= gBitTable[gBattlerPartyIndexes[gActiveBattler]]; } // Update healthbox and elevation. else @@ -9606,15 +9579,7 @@ static void Cmd_various(void) return; case VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL: { - bool8 canDoPrimalReversion = FALSE; - - for (i = 0; i < EVOS_PER_MON; i++) - { - if (gEvolutionTable[gBattleMons[gActiveBattler].species][i].method == EVO_PRIMAL_REVERSION - && gEvolutionTable[gBattleMons[gActiveBattler].species][i].param == gBattleMons[gActiveBattler].item) - canDoPrimalReversion = TRUE; - } - if (!canDoPrimalReversion) + if (GetPrimalReversionSpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].item) == SPECIES_NONE) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); else gBattlescriptCurrInstr += 7; @@ -14109,7 +14074,7 @@ static void Cmd_handleballthrow(void) { BtlController_EmitBallThrowAnim(BUFFER_A, BALL_3_SHAKES_SUCCESS); MarkBattlerForControllerExec(gActiveBattler); - BattleFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FORM_CHANGE_BATTLE_END), + TryFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FORM_CHANGE_BATTLE_END), gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); @@ -14163,7 +14128,7 @@ static void Cmd_handleballthrow(void) if (IsCriticalCapture()) gBattleSpritesDataPtr->animationData->criticalCaptureSuccess = TRUE; - BattleFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FORM_CHANGE_BATTLE_END), + TryFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FORM_CHANGE_BATTLE_END), gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); diff --git a/src/battle_util.c b/src/battle_util.c index f39d2a03e..729728ec0 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -518,7 +518,7 @@ void HandleAction_Switch(void) if (gBattleResults.playerSwitchesCounter < 255) gBattleResults.playerSwitchesCounter++; - BattleFormChange(gBattlerPartyIndexes[gBattlerAttacker], GetBattlerSide(gBattlerAttacker), FORM_CHANGE_BATTLE_SWITCH); + TryFormChange(gBattlerPartyIndexes[gBattlerAttacker], GetBattlerSide(gBattlerAttacker), FORM_CHANGE_BATTLE_SWITCH); } void HandleAction_UseItem(void) @@ -8955,8 +8955,7 @@ static bool32 CanEvolve(u32 species) { if (gEvolutionTable[species][i].method && gEvolutionTable[species][i].method != EVO_MEGA_EVOLUTION - && gEvolutionTable[species][i].method != EVO_MOVE_MEGA_EVOLUTION - && gEvolutionTable[species][i].method != EVO_PRIMAL_REVERSION) + && gEvolutionTable[species][i].method != EVO_MOVE_MEGA_EVOLUTION) return TRUE; } return FALSE; @@ -9565,15 +9564,20 @@ u16 GetMegaEvolutionSpecies(u16 preEvoSpecies, u16 heldItemId) return SPECIES_NONE; } -u16 GetPrimalReversionSpecies(u16 preEvoSpecies, u16 heldItemId) +u16 GetPrimalReversionSpecies(u16 preSpecies, u16 heldItemId) { u32 i; + const struct FormChange *formChanges = gFormChangeTablePointers[preSpecies]; - for (i = 0; i < EVOS_PER_MON; i++) + if (formChanges != NULL) { - if (gEvolutionTable[preEvoSpecies][i].method == EVO_PRIMAL_REVERSION - && gEvolutionTable[preEvoSpecies][i].param == heldItemId) - return gEvolutionTable[preEvoSpecies][i].targetSpecies; + for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) + { + if (formChanges[i].method == FORM_CHANGE_PRIMAL_REVERSION + && formChanges[i].param1 == heldItemId + && formChanges[i].targetSpecies != preSpecies) + return formChanges[i].targetSpecies; + } } return SPECIES_NONE; } @@ -9675,12 +9679,6 @@ void UndoMegaEvolution(u32 monId) SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleStruct->mega.playerEvolvedSpecies); CalculateMonStats(&gPlayerParty[monId]); } - else if (gBattleStruct->mega.primalRevertedPartyIds[B_SIDE_PLAYER] & gBitTable[monId]) - { - gBattleStruct->mega.primalRevertedPartyIds[B_SIDE_PLAYER] &= ~(gBitTable[monId]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &baseSpecies); - CalculateMonStats(&gPlayerParty[monId]); - } // While not exactly a mega evolution, Zygarde follows the same rules. else if (GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, NULL) == SPECIES_ZYGARDE_COMPLETE) { @@ -9690,17 +9688,23 @@ void UndoMegaEvolution(u32 monId) } } -void BattleFormChange(u32 monId, u32 side, u16 method) +bool32 IsBattlerPrimalReverted(u8 battlerId) { - u32 targetSpecies; + return (gBaseStats[gBattleMons[battlerId].species].flags & SPECIES_FLAG_PRIMAL_REVERSION); +} + +void TryBattleFormChange(u8 battlerId, u16 method) +{ + u16 targetSpecies; + u8 monId = gBattlerPartyIndexes[battlerId]; + u8 side = GET_BATTLER_SIDE(battlerId); struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; targetSpecies = GetFormChangeTargetSpecies(&party[monId], method, 0); if (targetSpecies != SPECIES_NONE) { - TryToSetBattleFormChangeMoves(&party[monId], method); SetMonData(&party[monId], MON_DATA_SPECIES, &targetSpecies); - CalculateMonStats(&party[monId]); + RecalcBattlerStats(battlerId, &party[monId]); } } @@ -10362,3 +10366,19 @@ bool32 CanTargetBattler(u8 battlerAtk, u8 battlerDef, u16 move) return FALSE; // Pokémon affected by Heal Block cannot target allies with Pollen Puff return TRUE; } + +void RecalcBattlerStats(u32 battler, struct Pokemon *mon) +{ + CalculateMonStats(mon); + gBattleMons[battler].level = GetMonData(mon, MON_DATA_LEVEL); + gBattleMons[battler].hp = GetMonData(mon, MON_DATA_HP); + gBattleMons[battler].maxHP = GetMonData(mon, MON_DATA_MAX_HP); + gBattleMons[battler].attack = GetMonData(mon, MON_DATA_ATK); + gBattleMons[battler].defense = GetMonData(mon, MON_DATA_DEF); + gBattleMons[battler].speed = GetMonData(mon, MON_DATA_SPEED); + gBattleMons[battler].spAttack = GetMonData(mon, MON_DATA_SPATK); + gBattleMons[battler].spDefense = GetMonData(mon, MON_DATA_SPDEF); + gBattleMons[battler].ability = GetMonAbility(mon); + gBattleMons[battler].type1 = gBaseStats[gBattleMons[battler].species].type1; + gBattleMons[battler].type2 = gBaseStats[gBattleMons[battler].species].type2; +} diff --git a/src/data/pokemon/base_stats.h b/src/data/pokemon/base_stats.h index a161fbf90..a13ea5939 100644 --- a/src/data/pokemon/base_stats.h +++ b/src/data/pokemon/base_stats.h @@ -24117,7 +24117,7 @@ const struct BaseStats gBaseStats[] = .abilities = {ABILITY_PRIMORDIAL_SEA, ABILITY_PRIMORDIAL_SEA}, .bodyColor = BODY_COLOR_BLUE, .noFlip = FALSE, - .flags = SPECIES_FLAG_LEGENDARY, + .flags = SPECIES_FLAG_LEGENDARY | SPECIES_FLAG_PRIMAL_REVERSION, }, [SPECIES_GROUDON_PRIMAL] = @@ -24142,7 +24142,7 @@ const struct BaseStats gBaseStats[] = .abilities = {ABILITY_DESOLATE_LAND, ABILITY_DESOLATE_LAND}, .bodyColor = BODY_COLOR_RED, .noFlip = FALSE, - .flags = SPECIES_FLAG_LEGENDARY, + .flags = SPECIES_FLAG_LEGENDARY | SPECIES_FLAG_PRIMAL_REVERSION, }, [SPECIES_RATTATA_ALOLAN] = diff --git a/src/data/pokemon/evolution.h b/src/data/pokemon/evolution.h index 4f09867a6..0aaf8f90c 100644 --- a/src/data/pokemon/evolution.h +++ b/src/data/pokemon/evolution.h @@ -293,8 +293,6 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_METAGROSS] = {{EVO_MEGA_EVOLUTION, ITEM_METAGROSSITE, SPECIES_METAGROSS_MEGA}}, [SPECIES_LATIAS] = {{EVO_MEGA_EVOLUTION, ITEM_LATIASITE, SPECIES_LATIAS_MEGA}}, [SPECIES_LATIOS] = {{EVO_MEGA_EVOLUTION, ITEM_LATIOSITE, SPECIES_LATIOS_MEGA}}, - [SPECIES_KYOGRE] = {{EVO_PRIMAL_REVERSION, ITEM_BLUE_ORB, SPECIES_KYOGRE_PRIMAL}}, - [SPECIES_GROUDON] = {{EVO_PRIMAL_REVERSION, ITEM_RED_ORB, SPECIES_GROUDON_PRIMAL}}, [SPECIES_RAYQUAZA] = {{EVO_MOVE_MEGA_EVOLUTION, MOVE_DRAGON_ASCENT, SPECIES_RAYQUAZA_MEGA}}, #if P_GEN_4_POKEMON == TRUE diff --git a/src/data/pokemon/form_change_table_pointers.h b/src/data/pokemon/form_change_table_pointers.h index 63971f132..a0cc805e9 100644 --- a/src/data/pokemon/form_change_table_pointers.h +++ b/src/data/pokemon/form_change_table_pointers.h @@ -1,5 +1,9 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] = { + [SPECIES_KYOGRE] = sKyogreFormChangeTable, + [SPECIES_KYOGRE_PRIMAL] = sKyogreFormChangeTable, + [SPECIES_GROUDON] = sGroudonFormChangeTable, + [SPECIES_GROUDON_PRIMAL] = sGroudonFormChangeTable, #if P_GEN_4_POKEMON == TRUE [SPECIES_GIRATINA] = sGiratinaFormChangeTable, [SPECIES_GIRATINA_ORIGIN] = sGiratinaFormChangeTable, diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 0586c8ac8..7342256ec 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -47,6 +47,18 @@ FORM_CHANGE_BATTLE_END: #define DAY 1 #define NIGHT 2 +static const struct FormChange sKyogreFormChangeTable[] = { + {FORM_CHANGE_PRIMAL_REVERSION, SPECIES_KYOGRE_PRIMAL, ITEM_BLUE_ORB}, + {FORM_CHANGE_BATTLE_END, SPECIES_KYOGRE}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sGroudonFormChangeTable[] = { + {FORM_CHANGE_PRIMAL_REVERSION, SPECIES_GROUDON_PRIMAL, ITEM_RED_ORB}, + {FORM_CHANGE_BATTLE_END, SPECIES_GROUDON}, + {FORM_CHANGE_END}, +}; + #if P_GEN_4_POKEMON == TRUE static const struct FormChange sGiratinaFormChangeTable[] = { {FORM_CHANGE_ITEM_HOLD, SPECIES_GIRATINA, ITEM_NONE}, @@ -178,7 +190,7 @@ static const struct FormChange sXerneasFormChangeTable[] = { static const struct FormChange sHoopaFormChangeTable[] = { {FORM_CHANGE_ITEM_USE, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA}, - // {FORM_CHANGE_WITHDRAW, SPECIES_HOOPA}, + {FORM_CHANGE_WITHDRAW, SPECIES_HOOPA}, {FORM_CHANGE_END}, }; #endif diff --git a/src/pokemon.c b/src/pokemon.c index b60e5a30e..ced0f67b9 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8397,6 +8397,16 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 case FORM_CHANGE_BATTLE_END: if (heldItem == formChanges[i].param1 || formChanges[i].param1 == ITEM_NONE) targetSpecies = formChanges[i].targetSpecies; + break; + case FORM_CHANGE_PRIMAL_REVERSION: + if (arg == formChanges[i].param1) + targetSpecies = formChanges[i].targetSpecies; + break; + case FORM_CHANGE_WITHDRAW: + case FORM_CHANGE_BATTLE_SWITCH: + case FORM_CHANGE_BATTLE_FAINT: + targetSpecies = formChanges[i].targetSpecies; + break; } } } @@ -8485,13 +8495,28 @@ bool32 ShouldShowFemaleDifferences(u16 species, u32 personality) return (gBaseStats[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE; } +void TryFormChange(u32 monId, u32 side, u16 method) +{ + u32 targetSpecies; + struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + + targetSpecies = GetFormChangeTargetSpecies(&party[monId], method, 0); + if (targetSpecies != SPECIES_NONE) + { + TryToSetBattleFormChangeMoves(&party[monId], method); + SetMonData(&party[monId], MON_DATA_SPECIES, &targetSpecies); + CalculateMonStats(&party[monId]); + } +} + void TryToSetBattleFormChangeMoves(struct Pokemon *mon, u16 method) { int i, j; u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL); const struct FormChange *formChanges = gFormChangeTablePointers[species]; - if (formChanges == NULL || (method != FORM_CHANGE_BATTLE_BEGIN && method != FORM_CHANGE_BATTLE_END)) + if (formChanges == NULL + || (method != FORM_CHANGE_BATTLE_BEGIN && method != FORM_CHANGE_BATTLE_END)) return; for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) From a57f6d184b9c0aa9f6d3af6a81aead19ea9e3552 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 1 Nov 2022 12:24:04 -0300 Subject: [PATCH 07/37] Fainting by poison in the overworld reverts forms --- include/constants/pokemon.h | 10 ++++----- src/battle_main.c | 2 +- src/data/pokemon/form_change_tables.h | 32 +++++++++++++-------------- src/field_poison.c | 3 +++ src/pokemon.c | 2 +- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 7dc250834..06e4be4f3 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -320,11 +320,11 @@ #define FORM_CHANGE_ITEM_HOLD 1 #define FORM_CHANGE_ITEM_USE 2 #define FORM_CHANGE_MOVE 3 // Todo -#define FORM_CHANGE_WITHDRAW 4 // -#define FORM_CHANGE_BATTLE_BEGIN 5 -#define FORM_CHANGE_BATTLE_END 6 -#define FORM_CHANGE_BATTLE_SWITCH 7 -#define FORM_CHANGE_BATTLE_FAINT 8 +#define FORM_CHANGE_WITHDRAW 4 // Daycare done, Todo PC +#define FORM_CHANGE_FAINT 5 +#define FORM_CHANGE_BATTLE_BEGIN 6 +#define FORM_CHANGE_BATTLE_END 7 +#define FORM_CHANGE_BATTLE_SWITCH 8 #define FORM_CHANGE_PRIMAL_REVERSION 9 #define MON_PIC_WIDTH 64 diff --git a/src/battle_main.c b/src/battle_main.c index f58c0d43b..9d08a4e8c 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3247,7 +3247,7 @@ void FaintClearSetData(void) gBattleMons[gActiveBattler].type3 = TYPE_MYSTERY; Ai_UpdateFaintData(gActiveBattler); - TryFormChange(gBattlerPartyIndexes[gActiveBattler], GET_BATTLER_SIDE(gActiveBattler), FORM_CHANGE_BATTLE_FAINT); + TryFormChange(gBattlerPartyIndexes[gActiveBattler], GET_BATTLER_SIDE(gActiveBattler), FORM_CHANGE_FAINT); if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) UndoMegaEvolution(gBattlerPartyIndexes[gActiveBattler]); diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 7342256ec..b936808b6 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -116,20 +116,20 @@ static const struct FormChange sArceusFormChangeTable[] = { static const struct FormChange sDarmanitanFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_DARMANITAN}, - {FORM_CHANGE_BATTLE_FAINT, SPECIES_DARMANITAN}, + {FORM_CHANGE_FAINT, SPECIES_DARMANITAN}, {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN}, {FORM_CHANGE_END}, }; static const struct FormChange sDarmanitanGalarianFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_DARMANITAN_GALARIAN}, - {FORM_CHANGE_BATTLE_FAINT, SPECIES_DARMANITAN_GALARIAN}, + {FORM_CHANGE_FAINT, SPECIES_DARMANITAN_GALARIAN}, {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN_GALARIAN}, {FORM_CHANGE_END}, }; static const struct FormChange sMeloettaFormChangeTable[] = { - {FORM_CHANGE_BATTLE_FAINT, SPECIES_MELOETTA}, + {FORM_CHANGE_FAINT, SPECIES_MELOETTA}, {FORM_CHANGE_BATTLE_END, SPECIES_MELOETTA}, {FORM_CHANGE_END}, }; @@ -170,14 +170,14 @@ static const struct FormChange sGenesectFormChangeTable[] = { #if P_GEN_6_POKEMON == TRUE static const struct FormChange sGreninjaBattleBondFormChangeTable[] = { - {FORM_CHANGE_BATTLE_FAINT, SPECIES_GRENINJA_BATTLE_BOND}, + {FORM_CHANGE_FAINT, SPECIES_GRENINJA_BATTLE_BOND}, {FORM_CHANGE_BATTLE_END, SPECIES_GRENINJA_BATTLE_BOND}, {FORM_CHANGE_END}, }; static const struct FormChange sAegislashFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_AEGISLASH}, - {FORM_CHANGE_BATTLE_FAINT, SPECIES_AEGISLASH}, + {FORM_CHANGE_FAINT, SPECIES_AEGISLASH}, {FORM_CHANGE_BATTLE_END, SPECIES_AEGISLASH}, {FORM_CHANGE_END}, }; @@ -205,7 +205,7 @@ static const struct FormChange sOricorioFormChangeTable[] = { }; static const struct FormChange sWishiwashiFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_WISHIWASHI}, - {FORM_CHANGE_BATTLE_FAINT, SPECIES_WISHIWASHI}, + {FORM_CHANGE_FAINT, SPECIES_WISHIWASHI}, {FORM_CHANGE_BATTLE_END, SPECIES_WISHIWASHI}, {FORM_CHANGE_END}, }; @@ -233,50 +233,50 @@ static const struct FormChange sSilvallyFormChangeTable[] = { }; static const struct FormChange sMimikyuFormChangeTable[] = { - {FORM_CHANGE_BATTLE_FAINT, SPECIES_MIMIKYU}, + {FORM_CHANGE_FAINT, SPECIES_MIMIKYU}, {FORM_CHANGE_BATTLE_END, SPECIES_MIMIKYU}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorRedFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_RED}, - {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_RED}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_RED}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_RED}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorBlueFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_BLUE}, - {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_BLUE}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_BLUE}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_BLUE}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorGreenFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_GREEN}, - {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_GREEN}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_GREEN}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_GREEN}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorIndigoFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_INDIGO}, - {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_INDIGO}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_INDIGO}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_INDIGO}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorOrangeFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_ORANGE}, - {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_ORANGE}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_ORANGE}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_ORANGE}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorVioletFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_VIOLET}, - {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_VIOLET}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_VIOLET}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_VIOLET}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorYellowFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_YELLOW}, - {FORM_CHANGE_BATTLE_FAINT, SPECIES_MINIOR_CORE_YELLOW}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_YELLOW}, {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_YELLOW}, {FORM_CHANGE_END}, }; @@ -286,14 +286,14 @@ static const struct FormChange sMiniorYellowFormChangeTable[] = { #if P_GEN_8_POKEMON == TRUE static const struct FormChange sCramorantFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_CRAMORANT}, - {FORM_CHANGE_BATTLE_FAINT, SPECIES_CRAMORANT}, + {FORM_CHANGE_FAINT, SPECIES_CRAMORANT}, {FORM_CHANGE_BATTLE_END, SPECIES_CRAMORANT}, {FORM_CHANGE_END}, }; static const struct FormChange sMorpekoFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MORPEKO}, - {FORM_CHANGE_BATTLE_FAINT, SPECIES_MORPEKO}, + {FORM_CHANGE_FAINT, SPECIES_MORPEKO}, {FORM_CHANGE_BATTLE_END, SPECIES_MORPEKO}, {FORM_CHANGE_END}, }; diff --git a/src/field_poison.c b/src/field_poison.c index fcb47acdb..68a345919 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -128,7 +128,10 @@ s32 DoPoisonFieldEffect(void) // Apply poison damage hp = GetMonData(pokemon, MON_DATA_HP); if (hp == 0 || --hp == 0) + { + TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_FAINT); numFainted++; + } SetMonData(pokemon, MON_DATA_HP, &hp); numPoisoned++; diff --git a/src/pokemon.c b/src/pokemon.c index ced0f67b9..c296e1413 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8404,7 +8404,7 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 break; case FORM_CHANGE_WITHDRAW: case FORM_CHANGE_BATTLE_SWITCH: - case FORM_CHANGE_BATTLE_FAINT: + case FORM_CHANGE_FAINT: targetSpecies = formChanges[i].targetSpecies; break; } From f5b900e2ef23713aa83096eb843c8fe33785e9b4 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 1 Nov 2022 15:02:22 -0300 Subject: [PATCH 08/37] Defaults Primal Reversion indicator to Alpha when item not Red Orb. --- src/battle_interface.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/battle_interface.c b/src/battle_interface.c index ed756592f..48882bb26 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -1563,12 +1563,12 @@ u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which) } else if (IsBattlerPrimalReverted(battlerId)) { - if (GET_BASE_SPECIES_ID(gBattleMons[battlerId].species) == SPECIES_GROUDON) + if (gBattleMons[battlerId].item == ITEM_RED_ORB) { LoadSpritePalette(&sSpritePalette_OmegaIndicator); LoadSpriteSheet(&sSpriteSheet_OmegaIndicator); } - else if (GET_BASE_SPECIES_ID(gBattleMons[battlerId].species) == SPECIES_KYOGRE) + else // ITEM_BLUE_ORB { LoadSpritePalette(&sSpritePalette_AlphaIndicator); LoadSpriteSheet(&sSpriteSheet_AlphaIndicator); @@ -1592,9 +1592,9 @@ u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which) } else if (IsBattlerPrimalReverted(battlerId)) { - if (GET_BASE_SPECIES_ID(gBattleMons[battlerId].species) == SPECIES_GROUDON) + if (gBattleMons[battlerId].item == ITEM_RED_ORB) spriteId = CreateSpriteAtEnd(&sSpriteTemplate_OmegaIndicator, x, y, 0); - else if (GET_BASE_SPECIES_ID(gBattleMons[battlerId].species) == SPECIES_KYOGRE) + else // ITEM_BLUE_ORB spriteId = CreateSpriteAtEnd(&sSpriteTemplate_AlphaIndicator, x, y, 0); } From fa8b1b9c053fb5360ff0ba2c702acdaad4acc066 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 1 Nov 2022 15:02:45 -0300 Subject: [PATCH 09/37] Updated descriptions of form change constants --- src/data/pokemon/form_change_tables.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index b936808b6..1f0dc85da 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -20,11 +20,11 @@ FORM_CHANGE_MOVE: FORM_CHANGE_WITHDRAW: Form change activates when the Pokémon is withdrawn from the PC or Daycare. - no parameters + No parameters. -FORM_CHANGE_SWITCH: - Form change activates when the Pokémon is switched out in battle. - no parameters +FORM_CHANGE_FAINT: + Form change activates when the Pokémon faints, either in battle or in the overworld by poison. + No parameters. FORM_CHANGE_BATTLE_BEGIN: Form change activates when the Pokémon is sent out at the beginning of a battle @@ -37,6 +37,15 @@ FORM_CHANGE_BATTLE_END: param1 = item to hold, optional param2 = a move that will be replaced, optional param3 = a new move to replace it with, optional + +FORM_CHANGE_BATTLE_SWITCH: + Form change activates when the Pokémon is switched out in battle. + No parameters. + +FORM_CHANGE_PRIMAL_REVERSION: + Form change activates when entering battle with the specified item. If the item is a Red Orb, + it uses the Omega Symbol for the animation and icon. Otherwise, it defaults to Alpha. + param1 = item to hold, required. */ // FORM_CHANGE_MOVE param2 Arguments From 797c5514d3a39332f8df1eaba967dc7959bc2eb6 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 1 Nov 2022 18:37:23 -0300 Subject: [PATCH 10/37] Mega Evolution in form change tables --- include/battle.h | 3 - include/battle_util.h | 1 + include/constants/pokemon.h | 6 +- src/battle_interface.c | 13 +- src/battle_script_commands.c | 14 +- src/battle_util.c | 47 +-- src/data/pokemon/evolution.h | 49 --- src/data/pokemon/form_change_table_pointers.h | 94 +++++ src/data/pokemon/form_change_tables.h | 323 ++++++++++++++++++ 9 files changed, 453 insertions(+), 97 deletions(-) diff --git a/include/battle.h b/include/battle.h index ff5d698ab..0ff70ee70 100644 --- a/include/battle.h +++ b/include/battle.h @@ -468,10 +468,7 @@ struct LinkBattlerHeader struct MegaEvolutionData { u8 toEvolve; // As flags using gBitTable. - u8 evolvedPartyIds[2]; // As flags using gBitTable; bool8 alreadyEvolved[4]; // Array id is used for mon position. - u16 evolvedSpecies[MAX_BATTLERS_COUNT]; - u16 playerEvolvedSpecies; u8 battlerId; bool8 playerSelect; u8 triggerSpriteId; diff --git a/include/battle_util.h b/include/battle_util.h index 5a0990950..e1b890ebf 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -149,6 +149,7 @@ u16 GetPrimalReversionSpecies(u16 preSpecies, u16 heldItemId); u16 GetWishMegaEvolutionSpecies(u16 preEvoSpecies, u16 moveId1, u16 moveId2, u16 moveId3, u16 moveId4); bool32 CanMegaEvolve(u8 battlerId); void UndoMegaEvolution(u32 monId); +bool32 IsBattlerMegaEvolved(u8 battlerId); bool32 IsBattlerPrimalReverted(u8 battlerId); void TryBattleFormChange(u8 battlerId, u16 method); bool32 DoBattlersShareType(u32 battler1, u32 battler2); diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 06e4be4f3..f31fa8d6c 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -264,8 +264,6 @@ #define F_SUMMARY_SCREEN_FLIP_SPRITE 0x80 // Evolution types -#define EVO_MEGA_EVOLUTION 0xffff // Not an actual evolution, used to temporarily mega evolve in battle. -#define EVO_MOVE_MEGA_EVOLUTION 0xfffe // Mega Evolution that checks for a move instead of held item. #define EVO_FRIENDSHIP 1 // Pokémon levels up with friendship ≥ 220 #define EVO_FRIENDSHIP_DAY 2 // Pokémon levels up during the day with friendship ≥ 220 #define EVO_FRIENDSHIP_NIGHT 3 // Pokémon levels up at night with friendship ≥ 220 @@ -325,7 +323,9 @@ #define FORM_CHANGE_BATTLE_BEGIN 6 #define FORM_CHANGE_BATTLE_END 7 #define FORM_CHANGE_BATTLE_SWITCH 8 -#define FORM_CHANGE_PRIMAL_REVERSION 9 +#define FORM_CHANGE_MEGA_EVOLUTION_ITEM 9 +#define FORM_CHANGE_MEGA_EVOLUTION_MOVE 10 +#define FORM_CHANGE_PRIMAL_REVERSION 11 #define MON_PIC_WIDTH 64 #define MON_PIC_HEIGHT 64 diff --git a/src/battle_interface.c b/src/battle_interface.c index 48882bb26..c3d97f137 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -871,8 +871,7 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId) healthBarSpritePtr->invisible = TRUE; // Create mega indicator sprite if is a mega evolved or a primal reverted mon. - if ((gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) - || IsBattlerPrimalReverted(battlerId)) + if (IsBattlerMegaEvolved(battlerId) || IsBattlerPrimalReverted(battlerId)) { megaIndicatorSpriteId = CreateMegaIndicatorSprite(battlerId, 0); gSprites[megaIndicatorSpriteId].invisible = TRUE; @@ -979,8 +978,7 @@ void SetHealthboxSpriteVisible(u8 healthboxSpriteId) gSprites[healthboxSpriteId].invisible = FALSE; gSprites[gSprites[healthboxSpriteId].hMain_HealthBarSpriteId].invisible = FALSE; gSprites[gSprites[healthboxSpriteId].oam.affineParam].invisible = FALSE; - if ((gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) - || IsBattlerPrimalReverted(battlerId)) + if (IsBattlerMegaEvolved(battlerId) || IsBattlerPrimalReverted(battlerId)) { u8 spriteId = GetMegaIndicatorSpriteId(healthboxSpriteId); if (spriteId != 0xFF) @@ -1104,8 +1102,7 @@ static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl) u8 battler = gSprites[healthboxSpriteId].hMain_Battler; // Don't print Lv char if mon is mega evolved or primal reverted. - if ((gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]]) - || IsBattlerPrimalReverted(battler)) + if (IsBattlerMegaEvolved(battler) || IsBattlerPrimalReverted(battler)) { objVram = ConvertIntToDecimalStringN(text, lvl, STR_CONV_MODE_LEFT_ALIGN, 3); xPos = 5 * (3 - (objVram - (text + 2))) - 1; @@ -1556,7 +1553,7 @@ u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which) u32 spriteId, position; s16 x, y; - if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + if (IsBattlerMegaEvolved(battlerId)) { LoadSpritePalette(&sSpritePalette_MegaIndicator); LoadSpriteSheet(&sSpriteSheet_MegaIndicator); @@ -1586,7 +1583,7 @@ u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which) else if (gBattleMons[battlerId].level < 10) x += 5; - if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + if (IsBattlerMegaEvolved(battlerId)) { spriteId = CreateSpriteAtEnd(&sSpriteTemplate_MegaIndicator, x, y, 0); } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 51d3cfbe1..6cc2bc323 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8807,20 +8807,11 @@ static void Cmd_various(void) // Change species. if (gBattlescriptCurrInstr[3] == 0) { - u16 megaSpecies; - gBattleStruct->mega.evolvedSpecies[gActiveBattler] = gBattleMons[gActiveBattler].species; - if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT - || (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT && !(gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER)))) - { - gBattleStruct->mega.playerEvolvedSpecies = gBattleStruct->mega.evolvedSpecies[gActiveBattler]; - } //Checks regular Mega Evolution - megaSpecies = GetMegaEvolutionSpecies(gBattleStruct->mega.evolvedSpecies[gActiveBattler], gBattleMons[gActiveBattler].item); + u16 megaSpecies = GetMegaEvolutionSpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].item); //Checks Wish Mega Evolution if (megaSpecies == SPECIES_NONE) - { - megaSpecies = GetWishMegaEvolutionSpecies(gBattleStruct->mega.evolvedSpecies[gActiveBattler], gBattleMons[gActiveBattler].moves[0], gBattleMons[gActiveBattler].moves[1], gBattleMons[gActiveBattler].moves[2], gBattleMons[gActiveBattler].moves[3]); - } + megaSpecies = GetWishMegaEvolutionSpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].moves[0], gBattleMons[gActiveBattler].moves[1], gBattleMons[gActiveBattler].moves[2], gBattleMons[gActiveBattler].moves[3]); gBattleMons[gActiveBattler].species = megaSpecies; PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gActiveBattler].species); @@ -8833,7 +8824,6 @@ static void Cmd_various(void) { RecalcBattlerStats(gActiveBattler, mon); gBattleStruct->mega.alreadyEvolved[GetBattlerPosition(gActiveBattler)] = TRUE; - gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(gActiveBattler)] |= gBitTable[gBattlerPartyIndexes[gActiveBattler]]; } // Update healthbox and elevation. else diff --git a/src/battle_util.c b/src/battle_util.c index 729728ec0..d4efdb898 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8953,9 +8953,7 @@ static bool32 CanEvolve(u32 species) for (i = 0; i < EVOS_PER_MON; i++) { - if (gEvolutionTable[species][i].method - && gEvolutionTable[species][i].method != EVO_MEGA_EVOLUTION - && gEvolutionTable[species][i].method != EVO_MOVE_MEGA_EVOLUTION) + if (gEvolutionTable[species][i].method) return TRUE; } return FALSE; @@ -9554,12 +9552,17 @@ bool32 IsPartnerMonFromSameTrainer(u8 battlerId) u16 GetMegaEvolutionSpecies(u16 preEvoSpecies, u16 heldItemId) { u32 i; + const struct FormChange *formChanges = gFormChangeTablePointers[preEvoSpecies]; - for (i = 0; i < EVOS_PER_MON; i++) + if (formChanges != NULL) { - if (gEvolutionTable[preEvoSpecies][i].method == EVO_MEGA_EVOLUTION - && gEvolutionTable[preEvoSpecies][i].param == heldItemId) - return gEvolutionTable[preEvoSpecies][i].targetSpecies; + for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) + { + if ((formChanges[i].method == FORM_CHANGE_MEGA_EVOLUTION_ITEM + && formChanges[i].param1 == heldItemId) + && formChanges[i].targetSpecies != preEvoSpecies) + return formChanges[i].targetSpecies; + } } return SPECIES_NONE; } @@ -9584,15 +9587,18 @@ u16 GetPrimalReversionSpecies(u16 preSpecies, u16 heldItemId) u16 GetWishMegaEvolutionSpecies(u16 preEvoSpecies, u16 moveId1, u16 moveId2, u16 moveId3, u16 moveId4) { - u32 i, par; + u32 i, param; + const struct FormChange *formChanges = gFormChangeTablePointers[preEvoSpecies]; - for (i = 0; i < EVOS_PER_MON; i++) + if (formChanges != NULL) { - if (gEvolutionTable[preEvoSpecies][i].method == EVO_MOVE_MEGA_EVOLUTION) + for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) { - par = gEvolutionTable[preEvoSpecies][i].param; - if (par == moveId1 || par == moveId2 || par == moveId3 || par == moveId4) - return gEvolutionTable[preEvoSpecies][i].targetSpecies; + param = formChanges[i].param1; + if ((formChanges[i].method == FORM_CHANGE_MEGA_EVOLUTION_MOVE + && (param == moveId1 || param == moveId2 || param == moveId3 || param == moveId4)) + && formChanges[i].targetSpecies != preEvoSpecies) + return formChanges[i].targetSpecies; } } return SPECIES_NONE; @@ -9671,16 +9677,8 @@ bool32 CanMegaEvolve(u8 battlerId) void UndoMegaEvolution(u32 monId) { - u16 baseSpecies = GET_BASE_SPECIES_ID(GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES)); - - if (gBattleStruct->mega.evolvedPartyIds[B_SIDE_PLAYER] & gBitTable[monId]) - { - gBattleStruct->mega.evolvedPartyIds[B_SIDE_PLAYER] &= ~(gBitTable[monId]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleStruct->mega.playerEvolvedSpecies); - CalculateMonStats(&gPlayerParty[monId]); - } // While not exactly a mega evolution, Zygarde follows the same rules. - else if (GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, NULL) == SPECIES_ZYGARDE_COMPLETE) + if (GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, NULL) == SPECIES_ZYGARDE_COMPLETE) { SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleStruct->changedSpecies[monId]); gBattleStruct->changedSpecies[monId] = 0; @@ -9688,6 +9686,11 @@ void UndoMegaEvolution(u32 monId) } } +bool32 IsBattlerMegaEvolved(u8 battlerId) +{ + return (gBaseStats[gBattleMons[battlerId].species].flags & SPECIES_FLAG_MEGA_EVOLUTION); +} + bool32 IsBattlerPrimalReverted(u8 battlerId) { return (gBaseStats[gBattleMons[battlerId].species].flags & SPECIES_FLAG_PRIMAL_REVERSION); diff --git a/src/data/pokemon/evolution.h b/src/data/pokemon/evolution.h index 0aaf8f90c..20279043f 100644 --- a/src/data/pokemon/evolution.h +++ b/src/data/pokemon/evolution.h @@ -2,22 +2,16 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = { [SPECIES_BULBASAUR] = {{EVO_LEVEL, 16, SPECIES_IVYSAUR}}, [SPECIES_IVYSAUR] = {{EVO_LEVEL, 32, SPECIES_VENUSAUR}}, - [SPECIES_VENUSAUR] = {{EVO_MEGA_EVOLUTION, ITEM_VENUSAURITE, SPECIES_VENUSAUR_MEGA}}, [SPECIES_CHARMANDER] = {{EVO_LEVEL, 16, SPECIES_CHARMELEON}}, [SPECIES_CHARMELEON] = {{EVO_LEVEL, 36, SPECIES_CHARIZARD}}, - [SPECIES_CHARIZARD] = {{EVO_MEGA_EVOLUTION, ITEM_CHARIZARDITE_X, SPECIES_CHARIZARD_MEGA_X}, - {EVO_MEGA_EVOLUTION, ITEM_CHARIZARDITE_Y, SPECIES_CHARIZARD_MEGA_Y}}, [SPECIES_SQUIRTLE] = {{EVO_LEVEL, 16, SPECIES_WARTORTLE}}, [SPECIES_WARTORTLE] = {{EVO_LEVEL, 36, SPECIES_BLASTOISE}}, - [SPECIES_BLASTOISE] = {{EVO_MEGA_EVOLUTION, ITEM_BLASTOISINITE, SPECIES_BLASTOISE_MEGA}}, [SPECIES_CATERPIE] = {{EVO_LEVEL, 7, SPECIES_METAPOD}}, [SPECIES_METAPOD] = {{EVO_LEVEL, 10, SPECIES_BUTTERFREE}}, [SPECIES_WEEDLE] = {{EVO_LEVEL, 7, SPECIES_KAKUNA}}, [SPECIES_KAKUNA] = {{EVO_LEVEL, 10, SPECIES_BEEDRILL}}, - [SPECIES_BEEDRILL] = {{EVO_MEGA_EVOLUTION, ITEM_BEEDRILLITE, SPECIES_BEEDRILL_MEGA}}, [SPECIES_PIDGEY] = {{EVO_LEVEL, 18, SPECIES_PIDGEOTTO}}, [SPECIES_PIDGEOTTO] = {{EVO_LEVEL, 36, SPECIES_PIDGEOT}}, - [SPECIES_PIDGEOT] = {{EVO_MEGA_EVOLUTION, ITEM_PIDGEOTITE, SPECIES_PIDGEOT_MEGA}}, [SPECIES_RATTATA] = {{EVO_LEVEL, 20, SPECIES_RATICATE}}, [SPECIES_SPEAROW] = {{EVO_LEVEL, 20, SPECIES_FEAROW}}, [SPECIES_EKANS] = {{EVO_LEVEL, 22, SPECIES_ARBOK}}, @@ -48,7 +42,6 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = {EVO_TRADE_ITEM, ITEM_KINGS_ROCK, SPECIES_POLITOED}}, [SPECIES_ABRA] = {{EVO_LEVEL, 16, SPECIES_KADABRA}}, [SPECIES_KADABRA] = {{EVO_TRADE, 0, SPECIES_ALAKAZAM}}, - [SPECIES_ALAKAZAM] = {{EVO_MEGA_EVOLUTION, ITEM_ALAKAZITE, SPECIES_ALAKAZAM_MEGA}}, [SPECIES_MACHOP] = {{EVO_LEVEL, 28, SPECIES_MACHOKE}}, [SPECIES_MACHOKE] = {{EVO_TRADE, 0, SPECIES_MACHAMP}}, [SPECIES_BELLSPROUT] = {{EVO_LEVEL, 21, SPECIES_WEEPINBELL}}, @@ -59,7 +52,6 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_PONYTA] = {{EVO_LEVEL, 40, SPECIES_RAPIDASH}}, [SPECIES_SLOWPOKE] = {{EVO_LEVEL, 37, SPECIES_SLOWBRO}, {EVO_TRADE_ITEM, ITEM_KINGS_ROCK, SPECIES_SLOWKING}}, - [SPECIES_SLOWBRO] = {{EVO_MEGA_EVOLUTION, ITEM_SLOWBRONITE, SPECIES_SLOWBRO_MEGA}}, [SPECIES_MAGNEMITE] = {{EVO_LEVEL, 30, SPECIES_MAGNETON}}, #if P_GEN_4_POKEMON == TRUE [SPECIES_MAGNETON] = {{EVO_MAPSEC, MAPSEC_NEW_MAUVILLE, SPECIES_MAGNEZONE}, @@ -71,7 +63,6 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_SHELLDER] = {{EVO_ITEM, ITEM_WATER_STONE, SPECIES_CLOYSTER}}, [SPECIES_GASTLY] = {{EVO_LEVEL, 25, SPECIES_HAUNTER}}, [SPECIES_HAUNTER] = {{EVO_TRADE, 0, SPECIES_GENGAR}}, - [SPECIES_GENGAR] = {{EVO_MEGA_EVOLUTION, ITEM_GENGARITE, SPECIES_GENGAR_MEGA}}, [SPECIES_ONIX] = {{EVO_TRADE_ITEM, ITEM_METAL_COAT, SPECIES_STEELIX}}, [SPECIES_DROWZEE] = {{EVO_LEVEL, 26, SPECIES_HYPNO}}, [SPECIES_KRABBY] = {{EVO_LEVEL, 28, SPECIES_KINGLER}}, @@ -92,7 +83,6 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = #if P_GEN_4_POKEMON == TRUE [SPECIES_TANGELA] = {{EVO_MOVE, MOVE_ANCIENT_POWER, SPECIES_TANGROWTH}}, #endif - [SPECIES_KANGASKHAN] = {{EVO_MEGA_EVOLUTION, ITEM_KANGASKHANITE, SPECIES_KANGASKHAN_MEGA}}, [SPECIES_HORSEA] = {{EVO_LEVEL, 32, SPECIES_SEADRA}}, [SPECIES_SEADRA] = {{EVO_TRADE_ITEM, ITEM_DRAGON_SCALE, SPECIES_KINGDRA}}, [SPECIES_GOLDEEN] = {{EVO_LEVEL, 33, SPECIES_SEAKING}}, @@ -102,9 +92,7 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_ELECTABUZZ] = {{EVO_TRADE_ITEM, ITEM_ELECTIRIZER, SPECIES_ELECTIVIRE}}, [SPECIES_MAGMAR] = {{EVO_TRADE_ITEM, ITEM_MAGMARIZER, SPECIES_MAGMORTAR}}, #endif - [SPECIES_PINSIR] = {{EVO_MEGA_EVOLUTION, ITEM_PINSIRITE, SPECIES_PINSIR_MEGA}}, [SPECIES_MAGIKARP] = {{EVO_LEVEL, 20, SPECIES_GYARADOS}}, - [SPECIES_GYARADOS] = {{EVO_MEGA_EVOLUTION, ITEM_GYARADOSITE, SPECIES_GYARADOS_MEGA}}, [SPECIES_EEVEE] = {{EVO_ITEM, ITEM_THUNDER_STONE, SPECIES_JOLTEON}, {EVO_ITEM, ITEM_WATER_STONE, SPECIES_VAPOREON}, {EVO_ITEM, ITEM_FIRE_STONE, SPECIES_FLAREON}, @@ -123,11 +111,8 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_PORYGON] = {{EVO_TRADE_ITEM, ITEM_UPGRADE, SPECIES_PORYGON2}}, [SPECIES_OMANYTE] = {{EVO_LEVEL, 40, SPECIES_OMASTAR}}, [SPECIES_KABUTO] = {{EVO_LEVEL, 40, SPECIES_KABUTOPS}}, - [SPECIES_AERODACTYL] = {{EVO_MEGA_EVOLUTION, ITEM_AERODACTYLITE, SPECIES_AERODACTYL_MEGA}}, [SPECIES_DRATINI] = {{EVO_LEVEL, 30, SPECIES_DRAGONAIR}}, [SPECIES_DRAGONAIR] = {{EVO_LEVEL, 55, SPECIES_DRAGONITE}}, - [SPECIES_MEWTWO] = {{EVO_MEGA_EVOLUTION, ITEM_MEWTWONITE_X, SPECIES_MEWTWO_MEGA_X}, - {EVO_MEGA_EVOLUTION, ITEM_MEWTWONITE_Y, SPECIES_MEWTWO_MEGA_Y}}, [SPECIES_CHIKORITA] = {{EVO_LEVEL, 16, SPECIES_BAYLEEF}}, [SPECIES_BAYLEEF] = {{EVO_LEVEL, 32, SPECIES_MEGANIUM}}, [SPECIES_CYNDAQUIL] = {{EVO_LEVEL, 14, SPECIES_QUILAVA}}, @@ -149,7 +134,6 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_NATU] = {{EVO_LEVEL, 25, SPECIES_XATU}}, [SPECIES_MAREEP] = {{EVO_LEVEL, 15, SPECIES_FLAAFFY}}, [SPECIES_FLAAFFY] = {{EVO_LEVEL, 30, SPECIES_AMPHAROS}}, - [SPECIES_AMPHAROS] = {{EVO_MEGA_EVOLUTION, ITEM_AMPHAROSITE, SPECIES_AMPHAROS_MEGA}}, [SPECIES_MARILL] = {{EVO_LEVEL, 18, SPECIES_AZUMARILL}}, [SPECIES_HOPPIP] = {{EVO_LEVEL, 18, SPECIES_SKIPLOOM}}, [SPECIES_SKIPLOOM] = {{EVO_LEVEL, 27, SPECIES_JUMPLUFF}}, @@ -167,10 +151,7 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = #if P_GEN_4_POKEMON == TRUE [SPECIES_GLIGAR] = {{EVO_ITEM_HOLD_NIGHT, ITEM_RAZOR_FANG, SPECIES_GLISCOR}}, #endif - [SPECIES_STEELIX] = {{EVO_MEGA_EVOLUTION, ITEM_STEELIXITE, SPECIES_STEELIX_MEGA}}, [SPECIES_SNUBBULL] = {{EVO_LEVEL, 23, SPECIES_GRANBULL}}, - [SPECIES_SCIZOR] = {{EVO_MEGA_EVOLUTION, ITEM_SCIZORITE, SPECIES_SCIZOR_MEGA}}, - [SPECIES_HERACROSS] = {{EVO_MEGA_EVOLUTION, ITEM_HERACRONITE, SPECIES_HERACROSS_MEGA}}, #if P_GEN_4_POKEMON == TRUE [SPECIES_SNEASEL] = {{EVO_ITEM_HOLD_NIGHT, ITEM_RAZOR_CLAW, SPECIES_WEAVILE}}, #endif @@ -182,7 +163,6 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = #endif [SPECIES_REMORAID] = {{EVO_LEVEL, 25, SPECIES_OCTILLERY}}, [SPECIES_HOUNDOUR] = {{EVO_LEVEL, 24, SPECIES_HOUNDOOM}}, - [SPECIES_HOUNDOOM] = {{EVO_MEGA_EVOLUTION, ITEM_HOUNDOOMINITE, SPECIES_HOUNDOOM_MEGA}}, [SPECIES_PHANPY] = {{EVO_LEVEL, 25, SPECIES_DONPHAN}}, #if P_GEN_4_POKEMON == TRUE [SPECIES_PORYGON2] = {{EVO_TRADE_ITEM, ITEM_DUBIOUS_DISC, SPECIES_PORYGON_Z}}, @@ -195,16 +175,12 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_MAGBY] = {{EVO_LEVEL, 30, SPECIES_MAGMAR}}, [SPECIES_LARVITAR] = {{EVO_LEVEL, 30, SPECIES_PUPITAR}}, [SPECIES_PUPITAR] = {{EVO_LEVEL, 55, SPECIES_TYRANITAR}}, - [SPECIES_TYRANITAR] = {{EVO_MEGA_EVOLUTION, ITEM_TYRANITARITE, SPECIES_TYRANITAR_MEGA}}, [SPECIES_TREECKO] = {{EVO_LEVEL, 16, SPECIES_GROVYLE}}, [SPECIES_GROVYLE] = {{EVO_LEVEL, 36, SPECIES_SCEPTILE}}, - [SPECIES_SCEPTILE] = {{EVO_MEGA_EVOLUTION, ITEM_SCEPTILITE, SPECIES_SCEPTILE_MEGA}}, [SPECIES_TORCHIC] = {{EVO_LEVEL, 16, SPECIES_COMBUSKEN}}, [SPECIES_COMBUSKEN] = {{EVO_LEVEL, 36, SPECIES_BLAZIKEN}}, - [SPECIES_BLAZIKEN] = {{EVO_MEGA_EVOLUTION, ITEM_BLAZIKENITE, SPECIES_BLAZIKEN_MEGA}}, [SPECIES_MUDKIP] = {{EVO_LEVEL, 16, SPECIES_MARSHTOMP}}, [SPECIES_MARSHTOMP] = {{EVO_LEVEL, 36, SPECIES_SWAMPERT}}, - [SPECIES_SWAMPERT] = {{EVO_MEGA_EVOLUTION, ITEM_SWAMPERTITE, SPECIES_SWAMPERT_MEGA}}, [SPECIES_POOCHYENA] = {{EVO_LEVEL, 18, SPECIES_MIGHTYENA}}, [SPECIES_ZIGZAGOON] = {{EVO_LEVEL, 20, SPECIES_LINOONE}}, [SPECIES_WURMPLE] = {{EVO_LEVEL_SILCOON, 7, SPECIES_SILCOON}, @@ -227,20 +203,16 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = #if P_GEN_4_POKEMON == TRUE [SPECIES_NOSEPASS] = {{EVO_MAPSEC, MAPSEC_NEW_MAUVILLE, SPECIES_PROBOPASS}}, #endif - [SPECIES_SABLEYE] = {{EVO_MEGA_EVOLUTION, ITEM_SABLENITE, SPECIES_SABLEYE_MEGA}}, [SPECIES_BARBOACH] = {{EVO_LEVEL, 30, SPECIES_WHISCASH}}, [SPECIES_CORPHISH] = {{EVO_LEVEL, 30, SPECIES_CRAWDAUNT}}, [SPECIES_FEEBAS] = {{EVO_BEAUTY, 170, SPECIES_MILOTIC}, {EVO_TRADE_ITEM, ITEM_PRISM_SCALE, SPECIES_MILOTIC}}, [SPECIES_CARVANHA] = {{EVO_LEVEL, 30, SPECIES_SHARPEDO}}, - [SPECIES_SHARPEDO] = {{EVO_MEGA_EVOLUTION, ITEM_SHARPEDONITE, SPECIES_SHARPEDO_MEGA}}, [SPECIES_TRAPINCH] = {{EVO_LEVEL, 35, SPECIES_VIBRAVA}}, [SPECIES_VIBRAVA] = {{EVO_LEVEL, 45, SPECIES_FLYGON}}, [SPECIES_MAKUHITA] = {{EVO_LEVEL, 24, SPECIES_HARIYAMA}}, [SPECIES_ELECTRIKE] = {{EVO_LEVEL, 26, SPECIES_MANECTRIC}}, - [SPECIES_MANECTRIC] = {{EVO_MEGA_EVOLUTION, ITEM_MANECTITE, SPECIES_MANECTRIC_MEGA}}, [SPECIES_NUMEL] = {{EVO_LEVEL, 33, SPECIES_CAMERUPT}}, - [SPECIES_CAMERUPT] = {{EVO_MEGA_EVOLUTION, ITEM_CAMERUPTITE, SPECIES_CAMERUPT_MEGA}}, [SPECIES_SPHEAL] = {{EVO_LEVEL, 32, SPECIES_SEALEO}}, [SPECIES_SEALEO] = {{EVO_LEVEL, 44, SPECIES_WALREIN}}, [SPECIES_CACNEA] = {{EVO_LEVEL, 32, SPECIES_CACTURNE}}, @@ -249,14 +221,10 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = {EVO_ITEM_FEMALE, ITEM_DAWN_STONE, SPECIES_FROSLASS} #endif }, - [SPECIES_GLALIE] = {{EVO_MEGA_EVOLUTION, ITEM_GLALITITE, SPECIES_GLALIE_MEGA}}, [SPECIES_AZURILL] = {{EVO_FRIENDSHIP, 0, SPECIES_MARILL}}, [SPECIES_SPOINK] = {{EVO_LEVEL, 32, SPECIES_GRUMPIG}}, - [SPECIES_MAWILE] = {{EVO_MEGA_EVOLUTION, ITEM_MAWILITE, SPECIES_MAWILE_MEGA}}, [SPECIES_MEDITITE] = {{EVO_LEVEL, 37, SPECIES_MEDICHAM}}, - [SPECIES_MEDICHAM] = {{EVO_MEGA_EVOLUTION, ITEM_MEDICHAMITE, SPECIES_MEDICHAM_MEGA}}, [SPECIES_SWABLU] = {{EVO_LEVEL, 35, SPECIES_ALTARIA}}, - [SPECIES_ALTARIA] = {{EVO_MEGA_EVOLUTION, ITEM_ALTARIANITE, SPECIES_ALTARIA_MEGA}}, [SPECIES_WYNAUT] = {{EVO_LEVEL, 15, SPECIES_WOBBUFFET}}, [SPECIES_DUSKULL] = {{EVO_LEVEL, 37, SPECIES_DUSCLOPS}}, #if P_GEN_4_POKEMON == TRUE @@ -270,12 +238,9 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_LOUDRED] = {{EVO_LEVEL, 40, SPECIES_EXPLOUD}}, [SPECIES_CLAMPERL] = {{EVO_TRADE_ITEM, ITEM_DEEP_SEA_TOOTH, SPECIES_HUNTAIL}, {EVO_TRADE_ITEM, ITEM_DEEP_SEA_SCALE, SPECIES_GOREBYSS}}, - [SPECIES_ABSOL] = {{EVO_MEGA_EVOLUTION, ITEM_ABSOLITE, SPECIES_ABSOL_MEGA}}, [SPECIES_SHUPPET] = {{EVO_LEVEL, 37, SPECIES_BANETTE}}, - [SPECIES_BANETTE] = {{EVO_MEGA_EVOLUTION, ITEM_BANETTITE, SPECIES_BANETTE_MEGA}}, [SPECIES_ARON] = {{EVO_LEVEL, 32, SPECIES_LAIRON}}, [SPECIES_LAIRON] = {{EVO_LEVEL, 42, SPECIES_AGGRON}}, - [SPECIES_AGGRON] = {{EVO_MEGA_EVOLUTION, ITEM_AGGRONITE, SPECIES_AGGRON_MEGA}}, [SPECIES_LILEEP] = {{EVO_LEVEL, 40, SPECIES_CRADILY}}, [SPECIES_ANORITH] = {{EVO_LEVEL, 40, SPECIES_ARMALDO}}, [SPECIES_RALTS] = {{EVO_LEVEL, 20, SPECIES_KIRLIA}}, @@ -284,17 +249,10 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = {EVO_ITEM_MALE, ITEM_DAWN_STONE, SPECIES_GALLADE} #endif }, - [SPECIES_GARDEVOIR] = {{EVO_MEGA_EVOLUTION, ITEM_GARDEVOIRITE, SPECIES_GARDEVOIR_MEGA}}, [SPECIES_BAGON] = {{EVO_LEVEL, 30, SPECIES_SHELGON}}, [SPECIES_SHELGON] = {{EVO_LEVEL, 50, SPECIES_SALAMENCE}}, - [SPECIES_SALAMENCE] = {{EVO_MEGA_EVOLUTION, ITEM_SALAMENCITE, SPECIES_SALAMENCE_MEGA}}, [SPECIES_BELDUM] = {{EVO_LEVEL, 20, SPECIES_METANG}}, [SPECIES_METANG] = {{EVO_LEVEL, 45, SPECIES_METAGROSS}}, - [SPECIES_METAGROSS] = {{EVO_MEGA_EVOLUTION, ITEM_METAGROSSITE, SPECIES_METAGROSS_MEGA}}, - [SPECIES_LATIAS] = {{EVO_MEGA_EVOLUTION, ITEM_LATIASITE, SPECIES_LATIAS_MEGA}}, - [SPECIES_LATIOS] = {{EVO_MEGA_EVOLUTION, ITEM_LATIOSITE, SPECIES_LATIOS_MEGA}}, - [SPECIES_RAYQUAZA] = {{EVO_MOVE_MEGA_EVOLUTION, MOVE_DRAGON_ASCENT, SPECIES_RAYQUAZA_MEGA}}, - #if P_GEN_4_POKEMON == TRUE // Gens 4-7 [SPECIES_TURTWIG] = {{EVO_LEVEL, 18, SPECIES_GROTLE}}, @@ -320,7 +278,6 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_SHELLOS] = {{EVO_LEVEL, 30, SPECIES_GASTRODON}}, [SPECIES_DRIFLOON] = {{EVO_LEVEL, 28, SPECIES_DRIFBLIM}}, [SPECIES_BUNEARY] = {{EVO_FRIENDSHIP, 0, SPECIES_LOPUNNY}}, - [SPECIES_LOPUNNY] = {{EVO_MEGA_EVOLUTION, ITEM_LOPUNNITE, SPECIES_LOPUNNY_MEGA}}, [SPECIES_GLAMEOW] = {{EVO_LEVEL, 38, SPECIES_PURUGLY}}, [SPECIES_CHINGLING] = {{EVO_FRIENDSHIP_NIGHT, 0, SPECIES_CHIMECHO}}, [SPECIES_STUNKY] = {{EVO_LEVEL, 34, SPECIES_SKUNTANK}}, @@ -330,18 +287,14 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_HAPPINY] = {{EVO_ITEM_HOLD_DAY, ITEM_OVAL_STONE, SPECIES_CHANSEY}}, [SPECIES_GIBLE] = {{EVO_LEVEL, 24, SPECIES_GABITE}}, [SPECIES_GABITE] = {{EVO_LEVEL, 48, SPECIES_GARCHOMP}}, - [SPECIES_GARCHOMP] = {{EVO_MEGA_EVOLUTION, ITEM_GARCHOMPITE, SPECIES_GARCHOMP_MEGA}}, [SPECIES_MUNCHLAX] = {{EVO_FRIENDSHIP, 0, SPECIES_SNORLAX}}, [SPECIES_RIOLU] = {{EVO_FRIENDSHIP_DAY, 0, SPECIES_LUCARIO}}, - [SPECIES_LUCARIO] = {{EVO_MEGA_EVOLUTION, ITEM_LUCARIONITE, SPECIES_LUCARIO_MEGA}}, [SPECIES_HIPPOPOTAS] = {{EVO_LEVEL, 34, SPECIES_HIPPOWDON}}, [SPECIES_SKORUPI] = {{EVO_LEVEL, 40, SPECIES_DRAPION}}, [SPECIES_CROAGUNK] = {{EVO_LEVEL, 37, SPECIES_TOXICROAK}}, [SPECIES_FINNEON] = {{EVO_LEVEL, 31, SPECIES_LUMINEON}}, [SPECIES_MANTYKE] = {{EVO_SPECIFIC_MON_IN_PARTY, SPECIES_REMORAID, SPECIES_MANTINE}}, [SPECIES_SNOVER] = {{EVO_LEVEL, 40, SPECIES_ABOMASNOW}}, - [SPECIES_ABOMASNOW] = {{EVO_MEGA_EVOLUTION, ITEM_ABOMASITE, SPECIES_ABOMASNOW_MEGA}}, - [SPECIES_GALLADE] = {{EVO_MEGA_EVOLUTION, ITEM_GALLADITE, SPECIES_GALLADE_MEGA}}, #endif #if P_GEN_5_POKEMON == TRUE [SPECIES_SNIVY] = {{EVO_LEVEL, 17, SPECIES_SERVINE}}, @@ -365,7 +318,6 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_BOLDORE] = {{EVO_TRADE, 0, SPECIES_GIGALITH}}, [SPECIES_WOOBAT] = {{EVO_FRIENDSHIP, 0, SPECIES_SWOOBAT}}, [SPECIES_DRILBUR] = {{EVO_LEVEL, 31, SPECIES_EXCADRILL}}, - [SPECIES_AUDINO] = {{EVO_MEGA_EVOLUTION, ITEM_AUDINITE, SPECIES_AUDINO_MEGA}}, [SPECIES_TIMBURR] = {{EVO_LEVEL, 25, SPECIES_GURDURR}}, [SPECIES_GURDURR] = {{EVO_TRADE, 0, SPECIES_CONKELDURR}}, [SPECIES_TYMPOLE] = {{EVO_LEVEL, 25, SPECIES_PALPITOAD}}, @@ -456,7 +408,6 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_PUMPKABOO] = {{EVO_TRADE, 0, SPECIES_GOURGEIST}}, [SPECIES_BERGMITE] = {{EVO_LEVEL, 37, SPECIES_AVALUGG}}, [SPECIES_NOIBAT] = {{EVO_LEVEL, 48, SPECIES_NOIVERN}}, - [SPECIES_DIANCIE] = {{EVO_MEGA_EVOLUTION, ITEM_DIANCITE, SPECIES_DIANCIE_MEGA}}, #endif #if P_GEN_7_POKEMON == TRUE [SPECIES_ROWLET] = {{EVO_LEVEL, 17, SPECIES_DARTRIX}}, diff --git a/src/data/pokemon/form_change_table_pointers.h b/src/data/pokemon/form_change_table_pointers.h index a0cc805e9..d69ced5bf 100644 --- a/src/data/pokemon/form_change_table_pointers.h +++ b/src/data/pokemon/form_change_table_pointers.h @@ -1,10 +1,100 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] = { + [SPECIES_VENUSAUR] = sVenusaurFormChangeTable, + [SPECIES_VENUSAUR_MEGA] = sVenusaurFormChangeTable, + [SPECIES_CHARIZARD] = sCharizardFormChangeTable, + [SPECIES_CHARIZARD_MEGA_X] = sCharizardFormChangeTable, + [SPECIES_CHARIZARD_MEGA_Y] = sCharizardFormChangeTable, + [SPECIES_BLASTOISE] = sBlastoiseFormChangeTable, + [SPECIES_BLASTOISE_MEGA] = sBlastoiseFormChangeTable, + [SPECIES_BEEDRILL] = sBeedrillFormChangeTable, + [SPECIES_BEEDRILL_MEGA] = sBeedrillFormChangeTable, + [SPECIES_PIDGEOT] = sPidgeotFormChangeTable, + [SPECIES_PIDGEOT_MEGA] = sPidgeotFormChangeTable, + [SPECIES_ALAKAZAM] = sAlakazamFormChangeTable, + [SPECIES_ALAKAZAM_MEGA] = sAlakazamFormChangeTable, + [SPECIES_SLOWBRO] = sSlowbroFormChangeTable, + [SPECIES_SLOWBRO_MEGA] = sSlowbroFormChangeTable, + [SPECIES_GENGAR] = sGengarFormChangeTable, + [SPECIES_GENGAR_MEGA] = sGengarFormChangeTable, + [SPECIES_KANGASKHAN] = sKangaskhanFormChangeTable, + [SPECIES_KANGASKHAN_MEGA] = sKangaskhanFormChangeTable, + [SPECIES_PINSIR] = sPinsirFormChangeTable, + [SPECIES_PINSIR_MEGA] = sPinsirFormChangeTable, + [SPECIES_GYARADOS] = sGyaradosFormChangeTable, + [SPECIES_GYARADOS_MEGA] = sGyaradosFormChangeTable, + [SPECIES_AERODACTYL] = sAerodactylFormChangeTable, + [SPECIES_AERODACTYL_MEGA] = sAerodactylFormChangeTable, + [SPECIES_MEWTWO] = sMewtwoFormChangeTable, + [SPECIES_MEWTWO_MEGA_X] = sMewtwoFormChangeTable, + [SPECIES_MEWTWO_MEGA_Y] = sMewtwoFormChangeTable, + [SPECIES_AMPHAROS] = sAmpharosFormChangeTable, + [SPECIES_AMPHAROS_MEGA] = sAmpharosFormChangeTable, + [SPECIES_STEELIX] = sSteelixFormChangeTable, + [SPECIES_STEELIX_MEGA] = sSteelixFormChangeTable, + [SPECIES_SCIZOR] = sScizorFormChangeTable, + [SPECIES_SCIZOR_MEGA] = sScizorFormChangeTable, + [SPECIES_HERACROSS] = sHeracrossFormChangeTable, + [SPECIES_HERACROSS_MEGA] = sHeracrossFormChangeTable, + [SPECIES_HOUNDOOM] = sHoundoomFormChangeTable, + [SPECIES_HOUNDOOM_MEGA] = sHoundoomFormChangeTable, + [SPECIES_TYRANITAR] = sTyranitarFormChangeTable, + [SPECIES_TYRANITAR_MEGA] = sTyranitarFormChangeTable, + [SPECIES_SCEPTILE] = sSceptileFormChangeTable, + [SPECIES_SCEPTILE_MEGA] = sSceptileFormChangeTable, + [SPECIES_BLAZIKEN] = sBlazikenFormChangeTable, + [SPECIES_BLAZIKEN_MEGA] = sBlazikenFormChangeTable, + [SPECIES_SWAMPERT] = sSwampertFormChangeTable, + [SPECIES_SWAMPERT_MEGA] = sSwampertFormChangeTable, + [SPECIES_SABLEYE] = sSableyeFormChangeTable, + [SPECIES_SABLEYE_MEGA] = sSableyeFormChangeTable, + [SPECIES_SHARPEDO] = sSharpedoFormChangeTable, + [SPECIES_SHARPEDO_MEGA] = sSharpedoFormChangeTable, + [SPECIES_MANECTRIC] = sManectricFormChangeTable, + [SPECIES_MANECTRIC_MEGA] = sManectricFormChangeTable, + [SPECIES_CAMERUPT] = sCameruptFormChangeTable, + [SPECIES_CAMERUPT_MEGA] = sCameruptFormChangeTable, + [SPECIES_GLALIE] = sGlalieFormChangeTable, + [SPECIES_GLALIE_MEGA] = sGlalieFormChangeTable, + [SPECIES_MAWILE] = sMawileFormChangeTable, + [SPECIES_MAWILE_MEGA] = sMawileFormChangeTable, + [SPECIES_MEDICHAM] = sMedichamFormChangeTable, + [SPECIES_MEDICHAM_MEGA] = sMedichamFormChangeTable, + [SPECIES_ALTARIA] = sAltariaFormChangeTable, + [SPECIES_ALTARIA_MEGA] = sAltariaFormChangeTable, + [SPECIES_ABSOL] = sAbsolFormChangeTable, + [SPECIES_ABSOL_MEGA] = sAbsolFormChangeTable, + [SPECIES_BANETTE] = sBanetteFormChangeTable, + [SPECIES_BANETTE_MEGA] = sBanetteFormChangeTable, + [SPECIES_AGGRON] = sAggronFormChangeTable, + [SPECIES_AGGRON_MEGA] = sAggronFormChangeTable, + [SPECIES_GARDEVOIR] = sGardevoirFormChangeTable, + [SPECIES_GARDEVOIR_MEGA] = sGardevoirFormChangeTable, + [SPECIES_SALAMENCE] = sSalamenceFormChangeTable, + [SPECIES_SALAMENCE_MEGA] = sSalamenceFormChangeTable, + [SPECIES_METAGROSS] = sMetagrossFormChangeTable, + [SPECIES_METAGROSS_MEGA] = sMetagrossFormChangeTable, + [SPECIES_LATIAS] = sLatiasFormChangeTable, + [SPECIES_LATIAS_MEGA] = sLatiasFormChangeTable, + [SPECIES_LATIOS] = sLatiosFormChangeTable, + [SPECIES_LATIOS_MEGA] = sLatiosFormChangeTable, [SPECIES_KYOGRE] = sKyogreFormChangeTable, [SPECIES_KYOGRE_PRIMAL] = sKyogreFormChangeTable, [SPECIES_GROUDON] = sGroudonFormChangeTable, [SPECIES_GROUDON_PRIMAL] = sGroudonFormChangeTable, + [SPECIES_RAYQUAZA] = sRayquazaFormChangeTable, + [SPECIES_RAYQUAZA_MEGA] = sRayquazaFormChangeTable, #if P_GEN_4_POKEMON == TRUE + [SPECIES_LOPUNNY] = sLopunnyFormChangeTable, + [SPECIES_LOPUNNY_MEGA] = sLopunnyFormChangeTable, + [SPECIES_GARCHOMP] = sGarchompFormChangeTable, + [SPECIES_GARCHOMP_MEGA] = sGarchompFormChangeTable, + [SPECIES_LUCARIO] = sLucarioFormChangeTable, + [SPECIES_LUCARIO_MEGA] = sLucarioFormChangeTable, + [SPECIES_ABOMASNOW] = sAbomasnowFormChangeTable, + [SPECIES_ABOMASNOW_MEGA] = sAbomasnowFormChangeTable, + [SPECIES_GALLADE] = sGalladeFormChangeTable, + [SPECIES_GALLADE_MEGA] = sGalladeFormChangeTable, [SPECIES_GIRATINA] = sGiratinaFormChangeTable, [SPECIES_GIRATINA_ORIGIN] = sGiratinaFormChangeTable, [SPECIES_SHAYMIN] = sShayminFormChangeTable, @@ -29,6 +119,8 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] = [SPECIES_ARCEUS_FAIRY] = sArceusFormChangeTable, #endif #if P_GEN_5_POKEMON == TRUE + [SPECIES_AUDINO] = sAudinoFormChangeTable, + [SPECIES_AUDINO_MEGA] = sAudinoFormChangeTable, [SPECIES_DARMANITAN] = sDarmanitanFormChangeTable, [SPECIES_DARMANITAN_ZEN_MODE] = sDarmanitanFormChangeTable, [SPECIES_DARMANITAN_GALARIAN] = sDarmanitanGalarianFormChangeTable, @@ -56,6 +148,8 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] = [SPECIES_AEGISLASH_BLADE] = sAegislashFormChangeTable, [SPECIES_XERNEAS] = sXerneasFormChangeTable, [SPECIES_XERNEAS_ACTIVE] = sXerneasFormChangeTable, + [SPECIES_DIANCIE] = sDiancieFormChangeTable, + [SPECIES_DIANCIE_MEGA] = sDiancieFormChangeTable, [SPECIES_HOOPA] = sHoopaFormChangeTable, [SPECIES_HOOPA_UNBOUND] = sHoopaFormChangeTable, #endif diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 1f0dc85da..9c0b2d866 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -56,6 +56,274 @@ FORM_CHANGE_PRIMAL_REVERSION: #define DAY 1 #define NIGHT 2 +static const struct FormChange sVenusaurFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_VENUSAUR_MEGA, ITEM_VENUSAURITE}, + {FORM_CHANGE_FAINT, SPECIES_VENUSAUR}, + {FORM_CHANGE_BATTLE_END, SPECIES_VENUSAUR}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sCharizardFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_CHARIZARD_MEGA_X, ITEM_CHARIZARDITE_X}, + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_CHARIZARD_MEGA_Y, ITEM_CHARIZARDITE_Y}, + {FORM_CHANGE_FAINT, SPECIES_CHARIZARD}, + {FORM_CHANGE_BATTLE_END, SPECIES_CHARIZARD}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sBlastoiseFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_BLASTOISE_MEGA, ITEM_BLASTOISINITE}, + {FORM_CHANGE_FAINT, SPECIES_BLASTOISE}, + {FORM_CHANGE_BATTLE_END, SPECIES_BLASTOISE}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sBeedrillFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_BEEDRILL_MEGA, ITEM_BEEDRILLITE}, + {FORM_CHANGE_FAINT, SPECIES_BEEDRILL}, + {FORM_CHANGE_BATTLE_END, SPECIES_BEEDRILL}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sPidgeotFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_PIDGEOT_MEGA, ITEM_PIDGEOTITE}, + {FORM_CHANGE_FAINT, SPECIES_PIDGEOT}, + {FORM_CHANGE_BATTLE_END, SPECIES_PIDGEOT}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sAlakazamFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_ALAKAZAM_MEGA, ITEM_ALAKAZITE}, + {FORM_CHANGE_FAINT, SPECIES_ALAKAZAM}, + {FORM_CHANGE_BATTLE_END, SPECIES_ALAKAZAM}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sSlowbroFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SLOWBRO_MEGA, ITEM_SLOWBRONITE}, + {FORM_CHANGE_FAINT, SPECIES_SLOWBRO}, + {FORM_CHANGE_BATTLE_END, SPECIES_SLOWBRO}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sGengarFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_GENGAR_MEGA, ITEM_GENGARITE}, + {FORM_CHANGE_FAINT, SPECIES_GENGAR}, + {FORM_CHANGE_BATTLE_END, SPECIES_GENGAR}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sKangaskhanFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_KANGASKHAN_MEGA, ITEM_KANGASKHANITE}, + {FORM_CHANGE_FAINT, SPECIES_KANGASKHAN}, + {FORM_CHANGE_BATTLE_END, SPECIES_KANGASKHAN}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sPinsirFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_PINSIR_MEGA, ITEM_PINSIRITE}, + {FORM_CHANGE_FAINT, SPECIES_PINSIR}, + {FORM_CHANGE_BATTLE_END, SPECIES_PINSIR}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sGyaradosFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_GYARADOS_MEGA, ITEM_GYARADOSITE}, + {FORM_CHANGE_FAINT, SPECIES_GYARADOS}, + {FORM_CHANGE_BATTLE_END, SPECIES_GYARADOS}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sAerodactylFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_AERODACTYL_MEGA, ITEM_AERODACTYLITE}, + {FORM_CHANGE_FAINT, SPECIES_AERODACTYL}, + {FORM_CHANGE_BATTLE_END, SPECIES_AERODACTYL}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sMewtwoFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_MEWTWO_MEGA_X, ITEM_MEWTWONITE_X}, + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_MEWTWO_MEGA_Y, ITEM_MEWTWONITE_Y}, + {FORM_CHANGE_FAINT, SPECIES_MEWTWO}, + {FORM_CHANGE_BATTLE_END, SPECIES_MEWTWO}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sAmpharosFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_AMPHAROS_MEGA, ITEM_AMPHAROSITE}, + {FORM_CHANGE_FAINT, SPECIES_AMPHAROS}, + {FORM_CHANGE_BATTLE_END, SPECIES_AMPHAROS}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sSteelixFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_STEELIX_MEGA, ITEM_STEELIXITE}, + {FORM_CHANGE_FAINT, SPECIES_STEELIX}, + {FORM_CHANGE_BATTLE_END, SPECIES_STEELIX}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sScizorFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SCIZOR_MEGA, ITEM_SCIZORITE}, + {FORM_CHANGE_FAINT, SPECIES_SCIZOR}, + {FORM_CHANGE_BATTLE_END, SPECIES_SCIZOR}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sHeracrossFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_HERACROSS_MEGA, ITEM_HERACRONITE}, + {FORM_CHANGE_FAINT, SPECIES_HERACROSS}, + {FORM_CHANGE_BATTLE_END, SPECIES_HERACROSS}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sHoundoomFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_HOUNDOOM_MEGA, ITEM_HOUNDOOMINITE}, + {FORM_CHANGE_FAINT, SPECIES_HOUNDOOM}, + {FORM_CHANGE_BATTLE_END, SPECIES_HOUNDOOM}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sTyranitarFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_TYRANITAR_MEGA, ITEM_TYRANITARITE}, + {FORM_CHANGE_FAINT, SPECIES_TYRANITAR}, + {FORM_CHANGE_BATTLE_END, SPECIES_TYRANITAR}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sSceptileFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SCEPTILE_MEGA, ITEM_SCEPTILITE}, + {FORM_CHANGE_FAINT, SPECIES_SCEPTILE}, + {FORM_CHANGE_BATTLE_END, SPECIES_SCEPTILE}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sBlazikenFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_BLAZIKEN_MEGA, ITEM_BLAZIKENITE}, + {FORM_CHANGE_FAINT, SPECIES_BLAZIKEN}, + {FORM_CHANGE_BATTLE_END, SPECIES_BLAZIKEN}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sSwampertFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SWAMPERT_MEGA, ITEM_SWAMPERTITE}, + {FORM_CHANGE_FAINT, SPECIES_SWAMPERT}, + {FORM_CHANGE_BATTLE_END, SPECIES_SWAMPERT}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sSableyeFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SABLEYE_MEGA, ITEM_SABLENITE}, + {FORM_CHANGE_FAINT, SPECIES_SABLEYE}, + {FORM_CHANGE_BATTLE_END, SPECIES_SABLEYE}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sSharpedoFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SHARPEDO_MEGA, ITEM_SHARPEDONITE}, + {FORM_CHANGE_FAINT, SPECIES_SHARPEDO}, + {FORM_CHANGE_BATTLE_END, SPECIES_SHARPEDO}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sManectricFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_MANECTRIC_MEGA, ITEM_MANECTITE}, + {FORM_CHANGE_FAINT, SPECIES_MANECTRIC}, + {FORM_CHANGE_BATTLE_END, SPECIES_MANECTRIC}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sCameruptFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_CAMERUPT_MEGA, ITEM_CAMERUPTITE}, + {FORM_CHANGE_FAINT, SPECIES_CAMERUPT}, + {FORM_CHANGE_BATTLE_END, SPECIES_CAMERUPT}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sGlalieFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_GLALIE_MEGA, ITEM_GLALITITE}, + {FORM_CHANGE_FAINT, SPECIES_GLALIE}, + {FORM_CHANGE_BATTLE_END, SPECIES_GLALIE}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sMawileFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_MAWILE_MEGA, ITEM_MAWILITE}, + {FORM_CHANGE_FAINT, SPECIES_MAWILE}, + {FORM_CHANGE_BATTLE_END, SPECIES_MAWILE}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sMedichamFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_MEDICHAM_MEGA, ITEM_MEDICHAMITE}, + {FORM_CHANGE_FAINT, SPECIES_MEDICHAM}, + {FORM_CHANGE_BATTLE_END, SPECIES_MEDICHAM}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sAltariaFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_ALTARIA_MEGA, ITEM_ALTARIANITE}, + {FORM_CHANGE_FAINT, SPECIES_ALTARIA}, + {FORM_CHANGE_BATTLE_END, SPECIES_ALTARIA}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sAbsolFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_ABSOL_MEGA, ITEM_ABSOLITE}, + {FORM_CHANGE_FAINT, SPECIES_ABSOL}, + {FORM_CHANGE_BATTLE_END, SPECIES_ABSOL}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sBanetteFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_BANETTE_MEGA, ITEM_BANETTITE}, + {FORM_CHANGE_FAINT, SPECIES_BANETTE}, + {FORM_CHANGE_BATTLE_END, SPECIES_BANETTE}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sAggronFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_AGGRON_MEGA, ITEM_AGGRONITE}, + {FORM_CHANGE_FAINT, SPECIES_AGGRON}, + {FORM_CHANGE_BATTLE_END, SPECIES_AGGRON}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sGardevoirFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_GARDEVOIR_MEGA, ITEM_GARDEVOIRITE}, + {FORM_CHANGE_FAINT, SPECIES_GARDEVOIR}, + {FORM_CHANGE_BATTLE_END, SPECIES_GARDEVOIR}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sSalamenceFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SALAMENCE_MEGA, ITEM_SALAMENCITE}, + {FORM_CHANGE_FAINT, SPECIES_SALAMENCE}, + {FORM_CHANGE_BATTLE_END, SPECIES_SALAMENCE}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sMetagrossFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_METAGROSS_MEGA, ITEM_METAGROSSITE}, + {FORM_CHANGE_FAINT, SPECIES_METAGROSS}, + {FORM_CHANGE_BATTLE_END, SPECIES_METAGROSS}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sLatiasFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_LATIAS_MEGA, ITEM_LATIASITE}, + {FORM_CHANGE_FAINT, SPECIES_LATIAS}, + {FORM_CHANGE_BATTLE_END, SPECIES_LATIAS}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sLatiosFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_LATIOS_MEGA, ITEM_LATIOSITE}, + {FORM_CHANGE_FAINT, SPECIES_LATIOS}, + {FORM_CHANGE_BATTLE_END, SPECIES_LATIOS}, + {FORM_CHANGE_END}, +}; + static const struct FormChange sKyogreFormChangeTable[] = { {FORM_CHANGE_PRIMAL_REVERSION, SPECIES_KYOGRE_PRIMAL, ITEM_BLUE_ORB}, {FORM_CHANGE_BATTLE_END, SPECIES_KYOGRE}, @@ -68,7 +336,49 @@ static const struct FormChange sGroudonFormChangeTable[] = { {FORM_CHANGE_END}, }; +static const struct FormChange sRayquazaFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_MOVE, SPECIES_RAYQUAZA_MEGA, MOVE_DRAGON_ASCENT}, + {FORM_CHANGE_FAINT, SPECIES_RAYQUAZA}, + {FORM_CHANGE_BATTLE_END, SPECIES_RAYQUAZA}, + {FORM_CHANGE_END}, +}; + #if P_GEN_4_POKEMON == TRUE +static const struct FormChange sLopunnyFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_LOPUNNY_MEGA, ITEM_LOPUNNITE}, + {FORM_CHANGE_FAINT, SPECIES_LOPUNNY}, + {FORM_CHANGE_BATTLE_END, SPECIES_LOPUNNY}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sGarchompFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_GARCHOMP_MEGA, ITEM_GARCHOMPITE}, + {FORM_CHANGE_FAINT, SPECIES_GARCHOMP}, + {FORM_CHANGE_BATTLE_END, SPECIES_GARCHOMP}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sLucarioFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_LUCARIO_MEGA, ITEM_LUCARIONITE}, + {FORM_CHANGE_FAINT, SPECIES_LUCARIO}, + {FORM_CHANGE_BATTLE_END, SPECIES_LUCARIO}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sAbomasnowFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_ABOMASNOW_MEGA, ITEM_ABOMASITE}, + {FORM_CHANGE_FAINT, SPECIES_ABOMASNOW}, + {FORM_CHANGE_BATTLE_END, SPECIES_ABOMASNOW}, + {FORM_CHANGE_END}, +}; + +static const struct FormChange sGalladeFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_GALLADE_MEGA, ITEM_GALLADITE}, + {FORM_CHANGE_FAINT, SPECIES_GALLADE}, + {FORM_CHANGE_BATTLE_END, SPECIES_GALLADE}, + {FORM_CHANGE_END}, +}; + static const struct FormChange sGiratinaFormChangeTable[] = { {FORM_CHANGE_ITEM_HOLD, SPECIES_GIRATINA, ITEM_NONE}, {FORM_CHANGE_ITEM_HOLD, SPECIES_GIRATINA_ORIGIN, ITEM_GRISEOUS_ORB}, @@ -122,6 +432,12 @@ static const struct FormChange sArceusFormChangeTable[] = { #endif #if P_GEN_5_POKEMON == TRUE +static const struct FormChange sAudinoFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_AUDINO_MEGA, ITEM_AUDINITE}, + {FORM_CHANGE_FAINT, SPECIES_AUDINO}, + {FORM_CHANGE_BATTLE_END, SPECIES_AUDINO}, + {FORM_CHANGE_END}, +}; static const struct FormChange sDarmanitanFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_DARMANITAN}, @@ -197,6 +513,13 @@ static const struct FormChange sXerneasFormChangeTable[] = { {FORM_CHANGE_END}, }; +static const struct FormChange sDiancieFormChangeTable[] = { + {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_DIANCIE_MEGA, ITEM_DIANCITE}, + {FORM_CHANGE_FAINT, SPECIES_DIANCIE}, + {FORM_CHANGE_BATTLE_END, SPECIES_DIANCIE}, + {FORM_CHANGE_END}, +}; + static const struct FormChange sHoopaFormChangeTable[] = { {FORM_CHANGE_ITEM_USE, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA}, {FORM_CHANGE_WITHDRAW, SPECIES_HOOPA}, From 15c12af2cf9d51731e8ca9b9cce3f2d3adf7e97f Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 1 Nov 2022 23:50:26 -0300 Subject: [PATCH 11/37] Using TryBattleFormChange in place of certain TryFormChange --- include/battle_util.h | 2 ++ include/pokemon.h | 2 +- src/battle_main.c | 2 +- src/battle_script_commands.c | 14 +++----------- src/battle_util.c | 25 +++++++++++++++++-------- src/pokemon.c | 4 +++- 6 files changed, 27 insertions(+), 22 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index e1b890ebf..120c0b7e9 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -188,6 +188,8 @@ void TryToRevertMimicry(void); void RestoreBattlerOriginalTypes(u8 battlerId); u32 GetBattlerMoveTargetType(u8 battlerId, u16 move); bool32 CanTargetBattler(u8 battlerAtk, u8 battlerDef, u16 move); +void CopyMonLevelAndBaseStatsToBattleMon(u32 battler, struct Pokemon *mon); +void CopyMonAbilityAndTypesToBattleMon(u32 battler, struct Pokemon *mon); void RecalcBattlerStats(u32 battler, struct Pokemon *mon); // Ability checks bool32 IsRolePlayBannedAbilityAtk(u16 ability); diff --git a/include/pokemon.h b/include/pokemon.h index 134991b95..10b132f48 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -565,7 +565,7 @@ u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg); u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *mon, u16 method, u32 arg); u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove); bool32 ShouldShowFemaleDifferences(u16 species, u32 personality); -void TryFormChange(u32 monId, u32 side, u16 method); +bool32 TryFormChange(u32 monId, u32 side, u16 method); void TryToSetBattleFormChangeMoves(struct Pokemon *mon, u16 method); u32 GetMonFriendshipScore(struct Pokemon *pokemon); diff --git a/src/battle_main.c b/src/battle_main.c index 9d08a4e8c..6afae7d9c 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3247,7 +3247,7 @@ void FaintClearSetData(void) gBattleMons[gActiveBattler].type3 = TYPE_MYSTERY; Ai_UpdateFaintData(gActiveBattler); - TryFormChange(gBattlerPartyIndexes[gActiveBattler], GET_BATTLER_SIDE(gActiveBattler), FORM_CHANGE_FAINT); + TryBattleFormChange(gActiveBattler, FORM_CHANGE_FAINT); if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) UndoMegaEvolution(gBattlerPartyIndexes[gActiveBattler]); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 6cc2bc323..d2de985a7 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4213,15 +4213,7 @@ static void Cmd_getexp(void) if (battlerId != 0xFF) { - gBattleMons[battlerId].level = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL); - gBattleMons[battlerId].hp = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_HP); - gBattleMons[battlerId].maxHP = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP); - gBattleMons[battlerId].attack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK); - gBattleMons[battlerId].defense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_DEF); - gBattleMons[battlerId].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED); - gBattleMons[battlerId].spAttack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPATK); - gBattleMons[battlerId].spDefense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPDEF); - + CopyMonLevelAndBaseStatsToBattleMon(battlerId, &gPlayerParty[gBattleStruct->expGetterMonId]); if (gStatuses3[battlerId] & STATUS3_POWER_TRICK) SWAP(gBattleMons[battlerId].attack, gBattleMons[battlerId].defense, temp); } @@ -14064,7 +14056,7 @@ static void Cmd_handleballthrow(void) { BtlController_EmitBallThrowAnim(BUFFER_A, BALL_3_SHAKES_SUCCESS); MarkBattlerForControllerExec(gActiveBattler); - TryFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FORM_CHANGE_BATTLE_END), + TryBattleFormChange(gBattlerTarget, FORM_CHANGE_BATTLE_END); gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); @@ -14118,7 +14110,7 @@ static void Cmd_handleballthrow(void) if (IsCriticalCapture()) gBattleSpritesDataPtr->animationData->criticalCaptureSuccess = TRUE; - TryFormChange(gBattlerPartyIndexes[gBattlerTarget], GET_BATTLER_SIDE(gBattlerTarget), FORM_CHANGE_BATTLE_END), + TryBattleFormChange(gBattlerTarget, FORM_CHANGE_BATTLE_END); gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); diff --git a/src/battle_util.c b/src/battle_util.c index d4efdb898..7709fa59e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -518,7 +518,7 @@ void HandleAction_Switch(void) if (gBattleResults.playerSwitchesCounter < 255) gBattleResults.playerSwitchesCounter++; - TryFormChange(gBattlerPartyIndexes[gBattlerAttacker], GetBattlerSide(gBattlerAttacker), FORM_CHANGE_BATTLE_SWITCH); + TryBattleFormChange(gBattlerAttacker, FORM_CHANGE_BATTLE_SWITCH); } void HandleAction_UseItem(void) @@ -9698,16 +9698,14 @@ bool32 IsBattlerPrimalReverted(u8 battlerId) void TryBattleFormChange(u8 battlerId, u16 method) { - u16 targetSpecies; u8 monId = gBattlerPartyIndexes[battlerId]; u8 side = GET_BATTLER_SIDE(battlerId); struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; - targetSpecies = GetFormChangeTargetSpecies(&party[monId], method, 0); - if (targetSpecies != SPECIES_NONE) + if (TryFormChange(monId, side, method)) { - SetMonData(&party[monId], MON_DATA_SPECIES, &targetSpecies); - RecalcBattlerStats(battlerId, &party[monId]); + CopyMonLevelAndBaseStatsToBattleMon(battlerId, &party[monId]); + CopyMonAbilityAndTypesToBattleMon(battlerId, &party[monId]); } } @@ -10370,9 +10368,8 @@ bool32 CanTargetBattler(u8 battlerAtk, u8 battlerDef, u16 move) return TRUE; } -void RecalcBattlerStats(u32 battler, struct Pokemon *mon) +void CopyMonLevelAndBaseStatsToBattleMon(u32 battler, struct Pokemon *mon) { - CalculateMonStats(mon); gBattleMons[battler].level = GetMonData(mon, MON_DATA_LEVEL); gBattleMons[battler].hp = GetMonData(mon, MON_DATA_HP); gBattleMons[battler].maxHP = GetMonData(mon, MON_DATA_MAX_HP); @@ -10381,7 +10378,19 @@ void RecalcBattlerStats(u32 battler, struct Pokemon *mon) gBattleMons[battler].speed = GetMonData(mon, MON_DATA_SPEED); gBattleMons[battler].spAttack = GetMonData(mon, MON_DATA_SPATK); gBattleMons[battler].spDefense = GetMonData(mon, MON_DATA_SPDEF); +} + +void CopyMonAbilityAndTypesToBattleMon(u32 battler, struct Pokemon *mon) +{ gBattleMons[battler].ability = GetMonAbility(mon); gBattleMons[battler].type1 = gBaseStats[gBattleMons[battler].species].type1; gBattleMons[battler].type2 = gBaseStats[gBattleMons[battler].species].type2; + gBattleMons[battler].type3 = TYPE_MYSTERY; +} + +void RecalcBattlerStats(u32 battler, struct Pokemon *mon) +{ + CalculateMonStats(mon); + CopyMonLevelAndBaseStatsToBattleMon(battler, mon); + CopyMonAbilityAndTypesToBattleMon(battler, mon); } diff --git a/src/pokemon.c b/src/pokemon.c index c296e1413..d4f14b5b9 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8495,7 +8495,7 @@ bool32 ShouldShowFemaleDifferences(u16 species, u32 personality) return (gBaseStats[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE; } -void TryFormChange(u32 monId, u32 side, u16 method) +bool32 TryFormChange(u32 monId, u32 side, u16 method) { u32 targetSpecies; struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; @@ -8506,7 +8506,9 @@ void TryFormChange(u32 monId, u32 side, u16 method) TryToSetBattleFormChangeMoves(&party[monId], method); SetMonData(&party[monId], MON_DATA_SPECIES, &targetSpecies); CalculateMonStats(&party[monId]); + return TRUE; } + return FALSE; } void TryToSetBattleFormChangeMoves(struct Pokemon *mon, u16 method) From 8b0a8484247f09a809fc97c0b966b1b154880a62 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 1 Nov 2022 23:53:04 -0300 Subject: [PATCH 12/37] Zen Mode triggers at the beginning of a battle --- src/battle_util.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/battle_util.c b/src/battle_util.c index 7709fa59e..544eef1fd 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4735,6 +4735,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move case ABILITY_SCHOOLING: if (gBattleMons[battler].level < 20) break; + // Fallthrough + case ABILITY_ZEN_MODE: case ABILITY_SHIELDS_DOWN: if (ShouldChangeFormHpBased(battler)) { @@ -4954,6 +4956,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move case ABILITY_SCHOOLING: if (gBattleMons[battler].level < 20) break; + // Fallthrough case ABILITY_ZEN_MODE: case ABILITY_SHIELDS_DOWN: if ((effect = ShouldChangeFormHpBased(battler))) From 271bff5675f69781dcae95c3696347806df9e746 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 2 Nov 2022 10:06:02 -0300 Subject: [PATCH 13/37] Gen 5+ stat recalculate in the same party loop at the end of battle that changes forms. --- src/battle_main.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index 6afae7d9c..df8e24551 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5203,18 +5203,15 @@ static void HandleEndTurn_FinishBattle(void) UndoMegaEvolution(i); TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_BATTLE_END); DoBurmyFormChange(i); - } - #if B_RECALCULATE_STATS >= GEN_5 - // Recalculate the stats of every party member before the end - for (i = 0; i < PARTY_SIZE; i++) - { + #if B_RECALCULATE_STATS >= GEN_5 + // Recalculate the stats of every party member before the end if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_NONE && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) { CalculateMonStats(&gPlayerParty[i]); } + #endif } - #endif // Clear battle mon species to avoid a bug on the next battle that causes // healthboxes loading incorrectly due to it trying to create a Mega Indicator // if the previous battler would've had. From 42f8e8c11461cc09830c143c14f953e42d23b79e Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 5 Nov 2022 20:00:12 -0300 Subject: [PATCH 14/37] Multiple refactors - Added a general GetBattleFormChangeTargetSpecies instead of getting specific ones for Mega Evolution and Primal Reversion. - Added FORM_CHANGE_BATTLE_HP_PERCENT, to replace ShouldChangeFormHpBased. - Cleaned ifdefs for hold effects. - Finally removed UndoMegaEvolution. - FORM_CHANGE_FAINT and FORM_CHANGE_BATTLE_END restore to the first form before a battle form change if species isn't specified. - When changing from a form with more HP to one with less, now current HP is kept to fix Zygarde edge case. (Will likely need to be reworked for Dynamax, as it behaves differently) - Uses DoesSpeciesUseHoldItemToChangeForm in CanBattlerGetOrLoseItem. --- include/battle_util.h | 8 +- include/constants/pokemon.h | 11 +- include/pokemon.h | 3 +- src/battle_ai_main.c | 4 - src/battle_main.c | 15 +- src/battle_script_commands.c | 8 +- src/battle_util.c | 258 +++++++++--------- src/data/pokemon/form_change_table_pointers.h | 3 + src/data/pokemon/form_change_tables.h | 120 +++++--- src/daycare.c | 3 +- src/pokemon.c | 47 +++- 11 files changed, 272 insertions(+), 208 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index 120c0b7e9..4f263e8da 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -144,14 +144,12 @@ u16 CalcTypeEffectivenessMultiplier(u16 move, u8 moveType, u8 battlerAtk, u8 bat u16 CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, u16 abilityDef); u16 GetTypeModifier(u8 atkType, u8 defType); s32 GetStealthHazardDamage(u8 hazardType, u8 battlerId); -u16 GetMegaEvolutionSpecies(u16 preEvoSpecies, u16 heldItemId); -u16 GetPrimalReversionSpecies(u16 preSpecies, u16 heldItemId); -u16 GetWishMegaEvolutionSpecies(u16 preEvoSpecies, u16 moveId1, u16 moveId2, u16 moveId3, u16 moveId4); +bool32 DoesSpeciesUseHoldItemToChangeForm(u16 species, u16 heldItemId); bool32 CanMegaEvolve(u8 battlerId); -void UndoMegaEvolution(u32 monId); bool32 IsBattlerMegaEvolved(u8 battlerId); bool32 IsBattlerPrimalReverted(u8 battlerId); -void TryBattleFormChange(u8 battlerId, u16 method); +u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method); +bool32 TryBattleFormChange(u8 battlerId, u16 method); bool32 DoBattlersShareType(u32 battler1, u32 battler2); bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId); struct Pokemon *GetIllusionMonPtr(u32 battlerId); diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index f31fa8d6c..31b7e72fb 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -323,9 +323,14 @@ #define FORM_CHANGE_BATTLE_BEGIN 6 #define FORM_CHANGE_BATTLE_END 7 #define FORM_CHANGE_BATTLE_SWITCH 8 -#define FORM_CHANGE_MEGA_EVOLUTION_ITEM 9 -#define FORM_CHANGE_MEGA_EVOLUTION_MOVE 10 -#define FORM_CHANGE_PRIMAL_REVERSION 11 +#define FORM_CHANGE_BATTLE_HP_PERCENT 9 +#define FORM_CHANGE_MEGA_EVOLUTION_ITEM 10 +#define FORM_CHANGE_MEGA_EVOLUTION_MOVE 11 +#define FORM_CHANGE_PRIMAL_REVERSION 12 + +// FORM_CHANGE_BATTLE_HP_PERCENT param2 arguments +#define HP_HIGHER_THAN 1 +#define HP_LOWER_EQ_THAN 2 #define MON_PIC_WIDTH 64 #define MON_PIC_HEIGHT 64 diff --git a/include/pokemon.h b/include/pokemon.h index 10b132f48..f7f5ea6de 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -562,7 +562,8 @@ u8 *MonSpritesGfxManager_GetSpritePtr(u8 managerId, u8 spriteNum); u16 GetFormSpeciesId(u16 speciesId, u8 formId); u8 GetFormIdFromFormSpeciesId(u16 formSpeciesId); u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg); -u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *mon, u16 method, u32 arg); +u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 arg); +bool32 DoesSpeciesHaveFormChangeMethod(u16 species, u16 method); u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove); bool32 ShouldShowFemaleDifferences(u16 species, u32 personality); bool32 TryFormChange(u32 monId, u32 side, u16 method); diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index b1154e793..0998d0a48 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -3043,12 +3043,8 @@ static bool32 IsPinchBerryItemEffect(u16 holdEffect) case HOLD_EFFECT_SP_DEFENSE_UP: case HOLD_EFFECT_CRITICAL_UP: case HOLD_EFFECT_RANDOM_STAT_UP: - #ifdef HOLD_EFFECT_CUSTAP_BERRY case HOLD_EFFECT_CUSTAP_BERRY: - #endif - #ifdef HOLD_EFFECT_MICLE_BERRY case HOLD_EFFECT_MICLE_BERRY: - #endif return TRUE; } diff --git a/src/battle_main.c b/src/battle_main.c index df8e24551..907fb1aa4 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3248,8 +3248,6 @@ void FaintClearSetData(void) Ai_UpdateFaintData(gActiveBattler); TryBattleFormChange(gActiveBattler, FORM_CHANGE_FAINT); - if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) - UndoMegaEvolution(gBattlerPartyIndexes[gActiveBattler]); gBattleStruct->overwrittenAbilities[gActiveBattler] = ABILITY_NONE; @@ -3683,7 +3681,7 @@ static void TryDoEventsBeforeFirstTurn(void) for (i = 0; i < gBattlersCount; i++) { if (GetBattlerHoldEffect(i, TRUE) == HOLD_EFFECT_PRIMAL_ORB - && GetPrimalReversionSpecies(gBattleMons[i].species, gBattleMons[i].item) != SPECIES_NONE) + && GetBattleFormChangeTargetSpecies(i, FORM_CHANGE_PRIMAL_REVERSION) != SPECIES_NONE) { gBattlerAttacker = i; BattleScriptExecute(BattleScript_PrimalReversion); @@ -5200,16 +5198,15 @@ static void HandleEndTurn_FinishBattle(void) #endif for (i = 0; i < PARTY_SIZE; i++) { - UndoMegaEvolution(i); - TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_BATTLE_END); + bool32 changedForm = TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_BATTLE_END); DoBurmyFormChange(i); + // Clear original species field + gBattleStruct->changedSpecies[i] = SPECIES_NONE; + #if B_RECALCULATE_STATS >= GEN_5 // Recalculate the stats of every party member before the end - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) - { + if (!changedForm) CalculateMonStats(&gPlayerParty[i]); - } #endif } // Clear battle mon species to avoid a bug on the next battle that causes diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index d2de985a7..5ea145c05 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8800,10 +8800,10 @@ static void Cmd_various(void) if (gBattlescriptCurrInstr[3] == 0) { //Checks regular Mega Evolution - u16 megaSpecies = GetMegaEvolutionSpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].item); + u16 megaSpecies = GetBattleFormChangeTargetSpecies(gActiveBattler, FORM_CHANGE_MEGA_EVOLUTION_ITEM); //Checks Wish Mega Evolution if (megaSpecies == SPECIES_NONE) - megaSpecies = GetWishMegaEvolutionSpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].moves[0], gBattleMons[gActiveBattler].moves[1], gBattleMons[gActiveBattler].moves[2], gBattleMons[gActiveBattler].moves[3]); + megaSpecies = GetBattleFormChangeTargetSpecies(gActiveBattler, FORM_CHANGE_MEGA_EVOLUTION_MOVE); gBattleMons[gActiveBattler].species = megaSpecies; PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gActiveBattler].species); @@ -8836,7 +8836,7 @@ static void Cmd_various(void) // Change species. if (gBattlescriptCurrInstr[3] == 0) { - gBattleMons[gActiveBattler].species = GetPrimalReversionSpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].item); + gBattleMons[gActiveBattler].species = GetBattleFormChangeTargetSpecies(gActiveBattler, FORM_CHANGE_PRIMAL_REVERSION); PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gActiveBattler].species); BtlController_EmitSetMonData(BUFFER_A, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[gActiveBattler]], sizeof(gBattleMons[gActiveBattler].species), &gBattleMons[gActiveBattler].species); @@ -9561,7 +9561,7 @@ static void Cmd_various(void) return; case VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL: { - if (GetPrimalReversionSpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].item) == SPECIES_NONE) + if (GetBattleFormChangeTargetSpecies(gActiveBattler, FORM_CHANGE_PRIMAL_REVERSION) == SPECIES_NONE) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); else gBattlescriptCurrInstr += 7; diff --git a/src/battle_util.c b/src/battle_util.c index 544eef1fd..27b8cf945 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4170,51 +4170,6 @@ static bool32 TryChangeBattleTerrain(u32 battler, u32 statusFlag, u8 *timer) return FALSE; } -static bool32 ShouldChangeFormHpBased(u32 battler) -{ - // Ability, form >, form <=, hp divided - static const u16 forms[][4] = - { - {ABILITY_ZEN_MODE, SPECIES_DARMANITAN, SPECIES_DARMANITAN_ZEN_MODE, 2}, - {ABILITY_SHIELDS_DOWN, SPECIES_MINIOR, SPECIES_MINIOR_CORE_RED, 2}, - {ABILITY_SHIELDS_DOWN, SPECIES_MINIOR_METEOR_BLUE, SPECIES_MINIOR_CORE_BLUE, 2}, - {ABILITY_SHIELDS_DOWN, SPECIES_MINIOR_METEOR_GREEN, SPECIES_MINIOR_CORE_GREEN, 2}, - {ABILITY_SHIELDS_DOWN, SPECIES_MINIOR_METEOR_INDIGO, SPECIES_MINIOR_CORE_INDIGO, 2}, - {ABILITY_SHIELDS_DOWN, SPECIES_MINIOR_METEOR_ORANGE, SPECIES_MINIOR_CORE_ORANGE, 2}, - {ABILITY_SHIELDS_DOWN, SPECIES_MINIOR_METEOR_VIOLET, SPECIES_MINIOR_CORE_VIOLET, 2}, - {ABILITY_SHIELDS_DOWN, SPECIES_MINIOR_METEOR_YELLOW, SPECIES_MINIOR_CORE_YELLOW, 2}, - {ABILITY_SCHOOLING, SPECIES_WISHIWASHI_SCHOOL, SPECIES_WISHIWASHI, 4}, - {ABILITY_GULP_MISSILE, SPECIES_CRAMORANT, SPECIES_CRAMORANT_GORGING, 2}, - {ABILITY_GULP_MISSILE, SPECIES_CRAMORANT, SPECIES_CRAMORANT_GULPING, 1}, - {ABILITY_ZEN_MODE, SPECIES_DARMANITAN_GALARIAN, SPECIES_DARMANITAN_ZEN_MODE_GALARIAN, 2}, - }; - u32 i; - u16 battlerAbility = GetBattlerAbility(battler); - - if (gBattleMons[battler].status2 & STATUS2_TRANSFORMED) - return FALSE; - - for (i = 0; i < ARRAY_COUNT(forms); i++) - { - if (battlerAbility == forms[i][0]) - { - if (gBattleMons[battler].species == forms[i][2] - && gBattleMons[battler].hp > gBattleMons[battler].maxHP / forms[i][3]) - { - gBattleMons[battler].species = forms[i][1]; - return TRUE; - } - if (gBattleMons[battler].species == forms[i][1] - && gBattleMons[battler].hp <= gBattleMons[battler].maxHP / forms[i][3]) - { - gBattleMons[battler].species = forms[i][2]; - return TRUE; - } - } - } - return FALSE; -} - static u8 ForewarnChooseMove(u32 battler) { struct Forewarn { @@ -4738,7 +4693,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move // Fallthrough case ABILITY_ZEN_MODE: case ABILITY_SHIELDS_DOWN: - if (ShouldChangeFormHpBased(battler)) + if (TryBattleFormChange(battler, FORM_CHANGE_BATTLE_HP_PERCENT)) { BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeEnd3); effect++; @@ -4959,15 +4914,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move // Fallthrough case ABILITY_ZEN_MODE: case ABILITY_SHIELDS_DOWN: - if ((effect = ShouldChangeFormHpBased(battler))) - BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeEnd3); - break; case ABILITY_POWER_CONSTRUCT: - if ((gBattleMons[battler].species == SPECIES_ZYGARDE || gBattleMons[battler].species == SPECIES_ZYGARDE_10) - && gBattleMons[battler].hp <= gBattleMons[battler].maxHP / 2) + if (TryBattleFormChange(battler, FORM_CHANGE_BATTLE_HP_PERCENT)) { - gBattleStruct->changedSpecies[gBattlerPartyIndexes[battler]] = gBattleMons[battler].species; - gBattleMons[battler].species = SPECIES_ZYGARDE_COMPLETE; BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeEnd3); effect++; } @@ -5614,7 +5563,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move { if (gBattleMons[gBattlerTarget].species == SPECIES_CRAMORANT_GORGING) { - gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerTarget]] = gBattleMons[gBattlerTarget].species; gBattleMons[gBattlerTarget].species = SPECIES_CRAMORANT; if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) { @@ -5628,7 +5576,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } else if (gBattleMons[gBattlerTarget].species == SPECIES_CRAMORANT_GULPING) { - gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerTarget]] = gBattleMons[gBattlerTarget].species; gBattleMons[gBattlerTarget].species = SPECIES_CRAMORANT; if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) { @@ -5681,7 +5628,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move break; case ABILITY_GULP_MISSILE: if (((gCurrentMove == MOVE_SURF && TARGET_TURN_DAMAGED) || gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER) - && (effect = ShouldChangeFormHpBased(gBattlerAttacker))) + && TryBattleFormChange(gBattlerAttacker, FORM_CHANGE_BATTLE_HP_PERCENT)) { BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_AttackerFormChange; @@ -9552,59 +9499,27 @@ bool32 IsPartnerMonFromSameTrainer(u8 battlerId) return TRUE; } -u16 GetMegaEvolutionSpecies(u16 preEvoSpecies, u16 heldItemId) +bool32 DoesSpeciesUseHoldItemToChangeForm(u16 species, u16 heldItemId) { u32 i; - const struct FormChange *formChanges = gFormChangeTablePointers[preEvoSpecies]; + const struct FormChange *formChanges = gFormChangeTablePointers[species]; if (formChanges != NULL) { for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) { - if ((formChanges[i].method == FORM_CHANGE_MEGA_EVOLUTION_ITEM - && formChanges[i].param1 == heldItemId) - && formChanges[i].targetSpecies != preEvoSpecies) - return formChanges[i].targetSpecies; + switch (formChanges[i].method) + { + case FORM_CHANGE_MEGA_EVOLUTION_ITEM: + case FORM_CHANGE_PRIMAL_REVERSION: + case FORM_CHANGE_ITEM_HOLD: + if (formChanges[i].param1 == heldItemId) + return TRUE; + break; + } } } - return SPECIES_NONE; -} - -u16 GetPrimalReversionSpecies(u16 preSpecies, u16 heldItemId) -{ - u32 i; - const struct FormChange *formChanges = gFormChangeTablePointers[preSpecies]; - - if (formChanges != NULL) - { - for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) - { - if (formChanges[i].method == FORM_CHANGE_PRIMAL_REVERSION - && formChanges[i].param1 == heldItemId - && formChanges[i].targetSpecies != preSpecies) - return formChanges[i].targetSpecies; - } - } - return SPECIES_NONE; -} - -u16 GetWishMegaEvolutionSpecies(u16 preEvoSpecies, u16 moveId1, u16 moveId2, u16 moveId3, u16 moveId4) -{ - u32 i, param; - const struct FormChange *formChanges = gFormChangeTablePointers[preEvoSpecies]; - - if (formChanges != NULL) - { - for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) - { - param = formChanges[i].param1; - if ((formChanges[i].method == FORM_CHANGE_MEGA_EVOLUTION_MOVE - && (param == moveId1 || param == moveId2 || param == moveId3 || param == moveId4)) - && formChanges[i].targetSpecies != preEvoSpecies) - return formChanges[i].targetSpecies; - } - } - return SPECIES_NONE; + return FALSE; } bool32 CanMegaEvolve(u8 battlerId) @@ -9647,7 +9562,7 @@ bool32 CanMegaEvolve(u8 battlerId) itemId = GetMonData(mon, MON_DATA_HELD_ITEM); // Check if there is an entry in the evolution table for regular Mega Evolution. - if (GetMegaEvolutionSpecies(species, itemId) != SPECIES_NONE) + if (GetBattleFormChangeTargetSpecies(battlerId, FORM_CHANGE_MEGA_EVOLUTION_ITEM) != SPECIES_NONE) { #if B_ENABLE_DEBUG == TRUE if (B_ENABLE_DEBUG && gBattleStruct->debugHoldEffects[battlerId]) @@ -9668,7 +9583,7 @@ bool32 CanMegaEvolve(u8 battlerId) } // Check if there is an entry in the evolution table for Wish Mega Evolution. - if (GetWishMegaEvolutionSpecies(species, GetMonData(mon, MON_DATA_MOVE1), GetMonData(mon, MON_DATA_MOVE2), GetMonData(mon, MON_DATA_MOVE3), GetMonData(mon, MON_DATA_MOVE4))) + if (GetBattleFormChangeTargetSpecies(battlerId, FORM_CHANGE_MEGA_EVOLUTION_MOVE) != SPECIES_NONE) { gBattleStruct->mega.isWishMegaEvo = TRUE; return TRUE; @@ -9678,17 +9593,6 @@ bool32 CanMegaEvolve(u8 battlerId) return FALSE; } -void UndoMegaEvolution(u32 monId) -{ - // While not exactly a mega evolution, Zygarde follows the same rules. - if (GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, NULL) == SPECIES_ZYGARDE_COMPLETE) - { - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleStruct->changedSpecies[monId]); - gBattleStruct->changedSpecies[monId] = 0; - CalculateMonStats(&gPlayerParty[monId]); - } -} - bool32 IsBattlerMegaEvolved(u8 battlerId) { return (gBaseStats[gBattleMons[battlerId].species].flags & SPECIES_FLAG_MEGA_EVOLUTION); @@ -9699,17 +9603,121 @@ bool32 IsBattlerPrimalReverted(u8 battlerId) return (gBaseStats[gBattleMons[battlerId].species].flags & SPECIES_FLAG_PRIMAL_REVERSION); } -void TryBattleFormChange(u8 battlerId, u16 method) +// Returns SPECIES_NONE if no form change is possible +u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method) +{ + u32 i, j; + u16 targetSpecies = SPECIES_NONE; + u16 species = gBattleMons[battlerId].species; + const struct FormChange *formChanges = gFormChangeTablePointers[species]; + u16 heldItem; + u32 ability; + + if (formChanges != NULL) + { + heldItem = gBattleMons[battlerId].item; + ability = GetBattlerAbility(battlerId); + + for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) + { + if (method == formChanges[i].method && species != formChanges[i].targetSpecies) + { + switch (method) + { + case FORM_CHANGE_MEGA_EVOLUTION_ITEM: + case FORM_CHANGE_PRIMAL_REVERSION: + if (heldItem == formChanges[i].param1) + targetSpecies = formChanges[i].targetSpecies; + break; + case FORM_CHANGE_MEGA_EVOLUTION_MOVE: + if (gBattleMons[battlerId].moves[0] == formChanges[i].param1 + || gBattleMons[battlerId].moves[1] == formChanges[i].param1 + || gBattleMons[battlerId].moves[2] == formChanges[i].param1 + || gBattleMons[battlerId].moves[3] == formChanges[i].param1) + targetSpecies = formChanges[i].targetSpecies; + break; + case FORM_CHANGE_BATTLE_SWITCH: + targetSpecies = formChanges[i].targetSpecies; + break; + case FORM_CHANGE_BATTLE_HP_PERCENT: + { + if (formChanges[i].param1 == GetBattlerAbility(battlerId)) + { + // We multiply by 100 to make sure that integer division doesn't mess with the health check. + u32 hpCheck = gBattleMons[battlerId].hp * 100 * 100 / gBattleMons[battlerId].maxHP; + switch(formChanges[i].param2) + { + case HP_HIGHER_THAN: + if (hpCheck > formChanges[i].param3 * 100) + targetSpecies = formChanges[i].targetSpecies; + break; + case HP_LOWER_EQ_THAN: + if (hpCheck <= formChanges[i].param3 * 100) + targetSpecies = formChanges[i].targetSpecies; + break; + } + } + break; + } + } + } + } + } + + return targetSpecies; +} + +bool32 TryBattleFormChange(u8 battlerId, u16 method) { u8 monId = gBattlerPartyIndexes[battlerId]; u8 side = GET_BATTLER_SIDE(battlerId); struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + u16 targetSpecies; - if (TryFormChange(monId, side, method)) + // Can't change form if transformed. + if (gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED) + return FALSE; + + if (!DoesSpeciesHaveFormChangeMethod(gBattleMons[battlerId].species, method)) + return FALSE; + + targetSpecies = GetBattleFormChangeTargetSpecies(battlerId, method); + if (targetSpecies != SPECIES_NONE) { - CopyMonLevelAndBaseStatsToBattleMon(battlerId, &party[monId]); - CopyMonAbilityAndTypesToBattleMon(battlerId, &party[monId]); + // Saves the original species on the first form change. + if (gBattleStruct->changedSpecies[monId] == SPECIES_NONE) + gBattleStruct->changedSpecies[monId] = gBattleMons[battlerId].species; + + TryToSetBattleFormChangeMoves(&party[monId], method); + SetMonData(&party[monId], MON_DATA_SPECIES, &targetSpecies); + gBattleMons[battlerId].species = targetSpecies; + RecalcBattlerStats(battlerId, &party[monId]); + return TRUE; } + + targetSpecies = GetFormChangeTargetSpecies(&party[monId], method, 0); + if (targetSpecies != SPECIES_NONE) + { + // Saves the original species on the first form change. + if (gBattleStruct->changedSpecies[monId] == SPECIES_NONE) + gBattleStruct->changedSpecies[monId] = targetSpecies; + + TryToSetBattleFormChangeMoves(&party[monId], method); + SetMonData(&party[monId], MON_DATA_SPECIES, &targetSpecies); + gBattleMons[battlerId].species = targetSpecies; + RecalcBattlerStats(battlerId, &party[monId]); + return TRUE; + } + else if ((method == FORM_CHANGE_BATTLE_END || method == FORM_CHANGE_FAINT) + && gBattleStruct->changedSpecies[monId] != SPECIES_NONE) + { + TryToSetBattleFormChangeMoves(&party[monId], method); + SetMonData(&party[monId], MON_DATA_SPECIES, &gBattleStruct->changedSpecies[monId]); + RecalcBattlerStats(battlerId, &party[monId]); + return TRUE; + } + + return FALSE; } bool32 DoBattlersShareType(u32 battler1, u32 battler2) @@ -9740,24 +9748,10 @@ bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId) // Mail can be stolen now if (itemId == ITEM_ENIGMA_BERRY_E_READER) return FALSE; - // Primal Reversion inducing items cannot be lost if pokemon's base species can undergo primal reversion with it. - else if (holdEffect == HOLD_EFFECT_PRIMAL_ORB && (GetPrimalReversionSpecies(GET_BASE_SPECIES_ID(species), itemId) != SPECIES_NONE)) + else if (DoesSpeciesUseHoldItemToChangeForm(species, itemId)) return FALSE; - // Mega stone cannot be lost if pokemon's base species can mega evolve with it. - else if (holdEffect == HOLD_EFFECT_MEGA_STONE && (GetMegaEvolutionSpecies(GET_BASE_SPECIES_ID(species), itemId) != SPECIES_NONE)) - return FALSE; - else if (GET_BASE_SPECIES_ID(species) == SPECIES_GIRATINA && itemId == ITEM_GRISEOUS_ORB) - return FALSE; - else if (GET_BASE_SPECIES_ID(species) == SPECIES_GENESECT && holdEffect == HOLD_EFFECT_DRIVE) - return FALSE; - else if (GET_BASE_SPECIES_ID(species) == SPECIES_SILVALLY && holdEffect == HOLD_EFFECT_MEMORY) - return FALSE; - else if (GET_BASE_SPECIES_ID(species) == SPECIES_ARCEUS && holdEffect == HOLD_EFFECT_PLATE) - return FALSE; -#ifdef HOLD_EFFECT_Z_CRYSTAL else if (holdEffect == HOLD_EFFECT_Z_CRYSTAL) return FALSE; -#endif else return TRUE; } diff --git a/src/data/pokemon/form_change_table_pointers.h b/src/data/pokemon/form_change_table_pointers.h index d69ced5bf..06d5825a2 100644 --- a/src/data/pokemon/form_change_table_pointers.h +++ b/src/data/pokemon/form_change_table_pointers.h @@ -148,6 +148,9 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] = [SPECIES_AEGISLASH_BLADE] = sAegislashFormChangeTable, [SPECIES_XERNEAS] = sXerneasFormChangeTable, [SPECIES_XERNEAS_ACTIVE] = sXerneasFormChangeTable, + [SPECIES_ZYGARDE_10_POWER_CONSTRUCT] = sZygardePowerConstructFormChangeTable, + [SPECIES_ZYGARDE_50_POWER_CONSTRUCT] = sZygardePowerConstructFormChangeTable, + [SPECIES_ZYGARDE_COMPLETE] = sZygardePowerConstructFormChangeTable, [SPECIES_DIANCIE] = sDiancieFormChangeTable, [SPECIES_DIANCIE_MEGA] = sDiancieFormChangeTable, [SPECIES_HOOPA] = sHoopaFormChangeTable, diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 9c0b2d866..1df1d7581 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -24,6 +24,8 @@ FORM_CHANGE_WITHDRAW: FORM_CHANGE_FAINT: Form change activates when the Pokémon faints, either in battle or in the overworld by poison. + If species is not specified and it's on the player's side, it will try to use the value + saved in gBattleStruct->changedSpecies from a previous form change. No parameters. FORM_CHANGE_BATTLE_BEGIN: @@ -33,7 +35,8 @@ FORM_CHANGE_BATTLE_BEGIN: param3 = a new move to replace it with, optional FORM_CHANGE_BATTLE_END: - Form change activates at the end of a battle + Form change activates at the end of a battle. If species is not specified and it's on the player's side, + it will try to use the value saved in gBattleStruct->changedSpecies from a previous form change. param1 = item to hold, optional param2 = a move that will be replaced, optional param3 = a new move to replace it with, optional @@ -42,10 +45,27 @@ FORM_CHANGE_BATTLE_SWITCH: Form change activates when the Pokémon is switched out in battle. No parameters. +FORM_CHANGE_BATTLE_HP_PERCENT: + Form change activates when the Pokémon's HP % passes a certain threshold. + param1 = Ability to check. + param2 = HP_HIGHER_THAN if the form triggers when the current HP is higher than the specified threshold. + HP_LOWER_EQ_THAN if the form triggers when the current HP is lower or equal than the specified threshold. + param3 = HP percentage threshold. + +FORM_CHANGE_MEGA_EVOLUTION_ITEM: + Form change activates when the mon has the defined item. If it's on the player's side, it also requires + ITEM_MEGA_RING in the user's bag and for the player to choose to enable it. + param1 = item to hold. + +FORM_CHANGE_MEGA_EVOLUTION_MOVE: + Form change activates when the mon has the defined move. If it's on the player's side, it also requires + ITEM_MEGA_RING in the user's bag and for the player to choose to enable it. + param1 = move to have. + FORM_CHANGE_PRIMAL_REVERSION: - Form change activates when entering battle with the specified item. If the item is a Red Orb, + Form change activates automatically when entering battle with the specified item. If the item is a Red Orb, it uses the Omega Symbol for the animation and icon. Otherwise, it defaults to Alpha. - param1 = item to hold, required. + param1 = item to hold. */ // FORM_CHANGE_MOVE param2 Arguments @@ -440,16 +460,18 @@ static const struct FormChange sAudinoFormChangeTable[] = { }; static const struct FormChange sDarmanitanFormChangeTable[] = { - {FORM_CHANGE_BATTLE_SWITCH, SPECIES_DARMANITAN}, - {FORM_CHANGE_FAINT, SPECIES_DARMANITAN}, - {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_DARMANITAN, ABILITY_ZEN_MODE, HP_HIGHER_THAN, 50}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_DARMANITAN_ZEN_MODE, ABILITY_ZEN_MODE, HP_LOWER_EQ_THAN, 50}, + {FORM_CHANGE_FAINT, SPECIES_DARMANITAN}, + {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN}, {FORM_CHANGE_END}, }; static const struct FormChange sDarmanitanGalarianFormChangeTable[] = { - {FORM_CHANGE_BATTLE_SWITCH, SPECIES_DARMANITAN_GALARIAN}, - {FORM_CHANGE_FAINT, SPECIES_DARMANITAN_GALARIAN}, - {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN_GALARIAN}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_DARMANITAN_GALARIAN, ABILITY_ZEN_MODE, HP_HIGHER_THAN, 50}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_DARMANITAN_ZEN_MODE_GALARIAN, ABILITY_ZEN_MODE, HP_LOWER_EQ_THAN, 50}, + {FORM_CHANGE_FAINT, SPECIES_DARMANITAN_GALARIAN}, + {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN_GALARIAN}, {FORM_CHANGE_END}, }; @@ -513,6 +535,13 @@ static const struct FormChange sXerneasFormChangeTable[] = { {FORM_CHANGE_END}, }; +static const struct FormChange sZygardePowerConstructFormChangeTable[] = { + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_ZYGARDE_COMPLETE, ABILITY_POWER_CONSTRUCT, HP_LOWER_EQ_THAN, 50}, + {FORM_CHANGE_FAINT}, + {FORM_CHANGE_BATTLE_END}, + {FORM_CHANGE_END}, +}; + static const struct FormChange sDiancieFormChangeTable[] = { {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_DIANCIE_MEGA, ITEM_DIANCITE}, {FORM_CHANGE_FAINT, SPECIES_DIANCIE}, @@ -536,9 +565,11 @@ static const struct FormChange sOricorioFormChangeTable[] = { {FORM_CHANGE_END}, }; static const struct FormChange sWishiwashiFormChangeTable[] = { - {FORM_CHANGE_BATTLE_SWITCH, SPECIES_WISHIWASHI}, - {FORM_CHANGE_FAINT, SPECIES_WISHIWASHI}, - {FORM_CHANGE_BATTLE_END, SPECIES_WISHIWASHI}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_WISHIWASHI_SCHOOL, ABILITY_SCHOOLING, HP_HIGHER_THAN, 25}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_WISHIWASHI, ABILITY_SCHOOLING, HP_LOWER_EQ_THAN, 25}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_WISHIWASHI}, + {FORM_CHANGE_FAINT, SPECIES_WISHIWASHI}, + {FORM_CHANGE_BATTLE_END, SPECIES_WISHIWASHI}, {FORM_CHANGE_END}, }; @@ -571,55 +602,70 @@ static const struct FormChange sMimikyuFormChangeTable[] = { }; static const struct FormChange sMiniorRedFormChangeTable[] = { - {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_RED}, - {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_RED}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_RED}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR, ABILITY_SHIELDS_DOWN, HP_HIGHER_THAN, 50}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_RED, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_RED}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_RED}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_RED}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorBlueFormChangeTable[] = { - {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_BLUE}, - {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_BLUE}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_BLUE}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_METEOR_BLUE, ABILITY_SHIELDS_DOWN, HP_HIGHER_THAN, 50}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_BLUE, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_BLUE}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_BLUE}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_BLUE}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorGreenFormChangeTable[] = { - {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_GREEN}, - {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_GREEN}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_GREEN}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_METEOR_GREEN, ABILITY_SHIELDS_DOWN, HP_HIGHER_THAN, 50}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_GREEN, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_GREEN}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_GREEN}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_GREEN}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorIndigoFormChangeTable[] = { - {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_INDIGO}, - {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_INDIGO}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_INDIGO}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_METEOR_INDIGO, ABILITY_SHIELDS_DOWN, HP_HIGHER_THAN, 50}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_INDIGO, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_INDIGO}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_INDIGO}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_INDIGO}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorOrangeFormChangeTable[] = { - {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_ORANGE}, - {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_ORANGE}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_ORANGE}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_METEOR_ORANGE, ABILITY_SHIELDS_DOWN, HP_HIGHER_THAN, 50}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_ORANGE, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_ORANGE}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_ORANGE}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_ORANGE}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorVioletFormChangeTable[] = { - {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_VIOLET}, - {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_VIOLET}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_VIOLET}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_METEOR_VIOLET, ABILITY_SHIELDS_DOWN, HP_HIGHER_THAN, 50}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_VIOLET, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_VIOLET}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_VIOLET}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_VIOLET}, {FORM_CHANGE_END}, }; static const struct FormChange sMiniorYellowFormChangeTable[] = { - {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_YELLOW}, - {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_YELLOW}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_YELLOW}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_METEOR_YELLOW, ABILITY_SHIELDS_DOWN, HP_HIGHER_THAN, 50}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_YELLOW, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_YELLOW}, + {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_YELLOW}, + {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_YELLOW}, {FORM_CHANGE_END}, }; - #endif #if P_GEN_8_POKEMON == TRUE static const struct FormChange sCramorantFormChangeTable[] = { - {FORM_CHANGE_BATTLE_SWITCH, SPECIES_CRAMORANT}, - {FORM_CHANGE_FAINT, SPECIES_CRAMORANT}, - {FORM_CHANGE_BATTLE_END, SPECIES_CRAMORANT}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_CRAMORANT_GULPING, ABILITY_GULP_MISSILE, HP_HIGHER_THAN, 50}, + {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_CRAMORANT_GORGING, ABILITY_GULP_MISSILE, HP_LOWER_EQ_THAN, 50}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_CRAMORANT}, + {FORM_CHANGE_FAINT, SPECIES_CRAMORANT}, + {FORM_CHANGE_BATTLE_END, SPECIES_CRAMORANT}, {FORM_CHANGE_END}, }; diff --git a/src/daycare.c b/src/daycare.c index fc44e200e..82280077b 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -256,7 +256,8 @@ static u16 TakeSelectedPokemonFromDaycare(struct DaycareMon *daycareMon) BoxMonToMon(&daycareMon->mon, &pokemon); newSpecies = GetFormChangeTargetSpecies(&pokemon, FORM_CHANGE_WITHDRAW, 0); - if (newSpecies != SPECIES_NONE) { + if (newSpecies != SPECIES_NONE) + { SetMonData(&pokemon, MON_DATA_SPECIES, &newSpecies); CalculateMonStats(&pokemon); species = newSpecies; diff --git a/src/pokemon.c b/src/pokemon.c index d4f14b5b9..0fc69a35f 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3999,13 +3999,14 @@ void CalculateMonStats(struct Pokemon *mon) { if (currentHP == 0 && oldMaxHP == 0) currentHP = newMaxHP; - else if (currentHP != 0) { - // BUG: currentHP is unintentionally able to become <= 0 after the instruction below. This causes the pomeg berry glitch. - currentHP += newMaxHP - oldMaxHP; - #ifdef BUGFIX + else if (currentHP != 0) + { + if (newMaxHP > oldMaxHP) + currentHP += newMaxHP - oldMaxHP; if (currentHP <= 0) currentHP = 1; - #endif + if (currentHP > newMaxHP) + currentHP = newMaxHP; } else return; @@ -8397,13 +8398,8 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 case FORM_CHANGE_BATTLE_END: if (heldItem == formChanges[i].param1 || formChanges[i].param1 == ITEM_NONE) targetSpecies = formChanges[i].targetSpecies; - break; - case FORM_CHANGE_PRIMAL_REVERSION: - if (arg == formChanges[i].param1) - targetSpecies = formChanges[i].targetSpecies; - break; + break; case FORM_CHANGE_WITHDRAW: - case FORM_CHANGE_BATTLE_SWITCH: case FORM_CHANGE_FAINT: targetSpecies = formChanges[i].targetSpecies; break; @@ -8415,6 +8411,23 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 return targetSpecies; } +bool32 DoesSpeciesHaveFormChangeMethod(u16 species, u16 method) +{ + u32 i, j; + const struct FormChange *formChanges = gFormChangeTablePointers[species]; + + if (formChanges != NULL) + { + for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) + { + if (method == formChanges[i].method && species != formChanges[i].targetSpecies) + return TRUE; + } + } + + return FALSE; +} + u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove) { u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL); @@ -8495,12 +8508,21 @@ bool32 ShouldShowFemaleDifferences(u16 species, u32 personality) return (gBaseStats[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE; } +// Returns species that it transformed into. If it didn't, returns SPECIES_NONE. bool32 TryFormChange(u32 monId, u32 side, u16 method) { - u32 targetSpecies; struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + u16 targetSpecies; + + if (GetMonData(&party[monId], MON_DATA_SPECIES2, 0) == SPECIES_NONE + || GetMonData(&party[monId], MON_DATA_SPECIES2, 0) == SPECIES_EGG) + return FALSE; targetSpecies = GetFormChangeTargetSpecies(&party[monId], method, 0); + + if (targetSpecies == SPECIES_NONE) + targetSpecies = gBattleStruct->changedSpecies[monId]; + if (targetSpecies != SPECIES_NONE) { TryToSetBattleFormChangeMoves(&party[monId], method); @@ -8508,6 +8530,7 @@ bool32 TryFormChange(u32 monId, u32 side, u16 method) CalculateMonStats(&party[monId]); return TRUE; } + return FALSE; } From 8f289714b2037c2d01bc7d6826aa6e527b630632 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 5 Nov 2022 20:57:55 -0300 Subject: [PATCH 15/37] Moved form change defines and descriptions to their own header --- include/battle.h | 1 + include/constants/form_change_types.h | 81 +++++++++++++++++++++++++++ include/constants/pokemon.h | 19 ------- src/data/pokemon/form_change_tables.h | 78 -------------------------- src/daycare.c | 1 + src/field_poison.c | 1 + src/party_menu.c | 1 + src/pokemon.c | 1 + src/pokemon_storage_system.c | 1 + 9 files changed, 87 insertions(+), 97 deletions(-) create mode 100644 include/constants/form_change_types.h diff --git a/include/battle.h b/include/battle.h index 544514f13..e0baf8895 100644 --- a/include/battle.h +++ b/include/battle.h @@ -3,6 +3,7 @@ // should they be included here or included individually by every file? #include "constants/battle.h" +#include "constants/form_change_types.h" #include "battle_main.h" #include "battle_message.h" #include "battle_util.h" diff --git a/include/constants/form_change_types.h b/include/constants/form_change_types.h new file mode 100644 index 000000000..1eb2af30a --- /dev/null +++ b/include/constants/form_change_types.h @@ -0,0 +1,81 @@ + +// FORM_CHANGE_BATTLE_HP_PERCENT param2 arguments +#define HP_HIGHER_THAN 1 +#define HP_LOWER_EQ_THAN 2 +// FORM_CHANGE_MOVE param2 Arguments +#define WHEN_LEARNED 0 +#define WHEN_FORGOTTEN 1 +// FORM_CHANGE_ITEM_USE param2 Arguments +#define DAY 1 +#define NIGHT 2 + +#define FORM_CHANGE_END 0 // Form table terminator + +// Form change that activates when the specified item is given to or taken from the selected Pokémon. +// param1: item to hold. +// param2: ability to check for, optional. +#define FORM_CHANGE_ITEM_HOLD 1 + +// Form change that activates when the item is used on the selected Pokémon. +// param1: item to use +// param2: time of day to check, optional. +// - DAY if Form change that activates in the daytime. +// - NIGHT if Form change that activates at nighttime. +#define FORM_CHANGE_ITEM_USE 2 + +// TODO: Form change that activates when the Pokémon learns or forgets the move. +// param1: move to check for +// param2: +// - WHEN_LEARNED if Form change that activates when move is forgotten +// - WHEN_FORGOTTEN if Form change that activates when move is learned +#define FORM_CHANGE_MOVE 3 + +// Form change that activates when the Pokémon is withdrawn from the PC or Daycare. +// Daycare withdraw done, PC withdraw TODO. +// - No parameters. +#define FORM_CHANGE_WITHDRAW 4 + +// Form change that activates when the Pokémon faints, either in battle or in the overworld by poison. +// If species is not specified and it's on the player's side, it will try to use the value +// saved in gBattleStruct->changedSpecies from a previous form change. +// - No parameters. +#define FORM_CHANGE_FAINT 5 + +// Form change that activates when the Pokémon is sent out at the beginning of a battle +// param1: item to hold, optional +// param2: a move that will be replaced, optional +// param3: a new move to replace it with, optional +#define FORM_CHANGE_BATTLE_BEGIN 6 + +// Form change that activates at the end of a battle. If species is not specified and it's on the player's side, it will try to use the value saved in gBattleStruct->changedSpecies from a previous form change. +// param1: item to hold, optional +// param2: a move that will be replaced, optional +// param3: a new move to replace it with, optional +#define FORM_CHANGE_BATTLE_END 7 + +// Form change that activates when the Pokémon is switched out in battle. +// - No parameters. +#define FORM_CHANGE_BATTLE_SWITCH 8 + +// Form change that activates when the Pokémon's HP % passes a certain threshold. +// param1: Ability to check. +// param2: HP comparer +// - HP_HIGHER_THAN if the form triggers when the current HP is higher than the specified threshold. +// - HP_LOWER_EQ_THAN if the form triggers when the current HP is lower or equal than the specified threshold. +// param3: HP percentage threshold. +#define FORM_CHANGE_BATTLE_HP_PERCENT 9 + +// Form change that activates when the mon has the defined item. +// If it's on the player's side, it also requires ITEM_MEGA_RING in the user's bag and for the player to trigger it by pressing START before selecting a move. +// param1: item to hold. +#define FORM_CHANGE_MEGA_EVOLUTION_ITEM 10 + +// Form change that activates when the mon has the defined move. +// If it's on the player's side, it also requires ITEM_MEGA_RING in the user's bag and for the player to trigger it by pressing START before selecting a move. +// param1: move to have. +#define FORM_CHANGE_MEGA_EVOLUTION_MOVE 11 + +// Form change that activates automatically when entering battle with the specified item. +// If the item is a Red Orb, it uses the Omega Symbol for the animation and icon. Otherwise, it defaults to the Alpha symbol. +// param1: item to hold. +#define FORM_CHANGE_PRIMAL_REVERSION 12 diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 088015d06..7ba16fc57 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -313,25 +313,6 @@ #define EVO_MODE_BATTLE_SPECIAL 4 #define EVO_MODE_OVERWORLD_SPECIAL 5 -// Form change types -#define FORM_CHANGE_END 0 // Form table terminator -#define FORM_CHANGE_ITEM_HOLD 1 -#define FORM_CHANGE_ITEM_USE 2 -#define FORM_CHANGE_MOVE 3 // Todo -#define FORM_CHANGE_WITHDRAW 4 // Daycare done, Todo PC -#define FORM_CHANGE_FAINT 5 -#define FORM_CHANGE_BATTLE_BEGIN 6 -#define FORM_CHANGE_BATTLE_END 7 -#define FORM_CHANGE_BATTLE_SWITCH 8 -#define FORM_CHANGE_BATTLE_HP_PERCENT 9 -#define FORM_CHANGE_MEGA_EVOLUTION_ITEM 10 -#define FORM_CHANGE_MEGA_EVOLUTION_MOVE 11 -#define FORM_CHANGE_PRIMAL_REVERSION 12 - -// FORM_CHANGE_BATTLE_HP_PERCENT param2 arguments -#define HP_HIGHER_THAN 1 -#define HP_LOWER_EQ_THAN 2 - #define MON_PIC_WIDTH 64 #define MON_PIC_HEIGHT 64 #define MON_PIC_SIZE (MON_PIC_WIDTH * MON_PIC_HEIGHT / 2) diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 1df1d7581..4bb0c5780 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -1,81 +1,3 @@ -/* -FORM_CHANGE_ITEM_HOLD: - Form change activates when the specified item is given to or taken from the selected Pokémon. - Alternatively, form change activates when the specified item is is given to or taken from - the selected Pokémon that has a particular ability. - param1 = item to hold - param2 = ability to check for, optional - -FORM_CHANGE_ITEM_USE: - Form change activates when the item is used on the selected Pokémon. - param1 = item to use - param2 = DAY if form change activates in the daytime, optional - NIGHT if form change activates at nighttime, optional - -FORM_CHANGE_MOVE: - Form change activates when the Pokémon learns or forgets the move. - param1 = move to check for - param2 = WHEN_LEARNED if form change activates when move is forgotten - WHEN_FORGOTTEN if form change activates when move is learned - -FORM_CHANGE_WITHDRAW: - Form change activates when the Pokémon is withdrawn from the PC or Daycare. - No parameters. - -FORM_CHANGE_FAINT: - Form change activates when the Pokémon faints, either in battle or in the overworld by poison. - If species is not specified and it's on the player's side, it will try to use the value - saved in gBattleStruct->changedSpecies from a previous form change. - No parameters. - -FORM_CHANGE_BATTLE_BEGIN: - Form change activates when the Pokémon is sent out at the beginning of a battle - param1 = item to hold, optional - param2 = a move that will be replaced, optional - param3 = a new move to replace it with, optional - -FORM_CHANGE_BATTLE_END: - Form change activates at the end of a battle. If species is not specified and it's on the player's side, - it will try to use the value saved in gBattleStruct->changedSpecies from a previous form change. - param1 = item to hold, optional - param2 = a move that will be replaced, optional - param3 = a new move to replace it with, optional - -FORM_CHANGE_BATTLE_SWITCH: - Form change activates when the Pokémon is switched out in battle. - No parameters. - -FORM_CHANGE_BATTLE_HP_PERCENT: - Form change activates when the Pokémon's HP % passes a certain threshold. - param1 = Ability to check. - param2 = HP_HIGHER_THAN if the form triggers when the current HP is higher than the specified threshold. - HP_LOWER_EQ_THAN if the form triggers when the current HP is lower or equal than the specified threshold. - param3 = HP percentage threshold. - -FORM_CHANGE_MEGA_EVOLUTION_ITEM: - Form change activates when the mon has the defined item. If it's on the player's side, it also requires - ITEM_MEGA_RING in the user's bag and for the player to choose to enable it. - param1 = item to hold. - -FORM_CHANGE_MEGA_EVOLUTION_MOVE: - Form change activates when the mon has the defined move. If it's on the player's side, it also requires - ITEM_MEGA_RING in the user's bag and for the player to choose to enable it. - param1 = move to have. - -FORM_CHANGE_PRIMAL_REVERSION: - Form change activates automatically when entering battle with the specified item. If the item is a Red Orb, - it uses the Omega Symbol for the animation and icon. Otherwise, it defaults to Alpha. - param1 = item to hold. -*/ - -// FORM_CHANGE_MOVE param2 Arguments -#define WHEN_LEARNED 0 -#define WHEN_FORGOTTEN 1 - -// FORM_CHANGE_ITEM_USE param2 Arguments -#define DAY 1 -#define NIGHT 2 - static const struct FormChange sVenusaurFormChangeTable[] = { {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_VENUSAUR_MEGA, ITEM_VENUSAURITE}, {FORM_CHANGE_FAINT, SPECIES_VENUSAUR}, diff --git a/src/daycare.c b/src/daycare.c index 82280077b..f0eae449e 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -20,6 +20,7 @@ #include "list_menu.h" #include "overworld.h" #include "item.h" +#include "constants/form_change_types.h" #include "constants/items.h" #include "constants/moves.h" #include "constants/region_map_sections.h" diff --git a/src/field_poison.c b/src/field_poison.c index 68a345919..d1bd381cd 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -15,6 +15,7 @@ #include "task.h" #include "trainer_hill.h" #include "constants/field_poison.h" +#include "constants/form_change_types.h" #include "constants/party_menu.h" static bool32 IsMonValidSpecies(struct Pokemon *pokemon) diff --git a/src/party_menu.c b/src/party_menu.c index da87352b5..a3b65fe36 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -66,6 +66,7 @@ #include "constants/battle.h" #include "constants/battle_frontier.h" #include "constants/field_effects.h" +#include "constants/form_change_types.h" #include "constants/item_effects.h" #include "constants/items.h" #include "constants/moves.h" diff --git a/src/pokemon.c b/src/pokemon.c index b5d963376..9c13bd17e 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -43,6 +43,7 @@ #include "constants/battle_frontier.h" #include "constants/battle_move_effects.h" #include "constants/battle_script_commands.h" +#include "constants/form_change_types.h" #include "constants/hold_effects.h" #include "constants/item_effects.h" #include "constants/items.h" diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 3ede591e8..e1a38569b 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -36,6 +36,7 @@ #include "trig.h" #include "walda_phrase.h" #include "window.h" +#include "constants/form_change_types.h" #include "constants/items.h" #include "constants/moves.h" #include "constants/rgb.h" From 99536089cf7a051f4b86606075cbfad4c4e848bd Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 5 Nov 2022 22:02:25 -0300 Subject: [PATCH 16/37] Renamed form change defines to be consistant with which function calls which --- include/constants/form_change_types.h | 26 +- src/battle_main.c | 8 +- src/battle_script_commands.c | 12 +- src/battle_util.c | 20 +- src/data/pokemon/form_change_tables.h | 490 +++++++++++++------------- src/pokemon.c | 12 +- 6 files changed, 284 insertions(+), 284 deletions(-) diff --git a/include/constants/form_change_types.h b/include/constants/form_change_types.h index 1eb2af30a..c6d4c6eae 100644 --- a/include/constants/form_change_types.h +++ b/include/constants/form_change_types.h @@ -9,53 +9,53 @@ #define DAY 1 #define NIGHT 2 -#define FORM_CHANGE_END 0 // Form table terminator +#define FORM_CHANGE_TERMINATOR 0 // Form change that activates when the specified item is given to or taken from the selected Pokémon. // param1: item to hold. // param2: ability to check for, optional. -#define FORM_CHANGE_ITEM_HOLD 1 +#define FORM_CHANGE_ITEM_HOLD 1 // Form change that activates when the item is used on the selected Pokémon. // param1: item to use // param2: time of day to check, optional. // - DAY if Form change that activates in the daytime. // - NIGHT if Form change that activates at nighttime. -#define FORM_CHANGE_ITEM_USE 2 +#define FORM_CHANGE_ITEM_USE 2 // TODO: Form change that activates when the Pokémon learns or forgets the move. // param1: move to check for // param2: // - WHEN_LEARNED if Form change that activates when move is forgotten // - WHEN_FORGOTTEN if Form change that activates when move is learned -#define FORM_CHANGE_MOVE 3 +#define FORM_CHANGE_MOVE 3 // Form change that activates when the Pokémon is withdrawn from the PC or Daycare. // Daycare withdraw done, PC withdraw TODO. // - No parameters. -#define FORM_CHANGE_WITHDRAW 4 +#define FORM_CHANGE_WITHDRAW 4 // Form change that activates when the Pokémon faints, either in battle or in the overworld by poison. // If species is not specified and it's on the player's side, it will try to use the value // saved in gBattleStruct->changedSpecies from a previous form change. // - No parameters. -#define FORM_CHANGE_FAINT 5 +#define FORM_CHANGE_FAINT 5 // Form change that activates when the Pokémon is sent out at the beginning of a battle // param1: item to hold, optional // param2: a move that will be replaced, optional // param3: a new move to replace it with, optional -#define FORM_CHANGE_BATTLE_BEGIN 6 +#define FORM_CHANGE_BEGIN_BATTLE 6 // Form change that activates at the end of a battle. If species is not specified and it's on the player's side, it will try to use the value saved in gBattleStruct->changedSpecies from a previous form change. // param1: item to hold, optional // param2: a move that will be replaced, optional // param3: a new move to replace it with, optional -#define FORM_CHANGE_BATTLE_END 7 +#define FORM_CHANGE_END_BATTLE 7 // Form change that activates when the Pokémon is switched out in battle. // - No parameters. -#define FORM_CHANGE_BATTLE_SWITCH 8 +#define FORM_CHANGE_BATTLE_SWITCH 8 // Form change that activates when the Pokémon's HP % passes a certain threshold. // param1: Ability to check. @@ -63,19 +63,19 @@ // - HP_HIGHER_THAN if the form triggers when the current HP is higher than the specified threshold. // - HP_LOWER_EQ_THAN if the form triggers when the current HP is lower or equal than the specified threshold. // param3: HP percentage threshold. -#define FORM_CHANGE_BATTLE_HP_PERCENT 9 +#define FORM_CHANGE_BATTLE_HP_PERCENT 9 // Form change that activates when the mon has the defined item. // If it's on the player's side, it also requires ITEM_MEGA_RING in the user's bag and for the player to trigger it by pressing START before selecting a move. // param1: item to hold. -#define FORM_CHANGE_MEGA_EVOLUTION_ITEM 10 +#define FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM 10 // Form change that activates when the mon has the defined move. // If it's on the player's side, it also requires ITEM_MEGA_RING in the user's bag and for the player to trigger it by pressing START before selecting a move. // param1: move to have. -#define FORM_CHANGE_MEGA_EVOLUTION_MOVE 11 +#define FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE 11 // Form change that activates automatically when entering battle with the specified item. // If the item is a Red Orb, it uses the Omega Symbol for the animation and icon. Otherwise, it defaults to the Alpha symbol. // param1: item to hold. -#define FORM_CHANGE_PRIMAL_REVERSION 12 +#define FORM_CHANGE_BATTLE_PRIMAL_REVERSION 12 diff --git a/src/battle_main.c b/src/battle_main.c index 5138a6e02..f396b9b0a 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -602,9 +602,9 @@ static void CB2_InitBattleInternal(void) for (i = 0; i < PARTY_SIZE; i++) { // Player's side - TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_BATTLE_BEGIN); + TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_BEGIN_BATTLE); // Opponent's side - TryFormChange(i, B_SIDE_OPPONENT, FORM_CHANGE_BATTLE_BEGIN); + TryFormChange(i, B_SIDE_OPPONENT, FORM_CHANGE_BEGIN_BATTLE); } gBattleCommunication[MULTIUSE_STATE] = 0; @@ -3682,7 +3682,7 @@ static void TryDoEventsBeforeFirstTurn(void) for (i = 0; i < gBattlersCount; i++) { if (GetBattlerHoldEffect(i, TRUE) == HOLD_EFFECT_PRIMAL_ORB - && GetBattleFormChangeTargetSpecies(i, FORM_CHANGE_PRIMAL_REVERSION) != SPECIES_NONE) + && GetBattleFormChangeTargetSpecies(i, FORM_CHANGE_BATTLE_PRIMAL_REVERSION) != SPECIES_NONE) { gBattlerAttacker = i; BattleScriptExecute(BattleScript_PrimalReversion); @@ -5202,7 +5202,7 @@ static void HandleEndTurn_FinishBattle(void) #endif for (i = 0; i < PARTY_SIZE; i++) { - bool32 changedForm = TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_BATTLE_END); + bool32 changedForm = TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_END_BATTLE); DoBurmyFormChange(i); // Clear original species field gBattleStruct->changedSpecies[i] = SPECIES_NONE; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e60f5a49e..73604ce12 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8965,10 +8965,10 @@ static void Cmd_various(void) if (gBattlescriptCurrInstr[3] == 0) { //Checks regular Mega Evolution - u16 megaSpecies = GetBattleFormChangeTargetSpecies(gActiveBattler, FORM_CHANGE_MEGA_EVOLUTION_ITEM); + u16 megaSpecies = GetBattleFormChangeTargetSpecies(gActiveBattler, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM); //Checks Wish Mega Evolution if (megaSpecies == SPECIES_NONE) - megaSpecies = GetBattleFormChangeTargetSpecies(gActiveBattler, FORM_CHANGE_MEGA_EVOLUTION_MOVE); + megaSpecies = GetBattleFormChangeTargetSpecies(gActiveBattler, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE); gBattleMons[gActiveBattler].species = megaSpecies; PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gActiveBattler].species); @@ -9001,7 +9001,7 @@ static void Cmd_various(void) // Change species. if (gBattlescriptCurrInstr[3] == 0) { - gBattleMons[gActiveBattler].species = GetBattleFormChangeTargetSpecies(gActiveBattler, FORM_CHANGE_PRIMAL_REVERSION); + gBattleMons[gActiveBattler].species = GetBattleFormChangeTargetSpecies(gActiveBattler, FORM_CHANGE_BATTLE_PRIMAL_REVERSION); PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gActiveBattler].species); BtlController_EmitSetMonData(BUFFER_A, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[gActiveBattler]], sizeof(gBattleMons[gActiveBattler].species), &gBattleMons[gActiveBattler].species); @@ -9720,7 +9720,7 @@ static void Cmd_various(void) return; case VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL: { - if (GetBattleFormChangeTargetSpecies(gActiveBattler, FORM_CHANGE_PRIMAL_REVERSION) == SPECIES_NONE) + if (GetBattleFormChangeTargetSpecies(gActiveBattler, FORM_CHANGE_BATTLE_PRIMAL_REVERSION) == SPECIES_NONE) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); else gBattlescriptCurrInstr += 7; @@ -14241,7 +14241,7 @@ static void Cmd_handleballthrow(void) { BtlController_EmitBallThrowAnim(BUFFER_A, BALL_3_SHAKES_SUCCESS); MarkBattlerForControllerExec(gActiveBattler); - TryBattleFormChange(gBattlerTarget, FORM_CHANGE_BATTLE_END); + TryBattleFormChange(gBattlerTarget, FORM_CHANGE_END_BATTLE); gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); @@ -14295,7 +14295,7 @@ static void Cmd_handleballthrow(void) if (IsCriticalCapture()) gBattleSpritesDataPtr->animationData->criticalCaptureSuccess = TRUE; - TryBattleFormChange(gBattlerTarget, FORM_CHANGE_BATTLE_END); + TryBattleFormChange(gBattlerTarget, FORM_CHANGE_END_BATTLE); gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); diff --git a/src/battle_util.c b/src/battle_util.c index 634e30338..eaf3f72e0 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -9654,12 +9654,12 @@ bool32 DoesSpeciesUseHoldItemToChangeForm(u16 species, u16 heldItemId) if (formChanges != NULL) { - for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) + for (i = 0; formChanges[i].method != FORM_CHANGE_TERMINATOR; i++) { switch (formChanges[i].method) { - case FORM_CHANGE_MEGA_EVOLUTION_ITEM: - case FORM_CHANGE_PRIMAL_REVERSION: + case FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM: + case FORM_CHANGE_BATTLE_PRIMAL_REVERSION: case FORM_CHANGE_ITEM_HOLD: if (formChanges[i].param1 == heldItemId) return TRUE; @@ -9710,7 +9710,7 @@ bool32 CanMegaEvolve(u8 battlerId) itemId = GetMonData(mon, MON_DATA_HELD_ITEM); // Check if there is an entry in the evolution table for regular Mega Evolution. - if (GetBattleFormChangeTargetSpecies(battlerId, FORM_CHANGE_MEGA_EVOLUTION_ITEM) != SPECIES_NONE) + if (GetBattleFormChangeTargetSpecies(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM) != SPECIES_NONE) { #if B_ENABLE_DEBUG == TRUE if (B_ENABLE_DEBUG && gBattleStruct->debugHoldEffects[battlerId]) @@ -9731,7 +9731,7 @@ bool32 CanMegaEvolve(u8 battlerId) } // Check if there is an entry in the evolution table for Wish Mega Evolution. - if (GetBattleFormChangeTargetSpecies(battlerId, FORM_CHANGE_MEGA_EVOLUTION_MOVE) != SPECIES_NONE) + if (GetBattleFormChangeTargetSpecies(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE) != SPECIES_NONE) { gBattleStruct->mega.isWishMegaEvo = TRUE; return TRUE; @@ -9766,18 +9766,18 @@ u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method) heldItem = gBattleMons[battlerId].item; ability = GetBattlerAbility(battlerId); - for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) + for (i = 0; formChanges[i].method != FORM_CHANGE_TERMINATOR; i++) { if (method == formChanges[i].method && species != formChanges[i].targetSpecies) { switch (method) { - case FORM_CHANGE_MEGA_EVOLUTION_ITEM: - case FORM_CHANGE_PRIMAL_REVERSION: + case FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM: + case FORM_CHANGE_BATTLE_PRIMAL_REVERSION: if (heldItem == formChanges[i].param1) targetSpecies = formChanges[i].targetSpecies; break; - case FORM_CHANGE_MEGA_EVOLUTION_MOVE: + case FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE: if (gBattleMons[battlerId].moves[0] == formChanges[i].param1 || gBattleMons[battlerId].moves[1] == formChanges[i].param1 || gBattleMons[battlerId].moves[2] == formChanges[i].param1 @@ -9856,7 +9856,7 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method) RecalcBattlerStats(battlerId, &party[monId]); return TRUE; } - else if ((method == FORM_CHANGE_BATTLE_END || method == FORM_CHANGE_FAINT) + else if ((method == FORM_CHANGE_END_BATTLE || method == FORM_CHANGE_FAINT) && gBattleStruct->changedSpecies[monId] != SPECIES_NONE) { TryToSetBattleFormChangeMoves(&party[monId], method); diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 4bb0c5780..6f963b599 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -1,336 +1,336 @@ static const struct FormChange sVenusaurFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_VENUSAUR_MEGA, ITEM_VENUSAURITE}, - {FORM_CHANGE_FAINT, SPECIES_VENUSAUR}, - {FORM_CHANGE_BATTLE_END, SPECIES_VENUSAUR}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_VENUSAUR_MEGA, ITEM_VENUSAURITE}, + {FORM_CHANGE_FAINT, SPECIES_VENUSAUR}, + {FORM_CHANGE_END_BATTLE, SPECIES_VENUSAUR}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sCharizardFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_CHARIZARD_MEGA_X, ITEM_CHARIZARDITE_X}, - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_CHARIZARD_MEGA_Y, ITEM_CHARIZARDITE_Y}, - {FORM_CHANGE_FAINT, SPECIES_CHARIZARD}, - {FORM_CHANGE_BATTLE_END, SPECIES_CHARIZARD}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_CHARIZARD_MEGA_X, ITEM_CHARIZARDITE_X}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_CHARIZARD_MEGA_Y, ITEM_CHARIZARDITE_Y}, + {FORM_CHANGE_FAINT, SPECIES_CHARIZARD}, + {FORM_CHANGE_END_BATTLE, SPECIES_CHARIZARD}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sBlastoiseFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_BLASTOISE_MEGA, ITEM_BLASTOISINITE}, - {FORM_CHANGE_FAINT, SPECIES_BLASTOISE}, - {FORM_CHANGE_BATTLE_END, SPECIES_BLASTOISE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BLASTOISE_MEGA, ITEM_BLASTOISINITE}, + {FORM_CHANGE_FAINT, SPECIES_BLASTOISE}, + {FORM_CHANGE_END_BATTLE, SPECIES_BLASTOISE}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sBeedrillFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_BEEDRILL_MEGA, ITEM_BEEDRILLITE}, - {FORM_CHANGE_FAINT, SPECIES_BEEDRILL}, - {FORM_CHANGE_BATTLE_END, SPECIES_BEEDRILL}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BEEDRILL_MEGA, ITEM_BEEDRILLITE}, + {FORM_CHANGE_FAINT, SPECIES_BEEDRILL}, + {FORM_CHANGE_END_BATTLE, SPECIES_BEEDRILL}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sPidgeotFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_PIDGEOT_MEGA, ITEM_PIDGEOTITE}, - {FORM_CHANGE_FAINT, SPECIES_PIDGEOT}, - {FORM_CHANGE_BATTLE_END, SPECIES_PIDGEOT}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_PIDGEOT_MEGA, ITEM_PIDGEOTITE}, + {FORM_CHANGE_FAINT, SPECIES_PIDGEOT}, + {FORM_CHANGE_END_BATTLE, SPECIES_PIDGEOT}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAlakazamFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_ALAKAZAM_MEGA, ITEM_ALAKAZITE}, - {FORM_CHANGE_FAINT, SPECIES_ALAKAZAM}, - {FORM_CHANGE_BATTLE_END, SPECIES_ALAKAZAM}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ALAKAZAM_MEGA, ITEM_ALAKAZITE}, + {FORM_CHANGE_FAINT, SPECIES_ALAKAZAM}, + {FORM_CHANGE_END_BATTLE, SPECIES_ALAKAZAM}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSlowbroFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SLOWBRO_MEGA, ITEM_SLOWBRONITE}, - {FORM_CHANGE_FAINT, SPECIES_SLOWBRO}, - {FORM_CHANGE_BATTLE_END, SPECIES_SLOWBRO}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SLOWBRO_MEGA, ITEM_SLOWBRONITE}, + {FORM_CHANGE_FAINT, SPECIES_SLOWBRO}, + {FORM_CHANGE_END_BATTLE, SPECIES_SLOWBRO}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGengarFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_GENGAR_MEGA, ITEM_GENGARITE}, - {FORM_CHANGE_FAINT, SPECIES_GENGAR}, - {FORM_CHANGE_BATTLE_END, SPECIES_GENGAR}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GENGAR_MEGA, ITEM_GENGARITE}, + {FORM_CHANGE_FAINT, SPECIES_GENGAR}, + {FORM_CHANGE_END_BATTLE, SPECIES_GENGAR}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sKangaskhanFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_KANGASKHAN_MEGA, ITEM_KANGASKHANITE}, - {FORM_CHANGE_FAINT, SPECIES_KANGASKHAN}, - {FORM_CHANGE_BATTLE_END, SPECIES_KANGASKHAN}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_KANGASKHAN_MEGA, ITEM_KANGASKHANITE}, + {FORM_CHANGE_FAINT, SPECIES_KANGASKHAN}, + {FORM_CHANGE_END_BATTLE, SPECIES_KANGASKHAN}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sPinsirFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_PINSIR_MEGA, ITEM_PINSIRITE}, - {FORM_CHANGE_FAINT, SPECIES_PINSIR}, - {FORM_CHANGE_BATTLE_END, SPECIES_PINSIR}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_PINSIR_MEGA, ITEM_PINSIRITE}, + {FORM_CHANGE_FAINT, SPECIES_PINSIR}, + {FORM_CHANGE_END_BATTLE, SPECIES_PINSIR}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGyaradosFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_GYARADOS_MEGA, ITEM_GYARADOSITE}, - {FORM_CHANGE_FAINT, SPECIES_GYARADOS}, - {FORM_CHANGE_BATTLE_END, SPECIES_GYARADOS}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GYARADOS_MEGA, ITEM_GYARADOSITE}, + {FORM_CHANGE_FAINT, SPECIES_GYARADOS}, + {FORM_CHANGE_END_BATTLE, SPECIES_GYARADOS}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAerodactylFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_AERODACTYL_MEGA, ITEM_AERODACTYLITE}, - {FORM_CHANGE_FAINT, SPECIES_AERODACTYL}, - {FORM_CHANGE_BATTLE_END, SPECIES_AERODACTYL}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AERODACTYL_MEGA, ITEM_AERODACTYLITE}, + {FORM_CHANGE_FAINT, SPECIES_AERODACTYL}, + {FORM_CHANGE_END_BATTLE, SPECIES_AERODACTYL}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMewtwoFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_MEWTWO_MEGA_X, ITEM_MEWTWONITE_X}, - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_MEWTWO_MEGA_Y, ITEM_MEWTWONITE_Y}, - {FORM_CHANGE_FAINT, SPECIES_MEWTWO}, - {FORM_CHANGE_BATTLE_END, SPECIES_MEWTWO}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MEWTWO_MEGA_X, ITEM_MEWTWONITE_X}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MEWTWO_MEGA_Y, ITEM_MEWTWONITE_Y}, + {FORM_CHANGE_FAINT, SPECIES_MEWTWO}, + {FORM_CHANGE_END_BATTLE, SPECIES_MEWTWO}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAmpharosFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_AMPHAROS_MEGA, ITEM_AMPHAROSITE}, - {FORM_CHANGE_FAINT, SPECIES_AMPHAROS}, - {FORM_CHANGE_BATTLE_END, SPECIES_AMPHAROS}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AMPHAROS_MEGA, ITEM_AMPHAROSITE}, + {FORM_CHANGE_FAINT, SPECIES_AMPHAROS}, + {FORM_CHANGE_END_BATTLE, SPECIES_AMPHAROS}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSteelixFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_STEELIX_MEGA, ITEM_STEELIXITE}, - {FORM_CHANGE_FAINT, SPECIES_STEELIX}, - {FORM_CHANGE_BATTLE_END, SPECIES_STEELIX}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_STEELIX_MEGA, ITEM_STEELIXITE}, + {FORM_CHANGE_FAINT, SPECIES_STEELIX}, + {FORM_CHANGE_END_BATTLE, SPECIES_STEELIX}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sScizorFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SCIZOR_MEGA, ITEM_SCIZORITE}, - {FORM_CHANGE_FAINT, SPECIES_SCIZOR}, - {FORM_CHANGE_BATTLE_END, SPECIES_SCIZOR}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SCIZOR_MEGA, ITEM_SCIZORITE}, + {FORM_CHANGE_FAINT, SPECIES_SCIZOR}, + {FORM_CHANGE_END_BATTLE, SPECIES_SCIZOR}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sHeracrossFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_HERACROSS_MEGA, ITEM_HERACRONITE}, - {FORM_CHANGE_FAINT, SPECIES_HERACROSS}, - {FORM_CHANGE_BATTLE_END, SPECIES_HERACROSS}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_HERACROSS_MEGA, ITEM_HERACRONITE}, + {FORM_CHANGE_FAINT, SPECIES_HERACROSS}, + {FORM_CHANGE_END_BATTLE, SPECIES_HERACROSS}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sHoundoomFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_HOUNDOOM_MEGA, ITEM_HOUNDOOMINITE}, - {FORM_CHANGE_FAINT, SPECIES_HOUNDOOM}, - {FORM_CHANGE_BATTLE_END, SPECIES_HOUNDOOM}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_HOUNDOOM_MEGA, ITEM_HOUNDOOMINITE}, + {FORM_CHANGE_FAINT, SPECIES_HOUNDOOM}, + {FORM_CHANGE_END_BATTLE, SPECIES_HOUNDOOM}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sTyranitarFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_TYRANITAR_MEGA, ITEM_TYRANITARITE}, - {FORM_CHANGE_FAINT, SPECIES_TYRANITAR}, - {FORM_CHANGE_BATTLE_END, SPECIES_TYRANITAR}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_TYRANITAR_MEGA, ITEM_TYRANITARITE}, + {FORM_CHANGE_FAINT, SPECIES_TYRANITAR}, + {FORM_CHANGE_END_BATTLE, SPECIES_TYRANITAR}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSceptileFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SCEPTILE_MEGA, ITEM_SCEPTILITE}, - {FORM_CHANGE_FAINT, SPECIES_SCEPTILE}, - {FORM_CHANGE_BATTLE_END, SPECIES_SCEPTILE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SCEPTILE_MEGA, ITEM_SCEPTILITE}, + {FORM_CHANGE_FAINT, SPECIES_SCEPTILE}, + {FORM_CHANGE_END_BATTLE, SPECIES_SCEPTILE}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sBlazikenFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_BLAZIKEN_MEGA, ITEM_BLAZIKENITE}, - {FORM_CHANGE_FAINT, SPECIES_BLAZIKEN}, - {FORM_CHANGE_BATTLE_END, SPECIES_BLAZIKEN}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BLAZIKEN_MEGA, ITEM_BLAZIKENITE}, + {FORM_CHANGE_FAINT, SPECIES_BLAZIKEN}, + {FORM_CHANGE_END_BATTLE, SPECIES_BLAZIKEN}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSwampertFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SWAMPERT_MEGA, ITEM_SWAMPERTITE}, - {FORM_CHANGE_FAINT, SPECIES_SWAMPERT}, - {FORM_CHANGE_BATTLE_END, SPECIES_SWAMPERT}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SWAMPERT_MEGA, ITEM_SWAMPERTITE}, + {FORM_CHANGE_FAINT, SPECIES_SWAMPERT}, + {FORM_CHANGE_END_BATTLE, SPECIES_SWAMPERT}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSableyeFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SABLEYE_MEGA, ITEM_SABLENITE}, - {FORM_CHANGE_FAINT, SPECIES_SABLEYE}, - {FORM_CHANGE_BATTLE_END, SPECIES_SABLEYE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SABLEYE_MEGA, ITEM_SABLENITE}, + {FORM_CHANGE_FAINT, SPECIES_SABLEYE}, + {FORM_CHANGE_END_BATTLE, SPECIES_SABLEYE}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSharpedoFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SHARPEDO_MEGA, ITEM_SHARPEDONITE}, - {FORM_CHANGE_FAINT, SPECIES_SHARPEDO}, - {FORM_CHANGE_BATTLE_END, SPECIES_SHARPEDO}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SHARPEDO_MEGA, ITEM_SHARPEDONITE}, + {FORM_CHANGE_FAINT, SPECIES_SHARPEDO}, + {FORM_CHANGE_END_BATTLE, SPECIES_SHARPEDO}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sManectricFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_MANECTRIC_MEGA, ITEM_MANECTITE}, - {FORM_CHANGE_FAINT, SPECIES_MANECTRIC}, - {FORM_CHANGE_BATTLE_END, SPECIES_MANECTRIC}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MANECTRIC_MEGA, ITEM_MANECTITE}, + {FORM_CHANGE_FAINT, SPECIES_MANECTRIC}, + {FORM_CHANGE_END_BATTLE, SPECIES_MANECTRIC}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sCameruptFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_CAMERUPT_MEGA, ITEM_CAMERUPTITE}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_CAMERUPT_MEGA, ITEM_CAMERUPTITE}, {FORM_CHANGE_FAINT, SPECIES_CAMERUPT}, - {FORM_CHANGE_BATTLE_END, SPECIES_CAMERUPT}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_CAMERUPT}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGlalieFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_GLALIE_MEGA, ITEM_GLALITITE}, - {FORM_CHANGE_FAINT, SPECIES_GLALIE}, - {FORM_CHANGE_BATTLE_END, SPECIES_GLALIE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GLALIE_MEGA, ITEM_GLALITITE}, + {FORM_CHANGE_FAINT, SPECIES_GLALIE}, + {FORM_CHANGE_END_BATTLE, SPECIES_GLALIE}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMawileFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_MAWILE_MEGA, ITEM_MAWILITE}, - {FORM_CHANGE_FAINT, SPECIES_MAWILE}, - {FORM_CHANGE_BATTLE_END, SPECIES_MAWILE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MAWILE_MEGA, ITEM_MAWILITE}, + {FORM_CHANGE_FAINT, SPECIES_MAWILE}, + {FORM_CHANGE_END_BATTLE, SPECIES_MAWILE}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMedichamFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_MEDICHAM_MEGA, ITEM_MEDICHAMITE}, - {FORM_CHANGE_FAINT, SPECIES_MEDICHAM}, - {FORM_CHANGE_BATTLE_END, SPECIES_MEDICHAM}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MEDICHAM_MEGA, ITEM_MEDICHAMITE}, + {FORM_CHANGE_FAINT, SPECIES_MEDICHAM}, + {FORM_CHANGE_END_BATTLE, SPECIES_MEDICHAM}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAltariaFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_ALTARIA_MEGA, ITEM_ALTARIANITE}, - {FORM_CHANGE_FAINT, SPECIES_ALTARIA}, - {FORM_CHANGE_BATTLE_END, SPECIES_ALTARIA}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ALTARIA_MEGA, ITEM_ALTARIANITE}, + {FORM_CHANGE_FAINT, SPECIES_ALTARIA}, + {FORM_CHANGE_END_BATTLE, SPECIES_ALTARIA}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAbsolFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_ABSOL_MEGA, ITEM_ABSOLITE}, - {FORM_CHANGE_FAINT, SPECIES_ABSOL}, - {FORM_CHANGE_BATTLE_END, SPECIES_ABSOL}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ABSOL_MEGA, ITEM_ABSOLITE}, + {FORM_CHANGE_FAINT, SPECIES_ABSOL}, + {FORM_CHANGE_END_BATTLE, SPECIES_ABSOL}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sBanetteFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_BANETTE_MEGA, ITEM_BANETTITE}, - {FORM_CHANGE_FAINT, SPECIES_BANETTE}, - {FORM_CHANGE_BATTLE_END, SPECIES_BANETTE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BANETTE_MEGA, ITEM_BANETTITE}, + {FORM_CHANGE_FAINT, SPECIES_BANETTE}, + {FORM_CHANGE_END_BATTLE, SPECIES_BANETTE}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAggronFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_AGGRON_MEGA, ITEM_AGGRONITE}, - {FORM_CHANGE_FAINT, SPECIES_AGGRON}, - {FORM_CHANGE_BATTLE_END, SPECIES_AGGRON}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AGGRON_MEGA, ITEM_AGGRONITE}, + {FORM_CHANGE_FAINT, SPECIES_AGGRON}, + {FORM_CHANGE_END_BATTLE, SPECIES_AGGRON}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGardevoirFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_GARDEVOIR_MEGA, ITEM_GARDEVOIRITE}, - {FORM_CHANGE_FAINT, SPECIES_GARDEVOIR}, - {FORM_CHANGE_BATTLE_END, SPECIES_GARDEVOIR}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GARDEVOIR_MEGA, ITEM_GARDEVOIRITE}, + {FORM_CHANGE_FAINT, SPECIES_GARDEVOIR}, + {FORM_CHANGE_END_BATTLE, SPECIES_GARDEVOIR}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSalamenceFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_SALAMENCE_MEGA, ITEM_SALAMENCITE}, - {FORM_CHANGE_FAINT, SPECIES_SALAMENCE}, - {FORM_CHANGE_BATTLE_END, SPECIES_SALAMENCE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SALAMENCE_MEGA, ITEM_SALAMENCITE}, + {FORM_CHANGE_FAINT, SPECIES_SALAMENCE}, + {FORM_CHANGE_END_BATTLE, SPECIES_SALAMENCE}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMetagrossFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_METAGROSS_MEGA, ITEM_METAGROSSITE}, - {FORM_CHANGE_FAINT, SPECIES_METAGROSS}, - {FORM_CHANGE_BATTLE_END, SPECIES_METAGROSS}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_METAGROSS_MEGA, ITEM_METAGROSSITE}, + {FORM_CHANGE_FAINT, SPECIES_METAGROSS}, + {FORM_CHANGE_END_BATTLE, SPECIES_METAGROSS}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sLatiasFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_LATIAS_MEGA, ITEM_LATIASITE}, - {FORM_CHANGE_FAINT, SPECIES_LATIAS}, - {FORM_CHANGE_BATTLE_END, SPECIES_LATIAS}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LATIAS_MEGA, ITEM_LATIASITE}, + {FORM_CHANGE_FAINT, SPECIES_LATIAS}, + {FORM_CHANGE_END_BATTLE, SPECIES_LATIAS}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sLatiosFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_LATIOS_MEGA, ITEM_LATIOSITE}, - {FORM_CHANGE_FAINT, SPECIES_LATIOS}, - {FORM_CHANGE_BATTLE_END, SPECIES_LATIOS}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LATIOS_MEGA, ITEM_LATIOSITE}, + {FORM_CHANGE_FAINT, SPECIES_LATIOS}, + {FORM_CHANGE_END_BATTLE, SPECIES_LATIOS}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sKyogreFormChangeTable[] = { - {FORM_CHANGE_PRIMAL_REVERSION, SPECIES_KYOGRE_PRIMAL, ITEM_BLUE_ORB}, - {FORM_CHANGE_BATTLE_END, SPECIES_KYOGRE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_PRIMAL_REVERSION, SPECIES_KYOGRE_PRIMAL, ITEM_BLUE_ORB}, + {FORM_CHANGE_END_BATTLE, SPECIES_KYOGRE}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGroudonFormChangeTable[] = { - {FORM_CHANGE_PRIMAL_REVERSION, SPECIES_GROUDON_PRIMAL, ITEM_RED_ORB}, - {FORM_CHANGE_BATTLE_END, SPECIES_GROUDON}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_PRIMAL_REVERSION, SPECIES_GROUDON_PRIMAL, ITEM_RED_ORB}, + {FORM_CHANGE_END_BATTLE, SPECIES_GROUDON}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sRayquazaFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_MOVE, SPECIES_RAYQUAZA_MEGA, MOVE_DRAGON_ASCENT}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE, SPECIES_RAYQUAZA_MEGA, MOVE_DRAGON_ASCENT}, {FORM_CHANGE_FAINT, SPECIES_RAYQUAZA}, - {FORM_CHANGE_BATTLE_END, SPECIES_RAYQUAZA}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_RAYQUAZA}, + {FORM_CHANGE_TERMINATOR}, }; #if P_GEN_4_POKEMON == TRUE static const struct FormChange sLopunnyFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_LOPUNNY_MEGA, ITEM_LOPUNNITE}, - {FORM_CHANGE_FAINT, SPECIES_LOPUNNY}, - {FORM_CHANGE_BATTLE_END, SPECIES_LOPUNNY}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LOPUNNY_MEGA, ITEM_LOPUNNITE}, + {FORM_CHANGE_FAINT, SPECIES_LOPUNNY}, + {FORM_CHANGE_END_BATTLE, SPECIES_LOPUNNY}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGarchompFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_GARCHOMP_MEGA, ITEM_GARCHOMPITE}, - {FORM_CHANGE_FAINT, SPECIES_GARCHOMP}, - {FORM_CHANGE_BATTLE_END, SPECIES_GARCHOMP}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GARCHOMP_MEGA, ITEM_GARCHOMPITE}, + {FORM_CHANGE_FAINT, SPECIES_GARCHOMP}, + {FORM_CHANGE_END_BATTLE, SPECIES_GARCHOMP}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sLucarioFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_LUCARIO_MEGA, ITEM_LUCARIONITE}, - {FORM_CHANGE_FAINT, SPECIES_LUCARIO}, - {FORM_CHANGE_BATTLE_END, SPECIES_LUCARIO}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LUCARIO_MEGA, ITEM_LUCARIONITE}, + {FORM_CHANGE_FAINT, SPECIES_LUCARIO}, + {FORM_CHANGE_END_BATTLE, SPECIES_LUCARIO}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAbomasnowFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_ABOMASNOW_MEGA, ITEM_ABOMASITE}, - {FORM_CHANGE_FAINT, SPECIES_ABOMASNOW}, - {FORM_CHANGE_BATTLE_END, SPECIES_ABOMASNOW}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ABOMASNOW_MEGA, ITEM_ABOMASITE}, + {FORM_CHANGE_FAINT, SPECIES_ABOMASNOW}, + {FORM_CHANGE_END_BATTLE, SPECIES_ABOMASNOW}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGalladeFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_GALLADE_MEGA, ITEM_GALLADITE}, - {FORM_CHANGE_FAINT, SPECIES_GALLADE}, - {FORM_CHANGE_BATTLE_END, SPECIES_GALLADE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GALLADE_MEGA, ITEM_GALLADITE}, + {FORM_CHANGE_FAINT, SPECIES_GALLADE}, + {FORM_CHANGE_END_BATTLE, SPECIES_GALLADE}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGiratinaFormChangeTable[] = { {FORM_CHANGE_ITEM_HOLD, SPECIES_GIRATINA, ITEM_NONE}, {FORM_CHANGE_ITEM_HOLD, SPECIES_GIRATINA_ORIGIN, ITEM_GRISEOUS_ORB}, - {FORM_CHANGE_END}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sShayminFormChangeTable[] = { {FORM_CHANGE_ITEM_USE, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, DAY}, // {FORM_CHANGE_WITHDRAW, SPECIES_SHAYMIN}, - {FORM_CHANGE_END}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sArceusFormChangeTable[] = { @@ -369,62 +369,62 @@ static const struct FormChange sArceusFormChangeTable[] = { {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_DARK, ITEM_DARKINIUM_Z, ABILITY_MULTITYPE}, {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_FAIRY, ITEM_PIXIE_PLATE, ABILITY_MULTITYPE}, {FORM_CHANGE_ITEM_HOLD, SPECIES_ARCEUS_FAIRY, ITEM_FAIRIUM_Z, ABILITY_MULTITYPE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_TERMINATOR}, }; #endif #if P_GEN_5_POKEMON == TRUE static const struct FormChange sAudinoFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_AUDINO_MEGA, ITEM_AUDINITE}, - {FORM_CHANGE_FAINT, SPECIES_AUDINO}, - {FORM_CHANGE_BATTLE_END, SPECIES_AUDINO}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AUDINO_MEGA, ITEM_AUDINITE}, + {FORM_CHANGE_FAINT, SPECIES_AUDINO}, + {FORM_CHANGE_END_BATTLE, SPECIES_AUDINO}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sDarmanitanFormChangeTable[] = { {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_DARMANITAN, ABILITY_ZEN_MODE, HP_HIGHER_THAN, 50}, {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_DARMANITAN_ZEN_MODE, ABILITY_ZEN_MODE, HP_LOWER_EQ_THAN, 50}, {FORM_CHANGE_FAINT, SPECIES_DARMANITAN}, - {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_DARMANITAN}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sDarmanitanGalarianFormChangeTable[] = { {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_DARMANITAN_GALARIAN, ABILITY_ZEN_MODE, HP_HIGHER_THAN, 50}, {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_DARMANITAN_ZEN_MODE_GALARIAN, ABILITY_ZEN_MODE, HP_LOWER_EQ_THAN, 50}, {FORM_CHANGE_FAINT, SPECIES_DARMANITAN_GALARIAN}, - {FORM_CHANGE_BATTLE_END, SPECIES_DARMANITAN_GALARIAN}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_DARMANITAN_GALARIAN}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMeloettaFormChangeTable[] = { {FORM_CHANGE_FAINT, SPECIES_MELOETTA}, - {FORM_CHANGE_BATTLE_END, SPECIES_MELOETTA}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_MELOETTA}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sTornadusFormChangeTable[] = { {FORM_CHANGE_ITEM_USE, SPECIES_TORNADUS_THERIAN, ITEM_REVEAL_GLASS}, {FORM_CHANGE_ITEM_USE, SPECIES_TORNADUS, ITEM_REVEAL_GLASS}, - {FORM_CHANGE_END}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sThundurusFormChangeTable[] = { {FORM_CHANGE_ITEM_USE, SPECIES_THUNDURUS_THERIAN, ITEM_REVEAL_GLASS}, {FORM_CHANGE_ITEM_USE, SPECIES_THUNDURUS, ITEM_REVEAL_GLASS}, - {FORM_CHANGE_END}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sLandorusFormChangeTable[] = { {FORM_CHANGE_ITEM_USE, SPECIES_LANDORUS_THERIAN, ITEM_REVEAL_GLASS}, {FORM_CHANGE_ITEM_USE, SPECIES_LANDORUS, ITEM_REVEAL_GLASS}, - {FORM_CHANGE_END}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sKeldeoFormChangeTable[] = { // {FORM_CHANGE_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD, WHEN_LEARNED}, // {FORM_CHANGE_MOVE, SPECIES_KELDEO, MOVE_SECRET_SWORD, WHEN_FORGOTTEN}, - {FORM_CHANGE_END}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGenesectFormChangeTable[] = { @@ -433,48 +433,48 @@ static const struct FormChange sGenesectFormChangeTable[] = { {FORM_CHANGE_ITEM_HOLD, SPECIES_GENESECT_SHOCK_DRIVE, ITEM_SHOCK_DRIVE}, {FORM_CHANGE_ITEM_HOLD, SPECIES_GENESECT_BURN_DRIVE, ITEM_BURN_DRIVE}, {FORM_CHANGE_ITEM_HOLD, SPECIES_GENESECT_CHILL_DRIVE, ITEM_CHILL_DRIVE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_TERMINATOR}, }; #endif #if P_GEN_6_POKEMON == TRUE static const struct FormChange sGreninjaBattleBondFormChangeTable[] = { {FORM_CHANGE_FAINT, SPECIES_GRENINJA_BATTLE_BOND}, - {FORM_CHANGE_BATTLE_END, SPECIES_GRENINJA_BATTLE_BOND}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_GRENINJA_BATTLE_BOND}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAegislashFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_AEGISLASH}, {FORM_CHANGE_FAINT, SPECIES_AEGISLASH}, - {FORM_CHANGE_BATTLE_END, SPECIES_AEGISLASH}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_AEGISLASH}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sXerneasFormChangeTable[] = { - {FORM_CHANGE_BATTLE_BEGIN, SPECIES_XERNEAS_ACTIVE}, - {FORM_CHANGE_BATTLE_END, SPECIES_XERNEAS, }, - {FORM_CHANGE_END}, + {FORM_CHANGE_BEGIN_BATTLE, SPECIES_XERNEAS_ACTIVE}, + {FORM_CHANGE_END_BATTLE, SPECIES_XERNEAS, }, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sZygardePowerConstructFormChangeTable[] = { {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_ZYGARDE_COMPLETE, ABILITY_POWER_CONSTRUCT, HP_LOWER_EQ_THAN, 50}, {FORM_CHANGE_FAINT}, - {FORM_CHANGE_BATTLE_END}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sDiancieFormChangeTable[] = { - {FORM_CHANGE_MEGA_EVOLUTION_ITEM, SPECIES_DIANCIE_MEGA, ITEM_DIANCITE}, - {FORM_CHANGE_FAINT, SPECIES_DIANCIE}, - {FORM_CHANGE_BATTLE_END, SPECIES_DIANCIE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_DIANCIE_MEGA, ITEM_DIANCITE}, + {FORM_CHANGE_FAINT, SPECIES_DIANCIE}, + {FORM_CHANGE_END_BATTLE, SPECIES_DIANCIE}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sHoopaFormChangeTable[] = { {FORM_CHANGE_ITEM_USE, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA}, {FORM_CHANGE_WITHDRAW, SPECIES_HOOPA}, - {FORM_CHANGE_END}, + {FORM_CHANGE_TERMINATOR}, }; #endif @@ -484,15 +484,15 @@ static const struct FormChange sOricorioFormChangeTable[] = { {FORM_CHANGE_ITEM_USE, SPECIES_ORICORIO_POM_POM, ITEM_YELLOW_NECTAR}, {FORM_CHANGE_ITEM_USE, SPECIES_ORICORIO_PAU, ITEM_PINK_NECTAR}, {FORM_CHANGE_ITEM_USE, SPECIES_ORICORIO_SENSU, ITEM_PURPLE_NECTAR}, - {FORM_CHANGE_END}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sWishiwashiFormChangeTable[] = { {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_WISHIWASHI_SCHOOL, ABILITY_SCHOOLING, HP_HIGHER_THAN, 25}, {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_WISHIWASHI, ABILITY_SCHOOLING, HP_LOWER_EQ_THAN, 25}, {FORM_CHANGE_BATTLE_SWITCH, SPECIES_WISHIWASHI}, {FORM_CHANGE_FAINT, SPECIES_WISHIWASHI}, - {FORM_CHANGE_BATTLE_END, SPECIES_WISHIWASHI}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_WISHIWASHI}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSilvallyFormChangeTable[] = { @@ -514,13 +514,13 @@ static const struct FormChange sSilvallyFormChangeTable[] = { {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_DRAGON, ITEM_DRAGON_MEMORY, ABILITY_RKS_SYSTEM}, {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_DARK, ITEM_DARK_MEMORY, ABILITY_RKS_SYSTEM}, {FORM_CHANGE_ITEM_HOLD, SPECIES_SILVALLY_FAIRY, ITEM_FAIRY_MEMORY, ABILITY_RKS_SYSTEM}, - {FORM_CHANGE_END}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMimikyuFormChangeTable[] = { {FORM_CHANGE_FAINT, SPECIES_MIMIKYU}, - {FORM_CHANGE_BATTLE_END, SPECIES_MIMIKYU}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_MIMIKYU}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMiniorRedFormChangeTable[] = { @@ -528,56 +528,56 @@ static const struct FormChange sMiniorRedFormChangeTable[] = { {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_RED, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_RED}, {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_RED}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_RED}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_MINIOR_CORE_RED}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMiniorBlueFormChangeTable[] = { {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_METEOR_BLUE, ABILITY_SHIELDS_DOWN, HP_HIGHER_THAN, 50}, {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_BLUE, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_BLUE}, {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_BLUE}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_BLUE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_MINIOR_CORE_BLUE}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMiniorGreenFormChangeTable[] = { {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_METEOR_GREEN, ABILITY_SHIELDS_DOWN, HP_HIGHER_THAN, 50}, {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_GREEN, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_GREEN}, {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_GREEN}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_GREEN}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_MINIOR_CORE_GREEN}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMiniorIndigoFormChangeTable[] = { {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_METEOR_INDIGO, ABILITY_SHIELDS_DOWN, HP_HIGHER_THAN, 50}, {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_INDIGO, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_INDIGO}, {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_INDIGO}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_INDIGO}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_MINIOR_CORE_INDIGO}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMiniorOrangeFormChangeTable[] = { {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_METEOR_ORANGE, ABILITY_SHIELDS_DOWN, HP_HIGHER_THAN, 50}, {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_ORANGE, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_ORANGE}, {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_ORANGE}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_ORANGE}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_MINIOR_CORE_ORANGE}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMiniorVioletFormChangeTable[] = { {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_METEOR_VIOLET, ABILITY_SHIELDS_DOWN, HP_HIGHER_THAN, 50}, {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_VIOLET, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_VIOLET}, {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_VIOLET}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_VIOLET}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_MINIOR_CORE_VIOLET}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMiniorYellowFormChangeTable[] = { {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_METEOR_YELLOW, ABILITY_SHIELDS_DOWN, HP_HIGHER_THAN, 50}, {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_MINIOR_CORE_YELLOW, ABILITY_SHIELDS_DOWN, HP_LOWER_EQ_THAN, 50}, {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MINIOR_CORE_YELLOW}, {FORM_CHANGE_FAINT, SPECIES_MINIOR_CORE_YELLOW}, - {FORM_CHANGE_BATTLE_END, SPECIES_MINIOR_CORE_YELLOW}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_MINIOR_CORE_YELLOW}, + {FORM_CHANGE_TERMINATOR}, }; #endif @@ -587,33 +587,33 @@ static const struct FormChange sCramorantFormChangeTable[] = { {FORM_CHANGE_BATTLE_HP_PERCENT, SPECIES_CRAMORANT_GORGING, ABILITY_GULP_MISSILE, HP_LOWER_EQ_THAN, 50}, {FORM_CHANGE_BATTLE_SWITCH, SPECIES_CRAMORANT}, {FORM_CHANGE_FAINT, SPECIES_CRAMORANT}, - {FORM_CHANGE_BATTLE_END, SPECIES_CRAMORANT}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_CRAMORANT}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMorpekoFormChangeTable[] = { {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MORPEKO}, {FORM_CHANGE_FAINT, SPECIES_MORPEKO}, - {FORM_CHANGE_BATTLE_END, SPECIES_MORPEKO}, - {FORM_CHANGE_END}, + {FORM_CHANGE_END_BATTLE, SPECIES_MORPEKO}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sZacianFormChangeTable[] = { - {FORM_CHANGE_BATTLE_BEGIN, SPECIES_ZACIAN_CROWNED_SWORD, ITEM_RUSTED_SWORD, MOVE_IRON_HEAD, MOVE_BEHEMOTH_BLADE}, - {FORM_CHANGE_BATTLE_END, SPECIES_ZACIAN, ITEM_RUSTED_SWORD, MOVE_BEHEMOTH_BLADE, MOVE_IRON_HEAD}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BEGIN_BATTLE, SPECIES_ZACIAN_CROWNED_SWORD, ITEM_RUSTED_SWORD, MOVE_IRON_HEAD, MOVE_BEHEMOTH_BLADE}, + {FORM_CHANGE_END_BATTLE, SPECIES_ZACIAN, ITEM_RUSTED_SWORD, MOVE_BEHEMOTH_BLADE, MOVE_IRON_HEAD}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sZamazentaFormChangeTable[] = { - {FORM_CHANGE_BATTLE_BEGIN, SPECIES_ZAMAZENTA_CROWNED_SHIELD, ITEM_RUSTED_SHIELD, MOVE_IRON_HEAD, MOVE_BEHEMOTH_BASH}, - {FORM_CHANGE_BATTLE_END, SPECIES_ZAMAZENTA, ITEM_RUSTED_SHIELD, MOVE_BEHEMOTH_BASH, MOVE_IRON_HEAD}, - {FORM_CHANGE_END}, + {FORM_CHANGE_BEGIN_BATTLE, SPECIES_ZAMAZENTA_CROWNED_SHIELD, ITEM_RUSTED_SHIELD, MOVE_IRON_HEAD, MOVE_BEHEMOTH_BASH}, + {FORM_CHANGE_END_BATTLE, SPECIES_ZAMAZENTA, ITEM_RUSTED_SHIELD, MOVE_BEHEMOTH_BASH, MOVE_IRON_HEAD}, + {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sEnamorusFormChangeTable[] = { {FORM_CHANGE_ITEM_USE, SPECIES_ENAMORUS, ITEM_REVEAL_GLASS}, {FORM_CHANGE_ITEM_USE, SPECIES_ENAMORUS_THERIAN, ITEM_REVEAL_GLASS}, - {FORM_CHANGE_END}, + {FORM_CHANGE_TERMINATOR}, }; #endif diff --git a/src/pokemon.c b/src/pokemon.c index 9c13bd17e..1b41d666d 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8498,7 +8498,7 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 heldItem = GetBoxMonData(boxMon, MON_DATA_HELD_ITEM, NULL); ability = GetAbilityBySpecies(species, GetBoxMonData(boxMon, MON_DATA_ABILITY_NUM, NULL)); - for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) + for (i = 0; formChanges[i].method != FORM_CHANGE_TERMINATOR; i++) { if (method == formChanges[i].method && species != formChanges[i].targetSpecies) { @@ -8534,8 +8534,8 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 if (BoxMonKnowsMove(boxMon, formChanges[i].param1) != formChanges[i].param2) targetSpecies = formChanges[i].targetSpecies; break; - case FORM_CHANGE_BATTLE_BEGIN: - case FORM_CHANGE_BATTLE_END: + case FORM_CHANGE_BEGIN_BATTLE: + case FORM_CHANGE_END_BATTLE: if (heldItem == formChanges[i].param1 || formChanges[i].param1 == ITEM_NONE) targetSpecies = formChanges[i].targetSpecies; break; @@ -8558,7 +8558,7 @@ bool32 DoesSpeciesHaveFormChangeMethod(u16 species, u16 method) if (formChanges != NULL) { - for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) + for (i = 0; formChanges[i].method != FORM_CHANGE_TERMINATOR; i++) { if (method == formChanges[i].method && species != formChanges[i].targetSpecies) return TRUE; @@ -8681,10 +8681,10 @@ void TryToSetBattleFormChangeMoves(struct Pokemon *mon, u16 method) const struct FormChange *formChanges = gFormChangeTablePointers[species]; if (formChanges == NULL - || (method != FORM_CHANGE_BATTLE_BEGIN && method != FORM_CHANGE_BATTLE_END)) + || (method != FORM_CHANGE_BEGIN_BATTLE && method != FORM_CHANGE_END_BATTLE)) return; - for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++) + for (i = 0; formChanges[i].method != FORM_CHANGE_TERMINATOR; i++) { if (formChanges[i].method == method && formChanges[i].param2 From 57bdb683ece950a473b30230ccd9d4cafc86fed5 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 5 Nov 2022 23:27:40 -0300 Subject: [PATCH 17/37] DoBurmyFormChange handled by FORM_CHANGE_END_BATTLE_TERRAIN --- include/battle_util.h | 1 - include/constants/form_change_types.h | 14 ++++--- src/battle_main.c | 13 ++++-- src/battle_util.c | 40 ------------------- src/data/pokemon/form_change_table_pointers.h | 3 ++ src/data/pokemon/form_change_tables.h | 18 +++++++-- src/pokemon.c | 6 ++- 7 files changed, 42 insertions(+), 53 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index 18b31957b..ae5263b7f 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -177,7 +177,6 @@ void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast); bool32 CompareStat(u8 battlerId, u8 statId, u8 cmpTo, u8 cmpKind); bool32 TryRoomService(u8 battlerId); void BufferStatChange(u8 battlerId, u8 statId, u8 stringId); -void DoBurmyFormChange(u32 monId); bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef, bool32 checkTarget); u16 GetUsedHeldItem(u8 battler); bool32 IsBattlerWeatherAffected(u8 battlerId, u32 weatherFlags); diff --git a/include/constants/form_change_types.h b/include/constants/form_change_types.h index c6d4c6eae..8701a9497 100644 --- a/include/constants/form_change_types.h +++ b/include/constants/form_change_types.h @@ -53,9 +53,13 @@ // param3: a new move to replace it with, optional #define FORM_CHANGE_END_BATTLE 7 +// Form change that activates at the end of a battle based on the terrain if it participated in the battle and hasn't fainted. Takes priority over FORM_CHANGE_END_BATTLE. +// param1: battle terrain to check. +#define FORM_CHANGE_END_BATTLE_TERRAIN 8 + // Form change that activates when the Pokémon is switched out in battle. // - No parameters. -#define FORM_CHANGE_BATTLE_SWITCH 8 +#define FORM_CHANGE_BATTLE_SWITCH 9 // Form change that activates when the Pokémon's HP % passes a certain threshold. // param1: Ability to check. @@ -63,19 +67,19 @@ // - HP_HIGHER_THAN if the form triggers when the current HP is higher than the specified threshold. // - HP_LOWER_EQ_THAN if the form triggers when the current HP is lower or equal than the specified threshold. // param3: HP percentage threshold. -#define FORM_CHANGE_BATTLE_HP_PERCENT 9 +#define FORM_CHANGE_BATTLE_HP_PERCENT 10 // Form change that activates when the mon has the defined item. // If it's on the player's side, it also requires ITEM_MEGA_RING in the user's bag and for the player to trigger it by pressing START before selecting a move. // param1: item to hold. -#define FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM 10 +#define FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM 11 // Form change that activates when the mon has the defined move. // If it's on the player's side, it also requires ITEM_MEGA_RING in the user's bag and for the player to trigger it by pressing START before selecting a move. // param1: move to have. -#define FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE 11 +#define FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE 12 // Form change that activates automatically when entering battle with the specified item. // If the item is a Red Orb, it uses the Omega Symbol for the animation and icon. Otherwise, it defaults to the Alpha symbol. // param1: item to hold. -#define FORM_CHANGE_BATTLE_PRIMAL_REVERSION 12 +#define FORM_CHANGE_BATTLE_PRIMAL_REVERSION 13 diff --git a/src/battle_main.c b/src/battle_main.c index f396b9b0a..1aefd71b0 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5202,8 +5202,15 @@ static void HandleEndTurn_FinishBattle(void) #endif for (i = 0; i < PARTY_SIZE; i++) { - bool32 changedForm = TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_END_BATTLE); - DoBurmyFormChange(i); + bool32 changedForm = FALSE; + + // Appeared in battle and didn't faint + if ((gBattleStruct->appearedInBattle & gBitTable[i]) && GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) != 0) + changedForm = TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_END_BATTLE_TERRAIN); + + if (!changedForm) + changedForm = TryFormChange(i, B_SIDE_PLAYER, FORM_CHANGE_END_BATTLE); + // Clear original species field gBattleStruct->changedSpecies[i] = SPECIES_NONE; @@ -5215,7 +5222,7 @@ static void HandleEndTurn_FinishBattle(void) } // Clear battle mon species to avoid a bug on the next battle that causes // healthboxes loading incorrectly due to it trying to create a Mega Indicator - // if the previous battler would've had. + // if the previous battler would've had it. for (i = 0; i < MAX_BATTLERS_COUNT; i++) { gBattleMons[i].species = SPECIES_NONE; diff --git a/src/battle_util.c b/src/battle_util.c index eaf3f72e0..52a320200 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10414,46 +10414,6 @@ bool32 TryRoomService(u8 battlerId) } } -void DoBurmyFormChange(u32 monId) -{ - u16 newSpecies, currSpecies; - struct Pokemon *party = gPlayerParty; - - currSpecies = GetMonData(&party[monId], MON_DATA_SPECIES, NULL); - - if ((GET_BASE_SPECIES_ID(currSpecies) == SPECIES_BURMY) - && (gBattleStruct->appearedInBattle & gBitTable[monId]) // Burmy appeared in battle - && GetMonData(&party[monId], MON_DATA_HP, NULL) != 0) // Burmy isn't fainted - { - switch (gBattleTerrain) - { - case BATTLE_TERRAIN_GRASS: - case BATTLE_TERRAIN_LONG_GRASS: - case BATTLE_TERRAIN_POND: - case BATTLE_TERRAIN_MOUNTAIN: - case BATTLE_TERRAIN_PLAIN: - newSpecies = SPECIES_BURMY; - break; - case BATTLE_TERRAIN_CAVE: - case BATTLE_TERRAIN_SAND: - newSpecies = SPECIES_BURMY_SANDY_CLOAK; - break; - case BATTLE_TERRAIN_BUILDING: - newSpecies = SPECIES_BURMY_TRASH_CLOAK; - break; - default: // Don't change form if last battle was water-related - newSpecies = SPECIES_NONE; - break; - } - - if (newSpecies != SPECIES_NONE) - { - SetMonData(&party[monId], MON_DATA_SPECIES, &newSpecies); - CalculateMonStats(&party[monId]); - } - } -} - bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef, bool32 checkTarget) { #if B_PRANKSTER_DARK_TYPES >= GEN_7 diff --git a/src/data/pokemon/form_change_table_pointers.h b/src/data/pokemon/form_change_table_pointers.h index 06d5825a2..65e71b2cf 100644 --- a/src/data/pokemon/form_change_table_pointers.h +++ b/src/data/pokemon/form_change_table_pointers.h @@ -85,6 +85,9 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] = [SPECIES_RAYQUAZA] = sRayquazaFormChangeTable, [SPECIES_RAYQUAZA_MEGA] = sRayquazaFormChangeTable, #if P_GEN_4_POKEMON == TRUE + [SPECIES_BURMY] = sBurmyFormChangeTable, + [SPECIES_BURMY_SANDY_CLOAK] = sBurmyFormChangeTable, + [SPECIES_BURMY_TRASH_CLOAK] = sBurmyFormChangeTable, [SPECIES_LOPUNNY] = sLopunnyFormChangeTable, [SPECIES_LOPUNNY_MEGA] = sLopunnyFormChangeTable, [SPECIES_GARCHOMP] = sGarchompFormChangeTable, diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 6f963b599..7b8c4a6ce 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -279,13 +279,25 @@ static const struct FormChange sGroudonFormChangeTable[] = { }; static const struct FormChange sRayquazaFormChangeTable[] = { - {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE, SPECIES_RAYQUAZA_MEGA, MOVE_DRAGON_ASCENT}, - {FORM_CHANGE_FAINT, SPECIES_RAYQUAZA}, - {FORM_CHANGE_END_BATTLE, SPECIES_RAYQUAZA}, + {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE, SPECIES_RAYQUAZA_MEGA, MOVE_DRAGON_ASCENT}, + {FORM_CHANGE_FAINT, SPECIES_RAYQUAZA}, + {FORM_CHANGE_END_BATTLE, SPECIES_RAYQUAZA}, {FORM_CHANGE_TERMINATOR}, }; #if P_GEN_4_POKEMON == TRUE +static const struct FormChange sBurmyFormChangeTable[] = { + {FORM_CHANGE_END_BATTLE_TERRAIN, SPECIES_BURMY, BATTLE_TERRAIN_GRASS}, + {FORM_CHANGE_END_BATTLE_TERRAIN, SPECIES_BURMY, BATTLE_TERRAIN_LONG_GRASS}, + {FORM_CHANGE_END_BATTLE_TERRAIN, SPECIES_BURMY, BATTLE_TERRAIN_POND}, + {FORM_CHANGE_END_BATTLE_TERRAIN, SPECIES_BURMY, BATTLE_TERRAIN_MOUNTAIN}, + {FORM_CHANGE_END_BATTLE_TERRAIN, SPECIES_BURMY, BATTLE_TERRAIN_PLAIN}, + {FORM_CHANGE_END_BATTLE_TERRAIN, SPECIES_BURMY_SANDY_CLOAK, BATTLE_TERRAIN_CAVE}, + {FORM_CHANGE_END_BATTLE_TERRAIN, SPECIES_BURMY_SANDY_CLOAK, BATTLE_TERRAIN_SAND}, + {FORM_CHANGE_END_BATTLE_TERRAIN, SPECIES_BURMY_TRASH_CLOAK, BATTLE_TERRAIN_BUILDING}, + {FORM_CHANGE_TERMINATOR}, +}; + static const struct FormChange sLopunnyFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LOPUNNY_MEGA, ITEM_LOPUNNITE}, {FORM_CHANGE_FAINT, SPECIES_LOPUNNY}, diff --git a/src/pokemon.c b/src/pokemon.c index 1b41d666d..dc87126b9 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8538,7 +8538,11 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 case FORM_CHANGE_END_BATTLE: if (heldItem == formChanges[i].param1 || formChanges[i].param1 == ITEM_NONE) targetSpecies = formChanges[i].targetSpecies; - break; + break; + case FORM_CHANGE_END_BATTLE_TERRAIN: + if (gBattleTerrain == formChanges[i].param1) + targetSpecies = formChanges[i].targetSpecies; + break; case FORM_CHANGE_WITHDRAW: case FORM_CHANGE_FAINT: targetSpecies = formChanges[i].targetSpecies; From 0eccbdf980e09c4de4a11f63ea1cad2db7d9d9f7 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 6 Nov 2022 00:36:25 -0300 Subject: [PATCH 18/37] Primal Reversion at the beginning of a battle now happens in the switchin ability loop, making it happen by speed order. --- src/battle_main.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index 1aefd71b0..6abc19083 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3678,18 +3678,6 @@ static void TryDoEventsBeforeFirstTurn(void) } memset(gTotemBoosts, 0, sizeof(gTotemBoosts)); // erase all totem boosts just to be safe - // Primal Reversion - for (i = 0; i < gBattlersCount; i++) - { - if (GetBattlerHoldEffect(i, TRUE) == HOLD_EFFECT_PRIMAL_ORB - && GetBattleFormChangeTargetSpecies(i, FORM_CHANGE_BATTLE_PRIMAL_REVERSION) != SPECIES_NONE) - { - gBattlerAttacker = i; - BattleScriptExecute(BattleScript_PrimalReversion); - return; - } - } - // Check neutralizing gas if (AbilityBattleEffects(ABILITYEFFECT_NEUTRALIZINGGAS, 0, 0, 0, 0) != 0) return; @@ -3698,6 +3686,14 @@ static void TryDoEventsBeforeFirstTurn(void) while (gBattleStruct->switchInAbilitiesCounter < gBattlersCount) { gBattlerAttacker = gBattlerByTurnOrder[gBattleStruct->switchInAbilitiesCounter++]; + + // Primal Reversion + if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_PRIMAL_ORB + && GetBattleFormChangeTargetSpecies(gBattlerAttacker, FORM_CHANGE_BATTLE_PRIMAL_REVERSION) != SPECIES_NONE) + { + BattleScriptExecute(BattleScript_PrimalReversion); + return; + } if (AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gBattlerAttacker, 0, 0, 0) != 0) return; } From 62912f8caf852eb453fe07a1fb504123d1a50e2e Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 6 Nov 2022 16:01:07 -0300 Subject: [PATCH 19/37] Battle indicator now depends on species instead of held item - This is to avoid a situation where a user would plop a Primal Groudon and its indicator would become Alpha if it doesn't have a Red Orb. --- include/constants/form_change_types.h | 1 + src/battle_interface.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/constants/form_change_types.h b/include/constants/form_change_types.h index 8701a9497..b9d6c8942 100644 --- a/include/constants/form_change_types.h +++ b/include/constants/form_change_types.h @@ -81,5 +81,6 @@ // Form change that activates automatically when entering battle with the specified item. // If the item is a Red Orb, it uses the Omega Symbol for the animation and icon. Otherwise, it defaults to the Alpha symbol. +// The battle indicator icon is based on the species, with Primal Groudon's as Omega and otherwise being Alpha. // param1: item to hold. #define FORM_CHANGE_BATTLE_PRIMAL_REVERSION 13 diff --git a/src/battle_interface.c b/src/battle_interface.c index c3d97f137..f7882c15b 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -1560,12 +1560,12 @@ u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which) } else if (IsBattlerPrimalReverted(battlerId)) { - if (gBattleMons[battlerId].item == ITEM_RED_ORB) + if (gBattleMons[battlerId].species == SPECIES_GROUDON_PRIMAL) { LoadSpritePalette(&sSpritePalette_OmegaIndicator); LoadSpriteSheet(&sSpriteSheet_OmegaIndicator); } - else // ITEM_BLUE_ORB + else // SPECIES_KYOGRE_PRIMAL { LoadSpritePalette(&sSpritePalette_AlphaIndicator); LoadSpriteSheet(&sSpriteSheet_AlphaIndicator); @@ -1589,9 +1589,9 @@ u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which) } else if (IsBattlerPrimalReverted(battlerId)) { - if (gBattleMons[battlerId].item == ITEM_RED_ORB) + if (gBattleMons[battlerId].species == SPECIES_GROUDON_PRIMAL) spriteId = CreateSpriteAtEnd(&sSpriteTemplate_OmegaIndicator, x, y, 0); - else // ITEM_BLUE_ORB + else // SPECIES_KYOGRE_PRIMAL spriteId = CreateSpriteAtEnd(&sSpriteTemplate_AlphaIndicator, x, y, 0); } From 2ef2134be1a04e79bc09dfb35dd0ceda59ff4f2b Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 6 Nov 2022 17:12:34 -0300 Subject: [PATCH 20/37] Moved Hunger Switch to form change table. --- data/battle_scripts_1.s | 1 + include/constants/form_change_types.h | 4 ++++ src/battle_ai_main.c | 4 ---- src/battle_util.c | 19 ++++++------------- src/data/pokemon/form_change_tables.h | 8 +++++--- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 472b1c9d1..34a1bead8 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7525,6 +7525,7 @@ BattleScript_AttackerFormChangeEnd3:: BattleScript_AttackerFormChangeEnd3NoPopup:: call BattleScript_AttackerFormChangeNoPopup + end3 BattleScript_AttackerFormChangeMoveEffect:: waitmessage 1 diff --git a/include/constants/form_change_types.h b/include/constants/form_change_types.h index b9d6c8942..f6a858f97 100644 --- a/include/constants/form_change_types.h +++ b/include/constants/form_change_types.h @@ -84,3 +84,7 @@ // The battle indicator icon is based on the species, with Primal Groudon's as Omega and otherwise being Alpha. // param1: item to hold. #define FORM_CHANGE_BATTLE_PRIMAL_REVERSION 13 + +// Form change that activates automatically when the turn ends. +// param1: ability to check. +#define FORM_CHANGE_BATTLE_TURN_END 14 diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 70818a29c..25e06806b 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -3817,7 +3817,6 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) ProtectChecks(battlerAtk, battlerDef, move, predictedMove, &score); break; case MOVE_KINGS_SHIELD: - #if (defined SPECIES_AEGISLASH && defined SPECIES_AEGISLASH_BLADE) if (AI_DATA->abilities[battlerAtk] == ABILITY_STANCE_CHANGE //Special logic for Aegislash && gBattleMons[battlerAtk].species == SPECIES_AEGISLASH_BLADE && !IsBattlerIncapacitated(battlerDef, AI_DATA->abilities[battlerDef])) @@ -3825,7 +3824,6 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) score += 3; break; } - #endif //fallthrough default: // protect ProtectChecks(battlerAtk, battlerDef, move, predictedMove, &score); @@ -4484,7 +4482,6 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) score += 3; break; case EFFECT_RELIC_SONG: - #if (defined SPECIES_MELOETTA && defined SPECIES_MELOETTA_PIROUETTE) if (!(gBattleMons[battlerAtk].status2 & STATUS2_TRANSFORMED)) // Don't try to change form if it's transformed. { if (gBattleMons[battlerAtk].species == SPECIES_MELOETTA && gBattleMons[battlerDef].defense < gBattleMons[battlerDef].spDefense) @@ -4492,7 +4489,6 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) else if (gBattleMons[battlerAtk].species == SPECIES_MELOETTA_PIROUETTE && gBattleMons[battlerDef].spDefense < gBattleMons[battlerDef].defense) score += 3; // Change to Aria if can do more damage } - #endif break; case EFFECT_ELECTRIC_TERRAIN: case EFFECT_MISTY_TERRAIN: diff --git a/src/battle_util.c b/src/battle_util.c index 52a320200..5629acc95 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5019,18 +5019,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITY_HUNGER_SWITCH: - if (!(gBattleMons[battler].status2 & STATUS2_TRANSFORMED)) + if (TryBattleFormChange(battler, FORM_CHANGE_BATTLE_TURN_END)) { - if (gBattleMons[battler].species == SPECIES_MORPEKO) - { - gBattleMons[battler].species = SPECIES_MORPEKO_HANGRY; - BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeEnd3NoPopup); - } - else if (gBattleMons[battler].species == SPECIES_MORPEKO_HANGRY) - { - gBattleMons[battler].species = SPECIES_MORPEKO; - BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeEnd3NoPopup); - } + BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeEnd3NoPopup); effect++; } break; @@ -9788,7 +9779,6 @@ u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method) targetSpecies = formChanges[i].targetSpecies; break; case FORM_CHANGE_BATTLE_HP_PERCENT: - { if (formChanges[i].param1 == GetBattlerAbility(battlerId)) { // We multiply by 100 to make sure that integer division doesn't mess with the health check. @@ -9806,7 +9796,10 @@ u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method) } } break; - } + case FORM_CHANGE_BATTLE_TURN_END: + if (formChanges[i].param1 == GetBattlerAbility(battlerId)) + targetSpecies = formChanges[i].targetSpecies; + break; } } } diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 7b8c4a6ce..9f01f8320 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -604,9 +604,11 @@ static const struct FormChange sCramorantFormChangeTable[] = { }; static const struct FormChange sMorpekoFormChangeTable[] = { - {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MORPEKO}, - {FORM_CHANGE_FAINT, SPECIES_MORPEKO}, - {FORM_CHANGE_END_BATTLE, SPECIES_MORPEKO}, + {FORM_CHANGE_BATTLE_TURN_END, SPECIES_MORPEKO_HANGRY, ABILITY_HUNGER_SWITCH}, + {FORM_CHANGE_BATTLE_TURN_END, SPECIES_MORPEKO , ABILITY_HUNGER_SWITCH}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MORPEKO}, + {FORM_CHANGE_FAINT, SPECIES_MORPEKO}, + {FORM_CHANGE_END_BATTLE, SPECIES_MORPEKO}, {FORM_CHANGE_TERMINATOR}, }; From 034ba7d5d2a345c27de32019b869319a9dbed94a Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Mon, 26 Dec 2022 08:59:37 -0300 Subject: [PATCH 21/37] Fixed usage of gBattleStruct->changedSpecies so its only used by player's party --- src/battle_util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index b3b16f255..6a31bc9e2 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -9796,8 +9796,8 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method) targetSpecies = GetBattleFormChangeTargetSpecies(battlerId, method); if (targetSpecies != SPECIES_NONE) { - // Saves the original species on the first form change. - if (gBattleStruct->changedSpecies[monId] == SPECIES_NONE) + // Saves the original species on the first form change for the player. + if (side == B_SIDE_PLAYER && gBattleStruct->changedSpecies[monId] == SPECIES_NONE) gBattleStruct->changedSpecies[monId] = gBattleMons[battlerId].species; TryToSetBattleFormChangeMoves(&party[monId], method); @@ -9810,8 +9810,8 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method) targetSpecies = GetFormChangeTargetSpecies(&party[monId], method, 0); if (targetSpecies != SPECIES_NONE) { - // Saves the original species on the first form change. - if (gBattleStruct->changedSpecies[monId] == SPECIES_NONE) + // Saves the original species on the first form change for the player. + if (side == B_SIDE_PLAYER && gBattleStruct->changedSpecies[monId] == SPECIES_NONE) gBattleStruct->changedSpecies[monId] = targetSpecies; TryToSetBattleFormChangeMoves(&party[monId], method); From b5b7631be75619384f889147b964f08b694c5238 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Mon, 26 Dec 2022 09:14:28 -0300 Subject: [PATCH 22/37] Added guards to form_change_types.h --- include/constants/form_change_types.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/constants/form_change_types.h b/include/constants/form_change_types.h index f6a858f97..4e60904aa 100644 --- a/include/constants/form_change_types.h +++ b/include/constants/form_change_types.h @@ -1,3 +1,5 @@ +#ifndef GUARD_CONSTANTS_FORM_CHANGE_TYPES_H +#define GUARD_CONSTANTS_FORM_CHANGE_TYPES_H // FORM_CHANGE_BATTLE_HP_PERCENT param2 arguments #define HP_HIGHER_THAN 1 @@ -88,3 +90,5 @@ // Form change that activates automatically when the turn ends. // param1: ability to check. #define FORM_CHANGE_BATTLE_TURN_END 14 + +#endif // GUARD_CONSTANTS_FORM_CHANGE_TYPES_H From 46bdd21e7a9c96f4dbad84f775daef920a4d58ca Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 7 Mar 2023 11:39:47 -0300 Subject: [PATCH 23/37] Cleaned up stray comment --- src/battle_script_commands.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e8b23d43f..360cef125 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8670,7 +8670,6 @@ static bool32 CourtChangeSwapSideStatuses(void) SWAP(sideTimerPlayer->stickyWebBattlerSide, sideTimerOpp->stickyWebBattlerSide, temp); } -//cmd->case_, gActiveBattler, TRUE static void HandleScriptMegaPrimal(u32 caseId, u32 battlerId, bool32 isMega) { struct Pokemon *mon = GetBattlerPartyData(battlerId); From 7ce68994ec3f05c305f1800c490b429b3923d4f4 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 12 Mar 2023 02:32:09 -0300 Subject: [PATCH 24/37] Made Mega Evolution properly use TryBattleFormChange --- data/battle_scripts_1.s | 3 +- src/battle_script_commands.c | 20 ++---- src/battle_util.c | 63 +++++++++++------- src/data/pokemon/form_change_tables.h | 94 --------------------------- src/pokemon.c | 1 - 5 files changed, 45 insertions(+), 136 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 8bba93286..e8b45cc3d 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7833,10 +7833,9 @@ BattleScript_MegaEvolutionAfeterString: waitmessage B_WAIT_TIME_LONG setbyte gIsCriticalHit, 0 handlemegaevo BS_ATTACKER, 0 - handlemegaevo BS_ATTACKER, 1 playanimation BS_ATTACKER, B_ANIM_MEGA_EVOLUTION waitanimation - handlemegaevo BS_ATTACKER, 2 + handlemegaevo BS_ATTACKER, 1 printstring STRINGID_MEGAEVOEVOLVED waitmessage B_WAIT_TIME_LONG switchinabilities BS_ATTACKER diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 360cef125..486772257 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8679,37 +8679,27 @@ static void HandleScriptMegaPrimal(u32 caseId, u32 battlerId, bool32 isMega) // Change species. if (caseId == 0) { - u16 newSpecies; if (isMega) { - //Checks regular Mega Evolution - newSpecies = GetBattleFormChangeTargetSpecies(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM); - //Checks Wish Mega Evolution - if (newSpecies == SPECIES_NONE) - newSpecies = GetBattleFormChangeTargetSpecies(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE); + if (!TryBattleFormChange(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM)) + TryBattleFormChange(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE); } else - newSpecies = GetBattleFormChangeTargetSpecies(battlerId, FORM_CHANGE_BATTLE_PRIMAL_REVERSION); + TryBattleFormChange(battlerId, FORM_CHANGE_BATTLE_PRIMAL_REVERSION); - gBattleMons[battlerId].species = newSpecies; PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[battlerId].species); BtlController_EmitSetMonData(BUFFER_A, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[battlerId]], sizeof(gBattleMons[battlerId].species), &gBattleMons[battlerId].species); MarkBattlerForControllerExec(battlerId); } - // Change stats. - else if (caseId == 1) - { - RecalcBattlerStats(battlerId, mon); - if (isMega) - gBattleStruct->mega.alreadyEvolved[position] = TRUE; - } // Update healthbox and elevation and play cry. else { UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId], mon, HEALTHBOX_ALL); if (side == B_SIDE_OPPONENT) SetBattlerShadowSpriteCallback(battlerId, gBattleMons[battlerId].species); + if (isMega) + gBattleStruct->mega.alreadyEvolved[position] = TRUE; } } diff --git a/src/battle_util.c b/src/battle_util.c index 9a8954fd5..aba70e377 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10071,11 +10071,17 @@ bool32 CanMegaEvolve(u8 battlerId) bool32 IsBattlerMegaEvolved(u8 battlerId) { + // While Transform does copy stats and visuals, it shouldn't be counted as true Mega Evolution. + if (gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED) + return FALSE; return (gSpeciesInfo[gBattleMons[battlerId].species].flags & SPECIES_FLAG_MEGA_EVOLUTION); } bool32 IsBattlerPrimalReverted(u8 battlerId) { + // While Transform does copy stats and visuals, it shouldn't be counted as true Primal Revesion. + if (gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED) + return FALSE; return (gSpeciesInfo[gBattleMons[battlerId].species].flags & SPECIES_FLAG_PRIMAL_REVERSION); } @@ -10145,6 +10151,18 @@ u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method) return targetSpecies; } +bool32 CanBattlerFormChange(u8 battlerId, u16 method) +{ + // Can't change form if transformed. + if (gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED) + return FALSE; + // Mega Evolved Pokémon should always revert to normal upon fainting or ending the battle. + if (IsBattlerMegaEvolved(battlerId) + && (method == FORM_CHANGE_FAINT || method == FORM_CHANGE_END_BATTLE)) + return TRUE; + return DoesSpeciesHaveFormChangeMethod(gBattleMons[battlerId].species, method); +} + bool32 TryBattleFormChange(u8 battlerId, u16 method) { u8 monId = gBattlerPartyIndexes[battlerId]; @@ -10152,14 +10170,12 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method) struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; u16 targetSpecies; - // Can't change form if transformed. - if (gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED) - return FALSE; - - if (!DoesSpeciesHaveFormChangeMethod(gBattleMons[battlerId].species, method)) + if (!CanBattlerFormChange(battlerId, method)) return FALSE; targetSpecies = GetBattleFormChangeTargetSpecies(battlerId, method); + if (targetSpecies == SPECIES_NONE) + targetSpecies = GetFormChangeTargetSpecies(&party[monId], method, 0); if (targetSpecies != SPECIES_NONE) { // Saves the original species on the first form change for the player. @@ -10172,27 +10188,26 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method) RecalcBattlerStats(battlerId, &party[monId]); return TRUE; } - - targetSpecies = GetFormChangeTargetSpecies(&party[monId], method, 0); - if (targetSpecies != SPECIES_NONE) + else if (gBattleStruct->changedSpecies[monId] != SPECIES_NONE) { - // Saves the original species on the first form change for the player. - if (side == B_SIDE_PLAYER && gBattleStruct->changedSpecies[monId] == SPECIES_NONE) - gBattleStruct->changedSpecies[monId] = targetSpecies; + bool8 restoreSpecies = FALSE; - TryToSetBattleFormChangeMoves(&party[monId], method); - SetMonData(&party[monId], MON_DATA_SPECIES, &targetSpecies); - gBattleMons[battlerId].species = targetSpecies; - RecalcBattlerStats(battlerId, &party[monId]); - return TRUE; - } - else if ((method == FORM_CHANGE_END_BATTLE || method == FORM_CHANGE_FAINT) - && gBattleStruct->changedSpecies[monId] != SPECIES_NONE) - { - TryToSetBattleFormChangeMoves(&party[monId], method); - SetMonData(&party[monId], MON_DATA_SPECIES, &gBattleStruct->changedSpecies[monId]); - RecalcBattlerStats(battlerId, &party[monId]); - return TRUE; + // Mega Evolved Pokémon should always revert to normal upon fainting or ending the battle, so no need to add it to the form change tables. + if (IsBattlerMegaEvolved(battlerId) && (method == FORM_CHANGE_FAINT || method == FORM_CHANGE_END_BATTLE)) + restoreSpecies = TRUE; + + // Unlike Megas, Primal Reversion isn't canceled on fainting. + else if (IsBattlerPrimalReverted(battlerId) && (method == FORM_CHANGE_END_BATTLE)) + restoreSpecies = TRUE; + + if (restoreSpecies) + { + // Reverts the original species + TryToSetBattleFormChangeMoves(&party[monId], method); + SetMonData(&party[monId], MON_DATA_SPECIES, &gBattleStruct->changedSpecies[monId]); + RecalcBattlerStats(battlerId, &party[monId]); + return TRUE; + } } return FALSE; diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index 5050b488b..9787d2a9b 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -1,287 +1,207 @@ static const struct FormChange sVenusaurFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_VENUSAUR_MEGA, ITEM_VENUSAURITE}, - {FORM_CHANGE_FAINT, SPECIES_VENUSAUR}, - {FORM_CHANGE_END_BATTLE, SPECIES_VENUSAUR}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sCharizardFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_CHARIZARD_MEGA_X, ITEM_CHARIZARDITE_X}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_CHARIZARD_MEGA_Y, ITEM_CHARIZARDITE_Y}, - {FORM_CHANGE_FAINT, SPECIES_CHARIZARD}, - {FORM_CHANGE_END_BATTLE, SPECIES_CHARIZARD}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sBlastoiseFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BLASTOISE_MEGA, ITEM_BLASTOISINITE}, - {FORM_CHANGE_FAINT, SPECIES_BLASTOISE}, - {FORM_CHANGE_END_BATTLE, SPECIES_BLASTOISE}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sBeedrillFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BEEDRILL_MEGA, ITEM_BEEDRILLITE}, - {FORM_CHANGE_FAINT, SPECIES_BEEDRILL}, - {FORM_CHANGE_END_BATTLE, SPECIES_BEEDRILL}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sPidgeotFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_PIDGEOT_MEGA, ITEM_PIDGEOTITE}, - {FORM_CHANGE_FAINT, SPECIES_PIDGEOT}, - {FORM_CHANGE_END_BATTLE, SPECIES_PIDGEOT}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAlakazamFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ALAKAZAM_MEGA, ITEM_ALAKAZITE}, - {FORM_CHANGE_FAINT, SPECIES_ALAKAZAM}, - {FORM_CHANGE_END_BATTLE, SPECIES_ALAKAZAM}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSlowbroFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SLOWBRO_MEGA, ITEM_SLOWBRONITE}, - {FORM_CHANGE_FAINT, SPECIES_SLOWBRO}, - {FORM_CHANGE_END_BATTLE, SPECIES_SLOWBRO}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGengarFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GENGAR_MEGA, ITEM_GENGARITE}, - {FORM_CHANGE_FAINT, SPECIES_GENGAR}, - {FORM_CHANGE_END_BATTLE, SPECIES_GENGAR}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sKangaskhanFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_KANGASKHAN_MEGA, ITEM_KANGASKHANITE}, - {FORM_CHANGE_FAINT, SPECIES_KANGASKHAN}, - {FORM_CHANGE_END_BATTLE, SPECIES_KANGASKHAN}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sPinsirFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_PINSIR_MEGA, ITEM_PINSIRITE}, - {FORM_CHANGE_FAINT, SPECIES_PINSIR}, - {FORM_CHANGE_END_BATTLE, SPECIES_PINSIR}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGyaradosFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GYARADOS_MEGA, ITEM_GYARADOSITE}, - {FORM_CHANGE_FAINT, SPECIES_GYARADOS}, - {FORM_CHANGE_END_BATTLE, SPECIES_GYARADOS}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAerodactylFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AERODACTYL_MEGA, ITEM_AERODACTYLITE}, - {FORM_CHANGE_FAINT, SPECIES_AERODACTYL}, - {FORM_CHANGE_END_BATTLE, SPECIES_AERODACTYL}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMewtwoFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MEWTWO_MEGA_X, ITEM_MEWTWONITE_X}, {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MEWTWO_MEGA_Y, ITEM_MEWTWONITE_Y}, - {FORM_CHANGE_FAINT, SPECIES_MEWTWO}, - {FORM_CHANGE_END_BATTLE, SPECIES_MEWTWO}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAmpharosFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AMPHAROS_MEGA, ITEM_AMPHAROSITE}, - {FORM_CHANGE_FAINT, SPECIES_AMPHAROS}, - {FORM_CHANGE_END_BATTLE, SPECIES_AMPHAROS}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSteelixFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_STEELIX_MEGA, ITEM_STEELIXITE}, - {FORM_CHANGE_FAINT, SPECIES_STEELIX}, - {FORM_CHANGE_END_BATTLE, SPECIES_STEELIX}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sScizorFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SCIZOR_MEGA, ITEM_SCIZORITE}, - {FORM_CHANGE_FAINT, SPECIES_SCIZOR}, - {FORM_CHANGE_END_BATTLE, SPECIES_SCIZOR}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sHeracrossFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_HERACROSS_MEGA, ITEM_HERACRONITE}, - {FORM_CHANGE_FAINT, SPECIES_HERACROSS}, - {FORM_CHANGE_END_BATTLE, SPECIES_HERACROSS}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sHoundoomFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_HOUNDOOM_MEGA, ITEM_HOUNDOOMINITE}, - {FORM_CHANGE_FAINT, SPECIES_HOUNDOOM}, - {FORM_CHANGE_END_BATTLE, SPECIES_HOUNDOOM}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sTyranitarFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_TYRANITAR_MEGA, ITEM_TYRANITARITE}, - {FORM_CHANGE_FAINT, SPECIES_TYRANITAR}, - {FORM_CHANGE_END_BATTLE, SPECIES_TYRANITAR}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSceptileFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SCEPTILE_MEGA, ITEM_SCEPTILITE}, - {FORM_CHANGE_FAINT, SPECIES_SCEPTILE}, - {FORM_CHANGE_END_BATTLE, SPECIES_SCEPTILE}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sBlazikenFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BLAZIKEN_MEGA, ITEM_BLAZIKENITE}, - {FORM_CHANGE_FAINT, SPECIES_BLAZIKEN}, - {FORM_CHANGE_END_BATTLE, SPECIES_BLAZIKEN}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSwampertFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SWAMPERT_MEGA, ITEM_SWAMPERTITE}, - {FORM_CHANGE_FAINT, SPECIES_SWAMPERT}, - {FORM_CHANGE_END_BATTLE, SPECIES_SWAMPERT}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSableyeFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SABLEYE_MEGA, ITEM_SABLENITE}, - {FORM_CHANGE_FAINT, SPECIES_SABLEYE}, - {FORM_CHANGE_END_BATTLE, SPECIES_SABLEYE}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSharpedoFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SHARPEDO_MEGA, ITEM_SHARPEDONITE}, - {FORM_CHANGE_FAINT, SPECIES_SHARPEDO}, - {FORM_CHANGE_END_BATTLE, SPECIES_SHARPEDO}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sManectricFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MANECTRIC_MEGA, ITEM_MANECTITE}, - {FORM_CHANGE_FAINT, SPECIES_MANECTRIC}, - {FORM_CHANGE_END_BATTLE, SPECIES_MANECTRIC}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sCameruptFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_CAMERUPT_MEGA, ITEM_CAMERUPTITE}, - {FORM_CHANGE_FAINT, SPECIES_CAMERUPT}, - {FORM_CHANGE_END_BATTLE, SPECIES_CAMERUPT}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGlalieFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GLALIE_MEGA, ITEM_GLALITITE}, - {FORM_CHANGE_FAINT, SPECIES_GLALIE}, - {FORM_CHANGE_END_BATTLE, SPECIES_GLALIE}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMawileFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MAWILE_MEGA, ITEM_MAWILITE}, - {FORM_CHANGE_FAINT, SPECIES_MAWILE}, - {FORM_CHANGE_END_BATTLE, SPECIES_MAWILE}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMedichamFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_MEDICHAM_MEGA, ITEM_MEDICHAMITE}, - {FORM_CHANGE_FAINT, SPECIES_MEDICHAM}, - {FORM_CHANGE_END_BATTLE, SPECIES_MEDICHAM}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAltariaFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ALTARIA_MEGA, ITEM_ALTARIANITE}, - {FORM_CHANGE_FAINT, SPECIES_ALTARIA}, - {FORM_CHANGE_END_BATTLE, SPECIES_ALTARIA}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAbsolFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ABSOL_MEGA, ITEM_ABSOLITE}, - {FORM_CHANGE_FAINT, SPECIES_ABSOL}, - {FORM_CHANGE_END_BATTLE, SPECIES_ABSOL}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sBanetteFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BANETTE_MEGA, ITEM_BANETTITE}, - {FORM_CHANGE_FAINT, SPECIES_BANETTE}, - {FORM_CHANGE_END_BATTLE, SPECIES_BANETTE}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAggronFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AGGRON_MEGA, ITEM_AGGRONITE}, - {FORM_CHANGE_FAINT, SPECIES_AGGRON}, - {FORM_CHANGE_END_BATTLE, SPECIES_AGGRON}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGardevoirFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GARDEVOIR_MEGA, ITEM_GARDEVOIRITE}, - {FORM_CHANGE_FAINT, SPECIES_GARDEVOIR}, - {FORM_CHANGE_END_BATTLE, SPECIES_GARDEVOIR}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sSalamenceFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_SALAMENCE_MEGA, ITEM_SALAMENCITE}, - {FORM_CHANGE_FAINT, SPECIES_SALAMENCE}, - {FORM_CHANGE_END_BATTLE, SPECIES_SALAMENCE}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sMetagrossFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_METAGROSS_MEGA, ITEM_METAGROSSITE}, - {FORM_CHANGE_FAINT, SPECIES_METAGROSS}, - {FORM_CHANGE_END_BATTLE, SPECIES_METAGROSS}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sLatiasFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LATIAS_MEGA, ITEM_LATIASITE}, - {FORM_CHANGE_FAINT, SPECIES_LATIAS}, - {FORM_CHANGE_END_BATTLE, SPECIES_LATIAS}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sLatiosFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LATIOS_MEGA, ITEM_LATIOSITE}, - {FORM_CHANGE_FAINT, SPECIES_LATIOS}, - {FORM_CHANGE_END_BATTLE, SPECIES_LATIOS}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sKyogreFormChangeTable[] = { {FORM_CHANGE_BATTLE_PRIMAL_REVERSION, SPECIES_KYOGRE_PRIMAL, ITEM_BLUE_ORB}, - {FORM_CHANGE_END_BATTLE, SPECIES_KYOGRE}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGroudonFormChangeTable[] = { {FORM_CHANGE_BATTLE_PRIMAL_REVERSION, SPECIES_GROUDON_PRIMAL, ITEM_RED_ORB}, - {FORM_CHANGE_END_BATTLE, SPECIES_GROUDON}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sRayquazaFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE, SPECIES_RAYQUAZA_MEGA, MOVE_DRAGON_ASCENT}, - {FORM_CHANGE_FAINT, SPECIES_RAYQUAZA}, - {FORM_CHANGE_END_BATTLE, SPECIES_RAYQUAZA}, {FORM_CHANGE_TERMINATOR}, }; @@ -300,36 +220,26 @@ static const struct FormChange sBurmyFormChangeTable[] = { static const struct FormChange sLopunnyFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LOPUNNY_MEGA, ITEM_LOPUNNITE}, - {FORM_CHANGE_FAINT, SPECIES_LOPUNNY}, - {FORM_CHANGE_END_BATTLE, SPECIES_LOPUNNY}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGarchompFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GARCHOMP_MEGA, ITEM_GARCHOMPITE}, - {FORM_CHANGE_FAINT, SPECIES_GARCHOMP}, - {FORM_CHANGE_END_BATTLE, SPECIES_GARCHOMP}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sLucarioFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LUCARIO_MEGA, ITEM_LUCARIONITE}, - {FORM_CHANGE_FAINT, SPECIES_LUCARIO}, - {FORM_CHANGE_END_BATTLE, SPECIES_LUCARIO}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sAbomasnowFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_ABOMASNOW_MEGA, ITEM_ABOMASITE}, - {FORM_CHANGE_FAINT, SPECIES_ABOMASNOW}, - {FORM_CHANGE_END_BATTLE, SPECIES_ABOMASNOW}, {FORM_CHANGE_TERMINATOR}, }; static const struct FormChange sGalladeFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_GALLADE_MEGA, ITEM_GALLADITE}, - {FORM_CHANGE_FAINT, SPECIES_GALLADE}, - {FORM_CHANGE_END_BATTLE, SPECIES_GALLADE}, {FORM_CHANGE_TERMINATOR}, }; @@ -388,8 +298,6 @@ static const struct FormChange sArceusFormChangeTable[] = { #if P_GEN_5_POKEMON == TRUE static const struct FormChange sAudinoFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_AUDINO_MEGA, ITEM_AUDINITE}, - {FORM_CHANGE_FAINT, SPECIES_AUDINO}, - {FORM_CHANGE_END_BATTLE, SPECIES_AUDINO}, {FORM_CHANGE_TERMINATOR}, }; @@ -478,8 +386,6 @@ static const struct FormChange sZygardePowerConstructFormChangeTable[] = { static const struct FormChange sDiancieFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_DIANCIE_MEGA, ITEM_DIANCITE}, - {FORM_CHANGE_FAINT, SPECIES_DIANCIE}, - {FORM_CHANGE_END_BATTLE, SPECIES_DIANCIE}, {FORM_CHANGE_TERMINATOR}, }; diff --git a/src/pokemon.c b/src/pokemon.c index f01e72dcd..e11014120 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8659,7 +8659,6 @@ bool32 ShouldShowFemaleDifferences(u16 species, u32 personality) return (gSpeciesInfo[species].flags & SPECIES_FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE; } -// Returns species that it transformed into. If it didn't, returns SPECIES_NONE. bool32 TryFormChange(u32 monId, u32 side, u16 method) { struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; From c46e70ca8215831038c8312baf7caf3a29f323dd Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 12 Mar 2023 02:38:27 -0300 Subject: [PATCH 25/37] Forgot about Primal Reversion --- src/battle_util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index aba70e377..f4aa344b5 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10157,8 +10157,9 @@ bool32 CanBattlerFormChange(u8 battlerId, u16 method) if (gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED) return FALSE; // Mega Evolved Pokémon should always revert to normal upon fainting or ending the battle. - if (IsBattlerMegaEvolved(battlerId) - && (method == FORM_CHANGE_FAINT || method == FORM_CHANGE_END_BATTLE)) + if (IsBattlerMegaEvolved(battlerId) && (method == FORM_CHANGE_FAINT || method == FORM_CHANGE_END_BATTLE)) + return TRUE; + else if (IsBattlerPrimalReverted(battlerId) && (method == FORM_CHANGE_END_BATTLE)) return TRUE; return DoesSpeciesHaveFormChangeMethod(gBattleMons[battlerId].species, method); } From a101476d5187243b1d9c7a22d44d9fc60bbd7481 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 12 Mar 2023 17:01:53 -0300 Subject: [PATCH 26/37] Hunger Switch test --- test/ability_hunger_switch.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/ability_hunger_switch.c diff --git a/test/ability_hunger_switch.c b/test/ability_hunger_switch.c new file mode 100644 index 000000000..8ae313929 --- /dev/null +++ b/test/ability_hunger_switch.c @@ -0,0 +1,25 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Hunger Switch switches Morpeko's forms at the end of the turn") +{ + u16 species; + PARAMETRIZE { species = SPECIES_MORPEKO; } + PARAMETRIZE { species = SPECIES_MORPEKO_HANGRY; } + GIVEN { + ASSUME(P_GEN_8_POKEMON == TRUE); + PLAYER(species) { Moves(MOVE_CELEBRATE); Speed(2); }; + OPPONENT(SPECIES_WOBBUFFET) { Moves(MOVE_CELEBRATE); Speed(1); }; + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE); } + } SCENE { + MESSAGE("Morpeko used Celebrate!"); + MESSAGE("Foe Wobbuffet used Celebrate!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + } THEN { + if (species == SPECIES_MORPEKO) + EXPECT_EQ(player->species, SPECIES_MORPEKO_HANGRY); + else + EXPECT_EQ(player->species, SPECIES_MORPEKO); + } +} From 0dfb60f2e462f2980cab20697a46db8fa3102c47 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 14 Mar 2023 11:07:26 -0300 Subject: [PATCH 27/37] Removed uneeded parameters --- test/ability_hunger_switch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/ability_hunger_switch.c b/test/ability_hunger_switch.c index 8ae313929..9250ae85a 100644 --- a/test/ability_hunger_switch.c +++ b/test/ability_hunger_switch.c @@ -8,8 +8,8 @@ SINGLE_BATTLE_TEST("Hunger Switch switches Morpeko's forms at the end of the tur PARAMETRIZE { species = SPECIES_MORPEKO_HANGRY; } GIVEN { ASSUME(P_GEN_8_POKEMON == TRUE); - PLAYER(species) { Moves(MOVE_CELEBRATE); Speed(2); }; - OPPONENT(SPECIES_WOBBUFFET) { Moves(MOVE_CELEBRATE); Speed(1); }; + PLAYER(species) { Speed(2); }; + OPPONENT(SPECIES_WOBBUFFET) { Speed(1); }; } WHEN { TURN { MOVE(player, MOVE_CELEBRATE); } } SCENE { From bef5d98b88cef4138fe83adad0b572f0893f6661 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 18 Mar 2023 09:47:54 -0300 Subject: [PATCH 28/37] =?UTF-8?q?Fixed=20Pok=C3=A9mon=20fainting=20in=20th?= =?UTF-8?q?e=20Overworld=20that=20don't=20have=20that=20specific=20form=20?= =?UTF-8?q?change=20entry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pokemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pokemon.c b/src/pokemon.c index e11014120..62e1891ab 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8670,7 +8670,7 @@ bool32 TryFormChange(u32 monId, u32 side, u16 method) targetSpecies = GetFormChangeTargetSpecies(&party[monId], method, 0); - if (targetSpecies == SPECIES_NONE) + if (targetSpecies == SPECIES_NONE && gBattleStruct != NULL) targetSpecies = gBattleStruct->changedSpecies[monId]; if (targetSpecies != SPECIES_NONE) From 168ed1cc55468863107edda6af375284a7cd133a Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 22 Mar 2023 07:33:13 -0300 Subject: [PATCH 29/37] Xerneas/Zacian/Zamazenta form change tests --- test/form_change.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 test/form_change.c diff --git a/test/form_change.c b/test/form_change.c new file mode 100644 index 000000000..8d761bb12 --- /dev/null +++ b/test/form_change.c @@ -0,0 +1,81 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Xerneas changes into Active Form upon battle start") +{ + GIVEN { + ASSUME(P_GEN_6_POKEMON == TRUE); + PLAYER(SPECIES_XERNEAS); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE); } + } THEN { + EXPECT_EQ(player->species, SPECIES_XERNEAS_ACTIVE); + } +} + +SINGLE_BATTLE_TEST("Zacian changes into its Crowned Form when holding the Rusted Sword upon battle start") +{ + u16 item; + PARAMETRIZE { item = ITEM_NONE; } + PARAMETRIZE { item = ITEM_RUSTED_SWORD; } + GIVEN { + ASSUME(P_GEN_8_POKEMON == TRUE); + PLAYER(SPECIES_ZACIAN) { Item(item); }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE); } + } THEN { + if (item == ITEM_NONE) + EXPECT_EQ(player->species, SPECIES_ZACIAN); + else + EXPECT_EQ(player->species, SPECIES_ZACIAN_CROWNED_SWORD); + } +} + +SINGLE_BATTLE_TEST("Zacian's Iron Head becomes Behemoth Blade upon form change") +{ + GIVEN { + ASSUME(P_GEN_8_POKEMON == TRUE); + PLAYER(SPECIES_ZACIAN) { Item(ITEM_RUSTED_SWORD); Moves(MOVE_IRON_HEAD, MOVE_CELEBRATE); }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE); } + } THEN { + ASSUME(player->species == SPECIES_ZACIAN_CROWNED_SWORD); // Assumes form change worked. + EXPECT_EQ(player->moves[0], MOVE_BEHEMOTH_BLADE); + } +} + +SINGLE_BATTLE_TEST("Zamazenta changes into its Crowned Form when holding the Rusted Shield upon battle start") +{ + u16 item; + PARAMETRIZE { item = ITEM_NONE; } + PARAMETRIZE { item = ITEM_RUSTED_SHIELD; } + GIVEN { + ASSUME(P_GEN_8_POKEMON == TRUE); + PLAYER(SPECIES_ZAMAZENTA) { Item(item); }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE); } + } THEN { + if (item == ITEM_NONE) + EXPECT_EQ(player->species, SPECIES_ZAMAZENTA); + else + EXPECT_EQ(player->species, SPECIES_ZAMAZENTA_CROWNED_SHIELD); + } +} + +SINGLE_BATTLE_TEST("Zamazenta's Iron Head becomes Behemoth Bash upon form change") +{ + GIVEN { + ASSUME(P_GEN_8_POKEMON == TRUE); + PLAYER(SPECIES_ZAMAZENTA) { Item(ITEM_RUSTED_SHIELD); Moves(MOVE_IRON_HEAD, MOVE_CELEBRATE); }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE); } + } THEN { + ASSUME(player->species == SPECIES_ZAMAZENTA_CROWNED_SHIELD); // Assumes form change worked. + EXPECT_EQ(player->moves[0], MOVE_BEHEMOTH_BASH); + } +} From 52011804b96fb57f12f2871721ead16dc5ff8baa Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 24 Mar 2023 09:36:33 -0300 Subject: [PATCH 30/37] Level command now also sets experience to avoid losing level upon form changes --- test/test_runner_battle.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index ec7ba275c..524525c13 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -933,9 +933,11 @@ void Ability_(u32 sourceLine, u32 ability) void Level_(u32 sourceLine, u32 level) { // TODO: Preserve any explicitly-set stats. + u32 species = GetMonData(DATA.currentMon, MON_DATA_SPECIES); INVALID_IF(!DATA.currentMon, "Level outside of PLAYER/OPPONENT"); INVALID_IF(level == 0 || level > MAX_LEVEL, "Illegal level: %d", level); SetMonData(DATA.currentMon, MON_DATA_LEVEL, &level); + SetMonData(DATA.currentMon, MON_DATA_EXP, &gExperienceTables[gSpeciesInfo[species].growthRate][level]); } void MaxHP_(u32 sourceLine, u32 maxHP) From 498f4a2c972941bd271e3487007eb6a919e15584 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 24 Mar 2023 10:04:38 -0300 Subject: [PATCH 31/37] Schooling and Zen Mode tests --- test/ability_schooling.c | 111 ++++++++++++++++++++++++++++++++++++++ test/ability_zen_mode.c | 93 ++++++++++++++++++++++++++++++++ test/test_runner_battle.c | 1 + 3 files changed, 205 insertions(+) create mode 100644 test/ability_schooling.c create mode 100644 test/ability_zen_mode.c diff --git a/test/ability_schooling.c b/test/ability_schooling.c new file mode 100644 index 000000000..03a5303f0 --- /dev/null +++ b/test/ability_schooling.c @@ -0,0 +1,111 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Schooling switches Level 20+ Wishiwashi's form when HP is 25-percent or less at the end of the turn") +{ + u16 level; + PARAMETRIZE { level = 19; } + PARAMETRIZE { level = 20; } + + GIVEN { + ASSUME(P_GEN_7_POKEMON == TRUE); + ASSUME(gSpeciesInfo[SPECIES_WISHIWASHI].baseHP == gSpeciesInfo[SPECIES_WISHIWASHI_SCHOOL].baseHP); + PLAYER(SPECIES_WISHIWASHI) + { + Level(level); + HP(GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP) / 2); + Ability(ABILITY_SCHOOLING); + }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE); MOVE(opponent, MOVE_SUPER_FANG); } + } SCENE { + if (level >= 20) + { + ABILITY_POPUP(player, ABILITY_SCHOOLING); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + } + MESSAGE("Wishiwashi used Celebrate!"); + MESSAGE("Foe Wobbuffet used Super Fang!"); + HP_BAR(player); + if (level >= 20) + { + ABILITY_POPUP(player, ABILITY_SCHOOLING); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + } + } THEN { + EXPECT_EQ(player->species, SPECIES_WISHIWASHI); + } +} + +SINGLE_BATTLE_TEST("Schooling switches Level 20+ Wishiwashi's form when HP is over 25-percent before the first turn") +{ + u16 level; + bool32 overQuarterHP; + PARAMETRIZE { level = 19; overQuarterHP = FALSE; } + PARAMETRIZE { level = 20; overQuarterHP = FALSE; } + PARAMETRIZE { level = 19; overQuarterHP = TRUE; } + PARAMETRIZE { level = 20; overQuarterHP = TRUE; } + + GIVEN { + ASSUME(P_GEN_7_POKEMON == TRUE); + ASSUME(gSpeciesInfo[SPECIES_WISHIWASHI].baseHP == gSpeciesInfo[SPECIES_WISHIWASHI_SCHOOL].baseHP); + PLAYER(SPECIES_WISHIWASHI) + { + Level(level); + HP(GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP) / (overQuarterHP ? 2 : 4)); + Ability(ABILITY_SCHOOLING); + }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE); MOVE(opponent, MOVE_CELEBRATE); } + } SCENE { + if (level >= 20 && overQuarterHP) + { + ABILITY_POPUP(player, ABILITY_SCHOOLING); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + } + MESSAGE("Wishiwashi used Celebrate!"); + MESSAGE("Foe Wobbuffet used Celebrate!"); + } THEN { + if (level >= 20 && overQuarterHP) + EXPECT_EQ(player->species, SPECIES_WISHIWASHI_SCHOOL); + else + EXPECT_EQ(player->species, SPECIES_WISHIWASHI); + } +} + +SINGLE_BATTLE_TEST("Schooling switches Level 20+ Wishiwashi's form when HP is healed above 25-percent") +{ + u16 level; + PARAMETRIZE { level = 19; } + PARAMETRIZE { level = 20; } + + GIVEN { + ASSUME(P_GEN_7_POKEMON == TRUE); + ASSUME(gSpeciesInfo[SPECIES_WISHIWASHI].baseHP == gSpeciesInfo[SPECIES_WISHIWASHI_SCHOOL].baseHP); + PLAYER(SPECIES_WISHIWASHI) + { + Level(level); + HP(GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP) / 4); + Ability(ABILITY_SCHOOLING); + }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE); MOVE(opponent, MOVE_HEAL_PULSE); } + } SCENE { + MESSAGE("Wishiwashi used Celebrate!"); + MESSAGE("Foe Wobbuffet used Heal Pulse!"); + HP_BAR(player); + if (level >= 20) + { + ABILITY_POPUP(player, ABILITY_SCHOOLING); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + } + } THEN { + if (level >= 20) + EXPECT_EQ(player->species, SPECIES_WISHIWASHI_SCHOOL); + else + EXPECT_EQ(player->species, SPECIES_WISHIWASHI); + } +} diff --git a/test/ability_zen_mode.c b/test/ability_zen_mode.c new file mode 100644 index 000000000..acf0ba291 --- /dev/null +++ b/test/ability_zen_mode.c @@ -0,0 +1,93 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Zen Mode switches Darmanitan's form when HP is half or less at the end of the turn") +{ + u16 standardSpecies, zenSpecies; + PARAMETRIZE { standardSpecies = SPECIES_DARMANITAN; zenSpecies = SPECIES_DARMANITAN_ZEN_MODE; } + PARAMETRIZE { standardSpecies = SPECIES_DARMANITAN_GALARIAN; zenSpecies = SPECIES_DARMANITAN_ZEN_MODE_GALARIAN; } + + GIVEN { + ASSUME(P_GEN_5_POKEMON == TRUE); + ASSUME(gSpeciesInfo[standardSpecies].baseHP == 105); + ASSUME(gSpeciesInfo[zenSpecies].baseHP == 105); + PLAYER(standardSpecies) + { + Ability(ABILITY_ZEN_MODE); + HP((GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP) / 2) + 1); + }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE); MOVE(opponent, MOVE_TACKLE); } + } SCENE { + MESSAGE("Darmanitan used Celebrate!"); + MESSAGE("Foe Wobbuffet used Tackle!"); + HP_BAR(player); + ABILITY_POPUP(player, ABILITY_ZEN_MODE); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + } THEN { + ASSUME(player->hp <= player->maxHP / 2); + EXPECT_EQ(player->species, zenSpecies); + } +} + +SINGLE_BATTLE_TEST("Zen Mode switches Darmanitan's form when HP is half or less before the first turn") +{ + u16 standardSpecies, zenSpecies; + PARAMETRIZE { standardSpecies = SPECIES_DARMANITAN; zenSpecies = SPECIES_DARMANITAN_ZEN_MODE; } + PARAMETRIZE { standardSpecies = SPECIES_DARMANITAN_GALARIAN; zenSpecies = SPECIES_DARMANITAN_ZEN_MODE_GALARIAN; } + + GIVEN { + ASSUME(P_GEN_5_POKEMON == TRUE); + ASSUME(gSpeciesInfo[standardSpecies].baseHP == 105); + ASSUME(gSpeciesInfo[zenSpecies].baseHP == 105); + PLAYER(standardSpecies) + { + Ability(ABILITY_ZEN_MODE); + HP(GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP) / 2); + }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE); MOVE(opponent, MOVE_CELEBRATE); } + } SCENE { + ABILITY_POPUP(player, ABILITY_ZEN_MODE); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + MESSAGE("Darmanitan used Celebrate!"); + MESSAGE("Foe Wobbuffet used Celebrate!"); + } THEN { + EXPECT_LE(player->hp, player->maxHP / 2); + EXPECT_EQ(player->species, zenSpecies); + } +} + +SINGLE_BATTLE_TEST("Zen Mode switches Darmanitan's form when HP is healed above half") +{ + u16 standardSpecies, zenSpecies; + PARAMETRIZE { standardSpecies = SPECIES_DARMANITAN; zenSpecies = SPECIES_DARMANITAN_ZEN_MODE; } + PARAMETRIZE { standardSpecies = SPECIES_DARMANITAN_GALARIAN; zenSpecies = SPECIES_DARMANITAN_ZEN_MODE_GALARIAN; } + + GIVEN { + ASSUME(P_GEN_5_POKEMON == TRUE); + ASSUME(gSpeciesInfo[standardSpecies].baseHP == 105); + ASSUME(gSpeciesInfo[zenSpecies].baseHP == 105); + PLAYER(standardSpecies) + { + Ability(ABILITY_ZEN_MODE); + HP(GetMonData(&PLAYER_PARTY[0], MON_DATA_MAX_HP) / 2); + }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE); MOVE(opponent, MOVE_HEAL_PULSE); } + } SCENE { + ABILITY_POPUP(player, ABILITY_ZEN_MODE); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + MESSAGE("Darmanitan used Celebrate!"); + MESSAGE("Foe Wobbuffet used Heal Pulse!"); + HP_BAR(player); + ABILITY_POPUP(player, ABILITY_ZEN_MODE); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + } THEN { + EXPECT_GT(player->hp, player->maxHP / 2); + EXPECT_EQ(player->species, standardSpecies); + } +} diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index 524525c13..e96a6ea7b 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -938,6 +938,7 @@ void Level_(u32 sourceLine, u32 level) INVALID_IF(level == 0 || level > MAX_LEVEL, "Illegal level: %d", level); SetMonData(DATA.currentMon, MON_DATA_LEVEL, &level); SetMonData(DATA.currentMon, MON_DATA_EXP, &gExperienceTables[gSpeciesInfo[species].growthRate][level]); + CalculateMonStats(DATA.currentMon); } void MaxHP_(u32 sourceLine, u32 maxHP) From fad11981a58ad3a5d2299533da0c29ec38a461e9 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 24 Mar 2023 11:03:34 -0300 Subject: [PATCH 32/37] Tests for form change on switch out and fainting --- test/ability_zen_mode.c | 10 +++++----- test/form_change.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/test/ability_zen_mode.c b/test/ability_zen_mode.c index acf0ba291..f18f6d659 100644 --- a/test/ability_zen_mode.c +++ b/test/ability_zen_mode.c @@ -20,11 +20,11 @@ SINGLE_BATTLE_TEST("Zen Mode switches Darmanitan's form when HP is half or less } WHEN { TURN { MOVE(player, MOVE_CELEBRATE); MOVE(opponent, MOVE_TACKLE); } } SCENE { - MESSAGE("Darmanitan used Celebrate!"); - MESSAGE("Foe Wobbuffet used Tackle!"); - HP_BAR(player); - ABILITY_POPUP(player, ABILITY_ZEN_MODE); - ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + MESSAGE("Darmanitan used Celebrate!"); + MESSAGE("Foe Wobbuffet used Tackle!"); + HP_BAR(player); + ABILITY_POPUP(player, ABILITY_ZEN_MODE); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); } THEN { ASSUME(player->hp <= player->maxHP / 2); EXPECT_EQ(player->species, zenSpecies); diff --git a/test/form_change.c b/test/form_change.c index 8d761bb12..74ba2b75f 100644 --- a/test/form_change.c +++ b/test/form_change.c @@ -79,3 +79,41 @@ SINGLE_BATTLE_TEST("Zamazenta's Iron Head becomes Behemoth Bash upon form change EXPECT_EQ(player->moves[0], MOVE_BEHEMOTH_BASH); } } + +SINGLE_BATTLE_TEST("Aegislash reverts to Shield Form upon switching out") +{ + GIVEN { + ASSUME(P_GEN_6_POKEMON == TRUE); + PLAYER(SPECIES_AEGISLASH); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TACKLE); } + TURN { SWITCH(player, 1); } + TURN { SWITCH(player, 0); } + } SCENE { + ABILITY_POPUP(player, ABILITY_STANCE_CHANGE); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + MESSAGE("Aegislash used Tackle!"); + MESSAGE("Foe Wobbuffet used Celebrate!"); + } THEN { + EXPECT_EQ(player->species, SPECIES_AEGISLASH); + } +} + +SINGLE_BATTLE_TEST("Aegislash reverts to Shield Form upon fainting") +{ + GIVEN { + ASSUME(P_GEN_6_POKEMON == TRUE); + PLAYER(SPECIES_AEGISLASH) { HP(1); }; + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_GUST); SEND_OUT(player, 1);} + } SCENE { + MESSAGE("Foe Wobbuffet used Gust!"); + MESSAGE("Aegislash fainted!"); + } THEN { + EXPECT_EQ(GetMonData(&PLAYER_PARTY[0], MON_DATA_SPECIES), SPECIES_AEGISLASH); + } +} From 2017bee3f8efc1c0d37175cf913bf8a593519b97 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Mon, 27 Mar 2023 11:35:23 -0700 Subject: [PATCH 33/37] fixed Castform + Cherrim --- data/battle_scripts_1.s | 60 ++++++------------- include/battle_scripts.h | 3 - include/config/battle.h | 1 + include/constants/battle.h | 1 + include/constants/battle_script_commands.h | 7 +-- include/constants/form_change_types.h | 6 +- src/battle_script_commands.c | 36 +++-------- src/battle_util.c | 26 ++++++-- src/data/pokemon/form_change_table_pointers.h | 4 ++ src/data/pokemon/form_change_tables.h | 22 +++++++ 10 files changed, 82 insertions(+), 84 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index b8740cb6b..e07ecdb72 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5156,7 +5156,7 @@ BattleScript_MoveWeatherChange:: waitanimation printfromtable gMoveWeatherChangeStringIds waitmessage B_WAIT_TIME_LONG - call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities goto BattleScript_MoveEnd BattleScript_EffectSunnyDay:: @@ -6860,7 +6860,7 @@ BattleScript_OverworldWeatherStarts:: printfromtable gWeatherStartsStringIds waitmessage B_WAIT_TIME_LONG playanimation_var BS_ATTACKER, sB_ANIM_ARG1 - call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_OverworldTerrain:: @@ -8413,7 +8413,7 @@ BattleScript_DrizzleActivates:: printstring STRINGID_PKMNMADEITRAIN waitstate playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES - call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_AbilityRaisesDefenderStat:: @@ -8575,7 +8575,7 @@ BattleScript_SandstreamActivates:: printstring STRINGID_PKMNSXWHIPPEDUPSANDSTORM waitstate playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES - call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_SandSpitActivates:: @@ -8584,7 +8584,7 @@ BattleScript_SandSpitActivates:: printstring STRINGID_ASANDSTORMKICKEDUP waitstate playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES - call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities return BattleScript_ShedSkinActivates:: @@ -8594,37 +8594,15 @@ BattleScript_ShedSkinActivates:: updatestatusicon BS_ATTACKER end3 -BattleScript_WeatherFormChanges:: - setbyte sBATTLER, 0 -BattleScript_WeatherFormChangesLoop:: - tryweatherformdatachange - activateweatherchangeabilities BS_SCRIPTING - addbyte sBATTLER, 1 - jumpifbytenotequal sBATTLER, gBattlersCount, BattleScript_WeatherFormChangesLoop - return - -BattleScript_WeatherFormChange:: - call BattleScript_DoWeatherFormChange - end3 - -BattleScript_DoWeatherFormChange:: - copybyte gBattlerAbility, sBATTLER -.if B_WEATHER_FORMS >= GEN_5 - jumpifspecies BS_SCRIPTING, SPECIES_CASTFORM, BattleScript_DoWeatherFormChange_ForecastCheck -BattleScript_DoWeatherFormChange_FlowerGiftCheck: - jumpifability BS_SCRIPTING, ABILITY_FLOWER_GIFT, BattleScript_DoWeatherFormChange_PopUp - goto BattleScript_DoWeatherFormChange_AfterPopUp -.endif -BattleScript_DoWeatherFormChange_ForecastCheck: - jumpifability BS_SCRIPTING, ABILITY_FORECAST, BattleScript_DoWeatherFormChange_PopUp - goto BattleScript_DoWeatherFormChange_AfterPopUp -BattleScript_DoWeatherFormChange_PopUp: - call BattleScript_AbilityPopUp -BattleScript_DoWeatherFormChange_AfterPopUp: - doweatherformchangeanimation - waitstate - printstring STRINGID_PKMNTRANSFORMED - waitmessage B_WAIT_TIME_LONG +BattleScript_ActivateWeatherAbilities: + copybyte sBATTLER, gBattlerAttacker + setbyte gBattlerAttacker, 0 +BattleScript_ActivateWeatherAbilities_Loop: + activateweatherchangeabilities BS_ATTACKER +BattleScript_ActivateWeatherAbilities_Increment: + addbyte gBattlerAttacker, 1 + jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_ActivateWeatherAbilities_Loop + copybyte gBattlerAttacker, sBATTLER return BattleScript_TryAdrenalineOrb: @@ -8719,7 +8697,7 @@ BattleScript_DroughtActivates:: printstring STRINGID_PKMNSXINTENSIFIEDSUN waitstate playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES - call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_DesolateLandActivates:: @@ -8728,7 +8706,7 @@ BattleScript_DesolateLandActivates:: printstring STRINGID_EXTREMELYHARSHSUNLIGHT waitstate playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES - call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_DesolateLandEvaporatesWaterTypeMoves:: @@ -8748,7 +8726,7 @@ BattleScript_PrimordialSeaActivates:: printstring STRINGID_HEAVYRAIN waitstate playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES - call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_PrimordialSeaFizzlesOutFireTypeMoves:: @@ -8825,7 +8803,7 @@ BattleScript_SnowWarningActivates:: printstring STRINGID_SNOWWARNINGHAIL waitstate playanimation BS_BATTLER_0, B_ANIM_HAIL_CONTINUES - call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_TerrainSeedLoop: @@ -10002,7 +9980,7 @@ BattleScript_AnnounceAirLockCloudNine:: call BattleScript_AbilityPopUp printstring STRINGID_AIRLOCKACTIVATES waitmessage B_WAIT_TIME_LONG - call BattleScript_WeatherFormChanges + call BattleScript_ActivateWeatherAbilities end3 BattleScript_QuickClawActivation:: diff --git a/include/battle_scripts.h b/include/battle_scripts.h index c78fcafe4..b6a284488 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -149,9 +149,6 @@ extern const u8 BattleScript_TraceActivatesEnd3[]; extern const u8 BattleScript_RainDishActivates[]; extern const u8 BattleScript_SandstreamActivates[]; extern const u8 BattleScript_ShedSkinActivates[]; -extern const u8 BattleScript_WeatherFormChanges[]; -extern const u8 BattleScript_WeatherFormChangesLoop[]; -extern const u8 BattleScript_WeatherFormChange[]; extern const u8 BattleScript_IntimidateActivates[]; extern const u8 BattleScript_DroughtActivates[]; extern const u8 BattleScript_TookAttack[]; diff --git a/include/config/battle.h b/include/config/battle.h index 4a3d6382f..173f57ac3 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -99,6 +99,7 @@ // Additionally, in gen8+ the Healing Wish's effect will be stored until the user switches into a statused or hurt mon. #define B_DEFOG_CLEARS_TERRAIN GEN_LATEST // In Gen8+, Defog also clears active Terrain. #define B_STOCKPILE_RAISES_DEFS GEN_LATEST // In Gen4+, Stockpile also raises Defense and Sp.Defense stats. Once Spit Up / Swallow is used, these stat changes are lost. +#define B_TRANSFORM_FORM_CHANGES GEN_LATEST // In Gen5+, Transformed Pokemon cannot change forms. // Ability settings #define B_EXPANDED_ABILITY_NAMES TRUE // If TRUE, ability names are increased from 12 characters to 16 characters. diff --git a/include/constants/battle.h b/include/constants/battle.h index 61c3776c6..5d5dca20a 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -269,6 +269,7 @@ #define MOVE_RESULT_NO_EFFECT (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE | MOVE_RESULT_FAILED) // Battle Weather flags +#define B_WEATHER_NONE 0 #define B_WEATHER_RAIN_TEMPORARY (1 << 0) #define B_WEATHER_RAIN_DOWNPOUR (1 << 1) // unused #define B_WEATHER_RAIN_PERMANENT (1 << 2) diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 26064bcfb..b8a689098 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -332,10 +332,9 @@ #define MOVEEND_PICKPOCKET 30 #define MOVEEND_DANCER 31 #define MOVEEND_EMERGENCY_EXIT 32 -#define MOVEEND_WEATHER_FORM 33 -#define MOVEEND_SYMBIOSIS 34 -#define MOVEEND_CLEAR_BITS 35 -#define MOVEEND_COUNT 36 +#define MOVEEND_SYMBIOSIS 33 +#define MOVEEND_CLEAR_BITS 34 +#define MOVEEND_COUNT 35 // switch cases #define B_SWITCH_NORMAL 0 diff --git a/include/constants/form_change_types.h b/include/constants/form_change_types.h index 4e60904aa..651bcf788 100644 --- a/include/constants/form_change_types.h +++ b/include/constants/form_change_types.h @@ -87,8 +87,12 @@ // param1: item to hold. #define FORM_CHANGE_BATTLE_PRIMAL_REVERSION 13 +// Form change that activates when a specific weather is set during battle. +// param1: weather to check +#define FORM_CHANGE_BATTLE_WEATHER 14 + // Form change that activates automatically when the turn ends. // param1: ability to check. -#define FORM_CHANGE_BATTLE_TURN_END 14 +#define FORM_CHANGE_BATTLE_TURN_END 15 #endif // GUARD_CONSTANTS_FORM_CHANGE_TYPES_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 51d71e347..c1df49b4a 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6216,28 +6216,6 @@ static void Cmd_moveend(void) } gBattleScripting.moveendState++; break; - case MOVEEND_WEATHER_FORM: - for (i = 0; i < MAX_BATTLERS_COUNT; i++) - { - switch (gBattleMons[i].species) - { - case SPECIES_CASTFORM: - case SPECIES_CASTFORM_RAINY: - case SPECIES_CASTFORM_SNOWY: - case SPECIES_CASTFORM_SUNNY: - case SPECIES_CHERRIM: - case SPECIES_CHERRIM_SUNSHINE: - effect = TryWeatherFormChange(i); - if (effect) - { - BattleScriptPushCursorAndCallback(BattleScript_WeatherFormChange); - gBattleScripting.battler = i; - gBattleStruct->formToChangeInto = effect - 1; - } - } - } - gBattleScripting.moveendState++; - break; case MOVEEND_SYMBIOSIS: for (i = 0; i < gBattlersCount; i++) { @@ -15080,13 +15058,13 @@ static void Cmd_tryweatherformdatachange(void) u8 form; - gBattlescriptCurrInstr = cmd->nextInstr; - form = TryWeatherFormChange(gBattleScripting.battler); - if (form) - { - BattleScriptPushCursorAndCallback(BattleScript_WeatherFormChange); - *(&gBattleStruct->formToChangeInto) = form - 1; - } + // gBattlescriptCurrInstr = cmd->nextInstr; + // form = TryWeatherFormChange(gBattleScripting.battler); + // if (form) + // { + // BattleScriptPushCursorAndCallback(BattleScript_WeatherFormChange); + // *(&gBattleStruct->formToChangeInto) = form - 1; + // } } // Water and Mud Sport diff --git a/src/battle_util.c b/src/battle_util.c index c6a59acf5..3f85d298a 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2564,7 +2564,15 @@ u8 DoFieldEndTurnEffects(void) gBattleStruct->turnCountersTracker++; break; case ENDTURN_WEATHER_FORM: - AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, 0, 0, 0, 0); + for (i = 0; i < gBattlersCount; ++i) + { + // This breaks Eiscue right now, because Eiscue doesn't use FORM_CHANGE_BATTLE_WEATHER. + if(TryBattleFormChange(i, FORM_CHANGE_BATTLE_WEATHER)) + { + BattleScriptPushCursorAndCallback(BattleScript_BattlerFormChangeWithStringEnd3); + effect++; + } + } gBattleStruct->turnCountersTracker++; break; case ENDTURN_STATUS_HEAL: @@ -6155,11 +6163,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move #else TRY_WEATHER_FORM: #endif - effect = TryWeatherFormChange(battler); - if (effect != 0) + if (IsBattlerWeatherAffected(battler, gBattleWeather) + && TryBattleFormChange(battler, FORM_CHANGE_BATTLE_WEATHER)) { - BattleScriptPushCursorAndCallback(BattleScript_WeatherFormChange); - *(&gBattleStruct->formToChangeInto) = effect - 1; + BattleScriptPushCursorAndCallback(BattleScript_BattlerFormChangeWithStringEnd3); + effect++; } break; case ABILITY_ICE_FACE: @@ -10153,6 +10161,11 @@ u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method) } } break; + case FORM_CHANGE_BATTLE_WEATHER: + if (gBattleWeather & formChanges[i].param1 + || (gBattleWeather == B_WEATHER_NONE && formChanges[i].param1 == B_WEATHER_NONE)) + targetSpecies = formChanges[i].targetSpecies; + break; case FORM_CHANGE_BATTLE_TURN_END: if (formChanges[i].param1 == GetBattlerAbility(battlerId)) targetSpecies = formChanges[i].targetSpecies; @@ -10168,7 +10181,8 @@ u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method) bool32 CanBattlerFormChange(u8 battlerId, u16 method) { // Can't change form if transformed. - if (gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED) + if (gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED + && B_TRANSFORM_FORM_CHANGES >= GEN_5) return FALSE; // Mega Evolved Pokémon should always revert to normal upon fainting or ending the battle. if (IsBattlerMegaEvolved(battlerId) && (method == FORM_CHANGE_FAINT || method == FORM_CHANGE_END_BATTLE)) diff --git a/src/data/pokemon/form_change_table_pointers.h b/src/data/pokemon/form_change_table_pointers.h index 83f68d70c..daeaa9cbb 100644 --- a/src/data/pokemon/form_change_table_pointers.h +++ b/src/data/pokemon/form_change_table_pointers.h @@ -64,6 +64,10 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] = [SPECIES_ALTARIA_MEGA] = sAltariaFormChangeTable, [SPECIES_ABSOL] = sAbsolFormChangeTable, [SPECIES_ABSOL_MEGA] = sAbsolFormChangeTable, + [SPECIES_CASTFORM] = sCastformFormChangeTable, + [SPECIES_CASTFORM_SUNNY] = sCastformFormChangeTable, + [SPECIES_CASTFORM_RAINY] = sCastformFormChangeTable, + [SPECIES_CASTFORM_SNOWY] = sCastformFormChangeTable, [SPECIES_BANETTE] = sBanetteFormChangeTable, [SPECIES_BANETTE_MEGA] = sBanetteFormChangeTable, [SPECIES_AGGRON] = sAggronFormChangeTable, diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index afe54f632..c4ade7b9a 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -155,6 +155,18 @@ static const struct FormChange sAbsolFormChangeTable[] = { {FORM_CHANGE_TERMINATOR}, }; +static const struct FormChange sCastformFormChangeTable[] = { + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM_SUNNY, B_WEATHER_SUN}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM_RAINY, B_WEATHER_RAIN}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM_SNOWY, B_WEATHER_HAIL}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM, ~(B_WEATHER_SUN | B_WEATHER_RAIN | B_WEATHER_HAIL)}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM, B_WEATHER_NONE}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_CASTFORM}, + {FORM_CHANGE_FAINT, SPECIES_CASTFORM}, + {FORM_CHANGE_END_BATTLE, SPECIES_CASTFORM}, + {FORM_CHANGE_TERMINATOR}, +}; + static const struct FormChange sBanetteFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_BANETTE_MEGA, ITEM_BANETTITE}, {FORM_CHANGE_TERMINATOR}, @@ -218,6 +230,16 @@ static const struct FormChange sBurmyFormChangeTable[] = { {FORM_CHANGE_TERMINATOR}, }; +static const struct FormChange sCherrimFormChangeTable[] = { + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CHERRIM_SUNSHINE, B_WEATHER_SUN}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CHERRIM, ~B_WEATHER_SUN}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CHERRIM, B_WEATHER_NONE}, + {FORM_CHANGE_BATTLE_SWITCH, SPECIES_CHERRIM}, + {FORM_CHANGE_FAINT, SPECIES_CHERRIM}, + {FORM_CHANGE_END_BATTLE, SPECIES_CHERRIM}, + {FORM_CHANGE_TERMINATOR}, +}; + static const struct FormChange sLopunnyFormChangeTable[] = { {FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM, SPECIES_LOPUNNY_MEGA, ITEM_LOPUNNITE}, {FORM_CHANGE_TERMINATOR}, From b856cb3e624652e5fb4b75d598359c84cd3f5764 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Mon, 27 Mar 2023 12:05:06 -0700 Subject: [PATCH 34/37] fixed Eiscue + multiple weather form changes at once (probably) --- src/battle_util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 3f85d298a..9e85f3ce3 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2566,14 +2566,14 @@ u8 DoFieldEndTurnEffects(void) case ENDTURN_WEATHER_FORM: for (i = 0; i < gBattlersCount; ++i) { - // This breaks Eiscue right now, because Eiscue doesn't use FORM_CHANGE_BATTLE_WEATHER. - if(TryBattleFormChange(i, FORM_CHANGE_BATTLE_WEATHER)) + if (AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, i, 0, 0, 0)) { - BattleScriptPushCursorAndCallback(BattleScript_BattlerFormChangeWithStringEnd3); effect++; + break; } } - gBattleStruct->turnCountersTracker++; + if (effect == 0) + gBattleStruct->turnCountersTracker++; break; case ENDTURN_STATUS_HEAL: for (gBattlerAttacker = 0; gBattlerAttacker < gBattlersCount; gBattlerAttacker++) @@ -6163,7 +6163,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move #else TRY_WEATHER_FORM: #endif - if (IsBattlerWeatherAffected(battler, gBattleWeather) + if ((IsBattlerWeatherAffected(battler, gBattleWeather) || gBattleWeather == B_WEATHER_NONE) && TryBattleFormChange(battler, FORM_CHANGE_BATTLE_WEATHER)) { BattleScriptPushCursorAndCallback(BattleScript_BattlerFormChangeWithStringEnd3); From dacd0785db12a41df50a0b12989d58c54ae41f3b Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 14 Apr 2023 15:17:19 -0400 Subject: [PATCH 35/37] Fixed Mega Evolution script name --- data/battle_scripts_1.s | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index ebb23d201..30a80bf19 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7872,7 +7872,7 @@ BattleScript_FocusPunchSetUp:: BattleScript_MegaEvolution:: printstring STRINGID_MEGAEVOREACTING -BattleScript_MegaEvolutionAfeterString: +BattleScript_MegaEvolutionAfterString: waitmessage B_WAIT_TIME_LONG setbyte gIsCriticalHit, 0 handlemegaevo BS_ATTACKER, 0 @@ -7886,7 +7886,7 @@ BattleScript_MegaEvolutionAfeterString: BattleScript_WishMegaEvolution:: printstring STRINGID_FERVENTWISHREACHED - goto BattleScript_MegaEvolutionAfeterString + goto BattleScript_MegaEvolutionAfterString BattleScript_PrimalReversion:: printstring STRINGID_EMPTYSTRING3 From c82c2c185ecc62b58e79ab5feb5e29b3e4268f8f Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Sat, 29 Apr 2023 18:29:50 +0200 Subject: [PATCH 36/37] Integrate ghoul's review Co-Authored-By: ghoulslash <41651341+ghoulslash@users.noreply.github.com> --- src/battle_script_commands.c | 10 ---------- src/battle_util.c | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 81c39f893..ccbb488d2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -15147,16 +15147,6 @@ static void Cmd_doweatherformchangeanimation(void) static void Cmd_tryweatherformdatachange(void) { CMD_ARGS(); - - u8 form; - - // gBattlescriptCurrInstr = cmd->nextInstr; - // form = TryWeatherFormChange(gBattleScripting.battler); - // if (form) - // { - // BattleScriptPushCursorAndCallback(BattleScript_WeatherFormChange); - // *(&gBattleStruct->formToChangeInto) = form - 1; - // } } // Water and Mud Sport diff --git a/src/battle_util.c b/src/battle_util.c index e3c4ceed6..aab0f2db6 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2487,7 +2487,7 @@ u8 DoFieldEndTurnEffects(void) gBattleStruct->turnCountersTracker++; break; case ENDTURN_WEATHER_FORM: - for (i = 0; i < gBattlersCount; ++i) + for (i = 0; i < gBattlersCount; i++) { if (AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, i, 0, 0, 0)) { @@ -10154,7 +10154,7 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method) { u8 monId = gBattlerPartyIndexes[battlerId]; u8 side = GET_BATTLER_SIDE(battlerId); - struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + struct Pokemon *party = GetBattlerParty(battlerId); u16 targetSpecies; if (!CanBattlerFormChange(battlerId, method)) From c7d39e561dd638e9da7b96768fb51c085ea5b58b Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Sat, 29 Apr 2023 20:41:54 +0200 Subject: [PATCH 37/37] Clarify weather function --- src/battle_script_commands.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ccbb488d2..aead0fe3c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -15147,6 +15147,8 @@ static void Cmd_doweatherformchangeanimation(void) static void Cmd_tryweatherformdatachange(void) { CMD_ARGS(); + + // removed in favor of new form system } // Water and Mud Sport