Remove UndoFormChangeOnSwitch

Handle switching out Mimikyu Busted in UndoFormChange.
This commit is contained in:
BuffelSaft 2021-07-16 17:56:53 +12:00
parent 63faa6e3a9
commit 90fdb74ccb
3 changed files with 10 additions and 37 deletions

View file

@ -123,8 +123,7 @@ u16 GetMegaEvolutionSpecies(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);
void UndoFormChangeOnSwitch(u32 monId, u32 side);
void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut);
bool32 DoBattlersShareType(u32 battler1, u32 battler2);
bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId);
struct Pokemon *GetIllusionMonPtr(u32 battlerId);

View file

@ -3122,7 +3122,7 @@ void FaintClearSetData(void)
ClearBattlerMoveHistory(gActiveBattler);
ClearBattlerAbilityHistory(gActiveBattler);
ClearBattlerItemEffectHistory(gActiveBattler);
UndoFormChange(gBattlerPartyIndexes[gActiveBattler], GET_BATTLER_SIDE(gActiveBattler));
UndoFormChange(gBattlerPartyIndexes[gActiveBattler], GET_BATTLER_SIDE(gActiveBattler), FALSE);
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
UndoMegaEvolution(gBattlerPartyIndexes[gActiveBattler]);
}
@ -4878,7 +4878,7 @@ static void HandleEndTurn_FinishBattle(void)
for (i = 0; i < PARTY_SIZE; i++)
{
UndoMegaEvolution(i);
UndoFormChange(i, B_SIDE_PLAYER);
UndoFormChange(i, B_SIDE_PLAYER, FALSE);
}
gBattleMainFunc = FreeResetData_ReturnToOvOrDoEvolutions;
gCB2_AfterEvolution = BattleMainCB2;

View file

@ -492,7 +492,7 @@ void HandleAction_Switch(void)
if (gBattleResults.playerSwitchesCounter < 255)
gBattleResults.playerSwitchesCounter++;
UndoFormChangeOnSwitch(gBattlerPartyIndexes[gBattlerAttacker], GetBattlerSide(gBattlerAttacker));
UndoFormChange(gBattlerPartyIndexes[gBattlerAttacker], GetBattlerSide(gBattlerAttacker), TRUE);
}
void HandleAction_UseItem(void)
@ -8322,44 +8322,13 @@ void UndoMegaEvolution(u32 monId)
}
}
void UndoFormChange(u32 monId, u32 side)
void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut)
{
u32 i, currSpecies;
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
static const u16 species[][2] = // changed form id, default form id
{
{SPECIES_AEGISLASH_BLADE, SPECIES_AEGISLASH},
{SPECIES_MIMIKYU_BUSTED, SPECIES_MIMIKYU},
{SPECIES_DARMANITAN_ZEN_MODE, SPECIES_DARMANITAN},
{SPECIES_MINIOR, SPECIES_MINIOR_CORE_RED},
{SPECIES_MINIOR_METEOR_BLUE, SPECIES_MINIOR_CORE_BLUE},
{SPECIES_MINIOR_METEOR_GREEN, SPECIES_MINIOR_CORE_GREEN},
{SPECIES_MINIOR_METEOR_INDIGO, SPECIES_MINIOR_CORE_INDIGO},
{SPECIES_MINIOR_METEOR_ORANGE, SPECIES_MINIOR_CORE_ORANGE},
{SPECIES_MINIOR_METEOR_VIOLET, SPECIES_MINIOR_CORE_VIOLET},
{SPECIES_MINIOR_METEOR_YELLOW, SPECIES_MINIOR_CORE_YELLOW},
{SPECIES_WISHIWASHI_SCHOOL, SPECIES_WISHIWASHI},
};
currSpecies = GetMonData(&party[monId], MON_DATA_SPECIES, NULL);
for (i = 0; i < ARRAY_COUNT(species); i++)
{
if (currSpecies == species[i][0])
{
SetMonData(&party[monId], MON_DATA_SPECIES, &species[i][1]);
CalculateMonStats(&party[monId]);
break;
}
}
}
// Same as UndoFormChange but doesn't revert Mimikyu
void UndoFormChangeOnSwitch(u32 monId, u32 side)
{
u32 i, currSpecies;
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
static const u16 species[][2] = // changed form id, default form id
{
{SPECIES_AEGISLASH_BLADE, SPECIES_AEGISLASH},
{SPECIES_DARMANITAN_ZEN_MODE, SPECIES_DARMANITAN},
{SPECIES_MINIOR, SPECIES_MINIOR_CORE_RED},
@ -8375,6 +8344,11 @@ void UndoFormChangeOnSwitch(u32 monId, u32 side)
currSpecies = GetMonData(&party[monId], MON_DATA_SPECIES, NULL);
for (i = 0; i < ARRAY_COUNT(species); i++)
{
if (i == 0 && isSwitchingOut)
{
i++; // Don't revert Mimikyu Busted when switching out
}
if (currSpecies == species[i][0])
{
SetMonData(&party[monId], MON_DATA_SPECIES, &species[i][1]);