diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index e49c949b7b..b91045fc48 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -297,6 +297,7 @@ #define EVO_RECOIL_DAMAGE_FEMALE 49 // Pokémon levels up after having suffered specified amount of non-fainting recoil damage as a female #define EVO_ITEM_COUNT_999 50 // Pokémon levels up after trainer has collected 999 of a specific item #define EVO_DEFEAT_WITH_ITEM 51 // Pokémon levels up after having defeat 3 Pokémon of the same species holding the specified item +#define EVO_OVERWORLD_STEPS 52 // Pokémon levels up after having taken a specific amount of steps in the overworld // Evolution 'modes,' for GetEvolutionTargetSpecies #define EVO_MODE_NORMAL 0 diff --git a/include/pokemon.h b/include/pokemon.h index 420bf57295..84ddb084a3 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -138,8 +138,7 @@ struct PokemonSubstruct1 u16 move1:11; // 2047 moves. u16 evolutionTracker1:5; u16 move2:11; // 2047 moves. - u16 evolutionTracker2:4; - u16 unused_02:1; + u16 evolutionTracker2:5; u16 move3:11; // 2047 moves. u16 unused_04:5; u16 move4:11; // 2047 moves. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e61028bddf..d576f4c15e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -16899,8 +16899,8 @@ static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount, u16 use if (evolutions[i].method == evolutionMethod) { - // We only have 9 bits to use - u16 val = min(511, GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER) + upAmount); + // We only have 10 bits to use + u16 val = min(1023, GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER) + upAmount); // Reset progress if you faint for the recoil method. switch (evolutionMethod) { diff --git a/src/data/pokemon/species_info/gen_9_families.h b/src/data/pokemon/species_info/gen_9_families.h index 912496c210..b623c4bb3b 100644 --- a/src/data/pokemon/species_info/gen_9_families.h +++ b/src/data/pokemon/species_info/gen_9_families.h @@ -969,7 +969,7 @@ const struct SpeciesInfo gSpeciesInfoGen9[] = FOOTPRINT(Pawmo) .levelUpLearnset = sPawmoLevelUpLearnset, .teachableLearnset = sPawmoTeachableLearnset, - .evolutions = EVOLUTION({EVO_NONE, 0, SPECIES_PAWMOT}), + .evolutions = EVOLUTION({EVO_OVERWORLD_STEPS, 1000, SPECIES_PAWMOT}), }, [SPECIES_PAWMOT] = @@ -2481,7 +2481,7 @@ const struct SpeciesInfo gSpeciesInfoGen9[] = .levelUpLearnset = sBramblinLevelUpLearnset, .teachableLearnset = sBramblinTeachableLearnset, .eggMoveLearnset = sBramblinEggMoveLearnset, - .evolutions = EVOLUTION({EVO_NONE, 0, SPECIES_BRAMBLEGHAST}), + .evolutions = EVOLUTION({EVO_OVERWORLD_STEPS, 1000, SPECIES_BRAMBLEGHAST}), }, [SPECIES_BRAMBLEGHAST] = @@ -2860,7 +2860,7 @@ const struct SpeciesInfo gSpeciesInfoGen9[] = .levelUpLearnset = sRellorLevelUpLearnset, .teachableLearnset = sRellorTeachableLearnset, .eggMoveLearnset = sRellorEggMoveLearnset, - .evolutions = EVOLUTION({EVO_NONE, 0, SPECIES_RABSCA}), + .evolutions = EVOLUTION({EVO_OVERWORLD_STEPS, 1000, SPECIES_RABSCA}), }, [SPECIES_RABSCA] = diff --git a/src/evolution_scene.c b/src/evolution_scene.c index c5d7e56f0b..98879430cb 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -769,11 +769,13 @@ static void Task_EvolutionScene(u8 taskId) case EVOSTATE_SET_MON_EVOLVED: if (IsCryFinished()) { + u32 zero = 0; StringExpandPlaceholders(gStringVar4, gText_CongratsPkmnEvolved); BattlePutTextOnWindow(gStringVar4, B_WIN_MSG); PlayBGM(MUS_EVOLVED); gTasks[taskId].tState++; SetMonData(mon, MON_DATA_SPECIES, (void *)(&gTasks[taskId].tPostEvoSpecies)); + SetMonData(mon, MON_DATA_EVOLUTION_TRACKER, &zero); CalculateMonStats(mon); EvolutionRenameMon(mon, gTasks[taskId].tPreEvoSpecies, gTasks[taskId].tPostEvoSpecies); GetSetPokedexFlag(SpeciesToNationalPokedexNum(gTasks[taskId].tPostEvoSpecies), FLAG_SET_SEEN); @@ -1188,11 +1190,13 @@ static void Task_TradeEvolutionScene(u8 taskId) case T_EVOSTATE_SET_MON_EVOLVED: if (IsCryFinished()) { + u32 zero = 0; StringExpandPlaceholders(gStringVar4, gText_CongratsPkmnEvolved); DrawTextOnTradeWindow(0, gStringVar4, 1); PlayFanfare(MUS_EVOLVED); gTasks[taskId].tState++; SetMonData(mon, MON_DATA_SPECIES, (&gTasks[taskId].tPostEvoSpecies)); + SetMonData(mon, MON_DATA_EVOLUTION_TRACKER, &zero); CalculateMonStats(mon); EvolutionRenameMon(mon, gTasks[taskId].tPreEvoSpecies, gTasks[taskId].tPostEvoSpecies); GetSetPokedexFlag(SpeciesToNationalPokedexNum(gTasks[taskId].tPostEvoSpecies), FLAG_SET_SEEN); diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index d5c252415d..5e709a9fb0 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -69,6 +69,7 @@ static bool8 TryStartWarpEventScript(struct MapPosition *, u16); static bool8 TryStartMiscWalkingScripts(u16); static bool8 TryStartStepCountScript(u16); static void UpdateFriendshipStepCounter(void); +static void UpdateLetsGoEvolutionTracker(void); #if OW_POISON_DAMAGE < GEN_5 static bool8 UpdatePoisonStepCounter(void); #endif // OW_POISON_DAMAGE @@ -565,6 +566,7 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior) IncrementRematchStepCounter(); UpdateFriendshipStepCounter(); UpdateFarawayIslandStepCounter(); + UpdateLetsGoEvolutionTracker(); if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FORCED_MOVE) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior)) { @@ -658,6 +660,28 @@ static void UpdateFriendshipStepCounter(void) } } +static void UpdateLetsGoEvolutionTracker(void) +{ + u32 i; + u16 count; + struct Pokemon *followingMon = GetFirstLiveMon(); + const struct Evolution *evolutions = GetSpeciesEvolutions(GetMonData(followingMon, MON_DATA_SPECIES)); + + if (evolutions == NULL) + return; + + for (i = 0; evolutions[i].method != EVOLUTIONS_END; i++) + { + if (evolutions[i].method != EVO_OVERWORLD_STEPS || SanitizeSpeciesId(evolutions[i].targetSpecies) == SPECIES_NONE) + continue; + + // We only have 10 bits to use + count = min(1023, GetMonData(followingMon, MON_DATA_EVOLUTION_TRACKER) + 1); + SetMonData(followingMon, MON_DATA_EVOLUTION_TRACKER, &count); + return; + } +} + void ClearPoisonStepCounter(void) { VarSet(VAR_POISON_STEP_COUNTER, 0); diff --git a/src/pokedex_plus_hgss.c b/src/pokedex_plus_hgss.c index bec3308065..e3728132db 100644 --- a/src/pokedex_plus_hgss.c +++ b/src/pokedex_plus_hgss.c @@ -250,6 +250,7 @@ static const u8 sText_EVO_RECOIL_DAMAGE_MALE[] = _("{LV}{UP_ARROW} with {STR_VAR static const u8 sText_EVO_RECOIL_DAMAGE_FEMALE[] = _("{LV}{UP_ARROW} with {STR_VAR_2} recoil, female"); static const u8 sText_EVO_ITEM_COUNT_999[] = _("{LV}{UP_ARROW} with 999 {STR_VAR_2} in bag"); static const u8 sText_EVO_DEFEAT_WITH_ITEM[] = _("{LV}{UP_ARROW} defeating {STR_VAR_3} holding {STR_VAR_2}"); +static const u8 sText_EVO_OVERWORLD_STEPS[] = _("{LV}{UP_ARROW} after {STR_VAR_2} steps"); static const u8 sText_EVO_UNKNOWN[] = _("Method unknown"); static const u8 sText_EVO_NONE[] = _("{STR_VAR_1} has no evolution."); @@ -6628,12 +6629,16 @@ static void PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 dept CopyItemName(item, gStringVar2); StringExpandPlaceholders(gStringVar4, sText_EVO_ITEM_COUNT_999); break; - case EVO_DEFEAT_WITH_ITEM: + case EVO_DEFEAT_WITH_ITEM: item = evolutions[i].param; CopyItemName(item, gStringVar2); StringCopy(gStringVar3, GetSpeciesName(species)); StringExpandPlaceholders(gStringVar4, sText_EVO_DEFEAT_WITH_ITEM); break; + case EVO_OVERWORLD_STEPS: + ConvertIntToDecimalStringN(gStringVar2, evolutions[i].param, STR_CONV_MODE_LEADING_ZEROS, 4); + StringExpandPlaceholders(gStringVar4, sText_EVO_OVERWORLD_STEPS); + break; default: StringExpandPlaceholders(gStringVar4, sText_EVO_UNKNOWN); break; diff --git a/src/pokemon.c b/src/pokemon.c index 4fdb9ef6ba..36d44eded2 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2383,8 +2383,8 @@ u32 GetMonData2(struct Pokemon *mon, s32 field) struct EvolutionTrackerBitfield { u16 a: 5; - u16 b: 4; - u16 unused: 7; + u16 b: 5; + u16 unused: 6; }; union EvolutionTracker @@ -4688,6 +4688,10 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, s if (evolutionTracker >= 3) targetSpecies = evolutions[i].targetSpecies; break; + case EVO_OVERWORLD_STEPS: + if (evolutionTracker >= evolutions[i].param) + targetSpecies = evolutions[i].targetSpecies; + break; } } break;