Skip to content

Commit

Permalink
Adds forbidden status parameter to FORM_CHANGE_ITEM_USE (#4738)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bassoonian committed Jun 8, 2024
1 parent f1911da commit 568ce39
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions include/constants/form_change_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
// param2: time of day to check, optional.
// - DAY if Form change that activates in the daytime.
// - NIGHT if Form change that activates at nighttime.
// - 0 if irrelevant, but param3 is necessary.
// param3: illegal statuses to have, optional.
#define FORM_CHANGE_ITEM_USE 2

// TODO: Form change that activates when the Pokémon learns or forgets the move.
Expand Down
2 changes: 1 addition & 1 deletion src/data/pokemon/form_change_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ static const struct FormChange sGiratinaFormChangeTable[] = {

#if P_FAMILY_SHAYMIN
static const struct FormChange sShayminFormChangeTable[] = {
{FORM_CHANGE_ITEM_USE, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, DAY},
{FORM_CHANGE_ITEM_USE, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, DAY, STATUS1_FREEZE | STATUS1_FROSTBITE},
{FORM_CHANGE_WITHDRAW, SPECIES_SHAYMIN_LAND},
{FORM_CHANGE_TIME_OF_DAY, SPECIES_SHAYMIN_LAND, NIGHT},
{FORM_CHANGE_STATUS, SPECIES_SHAYMIN_LAND, STATUS1_FREEZE | STATUS1_FROSTBITE},
Expand Down
18 changes: 11 additions & 7 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -6196,20 +6196,24 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32
case FORM_CHANGE_ITEM_USE:
if (arg == formChanges[i].param1)
{
bool32 pass = TRUE;
switch (formChanges[i].param2)
{
case DAY:
if (GetTimeOfDay() != TIME_NIGHT)
targetSpecies = formChanges[i].targetSpecies;
break;
case NIGHT:
if (GetTimeOfDay() == TIME_NIGHT)
targetSpecies = formChanges[i].targetSpecies;
pass = FALSE;
break;
default:
targetSpecies = formChanges[i].targetSpecies;
case NIGHT:
if (GetTimeOfDay() != TIME_NIGHT)
pass = FALSE;
break;
}

if (formChanges[i].param3 != STATUS1_NONE && GetBoxMonData(boxMon, MON_DATA_STATUS, NULL) & formChanges[i].param3)
pass = FALSE;

if (pass)
targetSpecies = formChanges[i].targetSpecies;
}
break;
case FORM_CHANGE_ITEM_USE_MULTICHOICE:
Expand Down

0 comments on commit 568ce39

Please sign in to comment.