From 5c86aa126f9b06b28bc4d97778ce37b6d577a4ad Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Fri, 6 Sep 2024 21:09:04 +0200 Subject: [PATCH] Revert rtc based encounters (#5331) * Revert "RTC-based wild encounters follow up (#5328)" This reverts commit 9a95c9b07a4084afe0e96fd5d4408777172be822. * Revert "RTC-based wild encounters (#5313)" This reverts commit 7c7fd905bae849bc1244a66545e10677fed763dd. --- include/config/overworld.h | 7 ----- include/wild_encounter.h | 1 - src/data/wild_encounters.json.txt | 2 -- src/wild_encounter.c | 45 ++----------------------------- tools/jsonproc/jsonproc.cpp | 21 --------------- 5 files changed, 2 insertions(+), 74 deletions(-) diff --git a/include/config/overworld.h b/include/config/overworld.h index 8be52abfb5..cebbe5b34b 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -74,13 +74,6 @@ #define OW_USE_FAKE_RTC FALSE // When TRUE, seconds on the in-game clock will only advance once every 60 playTimeVBlanks (every 60 frames). #define OW_ALTERED_TIME_RATIO GEN_LATEST // In GEN_8_PLA, the time in game moves forward 60 seconds for every second in the RTC. In GEN_9, it is 20 seconds. This has no effect if OW_USE_FAKE_RTC is FALSE. -// Time-based wild Pokemon encounters - Allows you to create additional encounter groups in wild_encounters.json (or in porymap). -// The groups are processed by base label's suffix. For example, "gRoute101" (no suffix) contains daytime encounters, and "gRoute101_Night" contains nighttime encounters. -// Not every group needs to be defined for every map - you could for example omit them inside caves and it would fall back to the unsuffixed daytime encounter group. -#define OW_TIME_BASED_WILD_ENCOUNTERS FALSE // Enables the system. If disabled, all suffixes are ignored and the first encounter group found for a map will be used for wild encounters. -#define OW_ENABLE_MORNING_WILD_ENCOUNTERS FALSE // If true, allows definition of morning encounter groups such as "gRoute101_Morning". Otherwise, morning is considered to be day for encounters. No effect if OW_TIME_BASED_WILD_ENCOUNTERS is false. -#define OW_ENABLE_EVENING_WILD_ENCOUNTERS FALSE // If true, allows definition of evening encounter groups such as "gRoute101_Evening". Otherwise, evening is considered to be night for encounters. No effect if OW_TIME_BASED_WILD_ENCOUNTERS is false. - // Overworld flags // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. // Eg: Replace with FLAG_UNUSED_0x264 so you can use that flag to toggle the feature. diff --git a/include/wild_encounter.h b/include/wild_encounter.h index fb0f5ab00e..63289f081c 100644 --- a/include/wild_encounter.h +++ b/include/wild_encounter.h @@ -20,7 +20,6 @@ struct WildPokemonHeader { u8 mapGroup; u8 mapNum; - u8 timeOfDay; const struct WildPokemonInfo *landMonsInfo; const struct WildPokemonInfo *waterMonsInfo; const struct WildPokemonInfo *rockSmashMonsInfo; diff --git a/src/data/wild_encounters.json.txt b/src/data/wild_encounters.json.txt index 55dd20cd52..bf848249f0 100755 --- a/src/data/wild_encounters.json.txt +++ b/src/data/wild_encounters.json.txt @@ -72,7 +72,6 @@ const struct WildPokemonHeader {{ wild_encounter_group.label }}[] = { .mapGroup = {% if wild_encounter_group.for_maps %}MAP_GROUP({{ removePrefix(encounter.map, "MAP_") }}){% else %}0{% endif %}, .mapNum = {% if wild_encounter_group.for_maps %}MAP_NUM({{ removePrefix(encounter.map, "MAP_") }}){% else %}{{ loop.index1 }}{% endif %}, - .timeOfDay = {% if stringEndsWith(encounter.base_label, "_Night") or stringContains(encounter.base_label, "_Night_") %}TIME_NIGHT{% else if stringEndsWith(encounter.base_label, "_Morning") or stringContains(encounter.base_label, "_Morning_") %}TIME_MORNING{% else if stringEndsWith(encounter.base_label, "_Evening") or stringContains(encounter.base_label, "_Evening_") %}TIME_EVENING{% else %}TIME_DAY{% endif %}, .landMonsInfo = {% if existsIn(encounter, "land_mons") %}&{{ encounter.base_label }}_LandMonsInfo{% else %}NULL{% endif %}, .waterMonsInfo = {% if existsIn(encounter, "water_mons") %}&{{ encounter.base_label }}_WaterMonsInfo{% else %}NULL{% endif %}, .rockSmashMonsInfo = {% if existsIn(encounter, "rock_smash_mons") %}&{{ encounter.base_label }}_RockSmashMonsInfo{% else %}NULL{% endif %}, @@ -82,7 +81,6 @@ const struct WildPokemonHeader {{ wild_encounter_group.label }}[] = { .mapGroup = MAP_GROUP(UNDEFINED), .mapNum = MAP_NUM(UNDEFINED), - .timeOfDay = TIME_DAY, .landMonsInfo = NULL, .waterMonsInfo = NULL, .rockSmashMonsInfo = NULL, diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 81721596ad..033eec56da 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -11,7 +11,6 @@ #include "pokeblock.h" #include "battle_setup.h" #include "roamer.h" -#include "rtc.h" #include "tv.h" #include "link.h" #include "script.h" @@ -355,32 +354,9 @@ static u8 ChooseWildMonLevel(const struct WildPokemon *wildPokemon, u8 wildMonIn } } -static bool32 IsExactTimeOfDayMatchForWildEncounters(u32 currentTimeOfDay, u32 encounterTimeOfDay) -{ - switch (currentTimeOfDay) - { - case TIME_MORNING: - if (OW_ENABLE_MORNING_WILD_ENCOUNTERS) - return encounterTimeOfDay == TIME_MORNING; - // fallthrough - case TIME_DAY: - return encounterTimeOfDay == TIME_DAY; - case TIME_EVENING: - if (OW_ENABLE_EVENING_WILD_ENCOUNTERS) - return encounterTimeOfDay == TIME_EVENING; - // fallthrough - case TIME_NIGHT: - return encounterTimeOfDay == TIME_NIGHT; - } - return FALSE; -} - static u16 GetCurrentMapWildMonHeaderId(void) { u16 i; - u8 currentTimeOfDay = GetTimeOfDay(); - u16 dayId = HEADER_NONE; - u16 nightId = HEADER_NONE; for (i = 0; ; i++) { @@ -399,30 +375,13 @@ static u16 GetCurrentMapWildMonHeaderId(void) alteringCaveId = 0; i += alteringCaveId; - return i; // Altering cave is not affected by time-of-day encounters. } - if (OW_TIME_BASED_WILD_ENCOUNTERS) - { - if (IsExactTimeOfDayMatchForWildEncounters(currentTimeOfDay, gWildMonHeaders[i].timeOfDay)) - return i; - else if (gWildMonHeaders[i].timeOfDay == TIME_DAY && dayId == HEADER_NONE) - dayId = i; - else if (gWildMonHeaders[i].timeOfDay == TIME_NIGHT && nightId == HEADER_NONE) - nightId = i; - } - else - return i; + return i; } } - if (!OW_TIME_BASED_WILD_ENCOUNTERS) - return HEADER_NONE; - - // Exact match for time of day was not found. We fall back to other encounter groups for this map - if (currentTimeOfDay == TIME_EVENING && OW_ENABLE_EVENING_WILD_ENCOUNTERS && nightId != HEADER_NONE) - return nightId; - return dayId; + return HEADER_NONE; } u8 PickWildMonNature(void) diff --git a/tools/jsonproc/jsonproc.cpp b/tools/jsonproc/jsonproc.cpp index 5e661e40d3..9ef23cd43e 100755 --- a/tools/jsonproc/jsonproc.cpp +++ b/tools/jsonproc/jsonproc.cpp @@ -118,27 +118,6 @@ int main(int argc, char *argv[]) return str; }); - env.add_callback("stringContains", 2, [](Arguments& args) { - string str = args.at(0)->get(); - string check = args.at(1)->get(); - - return str.find(check) != std::string::npos; - }); - - env.add_callback("stringStartsWith", 2, [](Arguments& args) { - string str = args.at(0)->get(); - string check = args.at(1)->get(); - - return str.find(check) == 0; - }); - - env.add_callback("stringEndsWith", 2, [](Arguments& args) { - string str = args.at(0)->get(); - string check = args.at(1)->get(); - - return str.rfind(check) == (str.length() - check.length()); - }); - try { env.write_with_json_file(templateFilepath, jsonfilepath, outputFilepath);