From bfd54abada20e30d36959b66e4df2d11d5bb0888 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Wed, 13 Nov 2024 14:19:11 -0600 Subject: [PATCH] Fix christmas tree messages --- soh/soh/Enhancements/Holiday/Rando.cpp | 49 +++++++++++++++++++ .../randomizer/option_descriptions.cpp | 10 ++-- .../Enhancements/randomizer/randomizer.cpp | 35 ------------- soh/soh/Enhancements/randomizer/randomizer.h | 2 - soh/soh/Enhancements/randomizer/settings.cpp | 6 +-- soh/soh/OTRGlobals.cpp | 4 +- 6 files changed, 58 insertions(+), 48 deletions(-) create mode 100644 soh/soh/Enhancements/Holiday/Rando.cpp diff --git a/soh/soh/Enhancements/Holiday/Rando.cpp b/soh/soh/Enhancements/Holiday/Rando.cpp new file mode 100644 index 000000000..e5466dccf --- /dev/null +++ b/soh/soh/Enhancements/Holiday/Rando.cpp @@ -0,0 +1,49 @@ +#include "Holiday.hpp" +#include +#include "soh/UIWidgets.hpp" +#include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/Enhancements/custom-message/CustomMessageManager.h" +#include "include/message_data_fmt.h" +#include "soh/OTRGlobals.h" + +extern "C" { +#include "macros.h" +#include "functions.h" +#include "variables.h" +extern PlayState* gPlayState; +} + +static void ConfigurationChanged() { + COND_ID_HOOK(OnOpenText, 0x406B, IS_RANDO, [](u16 * textId, bool* loadFromMessageTable) { + if (gPlayState->sceneNum != SCENE_KAKARIKO_VILLAGE) { + return; + } + + std::string message; + uint8_t current = gSaveContext.triforcePiecesCollected; + uint8_t required = OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED); + + if (current < required) { + message = "The %yChristmas tree%w seems to be&missing some of %gits magic%w... Find all&ornaments to save %rChristmas%w!"; + } else { + message = "The tree's magic has been fully&restored. %gMerry %rChristmas%w!"; + } + + auto messageEntry = CustomMessage(message); + messageEntry.Format(); + messageEntry.LoadIntoFont(); + *loadFromMessageTable = false; + }); +} + +static void RegisterMod() { + // #region Leave this alone unless you know what you are doing + ConfigurationChanged(); + // #endregion + + GameInteractor::Instance->RegisterGameHook([](int16_t fileNum) { + ConfigurationChanged(); + }); +} + +static Holiday holiday([]() {}, RegisterMod); diff --git a/soh/soh/Enhancements/randomizer/option_descriptions.cpp b/soh/soh/Enhancements/randomizer/option_descriptions.cpp index 7de98b3d0..bd3f5dd77 100644 --- a/soh/soh/Enhancements/randomizer/option_descriptions.cpp +++ b/soh/soh/Enhancements/randomizer/option_descriptions.cpp @@ -109,14 +109,14 @@ void Settings::CreateOptionDescriptions() { "set to either MQ or Random here, you will have fewer MQ Dungeons than the number you " "set."; mOptionDescriptions[RSK_TRIFORCE_HUNT] = - "Pieces of the Triforce of Courage have been scattered across the world. Find them all to finish the game!\n\n" - "When the required amount of pieces have been found, the game is saved and Ganon's Boss key is given " + "Ornaments have been scattered across the world. Find them all to finish the game!\n\n" + "When the required amount of ornaments have been found, the game is saved and Ganon's Boss key is given " "to you when you load back into the game if you desire to beat Ganon afterwards.\n\n" "Keep in mind Ganon might not be logically beatable when \"All Locations Reachable\" is turned off."; mOptionDescriptions[RSK_TRIFORCE_HUNT_PIECES_TOTAL] = - "The amount of Triforce pieces that will be placed in the world. " - "Keep in mind seed generation can fail if more pieces are placed than there are junk items in the item pool."; - mOptionDescriptions[RSK_TRIFORCE_HUNT_PIECES_REQUIRED] = "The amount of Triforce pieces required to win the game."; + "The amount of Ornaments that will be placed in the world. " + "Keep in mind seed generation can fail if more ornaments are placed than there are junk items in the item pool."; + mOptionDescriptions[RSK_TRIFORCE_HUNT_PIECES_REQUIRED] = "The amount of Ornaments required to win the game."; mOptionDescriptions[RSK_SHUFFLE_DUNGEON_ENTRANCES] = "Shuffle the pool of dungeon entrances, including Bottom of the Well, Ice Cavern and Gerudo Training Grounds.\n" "\n" diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 0242c9eb8..d6a2bdfaa 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -64,7 +64,6 @@ const std::string Randomizer::hintMessageTableID = "RandomizerHints"; const std::string Randomizer::merchantMessageTableID = "RandomizerMerchants"; const std::string Randomizer::rupeeMessageTableID = "RandomizerRupees"; const std::string Randomizer::triforcePieceMessageTableID = "RandomizerTriforcePiece"; -const std::string Randomizer::christmasTreeMessageTableID = "RandomizerChristmasTree"; const std::string Randomizer::NaviRandoMessageTableID = "RandomizerNavi"; const std::string Randomizer::IceTrapRandoMessageTableID = "RandomizerIceTrap"; const std::string Randomizer::randoMiscHintsTableID = "RandomizerMiscHints"; @@ -2255,39 +2254,6 @@ CustomMessage Randomizer::GetTriforcePieceMessage() { messageEntry.Format(); return messageEntry; } -void CreateChristmasTreeMessages() { - CustomMessage ChristmasTreeMessages[2] = { - - { "The %yChristmas tree%w seems to be&missing some of %gits magic%w... Find all&ornaments to save %rChristmas%w!", - "The %yChristmas tree%w seems to be&missing some of %gits magic%w... Find all&ornaments to save %rChristmas%w!", - "The %yChristmas tree%w seems to be&missing some of %gits magic%w... Find all&ornaments to save %rChristmas%w!" }, - - { "The tree's magic has been fully&restored. %gMerry %rChristmas%w!", - "The tree's magic has been fully&restored. %gMerry %rChristmas%w!", - "The tree's magic has been fully&restored. %gMerry %rChristmas%w!" } - }; - CustomMessageManager* customMessageManager = CustomMessageManager::Instance; - customMessageManager->AddCustomMessageTable(Randomizer::christmasTreeMessageTableID); - for (unsigned int i = 0; i <= 1; i++) { - customMessageManager->CreateMessage(Randomizer::christmasTreeMessageTableID, i, ChristmasTreeMessages[i]); - } -} - -CustomMessage Randomizer::GetChristmasTreeMessage() { - // Item is only given after the textbox, so reflect that inside the textbox. - uint8_t current = gSaveContext.triforcePiecesCollected; - uint8_t required = OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED); - uint8_t messageIndex; - - if (current < required) { - messageIndex = 0; - } else { - messageIndex = 1; - } - - CustomMessage messageEntry = CustomMessageManager::Instance->RetrieveMessage(Randomizer::christmasTreeMessageTableID, messageIndex); - return messageEntry; -} void CreateNaviRandoMessages() { CustomMessage NaviMessages[NUM_NAVI_MESSAGES] = { @@ -3038,7 +3004,6 @@ void Randomizer::CreateCustomMessages() { CreateGetItemMessages(&getItemMessages); CreateRupeeMessages(); CreateTriforcePieceMessages(); - CreateChristmasTreeMessages(); CreateNaviRandoMessages(); CreateFireTempleGoronMessages(); } diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index 0ec13452a..4a84d6302 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -35,7 +35,6 @@ class Randomizer { static const std::string merchantMessageTableID; static const std::string rupeeMessageTableID; static const std::string triforcePieceMessageTableID; - static const std::string christmasTreeMessageTableID; static const std::string NaviRandoMessageTableID; static const std::string IceTrapRandoMessageTableID; static const std::string randoMiscHintsTableID; @@ -68,7 +67,6 @@ class Randomizer { static CustomMessage GetRupeeMessage(u16 rupeeTextId); static CustomMessage GetIceTrapMessage(); static CustomMessage GetTriforcePieceMessage(); - static CustomMessage GetChristmasTreeMessage(); }; #ifdef __cplusplus diff --git a/soh/soh/Enhancements/randomizer/settings.cpp b/soh/soh/Enhancements/randomizer/settings.cpp index 56c1a8111..62a8316be 100644 --- a/soh/soh/Enhancements/randomizer/settings.cpp +++ b/soh/soh/Enhancements/randomizer/settings.cpp @@ -139,9 +139,9 @@ void Settings::CreateOptions() { mOptions[RSK_BOMBCHUS_IN_LOGIC] = Option::Bool("Bombchus in Logic", CVAR_RANDOMIZER_SETTING("BombchusInLogic"), mOptionDescriptions[RSK_BOMBCHUS_IN_LOGIC]); mOptions[RSK_ENABLE_BOMBCHU_DROPS] = Option::U8("Bombchu Drops", {"No", "Yes"}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("EnableBombchuDrops"), mOptionDescriptions[RSK_ENABLE_BOMBCHU_DROPS], WidgetType::Combobox, RO_AMMO_DROPS_ON); // TODO: AmmoDrops and/or HeartDropRefill, combine with/separate Ammo Drops from Bombchu Drops? - mOptions[RSK_TRIFORCE_HUNT] = Option::Bool("Triforce Hunt", CVAR_RANDOMIZER_SETTING("TriforceHunt"), mOptionDescriptions[RSK_TRIFORCE_HUNT], IMFLAG_NONE); - mOptions[RSK_TRIFORCE_HUNT_PIECES_TOTAL] = Option::U8("Triforce Hunt Total Pieces", {NumOpts(1, 100)}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("TriforceHuntTotalPieces"), mOptionDescriptions[RSK_TRIFORCE_HUNT_PIECES_TOTAL], WidgetType::Slider, 29, false, IMFLAG_NONE); - mOptions[RSK_TRIFORCE_HUNT_PIECES_REQUIRED] = Option::U8("Triforce Hunt Required Pieces", {NumOpts(1, 100)}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("TriforceHuntRequiredPieces"), mOptionDescriptions[RSK_TRIFORCE_HUNT_PIECES_REQUIRED], WidgetType::Slider, 19); + mOptions[RSK_TRIFORCE_HUNT] = Option::Bool("Ornament Hunt", CVAR_RANDOMIZER_SETTING("TriforceHunt"), mOptionDescriptions[RSK_TRIFORCE_HUNT], IMFLAG_NONE); + mOptions[RSK_TRIFORCE_HUNT_PIECES_TOTAL] = Option::U8("Ornament Hunt Total Pieces", {NumOpts(1, 100)}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("TriforceHuntTotalPieces"), mOptionDescriptions[RSK_TRIFORCE_HUNT_PIECES_TOTAL], WidgetType::Slider, 29, false, IMFLAG_NONE); + mOptions[RSK_TRIFORCE_HUNT_PIECES_REQUIRED] = Option::U8("Ornament Hunt Required Pieces", {NumOpts(1, 100)}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("TriforceHuntRequiredPieces"), mOptionDescriptions[RSK_TRIFORCE_HUNT_PIECES_REQUIRED], WidgetType::Slider, 19); mOptions[RSK_MQ_DUNGEON_RANDOM] = Option::U8("MQ Dungeon Setting", {"None", "Set Number", "Random", "Selection Only"}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("MQDungeons"), mOptionDescriptions[RSK_MQ_DUNGEON_RANDOM], WidgetType::Combobox, RO_MQ_DUNGEONS_NONE, true, IMFLAG_NONE); mOptions[RSK_MQ_DUNGEON_COUNT] = Option::U8("MQ Dungeon Count", {NumOpts(0, 12)}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("MQDungeonCount"), "", WidgetType::Slider, 12, true, IMFLAG_NONE); mOptions[RSK_MQ_DUNGEON_SET] = Option::Bool("Set Dungeon Quests", {"Off", "On"}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("MQDungeonsSelection"), mOptionDescriptions[RSK_MQ_DUNGEON_SET], WidgetType::Checkbox, false, false, IMFLAG_NONE); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 53367935e..7f58f7e8c 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -2557,9 +2557,7 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) { bool nonBeanMerchants = ctx->GetOption(RSK_SHUFFLE_MERCHANTS).Is(RO_SHUFFLE_MERCHANTS_ALL_BUT_BEANS) || ctx->GetOption(RSK_SHUFFLE_MERCHANTS).Is(RO_SHUFFLE_MERCHANTS_ALL); Player* player = GET_PLAYER(play); - if (textId == 0x406B && play->sceneNum == SCENE_KAKARIKO_VILLAGE) { - messageEntry = Randomizer::GetChristmasTreeMessage(); - } else if (textId == TEXT_RANDOMIZER_CUSTOM_ITEM) { + if (textId == TEXT_RANDOMIZER_CUSTOM_ITEM) { if (player->getItemEntry.getItemId == RG_ICE_TRAP) { messageEntry = Randomizer::GetIceTrapMessage(); } else if (player->getItemEntry.getItemId == RG_TRIFORCE_PIECE) {