From 2ff9fcc8fa76bfc7e69646d2341e649f7e2f0ca2 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 | 1 - soh/soh/Enhancements/randomizer/randomizer.h | 1 - soh/soh/Enhancements/randomizer/settings.cpp | 6 +-- soh/soh/OTRGlobals.cpp | 4 +- 6 files changed, 58 insertions(+), 13 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 c544d3b29..b3ab8112b 100644 --- a/soh/soh/Enhancements/randomizer/option_descriptions.cpp +++ b/soh/soh/Enhancements/randomizer/option_descriptions.cpp @@ -124,14 +124,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 Ground.\n" "\n" diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index c06cb4ca8..f29b726a9 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -5939,7 +5939,6 @@ void Randomizer::CreateCustomMessages() { CreateGetItemMessages(getItemMessages); CreateRupeeMessages(); CreateTriforcePieceMessages(); - CreateChristmasTreeMessages(); CreateNaviRandoMessages(); CreateFireTempleGoronMessages(); CreateArchipelagoItemMessage(); diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index 636a806fb..19a21fe18 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; diff --git a/soh/soh/Enhancements/randomizer/settings.cpp b/soh/soh/Enhancements/randomizer/settings.cpp index 9055f6250..ec46209fe 100644 --- a/soh/soh/Enhancements/randomizer/settings.cpp +++ b/soh/soh/Enhancements/randomizer/settings.cpp @@ -160,9 +160,9 @@ void Settings::CreateOptions() { OPT_BOOL(RSK_BOMBCHU_BAG, "Bombchu Bag", CVAR_RANDOMIZER_SETTING("BombchuBag"), mOptionDescriptions[RSK_BOMBCHU_BAG]); OPT_U8(RSK_ENABLE_BOMBCHU_DROPS, "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? - OPT_BOOL(RSK_TRIFORCE_HUNT, "Triforce Hunt", CVAR_RANDOMIZER_SETTING("TriforceHunt"), mOptionDescriptions[RSK_TRIFORCE_HUNT], IMFLAG_NONE); - OPT_U8(RSK_TRIFORCE_HUNT_PIECES_TOTAL, "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); - OPT_U8(RSK_TRIFORCE_HUNT_PIECES_REQUIRED, "Triforce Hunt Required Pieces", {NumOpts(1, 100)}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("TriforceHuntRequiredPieces"), mOptionDescriptions[RSK_TRIFORCE_HUNT_PIECES_REQUIRED], WidgetType::Slider, 19); + OPT_BOOL(RSK_TRIFORCE_HUNT, "Ornament Hunt", CVAR_RANDOMIZER_SETTING("TriforceHunt"), mOptionDescriptions[RSK_TRIFORCE_HUNT], IMFLAG_NONE); + OPT_U8(RSK_TRIFORCE_HUNT_PIECES_TOTAL, "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); + OPT_U8(RSK_TRIFORCE_HUNT_PIECES_REQUIRED, "Ornament Hunt Required Pieces", {NumOpts(1, 100)}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("TriforceHuntRequiredPieces"), mOptionDescriptions[RSK_TRIFORCE_HUNT_PIECES_REQUIRED], WidgetType::Slider, 19); OPT_U8(RSK_MQ_DUNGEON_RANDOM, "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); OPT_U8(RSK_MQ_DUNGEON_COUNT, "MQ Dungeon Count", {NumOpts(0, 12)}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("MQDungeonCount"), "", WidgetType::Slider, 12, true, IMFLAG_NONE); OPT_BOOL(RSK_MQ_DUNGEON_SET, "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 6a20e893a..58d820352 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -2439,9 +2439,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) {