From 7144d1a32131aa2c0e9daf21a438bc5ca1ee77ea Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Sun, 7 Aug 2022 15:26:03 -0700 Subject: [PATCH 1/5] First test of Rando-specific Navi tips First test of this experiment --- soh/src/code/z_message_PAL.c | 3 + soh/src/code/z_message_RandoNaviTips.c | 58 +++++++++++++++++++ soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c | 4 +- .../actors/ovl_player_actor/z_player.c | 4 ++ 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 soh/src/code/z_message_RandoNaviTips.c diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 72058206f1..0d0da60517 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1750,6 +1750,9 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { break; } msgCtx->msgLength = font->msgLength = strlen(font->msgBuf); + } else if (textId == 0x0140 && gSaveContext.n64ddFlag) { //888888888 + RandoNaviTip(globalCtx); + msgCtx->msgLength = font->msgLength = strlen(font->msgBuf); } else { msgCtx->msgLength = font->msgLength; char* src = (uintptr_t)font->msgOffset; diff --git a/soh/src/code/z_message_RandoNaviTips.c b/soh/src/code/z_message_RandoNaviTips.c new file mode 100644 index 0000000000..6f380c4674 --- /dev/null +++ b/soh/src/code/z_message_RandoNaviTips.c @@ -0,0 +1,58 @@ +#include "global.h" +#include "message_data_static.h" +#include "vt.h" + +#include + +void RandoNaviTip(GlobalContext* globalCtx) { + u16 randNaviTip = rand() % 3; + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + + if (randNaviTip == 0) { + switch (gSaveContext.language) { + case LANGUAGE_FRA: + strcpy(font->msgBuf, "\x08French tip about playing rando!\x02"); + break; + case LANGUAGE_GER: + strcpy(font->msgBuf, "\x08German tip about playing rando!\x02"); + break; + case LANGUAGE_ENG: + default: + strcpy(font->msgBuf, "\x08Missing a small key in a dungeon?\x01Maybe the\x05\x43 " + "boss\x05\x40 has it!\x02"); + break; + } + } + if (randNaviTip == 1) { + switch (gSaveContext.language) { + case LANGUAGE_FRA: + strcpy(font->msgBuf, "\x08French tip about playing rando!\x02"); + break; + case LANGUAGE_GER: + strcpy(font->msgBuf, "\x08German tip about playing rando!\x02"); + break; + case LANGUAGE_ENG: + default: + strcpy(font->msgBuf, "\x08Sometimes you can use the \x05\x41Megaton\x01Hammer \x05\x40" + "instead of bombs!\x02"); + break; + } + } + if (randNaviTip == 2) { + switch (gSaveContext.language) { + case LANGUAGE_FRA: + strcpy(font->msgBuf, "\x08French tip about playing rando!\x02"); + break; + case LANGUAGE_GER: + strcpy(font->msgBuf, "\x08German tip about playing rando!\x02"); + break; + case LANGUAGE_ENG: + default: + strcpy(font->msgBuf, + "\x08There are three\x05\x42 business scrubs\x05\x40 in\x01" + "Hyrule who sell \x05\x44mysterious items\x05\x40. Do\x01you know where they are?\x02"); + break; + } + } +} \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c index ff9e37e524..307c81f7f7 100644 --- a/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1382,7 +1382,7 @@ void func_80A053F0(Actor* thisx, GlobalContext* globalCtx) { if (player->naviTextId == 0) { if (player->unk_664 == NULL) { - if (((gSaveContext.naviTimer >= 600) && (gSaveContext.naviTimer <= 3000)) || (nREG(89) != 0)) { + if (((gSaveContext.naviTimer >= 40) && (gSaveContext.naviTimer <= 3000)) || (nREG(89) != 0)) { player->naviTextId = ElfMessage_GetCUpText(globalCtx); if (player->naviTextId == 0x15F) { @@ -1401,7 +1401,7 @@ void func_80A053F0(Actor* thisx, GlobalContext* globalCtx) { if (thisx->textId == ElfMessage_GetCUpText(globalCtx)) { this->fairyFlags |= 0x80; - gSaveContext.naviTimer = 3001; + gSaveContext.naviTimer = 10; } this->fairyFlags |= 0x10; diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index c3df51636f..61f013d4c7 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -15286,5 +15286,9 @@ void func_80853148(GlobalContext* globalCtx, Actor* actor) { if ((this->naviActor == this->targetActor) && ((this->targetActor->textId & 0xFF00) != 0x200)) { this->naviActor->flags |= ACTOR_FLAG_8; func_80835EA4(globalCtx, 0xB); + + if (actor->textId >= 0x0140 && actor->textId <= 0x015F && gSaveContext.n64ddFlag) { + Message_StartTextbox(globalCtx, 0x0140, NULL); + } } } From 6e8b45d1293ab7bfd357ceb86e7642354b76e60b Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Sun, 7 Aug 2022 15:50:53 -0700 Subject: [PATCH 2/5] Fix text colours (Navi text is always light blue) Navi text should always be \x44 --- soh/src/code/z_message_RandoNaviTips.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/soh/src/code/z_message_RandoNaviTips.c b/soh/src/code/z_message_RandoNaviTips.c index 6f380c4674..edb1b7f9b5 100644 --- a/soh/src/code/z_message_RandoNaviTips.c +++ b/soh/src/code/z_message_RandoNaviTips.c @@ -12,29 +12,29 @@ void RandoNaviTip(GlobalContext* globalCtx) { if (randNaviTip == 0) { switch (gSaveContext.language) { case LANGUAGE_FRA: - strcpy(font->msgBuf, "\x08French tip about playing rando!\x02"); + strcpy(font->msgBuf, "\x08\x05\x44""French tip about playing rando!\x02"); break; case LANGUAGE_GER: - strcpy(font->msgBuf, "\x08German tip about playing rando!\x02"); + strcpy(font->msgBuf, "\x08\x05\x44German tip about playing rando!\x02"); break; case LANGUAGE_ENG: default: - strcpy(font->msgBuf, "\x08Missing a small key in a dungeon?\x01Maybe the\x05\x43 " - "boss\x05\x40 has it!\x02"); + strcpy(font->msgBuf, "\x08\x05\x44Missing a small key in a dungeon?\x01Maybe the\x05\x41 " + "boss\x05\x44 has it!\x02"); break; } } if (randNaviTip == 1) { switch (gSaveContext.language) { case LANGUAGE_FRA: - strcpy(font->msgBuf, "\x08French tip about playing rando!\x02"); + strcpy(font->msgBuf, "\x08\x05\x44""French tip about playing rando!\x02"); break; case LANGUAGE_GER: strcpy(font->msgBuf, "\x08German tip about playing rando!\x02"); break; case LANGUAGE_ENG: default: - strcpy(font->msgBuf, "\x08Sometimes you can use the \x05\x41Megaton\x01Hammer \x05\x40" + strcpy(font->msgBuf, "\x08\x05\x44Sometimes you can use the \x05\x41Megaton\x01Hammer \x05\x44" "instead of bombs!\x02"); break; } @@ -42,7 +42,7 @@ void RandoNaviTip(GlobalContext* globalCtx) { if (randNaviTip == 2) { switch (gSaveContext.language) { case LANGUAGE_FRA: - strcpy(font->msgBuf, "\x08French tip about playing rando!\x02"); + strcpy(font->msgBuf, "\x08\x05\x44""French tip about playing rando!\x02"); break; case LANGUAGE_GER: strcpy(font->msgBuf, "\x08German tip about playing rando!\x02"); @@ -50,8 +50,8 @@ void RandoNaviTip(GlobalContext* globalCtx) { case LANGUAGE_ENG: default: strcpy(font->msgBuf, - "\x08There are three\x05\x42 business scrubs\x05\x40 in\x01" - "Hyrule who sell \x05\x44mysterious items\x05\x40. Do\x01you know where they are?\x02"); + "\x08\x05\x44There are three\x05\x42 business scrubs\x05\x44 in\x01" + "Hyrule who sell \x05\x46mysterious items\x05\x44. Do\x01you know where they are?\x02"); break; } } From 48a41bd11c4bc9bd5383dffd4cfcd3323a74a67c Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Sun, 7 Aug 2022 16:31:50 -0700 Subject: [PATCH 3/5] Comment clarity --- soh/src/code/z_message_PAL.c | 3 +- soh/src/code/z_message_RandoNaviTips.c | 28 +++++++++++++++++-- .../actors/ovl_player_actor/z_player.c | 8 +++--- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 0d0da60517..0a12047757 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1750,7 +1750,8 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { break; } msgCtx->msgLength = font->msgLength = strlen(font->msgBuf); - } else if (textId == 0x0140 && gSaveContext.n64ddFlag) { //888888888 + // Give Navi rando-specific gameplay tips + } else if (textId == 0x0140 && gSaveContext.n64ddFlag) { RandoNaviTip(globalCtx); msgCtx->msgLength = font->msgLength = strlen(font->msgBuf); } else { diff --git a/soh/src/code/z_message_RandoNaviTips.c b/soh/src/code/z_message_RandoNaviTips.c index edb1b7f9b5..4d2bd0a925 100644 --- a/soh/src/code/z_message_RandoNaviTips.c +++ b/soh/src/code/z_message_RandoNaviTips.c @@ -4,8 +4,14 @@ #include +// Function for letting Navi give general rando tips to the player instead of her +// normal generic quest tips. + +// Only applies to Navi's overworld quest hints - does not apply to enemy information +// or contextual hints (e.g. "This hallway is twisted!" in Forest Temple) + void RandoNaviTip(GlobalContext* globalCtx) { - u16 randNaviTip = rand() % 3; + u16 randNaviTip = rand() % 4; MessageContext* msgCtx = &globalCtx->msgCtx; Font* font = &msgCtx->font; @@ -51,7 +57,25 @@ void RandoNaviTip(GlobalContext* globalCtx) { default: strcpy(font->msgBuf, "\x08\x05\x44There are three\x05\x42 business scrubs\x05\x44 in\x01" - "Hyrule who sell \x05\x46mysterious items\x05\x44. Do\x01you know where they are?\x02"); + "Hyrule who sell \x05\x49mysterious items\x05\x44. Do\x01you know where they are?\x02"); + break; + } + } + if (randNaviTip == 3) { + switch (gSaveContext.language) { + case LANGUAGE_FRA: + strcpy(font->msgBuf, "\x08\x05\x44" + "French tip about playing rando!\x02"); + break; + case LANGUAGE_GER: + strcpy(font->msgBuf, "\x08German tip about playing rando!\x02"); + break; + case LANGUAGE_ENG: + default: + strcpy(font->msgBuf, + "\x08\x05\x44Stuck on this seed? You could\x01" + "throw in the towel and check the \x01" + "\x05\x49spoiler log\x05\x44...\x02"); break; } } diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 61f013d4c7..7d5d616159 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -15286,9 +15286,9 @@ void func_80853148(GlobalContext* globalCtx, Actor* actor) { if ((this->naviActor == this->targetActor) && ((this->targetActor->textId & 0xFF00) != 0x200)) { this->naviActor->flags |= ACTOR_FLAG_8; func_80835EA4(globalCtx, 0xB); - - if (actor->textId >= 0x0140 && actor->textId <= 0x015F && gSaveContext.n64ddFlag) { - Message_StartTextbox(globalCtx, 0x0140, NULL); - } + // If rando'd and Navi wants to give you a general quest tip, give a rando tip instead + // if (actor->textId >= 0x0140 && actor->textId <= 0x015F && gSaveContext.n64ddFlag) { + // Message_StartTextbox(globalCtx, 0x0140, NULL); + // } } } From a5acf6da20e19903144e493f64e23e631b643036 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Sun, 7 Aug 2022 16:33:44 -0700 Subject: [PATCH 4/5] Set Navi timer back to normal --- soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c | 4 ++-- soh/src/overlays/actors/ovl_player_actor/z_player.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 307c81f7f7..ff9e37e524 100644 --- a/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1382,7 +1382,7 @@ void func_80A053F0(Actor* thisx, GlobalContext* globalCtx) { if (player->naviTextId == 0) { if (player->unk_664 == NULL) { - if (((gSaveContext.naviTimer >= 40) && (gSaveContext.naviTimer <= 3000)) || (nREG(89) != 0)) { + if (((gSaveContext.naviTimer >= 600) && (gSaveContext.naviTimer <= 3000)) || (nREG(89) != 0)) { player->naviTextId = ElfMessage_GetCUpText(globalCtx); if (player->naviTextId == 0x15F) { @@ -1401,7 +1401,7 @@ void func_80A053F0(Actor* thisx, GlobalContext* globalCtx) { if (thisx->textId == ElfMessage_GetCUpText(globalCtx)) { this->fairyFlags |= 0x80; - gSaveContext.naviTimer = 10; + gSaveContext.naviTimer = 3001; } this->fairyFlags |= 0x10; diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 7d5d616159..5bf9394d76 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -15287,8 +15287,8 @@ void func_80853148(GlobalContext* globalCtx, Actor* actor) { this->naviActor->flags |= ACTOR_FLAG_8; func_80835EA4(globalCtx, 0xB); // If rando'd and Navi wants to give you a general quest tip, give a rando tip instead - // if (actor->textId >= 0x0140 && actor->textId <= 0x015F && gSaveContext.n64ddFlag) { - // Message_StartTextbox(globalCtx, 0x0140, NULL); - // } + if (actor->textId >= 0x0140 && actor->textId <= 0x015F && gSaveContext.n64ddFlag) { + Message_StartTextbox(globalCtx, 0x0140, NULL); + } } } From f55623e1c684727a93207a950d0ecd9beb803729 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Tue, 9 Aug 2022 12:23:14 -0700 Subject: [PATCH 5/5] Update z_message_PAL.c --- soh/src/code/z_message_PAL.c | 96 +++++------------------------------- 1 file changed, 11 insertions(+), 85 deletions(-) diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 0a12047757..3a095b0d27 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1663,7 +1663,10 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { gSaveContext.eventInf[0] = gSaveContext.eventInf[1] = gSaveContext.eventInf[2] = gSaveContext.eventInf[3] = 0; } - if (sTextIsCredits) { + // RANDOTODO: Use this for ice trap messages + if (CustomMessage_RetrieveIfExists(globalCtx)) { + osSyncPrintf("Found custom message"); + } else if (sTextIsCredits) { Message_FindCreditsMessage(globalCtx, textId); msgCtx->msgLength = font->msgLength; char* src = (uintptr_t)font->msgOffset; @@ -1674,91 +1677,14 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { //font->msgLength, __FILE__, __LINE__); } else { Message_FindMessage(globalCtx, textId); - // if we're rando'd and talking to a gossip stone - if (gSaveContext.n64ddFlag && - textId == 0x2053 && - Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) != 0 && - (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == 1 || - (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == 2 && - Player_GetMask(globalCtx) == PLAYER_MASK_TRUTH) || - (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == 3 && - CHECK_QUEST_ITEM(QUEST_STONE_OF_AGONY)))) { + msgCtx->msgLength = font->msgLength; + char* src = (uintptr_t)font->msgOffset; + memcpy(font->msgBuf, src, font->msgLength); + } - s16 actorParams = msgCtx->talkActor->params; - - // if we're in a generic grotto - if (globalCtx->sceneNum == 62 && actorParams == 14360) { - // look for the chest in the actorlist to determine - // which grotto we're in - int numOfActorLists = sizeof(globalCtx->actorCtx.actorLists)/sizeof(globalCtx->actorCtx.actorLists[0]); - for(int i = 0; i < numOfActorLists; i++) { - if(globalCtx->actorCtx.actorLists[i].length) { - if(globalCtx->actorCtx.actorLists[i].head->id == 10) { - // set the params for the hint check to be negative chest params - actorParams = 0 - globalCtx->actorCtx.actorLists[i].head->params; - } - } - } - } - - RandomizerCheck hintCheck = Randomizer_GetCheckFromActor(globalCtx->sceneNum, msgCtx->talkActor->id, actorParams); - - // Pass the sizeof the message buffer so we don't hardcode any sizes and can rely on globals. - // If no hint can be found, this just returns 0 size and doesn't modify the buffer, so no worries. - msgCtx->msgLength = font->msgLength = Randomizer_CopyHintFromCheck(hintCheck, font->msgBuf, sizeof(font->msgBuf)); - } else if (gSaveContext.n64ddFlag && (textId == 0x7040 || textId == 0x7088)) { - // rando hints at altar - msgCtx->msgLength = font->msgLength = Randomizer_CopyAltarMessage(font->msgBuf, sizeof(font->msgBuf)); - } else if (textId == 0x00b4 && CVar_GetS32("gInjectSkulltulaCount", 0) != 0) { - switch (gSaveContext.language) { - case LANGUAGE_FRA: - strcpy(font->msgBuf, "\x08\x13\x71Vous obtenez un \x05\x41Symbole de\x01Skulltula d'or\x05\x40! " - "Vous avez\x01\collect\x96 " - "\x05\x41\x19\x05\x40 symboles en tout!\x02"); - break; - case LANGUAGE_GER: - strcpy(font->msgBuf, "\x08\x13\x71\Du erh\x93lst ein \x05\x41Goldene\x01Skulltula-Symbol\x05\x40\! " - "Du hast\x01insgesamt " - "\x05\x41\x19\x05\x40 symbol gesammelt!\x02"); - break; - case LANGUAGE_ENG: default: - strcpy(font->msgBuf, - "\x08\x13\x71You got a \x05\x41Gold Skulltula Token\x05\x40!\x01You've collected " - "\x05\x41\x19\x05\x40 tokens\x01in total!\x02"); - break; - } - msgCtx->msgLength = font->msgLength = strlen(font->msgBuf); - } else if (gSaveContext.n64ddFlag && (textId == 0x10A2 || textId == 0x10DC || textId == 0x10DD)) { - msgCtx->msgLength = font->msgLength = CopyScrubMessage(textId, font->msgBuf, sizeof(font->msgBuf)); - } else if (gSaveContext.n64ddFlag && textId == 0x70CC) { - if (INV_CONTENT(ITEM_ARROW_LIGHT) == ITEM_ARROW_LIGHT) { - msgCtx->msgLength = font->msgLength = Randomizer_CopyGanonText(font->msgBuf, sizeof(font->msgBuf)); - } else { - msgCtx->msgLength = font->msgLength = Randomizer_CopyGanonHintText(font->msgBuf, sizeof(font->msgBuf)); - } - } else if (textId == 0xF8 && GET_PLAYER(globalCtx)->getItemId == GI_ICE_TRAP) { - switch (gSaveContext.language) { - case LANGUAGE_FRA: - strcpy(font->msgBuf, "\x08\x06\x50\x05\x43IDIOT\x0E\x20\x02"); - break; - case LANGUAGE_GER: - strcpy(font->msgBuf, "\x08\x06\x15 Du bist ein\x05\x43 DUMMKOPF\x05\x40!\x0E\x20\x02"); - break; - case LANGUAGE_ENG: - default: - strcpy(font->msgBuf, "\x08\x06\x30You are a\x05\x43 FOWL\x05\x40!\x0E\x20\x02"); - break; - } - msgCtx->msgLength = font->msgLength = strlen(font->msgBuf); - // Give Navi rando-specific gameplay tips - } else if (textId == 0x0140 && gSaveContext.n64ddFlag) { - RandoNaviTip(globalCtx); - msgCtx->msgLength = font->msgLength = strlen(font->msgBuf); - } else { - msgCtx->msgLength = font->msgLength; - char* src = (uintptr_t)font->msgOffset; - memcpy(font->msgBuf, src, font->msgLength); - } + if (textId == 0x0140 && gSaveContext.n64ddFlag) { // 888888888 + RandoNaviTip(globalCtx); + msgCtx->msgLength = font->msgLength = strlen(font->msgBuf); } msgCtx->textBoxProperties = font->charTexBuf[0];