Add the Let's Go evolution method (#4758)

* Add overworld step evolution method

* Increase evolutionTracker bits from 9 to 10

* Implement tracker increase

* Remove leftover NDEBUG activation

* Reset evolution tracker data upon evolution

* Revert an accidental change to unrelated code

* Add missing break in switch case, oops
This commit is contained in:
Bassoonian 2024-06-12 11:31:19 +02:00 committed by GitHub
parent dffaaeaaa6
commit 76c566a0ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 47 additions and 10 deletions

View file

@ -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_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_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_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 // Evolution 'modes,' for GetEvolutionTargetSpecies
#define EVO_MODE_NORMAL 0 #define EVO_MODE_NORMAL 0

View file

@ -138,8 +138,7 @@ struct PokemonSubstruct1
u16 move1:11; // 2047 moves. u16 move1:11; // 2047 moves.
u16 evolutionTracker1:5; u16 evolutionTracker1:5;
u16 move2:11; // 2047 moves. u16 move2:11; // 2047 moves.
u16 evolutionTracker2:4; u16 evolutionTracker2:5;
u16 unused_02:1;
u16 move3:11; // 2047 moves. u16 move3:11; // 2047 moves.
u16 unused_04:5; u16 unused_04:5;
u16 move4:11; // 2047 moves. u16 move4:11; // 2047 moves.

View file

@ -16899,8 +16899,8 @@ static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount, u16 use
if (evolutions[i].method == evolutionMethod) if (evolutions[i].method == evolutionMethod)
{ {
// We only have 9 bits to use // We only have 10 bits to use
u16 val = min(511, GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER) + upAmount); u16 val = min(1023, GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER) + upAmount);
// Reset progress if you faint for the recoil method. // Reset progress if you faint for the recoil method.
switch (evolutionMethod) switch (evolutionMethod)
{ {

View file

@ -969,7 +969,7 @@ const struct SpeciesInfo gSpeciesInfoGen9[] =
FOOTPRINT(Pawmo) FOOTPRINT(Pawmo)
.levelUpLearnset = sPawmoLevelUpLearnset, .levelUpLearnset = sPawmoLevelUpLearnset,
.teachableLearnset = sPawmoTeachableLearnset, .teachableLearnset = sPawmoTeachableLearnset,
.evolutions = EVOLUTION({EVO_NONE, 0, SPECIES_PAWMOT}), .evolutions = EVOLUTION({EVO_OVERWORLD_STEPS, 1000, SPECIES_PAWMOT}),
}, },
[SPECIES_PAWMOT] = [SPECIES_PAWMOT] =
@ -2481,7 +2481,7 @@ const struct SpeciesInfo gSpeciesInfoGen9[] =
.levelUpLearnset = sBramblinLevelUpLearnset, .levelUpLearnset = sBramblinLevelUpLearnset,
.teachableLearnset = sBramblinTeachableLearnset, .teachableLearnset = sBramblinTeachableLearnset,
.eggMoveLearnset = sBramblinEggMoveLearnset, .eggMoveLearnset = sBramblinEggMoveLearnset,
.evolutions = EVOLUTION({EVO_NONE, 0, SPECIES_BRAMBLEGHAST}), .evolutions = EVOLUTION({EVO_OVERWORLD_STEPS, 1000, SPECIES_BRAMBLEGHAST}),
}, },
[SPECIES_BRAMBLEGHAST] = [SPECIES_BRAMBLEGHAST] =
@ -2860,7 +2860,7 @@ const struct SpeciesInfo gSpeciesInfoGen9[] =
.levelUpLearnset = sRellorLevelUpLearnset, .levelUpLearnset = sRellorLevelUpLearnset,
.teachableLearnset = sRellorTeachableLearnset, .teachableLearnset = sRellorTeachableLearnset,
.eggMoveLearnset = sRellorEggMoveLearnset, .eggMoveLearnset = sRellorEggMoveLearnset,
.evolutions = EVOLUTION({EVO_NONE, 0, SPECIES_RABSCA}), .evolutions = EVOLUTION({EVO_OVERWORLD_STEPS, 1000, SPECIES_RABSCA}),
}, },
[SPECIES_RABSCA] = [SPECIES_RABSCA] =

View file

@ -769,11 +769,13 @@ static void Task_EvolutionScene(u8 taskId)
case EVOSTATE_SET_MON_EVOLVED: case EVOSTATE_SET_MON_EVOLVED:
if (IsCryFinished()) if (IsCryFinished())
{ {
u32 zero = 0;
StringExpandPlaceholders(gStringVar4, gText_CongratsPkmnEvolved); StringExpandPlaceholders(gStringVar4, gText_CongratsPkmnEvolved);
BattlePutTextOnWindow(gStringVar4, B_WIN_MSG); BattlePutTextOnWindow(gStringVar4, B_WIN_MSG);
PlayBGM(MUS_EVOLVED); PlayBGM(MUS_EVOLVED);
gTasks[taskId].tState++; gTasks[taskId].tState++;
SetMonData(mon, MON_DATA_SPECIES, (void *)(&gTasks[taskId].tPostEvoSpecies)); SetMonData(mon, MON_DATA_SPECIES, (void *)(&gTasks[taskId].tPostEvoSpecies));
SetMonData(mon, MON_DATA_EVOLUTION_TRACKER, &zero);
CalculateMonStats(mon); CalculateMonStats(mon);
EvolutionRenameMon(mon, gTasks[taskId].tPreEvoSpecies, gTasks[taskId].tPostEvoSpecies); EvolutionRenameMon(mon, gTasks[taskId].tPreEvoSpecies, gTasks[taskId].tPostEvoSpecies);
GetSetPokedexFlag(SpeciesToNationalPokedexNum(gTasks[taskId].tPostEvoSpecies), FLAG_SET_SEEN); GetSetPokedexFlag(SpeciesToNationalPokedexNum(gTasks[taskId].tPostEvoSpecies), FLAG_SET_SEEN);
@ -1188,11 +1190,13 @@ static void Task_TradeEvolutionScene(u8 taskId)
case T_EVOSTATE_SET_MON_EVOLVED: case T_EVOSTATE_SET_MON_EVOLVED:
if (IsCryFinished()) if (IsCryFinished())
{ {
u32 zero = 0;
StringExpandPlaceholders(gStringVar4, gText_CongratsPkmnEvolved); StringExpandPlaceholders(gStringVar4, gText_CongratsPkmnEvolved);
DrawTextOnTradeWindow(0, gStringVar4, 1); DrawTextOnTradeWindow(0, gStringVar4, 1);
PlayFanfare(MUS_EVOLVED); PlayFanfare(MUS_EVOLVED);
gTasks[taskId].tState++; gTasks[taskId].tState++;
SetMonData(mon, MON_DATA_SPECIES, (&gTasks[taskId].tPostEvoSpecies)); SetMonData(mon, MON_DATA_SPECIES, (&gTasks[taskId].tPostEvoSpecies));
SetMonData(mon, MON_DATA_EVOLUTION_TRACKER, &zero);
CalculateMonStats(mon); CalculateMonStats(mon);
EvolutionRenameMon(mon, gTasks[taskId].tPreEvoSpecies, gTasks[taskId].tPostEvoSpecies); EvolutionRenameMon(mon, gTasks[taskId].tPreEvoSpecies, gTasks[taskId].tPostEvoSpecies);
GetSetPokedexFlag(SpeciesToNationalPokedexNum(gTasks[taskId].tPostEvoSpecies), FLAG_SET_SEEN); GetSetPokedexFlag(SpeciesToNationalPokedexNum(gTasks[taskId].tPostEvoSpecies), FLAG_SET_SEEN);

View file

@ -69,6 +69,7 @@ static bool8 TryStartWarpEventScript(struct MapPosition *, u16);
static bool8 TryStartMiscWalkingScripts(u16); static bool8 TryStartMiscWalkingScripts(u16);
static bool8 TryStartStepCountScript(u16); static bool8 TryStartStepCountScript(u16);
static void UpdateFriendshipStepCounter(void); static void UpdateFriendshipStepCounter(void);
static void UpdateLetsGoEvolutionTracker(void);
#if OW_POISON_DAMAGE < GEN_5 #if OW_POISON_DAMAGE < GEN_5
static bool8 UpdatePoisonStepCounter(void); static bool8 UpdatePoisonStepCounter(void);
#endif // OW_POISON_DAMAGE #endif // OW_POISON_DAMAGE
@ -565,6 +566,7 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior)
IncrementRematchStepCounter(); IncrementRematchStepCounter();
UpdateFriendshipStepCounter(); UpdateFriendshipStepCounter();
UpdateFarawayIslandStepCounter(); UpdateFarawayIslandStepCounter();
UpdateLetsGoEvolutionTracker();
if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FORCED_MOVE) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior)) 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) void ClearPoisonStepCounter(void)
{ {
VarSet(VAR_POISON_STEP_COUNTER, 0); VarSet(VAR_POISON_STEP_COUNTER, 0);

View file

@ -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_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_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_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_UNKNOWN[] = _("Method unknown");
static const u8 sText_EVO_NONE[] = _("{STR_VAR_1} has no evolution."); 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); CopyItemName(item, gStringVar2);
StringExpandPlaceholders(gStringVar4, sText_EVO_ITEM_COUNT_999); StringExpandPlaceholders(gStringVar4, sText_EVO_ITEM_COUNT_999);
break; break;
case EVO_DEFEAT_WITH_ITEM: case EVO_DEFEAT_WITH_ITEM:
item = evolutions[i].param; item = evolutions[i].param;
CopyItemName(item, gStringVar2); CopyItemName(item, gStringVar2);
StringCopy(gStringVar3, GetSpeciesName(species)); StringCopy(gStringVar3, GetSpeciesName(species));
StringExpandPlaceholders(gStringVar4, sText_EVO_DEFEAT_WITH_ITEM); StringExpandPlaceholders(gStringVar4, sText_EVO_DEFEAT_WITH_ITEM);
break; break;
case EVO_OVERWORLD_STEPS:
ConvertIntToDecimalStringN(gStringVar2, evolutions[i].param, STR_CONV_MODE_LEADING_ZEROS, 4);
StringExpandPlaceholders(gStringVar4, sText_EVO_OVERWORLD_STEPS);
break;
default: default:
StringExpandPlaceholders(gStringVar4, sText_EVO_UNKNOWN); StringExpandPlaceholders(gStringVar4, sText_EVO_UNKNOWN);
break; break;

View file

@ -2383,8 +2383,8 @@ u32 GetMonData2(struct Pokemon *mon, s32 field)
struct EvolutionTrackerBitfield struct EvolutionTrackerBitfield
{ {
u16 a: 5; u16 a: 5;
u16 b: 4; u16 b: 5;
u16 unused: 7; u16 unused: 6;
}; };
union EvolutionTracker union EvolutionTracker
@ -4688,6 +4688,10 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, s
if (evolutionTracker >= 3) if (evolutionTracker >= 3)
targetSpecies = evolutions[i].targetSpecies; targetSpecies = evolutions[i].targetSpecies;
break; break;
case EVO_OVERWORLD_STEPS:
if (evolutionTracker >= evolutions[i].param)
targetSpecies = evolutions[i].targetSpecies;
break;
} }
} }
break; break;