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
This commit is contained in:
kittenchilly 2024-03-17 16:03:40 -05:00 committed by GitHub
parent 1ff7cb6a7b
commit 920289641a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 64 additions and 12 deletions

View file

@ -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

View file

@ -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;
}
}

View file

@ -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] =

View file

@ -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

View file

@ -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;

View file

@ -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++)
{