From f865db5444c19c95fb94ce8aa9cdc9aa4850e59b Mon Sep 17 00:00:00 2001 From: vaguerant Date: Wed, 6 Jul 2022 09:29:43 +1000 Subject: [PATCH] MM Bunny Hood enhancements: no age restrictions & wear across entrances (#560) * Remove age restriction on MM Bunny Hood * Handle mask slot changing; init Link wearing mask * Reset mask state after selling --- .../actors/ovl_player_actor/z_player.c | 19 ++++++++++++++++++- .../misc/ovl_kaleido_scope/z_kaleido_item.c | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 8d51a055a..e6ca09d76 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -910,6 +910,8 @@ static s8 sItemActionParams[] = { PLAYER_AP_BOOTS_HOVER, }; +static u8 sMaskMemory; + static s32(*D_80853EDC[])(Player* this, GlobalContext* globalCtx) = { func_8083485C, func_8083485C, func_8083485C, func_808349DC, func_808349DC, func_808349DC, func_8083485C, func_8083485C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, @@ -1909,7 +1911,7 @@ void func_80833DF8(Player* this, GlobalContext* globalCtx) { if (gSaveContext.equips.buttonItems[0] != maskItem && gSaveContext.equips.buttonItems[1] != maskItem && gSaveContext.equips.buttonItems[2] != maskItem && gSaveContext.equips.buttonItems[3] != maskItem && !hasOnDpad) { - this->currentMask = PLAYER_MASK_NONE; + this->currentMask = sMaskMemory = PLAYER_MASK_NONE; func_808328EC(this, NA_SE_PL_CHANGE_ARMS); } } else { @@ -2886,6 +2888,7 @@ void func_80835F44(GlobalContext* globalCtx, Player* this, s32 item) { else { this->currentMask = actionParam - PLAYER_AP_MASK_KEATON + 1; } + sMaskMemory = this->currentMask; func_808328EC(this, NA_SE_PL_CHANGE_ARMS); return; } @@ -4574,6 +4577,7 @@ void func_8083A0F4(GlobalContext* globalCtx, Player* this) { this->interactRangeActor->parent = &this->actor; func_80835C58(globalCtx, this, func_8084F608, 0); this->stateFlags1 |= PLAYER_STATE1_29; + sMaskMemory = PLAYER_MASK_NONE; } else { LinkAnimationHeader* anim; @@ -8255,6 +8259,7 @@ void func_80843AE8(GlobalContext* globalCtx, Player* this) { } else if (globalCtx->gameOverCtx.state == GAMEOVER_DEATH_WAIT_GROUND) { globalCtx->gameOverCtx.state = GAMEOVER_DEATH_DELAY_MENU; + sMaskMemory = PLAYER_MASK_NONE; } } @@ -9523,6 +9528,18 @@ void Player_Init(Actor* thisx, GlobalContext* globalCtx2) { func_80835F44(globalCtx, this, ITEM_NONE); Player_SetEquipmentData(globalCtx, this); this->prevBoots = this->currentBoots; + if (CVar_GetS32("gMMBunnyHood", 0)) { + if (INV_CONTENT(ITEM_TRADE_CHILD) == ITEM_SOLD_OUT) { sMaskMemory = PLAYER_MASK_NONE; } + this->currentMask = sMaskMemory; + for (uint16_t cSlotIndex = 0; cSlotIndex < ARRAY_COUNT(gSaveContext.equips.cButtonSlots); cSlotIndex++) { + if (gSaveContext.equips.cButtonSlots[cSlotIndex] == SLOT_TRADE_CHILD && + (gItemAgeReqs[gSaveContext.equips.buttonItems[cSlotIndex+1]] != 9 && + LINK_IS_ADULT && !CVar_GetS32("gNoRestrictAge", 0))) { + gSaveContext.equips.cButtonSlots[cSlotIndex] = SLOT_NONE; + gSaveContext.equips.buttonItems[cSlotIndex+1] = ITEM_NONE; + } + } + } Player_InitCommon(this, globalCtx, gPlayerSkelHeaders[((void)0, gSaveContext.linkAge)]); this->giObjectSegment = (void*)(((uintptr_t)ZELDA_ARENA_MALLOC_DEBUG(0x3008) + 8) & ~0xF); 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 4d6239780..fc201ac50 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 @@ -338,6 +338,9 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) { pauseCtx->cursorItem[PAUSE_ITEM] = cursorItem; pauseCtx->cursorSlot[PAUSE_ITEM] = cursorSlot; + gSlotAgeReqs[SLOT_TRADE_CHILD] = gItemAgeReqs[ITEM_MASK_BUNNY] = + (CVar_GetS32("gMMBunnyHood", 0) && INV_CONTENT(ITEM_TRADE_CHILD) == ITEM_MASK_BUNNY) ? 9 : 1; + if (!((gSlotAgeReqs[cursorSlot] == 9) || (gSlotAgeReqs[cursorSlot] == ((void)0, gSaveContext.linkAge)))) { pauseCtx->nameColorSet = 1; }