Skip to content

Commit

Permalink
Merge pull request #2304 from LOuroboros/shashaForms
Browse files Browse the repository at this point in the history
Merged FORM_ITEM_USE_TIME into FORM_ITEM_USE
  • Loading branch information
AsparagusEduardo authored Sep 9, 2022
2 parents 69d3faf + ceb0c67 commit 6e7f139
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
5 changes: 2 additions & 3 deletions include/constants/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,8 @@
#define FORM_ITEM_USE 2
#define FORM_MOVE 3
#define FORM_WITHDRAW 4
#define FORM_ITEM_USE_TIME 5
#define FORM_BATTLE_BEGIN 6
#define FORM_BATTLE_END 7
#define FORM_BATTLE_BEGIN 5
#define FORM_BATTLE_END 6

#define NUM_MALE_LINK_FACILITY_CLASSES 8
#define NUM_FEMALE_LINK_FACILITY_CLASSES 8
Expand Down
2 changes: 1 addition & 1 deletion src/data/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -9071,7 +9071,7 @@ const struct Item gItems[] =
.pocket = POCKET_KEY_ITEMS,
.type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_FormChange,
.secondaryId = FORM_ITEM_USE_TIME,
.secondaryId = FORM_ITEM_USE,
},

[ITEM_REVEAL_GLASS] =
Expand Down
17 changes: 6 additions & 11 deletions src/data/pokemon/form_change_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
FORM_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 activates when the Pokémon learns or forgets the move.
Expand All @@ -20,13 +22,6 @@
Form change activates when the Pokémon is withdrawn from the PC or Daycare.
no parameters
FORM_ITEM_USE_TIME:
Form change activates when the item is used on the selected Pokémon at the
appropriate time of day.
param1 = item to use
param2 = DAY if form change activates in the daytime
NIGHT if form change activates at nighttime
FORM_BATTLE_BEGIN:
Form change activates when the Pokémon is sent out at the beginning of a battle
param1 = item to hold, optional
Expand All @@ -44,9 +39,9 @@
#define WHEN_LEARNED 0
#define WHEN_FORGOTTEN 1

// FORM_ITEM_USE_TIME param2 Arguments
#define DAY 0
#define NIGHT 1
// FORM_ITEM_USE param2 Arguments
#define DAY 1
#define NIGHT 2

#if P_NEW_POKEMON == TRUE
static const struct FormChange sGiratinaFormChangeTable[] = {
Expand All @@ -56,7 +51,7 @@ static const struct FormChange sGiratinaFormChangeTable[] = {
};

static const struct FormChange sShayminFormChangeTable[] = {
{FORM_ITEM_USE_TIME, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, DAY},
{FORM_ITEM_USE, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, DAY},
// {FORM_WITHDRAW, SPECIES_SHAYMIN},
{FORM_CHANGE_END},
};
Expand Down
18 changes: 9 additions & 9 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -8273,30 +8273,30 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32
targetSpecies = formChanges[i].targetSpecies;
break;
case FORM_ITEM_USE:
if (arg == formChanges[i].param1)
targetSpecies = formChanges[i].targetSpecies;
break;
case FORM_MOVE:
if (BoxMonKnowsMove(boxMon, formChanges[i].param1) != formChanges[i].param2)
targetSpecies = formChanges[i].targetSpecies;
break;
case FORM_ITEM_USE_TIME:
RtcCalcLocalTime();
if (arg == formChanges[i].param1)
{
switch (formChanges[i].param2)
{
case DAY:
RtcCalcLocalTime();
if (gLocalTime.hours >= 12 && gLocalTime.hours < 24)
targetSpecies = formChanges[i].targetSpecies;
break;
case NIGHT:
RtcCalcLocalTime();
if (gLocalTime.hours >= 0 && gLocalTime.hours < 12)
targetSpecies = formChanges[i].targetSpecies;
break;
default:
targetSpecies = formChanges[i].targetSpecies;
break;
}
}
break;
case FORM_MOVE:
if (BoxMonKnowsMove(boxMon, formChanges[i].param1) != formChanges[i].param2)
targetSpecies = formChanges[i].targetSpecies;
break;
case FORM_BATTLE_BEGIN:
case FORM_BATTLE_END:
if (heldItem == formChanges[i].param1 || formChanges[i].param1 == ITEM_NONE)
Expand Down

0 comments on commit 6e7f139

Please sign in to comment.