Skip to content

Commit

Permalink
Add vanilla logic option (HarbourMasters#2191)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjoecox authored Dec 4, 2023
1 parent a8c1888 commit 2d22a3e
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 51 deletions.
2 changes: 2 additions & 0 deletions soh/soh/Enhancements/randomizer/3drando/fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,8 @@ void VanillaFill() {
ShuffleAllEntrances();
printf("\x1b[7;32HDone");
}
// Populate the playthrough for entrances so they are placed in the spoiler log
GeneratePlaythrough();
//Finish up
CreateItemOverrides();
CreateEntranceOverrides();
Expand Down
8 changes: 4 additions & 4 deletions soh/soh/Enhancements/randomizer/3drando/item_location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void LocationTable_Init() {
locationTable[LW_NEAR_SHORTCUTS_GROTTO_CHEST] = ItemLocation::Chest (RC_LW_NEAR_SHORTCUTS_GROTTO_CHEST, 0x3E, 0x14, "LW Near Shortcuts Grotto Chest", LW_NEAR_SHORTCUTS_GROTTO_CHEST, BLUE_RUPEE, {}, SpoilerCollectionCheckGroup::GROUP_LOST_WOODS);
locationTable[LW_SKULL_KID] = ItemLocation::Base (RC_LW_SKULL_KID, 0x5B, "LW Skull Kid", LW_SKULL_KID, PIECE_OF_HEART, {}, SpoilerCollectionCheck::ItemGetInf(22), SpoilerCollectionCheckGroup::GROUP_LOST_WOODS);
locationTable[LW_TRADE_COJIRO] = ItemLocation::Base (RC_LW_TRADE_COJIRO, 0x5B, "LW Trade Cojiro", LW_TRADE_COJIRO, ODD_MUSHROOM, {Category::cAdultTrade}, SpoilerCollectionCheck::RandomizerInf(), SpoilerCollectionCheckGroup::GROUP_LOST_WOODS);
locationTable[LW_TRADE_ODD_POTION] = ItemLocation::Base (RC_LW_TRADE_ODD_POTION, 0x5B, "LW Trade Odd Potion", LW_TRADE_ODD_POTION, ODD_POTION, {Category::cAdultTrade}, SpoilerCollectionCheck::ItemGetInf(49), SpoilerCollectionCheckGroup::GROUP_LOST_WOODS);
locationTable[LW_TRADE_ODD_POTION] = ItemLocation::Base (RC_LW_TRADE_ODD_POTION, 0x5B, "LW Trade Odd Potion", LW_TRADE_ODD_POTION, POACHERS_SAW, {Category::cAdultTrade}, SpoilerCollectionCheck::ItemGetInf(49), SpoilerCollectionCheckGroup::GROUP_LOST_WOODS);
locationTable[LW_OCARINA_MEMORY_GAME] = ItemLocation::Base (RC_LW_OCARINA_MEMORY_GAME, 0x5B, "LW Ocarina Memory Game", LW_OCARINA_MEMORY_GAME, PIECE_OF_HEART, {}, SpoilerCollectionCheck::ItemGetInf(23), SpoilerCollectionCheckGroup::GROUP_LOST_WOODS);
locationTable[LW_TARGET_IN_WOODS] = ItemLocation::Base (RC_LW_TARGET_IN_WOODS, 0x5B, "LW Target in Woods", LW_TARGET_IN_WOODS, PROGRESSIVE_SLINGSHOT, {}, SpoilerCollectionCheck::ItemGetInf(29), SpoilerCollectionCheckGroup::GROUP_LOST_WOODS);
locationTable[LW_DEKU_SCRUB_NEAR_DEKU_THEATER_RIGHT] = ItemLocation::Base (RC_LW_DEKU_SCRUB_NEAR_DEKU_THEATER_RIGHT, 0x5B, "LW Deku Scrub Near Deku Theater Right",LW_DEKU_SCRUB_NEAR_DEKU_THEATER_RIGHT, BUY_DEKU_NUT_5, {Category::cDekuScrub}, SpoilerCollectionCheck::Scrub(), SpoilerCollectionCheckGroup::GROUP_LOST_WOODS);
Expand Down Expand Up @@ -120,7 +120,7 @@ void LocationTable_Init() {
locationTable[KAK_SHOOTING_GALLERY_REWARD] = ItemLocation::Base (RC_KAK_SHOOTING_GALLERY_REWARD, 0x42, "Kak Shooting Gallery Reward", KAK_SHOOTING_GALLERY_REWARD, PROGRESSIVE_BOW, {}, SpoilerCollectionCheck::Chest(0x42, 0x1F), SpoilerCollectionCheckGroup::GROUP_KAKARIKO);
locationTable[KAK_TRADE_ODD_MUSHROOM] = ItemLocation::Base (RC_KAK_TRADE_ODD_MUSHROOM, 0x4E, "Kak Trade Odd Mushroom", KAK_TRADE_ODD_MUSHROOM, ODD_POTION, {Category::cAdultTrade}, SpoilerCollectionCheck::ItemGetInf(48), SpoilerCollectionCheckGroup::GROUP_KAKARIKO);
locationTable[KAK_GRANNYS_SHOP] = ItemLocation::Base (RC_KAK_GRANNYS_SHOP, 0x4E, "Kak Granny's Shop", KAK_GRANNYS_SHOP, BLUE_POTION_REFILL, {Category::cMerchant}, SpoilerCollectionCheck::RandomizerInf(), SpoilerCollectionCheckGroup::GROUP_KAKARIKO);
locationTable[KAK_ANJU_AS_ADULT] = ItemLocation::Base (RC_KAK_ANJU_AS_ADULT, 0x52, "Kak Anju as Adult", KAK_ANJU_AS_ADULT, CLAIM_CHECK, {}, SpoilerCollectionCheck::ItemGetInf(44), SpoilerCollectionCheckGroup::GROUP_KAKARIKO);
locationTable[KAK_ANJU_AS_ADULT] = ItemLocation::Base (RC_KAK_ANJU_AS_ADULT, 0x52, "Kak Anju as Adult", KAK_ANJU_AS_ADULT, POCKET_EGG, {}, SpoilerCollectionCheck::ItemGetInf(44), SpoilerCollectionCheckGroup::GROUP_KAKARIKO);
locationTable[KAK_ANJU_AS_CHILD] = ItemLocation::Base (RC_KAK_ANJU_AS_CHILD, 0x52, "Kak Anju as Child", KAK_ANJU_AS_CHILD, EMPTY_BOTTLE, {}, SpoilerCollectionCheck::ItemGetInf(12), SpoilerCollectionCheckGroup::GROUP_KAKARIKO);
locationTable[KAK_TRADE_POCKET_CUCCO] = ItemLocation::Base (RC_KAK_TRADE_POCKET_CUCCO, 0x52, "Kak Trade Pocket Cucco", KAK_TRADE_POCKET_CUCCO, COJIRO, {Category::cAdultTrade}, SpoilerCollectionCheck::ItemGetInf(46), SpoilerCollectionCheckGroup::GROUP_KAKARIKO);
locationTable[KAK_IMPAS_HOUSE_FREESTANDING_POH] = ItemLocation::Collectable(RC_KAK_IMPAS_HOUSE_FREESTANDING_POH, 0x37, 0x01, "Kak Impas House Freestanding PoH", KAK_IMPAS_HOUSE_FREESTANDING_POH, PIECE_OF_HEART, {}, SpoilerCollectionCheckGroup::GROUP_KAKARIKO);
Expand Down Expand Up @@ -492,7 +492,7 @@ void LocationTable_Init() {
locationTable[GERUDO_TRAINING_GROUNDS_MQ_MAZE_PATH_THIRD_CHEST] = ItemLocation::Chest (RC_GERUDO_TRAINING_GROUND_MQ_MAZE_PATH_THIRD_CHEST, 0x0B, 0x09, "Gerudo Training Grounds MQ Maze Path Third Chest", GERUDO_TRAINING_GROUNDS_MQ_MAZE_PATH_THIRD_CHEST, TREASURE_GAME_GREEN_RUPEE, {}, SpoilerCollectionCheckGroup::GROUP_GERUDO_TRAINING_GROUND);
locationTable[GERUDO_TRAINING_GROUNDS_MQ_MAZE_PATH_SECOND_CHEST] = ItemLocation::Chest (RC_GERUDO_TRAINING_GROUND_MQ_MAZE_PATH_SECOND_CHEST, 0x0B, 0x0A, "Gerudo Training Grounds MQ Maze Path Second Chest", GERUDO_TRAINING_GROUNDS_MQ_MAZE_PATH_SECOND_CHEST, RED_RUPEE, {}, SpoilerCollectionCheckGroup::GROUP_GERUDO_TRAINING_GROUND);
locationTable[GERUDO_TRAINING_GROUNDS_MQ_HIDDEN_CEILING_CHEST] = ItemLocation::Chest (RC_GERUDO_TRAINING_GROUND_MQ_HIDDEN_CEILING_CHEST, 0x0B, 0x0B, "Gerudo Training Grounds MQ Hidden Ceiling Chest", GERUDO_TRAINING_GROUNDS_MQ_HIDDEN_CEILING_CHEST, PURPLE_RUPEE, {}, SpoilerCollectionCheckGroup::GROUP_GERUDO_TRAINING_GROUND);
locationTable[GERUDO_TRAINING_GROUNDS_MQ_UNDERWATER_SILVER_RUPEE_CHEST] = ItemLocation::Chest (RC_GERUDO_TRAINING_GROUND_MQ_UNDERWATER_SILVER_RUPEE_CHEST, 0x0B, 0x0D, "Gerudo Training Grounds MQ Underwater Silver Rupee Chest",GERUDO_TRAINING_GROUNDS_MQ_UNDERWATER_SILVER_RUPEE_CHEST, TREASURE_GAME_GREEN_RUPEE, {Category::cVanillaSmallKey}, SpoilerCollectionCheckGroup::GROUP_GERUDO_TRAINING_GROUND);
locationTable[GERUDO_TRAINING_GROUNDS_MQ_UNDERWATER_SILVER_RUPEE_CHEST] = ItemLocation::Chest (RC_GERUDO_TRAINING_GROUND_MQ_UNDERWATER_SILVER_RUPEE_CHEST, 0x0B, 0x0D, "Gerudo Training Grounds MQ Underwater Silver Rupee Chest",GERUDO_TRAINING_GROUNDS_MQ_UNDERWATER_SILVER_RUPEE_CHEST, GERUDO_TRAINING_GROUNDS_SMALL_KEY, {Category::cVanillaSmallKey}, SpoilerCollectionCheckGroup::GROUP_GERUDO_TRAINING_GROUND);
locationTable[GERUDO_TRAINING_GROUNDS_MQ_HEAVY_BLOCK_CHEST] = ItemLocation::Chest (RC_GERUDO_TRAINING_GROUND_MQ_HEAVY_BLOCK_CHEST, 0x0B, 0x02, "Gerudo Training Grounds MQ Heavy Block Chest", GERUDO_TRAINING_GROUNDS_MQ_HEAVY_BLOCK_CHEST, PURPLE_RUPEE, {}, SpoilerCollectionCheckGroup::GROUP_GERUDO_TRAINING_GROUND);

//Ganons Castle Shared
Expand Down Expand Up @@ -918,7 +918,7 @@ void LocationTable_Init() {
locationTable[DMC_UPPER_GROTTO_GOSSIP_STONE] = ItemLocation::HintStone(RC_DMC_UPPER_GROTTO_GOSSIP_STONE, "DMC Upper Grotto Gossip Stone");

locationTable[GANONDORF_HINT] = ItemLocation::OtherHint(RC_GANONDORF_HINT, "Ganondorf Hint");
locationTable[TRIFORCE_COMPLETED] = ItemLocation::Reward (RC_TRIFORCE_COMPLETED, 0xFF, "Completed Triforce", NONE, TRIFORCE_COMPLETED, {}, SpoilerCollectionCheck::None(), SpoilerCollectionCheckGroup::GROUP_NO_GROUP);
locationTable[TRIFORCE_COMPLETED] = ItemLocation::Reward (RC_TRIFORCE_COMPLETED, 0xFF, "Completed Triforce", NONE, NONE, {}, SpoilerCollectionCheck::None(), SpoilerCollectionCheckGroup::GROUP_NO_GROUP);

for (int i = NONE; i != KEY_ENUM_MAX; i++)
locationLookupTable.insert(std::make_pair(locationTable[i].GetRandomizerCheck(), static_cast<Key>(i)));
Expand Down
19 changes: 12 additions & 7 deletions soh/soh/Enhancements/randomizer/3drando/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ std::vector<std::string> presetEntries;
Option* currentSetting;
} // namespace

static void RestoreOverrides() {
if (Settings::Logic.Is(LOGIC_VANILLA)) {
for (auto overridePair : Settings::vanillaLogicOverrides) {
overridePair.first->RestoreDelayedOption();
}
}
}

std::string GenerateRandomizer(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettings, std::set<RandomizerCheck> excludedLocations, std::set<RandomizerTrick> enabledTricks,
std::string seedString) {

Expand Down Expand Up @@ -52,20 +60,17 @@ std::string GenerateRandomizer(std::unordered_map<RandomizerSettingKey, uint8_t>
printf("\n\nFailed to generate after 5 tries.\nPress B to go back to the menu.\nA different seed might be "
"successful.");
SPDLOG_DEBUG("\nRANDOMIZATION FAILED COMPLETELY. PLZ FIX\n");
RestoreOverrides();
return "";
} else {
printf("\n\nError %d with fill.\nPress Select to exit or B to go back to the menu.\n", ret);
RestoreOverrides();
return "";
}
}

// Restore settings that were set to a specific value for vanilla logic
if (Settings::Logic.Is(LOGIC_VANILLA)) {
for (Option* setting : Settings::vanillaLogicDefaults) {
setting->RestoreDelayedOption();
}
Settings::Keysanity.RestoreDelayedOption();
}
RestoreOverrides();

std::ostringstream fileNameStream;
for (int i = 0; i < Settings::hashIconIndexes.size(); i++) {
if (i) {
Expand Down
96 changes: 71 additions & 25 deletions soh/soh/Enhancements/randomizer/3drando/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2060,21 +2060,65 @@ namespace Settings {
}

//Options that should be saved, set to default, then restored after finishing when vanilla logic is enabled
std::vector<Option *> vanillaLogicDefaults = {
&LinksPocketItem,
&ShuffleRewards,
&ShuffleSongs,
&Shopsanity,
&ShopsanityPrices,
&ShopsanityPricesAffordable,
&Scrubsanity,
&ShuffleCows,
&ShuffleMagicBeans,
&ShuffleMerchants,
&ShuffleFrogSongRupees,
&ShuffleAdultTradeQuest,
&Shuffle100GSReward,
&GossipStoneHints,
std::vector<std::pair<Option*, uint8_t>> vanillaLogicOverrides = {
{ &OpenForest, OPENFOREST_CLOSED },
{ &OpenKakariko, OPENKAKARIKO_CLOSED },
{ &OpenDoorOfTime, OPENDOOROFTIME_CLOSED },
{ &ZorasFountain, ZORASFOUNTAIN_NORMAL },
{ &GerudoFortress, GERUDOFORTRESS_NORMAL },
{ &Bridge, RAINBOWBRIDGE_VANILLA },
{ &RandomGanonsTrials, OFF },
{ &GanonsTrialsCount, 6 },

{ &StartingAge, AGE_CHILD },
{ &TriforceHunt, TRIFORCE_HUNT_OFF },

{ &ShuffleRewards, REWARDSHUFFLE_END_OF_DUNGEON },
{ &LinksPocketItem, LINKSPOCKETITEM_DUNGEON_REWARD },
{ &ShuffleSongs, SONGSHUFFLE_SONG_LOCATIONS },
{ &Shopsanity, SHOPSANITY_OFF },
{ &Tokensanity, TOKENSANITY_OFF },
{ &Scrubsanity, SCRUBSANITY_OFF },
{ &ShuffleCows, OFF },
{ &ShuffleKokiriSword, OFF },
{ &ShuffleMasterSword, OFF },
{ &ShuffleOcarinas, OFF },
{ &ShuffleWeirdEgg, OFF },
{ &ShuffleGerudoToken, OFF },
{ &ShuffleMagicBeans, OFF },
{ &ShuffleMerchants, SHUFFLEMERCHANTS_OFF },
{ &ShuffleFrogSongRupees, SHUFFLEFROGSONGRUPEES_OFF },
{ &ShuffleAdultTradeQuest, SHUFFLEADULTTRADEQUEST_OFF },
{ &ShuffleChestMinigame, SHUFFLECHESTMINIGAME_OFF },
{ &Shuffle100GSReward, OFF },

{ &MapsAndCompasses, MAPSANDCOMPASSES_VANILLA },
{ &Keysanity, KEYSANITY_ANY_DUNGEON }, // Set small keys to any dungeon so FiT basement door will be locked
{ &GerudoKeys, GERUDOKEYS_VANILLA },
{ &BossKeysanity, BOSSKEYSANITY_VANILLA },
{ &GanonsBossKey, GANONSBOSSKEY_VANILLA },
{ &KeyRings, KEYRINGS_OFF },

{ &StartingOcarina, OFF },

{ &SkipChildStealth, DONT_SKIP },
{ &SkipTowerEscape, DONT_SKIP },
{ &SkipEponaRace, DONT_SKIP },

{ &GossipStoneHints, HINTS_NO_HINTS },
{ &AltarHintText, HINTS_NO_HINTS },
{ &LightArrowHintText, HINTS_NO_HINTS },
{ &DampeHintText, HINTS_NO_HINTS },
{ &GregHintText, HINTS_NO_HINTS },
{ &SariaHintText, HINTS_NO_HINTS },
{ &FrogsHintText, HINTS_NO_HINTS },
{ &WarpSongHints, HINTS_NO_HINTS },
{ &Kak10GSHintText, HINTS_NO_HINTS },
{ &Kak20GSHintText, HINTS_NO_HINTS },
{ &Kak30GSHintText, HINTS_NO_HINTS },
{ &Kak40GSHintText, HINTS_NO_HINTS },
{ &Kak50GSHintText, HINTS_NO_HINTS },
{ &ScrubHintText, HINTS_NO_HINTS },
};

// Randomizes all settings in a category if chosen
Expand Down Expand Up @@ -2207,6 +2251,9 @@ namespace Settings {
case RO_LOGIC_NO_LOGIC:
Logic.SetSelectedIndex(2);
break;
case RO_LOGIC_VANILLA:
Logic.SetSelectedIndex(3);
break;
}

LocationsReachable.SetSelectedIndex(cvarSettings[RSK_ALL_LOCATIONS_REACHABLE]);
Expand Down Expand Up @@ -2428,6 +2475,15 @@ namespace Settings {
// RANDOTODO implement chest shuffle with keysanity
// ShuffleChestMinigame.SetSelectedIndex(cvarSettings[RSK_SHUFFLE_CHEST_MINIGAME]);

if (Logic.Is(LOGIC_VANILLA)) {
LACSCondition = LACSCONDITION_VANILLA;
skipChildZelda = false;
for (auto overridePair : vanillaLogicOverrides) {
overridePair.first->SetDelayedOption();
overridePair.first->SetSelectedIndex(overridePair.second);
}
}

RandomizeAllSettings(true); //now select any random options instead of just hiding them

//shuffle the dungeons and then set MQ for as many as necessary
Expand Down Expand Up @@ -2594,16 +2650,6 @@ namespace Settings {
} else {
LACSCondition = LACSCONDITION_VANILLA;
}

//If vanilla logic, we want to set all settings which unnecessarily modify vanilla behavior to off
if (Logic.Is(LOGIC_VANILLA)) {
for (Option* setting : vanillaLogicDefaults) {
setting->SetDelayedOption();
setting->SetSelectedIndex(0);
}
Keysanity.SetDelayedOption();
Keysanity.SetSelectedIndex(3); //Set small keys to any dungeon so FiT basement door will be locked
}
}

//If this is an option menu, return the options
Expand Down
7 changes: 6 additions & 1 deletion soh/soh/Enhancements/randomizer/3drando/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ typedef enum {
SHUFFLEMERCHANTS_HINTS,
} ShuffleMerchantsSetting;

typedef enum {
SHUFFLEFROGSONGRUPEES_OFF,
SHUFFLEFROGSONGRUPEES_ON,
} ShuffleFrogSongRupeesSetting;

typedef enum {
SHUFFLEADULTTRADEQUEST_OFF,
SHUFFLEADULTTRADEQUEST_ON,
Expand Down Expand Up @@ -1173,5 +1178,5 @@ void UpdateSettings(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSettin

extern std::vector<Menu *> mainMenu;

extern std::vector<Option *> vanillaLogicDefaults;
extern std::vector<std::pair<Option*, uint8_t>> vanillaLogicOverrides;
}
Loading

0 comments on commit 2d22a3e

Please sign in to comment.