From 34ce08db0b7ceda4cd6d8ae79cec2499b1dde745 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 14 Oct 2020 20:16:18 -0300 Subject: [PATCH 1/3] Added Karrablast/Shelmet evolution method. --- include/constants/pokemon.h | 1 + include/pokemon.h | 2 +- src/battle_main.c | 2 +- src/data/pokemon/evolution.h | 4 ++-- src/party_menu.c | 4 ++-- src/pokemon.c | 8 ++++++-- src/trade.c | 6 +++--- 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 7708dd2f84..e87f8f8220 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 6c98e0f970..e12ba5bd5c 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -346,7 +346,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 d6191918fa..e7133a06f2 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, 0); if (species != SPECIES_NONE) { FreeAllWindowBuffers(); diff --git a/src/data/pokemon/evolution.h b/src/data/pokemon/evolution.h index e515f2117d..8057ac6f20 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 1d49523756..0b4e6cfa79 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, 0) != 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, 0, 0); if (targetSpecies != SPECIES_NONE) { diff --git a/src/pokemon.c b/src/pokemon.c index 2086f02dd7..9e7f7b0d50 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, 0); 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 5ba26842f1..60ab938284 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, 0)); 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, 0)); 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, 0)); if (evoTarget != SPECIES_NONE) TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); else if (IsWirelessTrade()) From 86334ca01181574a9c17b98568ee6b296cd59910 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 14 Oct 2020 20:50:33 -0300 Subject: [PATCH 2/3] 0 for SPECIES_NONE --- src/battle_main.c | 2 +- src/party_menu.c | 4 ++-- src/pokemon.c | 2 +- src/trade.c | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index e7133a06f2..443893712e 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, 0); + species = GetEvolutionTargetSpecies(&gPlayerParty[i], 0, levelUpBits, SPECIES_NONE); if (species != SPECIES_NONE) { FreeAllWindowBuffers(); diff --git a/src/party_menu.c b/src/party_menu.c index 0b4e6cfa79..f9e0731933 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, 0) != 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, 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 9e7f7b0d50..2898c8fedd 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, 0); + u16 targetSpecies = GetEvolutionTargetSpecies(mon, 2, item, SPECIES_NONE); if (targetSpecies != SPECIES_NONE) { diff --git a/src/trade.c b/src/trade.c index 60ab938284..e5e5254a1d 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, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES, 0)); + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES, SPECIES_NONE)); 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, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES, 0)); + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES, SPECIES_NONE)); 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, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES, 0)); + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES, SPECIES_NONE)); if (evoTarget != SPECIES_NONE) TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); else if (IsWirelessTrade()) From be2c56cc94100f3dfbc3eac87736bc3c550a15ba Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 15 Oct 2020 16:19:37 -0300 Subject: [PATCH 3/3] Shortened GetEvolutionTargetSpecies calls. --- src/trade.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/trade.c b/src/trade.c index e5e5254a1d..c58c8d21f8 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, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES, SPECIES_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, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES, SPECIES_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, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES, SPECIES_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())