Merged FORM_ITEM_USE_TIME into FORM_ITEM_USE

This commit is contained in:
LOuroboros 2022-09-09 15:39:48 -03:00
parent 69d3fafdcf
commit 12fee71008
4 changed files with 30 additions and 33 deletions

View File

@ -322,9 +322,8 @@
#define FORM_ITEM_USE 2 #define FORM_ITEM_USE 2
#define FORM_MOVE 3 #define FORM_MOVE 3
#define FORM_WITHDRAW 4 #define FORM_WITHDRAW 4
#define FORM_ITEM_USE_TIME 5 #define FORM_BATTLE_BEGIN 5
#define FORM_BATTLE_BEGIN 6 #define FORM_BATTLE_END 6
#define FORM_BATTLE_END 7
#define NUM_MALE_LINK_FACILITY_CLASSES 8 #define NUM_MALE_LINK_FACILITY_CLASSES 8
#define NUM_FEMALE_LINK_FACILITY_CLASSES 8 #define NUM_FEMALE_LINK_FACILITY_CLASSES 8

View File

@ -9071,7 +9071,7 @@ const struct Item gItems[] =
.pocket = POCKET_KEY_ITEMS, .pocket = POCKET_KEY_ITEMS,
.type = ITEM_USE_PARTY_MENU, .type = ITEM_USE_PARTY_MENU,
.fieldUseFunc = ItemUseOutOfBattle_FormChange, .fieldUseFunc = ItemUseOutOfBattle_FormChange,
.secondaryId = FORM_ITEM_USE_TIME, .secondaryId = FORM_ITEM_USE,
}, },
[ITEM_REVEAL_GLASS] = [ITEM_REVEAL_GLASS] =

View File

@ -9,6 +9,8 @@ FORM_ITEM_HOLD:
FORM_ITEM_USE: FORM_ITEM_USE:
Form change activates when the item is used on the selected Pokémon. Form change activates when the item is used on the selected Pokémon.
param1 = item to use 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_MOVE:
Form change activates when the Pokémon learns or forgets the move. Form change activates when the Pokémon learns or forgets the move.
@ -20,13 +22,6 @@ FORM_WITHDRAW:
Form change activates when the Pokémon is withdrawn from the PC or Daycare. Form change activates when the Pokémon is withdrawn from the PC or Daycare.
no parameters 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_BATTLE_BEGIN:
Form change activates when the Pokémon is sent out at the beginning of a battle Form change activates when the Pokémon is sent out at the beginning of a battle
param1 = item to hold, optional param1 = item to hold, optional
@ -44,9 +39,9 @@ FORM_BATTLE_END:
#define WHEN_LEARNED 0 #define WHEN_LEARNED 0
#define WHEN_FORGOTTEN 1 #define WHEN_FORGOTTEN 1
// FORM_ITEM_USE_TIME param2 Arguments // FORM_ITEM_USE param2 Arguments
#define DAY 0 #define DAY 1
#define NIGHT 1 #define NIGHT 2
#if P_NEW_POKEMON == TRUE #if P_NEW_POKEMON == TRUE
static const struct FormChange sGiratinaFormChangeTable[] = { static const struct FormChange sGiratinaFormChangeTable[] = {
@ -56,7 +51,7 @@ static const struct FormChange sGiratinaFormChangeTable[] = {
}; };
static const struct FormChange sShayminFormChangeTable[] = { 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_WITHDRAW, SPECIES_SHAYMIN},
{FORM_CHANGE_END}, {FORM_CHANGE_END},
}; };

View File

@ -8273,30 +8273,33 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32
targetSpecies = formChanges[i].targetSpecies; targetSpecies = formChanges[i].targetSpecies;
break; break;
case FORM_ITEM_USE: case FORM_ITEM_USE:
RtcCalcLocalTime();
if (arg == formChanges[i].param1) if (arg == formChanges[i].param1)
targetSpecies = formChanges[i].targetSpecies; {
if (!formChanges[i].param2)
{
targetSpecies = formChanges[i].targetSpecies;
}
else
{
switch (formChanges[i].param2)
{
case DAY:
if (gLocalTime.hours >= 12 && gLocalTime.hours < 24)
targetSpecies = formChanges[i].targetSpecies;
break;
case NIGHT:
if (gLocalTime.hours >= 0 && gLocalTime.hours < 12)
targetSpecies = formChanges[i].targetSpecies;
break;
}
}
}
break; break;
case FORM_MOVE: case FORM_MOVE:
if (BoxMonKnowsMove(boxMon, formChanges[i].param1) != formChanges[i].param2) if (BoxMonKnowsMove(boxMon, formChanges[i].param1) != formChanges[i].param2)
targetSpecies = formChanges[i].targetSpecies; targetSpecies = formChanges[i].targetSpecies;
break; break;
case FORM_ITEM_USE_TIME:
RtcCalcLocalTime();
if (arg == formChanges[i].param1)
{
switch (formChanges[i].param2)
{
case DAY:
if (gLocalTime.hours >= 12 && gLocalTime.hours < 24)
targetSpecies = formChanges[i].targetSpecies;
break;
case NIGHT:
if (gLocalTime.hours >= 0 && gLocalTime.hours < 12)
targetSpecies = formChanges[i].targetSpecies;
break;
}
}
break;
case FORM_BATTLE_BEGIN: case FORM_BATTLE_BEGIN:
case FORM_BATTLE_END: case FORM_BATTLE_END:
if (heldItem == formChanges[i].param1 || formChanges[i].param1 == ITEM_NONE) if (heldItem == formChanges[i].param1 || formChanges[i].param1 == ITEM_NONE)