Skip to content

Commit

Permalink
Add evolution method for Gimmighoul, EVO_LEVEL_ITEM_COUNT_999 (#4261)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kittenchilly authored Mar 17, 2024
1 parent 1ff7cb6 commit 9202896
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 12 deletions.
12 changes: 7 additions & 5 deletions include/constants/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/data/pokemon/species_info/gen_9_families.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down Expand Up @@ -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] =
Expand Down
22 changes: 19 additions & 3 deletions src/party_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -5735,20 +5743,28 @@ 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();
if (ItemId_GetFieldFunc(gSpecialVar_ItemId) == ItemUseOutOfBattle_RareCandy && gPartyMenu.menuType == PARTY_MENU_TYPE_FIELD && CheckBagHasItem(gSpecialVar_ItemId, 1))
gCB2_AfterEvolution = CB2_ReturnToPartyMenuUsingRareCandy;
else
gCB2_AfterEvolution = gPartyMenu.exitCallback;
BeginEvolutionScene(mon, targetSpecies, TRUE, gPartyMenu.slotId);
BeginEvolutionScene(mon, targetSpecies, evoModeNormal, gPartyMenu.slotId);
DestroyTask(taskId);
}
else
Expand Down
6 changes: 6 additions & 0 deletions src/pokedex_plus_hgss.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.");

Expand Down Expand Up @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand Down

0 comments on commit 9202896

Please sign in to comment.