From a5c0cede12d3a53cb0f1069a5d4a5c4febe991fa Mon Sep 17 00:00:00 2001 From: Pepe20129 <72659707+Pepe20129@users.noreply.github.com> Date: Wed, 17 Jul 2024 18:42:56 +0200 Subject: Rando: Shuffle consumable bags (#3959) * Main implementation * Fix sticks & nuts from shops & checks * Change the models to normal stick & nut Worth noting that before you have the bags, the refills are blue rupees so there will not be model collision * Update hook_handlers.cpp --- soh/src/code/z_parameter.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'soh/src/code') diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 658e96394..2f39ade8c 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1926,6 +1926,26 @@ u8 Return_Item(u8 itemID, ModIndex modId, ItemID returnItem) { * @return u8 */ u8 Item_Give(PlayState* play, u8 item) { + //prevents getting sticks without the bag in case something got missed + if ( + IS_RANDO && + (item == ITEM_STICK || item == ITEM_STICKS_5 || item == ITEM_STICKS_10) && + Randomizer_GetSettingValue(RSK_SHUFFLE_DEKU_STICK_BAG) && + CUR_UPG_VALUE(UPG_STICKS) == 0 + ) { + return; + } + + //prevents getting nuts without the bag in case something got missed + if ( + IS_RANDO && + (item == ITEM_NUT || item == ITEM_NUTS_5 || item == ITEM_NUTS_10) && + Randomizer_GetSettingValue(RSK_SHUFFLE_DEKU_NUT_BAG) && + CUR_UPG_VALUE(UPG_NUTS) == 0 + ) { + return; + } + lusprintf(__FILE__, __LINE__, 2, "Item Give - item: %#x", item); static s16 sAmmoRefillCounts[] = { 5, 10, 20, 30, 5, 10, 30, 0, 5, 20, 1, 5, 20, 50, 200, 10 }; s16 i; @@ -2776,6 +2796,20 @@ u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) { return Return_Item_Entry(giEntry, RG_NONE); } + if (item == RG_DEKU_STICK_BAG) { + Inventory_ChangeUpgrade(UPG_STICKS, 1); + INV_CONTENT(ITEM_STICK) = ITEM_STICK; + AMMO(ITEM_STICK) = CUR_CAPACITY(UPG_STICKS); + return Return_Item_Entry(giEntry, RG_NONE); + } + + if (item == RG_DEKU_NUT_BAG) { + Inventory_ChangeUpgrade(UPG_NUTS, 1); + INV_CONTENT(ITEM_NUT) = ITEM_NUT; + AMMO(ITEM_NUT) = CUR_CAPACITY(UPG_NUTS); + return Return_Item_Entry(giEntry, RG_NONE); + } + temp = gSaveContext.inventory.items[slot]; osSyncPrintf("Item_Register(%d)=%d %d\n", slot, item, temp); INV_CONTENT(item) = item; -- cgit v1.2.3