diff options
author | ghoulslash <41651341+ghoulslash@users.noreply.github.com> | 2021-01-21 09:00:07 -0700 |
---|---|---|
committer | ghoulslash <41651341+ghoulslash@users.noreply.github.com> | 2021-01-21 09:00:07 -0700 |
commit | 0554f529e8ba830fcfac6696e02fe4a5dcdac7f8 (patch) | |
tree | 856834f2ee2c481638dc1fb427acd40a04dd7d8f | |
parent | 749a0825b21a8524d738b0b9922ddb5b464fdab7 (diff) |
Updated Repeated Field Medicine Use (markdown)
-rw-r--r-- | Repeated-Field-Medicine-Use.md | 93 |
1 files changed, 64 insertions, 29 deletions
diff --git a/Repeated-Field-Medicine-Use.md b/Repeated-Field-Medicine-Use.md index 312715e..188fef2 100644 --- a/Repeated-Field-Medicine-Use.md +++ b/Repeated-Field-Medicine-Use.md @@ -8,48 +8,83 @@ Let's start by opening [src/party_menu.c](../blob/master/src/party_menu.c) ### 1. -First, find the function `ItemUseCB_Medicine`. Inside the code block that starts with `if (ExecuteTableBasedItemEffect_(gPartyMenu.slotId, item, 0))`, replace `gTasks[taskId].func = task;` with: +First, find the function `ItemUseCB_Medicine`. Replace the entire thing with: ```c -if (gPartyMenu.menuType == PARTY_MENU_TYPE_FIELD) - gTasks[taskId].func = Task_ReturnToChooseMonAfterText; -else - gTasks[taskId].func = task; -``` - - -### 2. - -Next, stay in the function `ItemUseCB_Medicine`. Towards the end of the function, replace -```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 { - GetMonNickname(mon, gStringVar1); - GetMedicineItemEffectMessage(item); - DisplayPartyMenuMessage(gStringVar4, TRUE); - ScheduleBgCopyTilemapToVram(2); - gTasks[taskId].func = task; + 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); } -``` - -with -```c - ..... - else + if (cannotUse != FALSE) { - GetMonNickname(mon, gStringVar1); - GetMedicineItemEffectMessage(item); - DisplayPartyMenuMessage(gStringVar4, TRUE); + gPartyMenuUseExitCallback = FALSE; + PlaySE(SE_SELECT); + DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); ScheduleBgCopyTilemapToVram(2); - if (gPartyMenu.menuType == PARTY_MENU_TYPE_FIELD && CheckBagHasItem(item, 1)) + 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; + } } +} ``` -### 3. +### 2. Finally, find `Task_DisplayHPRestoredMessage`. Replace `gTasks[taskId].func = Task_ClosePartyMenuAfterText;` with: ```c |