summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorExpoSeed <43502820+ExpoSeed@users.noreply.github.com>2020-06-12 23:36:07 -0500
committerExpoSeed <43502820+ExpoSeed@users.noreply.github.com>2020-06-12 23:36:07 -0500
commitb03462d145b67282a53b2188447770d88c758118 (patch)
tree5afe658a2de1de71eb70de868e891d2cea54109d
parenta7c7af85392e4fc5995a2387a090c04d04dfd770 (diff)
Created Prompt for reusing Repels (markdown)
-rw-r--r--Prompt-for-reusing-Repels.md116
1 files changed, 116 insertions, 0 deletions
diff --git a/Prompt-for-reusing-Repels.md b/Prompt-for-reusing-Repels.md
new file mode 100644
index 0000000..2722202
--- /dev/null
+++ b/Prompt-for-reusing-Repels.md
@@ -0,0 +1,116 @@
+Credit to DizzyEgg for this feature. This feature may also be directly pulled from DizzyEgg's [repel](https://github.com/DizzyEggg/pokeemerald/tree/repel) branch.
+
+This tutorial will ask the player, upon a Repel running out, if they want to use another repel and also let the player choose which repel to use.
+
+## Contents
+1. [Modify multichoice menu to work with custom options](#1-modify-multichoice-menu-to-work-with-custom-options)
+2. [Modify Repel script](#2-modify-repel-script)
+## 1. Modify multichoice menu to work with custom options
+The Repel menu will use the custom multichoice.
+
+Edit [src/script_menu.c](../blob/master/src/script_menu.c)
+```diff
+-static void DrawMultichoiceMenu(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPress, u8 cursorPos)
++static void DrawMultichoiceMenuCustom(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPress, u8 cursorPos, const struct MenuAction *actions, int count)
+ {
+ int i;
+ u8 windowId;
+- u8 count = gMultichoiceLists[multichoiceId].count;
+- const struct MenuAction *actions = gMultichoiceLists[multichoiceId].list;
+ int width = 0;
+ u8 newWidth;
+
+ for (i = 0; i < count; i++)
+ {
+ width = display_text_and_get_width(actions[i].text, width);
+ }
+ newWidth = convert_pixel_width_to_tile_width(width);
+ left = ScriptMenu_AdjustLeftCoordFromWidth(left, newWidth);
+ windowId = CreateWindowFromRect(left, top, newWidth, count * 2);
+ SetStandardWindowBorderStyle(windowId, 0);
+ PrintMenuTable(windowId, count, actions);
+ InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, count, cursorPos);
+ schedule_bg_copy_tilemap_to_vram(0);
+ InitMultichoiceCheckWrap(ignoreBPress, count, windowId, multichoiceId);
+ }
+```
+Add the following new code:
+```c
+static void DrawMultichoiceMenu(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPress, u8 cursorPos)
+{
+ DrawMultichoiceMenuCustom(left, top, multichoiceId, ignoreBPress, cursorPos, gMultichoiceLists[multichoiceId].list, gMultichoiceLists[multichoiceId].count);
+}
+
+void TryDrawRepelMenu(void)
+{
+ static const u16 repelItems[] = {ITEM_REPEL, ITEM_SUPER_REPEL, ITEM_MAX_REPEL};
+ struct MenuAction menuItems[4] = {NULL};
+ int i, count = 0;
+
+ for (i = 0; i < ARRAY_COUNT(repelItems); i++)
+ {
+ if (CheckBagHasItem(repelItems[i], 1))
+ {
+ VarSet(VAR_0x8004 + count, repelItems[i]);
+ menuItems[count].text = ItemId_GetName(repelItems[i]);
+ count++;
+ }
+ }
+
+ if (count > 1)
+ DrawMultichoiceMenuCustom(0, 0, 0, FALSE, 0, menuItems, count);
+
+ gSpecialVar_Result = (count > 1);
+}
+
+void HandleRepelMenuChoice(void)
+{
+ gSpecialVar_0x8004 = VarGet(VAR_0x8004 + gSpecialVar_Result); // Get item Id;
+ VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_0x8004));
+}
+```
+## 2. Modify Repel script
+Replace the contents of [data/scripts/repel.inc](../blob/master/data/scripts/repel.inc):
+```c
+EventScript_RepelWoreOff:: @ 82A4B2A
+ msgbox Text_RepelWoreOff, MSGBOX_SIGN
+ checkitem ITEM_REPEL, 1
+ compare VAR_RESULT, TRUE
+ goto_if_eq EventScript_RepelWoreOff_AskAnother
+ checkitem ITEM_SUPER_REPEL, 1
+ compare VAR_RESULT, TRUE
+ goto_if_eq EventScript_RepelWoreOff_AskAnother
+ checkitem ITEM_MAX_REPEL, 1
+ compare VAR_RESULT, FALSE
+ goto_if_eq EventScript_RepelWoreOff_End
+EventScript_RepelWoreOff_AskAnother:
+ msgbox Text_RepelAskAnother, MSGBOX_YESNO
+ closemessage
+ compare VAR_RESULT, 0
+ goto_if_eq EventScript_RepelWoreOff_End
+ callnative TryDrawRepelMenu
+ compare VAR_RESULT, FALSE
+ goto_if_eq EventScript_RepelWoreOff_Chose
+ waitstate
+ compare VAR_RESULT, 127
+ goto_if_eq EventScript_RepelWoreOff_End
+EventScript_RepelWoreOff_Chose:
+ callnative HandleRepelMenuChoice
+ bufferitemname 1, VAR_0x8004
+ removeitem VAR_0x8004, 1
+ playse SE_TU_SAA
+ msgbox gText_PlayerUsedVar2, MSGBOX_SIGN
+EventScript_RepelWoreOff_End:
+ end
+
+Text_RepelWoreOff: @ 82A4B33
+ .string "REPEL's effect wore off…$"
+Text_RepelAskAnother:
+ .string "Would you like to use another one?$"
+```
+
+And that's it!
+
+![](https://i.imgur.com/XyhyJei.png)
+![](https://i.imgur.com/xUFZfPh.png)
+![](https://i.imgur.com/1KBYTJ7.png) \ No newline at end of file