diff options
-rw-r--r-- | Plural-Giveitem.md | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Plural-Giveitem.md b/Plural-Giveitem.md new file mode 100644 index 0000000..c1520c0 --- /dev/null +++ b/Plural-Giveitem.md @@ -0,0 +1,57 @@ +## Proper Plural "giveitem" Command + +Currently, receiving multiple of a given item does not take into account the plurality unless it is a Poke Ball or a Berry. This small change will result in proper messages for such instances. + +### Copy the new string +Let's change `CopyItemNameHandlePlural` in [src/item.c](../blob/master/src/item.c) to the following +```c +static const u8 sText_s[] = _("S"); +void CopyItemNameHandlePlural(u16 itemId, u8 *dst, u32 quantity) +{ + StringCopy(dst, ItemId_GetName(itemId)); + if (quantity > 1) + { + if (ItemId_GetPocket(itemId) == POCKET_BERRIES) + GetBerryCountString(dst, gBerries[itemId - ITEM_CHERI_BERRY].name, quantity); + else + StringAppend(dst, sText_s); + } +} +``` +Change `static const u8 sText_s[] = _("S");` to `static const u8 sText_s[] = _("s");` if you have de-capitalized your item names. + +### Change the obtain item message +Add the following to [data/text/obtain_item.inc](../blob/master/data/text/obtain_item.inc): +```c +gText_ObtainedTheItems:: + .string "Obtained {STR_VAR_1} {STR_VAR_2}!$" +``` + +### Change the obtain item script +Open [data/scripts/obtain_item.inc](../blob/master/data/scripts/obtain_item.inc). Find `EventScript_ObtainedItem`, and modify it to the following: +```c +EventScript_ObtainedItem:: @ 8271B95 + compare VAR_0x8001, 1 + goto_if_eq EventScript_ObtainedItemMessage + buffernumberstring 0, VAR_0x8001 + message gText_ObtainedTheItems + goto EventScript_ContinueObtainedItem +EventScript_ObtainedItemMessage: + message gText_ObtainedTheItem +EventScript_ContinueObtainedItem: + waitfanfare + msgbox gText_PutItemInPocket, MSGBOX_DEFAULT + setvar VAR_RESULT, 1 + return +``` + +### Example +The following GIF shows the messages for the following script: +```c +VerdanturfTown_EventScript_TownSign:: + giveitem ITEM_POTION, 2 + giveitem ITEM_ORAN_BERRY, 3 + giveitem ITEM_POKE_BALL, 1 + end +``` +<a href="https://imgur.com/1cDuh4f"><img src="https://i.imgur.com/1cDuh4f.gif" title="source: imgur.com" /></a>
\ No newline at end of file |