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:
parent
dffaaeaaa6
commit
76c566a0ca
8 changed files with 47 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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] =
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue