Form changing method for Shaymin Sky into Land at night (#1690)
* 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 <iasperbassoonian@gmail.com>
This commit is contained in:
parent
8981897c9b
commit
c46f9ec6a5
4 changed files with 48 additions and 5 deletions
|
@ -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
src/clock.c
19
src/clock.c
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
};
|
||||
|
||||
|
@ -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},
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue