track twilight tears in tracker

This commit is contained in:
gymnast86
2026-06-08 13:44:35 -07:00
parent 3f6ae4324b
commit 302abd6b65
6 changed files with 198 additions and 105 deletions
@@ -69,6 +69,8 @@ std::optional<std::string> RandomizerContext::WriteToFile() {
const std::unordered_map<u16, u16> u16ShopOverrides(this->mShopOverrides.begin(), this->mShopOverrides.end());
out["mShopOverrides"] = u16ShopOverrides;
out["mTwilitInsectOverrides"] = mTwilitInsectOverrides;
for (const auto& [key, data] : this->mFlowItemMessageOverrides) {
auto node = out["mFlowItemMessageOverrides"][key];
node["itemId"] = data.itemId;
@@ -210,6 +212,12 @@ std::optional<std::string> RandomizerContext::LoadFromHash(const std::string& ha
this->mShopOverrides[key] = itemId;
}
for (const auto& twilitInsectNode : in["mTwilitInsectOverrides"]) {
u16 key = twilitInsectNode.first.as<u16>();
u16 itemId = twilitInsectNode.second.as<u16>();
this->mTwilitInsectOverrides[key] = itemId;
}
// Helper function for getting the item data out of a YAML node
auto retrieveItemData = [](auto& itemData, const YAML::Node& node) {
itemData.itemId = node["itemId"].as<int>();
@@ -1071,6 +1079,18 @@ RandomizerContext WriteSeedData(randomizer::logic::world::World* world) {
}
}
// Twilit Insect Overrides
// Keyed by u16 of 0xFF00 (stage index) and 0x00FF (flag, which is a tbox id)
if (location->HasCategories("Twilit Insect")) {
for (const auto& twilitInsectNode : metaData["Twilit Insect"]) {
u8 stage = twilitInsectNode["Stage"].as<u8>();
u8 tboxId = twilitInsectNode["Flag"].as<u8>();
u16 itemId = location->GetCurrentItem()->GetID();
u16 key = (stage << 8) | tboxId;
randoData.mTwilitInsectOverrides[key] = itemId;
}
}
// Helper function for getting flag values
auto getNodeFlags = [](auto& itemData, const YAML::Node& metaData) {
if (metaData["Event Flag"]) {
@@ -51,6 +51,7 @@ public:
std::unordered_map<u16, u8> mSkyCharacterOverrides{};
std::unordered_map<u16, u8> mGoldenWolfOverrides{};
std::unordered_map<u16, u8> mShopOverrides{};
std::unordered_map<u16, u16> mTwilitInsectOverrides{}; // Just used in tracker for now
std::unordered_map<u32, itemLocationData> mFlowItemMessageOverrides{};
std::unordered_map<std::string, itemLocationData> mItemLocations{};
+31 -10
View File
@@ -477,6 +477,17 @@ randomizer::logic::item_pool::ItemPool getSaveItemPool(randomizer::logic::world:
break;
}
// Twilight Tears
for (int i = 0; i < dComIfGs_getLightDropNum(0); ++i) {
pool.push_back(world->GetItem("Faron Twilight Tear", true));
}
for (int i = 0; i < dComIfGs_getLightDropNum(1); ++i) {
pool.push_back(world->GetItem("Eldin Twilight Tear", true));
}
for (int i = 0; i < dComIfGs_getLightDropNum(2); ++i) {
pool.push_back(world->GetItem("Lanayru Twilight Tear", true));
}
return pool;
}
@@ -520,6 +531,11 @@ bool isLocationObtained(randomizer::logic::location::Location* location) {
auto stageId = getStageSaveId(itemFlagNode["Stage"].as<u8>());
return tracker_isStageItem(stageId, flag);
}
if (auto& twilitInsectNode = locationMeta["Twilit Insect"]) {
auto flag = twilitInsectNode[0]["Flag"].as<u8>();
auto stageId = getStageSaveId(twilitInsectNode[0]["Stage"].as<u8>());
return dComIfGs_isStageTbox(stageId, flag);
}
return false;
}
@@ -545,6 +561,16 @@ int getLocationItem(randomizer::logic::location::Location* location) {
auto key = (stage << 8) | flag;
return context.mFreestandingItemOverrides[key];
}
if (auto& bugRewardNode = locationMeta["Bug Reward"]) {
u8 bugItemId = bugRewardNode[0]["Item Id"].as<u8>();
return context.mBugRewardOverrides[bugItemId];
}
if (auto& skyCharacterNode = locationMeta["Sky Character"]) {
u8 stageIdx = skyCharacterNode[0]["Stage"].as<u8>();
u8 roomNo = skyCharacterNode[0]["Room"].as<u8>();
u16 key = (stageIdx << 8) | roomNo;
return context.mSkyCharacterOverrides[key];
}
if (auto& wolfNode = locationMeta["Golden Wolf"]) {
auto flag = wolfNode[0]["Flag"].as<u16>();
return context.mGoldenWolfOverrides[flag];
@@ -555,17 +581,12 @@ int getLocationItem(randomizer::logic::location::Location* location) {
u16 key = (stage << 8) | originalItem;
return context.mShopOverrides[key];
}
if (auto& skyCharacterNode = locationMeta["Sky Character"]) {
u8 stageIdx = skyCharacterNode[0]["Stage"].as<u8>();
u8 roomNo = skyCharacterNode[0]["Room"].as<u8>();
u16 key = (stageIdx << 8) | roomNo;
return context.mSkyCharacterOverrides[key];
if (auto& twilitInsectNode = locationMeta["Twilit Insect"]) {
auto flag = twilitInsectNode[0]["Flag"].as<u8>();
auto stage = twilitInsectNode[0]["Stage"].as<u8>();
auto key = (stage << 8) | flag;
return context.mTwilitInsectOverrides[key];
}
if (auto& bugRewardNode = locationMeta["Bug Reward"]) {
u8 bugItemId = bugRewardNode[0]["Item Id"].as<u8>();
return context.mBugRewardOverrides[bugItemId];
}
if (auto& flwNode = locationMeta["FLW Message"]) {
auto group = flwNode[0]["Group"].as<u16>();
auto messageId = flwNode[0]["Message Id"].as<u16>();
+144 -93
View File
@@ -319,126 +319,140 @@
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0x1
- Name: South Faron Woods Twilit Insect in Tunnel 2
Original Item: Faron Twilight Tear
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0x6
- Name: Faron Woods Coros House Interior Twilit Insect 1
Original Item: Faron Twilight Tear
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 67
Flag: 0x9
- Name: Faron Woods Coros House Interior Twilit Insect 2
Original Item: Faron Twilight Tear
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 67
Flag: 0x4
- Name: South Faron Woods Coros House Exterior Twilit Insect
Original Item: Faron Twilight Tear
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0x0
- Name: South Faron Woods Twilit Insect Behind Gate 1
Original Item: Faron Twilight Tear
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0xB
- Name: South Faron Woods Twilit Insect Behind Gate 2
Original Item: Faron Twilight Tear
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0x5
- Name: Faron Mist Twilit Insect on Wall 1
Original Item: Faron Twilight Tear
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0x12
- Name: Faron Mist Twilit Insect on Wall 2
Original Item: Faron Twilight Tear
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0x11
- Name: Faron Mist Twilit Insect on Center Stump 1
Original Item: Faron Twilight Tear
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0xE
- Name: Faron Mist Twilit Insect on Center Stump 2
Original Item: Faron Twilight Tear
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0xD
- Name: Faron Mist Twilit Insect on Center Stump 3
Original Item: Faron Twilight Tear
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0xC
- Name: Faron Mist Burrowing Twilit Insect 1
Original Item: Faron Twilight Tear
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0x17
- Name: Faron Mist Burrowing Twilit Insect 2
Original Item: Faron Twilight Tear
Categories:
- Overworld
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0x8
- Name: North Faron Woods Twilit Insect 1
Original Item: Faron Twilight Tear
@@ -447,7 +461,9 @@
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0x15
- Name: North Faron Woods Twilit Insect 2
Original Item: Faron Twilight Tear
@@ -456,7 +472,9 @@
- Faron Woods
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 45
Flag: 0x14
- Name: South Faron Warp Portal
Original Item: South Faron Portal
@@ -900,144 +918,160 @@
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 75
Flag: 0x2
- Name: Sanctuary Basement Twilit Insect 2
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 75
Flag: 0x3
- Name: Sanctuary Basement Twilit Insect 3
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 75
Flag: 0xC
- Name: Kakariko Graveyard Twilit Insect
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 48
Flag: 0x6
- Name: Kakariko Malo Mart Twilit Insect
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 68
Flag: 0x9
- Name: Kakariko Inn Pipe Twilit Insect
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 68
Flag: 0x8
- Name: Kakariko Inn Bedroom Twilit Insect
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 68
Flag: 0x0
- Name: Kakariko Bug House Twilit Insect
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 68
Flag: 0x1
- Name: Barnes Bomb Shop Twilit Insect
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 68
Flag: 0x7
- Name: Kakariko Destroyed Building Twilit Insect 1
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 46
Flag: 0x4
- Name: Kakariko Destroyed Building Twilit Insect 2
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 46
Flag: 0x5
- Name: Kakariko Destroyed Building Twilit Insect 3
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 46
Flag: 0xB
- Name: Kakariko Watchtower Twilit Insect
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 68
Flag: 0xA
- Name: Death Mountain Trail Twilit Insect Near Howling Stone
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 47
Flag: 0xF
- Name: Death Mountain Trail Twilit Insect on Wall
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 47
Flag: 0xE
- Name: Death Mountain Trail Twilit Insect in Hot Spring
Original Item: Eldin Twilight Tear
Categories:
- Overworld
- Eldin Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 47
Flag: 0x10
- Name: Kakariko Gorge Warp Portal
Original Item: Kakariko Gorge Portal
@@ -1895,135 +1929,150 @@
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 53
Flag: 0x2C
- Name: Lake Hylia Twilit Insect Between Bridges
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 52
Flag: 0x2F
- Name: Lake Hylia Burrowing Twilit Insect
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 52
Flag: 0x30
- Name: Lake Hylia Twilit Insect Behind Canon
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 52
Flag: 0x32
- Name: Lake Hylia Twilit Insect on Docks
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 52
Flag: 0x31
- Name: Lake Hylia Twilit Bloat
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 52
Flag: 0x35
- Name: Zoras River Twilit Insect 1
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 49
Flag: 0x3D
- Name: Zoras River Twilit Insect 2
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 49
Flag: 0x36
- Name: Zoras River Twilit Insect 3
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 49
Flag: 0x3A
- Name: Zoras River Twilit Insect 4
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 49
Flag: 0x39
- Name: Upper Zoras River Twilit Insect
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 61
Flag: 0x37
- Name: Zoras Domain Twilit Insect near Lilypads 1
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 50
Flag: 0x3B
- Name: Zoras Domain Twilit Insect near Lilypads 2
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 50
Flag: 0x2E
- Name: Zoras Domain Burrowing Twilit Insect
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 50
Flag: 0x2D
- Name: Zoras Domain Twilit Insect on West Ledge
Original Item: Lanayru Twilight Tear
Categories:
- Overworld
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 50
Flag: 0x3C
- Name: Zoras Domain Throne Room Twilit Insect
Original Item: Lanayru Twilight Tear
@@ -2032,7 +2081,9 @@
- Lanayru Province
- Twilit Insect
Metadata:
- None
Twilit Insect:
- Stage: 50
Flag: 0x3E
- Name: Lanayru Field Behind Gate Underwater Chest
Original Item: Orange Rupee
@@ -1107,7 +1107,7 @@ namespace randomizer::logic::world
return this->_itemTable.at(name).get();
}
item::Item* World::GetItem(uint8_t id, const bool& ignoreError /*= false*/) {
item::Item* World::GetItem(uint16_t id, const bool& ignoreError /*= false*/) {
if (!this->_itemIdTable.contains(id))
{
if (!ignoreError)
@@ -124,7 +124,7 @@ namespace randomizer::logic::world
dungeon::Dungeon* GetDungeon(const std::string& name);
const std::map<std::string, std::unique_ptr<dungeon::Dungeon>>& GetDungeonTable() const;
item::Item* GetItem(const std::string& name, const bool& ignoreError = false);
item::Item* GetItem(uint8_t id, const bool& ignoreError = false);
item::Item* GetItem(uint16_t id, const bool& ignoreError = false);
item::Item* GetShadowCrystal();
item::Item* GetGameWinningItem() const;
item_pool::ItemPool& GetItemPool();