Skip to content

Commit

Permalink
Form changing method for Shaymin Sky into Land at night (rh-hideout#1690
Browse files Browse the repository at this point in the history
)

* Form changing method for Shaymin Sky into Land at night

* Ordered form change tables

* Refactored form change type to support both night and day

* Removed added space

---------

Co-authored-by: Bassoonian <[email protected]>
  • Loading branch information
2 people authored and PCG06 committed Dec 8, 2023
1 parent 51366bb commit 179cec4
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
10 changes: 9 additions & 1 deletion include/constants/form_change_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@
// - No parameters
#define FORM_CHANGE_BATTLE_GIGANTAMAX 17

#define FORM_CHANGE_ITEM_USE_MULTICHOICE 18
// Form change that activates at a certain time of day in the overworld automatically.
// param1: time of day to check.
// - DAY if Form change that activates in the daytime.
// - NIGHT if Form change that activates at nighttime.
#define FORM_CHANGE_TIME_OF_DAY 18

// Form change that depends on a multichoice (e.g. Rotom Catalog).
// param2: multichoice list (starting at 0).
#define FORM_CHANGE_ITEM_USE_MULTICHOICE 19

#endif // GUARD_CONSTANTS_FORM_CHANGE_TYPES_H
19 changes: 19 additions & 0 deletions src/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
#include "main.h"
#include "overworld.h"
#include "wallclock.h"
#include "constants/form_change_types.h"

static void UpdatePerDay(struct Time *localTime);
static void UpdatePerMinute(struct Time *localTime);
static void FormChangeTimeUpdate();

void InitTimeBasedEvents(void)
{
Expand Down Expand Up @@ -69,6 +71,23 @@ static void UpdatePerMinute(struct Time *localTime)
{
BerryTreeTimeUpdate(minutes);
gSaveBlock2Ptr->lastBerryTreeUpdate = *localTime;
FormChangeTimeUpdate();
}
}
}

static void FormChangeTimeUpdate()
{
s32 i;
for (i = 0; i < PARTY_SIZE; i++)
{
struct Pokemon *mon = &gPlayerParty[i];
u16 targetSpecies = GetFormChangeTargetSpecies(mon, FORM_CHANGE_TIME_OF_DAY, 0);

if (targetSpecies != SPECIES_NONE)
{
SetMonData(mon, MON_DATA_SPECIES, &targetSpecies);
CalculateMonStats(mon);
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/data/pokemon/form_change_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,9 @@ static const struct FormChange sGiratinaFormChangeTable[] = {
};

static const struct FormChange sShayminFormChangeTable[] = {
{FORM_CHANGE_ITEM_USE, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, DAY},
// {FORM_CHANGE_WITHDRAW, SPECIES_SHAYMIN_LAND},
{FORM_CHANGE_ITEM_USE, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, DAY},
{FORM_CHANGE_WITHDRAW, SPECIES_SHAYMIN_LAND},
{FORM_CHANGE_TIME_OF_DAY, SPECIES_SHAYMIN_LAND, NIGHT},
{FORM_CHANGE_TERMINATOR},
};

Expand Down Expand Up @@ -413,8 +414,8 @@ static const struct Fusion sKyuremFusionTable[] = {
};

static const struct FormChange sKeldeoFormChangeTable[] = {
// {FORM_CHANGE_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD, WHEN_LEARNED},
// {FORM_CHANGE_MOVE, SPECIES_KELDEO_ORDINARY, MOVE_SECRET_SWORD, WHEN_FORGOTTEN},
{FORM_CHANGE_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD, WHEN_LEARNED},
{FORM_CHANGE_MOVE, SPECIES_KELDEO_ORDINARY, MOVE_SECRET_SWORD, WHEN_FORGOTTEN},
{FORM_CHANGE_TERMINATOR},
};

Expand Down
15 changes: 15 additions & 0 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -9179,6 +9179,21 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32
case FORM_CHANGE_FAINT:
targetSpecies = formChanges[i].targetSpecies;
break;
case FORM_CHANGE_TIME_OF_DAY:
switch (formChanges[i].param1)
{
case DAY:
RtcCalcLocalTime();
if (gLocalTime.hours >= DAY_EVO_HOUR_BEGIN && gLocalTime.hours < DAY_EVO_HOUR_END)
targetSpecies = formChanges[i].targetSpecies;
break;
case NIGHT:
RtcCalcLocalTime();
if (gLocalTime.hours >= NIGHT_EVO_HOUR_BEGIN && gLocalTime.hours < NIGHT_EVO_HOUR_END)
targetSpecies = formChanges[i].targetSpecies;
break;
}
break;
}
}
}
Expand Down

0 comments on commit 179cec4

Please sign in to comment.