From f9a8a0251a886f0799dd4ef8eca751a8fa7bf136 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 25 Sep 2025 14:16:33 -0300 Subject: [PATCH] Added regional form evolution condition (#6990) --- include/constants/pokemon.h | 2 + .../pokemon/species_info/gen_1_families.h | 20 +++++----- .../pokemon/species_info/gen_2_families.h | 6 +-- .../pokemon/species_info/gen_5_families.h | 12 +++--- .../pokemon/species_info/gen_6_families.h | 8 ++-- .../pokemon/species_info/gen_7_families.h | 4 +- src/pokedex_plus_hgss.c | 38 ++++++++++++++++--- src/pokemon.c | 9 +++++ 8 files changed, 69 insertions(+), 30 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 20cff8a30f..9e0698b75d 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -300,6 +300,8 @@ enum EvolutionConditions { IF_PID_MODULO_100_LT, // The Pokémon's personality value's modulo by 100 is lower than the defined value. IF_MIN_OVERWORLD_STEPS, // The Player has taken a specific amount of steps in the overworld with the Pokémon following them or in the first slot of the party. IF_BAG_ITEM_COUNT, // The Player has the specific amount of an item in the bag. It then removes those items. + IF_REGION, // The Player is in the specific region. + IF_NOT_REGION, // The Player is NOT in the specific region. CONDITIONS_END }; diff --git a/src/data/pokemon/species_info/gen_1_families.h b/src/data/pokemon/species_info/gen_1_families.h index 1b0e94aa13..a661147349 100644 --- a/src/data/pokemon/species_info/gen_1_families.h +++ b/src/data/pokemon/species_info/gen_1_families.h @@ -2949,8 +2949,8 @@ const struct SpeciesInfo gSpeciesInfoGen1[] = .teachableLearnset = sPikachuTeachableLearnset, .formSpeciesIdTable = sPikachuFormSpeciesIdTable, .formChangeTable = sPikachuFormChangeTable, - .evolutions = EVOLUTION({EVO_ITEM, ITEM_THUNDER_STONE, SPECIES_RAICHU}, - {EVO_NONE, 0, SPECIES_RAICHU_ALOLA}), + .evolutions = EVOLUTION({EVO_ITEM, ITEM_THUNDER_STONE, SPECIES_RAICHU, CONDITIONS({IF_NOT_REGION, REGION_ALOLA})}, + {EVO_ITEM, ITEM_THUNDER_STONE, SPECIES_RAICHU_ALOLA, CONDITIONS({IF_REGION, REGION_ALOLA})}), }, #if P_COSPLAY_PIKACHU_FORMS @@ -13022,8 +13022,8 @@ const struct SpeciesInfo gSpeciesInfoGen1[] = .levelUpLearnset = sExeggcuteLevelUpLearnset, .teachableLearnset = sExeggcuteTeachableLearnset, .eggMoveLearnset = sExeggcuteEggMoveLearnset, - .evolutions = EVOLUTION({EVO_ITEM, ITEM_LEAF_STONE, SPECIES_EXEGGUTOR}, - {EVO_NONE, 0, SPECIES_EXEGGUTOR_ALOLA}), + .evolutions = EVOLUTION({EVO_ITEM, ITEM_LEAF_STONE, SPECIES_EXEGGUTOR, CONDITIONS({IF_NOT_REGION, REGION_ALOLA})}, + {EVO_ITEM, ITEM_LEAF_STONE, SPECIES_EXEGGUTOR_ALOLA, CONDITIONS({IF_REGION, REGION_ALOLA})}), }, #if P_UPDATED_EXP_YIELDS >= GEN_7 @@ -13249,8 +13249,8 @@ const struct SpeciesInfo gSpeciesInfoGen1[] = .levelUpLearnset = sCuboneLevelUpLearnset, .teachableLearnset = sCuboneTeachableLearnset, .eggMoveLearnset = sCuboneEggMoveLearnset, - .evolutions = EVOLUTION({EVO_LEVEL, 28, SPECIES_MAROWAK}, - {EVO_NONE, 0, SPECIES_MAROWAK_ALOLA}, + .evolutions = EVOLUTION({EVO_LEVEL, 28, SPECIES_MAROWAK, CONDITIONS({IF_NOT_REGION, REGION_ALOLA})}, + {EVO_LEVEL, 28, SPECIES_MAROWAK_ALOLA, CONDITIONS({IF_REGION, REGION_ALOLA}, {IF_TIME, TIME_NIGHT})}, {EVO_NONE, 0, SPECIES_MAROWAK_ALOLA_TOTEM}), }, @@ -13982,8 +13982,8 @@ const struct SpeciesInfo gSpeciesInfoGen1[] = .levelUpLearnset = sKoffingLevelUpLearnset, .teachableLearnset = sKoffingTeachableLearnset, .eggMoveLearnset = sKoffingEggMoveLearnset, - .evolutions = EVOLUTION({EVO_LEVEL, 35, SPECIES_WEEZING}, - {EVO_NONE, 0, SPECIES_WEEZING_GALAR}), + .evolutions = EVOLUTION({EVO_LEVEL, 35, SPECIES_WEEZING, CONDITIONS({IF_NOT_REGION, REGION_GALAR})}, + {EVO_LEVEL, 35, SPECIES_WEEZING_GALAR, CONDITIONS({IF_REGION, REGION_GALAR})}), }, [SPECIES_WEEZING] = @@ -15555,8 +15555,8 @@ const struct SpeciesInfo gSpeciesInfoGen1[] = .levelUpLearnset = sMimeJrLevelUpLearnset, .teachableLearnset = sMimeJrTeachableLearnset, .eggMoveLearnset = sMimeJrEggMoveLearnset, - .evolutions = EVOLUTION({EVO_LEVEL, 0, SPECIES_MR_MIME, CONDITIONS({IF_KNOWS_MOVE, MOVE_MIMIC})}, - {EVO_NONE, 0, SPECIES_MR_MIME_GALAR}), + .evolutions = EVOLUTION({EVO_LEVEL, 0, SPECIES_MR_MIME, CONDITIONS({IF_KNOWS_MOVE, MOVE_MIMIC}, {IF_NOT_REGION, REGION_GALAR})}, + {EVO_LEVEL, 0, SPECIES_MR_MIME_GALAR, CONDITIONS({IF_KNOWS_MOVE, MOVE_MIMIC}, {IF_REGION, REGION_GALAR})}), }, #endif //P_GEN_4_CROSS_EVOS diff --git a/src/data/pokemon/species_info/gen_2_families.h b/src/data/pokemon/species_info/gen_2_families.h index f95197332a..98e856aae5 100644 --- a/src/data/pokemon/species_info/gen_2_families.h +++ b/src/data/pokemon/species_info/gen_2_families.h @@ -364,8 +364,8 @@ const struct SpeciesInfo gSpeciesInfoGen2[] = ) .levelUpLearnset = sQuilavaLevelUpLearnset, .teachableLearnset = sQuilavaTeachableLearnset, - .evolutions = EVOLUTION({EVO_LEVEL, 36, SPECIES_TYPHLOSION}, - {EVO_NONE, 0, SPECIES_TYPHLOSION_HISUI}), + .evolutions = EVOLUTION({EVO_LEVEL, 36, SPECIES_TYPHLOSION, CONDITIONS({IF_NOT_REGION, REGION_HISUI})}, + {EVO_LEVEL, 36, SPECIES_TYPHLOSION_HISUI, CONDITIONS({IF_REGION, REGION_HISUI})}), }, #if P_UPDATED_EXP_YIELDS >= GEN_8 @@ -5916,7 +5916,7 @@ const struct SpeciesInfo gSpeciesInfoGen2[] = .levelUpLearnset = sUrsaringLevelUpLearnset, .teachableLearnset = sUrsaringTeachableLearnset, #if P_GEN_8_CROSS_EVOS - .evolutions = EVOLUTION({EVO_ITEM, ITEM_PEAT_BLOCK, SPECIES_URSALUNA, CONDITIONS({IF_TIME, TIME_NIGHT})}, + .evolutions = EVOLUTION({EVO_ITEM, ITEM_PEAT_BLOCK, SPECIES_URSALUNA, CONDITIONS({IF_REGION, REGION_HISUI}, {IF_TIME, TIME_NIGHT})}, {EVO_NONE, 0, SPECIES_URSALUNA_BLOODMOON}), #endif }, diff --git a/src/data/pokemon/species_info/gen_5_families.h b/src/data/pokemon/species_info/gen_5_families.h index 6b46006a58..1b5e484ab8 100644 --- a/src/data/pokemon/species_info/gen_5_families.h +++ b/src/data/pokemon/species_info/gen_5_families.h @@ -656,8 +656,8 @@ const struct SpeciesInfo gSpeciesInfoGen5[] = ) .levelUpLearnset = sDewottLevelUpLearnset, .teachableLearnset = sDewottTeachableLearnset, - .evolutions = EVOLUTION({EVO_LEVEL, 36, SPECIES_SAMUROTT}, - {EVO_NONE, 0, SPECIES_SAMUROTT_HISUI}), + .evolutions = EVOLUTION({EVO_LEVEL, 36, SPECIES_SAMUROTT, CONDITIONS({IF_NOT_REGION, REGION_HISUI})}, + {EVO_LEVEL, 36, SPECIES_SAMUROTT_HISUI, CONDITIONS({IF_REGION, REGION_HISUI})}), }, [SPECIES_SAMUROTT] = @@ -4158,8 +4158,8 @@ const struct SpeciesInfo gSpeciesInfoGen5[] = .levelUpLearnset = sPetililLevelUpLearnset, .teachableLearnset = sPetililTeachableLearnset, .eggMoveLearnset = sPetililEggMoveLearnset, - .evolutions = EVOLUTION({EVO_ITEM, ITEM_SUN_STONE, SPECIES_LILLIGANT}, - {EVO_NONE, 0, SPECIES_LILLIGANT_HISUI}), + .evolutions = EVOLUTION({EVO_ITEM, ITEM_SUN_STONE, SPECIES_LILLIGANT, CONDITIONS({IF_NOT_REGION, REGION_HISUI})}, + {EVO_ITEM, ITEM_SUN_STONE, SPECIES_LILLIGANT_HISUI, CONDITIONS({IF_REGION, REGION_HISUI})}), }, [SPECIES_LILLIGANT] = @@ -11316,8 +11316,8 @@ const struct SpeciesInfo gSpeciesInfoGen5[] = ) .levelUpLearnset = sRuffletLevelUpLearnset, .teachableLearnset = sRuffletTeachableLearnset, - .evolutions = EVOLUTION({EVO_LEVEL, 54, SPECIES_BRAVIARY}, - {EVO_NONE, 0, SPECIES_BRAVIARY_HISUI}), + .evolutions = EVOLUTION({EVO_LEVEL, 54, SPECIES_BRAVIARY, CONDITIONS({IF_NOT_REGION, REGION_HISUI})}, + {EVO_LEVEL, 54, SPECIES_BRAVIARY_HISUI, CONDITIONS({IF_REGION, REGION_HISUI})}), }, [SPECIES_BRAVIARY] = diff --git a/src/data/pokemon/species_info/gen_6_families.h b/src/data/pokemon/species_info/gen_6_families.h index 411ef400f6..03bfc713f2 100644 --- a/src/data/pokemon/species_info/gen_6_families.h +++ b/src/data/pokemon/species_info/gen_6_families.h @@ -4441,8 +4441,8 @@ const struct SpeciesInfo gSpeciesInfoGen6[] = .levelUpLearnset = sGoomyLevelUpLearnset, .teachableLearnset = sGoomyTeachableLearnset, .eggMoveLearnset = sGoomyEggMoveLearnset, - .evolutions = EVOLUTION({EVO_LEVEL, 40, SPECIES_SLIGGOO}, - {EVO_NONE, 0, SPECIES_SLIGGOO_HISUI}), + .evolutions = EVOLUTION({EVO_LEVEL, 40, SPECIES_SLIGGOO, CONDITIONS({IF_NOT_REGION, REGION_HISUI})}, + {EVO_LEVEL, 40, SPECIES_SLIGGOO_HISUI, CONDITIONS({IF_REGION, REGION_HISUI})}), }, [SPECIES_SLIGGOO] = @@ -5546,8 +5546,8 @@ const struct SpeciesInfo gSpeciesInfoGen6[] = .levelUpLearnset = sBergmiteLevelUpLearnset, .teachableLearnset = sBergmiteTeachableLearnset, .eggMoveLearnset = sBergmiteEggMoveLearnset, - .evolutions = EVOLUTION({EVO_LEVEL, 37, SPECIES_AVALUGG}, - {EVO_NONE, 0, SPECIES_AVALUGG_HISUI}), + .evolutions = EVOLUTION({EVO_LEVEL, 37, SPECIES_AVALUGG, CONDITIONS({IF_NOT_REGION, REGION_HISUI})}, + {EVO_LEVEL, 37, SPECIES_AVALUGG_HISUI, CONDITIONS({IF_REGION, REGION_HISUI})}), }, [SPECIES_AVALUGG] = diff --git a/src/data/pokemon/species_info/gen_7_families.h b/src/data/pokemon/species_info/gen_7_families.h index d264f830ad..3877ee2705 100644 --- a/src/data/pokemon/species_info/gen_7_families.h +++ b/src/data/pokemon/species_info/gen_7_families.h @@ -137,8 +137,8 @@ const struct SpeciesInfo gSpeciesInfoGen7[] = ) .levelUpLearnset = sDartrixLevelUpLearnset, .teachableLearnset = sDartrixTeachableLearnset, - .evolutions = EVOLUTION({EVO_LEVEL, 34, SPECIES_DECIDUEYE}, - {EVO_NONE, 0, SPECIES_DECIDUEYE_HISUI}), + .evolutions = EVOLUTION({EVO_LEVEL, 34, SPECIES_DECIDUEYE, CONDITIONS({IF_NOT_REGION, REGION_HISUI})}, + {EVO_LEVEL, 36, SPECIES_DECIDUEYE_HISUI, CONDITIONS({IF_REGION, REGION_HISUI})}), }, [SPECIES_DECIDUEYE] = diff --git a/src/pokedex_plus_hgss.c b/src/pokedex_plus_hgss.c index 49e1016d32..04eaa90310 100644 --- a/src/pokedex_plus_hgss.c +++ b/src/pokedex_plus_hgss.c @@ -6585,7 +6585,8 @@ static void PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 dept StringAppend(gStringVar4, COMPOUND_STRING(", ")); } - switch((enum EvolutionConditions)evolutions[i].params[j].condition) + enum EvolutionConditions condition = evolutions[i].params[j].condition; + switch(condition) { // Gen 2 case IF_GENDER: @@ -6642,10 +6643,10 @@ static void PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 dept case IF_PID_UPPER_MODULO_10_EQ: case IF_PID_UPPER_MODULO_10_LT: arg = evolutions[i].params[j].arg1; - if ((enum EvolutionConditions)evolutions[i].params[j].condition == IF_PID_UPPER_MODULO_10_GT + if (condition == IF_PID_UPPER_MODULO_10_GT && arg < 10 && arg >= 0) arg = 9 - arg; - else if ((enum EvolutionConditions)evolutions[i].params[j].condition == IF_PID_UPPER_MODULO_10_EQ + else if (condition == IF_PID_UPPER_MODULO_10_EQ && arg < 10 && arg >= 0) arg = 1; ConvertIntToDecimalStringN(gStringVar2, arg * 10, STR_CONV_MODE_LEFT_ALIGN, 3); @@ -6704,6 +6705,33 @@ static void PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 dept StringAppend(gStringVar4, gTypesInfo[evolutions[i].params[j].arg1].name); StringAppend(gStringVar4, COMPOUND_STRING(" move")); break; + case IF_REGION: + case IF_NOT_REGION: + { + if (condition == IF_REGION) + StringAppend(gStringVar4, COMPOUND_STRING("in ")); + else if (condition == IF_NOT_REGION) + StringAppend(gStringVar4, COMPOUND_STRING("out of ")); + + switch ((enum Region)evolutions[i].params[j].arg1) + { + case REGION_NONE: + case REGIONS_COUNT: + StringAppend(gStringVar4, COMPOUND_STRING("???")); + break; + case REGION_KANTO: StringAppend(gStringVar4, COMPOUND_STRING("Kanto")); break; + case REGION_JOHTO: StringAppend(gStringVar4, COMPOUND_STRING("Johto")); break; + case REGION_HOENN: StringAppend(gStringVar4, COMPOUND_STRING("Hoenn")); break; + case REGION_SINNOH: StringAppend(gStringVar4, COMPOUND_STRING("Sinnoh")); break; + case REGION_UNOVA: StringAppend(gStringVar4, COMPOUND_STRING("Unova")); break; + case REGION_KALOS: StringAppend(gStringVar4, COMPOUND_STRING("Kalos")); break; + case REGION_ALOLA: StringAppend(gStringVar4, COMPOUND_STRING("Alola")); break; + case REGION_GALAR: StringAppend(gStringVar4, COMPOUND_STRING("Galar")); break; + case REGION_HISUI: StringAppend(gStringVar4, COMPOUND_STRING("Hisui")); break; + case REGION_PALDEA: StringAppend(gStringVar4, COMPOUND_STRING("Paldea")); break; + } + break; + } // Gen 8 case IF_NATURE: StringCopy(gStringVar2, gNaturesInfo[evolutions[i].params[j].arg1].name); @@ -6755,10 +6783,10 @@ static void PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 dept case IF_PID_MODULO_100_EQ: case IF_PID_MODULO_100_LT: arg = evolutions[i].params[j].arg1; - if ((enum EvolutionConditions)evolutions[i].params[j].condition == IF_PID_MODULO_100_GT + if (condition == IF_PID_MODULO_100_GT && arg < 100 && arg >= 0) arg = 99 - arg; - else if ((enum EvolutionConditions)evolutions[i].params[j].condition == IF_PID_MODULO_100_EQ + else if (condition == IF_PID_MODULO_100_EQ && arg < 100 && arg >= 0) arg = 1; ConvertIntToDecimalStringN(gStringVar2, arg, STR_CONV_MODE_LEFT_ALIGN, 3); diff --git a/src/pokemon.c b/src/pokemon.c index 745c761356..ee04d88bcf 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -37,6 +37,7 @@ #include "pokemon_storage_system.h" #include "random.h" #include "recorded_battle.h" +#include "regions.h" #include "rtc.h" #include "sound.h" #include "string_util.h" @@ -4723,6 +4724,14 @@ bool32 DoesMonMeetAdditionalConditions(struct Pokemon *mon, const struct Evoluti *canStopEvo = FALSE; } break; + case IF_REGION: + if (GetCurrentRegion() == params[i].arg1) + currentCondition = TRUE; + break; + case IF_NOT_REGION: + if (GetCurrentRegion() != params[i].arg1) + currentCondition = TRUE; + break; case CONDITIONS_END: break; }