From f282e25c169b79a377eba4dce459686b97b85c57 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Sun, 4 Sep 2022 13:53:59 -0500 Subject: [PATCH] Move all merchant messages to be generated on file load --- .../Enhancements/randomizer/randomizer.cpp | 79 +++++++++---------- soh/soh/Enhancements/randomizer/randomizer.h | 2 +- soh/soh/OTRGlobals.cpp | 4 +- soh/soh/OTRGlobals.h | 2 +- .../ovl_file_choose/z_file_choose.c | 4 +- 5 files changed, 42 insertions(+), 49 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index b3df105f7..746d0d875 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -787,14 +787,46 @@ std::unordered_map randomizerGetToEnGirlShopItem = { { RG_BUY_RED_POTION_50, 0x31 }, }; -void Randomizer::LoadShopMessages(const char* spoilerFileName) { +void Randomizer::LoadMerchantMessages(const char* spoilerFileName) { if (strcmp(spoilerFileName, "") != 0) { ParseHintLocationsFile(spoilerFileName); } - // TODO: Remove these after we make sure it's fine that they aren't here - // CustomMessageManager::Instance->ClearMessageTable(Randomizer::merchantMessageTableID); - // CustomMessageManager::Instance->AddCustomMessageTable(Randomizer::merchantMessageTableID); + CustomMessageManager::Instance->ClearMessageTable(Randomizer::merchantMessageTableID); + CustomMessageManager::Instance->AddCustomMessageTable(Randomizer::merchantMessageTableID); + CustomMessageManager::Instance->CreateMessage(Randomizer::merchantMessageTableID, 0, + { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, + "\x12\x38\x82\All right! You win! In return for&sparing me, I will give you a&%gmysterious item%w!&Please, take it!\x07\x10\xA3", + "\x12\x38\x82\In Ordnung! Du gewinnst! Im Austausch&dafür, dass du mich verschont hast,&werde ich dir einen %gmysteriösen&Gegenstand%w geben! Bitte nimm ihn!\x07\x10\xA3", + "\x12\x38\x82\D'accord! Vous avez gagné! En échange&de m'épargner, je vous donnerai un &%gobjet mystérieux%w! S'il vous plaît,&prenez-le!\x07\x10\xA3", + }); + + // Currently these are generated at runtime, one for each price between 0-95. We're soon going to migrate this + // to being generated at save load, with only messages specific to each scrub. + for (u32 price = 5; price <= 95; price += 5) { + CustomMessageManager::Instance->CreateMessage(Randomizer::merchantMessageTableID, price, + { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, + "\x12\x38\x82\All right! You win! In return for&sparing me, I will sell you a&%gmysterious item%w!&%r" + + std::to_string(price) + " Rupees%w it is!\x07\x10\xA3", + // RANDTODO: Translate the below string to German. + "\x12\x38\x82\All right! You win! In return for&sparing me, I will sell you a&%gmysterious item%w!&%r" + + std::to_string(price) + " Rupees%w it is!\x07\x10\xA3", + "\x12\x38\x82J'abandonne! Tu veux bien m'acheter&un %gobjet mystérieux%w?&Ça fera %r" + + std::to_string(price) + " Rubis%w!\x07\x10\xA3" + }); + } + CustomMessageManager::Instance->CreateMessage( + Randomizer::merchantMessageTableID, TEXT_BEAN_SALESMAN, + { + TEXTBOX_TYPE_BLACK, + TEXTBOX_POS_BOTTOM, + "I tried to be a %rmagic bean%w salesman,&but it turns out my marketing skills&weren't worth " + "beans!^Anyway, want to buy my&%gmysterious item%w for 60 Rupees?\x1B&%gYes&No%w", + "Möchten Sie einen geheimnisvollen&Gegenstand für 60 Rubine?\x1B&%gJa&Nein%w", + "J'ai essayé d'être un vendeur de&%rharicots magiques%w, mais j'étais&mauvais au niveau du marketing et&ça " + "me courait sur le haricot...^Enfin bref, ça te dirait de m'acheter un&" + "%gobjet mystérieux%w pour 60 Rubis?\x1B&%gOui&Non%w", + }); // Make an inverse of std::unordered_map SpoilerfileGetNameToEnum // so that we can get the name of the item from the RandomizerCheck @@ -5179,44 +5211,6 @@ void CreateGetItemMessages(std::vector messageEntries) { } } -// Currently these are generated at runtime, one for each price between 0-95. We're soon going to migrate this -// to being generated at save load, with only messages specific to each scrub. -void CreateMerchantMessages() { - CustomMessageManager* customMessageManager = CustomMessageManager::Instance; - customMessageManager->AddCustomMessageTable(Randomizer::merchantMessageTableID); - customMessageManager->CreateMessage(Randomizer::merchantMessageTableID, 0, - { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, - "\x12\x38\x82\All right! You win! In return for&sparing me, I will give you a&%gmysterious item%w!&Please, take it!\x07\x10\xA3", - "\x12\x38\x82\In Ordnung! Du gewinnst! Im Austausch&dafür, dass du mich verschont hast,&werde ich dir einen %gmysteriösen&Gegenstand%w geben! Bitte nimm ihn!\x07\x10\xA3", - "\x12\x38\x82\D'accord! Vous avez gagné! En échange&de m'épargner, je vous donnerai un &%gobjet mystérieux%w! S'il vous plaît,&prenez-le!\x07\x10\xA3", - }); - - for (u32 price = 5; price <= 95; price += 5) { - customMessageManager->CreateMessage(Randomizer::merchantMessageTableID, price, - { TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM, - "\x12\x38\x82\All right! You win! In return for&sparing me, I will sell you a&%gmysterious item%w!&%r" + - std::to_string(price) + " Rupees%w it is!\x07\x10\xA3", - // RANDTODO: Translate the below string to German. - "\x12\x38\x82\All right! You win! In return for&sparing me, I will sell you a&%gmysterious item%w!&%r" + - std::to_string(price) + " Rupees%w it is!\x07\x10\xA3", - "\x12\x38\x82J'abandonne! Tu veux bien m'acheter&un %gobjet mystérieux%w?&Ça fera %r" + - std::to_string(price) + " Rubis%w!\x07\x10\xA3" - }); - } - customMessageManager->CreateMessage( - Randomizer::merchantMessageTableID, TEXT_BEAN_SALESMAN, - { - TEXTBOX_TYPE_BLACK, - TEXTBOX_POS_BOTTOM, - "I tried to be a %rmagic bean%w salesman,&but it turns out my marketing skills&weren't worth " - "beans!^Anyway, want to buy my&%gmysterious item%w for 60 Rupees?\x1B&%gYes&No%w", - "Möchten Sie einen geheimnisvollen&Gegenstand für 60 Rubine?\x1B&%gJa&Nein%w", - "J'ai essayé d'être un vendeur de&%rharicots magiques%w, mais j'étais&mauvais au niveau du marketing et&ça " - "me courait sur le haricot...^Enfin bref, ça te dirait de m'acheter un&" - "%gobjet mystérieux%w pour 60 Rubis?\x1B&%gOui&Non%w", - }); -} - void CreateRupeeMessages() { CustomMessageManager* customMessageManager = CustomMessageManager::Instance; customMessageManager->AddCustomMessageTable(Randomizer::rupeeMessageTableID); @@ -5490,7 +5484,6 @@ void Randomizer::CreateCustomMessages() { "Vous avez un %rPack de&haricots magiques%w ! Trouvez&un endroit convenable pour un&jardin et plantez-les.^Ensuite, attendez quelque&chose d'amusant doit arriver !") }; CreateGetItemMessages(getItemMessages); - CreateMerchantMessages(); CreateRupeeMessages(); CreateNaviRandoMessages(); } diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index cd7d04c8a..4a9106fa4 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -44,7 +44,7 @@ class Randomizer { bool SpoilerFileExists(const char* spoilerFileName); void LoadRandomizerSettings(const char* spoilerFileName); void LoadHintLocations(const char* spoilerFileName); - void LoadShopMessages(const char* spoilerFileName); + void LoadMerchantMessages(const char* spoilerFileName); void LoadItemLocations(const char* spoilerFileName, bool silent); void LoadRequiredTrials(const char* spoilerFileName); bool IsTrialRequired(RandomizerInf trial); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 272c44fc2..4def2de6c 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1567,8 +1567,8 @@ extern "C" void Randomizer_LoadHintLocations(const char* spoilerFileName) { OTRGlobals::Instance->gRandomizer->LoadHintLocations(spoilerFileName); } -extern "C" void Randomizer_LoadShopMessages(const char* spoilerFileName) { - OTRGlobals::Instance->gRandomizer->LoadShopMessages(spoilerFileName); +extern "C" void Randomizer_LoadMerchantMessages(const char* spoilerFileName) { + OTRGlobals::Instance->gRandomizer->LoadMerchantMessages(spoilerFileName); } extern "C" void Randomizer_LoadRequiredTrials(const char* spoilerFileName) { diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index f9e0ce6da..34f612aa0 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -100,7 +100,7 @@ RandomizerCheck Randomizer_GetCheckFromActor(s16 actorId, s16 sceneNum, s16 acto ScrubIdentity Randomizer_IdentifyScrub(s32 sceneNum, s32 actorParams, s32 respawnData); ShopItemIdentity Randomizer_IdentifyShopItem(s32 sceneNum, s32 actorParams); void Randomizer_LoadHintLocations(const char* spoilerFileName); -void Randomizer_LoadShopMessages(const char* spoilerFileName); +void Randomizer_LoadMerchantMessages(const char* spoilerFileName); void Randomizer_LoadRequiredTrials(const char* spoilerFileName); void Randomizer_LoadItemLocations(const char* spoilerFileName, bool silent); bool Randomizer_IsTrialRequired(RandomizerInf trial); diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 28843e0e1..33f757eed 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -435,7 +435,7 @@ void FileChoose_UpdateMainMenu(GameState* thisx) { Randomizer_LoadHintLocations(fileLoc); Randomizer_LoadRequiredTrials(fileLoc); Randomizer_LoadItemLocations(fileLoc, silent); - Randomizer_LoadShopMessages(fileLoc); + Randomizer_LoadMerchantMessages(fileLoc); fileSelectSpoilerFileLoaded = true; } @@ -1730,7 +1730,7 @@ void FileChoose_LoadGame(GameState* thisx) { Randomizer_LoadSettings(""); Randomizer_LoadHintLocations(""); - Randomizer_LoadShopMessages(""); + Randomizer_LoadMerchantMessages(""); Randomizer_LoadItemLocations("", true); gSaveContext.respawn[0].entranceIndex = -1;