add necessary settings to rando context

This commit is contained in:
gymnast86
2026-04-21 01:32:08 -07:00
parent 7606998ba6
commit dd04da230f
6 changed files with 58 additions and 5 deletions
+8 -1
View File
@@ -36,9 +36,16 @@ namespace dusk {
return;
}
auto& world = r.GetWorlds()[0];
const auto& world = r.GetWorlds()[0];
RandomizerContext randoData{};
for (const auto& [setting, info] : *randomizer::seedgen::settings::GetAllSettingsInfo()) {
if (info->NeedInGame()) {
randoData.mSettings[setting] = world->Setting(setting).GetCurrentOption();
}
}
// Chest overrides
for (const auto& location : world->GetAllLocations()) {
const auto& metaData = location->GetMetadata();
@@ -29,6 +29,10 @@ std::optional<std::string> RandomizerContext::WriteToFile() {
YAML::Node out{};
for (const auto& [settingName, option] : this->mSettings) {
out["Settings"][settingName] = option;
}
// NOTE: When dumping u8s, they must be converted to u16s (or higher), otherwise they get dumped
// as single characters and not numbers
@@ -61,6 +65,13 @@ std::optional<std::string> RandomizerContext::LoadFromHash(const std::string& ha
auto in = LoadYAML(this->GetSeedDataPath());
// Necessary settings
for (const auto& settingNode : in["mSettings"] ) {
const auto& settingName = settingNode.first.as<std::string>();
const auto& option = settingNode.second.as<std::string>();
this->mSettings[settingName] = option;
}
// Event flags
for (const auto& flag : in["mStartEventFlags"]) {
this->mStartEventFlags.push_back(flag.as<u16>());
@@ -16,6 +16,8 @@ public:
u32 mSeedID{0};
std::string mHash{""};
std::unordered_map<std::string, std::string> mSettings{};
std::list<u16> mStartEventFlags{};
std::unordered_map<u8, std::list<u8>> mStartRegionFlags{};
std::list<u8> mStartingInventory{};
@@ -17,6 +17,8 @@
######################
- Name: Hyrule Barrier Requirements
Need In Game: True
Tracker Important: True
Default Option: Vanilla
Options:
- Open: "The barrier around Hyrule Castle is dispelled from the beginning."
@@ -28,36 +30,43 @@
- Hearts: "The barrier will be dispelled once the required number of Hearts have been reached."
- Name: Hyrule Barrier Fused Shadows
Need In Game: True
Tracker Important: True
Default Option: 1
Options:
- 1-3: description
- Name: Hyrule Barrier Mirror Shards
Need In Game: True
Tracker Important: True
Default Option: 1
Options:
- 1-4: description
- Name: Hyrule Barrier Dungeons
Need In Game: True
Tracker Important: True
Default Option: 1
Options:
- 1-8: description
- Name: Hyrule Barrier Poe Souls
Need In Game: True
Tracker Important: True
Default Option: 1
Options:
- 1-60: description
- Name: Hyrule Barrier Hearts
Need In Game: True
Tracker Important: True
Default Option: 4
Options:
- 4-20: description # Hehe 420
- Name: Palace of Twilight Requirements
Need In Game: True
Tracker Important: True
Default Option: Vanilla
Options:
- Open: "The barrier around Hyrule Castle is dispelled from the beginning."
@@ -66,6 +75,7 @@
- Vanilla: "The player must complete City in the Sky."
- Name: Faron Woods Logic
Tracker Important: True
Default Option: Closed
Options:
- Closed: "Midna will block the player from leaving Faron Woods until Forest Temple is completed."
@@ -76,48 +86,56 @@
######################
- Name: Golden Bugs
Tracker Important: True
Default Option: "Off"
Options:
- "Off": "The Golden Bug locations across Hyrule will not be randomized."
- "On": "The Golden Bug locations across Hyrule will be randomized."
- Name: Sky Characters
Tracker Important: True
Default Option: "Off"
Options:
- "Off": description
- "On": description
- Name: Gifts From NPCs
Tracker Important: True
Default Option: "Off"
Options:
- "Off": description
- "On": description
- Name: Shop Items
Tracker Important: True
Default Option: "Off"
Options:
- "Off": description
- "On": description
- Name: Hidden Skills
Tracker Important: True
Default Option: "Off"
Options:
- "Off": description
- "On": description
- Name: Hidden Rupees
Tracker Important: True
Default Option: "Off"
Options:
- "Off": description
- "On": description
- Name: Freestanding Rupees
Tracker Important: True
Default Option: "Off"
Options:
- "Off": description
- "On": description
- Name: Poe Souls
Tracker Important: True
Default Option: Vanilla
Options:
- Vanilla: description
@@ -126,6 +144,7 @@
- All: description
- Name: Ilia Memory Quest
Tracker Important: True
Default Option: Vanilla
Options:
- Vanilla: description
@@ -183,6 +202,7 @@
- Start With: "The player starts with all Maps and Compasses."
- Name: Hyrule Castle Big Key Requirements
Need In Game: True
Tracker Important: True
Default Option: None
Options:
@@ -194,30 +214,35 @@
- Hearts: "The gate will open once the required number of Hearts have been reached."
- Name: Hyrule Castle Big Key Fused Shadows
Need In Game: True
Tracker Important: True
Default Option: 1
Options:
- 1-3: description
- Name: Hyrule Castle Big Key Mirror Shards
Need In Game: True
Tracker Important: True
Default Option: 1
Options:
- 1-4: description
- Name: Hyrule Castle Big Key Dungeons
Need In Game: True
Tracker Important: True
Default Option: 1
Options:
- 1-8: description
- Name: Hyrule Castle Big Key Poe Souls
Need In Game: True
Tracker Important: True
Default Option: 1
Options:
- 1-60: description
- Name: Hyrule Castle Big Key Hearts
Need In Game: True
Tracker Important: True
Default Option: 4
Options:
@@ -36,7 +36,8 @@ namespace randomizer::seedgen::settings
const int& randomOptionIndex,
const int& randomLow,
const int& randomHigh,
const bool& trackerImportant):
const bool& trackerImportant,
const bool& needInGame):
_id(id),
_name(name),
_type(type),
@@ -47,7 +48,8 @@ namespace randomizer::seedgen::settings
_randomOptionIndex(randomOptionIndex),
_randomLow(randomLow),
_randomHigh(randomHigh),
_trackerImportant(trackerImportant)
_trackerImportant(trackerImportant),
_needInGame(needInGame)
{
// The logic expression of a setting replaces spaces with underscores,
// and removes apostraphes and parenthesis
@@ -280,6 +282,8 @@ namespace randomizer::seedgen::settings
const auto& trackerImportant =
settingNode["Tracker Important"] ? settingNode["Tracker Important"].as<bool>() : false;
const auto& needInGame =
settingNode["Need In Game"] ? settingNode["Need In Game"].as<bool>() : false;
const auto& hasRandomOption =
settingNode["Autogenerate Random"] ? settingNode["Autogenerate Random"].as<bool>() : true;
const auto& randomAlias = settingNode["Random Alias"] ? settingNode["Random Alias"].as<std::string>() : "Random";
@@ -327,7 +331,8 @@ namespace randomizer::seedgen::settings
randomOptionIndex,
randomLow,
randomHigh,
trackerImportant);
trackerImportant,
needInGame);
settingInfoMap->emplace(name, std::move(info));
}
@@ -58,7 +58,8 @@ namespace randomizer::seedgen::settings
const int& randomOptionIndex,
const int& randomLow,
const int& randomHigh,
const bool& trackerImportant);
const bool& trackerImportant,
const bool& needInGame);
int GetID() const { return this->_id; }
@@ -98,6 +99,7 @@ namespace randomizer::seedgen::settings
int GetRandomLow() const { return this->_randomLow; }
int GetRandomHigh() const { return this->_randomHigh; }
bool TrackerImportant() const { return this->_trackerImportant; }
bool NeedInGame() const { return this->_needInGame; }
private:
int _id = -1;
@@ -111,6 +113,7 @@ namespace randomizer::seedgen::settings
int _randomLow = 0; // Lower bound when choosing a random option
int _randomHigh = 0; // Upper bound when choosing a random option
bool _trackerImportant = false; // Whether or not this setting can affect trackers
bool _needInGame = false; // Whether or not we need to read this setting during gameplay
// Variables that hold the setting's name and options when being checked
// in a logical requirement string.