From cf711d916408f9355ca8c6507d559802318dfe44 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sun, 21 May 2023 09:13:38 -0700 Subject: [PATCH] Initialize `gSlotAgeReqs[SLOT_TRADE_CHILD]` and `gItemAgeReqs[ITEM_MASK_BUNNY]` on load initialization according to `gMMBunnyHood` and `gTimelessEquipment` to prevent bunny hood from being unequipped from adult equips on first load. (#2904) Move the code to change those values based on the child trade slot item to the selecting mask loop to not be setting them every frame just because you're in the inventory. --- soh/include/variables.h | 1 + soh/src/code/z_play.c | 9 +++++++++ .../overlays/misc/ovl_kaleido_scope/z_kaleido_item.c | 12 ++++++------ .../misc/ovl_kaleido_scope/z_kaleido_scope.h | 1 - 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/soh/include/variables.h b/soh/include/variables.h index a2ac65faf..55adf0d2e 100644 --- a/soh/include/variables.h +++ b/soh/include/variables.h @@ -103,6 +103,7 @@ extern "C" extern u32 gGsFlagsShifts[4]; extern void* gItemIcons[0x82]; extern u8 gItemAgeReqs[]; + extern u8 gSlotAgeReqs[]; extern u8 gItemSlots[56]; extern void (*gSceneCmdHandlers[SCENE_CMD_ID_MAX])(PlayState*, SceneCmd*); extern s16 gLinkObjectIds[2]; diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 9ac45cdcc..3804b5bfc 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -604,6 +604,15 @@ void Play_Init(GameState* thisx) { (s32)(zAllocAligned + zAllocSize) - (s32)(zAllocAligned - zAlloc)); Fault_AddClient(&D_801614B8, ZeldaArena_Display, NULL, NULL); + // In order to keep bunny hood equipped on first load, we need to pre-set the age reqs for the item and slot + if (CVarGetInteger("gMMBunnyHood", 0) || CVarGetInteger("gTimelessEquipment", 0)) { + gItemAgeReqs[ITEM_MASK_BUNNY] = 9; + if(INV_CONTENT(ITEM_TRADE_CHILD) == ITEM_MASK_BUNNY) + gSlotAgeReqs[SLOT_TRADE_CHILD] = 9; + } + else { + gItemAgeReqs[ITEM_MASK_BUNNY] = gSlotAgeReqs[SLOT_TRADE_CHILD] = 1; + } func_800304DC(play, &play->actorCtx, play->linkActorEntry); while (!func_800973FC(play, &play->roomCtx)) { diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c index aae19180e..53bec6c7a 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c @@ -344,12 +344,6 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { pauseCtx->cursorItem[PAUSE_ITEM] = cursorItem; pauseCtx->cursorSlot[PAUSE_ITEM] = cursorSlot; - gSlotAgeReqs[SLOT_TRADE_CHILD] = gItemAgeReqs[ITEM_MASK_BUNNY] = - ((CVarGetInteger("gMMBunnyHood", 0) || CVarGetInteger("gTimelessEquipment", 0)) && - INV_CONTENT(ITEM_TRADE_CHILD) == ITEM_MASK_BUNNY) - ? 9 - : 1; - if (!CHECK_SLOT_AGE(cursorSlot)) { pauseCtx->nameColorSet = 1; } @@ -405,6 +399,12 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { } } gSelectingMask = cursorSlot == SLOT_TRADE_CHILD; + + gSlotAgeReqs[SLOT_TRADE_CHILD] = gItemAgeReqs[ITEM_MASK_BUNNY] = + ((CVarGetInteger("gMMBunnyHood", 0) || CVarGetInteger("gTimelessEquipment", 0)) && + INV_CONTENT(ITEM_TRADE_CHILD) == ITEM_MASK_BUNNY) + ? 9 + : 1; } if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SHUFFLE_ADULT_TRADE) && cursorSlot == SLOT_TRADE_ADULT && CHECK_BTN_ALL(input->press.button, BTN_A)) { diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h index ad53fdd3a..a3c97d9b2 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h @@ -7,7 +7,6 @@ extern u8 gAmmoItems[]; extern s16 D_8082AAEC[]; extern s16 D_8082AB2C[]; -extern u8 gSlotAgeReqs[]; extern u8 gEquipAgeReqs[][4]; extern u8 gAreaGsFlags[]; extern bool gSelectingMask;