Form change when fainting. Goodbye UndoFormChange!

This commit is contained in:
Eduardo Quezada 2022-10-20 18:53:12 -03:00
parent d8cc7f7abe
commit 861590f747
5 changed files with 22 additions and 44 deletions

View File

@ -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);

View File

@ -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

View File

@ -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]);

View File

@ -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;

View File

@ -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},
};