From fa473d48a917730e401c2a837ced4a21316f317a Mon Sep 17 00:00:00 2001 From: gymnast86 Date: Tue, 21 Apr 2026 20:54:07 -0700 Subject: [PATCH] implement Uli Cradle Delivery check --- src/d/actor/d_a_npc_uri.cpp | 5 +++++ src/dusk/imgui/ImGuiMenuRandomizer.cpp | 12 +++++++++++- src/dusk/randomizer/game/randomizer_context.cpp | 13 +++++++++++++ src/dusk/randomizer/game/randomizer_context.hpp | 3 +++ src/dusk/randomizer/generator/data/locations.yaml | 5 ++--- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/d/actor/d_a_npc_uri.cpp b/src/d/actor/d_a_npc_uri.cpp index bb0a561d26..7dc9eda11a 100644 --- a/src/d/actor/d_a_npc_uri.cpp +++ b/src/d/actor/d_a_npc_uri.cpp @@ -1165,6 +1165,11 @@ int daNpc_Uri_c::cutEndCarryTutorial(int param_1) { (s32)mFlow.getEventId(&local_48) == 1) { if (mItemPartnerId == fpcM_ERROR_PROCESS_ID_e) { +#if TARGET_PC + if (randomizer_IsActive()) { + local_48 = randomizer_getItemAtLocation("Uli Cradle Delivery"); + } +#endif mItemPartnerId = fopAcM_createItemForPresentDemo(¤t.pos, local_48, 0, -1, -1, NULL, NULL); } diff --git a/src/dusk/imgui/ImGuiMenuRandomizer.cpp b/src/dusk/imgui/ImGuiMenuRandomizer.cpp index ad13ea4b2d..7aae97f2a5 100644 --- a/src/dusk/imgui/ImGuiMenuRandomizer.cpp +++ b/src/dusk/imgui/ImGuiMenuRandomizer.cpp @@ -44,21 +44,31 @@ namespace dusk { RandomizerContext randoData{}; + // Settings we need to check ingame for (const auto& [setting, info] : *randomizer::seedgen::settings::GetAllSettingsInfo()) { if (info->NeedInGame()) { randoData.mSettings[setting] = world->Setting(setting).GetCurrentOption(); } } - // Chest overrides + // Set data for all locations for (const auto& location : world->GetAllLocations()) { const auto& metaData = location->GetMetadata(); + + // Chest Overrides if (location->HasCategories("Chest")) { const auto& stage = metaData[0]["Stage"].as(); const auto& tboxId = metaData[0]["Tbox ID"].as(); const auto& itemId = location->GetCurrentItem()->GetID(); randoData.mTreasureChestOverrides[stage][tboxId] = itemId; } + + // Items that we lookup just by calling their location name + if (location->HasCategories("Location Name Lookup")) { + const auto& locationName = metaData.as(); + const int itemId = location->GetCurrentItem()->GetID(); + randoData.mItemLocations[locationName] = itemId; + } } // Set starting inventory diff --git a/src/dusk/randomizer/game/randomizer_context.cpp b/src/dusk/randomizer/game/randomizer_context.cpp index f579e2058b..d1cd8a98b3 100644 --- a/src/dusk/randomizer/game/randomizer_context.cpp +++ b/src/dusk/randomizer/game/randomizer_context.cpp @@ -55,6 +55,8 @@ std::optional RandomizerContext::WriteToFile() { } } + out["mItemLocations"] = this->mItemLocations; + out["mStartHour"] = static_cast(this->mStartHour); out["mMapBits"] = static_cast(this->mMapBits); @@ -114,6 +116,13 @@ std::optional RandomizerContext::LoadFromHash(const std::string& ha } } + // Items For Present Demos + for (const auto& locationNode : in["mItemLocations"]) { + const auto& locationName = locationNode.first.as(); + int itemId = locationNode.second.as(); + this->mItemLocations[locationName] = itemId; + } + // Starting hour this->mStartHour = in["mStartHour"].as(); // Starting map bits @@ -152,6 +161,10 @@ std::vector HexToBytes(std::string hex) { return bytes; } +int randomizer_getItemAtLocation(const std::string& locationName) { + return randomizer_GetContext().mItemLocations[locationName]; +} + u32 getActorPatchesCurrentStageKey() { u32 actorPatchesStageKey{}; actorPatchesStageKey |= getStageID(dComIfGp_getStartStageName()) << 16; diff --git a/src/dusk/randomizer/game/randomizer_context.hpp b/src/dusk/randomizer/game/randomizer_context.hpp index 9760d4d35a..b9384b6b0b 100644 --- a/src/dusk/randomizer/game/randomizer_context.hpp +++ b/src/dusk/randomizer/game/randomizer_context.hpp @@ -27,6 +27,7 @@ public: std::list mStartingInventory{}; std::unordered_map> mTreasureChestOverrides{}; std::unordered_map> mPoeOverrides{}; + std::unordered_map mItemLocations{}; u8 mStartHour{0}; u8 mMapBits{}; @@ -41,6 +42,8 @@ RandomizerContext& randomizer_GetContext(); bool randomizer_IsActive(); +int randomizer_getItemAtLocation(const std::string& locationName); + /** * Helper function to convert raw bytes of a container to a hex string */ diff --git a/src/dusk/randomizer/generator/data/locations.yaml b/src/dusk/randomizer/generator/data/locations.yaml index 0877508028..52a4fe428e 100644 --- a/src/dusk/randomizer/generator/data/locations.yaml +++ b/src/dusk/randomizer/generator/data/locations.yaml @@ -27,9 +27,8 @@ Categories: - Overworld - Ordona Province - - ARC - Metadata: - - None + - Location Name Lookup + Metadata: Uli Cradle Delivery - Name: Ordon Cat Rescue Original Item: Bottle with Half Milk