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

Add config for times of day #3579

Merged
merged 5 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/config/overworld.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

// Other settings
#define OW_POISON_DAMAGE GEN_LATEST // In Gen4, Pokémon no longer faint from Poison in the overworld. In Gen5+, they no longer take damage at all.
#define OW_TIMES_OF_DAY GEN_LATEST // Different generations have the times of day change at different times

// PC settings
#define OW_PC_PRESS_B GEN_LATEST // In Gen4, pressing B when holding a Pokémon is equivalent to placing it. In Gen3, it gives the "You're holding a Pokémon!" error.
Expand Down
72 changes: 63 additions & 9 deletions include/rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,75 @@

#define RTC_ERR_FLAG_MASK 0x0FF0

#define MORNING_EVO_HOUR_BEGIN 6
#define MORNING_EVO_HOUR_END 10
//Morning and evening don't exist in Gen 3
#if OW_TIMES_OF_DAY == GEN_3
#define MORNING_HOUR_BEGIN 0
#define MORNING_HOUR_END 0

#define DAY_EVO_HOUR_BEGIN 10
#define DAY_EVO_HOUR_END 19
#define DAY_HOUR_BEGIN 12
#define DAY_HOUR_END HOURS_PER_DAY

#define DUSK_EVO_HOUR_BEGIN 19
#define DUSK_EVO_HOUR_END 20
#define EVENING_HOUR_BEGIN 0
#define EVENING_HOUR_END 0

#define NIGHT_EVO_HOUR_BEGIN 20
#define NIGHT_EVO_HOUR_END 6
#define NIGHT_HOUR_BEGIN 0
#define NIGHT_HOUR_END 12
//Evening doesn't exist in Gen 4
#elif OW_TIMES_OF_DAY == GEN_4
#define MORNING_HOUR_BEGIN 4
#define MORNING_HOUR_END 10

#define DAY_HOUR_BEGIN 10
#define DAY_HOUR_END 20

#define EVENING_HOUR_BEGIN 0
#define EVENING_HOUR_END 0

#define NIGHT_HOUR_BEGIN 20
#define NIGHT_HOUR_END 4
//Gen 5 currently not included as the seasons change the times of day
#elif OW_TIMES_OF_DAY <= GEN_6
#define MORNING_HOUR_BEGIN 4
#define MORNING_HOUR_END 11

#define DAY_HOUR_BEGIN 11
#define DAY_HOUR_END 18

#define EVENING_HOUR_BEGIN 18
#define EVENING_HOUR_END 21

#define NIGHT_HOUR_BEGIN 21
#define NIGHT_HOUR_END 4
//These are the Sun/Ultra Sun times
#elif OW_TIMES_OF_DAY == GEN_7
#define MORNING_HOUR_BEGIN 6
#define MORNING_HOUR_END 10

#define DAY_HOUR_BEGIN 10
#define DAY_HOUR_END 17

#define EVENING_HOUR_BEGIN 17
#define EVENING_HOUR_END 18

#define NIGHT_HOUR_BEGIN 18
#define NIGHT_HOUR_END 6
#elif OW_TIMES_OF_DAY >= GEN_8
#define MORNING_HOUR_BEGIN 6
#define MORNING_HOUR_END 10

#define DAY_HOUR_BEGIN 10
#define DAY_HOUR_END 19

#define EVENING_HOUR_BEGIN 19
#define EVENING_HOUR_END 20

#define NIGHT_HOUR_BEGIN 20
#define NIGHT_HOUR_END 6
#endif

#define TIME_MORNING 0
#define TIME_DAY 1
#define TIME_DUSK 2
#define TIME_EVENING 2
#define TIME_NIGHT 3

extern struct Time gLocalTime;
Expand Down
2 changes: 1 addition & 1 deletion src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -14858,7 +14858,7 @@ static void Cmd_handleballthrow(void)
ballMultiplier = 400;
break;
case ITEM_DUSK_BALL:
if ((GetTimeOfDay() == TIME_DUSK || GetTimeOfDay() == TIME_NIGHT) || gMapHeader.cave || gMapHeader.mapType == MAP_TYPE_UNDERGROUND)
if ((GetTimeOfDay() == TIME_EVENING || GetTimeOfDay() == TIME_NIGHT) || gMapHeader.cave || gMapHeader.mapType == MAP_TYPE_UNDERGROUND)
ballMultiplier = (B_DUSK_BALL_MODIFIER >= GEN_7 ? 300 : 350);
break;
case ITEM_QUICK_BALL:
Expand Down
2 changes: 1 addition & 1 deletion src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -7076,7 +7076,7 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, s
}
break;
case EVO_LEVEL_DUSK:
if (GetTimeOfDay() == TIME_DUSK && gEvolutionTable[species][i].param <= level)
if (GetTimeOfDay() == TIME_EVENING && gEvolutionTable[species][i].param <= level)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_LEVEL:
Expand Down
8 changes: 4 additions & 4 deletions src/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,11 @@ bool8 IsBetweenHours(s32 hours, s32 begin, s32 end)
u8 GetTimeOfDay(void)
{
RtcCalcLocalTime();
if (IsBetweenHours(gLocalTime.hours, MORNING_EVO_HOUR_BEGIN, MORNING_EVO_HOUR_END))
if (IsBetweenHours(gLocalTime.hours, MORNING_HOUR_BEGIN, MORNING_HOUR_END))
return TIME_MORNING;
else if (IsBetweenHours(gLocalTime.hours, DUSK_EVO_HOUR_BEGIN, DUSK_EVO_HOUR_END))
return TIME_DUSK;
else if (IsBetweenHours(gLocalTime.hours, NIGHT_EVO_HOUR_BEGIN, NIGHT_EVO_HOUR_END))
else if (IsBetweenHours(gLocalTime.hours, EVENING_HOUR_BEGIN, EVENING_HOUR_END))
return TIME_EVENING;
else if (IsBetweenHours(gLocalTime.hours, NIGHT_HOUR_BEGIN, NIGHT_HOUR_END))
return TIME_NIGHT;
return TIME_DAY;
}
Expand Down
Loading