Alcremie Evolution clean up follow up (#6557)

This commit is contained in:
Alex 2025-04-09 11:18:07 +02:00 committed by GitHub
parent 26f28103ec
commit f364cf9e71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 36 additions and 42 deletions

View File

@ -324,6 +324,11 @@ enum EvolutionMode {
EVO_MODE_BATTLE_ONLY, // This mode is only used in battles to support Tandemaus' unique requirement
};
enum StartEvo
{
CHECK_EVO,
DO_EVO,
};
enum PokemonJumpType{
PKMN_JUMP_TYPE_NONE, // Not allowed in Pokémon Jump

View File

@ -725,7 +725,7 @@ u8 *UseStatIncreaseItem(u16 itemId);
u8 GetNature(struct Pokemon *mon);
u8 GetNatureFromPersonality(u32 personality);
u32 GetGMaxTargetSpecies(u32 species);
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16 evolutionItem, struct Pokemon *tradePartner);
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16 evolutionItem, struct Pokemon *tradePartner, enum StartEvo prepareEvo);
bool8 IsMonPastEvolutionLevel(struct Pokemon *mon);
u16 NationalPokedexNumToSpecies(u16 nationalNum);
u16 NationalToHoennOrder(u16 nationalNum);
@ -813,6 +813,5 @@ u32 CheckDynamicMoveType(struct Pokemon *mon, u32 move, u32 battler);
uq4_12_t GetDynamaxLevelHPMultiplier(u32 dynamaxLevel, bool32 inverseMultiplier);
u32 GetRegionalFormByRegion(u32 species, u32 region);
bool32 IsSpeciesForeignRegionalForm(u32 species, u32 currentRegion);
void DoRemoveItems(struct Pokemon *mon);
#endif // GUARD_POKEMON_H

View File

@ -5678,19 +5678,19 @@ static void TryEvolvePokemon(void)
{
if (!(sTriedEvolving & (1u << i)))
{
u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i, NULL);
u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i, NULL, DO_EVO);
bool32 evoModeNormal = TRUE;
sTriedEvolving |= 1u << i;
if (species == SPECIES_NONE && (gLeveledUpInBattle & (1u << i)))
{
gLeveledUpInBattle &= ~(1u << i);
species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_ONLY, gLeveledUpInBattle, NULL);
species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_ONLY, gLeveledUpInBattle, NULL, DO_EVO);
}
if (species == SPECIES_NONE)
{
species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_CANT_STOP, ITEM_NONE, NULL);
species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_CANT_STOP, ITEM_NONE, NULL, DO_EVO);
evoModeNormal = FALSE;
}

View File

@ -821,7 +821,6 @@ static void Task_EvolutionScene(u8 taskId)
}
if (!gTasks[taskId].tEvoWasStopped)
{
DoRemoveItems(mon);
CreateShedinja(gTasks[taskId].tPreEvoSpecies, mon);
}

View File

@ -780,7 +780,7 @@ bool32 CanTriggerSpinEvolution()
{
for (u32 i = 0; i < PARTY_SIZE; i++)
{
u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_OVERWORLD_SPECIAL, gSpecialVar_0x8000, NULL);
u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_OVERWORLD_SPECIAL, gSpecialVar_0x8000, NULL, CHECK_EVO);
if (species != SPECIES_NONE)
{
return TRUE;

View File

@ -1154,7 +1154,7 @@ static bool8 DisplayPartyPokemonDataForMoveTutorOrEvolutionItem(u8 slot)
DisplayPartyPokemonDataToTeachMove(slot, ItemIdToBattleMoveId(item));
break;
case 2: // Evolution stone
if (!GetMonData(currentPokemon, MON_DATA_IS_EGG) && GetEvolutionTargetSpecies(currentPokemon, EVO_MODE_ITEM_CHECK, item, NULL) != SPECIES_NONE)
if (!GetMonData(currentPokemon, MON_DATA_IS_EGG) && GetEvolutionTargetSpecies(currentPokemon, EVO_MODE_ITEM_CHECK, item, NULL, DO_EVO) != SPECIES_NONE)
return FALSE;
DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_NO_USE);
break;
@ -5634,10 +5634,10 @@ void ItemUseCB_RareCandy(u8 taskId, TaskFunc task)
if (holdEffectParam == 0)
{
targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_NORMAL, ITEM_NONE, NULL);
targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_NORMAL, ITEM_NONE, NULL, DO_EVO);
if (targetSpecies == SPECIES_NONE)
{
targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_CANT_STOP, ITEM_NONE, NULL);
targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_CANT_STOP, ITEM_NONE, NULL, DO_EVO);
evoModeNormal = FALSE;
}
}
@ -5828,10 +5828,10 @@ static void PartyMenuTryEvolution(u8 taskId)
sInitialLevel = 0;
sFinalLevel = 0;
targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_NORMAL, ITEM_NONE, NULL);
targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_NORMAL, ITEM_NONE, NULL, DO_EVO);
if (targetSpecies == SPECIES_NONE)
{
targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_CANT_STOP, ITEM_NONE, NULL);
targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_CANT_STOP, ITEM_NONE, NULL, DO_EVO);
evoModeNormal = FALSE;
}

View File

@ -90,9 +90,6 @@ EWRAM_DATA struct SpriteTemplate gMultiuseSpriteTemplate = {0};
EWRAM_DATA static struct MonSpritesGfxManager *sMonSpritesGfxManagers[MON_SPR_GFX_MANAGERS_COUNT] = {NULL};
EWRAM_DATA static u8 sTriedEvolving = 0;
EWRAM_DATA u16 gFollowerSteps = 0;
EWRAM_DATA bool32 removeHeldItem = 0;
EWRAM_DATA u32 removeBagItem = 0;
EWRAM_DATA u32 removeBagItemCount = 0;
#include "data/abilities.h"
@ -4059,7 +4056,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
case 7: // ITEM4_EVO_STONE
{
u16 targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_ITEM_USE, item, NULL);
u16 targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_ITEM_USE, item, NULL, DO_EVO);
if (targetSpecies != SPECIES_NONE)
{
@ -4439,18 +4436,6 @@ u8 GetNatureFromPersonality(u32 personality)
return personality % NUM_NATURES;
}
void DoRemoveItems(struct Pokemon *mon)
{
if (removeHeldItem)
{
u32 heldItem = ITEM_NONE;
SetMonData(mon, MON_DATA_HELD_ITEM, &heldItem);
}
if (removeBagItem != ITEM_NONE && removeBagItemCount != 0)
RemoveBagItem(removeBagItem, removeBagItemCount);
}
u32 GetGMaxTargetSpecies(u32 species)
{
const struct FormChange *formChanges = GetSpeciesFormChanges(species);
@ -4463,7 +4448,7 @@ u32 GetGMaxTargetSpecies(u32 species)
return species;
}
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16 evolutionItem, struct Pokemon *tradePartner)
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16 evolutionItem, struct Pokemon *tradePartner, enum StartEvo prepareEvo)
{
int i, j;
u16 targetSpecies = SPECIES_NONE;
@ -4475,7 +4460,7 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16
u8 beauty = GetMonData(mon, MON_DATA_BEAUTY, 0);
u16 upperPersonality = personality >> 16;
u32 holdEffect, currentMap, partnerSpecies, partnerHeldItem, partnerHoldEffect;
removeHeldItem = FALSE;
bool32 consumeItem = FALSE;
u16 evolutionTracker = GetMonData(mon, MON_DATA_EVOLUTION_TRACKER, 0);
const struct Evolution *evolutions = GetSpeciesEvolutions(species);
@ -4556,14 +4541,14 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16
if (GetTimeOfDay() == TIME_NIGHT && heldItem == evolutions[i].param)
{
targetSpecies = evolutions[i].targetSpecies;
removeHeldItem = TRUE;
consumeItem = TRUE;
}
break;
case EVO_ITEM_HOLD_DAY:
if (GetTimeOfDay() != TIME_NIGHT && heldItem == evolutions[i].param)
{
targetSpecies = evolutions[i].targetSpecies;
removeHeldItem = TRUE;
consumeItem = TRUE;
}
break;
case EVO_LEVEL_DUSK:
@ -4743,7 +4728,7 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16
if (heldItem == evolutions[i].param)
{
targetSpecies = evolutions[i].targetSpecies;
removeHeldItem = TRUE;
consumeItem = TRUE;
}
break;
case EVO_USE_MOVE_TWENTY_TIMES:
@ -4784,8 +4769,8 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16
if (CheckBagHasItem(evolutions[i].param, 999))
{
targetSpecies = evolutions[i].targetSpecies;
removeBagItem = evolutions[i].param;
removeBagItemCount = 999;
if (prepareEvo == DO_EVO)
RemoveBagItem(evolutions[i].param, 999);
}
break;
}
@ -4806,7 +4791,7 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16
if (evolutions[i].param == heldItem)
{
targetSpecies = evolutions[i].targetSpecies;
removeHeldItem = TRUE;
consumeItem = TRUE;
}
break;
case EVO_TRADE_SPECIFIC_MON:
@ -4902,9 +4887,9 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16
if (evolutions[i].param == heldItem && evolutionItem == evolutions[i].method)
{
targetSpecies = evolutions[i].targetSpecies;
removeHeldItem = TRUE;
consumeItem = TRUE;
}
break;
}
}
@ -4921,6 +4906,12 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16
return SPECIES_NONE;
}
if (consumeItem && prepareEvo == DO_EVO)
{
heldItem = ITEM_NONE;
SetMonData(mon, MON_DATA_HELD_ITEM, &heldItem);
}
return targetSpecies;
}
@ -6741,7 +6732,7 @@ void TrySpecialOverworldEvo(void)
for (i = 0; i < PARTY_SIZE; i++)
{
u16 targetSpecies = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_OVERWORLD_SPECIAL, evoMethod, SPECIES_NONE);
u16 targetSpecies = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_OVERWORLD_SPECIAL, evoMethod, SPECIES_NONE, DO_EVO);
if (targetSpecies != SPECIES_NONE && !(sTriedEvolving & (1u << i)))
{
sTriedEvolving |= 1u << i;

View File

@ -3846,7 +3846,7 @@ static bool8 DoTradeAnim_Cable(void)
case STATE_TRY_EVOLUTION: // Only if in-game trade, link trades use CB2_TryLinkTradeEvolution
TradeMons(gSpecialVar_0x8005, 0);
gCB2_AfterEvolution = CB2_InGameTrade;
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE, &gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]]);
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE, &gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], DO_EVO);
if (evoTarget != SPECIES_NONE)
TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeAnim->monSpriteIds[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]);
sTradeAnim->state++;
@ -4343,7 +4343,7 @@ static bool8 DoTradeAnim_Wireless(void)
case STATE_TRY_EVOLUTION: // Only if in-game trade, link trades use CB2_TryLinkTradeEvolution
TradeMons(gSpecialVar_0x8005, 0);
gCB2_AfterEvolution = CB2_InGameTrade;
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE, &gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]]);
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE, &gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], DO_EVO);
if (evoTarget != SPECIES_NONE)
TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeAnim->monSpriteIds[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]);
sTradeAnim->state++;
@ -4386,7 +4386,7 @@ static void CB2_TryLinkTradeEvolution(void)
break;
case 4:
gCB2_AfterEvolution = CB2_SaveAndEndTrade;
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE, &gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]]);
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE, &gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], DO_EVO);
if (evoTarget != SPECIES_NONE)
TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeAnim->monSpriteIds[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]);
else if (IsWirelessTrade())