From 4669235f62bf387062b63f5cd8253d18784c31b9 Mon Sep 17 00:00:00 2001 From: earthcrafterman Date: Sun, 29 May 2022 11:46:47 -0400 Subject: [PATCH] Spammable kaepora (#354) * Players can now spam their way through Kaepora Gaebora dialogue * Turned the Owl Text Inversion into a toggle Instead of replacing the Kokiri Owl Text at boot, a new Text Entry is added for it * Attempt to make it compile on Linux * Added multilingual support * Commented the code to clear up confusion --- libultraship/libultraship/SohImGuiImpl.cpp | 3 +- soh/soh/z_message_OTR.cpp | 43 ++++++++++++++++++- soh/src/code/z_message_PAL.c | 13 ++++-- soh/src/overlays/actors/ovl_En_Owl/z_en_owl.c | 32 ++++++++++---- 4 files changed, 78 insertions(+), 13 deletions(-) diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index 5ea017173..f9f5d9b7b 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -723,9 +723,10 @@ namespace SohImGui { Tooltip("Allows equiping the tunic and boots to c-buttons"); EnhancementCheckbox("MM Bunny Hood", "gMMBunnyHood"); Tooltip("Wearing the Bunny Hood grants a speed increase like in Majora's Mask"); + EnhancementCheckbox("Better Owl", "gBetterOwl"); + Tooltip("The default response to Kaepora Gaebora is always that you understood what he said"); EnhancementCheckbox("Disable Navi Call Audio", "gDisableNaviCallAudio"); Tooltip("Disables the voice audio when Navi calls you"); - ImGui::EndMenu(); } diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index ac1f013c2..8c1d26a75 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -19,9 +19,50 @@ MessageTableEntry* OTRMessage_LoadTable(const char* filePath, bool isNES) { if (file == nullptr) return nullptr; - MessageTableEntry* table = (MessageTableEntry*)malloc(sizeof(MessageTableEntry) * file->messages.size()); + // Allocate room for an additional message + MessageTableEntry* table = (MessageTableEntry*)malloc(sizeof(MessageTableEntry) * (file->messages.size() + 1)); for (int i = 0; i < file->messages.size(); i++) { + // Look for Owl Text + if (file->messages[i].id == 0x2066) { + // Create a new message based on the Owl Text + char* kaeporaPatch = (char*)malloc(sizeof(char) * file->messages[i].msg.size()); + file->messages[i].msg.copy(kaeporaPatch, file->messages[i].msg.size(), 0); + + // Swap the order of yes and no in this new message + if (filePath == "text/nes_message_data_static/nes_message_data_static") { + kaeporaPatch[26] = 'Y'; + kaeporaPatch[27] = 'e'; + kaeporaPatch[28] = 's'; + kaeporaPatch[29] = 1; + kaeporaPatch[30] = 'N'; + kaeporaPatch[31] = 'o'; + } else if (filePath == "text/ger_message_data_static/ger_message_data_static") { + kaeporaPatch[30] = 'J'; + kaeporaPatch[31] = 'a'; + kaeporaPatch[32] = '!'; + kaeporaPatch[33] = 1; + kaeporaPatch[34] = 'N'; + kaeporaPatch[35] = 'e'; + kaeporaPatch[36] = 'i'; + kaeporaPatch[37] = 'n'; + } else { + kaeporaPatch[26] = 'O'; + kaeporaPatch[27] = 'u'; + kaeporaPatch[28] = 'i'; + kaeporaPatch[29] = 1; + kaeporaPatch[30] = 'N'; + kaeporaPatch[31] = 'o'; + kaeporaPatch[32] = 'n'; + } + + // load data into message + table[file->messages.size()].textId = 0x71B3; + table[file->messages.size()].typePos = (file->messages[i].textboxType << 4) | file->messages[i].textboxYPos; + table[file->messages.size()].segment = kaeporaPatch; + table[file->messages.size()].msgSize = file->messages[i].msg.size(); + } + table[i].textId = file->messages[i].id; table[i].typePos = (file->messages[i].textboxType << 4) | file->messages[i].textboxYPos; table[i].segment = file->messages[i].msg.c_str(); diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 33bc9a95e..84cf20e71 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -272,6 +272,13 @@ void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { const char** languageSegmentTable; Font* font; const char* seg; + u16 bufferId = textId; + // Use the better owl message if better owl is enabled + if (CVar_GetS32("gBetterOwl", 0) != 0 && (bufferId == 0x2066 || bufferId == 0x607B || + bufferId == 0x10C2 || bufferId == 0x10C6 || bufferId == 0x206A)) + { + bufferId = 0x71B3; + } if (gSaveContext.language == LANGUAGE_GER) messageTableEntry = sGerMessageEntryTablePtr; @@ -287,7 +294,7 @@ void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { while (messageTableEntry->textId != 0xFFFF) { font = &globalCtx->msgCtx.font; - if (messageTableEntry->textId == textId) { + if (messageTableEntry->textId == bufferId) { foundSeg = messageTableEntry->segment; font->charTexBuf[0] = messageTableEntry->typePos; @@ -298,14 +305,14 @@ void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { // "Message found!!!" osSyncPrintf(" メッセージが,見つかった!!! = %x " "(data=%x) (data0=%x) (data1=%x) (data2=%x) (data3=%x)\n", - textId, font->msgOffset, font->msgLength, foundSeg, seg, nextSeg); + bufferId, font->msgOffset, font->msgLength, foundSeg, seg, nextSeg); return; } messageTableEntry++; } // "Message not found!!!" - osSyncPrintf(" メッセージが,見つからなかった!!! = %x\n", textId); + osSyncPrintf(" メッセージが,見つからなかった!!! = %x\n", bufferId); font = &globalCtx->msgCtx.font; messageTableEntry = sNesMessageEntryTablePtr; diff --git a/soh/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/soh/src/overlays/actors/ovl_En_Owl/z_en_owl.c index 054f00b4d..aef838499 100644 --- a/soh/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/soh/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -366,7 +366,9 @@ void func_80ACA7E0(EnOwl* this, GlobalContext* globalCtx) { void EnOwl_ConfirmKokiriMessage(EnOwl* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + // swap the order of the responses if better owl is enabled + uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); + switch (index) { case OWL_REPEAT: Message_ContinueTextbox(globalCtx, 0x2065); break; @@ -393,7 +395,9 @@ void EnOwl_WaitOutsideKokiri(EnOwl* this, GlobalContext* globalCtx) { void func_80ACA998(EnOwl* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + // swap the order of the responses if better owl is enabled + uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); + switch (index) { case OWL_REPEAT: Message_ContinueTextbox(globalCtx, 0x2069); this->actionFunc = func_80ACAA54; @@ -437,7 +441,9 @@ void EnOwl_WaitHyruleCastle(EnOwl* this, GlobalContext* globalCtx) { void func_80ACAB88(EnOwl* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + // swap the order of the responses if better owl is enabled + uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); + switch (index) { case OWL_REPEAT: // obtained zelda's letter if (gSaveContext.eventChkInf[4] & 1) { @@ -478,7 +484,9 @@ void EnOwl_WaitKakariko(EnOwl* this, GlobalContext* globalCtx) { void func_80ACAD34(EnOwl* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + // swap the order of the responses if better owl is enabled + uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); + switch (index) { case OWL_REPEAT: Message_ContinueTextbox(globalCtx, 0x206F); this->actionFunc = func_80ACADF0; @@ -514,7 +522,9 @@ void EnOwl_WaitGerudo(EnOwl* this, GlobalContext* globalCtx) { void func_80ACAEB8(EnOwl* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + // swap the order of the responses if better owl is enabled + uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); + switch (index) { case OWL_REPEAT: Message_ContinueTextbox(globalCtx, 0x2071); this->actionFunc = func_80ACAF74; @@ -634,7 +644,9 @@ void EnOwl_WaitDeathMountainShortcut(EnOwl* this, GlobalContext* globalCtx) { void func_80ACB344(EnOwl* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + // swap the order of the responses if better owl is enabled + uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); + switch (index) { case OWL_REPEAT: Message_ContinueTextbox(globalCtx, 0x607A); break; @@ -657,7 +669,9 @@ void func_80ACB3E0(EnOwl* this, GlobalContext* globalCtx) { void func_80ACB440(EnOwl* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + // swap the order of the responses if better owl is enabled + uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); + switch (index) { case OWL_REPEAT: Message_ContinueTextbox(globalCtx, 0x10C1); this->actionFunc = func_80ACB4FC; @@ -692,7 +706,9 @@ void EnOwl_WaitLWPreSaria(EnOwl* this, GlobalContext* globalCtx) { void func_80ACB5C4(EnOwl* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE && Message_ShouldAdvance(globalCtx)) { - switch (globalCtx->msgCtx.choiceIndex) { + // swap the order of the responses if better owl is enabled + uint8_t index = CVar_GetS32("gBetterOwl", 0) == 0 ? globalCtx->msgCtx.choiceIndex : (1 - globalCtx->msgCtx.choiceIndex); + switch (index) { case OWL_REPEAT: Message_ContinueTextbox(globalCtx, 0x10C5); this->actionFunc = func_80ACB680;