Created Increase item bag capacity (markdown)

judicornadamsfoster
2026-07-05 21:04:20 +01:00
parent 1b92a11334
commit bb481bc3cc

@@ -0,0 +1,135 @@
original source: [MapleFall's pokecommunity post](https://www.pokecommunity.com/threads/simple-modifications-directory.416647/page-20#post-10523495) and
[Lunos' 999 items branch](https://github.com/LOuroboros/pokeemerald/tree/999items)
This code increases the bag item capacity from 99 up to 999 items
<img width="240" height="160" alt="pokeemerald-0" src="https://github.com/user-attachments/assets/c21f50bc-1b26-4d4d-9ce5-72c7a544583a" />
<img width="240" height="160" alt="pokeemerald-2" src="https://github.com/user-attachments/assets/b440bc4f-5ff1-4e57-a212-8eb5e9ff70f8" />
> `include/shop.h` is now at `src/shop.c` and is slightly different code to the original
__________
### include/constants/items.h
change `#define MAX_BAG_ITEM_CAPACITY 99` (at line 451)
to
```
#define MAX_BAG_ITEM_CAPACITY 999
```
__
change `#define BAG_ITEM_CAPACITY_DIGITS 2` (at line 455)
to
```
#define BAG_ITEM_CAPACITY_DIGITS 3
```
__________
### include/global.h
in section `struct PyramidBag` (line 224)
change `u8 quantity[FRONTIER_LVL_MODE_COUNT][PYRAMID_BAG_ITEMS_COUNT];`
to
```
u16 quantity[FRONTIER_LVL_MODE_COUNT][PYRAMID_BAG_ITEMS_COUNT];
```
__________
### src/shop.c
(data no longer stored in include/shop.h)
in section `struct ShopData` (line 94)
change `u8 maxQuantity;`
to
```
u16 maxQuantity;
```
__________
### src/battle_pyramid_bag.c
in these 3 sections (they are all after each other)
`static void SwapItems(u8 id1, u8 id2)` (line 725)
`static void MovePyramidBagItemSlotInList(u8 from, u8 to)` (line 735)
`static void CompactItems(void)` (line 768)
change `u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];`
to
```
u16 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
```
__
in section void `TryStoreHeldItemsInPyramidBag(void)` (line 1402)
change `u8 *newQuantities = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(*newQuantities));`
to
```
u16 *newQuantities = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(*newQuantities));
```
__________
### src/item.c
in these 4 sections (they're all after each other):
`static bool8 CheckPyramidBagHasItem(u16 itemId, u16 count)` (line 685)
`static bool8 CheckPyramidBagHasSpace(u16 itemId, u16 count)` (line 707)
`bool8 AddPyramidBagItem(u16 itemId, u16 count)` (line 729)
`bool8 RemovePyramidBagItem(u16 itemId, u16 count)` (line 802)
change `u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];`
to
```
u16 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
```
in these 2 sections:
`bool8 AddPyramidBagItem(u16 itemId, u16 count)` (line 729)
`bool8 RemovePyramidBagItem(u16 itemId, u16 count)` (line 802)
change `u8 *newQuantities = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(*newQuantities));`
to
```
u16 *newQuantities = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(*newQuantities));
```
__________
### src/scrcmd.c
> these 4 sections are after each other
__
in section `bool8 ScrCmd_additem(struct ScriptContext *ctx)` (line 488)
change `gSpecialVar_Result = AddBagItem(itemId, (u8)quantity);`
to
```
gSpecialVar_Result = AddBagItem(itemId, quantity);
```
__
in section `bool8 ScrCmd_removeitem(struct ScriptContext *ctx)` (line 497)
change `gSpecialVar_Result = RemoveBagItem(itemId, (u8)quantity);`
to
```
gSpecialVar_Result = RemoveBagItem(itemId, quantity);
```
__
in section `bool8 ScrCmd_checkitemspace(struct ScriptContext *ctx)` (line 506)
change `gSpecialVar_Result = CheckBagHasSpace(itemId, (u8)quantity);`
to
```
gSpecialVar_Result = CheckBagHasSpace(itemId, quantity);
```
in section `bool8 ScrCmd_checkitem(struct ScriptContext *ctx)` (line 515)
change `gSpecialVar_Result = CheckBagHasItem(itemId, (u8)quantity);`
to
```
gSpecialVar_Result = CheckBagHasItem(itemId, quantity);
```