From 170c8ce16e3a6f71da6825e7be6bfe3201894adc Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Thu, 15 Jun 2023 03:24:50 +0000 Subject: [PATCH] Extra modes tweaks (#2985) * Tweaks to extra modes menu * Update soh/soh/config/ConfigUpdaters.cpp Co-authored-by: Christopher Leggett --------- Co-authored-by: Christopher Leggett --- soh/soh/Enhancements/enemyrandomizer.cpp | 14 +++-- soh/soh/Enhancements/enhancementTypes.h | 6 +++ soh/soh/SohMenuBar.cpp | 66 +++++++++--------------- soh/soh/config/ConfigUpdaters.cpp | 6 +++ 4 files changed, 41 insertions(+), 51 deletions(-) diff --git a/soh/soh/Enhancements/enemyrandomizer.cpp b/soh/soh/Enhancements/enemyrandomizer.cpp index 0e9d9fcdf..414f296cc 100644 --- a/soh/soh/Enhancements/enemyrandomizer.cpp +++ b/soh/soh/Enhancements/enemyrandomizer.cpp @@ -2,6 +2,7 @@ #include "functions.h" #include "macros.h" #include "soh/Enhancements/randomizer/3drando/random.hpp" +#include "soh/Enhancements/enhancementTypes.h" #include "variables.h" extern "C" { @@ -232,16 +233,13 @@ extern "C" uint8_t GetRandomizedEnemy(PlayState* play, int16_t *actorId, f32 *po } EnemyEntry GetRandomizedEnemyEntry(uint32_t seed) { - if (CVarGetInteger("gSeededRandomizedEnemies", 0) && gSaveContext.n64ddFlag) { - uint32_t finalSeed = seed + gSaveContext.seedIcons[0] + gSaveContext.seedIcons[1] + gSaveContext.seedIcons[2] + - gSaveContext.seedIcons[3] + gSaveContext.seedIcons[4]; + if (CVarGetInteger("gRandomizedEnemies", ENEMY_RANDOMIZER_OFF) == ENEMY_RANDOMIZER_RANDOM_SEEDED) { + uint32_t finalSeed = seed + (gSaveContext.n64ddFlag ? (gSaveContext.seedIcons[0] + gSaveContext.seedIcons[1] + gSaveContext.seedIcons[2] + gSaveContext.seedIcons[3] + gSaveContext.seedIcons[4]) : gSaveContext.sohStats.fileCreatedAt); Random_Init(finalSeed); - uint32_t randomNumber = Random(0, RANDOMIZED_ENEMY_SPAWN_TABLE_SIZE); - return randomizedEnemySpawnTable[randomNumber]; - } else { - uint32_t randomNumber = rand() + seed; - return randomizedEnemySpawnTable[randomNumber % RANDOMIZED_ENEMY_SPAWN_TABLE_SIZE]; } + + uint32_t randomNumber = Random(0, RANDOMIZED_ENEMY_SPAWN_TABLE_SIZE); + return randomizedEnemySpawnTable[randomNumber]; } bool IsEnemyFoundToRandomize(int16_t sceneNum, int8_t roomNum, int16_t actorId, int16_t params, float posX) { diff --git a/soh/soh/Enhancements/enhancementTypes.h b/soh/soh/Enhancements/enhancementTypes.h index a13494a3a..1699ddf89 100644 --- a/soh/soh/Enhancements/enhancementTypes.h +++ b/soh/soh/Enhancements/enhancementTypes.h @@ -18,6 +18,12 @@ typedef enum { MIRRORED_WORLD_RANDOM_SEEDED, } MirroredWorldMode; +typedef enum { + ENEMY_RANDOMIZER_OFF, + ENEMY_RANDOMIZER_RANDOM, + ENEMY_RANDOMIZER_RANDOM_SEEDED, +} EnemyRandomizerMode; + typedef enum { FASTFILE_1, FASTFILE_2, diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 84afa1055..695b2f629 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -63,6 +63,7 @@ std::string GetWindowButtonText(const char* text, bool menuOpen) { static const char* chestStyleMatchesContentsOptions[4] = { "Disabled", "Both", "Texture Only", "Size Only" }; static const char* bunnyHoodOptions[3] = { "Disabled", "Faster Run & Longer Jump", "Faster Run" }; static const char* mirroredWorldModes[4] = { "Disabled", "Always", "Random", "Random (Seeded)" }; + static const char* enemyRandomizerModes[3] = { "Disabled", "Random", "Random (Seeded)" }; static const char* allPowers[9] = { "Vanilla (1x)", "Double (2x)", @@ -1031,7 +1032,18 @@ void DrawEnhancementsMenu() { UIWidgets::Spacer(0); if (ImGui::BeginMenu("Extra Modes")) { - UIWidgets::PaddedText("Mirrored World Mode", true, false); + #ifdef ENABLE_CROWD_CONTROL + if (UIWidgets::PaddedEnhancementCheckbox("Crowd Control", "gCrowdControl", false, false)) { + if (CVarGetInteger("gCrowdControl", 0)) { + CrowdControl::Instance->Enable(); + } else { + CrowdControl::Instance->Disable(); + } + } + UIWidgets::Tooltip("Will attempt to connect to the Crowd Control server. Check out crowdcontrol.live for more information."); + #endif + + UIWidgets::PaddedText("Mirrored World", true, false); if (UIWidgets::EnhancementCombobox("gMirroredWorldMode", mirroredWorldModes, MIRRORED_WORLD_OFF) && gPlayState != NULL) { UpdateMirrorModeState(gPlayState->sceneNum); } @@ -1042,18 +1054,23 @@ void DrawEnhancementsMenu() { "- Random (Seeded): Scenes are mirrored based on the current randomizer seed/file\n" ); - UIWidgets::Spacer(0); + UIWidgets::PaddedText("Enemy Randomizer", true, false); + UIWidgets::EnhancementCombobox("gRandomizedEnemies", enemyRandomizerModes, ENEMY_RANDOMIZER_OFF); + UIWidgets::Tooltip( + "Replaces fixed enemies throughout the game with a random enemy. Bosses, mini-bosses and a few specific regular enemies are excluded.\n" + "Enemies that need more than Deku Nuts + either Deku Sticks or a sword to kill are excluded from spawning in \"clear enemy\" rooms.\n\n" + "- Random: Enemies are randomized every time you load a room\n" + "- Random (Seeded): Enemies are randomized based on the current randomizer seed/file\n" + ); UIWidgets::PaddedEnhancementCheckbox("Ivan the Fairy (Coop Mode)", "gIvanCoopModeEnabled", true, false); UIWidgets::Tooltip("Enables Ivan the Fairy upon the next map change. Player 2 can control Ivan and " "press the C-Buttons to use items and mess with Player 1!"); - UIWidgets::Spacer(0); - UIWidgets::PaddedEnhancementCheckbox("Rupee Dash Mode", "gRupeeDash", true, false); + UIWidgets::Tooltip("Rupees reduced over time, Link suffers damage when the count hits 0."); if (CVarGetInteger("gRupeeDash", 0)) { - UIWidgets::Tooltip("Rupees reduced over time, Link suffers damage when the count hits 0."); UIWidgets::PaddedEnhancementSliderInt( "Rupee Dash Interval: %d", "##DashInterval", "gDashInterval", 3, 5, "", 5, true, true, false, !CVarGetInteger("gRupeeDash", 0), @@ -1061,13 +1078,8 @@ void DrawEnhancementsMenu() { UIWidgets::Tooltip("Interval between Rupee reduction in Rupee Dash Mode"); } - UIWidgets::Spacer(0); - UIWidgets::PaddedEnhancementCheckbox("Shadow Tag Mode", "gShadowTag", true, false); - - if (CVarGetInteger("gShadowTag", 0)) { - UIWidgets::Tooltip("A wallmaster follows Link everywhere, don't get caught!"); - } + UIWidgets::Tooltip("A wallmaster follows Link everywhere, don't get caught!"); ImGui::EndMenu(); } @@ -1421,38 +1433,6 @@ void DrawRandomizerMenu() { ImGui::EndMenu(); } - UIWidgets::PaddedSeparator(); - - #ifdef ENABLE_CROWD_CONTROL - UIWidgets::EnhancementCheckbox("Crowd Control", "gCrowdControl"); - UIWidgets::Tooltip("Will attempt to connect to the Crowd Control server. Check out crowdcontrol.live for more information."); - - if (CVarGetInteger("gCrowdControl", 0)) { - CrowdControl::Instance->Enable(); - } else { - CrowdControl::Instance->Disable(); - } - - UIWidgets::Spacer(0); - #endif - - UIWidgets::EnhancementCheckbox("Enemy Randomizer", "gRandomizedEnemies"); - UIWidgets::Tooltip( - "Randomizes regular enemies every time you load a room. Bosses, mini-bosses and a few specific regular enemies are excluded.\n\n" - "Enemies that need more than Deku Nuts + either Deku Sticks or a sword to kill are excluded from spawning in \"clear enemy\" rooms." - ); - - if (CVarGetInteger("gRandomizedEnemies", 0)) { - - bool disableSeededEnemies = !gSaveContext.n64ddFlag && gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2; - static const char* disableSeededEnemiesText = "This setting is disabled because it relies on a randomizer savefile."; - - UIWidgets::PaddedEnhancementCheckbox("Seeded Enemy Spawns", "gSeededRandomizedEnemies", true, false, disableSeededEnemies, disableSeededEnemiesText); - UIWidgets::Tooltip( - "Enemy spawns will stay consistent throughout room reloads. Enemy spawns are based on randomizer seeds, so this only works with randomizer savefiles." - ); - } - ImGui::EndMenu(); } } diff --git a/soh/soh/config/ConfigUpdaters.cpp b/soh/soh/config/ConfigUpdaters.cpp index a157ab9e7..c2689e676 100644 --- a/soh/soh/config/ConfigUpdaters.cpp +++ b/soh/soh/config/ConfigUpdaters.cpp @@ -53,5 +53,11 @@ namespace LUS { CVarSetInteger("gZFightingMode", CVarGetInteger("gDirtPathFix", 0)); CVarClear("gDirtPathFix"); } + if (CVarGetInteger("gRandomizedEnemies", 0) != 0) { + if (CVarGetInteger("gSeededRandomizedEnemies", 0)) { + CVarSetInteger("gRandomizedEnemies", 2); + } + } + CVarClear("gSeededRandomizedEnemies"); } } \ No newline at end of file