From 12fee71008028e30bfc3bc446034a1390403bf01 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 9 Sep 2022 15:39:48 -0300 Subject: [PATCH 1/2] Merged FORM_ITEM_USE_TIME into FORM_ITEM_USE --- include/constants/pokemon.h | 5 ++-- src/data/items.h | 2 +- src/data/pokemon/form_change_tables.h | 17 +++++------- src/pokemon.c | 39 ++++++++++++++------------- 4 files changed, 30 insertions(+), 33 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 6912cfe6bb..98b32ffd51 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -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 diff --git a/src/data/items.h b/src/data/items.h index 08060db773..6649fb24b6 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -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] = diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index ddcb4d9cbd..2531a10c9b 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -9,6 +9,8 @@ FORM_ITEM_HOLD: 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. @@ -20,13 +22,6 @@ FORM_WITHDRAW: 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 @@ -44,9 +39,9 @@ FORM_BATTLE_END: #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[] = { @@ -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}, }; diff --git a/src/pokemon.c b/src/pokemon.c index 722eaafe87..f735918083 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8273,30 +8273,33 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 targetSpecies = formChanges[i].targetSpecies; break; case FORM_ITEM_USE: + RtcCalcLocalTime(); 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; 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: - 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_END: if (heldItem == formChanges[i].param1 || formChanges[i].param1 == ITEM_NONE) From ceb0c67bcfc44ca202e22e9afa5638746a625bd8 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 9 Sep 2022 16:05:32 -0300 Subject: [PATCH 2/2] Modified check in case FORM_ITEM_USE of GetFormChangeTargetSpeciesBoxMon --- src/pokemon.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/pokemon.c b/src/pokemon.c index f735918083..b421e5aced 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -8273,26 +8273,23 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 targetSpecies = formChanges[i].targetSpecies; break; case FORM_ITEM_USE: - RtcCalcLocalTime(); if (arg == formChanges[i].param1) { - if (!formChanges[i].param2) + 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; - } - 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;