1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
## Keep Party Menu Open During Field Medicine Use
Credit: ghoulslash
You can pull directly from their branch, here: https://github.com/ghoulslash/pokeemerald/tree/field-medicine
If you're using a lot of potions at once, it can be annoying to keep returning to the bag after use. This simple fix keeps the menu open unless you run out of potions. The user will have to select `Cancel` or press `B` to exit the party menu. But this is intuitive.
Let's start by opening [src/party_menu.c](../blob/master/src/party_menu.c)
### 1.
First, find the function `ItemUseCB_Medicine`. Replace the entire thing with:
```c
void ItemUseCB_Medicine(u8 taskId, TaskFunc task)
{
u16 hp = 0;
struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId];
u16 item = gSpecialVar_ItemId;
bool8 canHeal, cannotUse;
if (NotUsingHPEVItemOnShedinja(mon, item) == FALSE)
{
cannotUse = TRUE;
}
else
{
canHeal = IsHPRecoveryItem(item);
if (canHeal == TRUE)
{
hp = GetMonData(mon, MON_DATA_HP);
if (hp == GetMonData(mon, MON_DATA_MAX_HP))
canHeal = FALSE;
}
cannotUse = ExecuteTableBasedItemEffect_(gPartyMenu.slotId, item, 0);
}
if (cannotUse != FALSE)
{
gPartyMenuUseExitCallback = FALSE;
PlaySE(SE_SELECT);
DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE);
ScheduleBgCopyTilemapToVram(2);
if (gPartyMenu.menuType == PARTY_MENU_TYPE_FIELD)
gTasks[taskId].func = Task_ReturnToChooseMonAfterText;
else
gTasks[taskId].func = task;
return;
}
else
{
gPartyMenuUseExitCallback = TRUE;
if (!IsItemFlute(item))
{
PlaySE(SE_USE_ITEM);
if (gPartyMenu.action != PARTY_ACTION_REUSABLE_ITEM)
RemoveBagItem(item, 1);
}
else
{
PlaySE(SE_GLASS_FLUTE);
}
SetPartyMonAilmentGfx(mon, &sPartyMenuBoxes[gPartyMenu.slotId]);
if (gSprites[sPartyMenuBoxes[gPartyMenu.slotId].statusSpriteId].invisible)
DisplayPartyPokemonLevelCheck(mon, &sPartyMenuBoxes[gPartyMenu.slotId], 1);
if (canHeal == TRUE)
{
if (hp == 0)
AnimatePartySlot(gPartyMenu.slotId, 1);
PartyMenuModifyHP(taskId, gPartyMenu.slotId, 1, GetMonData(mon, MON_DATA_HP) - hp, Task_DisplayHPRestoredMessage);
ResetHPTaskData(taskId, 0, hp);
return;
}
else
{
GetMonNickname(mon, gStringVar1);
GetMedicineItemEffectMessage(item);
DisplayPartyMenuMessage(gStringVar4, TRUE);
ScheduleBgCopyTilemapToVram(2);
if (gPartyMenu.menuType == PARTY_MENU_TYPE_FIELD && CheckBagHasItem(item, 1))
gTasks[taskId].func = Task_ReturnToChooseMonAfterText;
else
gTasks[taskId].func = task;
}
}
}
```
### 2.
Finally, find `Task_DisplayHPRestoredMessage`. Replace `gTasks[taskId].func = Task_ClosePartyMenuAfterText;` with:
```c
if (gPartyMenu.menuType == PARTY_MENU_TYPE_FIELD && CheckBagHasItem(gSpecialVar_ItemId, 1))
gTasks[taskId].func = Task_ReturnToChooseMonAfterText;
else
gTasks[taskId].func = Task_ClosePartyMenuAfterText;
```
## Addendum: Rare Candies
Credit: AsparagusEduardo
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:
```c
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:
```c
if (gPartyMenu.menuType == PARTY_MENU_TYPE_FIELD)
gTasks[taskId].func = Task_ReturnToChooseMonAfterText;
else
gTasks[taskId].func = task;
```
|