From f3f6b097e7bae8be4ce3ed9e1bf101f2dbc1a07a Mon Sep 17 00:00:00 2001 From: Phlex Date: Sat, 3 Feb 2024 09:50:16 -0600 Subject: [PATCH 1/4] Include fixes for deku trade quest in giving repeat progressive items. --- code/include/rnd/savefile.h | 11 +++++++--- code/source/rnd/item_override.cpp | 35 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/code/include/rnd/savefile.h b/code/include/rnd/savefile.h index d3902197..b7cbfaca 100644 --- a/code/include/rnd/savefile.h +++ b/code/include/rnd/savefile.h @@ -7,7 +7,7 @@ #include "z3d/z3DVec.h" // Increment the version number whenever the ExtSaveData structure is changed -#define EXTSAVEDATA_VERSION 12 +#define EXTSAVEDATA_VERSION 13 #define SAVEFILE_SCENES_DISCOVERED_IDX_COUNT 4 #define SAVEFILE_SPOILER_ITEM_MAX 512 @@ -74,8 +74,13 @@ namespace rnd { BitField<30, 1, u64> enGoGivenItem; BitField<31, 1, u64> enBoss02GivenItem; BitField<32, 1, u64> enGinkoManGivenItem; - BitField<33, 31, u64> enShnGivenItem; - BitField<34, 30, u64> unused; + BitField<33, 1, u64> enShnGivenItem; + BitField<34, 1, u64> enObjMoonStoneGivenItem; + BitField<35, 1, u64> enTownDeedGivenItem; + BitField<35, 1, u64> enSwampDeedGivenItem; + BitField<35, 1, u64> enMtnDeedGivenItem; + BitField<35, 1, u64> enOcnDeedGivenItemsed; + BitField<35, 25, u64> unused; }; GivenItemRegister givenItemChecks; union FairyCollectRegister { diff --git a/code/source/rnd/item_override.cpp b/code/source/rnd/item_override.cpp index 85642f45..a69d84fe 100644 --- a/code/source/rnd/item_override.cpp +++ b/code/source/rnd/item_override.cpp @@ -483,6 +483,16 @@ namespace rnd { } } else if (storedActorId == game::act::Id::EnShn) { gExtSaveData.givenItemChecks.enShnGivenItem = 1; + } else if (storedGetItemId == rnd::GetItemID::GI_MOONS_TEAR) { + gExtSaveData.givenItemChecks.enObjMoonStoneGivenItem = 1; + } else if (storedGetItemId == rnd::GetItemID::GI_TOWN_TITLE_DEED) { + gExtSaveData.givenItemChecks.enTownDeedGivenItem = 1; + } else if (storedGetItemId == rnd::GetItemID::GI_SWAMP_TITLE_DEED) { + gExtSaveData.givenItemChecks.enSwampDeedGivenItem = 1; + } else if (storedGetItemId == rnd::GetItemID::GI_MOUNTAIN_TITLE_DEED) { + gExtSaveData.givenItemChecks.enMtnDeedGivenItem = 1; + } else if (storedGetItemId == rnd::GetItemID::GI_OCEAN_TITLE_DEED) { + gExtSaveData.givenItemChecks.enOcnDeedGivenItemsed = 1; } } @@ -637,6 +647,31 @@ namespace rnd { break; } return; + } else if (override.value.getItemId > 0x45 && override.value.getItemId < 0x4B) { + // This check is mainly to ensure we do not have repeatable progressive items within these base items. + // This is to ensure fairness and allows us to place these items without second guessing in logic. + // Let's be a bit rude and give them fishing passes. + if (incomingGetItemId == (s16)GetItemID::GI_MOONS_TEAR && + gExtSaveData.givenItemChecks.enObjMoonStoneGivenItem == 1) { + player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS; + return; + } else if (incomingGetItemId == (s16)GetItemID::GI_TOWN_TITLE_DEED && + gExtSaveData.givenItemChecks.enTownDeedGivenItem == 1) { + player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS; + return; + } else if (incomingGetItemId == (s16)GetItemID::GI_SWAMP_TITLE_DEED && + gExtSaveData.givenItemChecks.enSwampDeedGivenItem == 1) { + player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS; + return; + } else if (incomingGetItemId == (s16)GetItemID::GI_MOUNTAIN_TITLE_DEED && + gExtSaveData.givenItemChecks.enMtnDeedGivenItem == 1) { + player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS; + return; + } else if (incomingGetItemId == (s16)GetItemID::GI_OCEAN_TITLE_DEED && + gExtSaveData.givenItemChecks.enOcnDeedGivenItemsed == 1) { + player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS; + return; + } } ItemOverride_Activate(override); s16 baseItemId = rActiveItemRow->baseItemId; From 422d05da7e8be6e15be94e6bd0ca488f6ad29025 Mon Sep 17 00:00:00 2001 From: Phlex Date: Sat, 3 Feb 2024 11:29:07 -0600 Subject: [PATCH 2/4] Include gorman track fix for getting the mask and milk. --- code/source/rnd/item_override.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/source/rnd/item_override.cpp b/code/source/rnd/item_override.cpp index a69d84fe..2f166380 100644 --- a/code/source/rnd/item_override.cpp +++ b/code/source/rnd/item_override.cpp @@ -448,7 +448,7 @@ namespace rnd { gExtSaveData.givenItemChecks.enDnoGivenItem = 1; } else if (storedActorId == game::act::Id::NpcGreatFairy) { gExtSaveData.givenItemChecks.bgDyYoseizoGivenItem = 1; - } else if (storedActorId == game::act::Id::EnIn) { + } else if (storedActorId == game::act::Id::EnIn && storedGetItemId == (s16)GetItemID::GI_MASK_GARO) { gExtSaveData.givenItemChecks.enInGivenItem = 1; } else if (storedActorId == game::act::Id::EnHs) { gExtSaveData.givenItemChecks.enHsGivenItem = 1; From f2ce9d7df537a3ed8f3beab4f354491e7967fe3c Mon Sep 17 00:00:00 2001 From: Phlex Date: Sat, 3 Feb 2024 15:24:40 -0600 Subject: [PATCH 3/4] Fix for bottle refills and obtaining new bottles. --- code/include/rnd/savefile.h | 13 ++-- code/source/rnd/item_override.cpp | 106 ++++++++++++++++++++++-------- 2 files changed, 89 insertions(+), 30 deletions(-) diff --git a/code/include/rnd/savefile.h b/code/include/rnd/savefile.h index b7cbfaca..05d026dc 100644 --- a/code/include/rnd/savefile.h +++ b/code/include/rnd/savefile.h @@ -77,10 +77,15 @@ namespace rnd { BitField<33, 1, u64> enShnGivenItem; BitField<34, 1, u64> enObjMoonStoneGivenItem; BitField<35, 1, u64> enTownDeedGivenItem; - BitField<35, 1, u64> enSwampDeedGivenItem; - BitField<35, 1, u64> enMtnDeedGivenItem; - BitField<35, 1, u64> enOcnDeedGivenItemsed; - BitField<35, 25, u64> unused; + BitField<36, 1, u64> enSwampDeedGivenItem; + BitField<37, 1, u64> enMtnDeedGivenItem; + BitField<38, 1, u64> enOcnDeedGivenItem; + BitField<39, 1, u64> bottleMilkGiven; + BitField<40, 1, u64> bottleGoldDustGiven; + BitField<41, 1, u64> bottleSeahorseGiven; + BitField<42, 1, u64> bottleChateuGiven; + BitField<43, 1, u64> bottleMysteryMilkGiven; + BitField<44, 20, u64> unused; }; GivenItemRegister givenItemChecks; union FairyCollectRegister { diff --git a/code/source/rnd/item_override.cpp b/code/source/rnd/item_override.cpp index 2f166380..ff185506 100644 --- a/code/source/rnd/item_override.cpp +++ b/code/source/rnd/item_override.cpp @@ -44,9 +44,9 @@ namespace rnd { rItemOverrides[0].value.getItemId = 0x26; rItemOverrides[0].value.looksLikeItemId = 0x26; rItemOverrides[1].key.scene = 0x6F; - rItemOverrides[1].key.type = ItemOverride_Type::OVR_COLLECTABLE; - rItemOverrides[1].value.getItemId = 0xA1; - rItemOverrides[1].value.looksLikeItemId = 0xA1; + rItemOverrides[1].key.type = ItemOverride_Type::OVR_CHEST; + rItemOverrides[1].value.getItemId = 0x60; + rItemOverrides[1].value.looksLikeItemId = 0x60; rItemOverrides[2].key.scene = 0x12; rItemOverrides[2].key.type = ItemOverride_Type::OVR_COLLECTABLE; rItemOverrides[2].value.getItemId = 0x37; @@ -448,7 +448,7 @@ namespace rnd { gExtSaveData.givenItemChecks.enDnoGivenItem = 1; } else if (storedActorId == game::act::Id::NpcGreatFairy) { gExtSaveData.givenItemChecks.bgDyYoseizoGivenItem = 1; - } else if (storedActorId == game::act::Id::EnIn && storedGetItemId == (s16)GetItemID::GI_MASK_GARO) { + } else if (storedActorId == game::act::Id::EnIn && storedGetItemId == GetItemID::GI_MASK_GARO) { gExtSaveData.givenItemChecks.enInGivenItem = 1; } else if (storedActorId == game::act::Id::EnHs) { gExtSaveData.givenItemChecks.enHsGivenItem = 1; @@ -492,7 +492,7 @@ namespace rnd { } else if (storedGetItemId == rnd::GetItemID::GI_MOUNTAIN_TITLE_DEED) { gExtSaveData.givenItemChecks.enMtnDeedGivenItem = 1; } else if (storedGetItemId == rnd::GetItemID::GI_OCEAN_TITLE_DEED) { - gExtSaveData.givenItemChecks.enOcnDeedGivenItemsed = 1; + gExtSaveData.givenItemChecks.enOcnDeedGivenItem = 1; } } @@ -551,6 +551,33 @@ namespace rnd { return; } + void ItemOverride_SetBottleRefill(game::act::Player* player, s16 refItemId, bool isChest = false) { + switch (refItemId) { + case 0x60: + player->get_item_id = isChest ? -(s16)GetItemID::GI_BOTTLE_MILK_REFILL : (s16)GetItemID::GI_BOTTLE_MILK_REFILL; + break; + case 0x6A: + player->get_item_id = + isChest ? -(s16)GetItemID::GI_BOTTLE_GOLD_DUST_REFILL : (s16)GetItemID::GI_BOTTLE_GOLD_DUST_REFILL; + break; + case 0x6F: + player->get_item_id = + isChest ? -(s16)GetItemID::GI_BOTTLE_CHATEAU_ROMANI_REFILL : (s16)GetItemID::GI_BOTTLE_CHATEAU_ROMANI_REFILL; + break; + case 0x6E: + player->get_item_id = + isChest ? -(s16)GetItemID::GI_BOTTLE_SEAHORSE_REFILL : (s16)GetItemID::GI_BOTTLE_SEAHORSE_REFILL; + break; + case 0x70: + player->get_item_id = isChest ? -(s16)GetItemID::GI_BOTTLE_MYSTERY_MILK : (s16)GetItemID::GI_BOTTLE_MYSTERY_MILK; + break; + default: + player->get_item_id = isChest ? -(s16)GetItemID::GI_RUPEE_BLUE : (s16)GetItemID::GI_RUPEE_BLUE; + break; + } + return; + } + extern "C" { bool ItemOverride_CheckAromaGivenItem() { if (gExtSaveData.givenItemChecks.enAlGivenItem > 0) @@ -626,26 +653,7 @@ namespace rnd { rnd::util::Print("%s: Our ref item id is %#04x\n", __func__, refItemId); #endif ItemOverride_Clear(); - switch (refItemId) { - case 0x60: - player->get_item_id = -(s16)GetItemID::GI_BOTTLE_MILK_REFILL; - break; - case 0x6A: - player->get_item_id = -(s16)GetItemID::GI_BOTTLE_GOLD_DUST_REFILL; - break; - case 0x6F: - player->get_item_id = -(s16)GetItemID::GI_BOTTLE_CHATEAU_ROMANI_REFILL; - break; - case 0x6E: - player->get_item_id = -(s16)GetItemID::GI_BOTTLE_SEAHORSE_REFILL; - break; - case 0x70: - player->get_item_id = -(s16)GetItemID::GI_BOTTLE_MYSTERY_MILK; - break; - default: - player->get_item_id = -(s16)GetItemID::GI_RUPEE_BLUE; - break; - } + ItemOverride_SetBottleRefill(player, (s16)refItemId, true); return; } else if (override.value.getItemId > 0x45 && override.value.getItemId < 0x4B) { // This check is mainly to ensure we do not have repeatable progressive items within these base items. @@ -668,10 +676,56 @@ namespace rnd { player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS; return; } else if (incomingGetItemId == (s16)GetItemID::GI_OCEAN_TITLE_DEED && - gExtSaveData.givenItemChecks.enOcnDeedGivenItemsed == 1) { + gExtSaveData.givenItemChecks.enOcnDeedGivenItem == 1) { player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS; return; } + } else if (override.key.type != ItemOverride_Type::OVR_CHEST && override.value.getItemId == 0x60 || + (override.value.getItemId > 0x69 && override.value.getItemId < 0x71)) { + switch (override.value.getItemId) { + case 0x60: + if (gExtSaveData.givenItemChecks.bottleMilkGiven == 0) { + gExtSaveData.givenItemChecks.bottleMilkGiven = 1; + } else { + ItemOverride_SetBottleRefill(player, (s16) override.value.getItemId); + return; + } + break; + case 0x6A: + if (gExtSaveData.givenItemChecks.bottleGoldDustGiven == 0) { + gExtSaveData.givenItemChecks.bottleGoldDustGiven = 1; + } else { + ItemOverride_SetBottleRefill(player, (s16) override.value.getItemId); + return; + } + break; + case 0x6F: + if (gExtSaveData.givenItemChecks.bottleGoldDustGiven == 0) { + gExtSaveData.givenItemChecks.bottleGoldDustGiven = 1; + } else { + ItemOverride_SetBottleRefill(player, (s16) override.value.getItemId); + return; + } + break; + case 0x6E: + if (gExtSaveData.givenItemChecks.bottleSeahorseGiven == 0) { + gExtSaveData.givenItemChecks.bottleSeahorseGiven = 1; + } else { + ItemOverride_SetBottleRefill(player, (s16) override.value.getItemId); + return; + } + break; + case 0x70: + if (gExtSaveData.givenItemChecks.bottleMysteryMilkGiven == 0) { + gExtSaveData.givenItemChecks.bottleMysteryMilkGiven = 1; + } else { + ItemOverride_SetBottleRefill(player, (s16) override.value.getItemId); + return; + } + break; + default: + break; + } } ItemOverride_Activate(override); s16 baseItemId = rActiveItemRow->baseItemId; From 892a6de557498489975536a8a9a87fdf610b3833 Mon Sep 17 00:00:00 2001 From: Phlex Date: Sat, 3 Feb 2024 15:27:43 -0600 Subject: [PATCH 4/4] Bring back blue rupee item give back. --- code/source/rnd/item_override.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/source/rnd/item_override.cpp b/code/source/rnd/item_override.cpp index ff185506..4f808faf 100644 --- a/code/source/rnd/item_override.cpp +++ b/code/source/rnd/item_override.cpp @@ -724,8 +724,10 @@ namespace rnd { } break; default: + player->get_item_id = -(s16)GetItemID::GI_RUPEE_BLUE; break; } + return; } ItemOverride_Activate(override); s16 baseItemId = rActiveItemRow->baseItemId;