Skip to content

Commit

Permalink
Update Curiosity Shop logic to ensure the right flags are being set f…
Browse files Browse the repository at this point in the history
…or items. (#46)
  • Loading branch information
PhlexPlexico authored Feb 26, 2024
1 parent d965c90 commit 81c409d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 51 deletions.
45 changes: 10 additions & 35 deletions code/source/rnd/item_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ namespace rnd {
rItemOverrides[0].value.looksLikeItemId = 0x26;
rItemOverrides[1].key.scene = 0x6F;
rItemOverrides[1].key.type = ItemOverride_Type::OVR_COLLECTABLE;
rItemOverrides[1].value.getItemId = 0x02;
rItemOverrides[1].value.looksLikeItemId = 0x02;
rItemOverrides[1].value.getItemId = 0x0C;
rItemOverrides[1].value.looksLikeItemId = 0x0C;
rItemOverrides[2].key.scene = 0x12;
rItemOverrides[2].key.type = ItemOverride_Type::OVR_COLLECTABLE;
rItemOverrides[2].value.getItemId = 0x37;
Expand Down Expand Up @@ -424,6 +424,9 @@ 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) {
Expand All @@ -439,6 +442,8 @@ namespace rnd {
} else if (storedActorId == game::act::Id::NpcEnFsn) {
if (storedGetItemId == GetItemID::GI_MASK_ALL_NIGHT) {
gExtSaveData.givenItemChecks.enFsnANMGivenItem = 1;
} else if (storedGetItemId == GetItemID::GI_LETTER_TO_MAMA) {
gExtSaveData.givenItemChecks.letterToMamaGiven = 1;
} else {
gExtSaveData.givenItemChecks.enFsnGivenItem = 1;
}
Expand Down Expand Up @@ -506,8 +511,6 @@ namespace rnd {
gExtSaveData.givenItemChecks.bottleRedPotionGiven = 1;
} else if (storedGetItemId == GetItemID::GI_ROOM_KEY) {
gExtSaveData.givenItemChecks.roomKeyGiven = 1;
} else if (storedGetItemId == GetItemID::GI_LETTER_TO_MAMA) {
gExtSaveData.givenItemChecks.letterToMamaGiven = 1;
} else if (storedGetItemId == GetItemID::GI_LETTER_TO_KAFEI) {
gExtSaveData.givenItemChecks.letterToKafeiGiven = 1;
} else if (storedGetItemId == GetItemID::GI_PENDANT_OF_MEMORIES) {
Expand Down Expand Up @@ -734,6 +737,9 @@ namespace rnd {
// 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 ((override.value.getItemId > 0x45 && override.value.getItemId < 0x4A) || ItemOverride_IsItemObtained(override)) {
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
rnd::util::Print("%s: GID #%04x IS ALREADY OBTAINED, INCOMING ID IS %#04x\n", __func__, override.value.getItemId, incomingGetItemId);
#endif
if ((incomingGetItemId == (s16)GetItemID::GI_MOONS_TEAR &&
gExtSaveData.givenItemChecks.enObjMoonStoneGivenItem == 1) ||
(incomingGetItemId == (s16)GetItemID::GI_TOWN_TITLE_DEED &&
Expand All @@ -754,38 +760,7 @@ namespace rnd {
player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS;
ItemOverride_Clear();
return;
} /*else if (incomingGetItemId == (s16)GetItemID::GI_TOWN_TITLE_DEED &&
gExtSaveData.givenItemChecks.enTownDeedGivenItem == 1) {
player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS;
ItemOverride_Clear();
return;
} else if (incomingGetItemId == (s16)GetItemID::GI_SWAMP_TITLE_DEED &&
gExtSaveData.givenItemChecks.enSwampDeedGivenItem == 1) {
player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS;
ItemOverride_Clear();
return;
} else if (incomingGetItemId == (s16)GetItemID::GI_MOUNTAIN_TITLE_DEED &&
gExtSaveData.givenItemChecks.enMtnDeedGivenItem == 1) {
player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS;
ItemOverride_Clear();
return;
} else if (incomingGetItemId == (s16)GetItemID::GI_OCEAN_TITLE_DEED &&
gExtSaveData.givenItemChecks.enOcnDeedGivenItem == 1) {
player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS;
ItemOverride_Clear();
return;
}
else if ((incomingGetItemId == (s16)GetItemID::GI_ROOM_KEY && gExtSaveData.givenItemChecks.roomKeyGiven == 1) ||
(incomingGetItemId == (s16)GetItemID::GI_LETTER_TO_MAMA &&
gExtSaveData.givenItemChecks.letterToMamaGiven == 1) ||
(incomingGetItemId == (s16)GetItemID::GI_LETTER_TO_KAFEI &&
gExtSaveData.givenItemChecks.letterToKafeiGiven == 1) ||
(incomingGetItemId == (s16)GetItemID::GI_PENDANT_OF_MEMORIES &&
gExtSaveData.givenItemChecks.pendantGiven == 1)) {
player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS;
ItemOverride_Clear();
return;
}*/
}
if (incomingGetItemId == 0x70 || incomingGetItemId == 0x94) {
// If we've completed the milk quest, make sure we're not a heart piece
Expand Down
40 changes: 24 additions & 16 deletions code/source/rnd/savefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ namespace rnd {
saveData.skulltulas_collected.swamp_count = 30;
saveData.skulltulas_collected.ocean_count = 30;
saveData.anonymous_162 = saveData.anonymous_162 | 0x6000;
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::MaskOfTruth);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::PictographBox);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::BlastMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::KafeiMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::CircusLeaderMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::LetterToMama);

// rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::PowderKeg);
// saveData.inventory.inventory_count_register.quiver_upgrade = game::Quiver::Quiver50;
saveData.inventory.inventory_count_register.bomb_bag_upgrade = game::BombBag::BombBag40;
Expand All @@ -51,18 +46,25 @@ namespace rnd {
saveData.inventory.items[13] = game::ItemId::PictographBox;
// saveData.inventory.items[14] = game::ItemId::LensOfTruth;
saveData.inventory.items[15] = game::ItemId::Hookshot;
saveData.inventory.items[20] = game::ItemId::LandTitleDeed;

saveData.inventory.masks[5] = game::ItemId::DekuMask;

rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::MaskOfTruth);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::PictographBox);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::BlastMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::KafeiMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::CircusLeaderMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::LetterToMama);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::DekuMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::BremenMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::Bottle);
saveData.inventory.masks[11] = game::ItemId::GoronMask;
saveData.inventory.masks[17] = game::ItemId::ZoraMask;
saveData.inventory.masks[23] = game::ItemId::FierceDeityMask;
saveData.inventory.masks[19] = game::ItemId::StoneMask;
saveData.inventory.masks[8] = game::ItemId::BunnyHood;
saveData.inventory.masks[20] = game::ItemId::GaroMask;
saveData.inventory.masks[6] = game::ItemId::AllNightMask;
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::GoronMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::ZoraMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::FierceDeityMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::StoneMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::BunnyHood);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::GaroMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::AllNightMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::KeatonMask);


saveData.inventory.woodfall_dungeon_items.map = 1;
saveData.inventory.woodfall_dungeon_items.compass = 1;
Expand Down Expand Up @@ -909,6 +911,9 @@ namespace rnd {
}

extern "C" void SaveFile_RemoveStoredTradeItem(u16 item, u8 slot) {
#if defined ENABLE_DEBUG
return;
#endif
// This is a get item ID, we need to translate it to the regular item ID.
if (slot != 5 && slot != 17)
return;
Expand All @@ -933,6 +938,9 @@ namespace rnd {
saveData.inventory.items[slot] = firstItem;
}
extern "C" void SaveFile_RemoveTradeItemFromSlot(u16 item, u8 slot) {
#if defined ENABLE_DEBUG
return;
#endif
if (slot == 5) {
for (int i = 0; i < 5; i++) {
if (item == (u16)gExtSaveData.collectedTradeItems[i]) {
Expand Down

0 comments on commit 81c409d

Please sign in to comment.