Skip to content

Commit

Permalink
Add vanilla logic option
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjoecox committed Oct 3, 2023
1 parent b1f0c96 commit 8bf2c11
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 38 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
6 changes: 3 additions & 3 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(30), 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(57), 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(57), 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(31), 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(21), 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(56), 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(36), 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(36), 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(4), 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(38), 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
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
53 changes: 28 additions & 25 deletions soh/soh/Enhancements/randomizer/3drando/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2055,21 +2055,24 @@ 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 = {
{ &LinksPocketItem, LINKSPOCKETITEM_DUNGEON_REWARD },
{ &ShuffleRewards, REWARDSHUFFLE_END_OF_DUNGEON },
{ &ShuffleSongs, SONGSHUFFLE_SONG_LOCATIONS },
{ &Shopsanity, SHOPSANITY_OFF },
{ &Scrubsanity, SCRUBSANITY_OFF },
{ &ShuffleCows, OFF },
{ &ShuffleMagicBeans, OFF },
{ &ShuffleMerchants, SHUFFLEMERCHANTS_OFF },
{ &ShuffleChestMinigame, SHUFFLECHESTMINIGAME_OFF },
{ &ShuffleFrogSongRupees, SHUFFLEFROGSONGRUPEES_OFF },
{ &ShuffleAdultTradeQuest, SHUFFLEADULTTRADEQUEST_ON },
{ &MapsAndCompasses, MAPSANDCOMPASSES_VANILLA },
{ &Keysanity, KEYSANITY_ANY_DUNGEON }, // Set small keys to any dungeon so FiT basement door will be locked
{ &BossKeysanity, BOSSKEYSANITY_VANILLA },
{ &GanonsBossKey, GANONSBOSSKEY_VANILLA },
{ &Shuffle100GSReward, OFF },
{ &GossipStoneHints, HINTS_NO_HINTS },
};

// Randomizes all settings in a category if chosen
Expand Down Expand Up @@ -2202,6 +2205,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 @@ -2422,6 +2428,13 @@ namespace Settings {
// RANDOTODO implement chest shuffle with keysanity
// ShuffleChestMinigame.SetSelectedIndex(cvarSettings[RSK_SHUFFLE_CHEST_MINIGAME]);

if (Logic.Is(LOGIC_VANILLA)) {
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 @@ -2588,16 +2601,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 @@ -1172,5 +1177,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;
}
6 changes: 4 additions & 2 deletions soh/soh/Enhancements/randomizer/randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3096,7 +3096,7 @@ void RandomizerSettingsWindow::DrawElement() {

// Randomizer settings
// Logic Settings
static const char* randoLogicRules[2] = { "Glitchless", "No logic" };
static const char* randoLogicRules[3] = { "Glitchless", "No logic", "Vanilla" };

// Open Settings
static const char* randoForest[3] = { "Closed", "Closed Deku", "Open" };
Expand Down Expand Up @@ -4759,7 +4759,9 @@ void RandomizerSettingsWindow::DrawElement() {
"\n"
//"Glitched - Glitches may be required to beat the game. You can disable and enable glitches below.\n"
//"\n"
"No logic - Item placement is completely random. MAY BE IMPOSSIBLE TO BEAT."
"No logic - Item placement is completely random. MAY BE IMPOSSIBLE TO BEAT.\n"
"\n"
"Vanilla - Places all items and dungeon rewards in their vanilla locations."
);
UIWidgets::EnhancementCombobox("gRandomizeLogicRules", randoLogicRules, RO_LOGIC_GLITCHLESS);
if (CVarGetInteger("gRandomizeLogicRules", RO_LOGIC_GLITCHLESS) != RO_LOGIC_NO_LOGIC) {
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/randomizer/randomizerTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1747,6 +1747,7 @@ typedef enum {
RO_LOGIC_GLITCHLESS,
//RO_LOGIC_GLITCHED,
RO_LOGIC_NO_LOGIC,
RO_LOGIC_VANILLA,
} RandoOptionLogic;

// MQ Dungeons
Expand Down

0 comments on commit 8bf2c11

Please sign in to comment.