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
1 change: 1 addition & 0 deletions include/constants/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@
#define FORM_WITHDRAW 4
#define FORM_ITEM_HOLD_ABILITY 5
#define FORM_ITEM_USE_TIME 6
#define FORM_TIME 7

#define NUM_MALE_LINK_FACILITY_CLASSES 8
#define NUM_FEMALE_LINK_FACILITY_CLASSES 8
Expand Down
20 changes: 20 additions & 0 deletions src/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

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

static void InitTimeBasedEvents(void)
{
Expand Down Expand Up @@ -69,10 +70,29 @@ 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 species = GetMonData(mon, MON_DATA_SPECIES);
u16 targetSpecies = GetFormChangeTargetSpecies(mon, FORM_TIME, 0);

if (targetSpecies != SPECIES_NONE)
{
SetMonData(mon, MON_DATA_SPECIES, &targetSpecies);
CalculateMonStats(mon);
}
}

}

static void ReturnFromStartWallClock(void)
{
InitTimeBasedEvents();
Expand Down
118 changes: 59 additions & 59 deletions src/data/pokemon/form_change_table_pointers.h
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] =
{
[SPECIES_GIRATINA] = sGiratinaFormChangeTable,
[SPECIES_GIRATINA_ORIGIN] = sGiratinaFormChangeTable,
[SPECIES_SHAYMIN] = sShayminFormChangeTable,
[SPECIES_SHAYMIN_SKY] = sShayminSkyFormChangeTable,
[SPECIES_ARCEUS] = sArceusFormChangeTable,
[SPECIES_ARCEUS_FIGHTING] = sArceusFormChangeTable,
[SPECIES_ARCEUS_FLYING] = sArceusFormChangeTable,
[SPECIES_ARCEUS_POISON] = sArceusFormChangeTable,
[SPECIES_ARCEUS_ROCK] = sArceusFormChangeTable,
[SPECIES_ARCEUS_GROUND] = sArceusFormChangeTable,
[SPECIES_ARCEUS_BUG] = sArceusFormChangeTable,
[SPECIES_ARCEUS_GHOST] = sArceusFormChangeTable,
[SPECIES_ARCEUS_STEEL] = sArceusFormChangeTable,
[SPECIES_ARCEUS_FIRE] = sArceusFormChangeTable,
[SPECIES_ARCEUS_WATER] = sArceusFormChangeTable,
[SPECIES_ARCEUS_GRASS] = sArceusFormChangeTable,
[SPECIES_ARCEUS_ELECTRIC] = sArceusFormChangeTable,
[SPECIES_ARCEUS_PSYCHIC] = sArceusFormChangeTable,
[SPECIES_ARCEUS_ICE] = sArceusFormChangeTable,
[SPECIES_ARCEUS_DRAGON] = sArceusFormChangeTable,
[SPECIES_ARCEUS_DARK] = sArceusFormChangeTable,
[SPECIES_ARCEUS_FAIRY] = sArceusFormChangeTable,
[SPECIES_TORNADUS] = sTornadusFormChangeTable,
[SPECIES_TORNADUS_THERIAN] = sTornadusTherianFormChangeTable,
[SPECIES_THUNDURUS] = sThundurusFormChangeTable,
[SPECIES_THUNDURUS_THERIAN] = sThundurusTherianFormChangeTable,
[SPECIES_LANDORUS] = sLandorusFormChangeTable,
[SPECIES_LANDORUS_THERIAN] = sLandorusTherianFormChangeTable,
[SPECIES_KELDEO] = sKeldeoFormChangeTable,
[SPECIES_KELDEO_RESOLUTE] = sKeldeoResoluteFormChangeTable,
[SPECIES_GENESECT] = sGenesectFormChangeTable,
[SPECIES_GENESECT_DOUSE_DRIVE] = sGenesectFormChangeTable,
[SPECIES_GENESECT_SHOCK_DRIVE] = sGenesectFormChangeTable,
[SPECIES_GENESECT_BURN_DRIVE] = sGenesectFormChangeTable,
[SPECIES_GENESECT_CHILL_DRIVE] = sGenesectFormChangeTable,
[SPECIES_HOOPA] = sHoopaFormChangeTable,
[SPECIES_HOOPA_UNBOUND] = sHoopaUnboundFormChangeTable,
[SPECIES_ORICORIO] = sOricorioFormChangeTable,
[SPECIES_ORICORIO_POM_POM] = sOricorioFormChangeTable,
[SPECIES_ORICORIO_PAU] = sOricorioFormChangeTable,
[SPECIES_ORICORIO_SENSU] = sOricorioFormChangeTable,
[SPECIES_SILVALLY] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_BUG] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_DARK] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_DRAGON] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_ELECTRIC] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_FAIRY] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_FIGHTING] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_FIRE] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_FLYING] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_GHOST] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_GRASS] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_GROUND] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_ICE] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_POISON] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_PSYCHIC] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_ROCK] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_STEEL] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_WATER] = sSilvallyFormChangeTable,
[SPECIES_GIRATINA] = sGiratinaFormChangeTable,
[SPECIES_GIRATINA_ORIGIN] = sGiratinaFormChangeTable,
[SPECIES_SHAYMIN] = sShayminFormChangeTable,
[SPECIES_SHAYMIN_SKY] = sShayminFormChangeTable,
[SPECIES_ARCEUS] = sArceusFormChangeTable,
[SPECIES_ARCEUS_FIGHTING] = sArceusFormChangeTable,
[SPECIES_ARCEUS_FLYING] = sArceusFormChangeTable,
[SPECIES_ARCEUS_POISON] = sArceusFormChangeTable,
[SPECIES_ARCEUS_ROCK] = sArceusFormChangeTable,
[SPECIES_ARCEUS_GROUND] = sArceusFormChangeTable,
[SPECIES_ARCEUS_BUG] = sArceusFormChangeTable,
[SPECIES_ARCEUS_GHOST] = sArceusFormChangeTable,
[SPECIES_ARCEUS_STEEL] = sArceusFormChangeTable,
[SPECIES_ARCEUS_FIRE] = sArceusFormChangeTable,
[SPECIES_ARCEUS_WATER] = sArceusFormChangeTable,
[SPECIES_ARCEUS_GRASS] = sArceusFormChangeTable,
[SPECIES_ARCEUS_ELECTRIC] = sArceusFormChangeTable,
[SPECIES_ARCEUS_PSYCHIC] = sArceusFormChangeTable,
[SPECIES_ARCEUS_ICE] = sArceusFormChangeTable,
[SPECIES_ARCEUS_DRAGON] = sArceusFormChangeTable,
[SPECIES_ARCEUS_DARK] = sArceusFormChangeTable,
[SPECIES_ARCEUS_FAIRY] = sArceusFormChangeTable,
[SPECIES_TORNADUS] = sTornadusFormChangeTable,
[SPECIES_TORNADUS_THERIAN] = sTornadusFormChangeTable,
[SPECIES_THUNDURUS] = sThundurusFormChangeTable,
[SPECIES_THUNDURUS_THERIAN] = sThundurusFormChangeTable,
[SPECIES_LANDORUS] = sLandorusFormChangeTable,
[SPECIES_LANDORUS_THERIAN] = sLandorusFormChangeTable,
[SPECIES_KELDEO] = sKeldeoFormChangeTable,
[SPECIES_KELDEO_RESOLUTE] = sKeldeoFormChangeTable,
[SPECIES_GENESECT] = sGenesectFormChangeTable,
[SPECIES_GENESECT_DOUSE_DRIVE] = sGenesectFormChangeTable,
[SPECIES_GENESECT_SHOCK_DRIVE] = sGenesectFormChangeTable,
[SPECIES_GENESECT_BURN_DRIVE] = sGenesectFormChangeTable,
[SPECIES_GENESECT_CHILL_DRIVE] = sGenesectFormChangeTable,
[SPECIES_HOOPA] = sHoopaFormChangeTable,
[SPECIES_HOOPA_UNBOUND] = sHoopaFormChangeTable,
[SPECIES_ORICORIO] = sOricorioFormChangeTable,
[SPECIES_ORICORIO_POM_POM] = sOricorioFormChangeTable,
[SPECIES_ORICORIO_PAU] = sOricorioFormChangeTable,
[SPECIES_ORICORIO_SENSU] = sOricorioFormChangeTable,
[SPECIES_SILVALLY] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_BUG] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_DARK] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_DRAGON] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_ELECTRIC] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_FAIRY] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_FIGHTING] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_FIRE] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_FLYING] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_GHOST] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_GRASS] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_GROUND] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_ICE] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_POISON] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_PSYCHIC] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_ROCK] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_STEEL] = sSilvallyFormChangeTable,
[SPECIES_SILVALLY_WATER] = sSilvallyFormChangeTable,
};
45 changes: 14 additions & 31 deletions src/data/pokemon/form_change_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@
param1 = item to use
param2 = DAY if form change activates in the daytime
NIGHT if form change activates at nighttime

FORM_TIME:
Form change activates when the Pokémon is in the party at the appropriate
time of day.
param1 = DAY if form change activates in the daytime
NIGHT if form change activates at nighttime
*/

// FORM_MOVE param2 Arguments
#define WHEN_LEARNED 0
#define WHEN_FORGOTTEN 1

// FORM_ITEM_USE_TIME param2 Arguments
// FORM_ITEM_USE_TIME and FORM_TIME param Arguments
#define DAY 0
#define NIGHT 1

Expand All @@ -46,12 +52,9 @@ static const struct FormChange sGiratinaFormChangeTable[] = {
};

static const struct FormChange sShayminFormChangeTable[] = {
{FORM_ITEM_USE_TIME, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, DAY},
{FORM_CHANGE_END},
};

static const struct FormChange sShayminSkyFormChangeTable[] = {
{FORM_TIME, SPECIES_SHAYMIN, NIGHT},
{FORM_WITHDRAW, SPECIES_SHAYMIN},
{FORM_ITEM_USE_TIME, SPECIES_SHAYMIN_SKY, ITEM_GRACIDEA, DAY},
{FORM_CHANGE_END},
};

Expand Down Expand Up @@ -95,42 +98,26 @@ static const struct FormChange sArceusFormChangeTable[] = {
};

static const struct FormChange sTornadusFormChangeTable[] = {
// {FORM_ITEM_USE, SPECIES_TORNADUS_THERIAN, ITEM_REVEAL_GLASS},
{FORM_CHANGE_END},
};

static const struct FormChange sTornadusTherianFormChangeTable[] = {
// {FORM_ITEM_USE, SPECIES_TORNADUS, ITEM_REVEAL_GLASS},
// {FORM_ITEM_USE, SPECIES_TORNADUS_THERIAN, ITEM_REVEAL_GLASS},
{FORM_CHANGE_END},
};

static const struct FormChange sThundurusFormChangeTable[] = {
// {FORM_ITEM_USE, SPECIES_THUNDURUS_THERIAN, ITEM_REVEAL_GLASS},
{FORM_CHANGE_END},
};

static const struct FormChange sThundurusTherianFormChangeTable[] = {
// {FORM_ITEM_USE, SPECIES_THUNDURUS, ITEM_REVEAL_GLASS},
// {FORM_ITEM_USE, SPECIES_THUNDURUS_THERIAN, ITEM_REVEAL_GLASS},
{FORM_CHANGE_END},
};

static const struct FormChange sLandorusFormChangeTable[] = {
// {FORM_ITEM_USE, SPECIES_LANDORUS_THERIAN, ITEM_REVEAL_GLASS},
{FORM_CHANGE_END},
};

static const struct FormChange sLandorusTherianFormChangeTable[] = {
// {FORM_ITEM_USE, SPECIES_LANDORUS, ITEM_REVEAL_GLASS},
// {FORM_ITEM_USE, SPECIES_LANDORUS_THERIAN, ITEM_REVEAL_GLASS},
{FORM_CHANGE_END},
};

static const struct FormChange sKeldeoFormChangeTable[] = {
{FORM_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD, WHEN_LEARNED},
{FORM_CHANGE_END},
};

static const struct FormChange sKeldeoResoluteFormChangeTable[] = {
{FORM_MOVE, SPECIES_KELDEO, MOVE_SECRET_SWORD, WHEN_FORGOTTEN},
{FORM_MOVE, SPECIES_KELDEO_RESOLUTE, MOVE_SECRET_SWORD, WHEN_LEARNED},
{FORM_CHANGE_END},
};

Expand All @@ -144,12 +131,8 @@ static const struct FormChange sGenesectFormChangeTable[] = {
};

static const struct FormChange sHoopaFormChangeTable[] = {
// {FORM_ITEM_USE, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA},
{FORM_CHANGE_END},
};

static const struct FormChange sHoopaUnboundFormChangeTable[] = {
{FORM_WITHDRAW, SPECIES_HOOPA},
// {FORM_ITEM_USE, SPECIES_HOOPA_UNBOUND, ITEM_PRISON_BOTTLE, SPECIES_HOOPA},
{FORM_CHANGE_END},
};

Expand Down
14 changes: 14 additions & 0 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -8254,6 +8254,20 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *mon, u16 method, u32 arg
}
}
break;
case FORM_TIME:
RtcCalcLocalTime();
switch (formChanges[i].param1)
{
case DAY:
if (gLocalTime.hours >= 12 && gLocalTime.hours < 24)
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved
targetSpecies = formChanges[i].targetSpecies;
break;
case NIGHT:
if (gLocalTime.hours >= 0 && gLocalTime.hours < 12)
targetSpecies = formChanges[i].targetSpecies;
break;
}
break;
}
}
}
Expand Down