diff --git a/Repeated-Field-Medicine-Use.md b/Repeated-Field-Medicine-Use.md index ac50049..aa6286a 100644 --- a/Repeated-Field-Medicine-Use.md +++ b/Repeated-Field-Medicine-Use.md @@ -98,20 +98,39 @@ Finally, find `Task_DisplayHPRestoredMessage`. Replace `gTasks[taskId].func = Ta ## Addendum: Rare Candies -Credit: AsparagusEduardo +Credit: AsparagusEduardo, ghoulslash -You may also want to use this for Rare Candies, so all you have to do is find `PartyMenuTryEvolution` and replace `gTasks[taskId].func = Task_ClosePartyMenuAfterText;` with: +You may also want to use this for Rare Candies, so all you have to do is find `PartyMenuTryEvolution` and replace it with: ```c - if (gPartyMenu.menuType == PARTY_MENU_TYPE_FIELD && CheckBagHasItem(gSpecialVar_ItemId, 1)) - gTasks[taskId].func = Task_ReturnToChooseMonAfterText; +static void PartyMenuTryEvolution(u8 taskId) +{ + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; + u16 targetSpecies = GetEvolutionTargetSpecies(mon, 0, 0); + + if (targetSpecies != SPECIES_NONE) + { + FreePartyPointers(); + if (gSpecialVar_ItemId == ITEM_RARE_CANDY && gPartyMenu.menuType == PARTY_MENU_TYPE_FIELD && CheckBagHasItem(gSpecialVar_ItemId, 1)) + gCB2_AfterEvolution = CB2_ReturnToPartyMenuUsingRareCandy; + else + gCB2_AfterEvolution = gPartyMenu.exitCallback; + BeginEvolutionScene(mon, targetSpecies, 1, gPartyMenu.slotId); + DestroyTask(taskId); + } else - gTasks[taskId].func = Task_ClosePartyMenuAfterText; + { + if (gPartyMenu.menuType == PARTY_MENU_TYPE_FIELD && CheckBagHasItem(gSpecialVar_ItemId, 1)) + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; + else + gTasks[taskId].func = Task_ClosePartyMenuAfterText; + } +} ``` - -And finally, when using a Rare Candy on a Level 100 Pokémon it would normally go back to the Bag menu. To avoid that, we search for `ItemUseCB_RareCandy` and replace `gTasks[taskId].func = task;` with: +And add the function, `CB2_ReturnToPartyMenuUsingRareCandy`, somewhere in the file: ```c - if (gPartyMenu.menuType == PARTY_MENU_TYPE_FIELD) - gTasks[taskId].func = Task_ReturnToChooseMonAfterText; - else - gTasks[taskId].func = task; +static void CB2_ReturnToPartyMenuUsingRareCandy(void) +{ + gItemUseCB = ItemUseCB_RareCandy; + SetMainCallback2(CB2_ShowPartyMenuForItemUse); +} ``` \ No newline at end of file