summaryrefslogtreecommitdiff
path: root/Plural-Giveitem.md
blob: 82260aa886e195f08c83e82e0eeebd34de30f749 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
## 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](../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>

## Make them work with found items

Credit to Jaizu

### Change the found item message
Add the following to [data/text/obtain_item.inc](../blob/master/data/text/obtain_item.inc):
```c
gText_PlayerFoundItems::
    .string "{PLAYER} found {STR_VAR_1} {STR_VAR_2}!$"
```

### Change the found item script
Open [data/scripts/obtain_item.inc](../blob/master/data/scripts/obtain_item.inc). Find `EventScript_FoundItem`, and modify it to the following:
```c
EventScript_FoundItem:: @ 8271C9B
    compare VAR_0x8001, 1
    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.


![](https://i.imgur.com/ZvlAIIB.png)