5 Plural Giveitem
Jaizu edited this page 2022-08-03 12:09:19 +02:00

Proper Plural "giveitem" Command

Credit to ghoulslash

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, TRUE
	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, TRUE
	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

Make them work with found items

Credit to Jaizu

Change the found item message

Add the following to data/text/obtain_item.inc:

gText_PlayerFoundItems::
    .string "{PLAYER} found {STR_VAR_1} {STR_VAR_2}!$"

Change the found item script

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

EventScript_FoundItem:: @ 8271C9B
    compare VAR_0x8001, TRUE
    goto_if_eq EventScript_FoundItemMessage
    buffernumberstring 0, VAR_0x8001
    message gText_PlayerFoundItems
    return
EventScript_FoundItemMessage::
    message gText_PlayerFoundOneItem
    return

Result

Please ignore the custom graphics, text color and item description, feel free to update the wiki with a vanilla screenshot.