Skip to content
ghoulslash edited this page Jul 1, 2020 · 5 revisions

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 to the following

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:

gText_ObtainedTheItems::
    .string "Obtained {STR_VAR_1} {STR_VAR_2}!$"

Change the obtain item script

Open data/scripts/obtain_item.inc. Find EventScript_ObtainedItem, and modify it to the following:

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:

VerdanturfTown_EventScript_TownSign::
    giveitem ITEM_POTION, 2
    giveitem ITEM_ORAN_BERRY, 3
    giveitem ITEM_POKE_BALL, 1
    end

Clone this wiki locally