Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form changing method for Shaymin Sky into Land at night #1690

Merged
merged 9 commits into from
Nov 16, 2023
10 changes: 9 additions & 1 deletion include/constants/form_change_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,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 @@ -407,8 +408,8 @@ static const struct FormChange sLandorusFormChangeTable[] = {
};

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 @@ -9088,6 +9088,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
Loading