2 Increase item bag capacity
judicornadamsfoster edited this page 2026-07-05 21:12:29 +01:00

original source: MapleFall's pokecommunity post and Lunos' 999 items branch

This code increases the bag item capacity from 99 up to 999 items

pokeemerald-0 pokeemerald-2

include/shop.h is now at src/shop.c and is slightly different code to the original

the below code is also on a branch:
compare here / branch here


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);