From da6c9d651c6030a278739536a5533b54dcc375c1 Mon Sep 17 00:00:00 2001 From: Phlex <3514085+PhlexPlexico@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:57:12 -0600 Subject: [PATCH] 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/actors/en_si.h | 1 - code/include/rnd/item_override.h | 32 +++++++++++++-------------- code/source/rnd/actors/en_si.cpp | 5 +---- code/source/rnd/item_override.cpp | 36 +++++++++++++------------------ code/source/rnd/models.cpp | 7 +++--- 5 files changed, 36 insertions(+), 45 deletions(-) diff --git a/code/include/rnd/actors/en_si.h b/code/include/rnd/actors/en_si.h index d0e1c75..7b8d216 100644 --- a/code/include/rnd/actors/en_si.h +++ b/code/include/rnd/actors/en_si.h @@ -3,7 +3,6 @@ #include "game/actor.h" #include "rnd/models.h" -#include "rnd/item_override.h" #if defined ENABLE_DEBUG || defined DEBUG_PRINT #include "common/debug.h" extern "C" { diff --git a/code/include/rnd/item_override.h b/code/include/rnd/item_override.h index e00b82b..b9c2515 100644 --- a/code/include/rnd/item_override.h +++ b/code/include/rnd/item_override.h @@ -442,22 +442,22 @@ namespace rnd { u8 ItemOverride_SetProgressiveItemDraw(ItemOverride); bool ItemOverride_IsItemObtainedOrEmptyBottle(ItemOverride); extern "C" { - bool ItemOverride_CheckAromaGivenItem(); - bool ItemOverride_CheckMikauGivenItem(); - bool ItemOverride_CheckDarmaniGivenItem(); - void ItemOverride_GetItemTextAndItemID(game::act::Player*); - void ItemOverride_GetItem(game::GlobalContext*, game::act::Actor*, game::act::Player*, s16); - void ItemOverride_GetFairyRewardItem(game::GlobalContext*, game::act::GreatFairy*, s16); - void ItemOverride_GetSoHItem(game::GlobalContext*, game::act::Actor*, s16); - int ItemOverride_CheckInventoryItemOverride(game::ItemId); - void ItemOverride_SwapSoHGetItemText(game::GlobalContext*, u16, game::act::Actor*); - bool ItemOverride_CheckTingleMaps(u16, game::GlobalContext*); - u32 ItemOverride_GetGaboraExtData(); - u32 ItemOverride_GetOshExtData(); - void ItemOverride_SetSkullCollected(u16, game::SceneId); - u8 ItemOverride_IsSkullCollected(game::act::Actor*, game::SceneId); - u8 ItemOverride_OverrideSkullToken(game::act::Actor*); - u8 ItemOverride_CheckBossStatus(); + bool ItemOverride_CheckAromaGivenItem(); + bool ItemOverride_CheckMikauGivenItem(); + bool ItemOverride_CheckDarmaniGivenItem(); + void ItemOverride_GetItemTextAndItemID(game::act::Player*); + void ItemOverride_GetItem(game::GlobalContext*, game::act::Actor*, game::act::Player*, s16); + void ItemOverride_GetFairyRewardItem(game::GlobalContext*, game::act::GreatFairy*, s16); + void ItemOverride_GetSoHItem(game::GlobalContext*, game::act::Actor*, s16); + int ItemOverride_CheckInventoryItemOverride(game::ItemId); + void ItemOverride_SwapSoHGetItemText(game::GlobalContext*, u16, game::act::Actor*); + bool ItemOverride_CheckTingleMaps(u16, game::GlobalContext*); + u32 ItemOverride_GetGaboraExtData(); + u32 ItemOverride_GetOshExtData(); + void ItemOverride_SetSkullCollected(u16, game::SceneId); + u8 ItemOverride_IsSkullCollected(game::act::Actor*, game::SceneId); + u8 ItemOverride_OverrideSkullToken(game::act::Actor*); + u8 ItemOverride_CheckBossStatus(); } extern "C" u32 rActiveItemGraphicId; extern "C" ItemOverride rItemOverrides[640]; diff --git a/code/source/rnd/actors/en_si.cpp b/code/source/rnd/actors/en_si.cpp index d2499a3..059c437 100644 --- a/code/source/rnd/actors/en_si.cpp +++ b/code/source/rnd/actors/en_si.cpp @@ -3,11 +3,8 @@ namespace rnd { extern "C" { void En_Si_Init(game::act::Actor* actor, game::GlobalContext* gctx) { - ItemOverride override = ItemOverride_Lookup(actor, (u16)gctx->scene, 0x20); util::GetPointer(0x2E7FCC)(actor, gctx); - if (ItemOverride_IsSkullCollected(actor, gctx->scene) && ItemOverride_IsItemObtainedOrEmptyBottle(override)) - Model_SpawnByActor(actor, gctx, 0x01); - else Model_SpawnByActor(actor, 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 74b81d0..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,21 +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; - if (ItemOverride_IsSkullCollected(actor, gctx->scene)) { - ItemOverride_GetItem(gctx, actor, gctx->GetPlayerActor(), 0x01); - if (rActiveItemRow != NULL) { - ItemOverride_GetItemTextAndItemID(gctx->GetPlayerActor()); - return true; - } - } else { + ItemOverride_GetItem(gctx, actor, gctx->GetPlayerActor(), getItemId); + if (rActiveItemRow != NULL) { + ItemOverride_GetItemTextAndItemID(gctx->GetPlayerActor()); ItemOverride_SetSkullCollected(actor->params, gctx->scene); - ItemOverride_GetItem(gctx, actor, gctx->GetPlayerActor(), getItemId); - if (rActiveItemRow != NULL) { - ItemOverride_GetItemTextAndItemID(gctx->GetPlayerActor()); - return true; - } + 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); }