From 6399eb2d8997c2b85e09e505237a3fe88e4e8976 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Thu, 27 Feb 2025 17:06:07 -0500 Subject: [PATCH] Port Better Bombchu Shopping --- .../Items/BetterBombchuShopping.cpp | 39 +++++++++++++++++++ soh/soh/OTRGlobals.cpp | 5 +-- soh/soh/z_message_OTR.cpp | 14 ------- 3 files changed, 40 insertions(+), 18 deletions(-) create mode 100644 soh/soh/Enhancements/Items/BetterBombchuShopping.cpp diff --git a/soh/soh/Enhancements/Items/BetterBombchuShopping.cpp b/soh/soh/Enhancements/Items/BetterBombchuShopping.cpp new file mode 100644 index 000000000..918b5bba2 --- /dev/null +++ b/soh/soh/Enhancements/Items/BetterBombchuShopping.cpp @@ -0,0 +1,39 @@ +#include + +extern "C" { +#include +} + +//RANDOTODO: Port the rest of the behavior associated with this option here. + +void BuildShopDescMessage(uint16_t* textId, bool* loadFromMessageTable) { + CustomMessage msg = CustomMessage( + "\x08%rBombchu 10 pieces 99 Rupees&%wThis looks like a toy mouse, but&it's actually a " + "self-propelled time&bomb!\x09\x0A", + "\x08%rKrabbelmine 10 Stück 99 Rubine&%wDas ist eine praktische Zeitbombe,&die Du als " + "Distanzwaffe&einsetzen kannst!\x09\x0A", + "\x08%rMissile 10 unités 99 Rubis&%wProfilée comme une souris&mécanique, cette arme est " + "&destructrice!!!\x09\x0A" + ); + msg.AutoFormat(); + msg.LoadIntoFont(); + *loadFromMessageTable = false; +} + +void BuildShopPromptMessage(uint16_t* textId, bool* loadFromMessageTable) { + CustomMessage msg = CustomMessage( + "\x08Bombchu 10 pieces 99 Rupees\x09&&\x1B%gBuy&Don't buy%w", + "\x08Krabbelmine 10 Stück 99 Rubine\x09&&\x1B%gKaufen!&Nicht kaufen!%w", + "\x08Missiles 10 unités 99 Rubis\x09&&\x1B%gAcheter&Ne pas acheter%w" + ); + msg.AutoFormat(); + msg.LoadIntoFont(); + *loadFromMessageTable = false; +} + +void BetterBombchuShopping_Register() { + COND_ID_HOOK(OnOpenText, TEXT_BUY_BOMBCHUS_10_DESC, IS_RANDO || CVarGetInteger(CVAR_ENHANCEMENT("BetterBombchuShopping"), 0), BuildShopDescMessage); + COND_ID_HOOK(OnOpenText, TEXT_BUY_BOMBCHUS_10_PROMPT, IS_RANDO || CVarGetInteger(CVAR_ENHANCEMENT("BetterBombchuShopping"), 0), BuildShopPromptMessage); +} + +RegisterShipInitFunc initFunc(BetterBombchuShopping_Register, { "IS_RANDO", CVAR_ENHANCEMENT("BetterBombchuShopping") }); \ No newline at end of file diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 014d675a7..784291c26 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -2138,10 +2138,7 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) { const int maxBufferSize = sizeof(font->msgBuf); CustomMessage messageEntry; s16 actorParams = 0; - if ((IS_RANDO || CVarGetInteger(CVAR_ENHANCEMENT("BetterBombchuShopping"), 0)) && - (textId == TEXT_BUY_BOMBCHUS_10_DESC || textId == TEXT_BUY_BOMBCHUS_10_PROMPT)) { - messageEntry = CustomMessageManager::Instance->RetrieveMessage(customMessageTableID, textId, MF_FORMATTED); - } else if (textId == TEXT_MARKET_GUARD_NIGHT && CVarGetInteger(CVAR_ENHANCEMENT("MarketSneak"), 0) && play->sceneNum == SCENE_MARKET_ENTRANCE_NIGHT) { + if (textId == TEXT_MARKET_GUARD_NIGHT && CVarGetInteger(CVAR_ENHANCEMENT("MarketSneak"), 0) && play->sceneNum == SCENE_MARKET_ENTRANCE_NIGHT) { messageEntry = CustomMessageManager::Instance->RetrieveMessage(customMessageTableID, TEXT_MARKET_GUARD_NIGHT, MF_FORMATTED); } if (textId == TEXT_FISHERMAN_LEAVE && CVarGetInteger(CVAR_ENHANCEMENT("QuitFishingAtDoor"), 0)) { diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index b8d211ac4..b674ed86f 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -113,20 +113,6 @@ extern "C" void OTRMessage_Init() { } CustomMessageManager::Instance->AddCustomMessageTable(customMessageTableID); - CustomMessageManager::Instance->CreateMessage( - customMessageTableID, TEXT_BUY_BOMBCHUS_10_DESC, - CustomMessage("\x08%rBombchu 10 pieces 99 Rupees&%wThis looks like a toy mouse, but&it's actually a " - "self-propelled time&bomb!\x09\x0A", - "\x08%rKrabbelmine 10 Stück 99 Rubine&%wDas ist eine praktische Zeitbombe,&die Du als " - "Distanzwaffe&einsetzen kannst!\x09\x0A", - "\x08%rMissile 10 unités 99 Rubis&%wProfilée comme une souris&mécanique, cette arme est " - "&destructrice!!!\x09\x0A")); - CustomMessageManager::Instance->CreateMessage( - customMessageTableID, TEXT_BUY_BOMBCHUS_10_PROMPT, - CustomMessage("\x08" - "Bombchu 10 pieces 99 Rupees\x09&&\x1B%gBuy&Don't buy%w", - "\x08Krabbelmine 10 Stück 99 Rubine\x09&&\x1B%gKaufen!&Nicht kaufen!%w", - "\x08Missiles 10 unités 99 Rubis\x09&&\x1B%gAcheter&Ne pas acheter%w")); CustomMessageManager::Instance->CreateMessage( customMessageTableID, TEXT_MARKET_GUARD_NIGHT, CustomMessage("You look bored. Wanna go out for a&walk?\x1B&%gYes&No%w",