From 4176170ec22763e0f6f9fae323ffbb4af49af004 Mon Sep 17 00:00:00 2001 From: PhlexPlexico <3514085+PhlexPlexico@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:58:03 -0600 Subject: [PATCH] fix: Update en_st to allow for repeatable checks (#98) * Update skulltulas to respawn while giving only green rupee if item was collected. * fix: Enable repeatable items in Skulltulas. If an item is repeatable, it should respawn on cycle reset, and if the item is in inventory, it will only provide a blue rupee. --- code/include/rnd/item_override.h | 1 + code/mm.ld | 4 ++-- code/source/rnd/actors/en_si.cpp | 2 +- code/source/rnd/item_override.cpp | 21 ++++++++++++--------- code/source/rnd/models.cpp | 7 ++++--- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/code/include/rnd/item_override.h b/code/include/rnd/item_override.h index 1400272..b9c2515 100644 --- a/code/include/rnd/item_override.h +++ b/code/include/rnd/item_override.h @@ -440,6 +440,7 @@ namespace rnd { void ItemOverride_RevealMapBasedOnId(u8); void SetExtData(void); u8 ItemOverride_SetProgressiveItemDraw(ItemOverride); + bool ItemOverride_IsItemObtainedOrEmptyBottle(ItemOverride); extern "C" { bool ItemOverride_CheckAromaGivenItem(); bool ItemOverride_CheckMikauGivenItem(); diff --git a/code/mm.ld b/code/mm.ld index 63514b1..1e825e8 100644 --- a/code/mm.ld +++ b/code/mm.ld @@ -399,9 +399,9 @@ SECTIONS{ *(.patch_RemoveGoronMaskCheckDarmani) } - .patch_RemoveSkulltulaSpawnIfCollectedItem 0x2E8384 : { + /* .patch_RemoveSkulltulaSpawnIfCollectedItem 0x2E8384 : { *(.patch_RemoveSkulltulaSpawnIfCollectedItem) - } + } */ .patch_SaveExtDataOnOwl 0x317004 : { *(.patch_SaveExtDataOnOwl) diff --git a/code/source/rnd/actors/en_si.cpp b/code/source/rnd/actors/en_si.cpp index eae51d1..059c437 100644 --- a/code/source/rnd/actors/en_si.cpp +++ b/code/source/rnd/actors/en_si.cpp @@ -4,7 +4,7 @@ namespace rnd { extern "C" { void En_Si_Init(game::act::Actor* actor, game::GlobalContext* gctx) { util::GetPointer(0x2E7FCC)(actor, gctx); - Model_SpawnByActor(actor, GetContext().gctx, 0x20); + Model_SpawnByActor(actor, gctx, 0x20); } void En_Si_Draw(game::act::Actor* actor, game::GlobalContext* gctx) { diff --git a/code/source/rnd/item_override.cpp b/code/source/rnd/item_override.cpp index 08fe5c4..72b7947 100644 --- a/code/source/rnd/item_override.cpp +++ b/code/source/rnd/item_override.cpp @@ -438,9 +438,6 @@ namespace rnd { } void SetExtData() { -#if defined ENABLE_DEBUG || defined DEBUG_PRINT - rnd::util::Print("%s: STORED GET ITEM ID IS %#04x\n", __func__, storedGetItemId); -#endif if (storedActorId == game::act::Id::NpcEnNb) { gExtSaveData.givenItemChecks.enNbGivenItem = 1; } else if (storedActorId == game::act::Id::NpcInvisibleGuard) { @@ -727,6 +724,11 @@ namespace rnd { override.value.getItemId = 0x02; override.value.looksLikeItemId = 0x02; } + } else if (override.key.type == ItemOverride_Type::OVR_SKULL && + (gctx->scene == game::SceneId::SwampSpiderHouse || gctx->scene == game::SceneId::OceansideSpiderHouse) && + ItemOverride_IsSkullCollected(fromActor, gctx->scene)) { + override.value.getItemId = 0x02; + override.value.looksLikeItemId = 0x02; } // This check is mainly to ensure we do not have repeatable progressive items within these base items. @@ -1063,8 +1065,11 @@ namespace rnd { return; } } else if (scene == game::SceneId::OceansideSpiderHouse) { - if (skulltulaMapOSH[i] == (params & 0xFF)) { - gExtSaveData.chestRewarded[(u8)game::SceneId::OceansideSpiderHouse][i] = 1; + // Special case - since OSH has one chest, let's remove + if ((i + 1) == 30) + break; + if (skulltulaMapOSH[i + 1] == (params & 0xFF)) { + gExtSaveData.chestRewarded[(u8)game::SceneId::OceansideSpiderHouse][i + 1] = 1; return; } } @@ -1072,9 +1077,6 @@ namespace rnd { } u8 ItemOverride_IsSkullCollected(game::act::Actor* actor, game::SceneId scene) { -#if defined ENABLE_DEBUG || defined DEBUG_PRINT - rnd::util::Print("%s: Our scene is %#06x\n", __func__, scene); -#endif for (u8 i = 0; i < 30; i++) { if (scene == game::SceneId::SwampSpiderHouse) { if (skulltulaMapSSH[i] == (actor->params & 0xFF)) { @@ -1095,12 +1097,13 @@ namespace rnd { u8 ItemOverride_OverrideSkullToken(game::act::Actor* actor) { game::GlobalContext* gctx = GetContext().gctx; s16 getItemId = gctx->scene == game::SceneId::SwampSpiderHouse ? 0x44 : 0x6D; - ItemOverride_SetSkullCollected(actor->params, gctx->scene); ItemOverride_GetItem(gctx, actor, gctx->GetPlayerActor(), getItemId); if (rActiveItemRow != NULL) { ItemOverride_GetItemTextAndItemID(gctx->GetPlayerActor()); + ItemOverride_SetSkullCollected(actor->params, gctx->scene); return true; } + return false; } diff --git a/code/source/rnd/models.cpp b/code/source/rnd/models.cpp index 48a90f2..b1c5164 100644 --- a/code/source/rnd/models.cpp +++ b/code/source/rnd/models.cpp @@ -63,9 +63,6 @@ namespace rnd { objectBankIdx = ExtendedObject_Spawn(&globalCtx->object_context, model->itemRow->objectId); } storedObjId = model->itemRow->objectId; -#if defined ENABLE_DEBUG || defined DEBUG_PRINT - rnd::util::Print("%s: storedObjId is %#04x\n", __func__, storedObjId); -#endif model->objectBankIdx = objectBankIdx; } @@ -205,6 +202,10 @@ namespace rnd { ItemOverride override = ItemOverride_Lookup(actor, (u16)globalCtx->scene, baseItemId); if (override.key.all != 0) { + if (override.key.type == ItemOverride_Type::OVR_SKULL && ItemOverride_IsSkullCollected(actor, globalCtx->scene)) { + override.value.getItemId = 0x02; + override.value.looksLikeItemId = 0x02; + } Model_LookupByOverride(model, override); Model_GetObjectBankIndex(model, actor, globalCtx); }