diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 7708dd2f8..e87f8f822 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -301,6 +301,7 @@ #define EVO_LEVEL_RAIN 28 // Pokémon reaches the specified level while it's raining #define EVO_SPECIFIC_MON_IN_PARTY 29 // Pokémon levels up with a specified Pokémon in party #define EVO_LEVEL_DARK_TYPE_MON_IN_PARTY 30 // Pokémon reaches the specified level with a Dark Type Pokémon in party +#define EVO_TRADE_SPECIFIC_MON 31 // Pokémon is traded for a specified Pokémon #define EVOS_PER_MON 8 diff --git a/include/pokemon.h b/include/pokemon.h index a9ce1d149..4f8670b46 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -347,7 +347,7 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit); u8 *UseStatIncreaseItem(u16 itemId); u8 GetNature(struct Pokemon *mon); u8 GetNatureFromPersonality(u32 personality); -u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem); +u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem, u16 tradePartnerSpecies); u16 HoennPokedexNumToSpecies(u16 hoennNum); u16 NationalPokedexNumToSpecies(u16 nationalNum); u16 NationalToHoennOrder(u16 nationalNum); diff --git a/src/battle_main.c b/src/battle_main.c index d6191918f..443893712 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5102,7 +5102,7 @@ static void TryEvolvePokemon(void) levelUpBits &= ~(gBitTable[i]); gLeveledUpInBattle = levelUpBits; - species = GetEvolutionTargetSpecies(&gPlayerParty[i], 0, levelUpBits); + species = GetEvolutionTargetSpecies(&gPlayerParty[i], 0, levelUpBits, SPECIES_NONE); if (species != SPECIES_NONE) { FreeAllWindowBuffers(); diff --git a/src/data/pokemon/evolution.h b/src/data/pokemon/evolution.h index ef052dd3f..06a2bb571 100644 --- a/src/data/pokemon/evolution.h +++ b/src/data/pokemon/evolution.h @@ -354,7 +354,7 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_VANILLITE] = {{EVO_LEVEL, 35, SPECIES_VANILLISH}}, [SPECIES_VANILLISH] = {{EVO_LEVEL, 47, SPECIES_VANILLUXE}}, [SPECIES_DEERLING] = {{EVO_LEVEL, 34, SPECIES_SAWSBUCK}}, - [SPECIES_KARRABLAST] = {{EVO_LEVEL, SPECIES_SHELMET, SPECIES_ESCAVALIER}}, + [SPECIES_KARRABLAST] = {{EVO_TRADE_SPECIFIC_MON, SPECIES_SHELMET, SPECIES_ESCAVALIER}}, [SPECIES_FOONGUS] = {{EVO_LEVEL, 39, SPECIES_AMOONGUSS}}, [SPECIES_FRILLISH] = {{EVO_LEVEL, 40, SPECIES_JELLICENT}}, [SPECIES_JOLTIK] = {{EVO_LEVEL, 36, SPECIES_GALVANTULA}}, @@ -369,7 +369,7 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_AXEW] = {{EVO_LEVEL, 38, SPECIES_FRAXURE}}, [SPECIES_FRAXURE] = {{EVO_LEVEL, 48, SPECIES_HAXORUS}}, [SPECIES_CUBCHOO] = {{EVO_LEVEL, 37, SPECIES_BEARTIC}}, - [SPECIES_SHELMET] = {{EVO_LEVEL, SPECIES_KARRABLAST, SPECIES_ACCELGOR}}, + [SPECIES_SHELMET] = {{EVO_TRADE_SPECIFIC_MON, SPECIES_KARRABLAST, SPECIES_ACCELGOR}}, [SPECIES_MIENFOO] = {{EVO_LEVEL, 50, SPECIES_MIENSHAO}}, [SPECIES_GOLETT] = {{EVO_LEVEL, 43, SPECIES_GOLURK}}, [SPECIES_PAWNIARD] = {{EVO_LEVEL, 52, SPECIES_BISHARP}}, diff --git a/src/party_menu.c b/src/party_menu.c index 1d4952375..f9e073193 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -915,7 +915,7 @@ static bool8 DisplayPartyPokemonDataForMoveTutorOrEvolutionItem(u8 slot) DisplayPartyPokemonDataToTeachMove(slot, item, 0); break; case 2: // Evolution stone - if (!GetMonData(currentPokemon, MON_DATA_IS_EGG) && GetEvolutionTargetSpecies(currentPokemon, 3, item) != SPECIES_NONE) + if (!GetMonData(currentPokemon, MON_DATA_IS_EGG) && GetEvolutionTargetSpecies(currentPokemon, 3, item, SPECIES_NONE) != SPECIES_NONE) return FALSE; DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_NO_USE); break; @@ -5017,7 +5017,7 @@ static void Task_TryLearningNextMove(u8 taskId) static void PartyMenuTryEvolution(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; - u16 targetSpecies = GetEvolutionTargetSpecies(mon, 0, 0); + u16 targetSpecies = GetEvolutionTargetSpecies(mon, 0, ITEM_NONE, SPECIES_NONE); if (targetSpecies != SPECIES_NONE) { diff --git a/src/pokemon.c b/src/pokemon.c index 2086f02dd..2898c8fed 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5304,7 +5304,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov // Evolution stone case 7: { - u16 targetSpecies = GetEvolutionTargetSpecies(mon, 2, item); + u16 targetSpecies = GetEvolutionTargetSpecies(mon, 2, item, SPECIES_NONE); if (targetSpecies != SPECIES_NONE) { @@ -5669,7 +5669,7 @@ u8 GetNatureFromPersonality(u32 personality) return personality % NUM_NATURES; } -u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem) +u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem, u16 tradePartnerSpecies) { int i, j; u16 targetSpecies = 0; @@ -5857,6 +5857,10 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem) targetSpecies = gEvolutionTable[species][i].targetSpecies; } break; + case EVO_TRADE_SPECIFIC_MON: + if (gEvolutionTable[species][i].param == tradePartnerSpecies) + targetSpecies = gEvolutionTable[species][i].targetSpecies; + break; } } break; diff --git a/src/trade.c b/src/trade.c index 5ba26842f..c58c8d21f 100644 --- a/src/trade.c +++ b/src/trade.c @@ -3735,7 +3735,7 @@ static bool8 AnimateTradeSequenceCable(void) case 72: // Only if in-game trade TradeMons(gSpecialVar_0x8005, 0); gCB2_AfterEvolution = CB2_UpdateInGameTrade; - evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES)); if (evoTarget != SPECIES_NONE) { TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); @@ -4250,7 +4250,7 @@ static bool8 AnimateTradeSequenceWireless(void) case 72: // Only if in-game trade TradeMons(gSpecialVar_0x8005, 0); gCB2_AfterEvolution = CB2_UpdateInGameTrade; - evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES)); if (evoTarget != SPECIES_NONE) { TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); @@ -4293,7 +4293,7 @@ static void CB2_TryTradeEvolution(void) break; case 4: gCB2_AfterEvolution = CB2_SaveAndEndTrade; - evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES)); if (evoTarget != SPECIES_NONE) TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); else if (IsWirelessTrade())