Fixed Shelmet and Karrablast being able to evolve if the partner is holding an Everstone

This commit is contained in:
Eduardo Quezada D'Ottone 2022-02-26 21:40:20 -03:00
parent 74766c9a6e
commit ed1ea69759
5 changed files with 30 additions and 10 deletions

View File

@ -385,7 +385,7 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit);
u8 *UseStatIncreaseItem(u16 itemId); u8 *UseStatIncreaseItem(u16 itemId);
u8 GetNature(struct Pokemon *mon); u8 GetNature(struct Pokemon *mon);
u8 GetNatureFromPersonality(u32 personality); u8 GetNatureFromPersonality(u32 personality);
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem, u16 tradePartnerSpecies); u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem, struct Pokemon *tradePartner);
u16 HoennPokedexNumToSpecies(u16 hoennNum); u16 HoennPokedexNumToSpecies(u16 hoennNum);
u16 NationalPokedexNumToSpecies(u16 nationalNum); u16 NationalPokedexNumToSpecies(u16 nationalNum);
u16 NationalToHoennOrder(u16 nationalNum); u16 NationalToHoennOrder(u16 nationalNum);

View File

@ -5150,7 +5150,7 @@ static void TryEvolvePokemon(void)
levelUpBits &= ~(gBitTable[i]); levelUpBits &= ~(gBitTable[i]);
gLeveledUpInBattle = levelUpBits; gLeveledUpInBattle = levelUpBits;
species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_NORMAL, levelUpBits, SPECIES_NONE); species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_NORMAL, levelUpBits, NULL);
if (species != SPECIES_NONE) if (species != SPECIES_NONE)
{ {
FreeAllWindowBuffers(); FreeAllWindowBuffers();

View File

@ -915,7 +915,7 @@ static bool8 DisplayPartyPokemonDataForMoveTutorOrEvolutionItem(u8 slot)
DisplayPartyPokemonDataToTeachMove(slot, item, 0); DisplayPartyPokemonDataToTeachMove(slot, item, 0);
break; break;
case 2: // Evolution stone case 2: // Evolution stone
if (!GetMonData(currentPokemon, MON_DATA_IS_EGG) && GetEvolutionTargetSpecies(currentPokemon, EVO_MODE_ITEM_CHECK, item, SPECIES_NONE) != SPECIES_NONE) if (!GetMonData(currentPokemon, MON_DATA_IS_EGG) && GetEvolutionTargetSpecies(currentPokemon, EVO_MODE_ITEM_CHECK, item, NULL) != SPECIES_NONE)
return FALSE; return FALSE;
DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_NO_USE); DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_NO_USE);
break; break;
@ -5026,7 +5026,7 @@ static void Task_TryLearningNextMove(u8 taskId)
static void PartyMenuTryEvolution(u8 taskId) static void PartyMenuTryEvolution(u8 taskId)
{ {
struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId];
u16 targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_NORMAL, ITEM_NONE, SPECIES_NONE); u16 targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_NORMAL, ITEM_NONE, NULL);
if (targetSpecies != SPECIES_NONE) if (targetSpecies != SPECIES_NONE)
{ {

View File

@ -6086,7 +6086,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
case 7: // ITEM4_EVO_STONE case 7: // ITEM4_EVO_STONE
{ {
u16 targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_ITEM_USE, item, SPECIES_NONE); u16 targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_ITEM_USE, item, NULL);
if (targetSpecies != SPECIES_NONE) if (targetSpecies != SPECIES_NONE)
{ {
@ -6410,7 +6410,7 @@ u8 GetNatureFromPersonality(u32 personality)
return personality % NUM_NATURES; return personality % NUM_NATURES;
} }
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, u16 tradePartnerSpecies) u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, struct Pokemon *tradePartner)
{ {
int i, j; int i, j;
u16 targetSpecies = 0; u16 targetSpecies = 0;
@ -6423,6 +6423,26 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, u
u16 upperPersonality = personality >> 16; u16 upperPersonality = personality >> 16;
u8 holdEffect; u8 holdEffect;
u16 currentMap; u16 currentMap;
u16 partnerSpecies;
u16 partnerHeldItem;
u8 partnerHoldEffect;
if (tradePartner != NULL)
{
partnerSpecies = GetMonData(tradePartner, MON_DATA_SPECIES, 0);
partnerHeldItem = GetMonData(tradePartner, MON_DATA_HELD_ITEM, 0);
if (partnerHeldItem == ITEM_ENIGMA_BERRY)
partnerHoldEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect;
else
partnerHoldEffect = ItemId_GetHoldEffect(partnerHeldItem);
}
else
{
partnerSpecies = SPECIES_NONE;
partnerHeldItem = ITEM_NONE;
partnerHoldEffect = HOLD_EFFECT_NONE;
}
if (heldItem == ITEM_ENIGMA_BERRY) if (heldItem == ITEM_ENIGMA_BERRY)
holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect; holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect;
@ -6654,7 +6674,7 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, u
} }
break; break;
case EVO_TRADE_SPECIFIC_MON: case EVO_TRADE_SPECIFIC_MON:
if (gEvolutionTable[species][i].param == tradePartnerSpecies) if (gEvolutionTable[species][i].param == partnerSpecies && partnerHoldEffect != HOLD_EFFECT_PREVENT_EVOLVE)
targetSpecies = gEvolutionTable[species][i].targetSpecies; targetSpecies = gEvolutionTable[species][i].targetSpecies;
break; break;
} }

View File

@ -3798,7 +3798,7 @@ static bool8 AnimateTradeSequenceCable(void)
case TS_STATE_TRY_EVOLUTION: // Only if in-game trade, link trades use CB2_TryLinkTradeEvolution case TS_STATE_TRY_EVOLUTION: // Only if in-game trade, link trades use CB2_TryLinkTradeEvolution
TradeMons(gSpecialVar_0x8005, 0); TradeMons(gSpecialVar_0x8005, 0);
gCB2_AfterEvolution = CB2_UpdateInGameTrade; gCB2_AfterEvolution = CB2_UpdateInGameTrade;
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES)); evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE, &gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]]);
if (evoTarget != SPECIES_NONE) if (evoTarget != SPECIES_NONE)
{ {
TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->monSpriteIds[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->monSpriteIds[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]);
@ -4298,7 +4298,7 @@ static bool8 AnimateTradeSequenceWireless(void)
case TS_STATE_TRY_EVOLUTION: // Only if in-game trade, link trades use CB2_TryLinkTradeEvolution case TS_STATE_TRY_EVOLUTION: // Only if in-game trade, link trades use CB2_TryLinkTradeEvolution
TradeMons(gSpecialVar_0x8005, 0); TradeMons(gSpecialVar_0x8005, 0);
gCB2_AfterEvolution = CB2_UpdateInGameTrade; gCB2_AfterEvolution = CB2_UpdateInGameTrade;
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES)); evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE, &gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]]);
if (evoTarget != SPECIES_NONE) if (evoTarget != SPECIES_NONE)
{ {
TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->monSpriteIds[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->monSpriteIds[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]);
@ -4343,7 +4343,7 @@ static void CB2_TryLinkTradeEvolution(void)
break; break;
case 4: case 4:
gCB2_AfterEvolution = CB2_SaveAndEndTrade; gCB2_AfterEvolution = CB2_SaveAndEndTrade;
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE, GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]], MON_DATA_SPECIES)); evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], EVO_MODE_TRADE, ITEM_NONE, &gPlayerParty[gSelectedTradeMonPositions[TRADE_PARTNER]]);
if (evoTarget != SPECIES_NONE) if (evoTarget != SPECIES_NONE)
TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->monSpriteIds[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->monSpriteIds[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]);
else if (IsWirelessTrade()) else if (IsWirelessTrade())