Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include fixes for deku trade quest in giving repeat progressive items. #21

Merged
merged 4 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions code/include/rnd/savefile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -74,8 +74,18 @@ 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<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 {
Expand Down
111 changes: 101 additions & 10 deletions code/source/rnd/item_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 == GetItemID::GI_MASK_GARO) {
gExtSaveData.givenItemChecks.enInGivenItem = 1;
} else if (storedActorId == game::act::Id::EnHs) {
gExtSaveData.givenItemChecks.enHsGivenItem = 1;
Expand Down Expand Up @@ -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.enOcnDeedGivenItem = 1;
}
}

Expand Down Expand Up @@ -541,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)
Expand Down Expand Up @@ -616,21 +653,75 @@ namespace rnd {
rnd::util::Print("%s: Our ref item id is %#04x\n", __func__, refItemId);
#endif
ItemOverride_Clear();
switch (refItemId) {
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.
// 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.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:
player->get_item_id = -(s16)GetItemID::GI_BOTTLE_MILK_REFILL;
if (gExtSaveData.givenItemChecks.bottleMilkGiven == 0) {
gExtSaveData.givenItemChecks.bottleMilkGiven = 1;
} else {
ItemOverride_SetBottleRefill(player, (s16) override.value.getItemId);
return;
}
break;
case 0x6A:
player->get_item_id = -(s16)GetItemID::GI_BOTTLE_GOLD_DUST_REFILL;
if (gExtSaveData.givenItemChecks.bottleGoldDustGiven == 0) {
gExtSaveData.givenItemChecks.bottleGoldDustGiven = 1;
} else {
ItemOverride_SetBottleRefill(player, (s16) override.value.getItemId);
return;
}
break;
case 0x6F:
player->get_item_id = -(s16)GetItemID::GI_BOTTLE_CHATEAU_ROMANI_REFILL;
if (gExtSaveData.givenItemChecks.bottleGoldDustGiven == 0) {
gExtSaveData.givenItemChecks.bottleGoldDustGiven = 1;
} else {
ItemOverride_SetBottleRefill(player, (s16) override.value.getItemId);
return;
}
break;
case 0x6E:
player->get_item_id = -(s16)GetItemID::GI_BOTTLE_SEAHORSE_REFILL;
if (gExtSaveData.givenItemChecks.bottleSeahorseGiven == 0) {
gExtSaveData.givenItemChecks.bottleSeahorseGiven = 1;
} else {
ItemOverride_SetBottleRefill(player, (s16) override.value.getItemId);
return;
}
break;
case 0x70:
player->get_item_id = -(s16)GetItemID::GI_BOTTLE_MYSTERY_MILK;
if (gExtSaveData.givenItemChecks.bottleMysteryMilkGiven == 0) {
gExtSaveData.givenItemChecks.bottleMysteryMilkGiven = 1;
} else {
ItemOverride_SetBottleRefill(player, (s16) override.value.getItemId);
return;
}
break;
default:
player->get_item_id = -(s16)GetItemID::GI_RUPEE_BLUE;
Expand Down
Loading