Adjusted GetFormChangeTargetSpeciesBoxMon to allow having form changes of the same method in the same table

This commit is contained in:
Eduardo Quezada 2022-09-01 14:03:37 -04:00 committed by LOuroboros
parent 0b07f4a06e
commit 7a0838a0f2
3 changed files with 19 additions and 47 deletions

View file

@ -24,15 +24,15 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] =
[SPECIES_ARCEUS_DARK] = sArceusFormChangeTable,
[SPECIES_ARCEUS_FAIRY] = sArceusFormChangeTable,
[SPECIES_TORNADUS] = sTornadusFormChangeTable,
[SPECIES_TORNADUS_THERIAN] = sTornadusTherianFormChangeTable,
[SPECIES_TORNADUS_THERIAN] = sTornadusFormChangeTable,
[SPECIES_THUNDURUS] = sThundurusFormChangeTable,
[SPECIES_THUNDURUS_THERIAN] = sThundurusTherianFormChangeTable,
[SPECIES_THUNDURUS_THERIAN] = sThundurusFormChangeTable,
[SPECIES_LANDORUS] = sLandorusFormChangeTable,
[SPECIES_LANDORUS_THERIAN] = sLandorusTherianFormChangeTable,
[SPECIES_LANDORUS_THERIAN] = sLandorusFormChangeTable,
[SPECIES_ENAMORUS] = sEnamorusFormChangeTable,
[SPECIES_ENAMORUS_THERIAN] = sEnamorusTherianFormChangeTable,
[SPECIES_ENAMORUS_THERIAN] = sEnamorusFormChangeTable,
[SPECIES_KELDEO] = sKeldeoFormChangeTable,
[SPECIES_KELDEO_RESOLUTE] = sKeldeoResoluteFormChangeTable,
[SPECIES_KELDEO_RESOLUTE] = sKeldeoFormChangeTable,
[SPECIES_GENESECT] = sGenesectFormChangeTable,
[SPECIES_GENESECT_DOUSE_DRIVE] = sGenesectFormChangeTable,
[SPECIES_GENESECT_SHOCK_DRIVE] = sGenesectFormChangeTable,
@ -41,7 +41,7 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] =
[SPECIES_XERNEAS] = sXerneasFormChangeTable,
[SPECIES_XERNEAS_ACTIVE] = sXerneasFormChangeTable,
[SPECIES_HOOPA] = sHoopaFormChangeTable,
[SPECIES_HOOPA_UNBOUND] = sHoopaUnboundFormChangeTable,
[SPECIES_HOOPA_UNBOUND] = sHoopaFormChangeTable,
[SPECIES_ORICORIO] = sOricorioFormChangeTable,
[SPECIES_ORICORIO_POM_POM] = sOricorioFormChangeTable,
[SPECIES_ORICORIO_PAU] = sOricorioFormChangeTable,

View file

@ -1,8 +1,4 @@
/*
For cycling between forms with the same method and parameters but different target species (eg. Tornadus using the
Reveal Glass to change between its two forms), a separate form change table is required for each form.
Otherwise, only the last form change on the table will trigger.
FORM_ITEM_HOLD:
Form change activates when the item is given to or taken from the selected Pokémon.
param1 = item to hold
@ -64,7 +60,7 @@ static const struct FormChange sGiratinaFormChangeTable[] = {
static const struct FormChange sShayminFormChangeTable[] = {
{FORM_ITEM_USE_TIME, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, DAY},
{FORM_WITHDRAW, SPECIES_SHAYMIN},
// {FORM_WITHDRAW, SPECIES_SHAYMIN},
{FORM_CHANGE_END},
};
@ -109,51 +105,25 @@ static const struct FormChange sArceusFormChangeTable[] = {
static const struct FormChange sTornadusFormChangeTable[] = {
{FORM_ITEM_USE, SPECIES_TORNADUS_THERIAN, ITEM_REVEAL_GLASS},
{FORM_CHANGE_END},
};
static const struct FormChange sTornadusTherianFormChangeTable[] = {
{FORM_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_CHANGE_END},
};
static const struct FormChange sThundurusTherianFormChangeTable[] = {
{FORM_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_CHANGE_END},
};
static const struct FormChange sLandorusTherianFormChangeTable[] = {
{FORM_ITEM_USE, SPECIES_LANDORUS, ITEM_REVEAL_GLASS},
{FORM_CHANGE_END},
};
static const struct FormChange sEnamorusFormChangeTable[] = {
{FORM_ITEM_USE, SPECIES_ENAMORUS, ITEM_REVEAL_GLASS},
{FORM_CHANGE_END},
};
static const struct FormChange sEnamorusTherianFormChangeTable[] = {
{FORM_ITEM_USE, SPECIES_ENAMORUS_THERIAN, ITEM_REVEAL_GLASS},
{FORM_CHANGE_END},
};
static const struct FormChange sKeldeoFormChangeTable[] = {
{FORM_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD, WHEN_LEARNED},
{FORM_CHANGE_END},
};
static const struct FormChange sKeldeoResoluteFormChangeTable[] = {
{FORM_MOVE, SPECIES_KELDEO, MOVE_SECRET_SWORD, WHEN_FORGOTTEN},
// {FORM_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD, WHEN_LEARNED},
// {FORM_MOVE, SPECIES_KELDEO, MOVE_SECRET_SWORD, WHEN_FORGOTTEN},
{FORM_CHANGE_END},
};
@ -167,12 +137,8 @@ static const struct FormChange sGenesectFormChangeTable[] = {
};
static const struct FormChange sHoopaFormChangeTable[] = {
// {FORM_ITEM_USE, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA},
{FORM_CHANGE_END},
};
static const struct FormChange sHoopaUnboundFormChangeTable[] = {
{FORM_WITHDRAW, SPECIES_HOOPA},
{FORM_ITEM_USE, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA},
// {FORM_WITHDRAW, SPECIES_HOOPA},
{FORM_CHANGE_END},
};
@ -225,5 +191,11 @@ static const struct FormChange sZamazentaFormChangeTable[] = {
{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_END},
};
#undef WHEN_LEARNED
#undef WHEN_FORGOTTEN

View file

@ -8277,7 +8277,7 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32
for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++)
{
if (method == formChanges[i].method)
if (method == formChanges[i].method && species != formChanges[i].targetSpecies)
{
switch (method)
{
@ -8324,7 +8324,7 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32
}
}
return species != targetSpecies ? targetSpecies : SPECIES_NONE;
return targetSpecies;
}
u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove)