From 920289641a2e5961ca22964092d18f23dbc6b41a Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Sun, 17 Mar 2024 16:03:40 -0500 Subject: [PATCH] Add evolution method for Gimmighoul, EVO_LEVEL_ITEM_COUNT_999 (#4261) * Add evolution method for Gimmighoul, EVO_LEVEL_COLLECT_999 * Change to EVO_LEVEL_ITEM_COUNT_999 * Make logic use less duplicate code * Update gen_9_families.h * Update party_menu.c * Address reviews --- include/constants/pokemon.h | 12 +++++----- src/battle_main.c | 11 ++++++++-- .../pokemon/species_info/gen_9_families.h | 4 ++-- src/party_menu.c | 22 ++++++++++++++++--- src/pokedex_plus_hgss.c | 6 +++++ src/pokemon.c | 21 ++++++++++++++++++ 6 files changed, 64 insertions(+), 12 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 186ef5de59..1adefd4938 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -294,14 +294,16 @@ #define EVO_LEVEL_MOVE_TWENTY_TIMES 47 // Pokémon levels up after having used a move for at least 20 times #define EVO_LEVEL_RECOIL_DAMAGE_MALE 48 // Pokémon levels up after having suffered specified amount of non-fainting recoil damage as a male #define EVO_LEVEL_RECOIL_DAMAGE_FEMALE 49 // Pokémon levels up after having suffered specified amount of non-fainting recoil damage as a female +#define EVO_LEVEL_ITEM_COUNT_999 50 // Pokémon levels up after trainer has collected 999 of a specific item // Evolution 'modes,' for GetEvolutionTargetSpecies #define EVO_MODE_NORMAL 0 -#define EVO_MODE_TRADE 1 -#define EVO_MODE_ITEM_USE 2 -#define EVO_MODE_ITEM_CHECK 3 // If an Everstone is being held, still want to show that the stone *could* be used on that Pokémon to evolve -#define EVO_MODE_BATTLE_SPECIAL 4 -#define EVO_MODE_OVERWORLD_SPECIAL 5 +#define EVO_MODE_CANT_STOP 1 +#define EVO_MODE_TRADE 2 +#define EVO_MODE_ITEM_USE 3 +#define EVO_MODE_ITEM_CHECK 4 // If an Everstone is being held, still want to show that the stone *could* be used on that Pokémon to evolve +#define EVO_MODE_BATTLE_SPECIAL 5 +#define EVO_MODE_OVERWORLD_SPECIAL 6 #define MON_PIC_WIDTH 64 #define MON_PIC_HEIGHT 64 diff --git a/src/battle_main.c b/src/battle_main.c index e023080d3e..5e5f8187bb 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5848,16 +5848,23 @@ static void TryEvolvePokemon(void) { u16 species; u8 levelUpBits = gLeveledUpInBattle; + bool32 evoModeNormal = TRUE; levelUpBits &= ~(gBitTable[i]); gLeveledUpInBattle = levelUpBits; - species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_NORMAL, levelUpBits, NULL); + species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_NORMAL, ITEM_NONE, NULL); + if (species == SPECIES_NONE) + { + species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_CANT_STOP, ITEM_NONE, NULL); + evoModeNormal = FALSE; + } + if (species != SPECIES_NONE) { FreeAllWindowBuffers(); gBattleMainFunc = WaitForEvoSceneToFinish; - EvolutionScene(&gPlayerParty[i], species, TRUE, i); + EvolutionScene(&gPlayerParty[i], species, evoModeNormal, i); return; } } diff --git a/src/data/pokemon/species_info/gen_9_families.h b/src/data/pokemon/species_info/gen_9_families.h index 43c72fa2c5..06653c20de 100644 --- a/src/data/pokemon/species_info/gen_9_families.h +++ b/src/data/pokemon/species_info/gen_9_families.h @@ -5217,7 +5217,7 @@ const struct SpeciesInfo gSpeciesInfoGen9[] = .levelUpLearnset = sGimmighoulLevelUpLearnset, .teachableLearnset = sGimmighoulTeachableLearnset, .formSpeciesIdTable = sGimmighoulFormSpeciesIdTable, - .evolutions = EVOLUTION({EVO_NONE, 0, SPECIES_GHOLDENGO}), + .evolutions = EVOLUTION({EVO_LEVEL_ITEM_COUNT_999, ITEM_GIMMIGHOUL_COIN, SPECIES_GHOLDENGO}), }, [SPECIES_GIMMIGHOUL_ROAMING] = @@ -5271,7 +5271,7 @@ const struct SpeciesInfo gSpeciesInfoGen9[] = .levelUpLearnset = sGimmighoulLevelUpLearnset, .teachableLearnset = sGimmighoulTeachableLearnset, .formSpeciesIdTable = sGimmighoulFormSpeciesIdTable, - .evolutions = EVOLUTION({EVO_NONE, 0, SPECIES_GHOLDENGO}), + .evolutions = EVOLUTION({EVO_LEVEL_ITEM_COUNT_999, ITEM_GIMMIGHOUL_COIN, SPECIES_GHOLDENGO}), }, [SPECIES_GHOLDENGO] = diff --git a/src/party_menu.c b/src/party_menu.c index 19f50b7c88..7044244709 100644 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -5548,20 +5548,28 @@ void ItemUseCB_RareCandy(u8 taskId, TaskFunc task) if (cannotUseEffect) { u16 targetSpecies = SPECIES_NONE; + bool32 evoModeNormal = TRUE; // Resets values to 0 so other means of teaching moves doesn't overwrite levels sInitialLevel = 0; sFinalLevel = 0; if (holdEffectParam == 0) + { targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_NORMAL, ITEM_NONE, NULL); + if (targetSpecies == SPECIES_NONE) + { + targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_CANT_STOP, ITEM_NONE, NULL); + evoModeNormal = FALSE; + } + } if (targetSpecies != SPECIES_NONE) { RemoveBagItem(gSpecialVar_ItemId, 1); FreePartyPointers(); gCB2_AfterEvolution = gPartyMenu.exitCallback; - BeginEvolutionScene(mon, targetSpecies, TRUE, gPartyMenu.slotId); + BeginEvolutionScene(mon, targetSpecies, evoModeNormal, gPartyMenu.slotId); DestroyTask(taskId); } else @@ -5735,12 +5743,20 @@ static void CB2_ReturnToPartyMenuUsingRareCandy(void) static void PartyMenuTryEvolution(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; - u16 targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_NORMAL, ITEM_NONE, NULL); + u16 targetSpecies = SPECIES_NONE; + bool32 evoModeNormal = TRUE; // Resets values to 0 so other means of teaching moves doesn't overwrite levels sInitialLevel = 0; sFinalLevel = 0; + targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_NORMAL, ITEM_NONE, NULL); + if (targetSpecies == SPECIES_NONE) + { + targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_CANT_STOP, ITEM_NONE, NULL); + evoModeNormal = FALSE; + } + if (targetSpecies != SPECIES_NONE) { FreePartyPointers(); @@ -5748,7 +5764,7 @@ static void PartyMenuTryEvolution(u8 taskId) gCB2_AfterEvolution = CB2_ReturnToPartyMenuUsingRareCandy; else gCB2_AfterEvolution = gPartyMenu.exitCallback; - BeginEvolutionScene(mon, targetSpecies, TRUE, gPartyMenu.slotId); + BeginEvolutionScene(mon, targetSpecies, evoModeNormal, gPartyMenu.slotId); DestroyTask(taskId); } else diff --git a/src/pokedex_plus_hgss.c b/src/pokedex_plus_hgss.c index db80b2dc19..6a2d16caee 100644 --- a/src/pokedex_plus_hgss.c +++ b/src/pokedex_plus_hgss.c @@ -247,6 +247,7 @@ static const u8 sText_EVO_ITEM_HOLD[] = _("{LV}{UP_ARROW}, holds {STR_VAR_2}"); static const u8 sText_EVO_LEVEL_MOVE_TWENTY_TIMES[] = _("{LV}{UP_ARROW} after 20x {STR_VAR_2}"); static const u8 sText_EVO_LEVEL_RECOIL_DAMAGE_MALE[] = _("{LV}{UP_ARROW} with {STR_VAR_2} recoil, male"); static const u8 sText_EVO_LEVEL_RECOIL_DAMAGE_FEMALE[] = _("{LV}{UP_ARROW} with {STR_VAR_2} recoil, female"); +static const u8 sText_EVO_LEVEL_ITEM_COUNT_999[] = _("{LV}{UP_ARROW} with 999 {STR_VAR_2} in bag"); static const u8 sText_EVO_UNKNOWN[] = _("Method unknown"); static const u8 sText_EVO_NONE[] = _("{STR_VAR_1} has no evolution."); @@ -6653,6 +6654,11 @@ static u8 PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 depth, ConvertIntToDecimalStringN(gStringVar2, evolutions[i].param, STR_CONV_MODE_LEADING_ZEROS, 3); StringExpandPlaceholders(gStringVar4, sText_EVO_LEVEL_RECOIL_DAMAGE_FEMALE); break; + case EVO_LEVEL_ITEM_COUNT_999: + item = evolutions[i].param; + CopyItemName(item, gStringVar2); + StringExpandPlaceholders(gStringVar4, sText_EVO_LEVEL_ITEM_COUNT_999); + break; default: StringExpandPlaceholders(gStringVar4, sText_EVO_UNKNOWN ); break; diff --git a/src/pokemon.c b/src/pokemon.c index ab36c3e7fb..614adf6c5c 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4389,6 +4389,27 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, s } } break; + case EVO_MODE_CANT_STOP: + level = GetMonData(mon, MON_DATA_LEVEL, 0); + friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, 0); + + for (i = 0; evolutions[i].method != EVOLUTIONS_END; i++) + { + if (SanitizeSpeciesId(evolutions[i].targetSpecies) == SPECIES_NONE) + continue; + + switch (evolutions[i].method) + { + case EVO_LEVEL_ITEM_COUNT_999: + if (CheckBagHasItem(evolutions[i].param, 999)) + { + targetSpecies = evolutions[i].targetSpecies; + RemoveBagItem(evolutions[i].param, 999); + } + break; + } + } + break; case EVO_MODE_TRADE: for (i = 0; evolutions[i].method != EVOLUTIONS_END; i++) {