diff options
| author | Garrett Cox <garrettjcox@gmail.com> | 2025-02-11 01:29:32 -0600 |
|---|---|---|
| committer | Garrett Cox <garrettjcox@gmail.com> | 2025-02-11 01:29:32 -0600 |
| commit | 332171736e5b27fd9a80975fea5d6362be349366 (patch) | |
| tree | f36999da2c9af93f94c81d0c166ee8d0ea876217 /mm/2s2h/Rando/ActorBehavior/EnGs.cpp | |
| parent | 2b7eb416e936ab9c1f29c2ab01a96a02d8dc2cbf (diff) | |
Implement toggles for a few more things like hints and cows
Diffstat (limited to 'mm/2s2h/Rando/ActorBehavior/EnGs.cpp')
| -rw-r--r-- | mm/2s2h/Rando/ActorBehavior/EnGs.cpp | 111 |
1 files changed, 65 insertions, 46 deletions
diff --git a/mm/2s2h/Rando/ActorBehavior/EnGs.cpp b/mm/2s2h/Rando/ActorBehavior/EnGs.cpp index 1be29e46a..1f1255367 100644 --- a/mm/2s2h/Rando/ActorBehavior/EnGs.cpp +++ b/mm/2s2h/Rando/ActorBehavior/EnGs.cpp @@ -11,11 +11,17 @@ extern "C" { #include "overlays/actors/ovl_En_Gs/z_en_gs.h" } -std::unordered_map<RandoCheckId, std::string> readableCheckNamesForGs; - #define FIRST_GS_MESSAGE 0x20D1 #define SECOND_GS_MESSAGE 0x20C0 +std::vector<std::string> flavorText = { + "Good luck on your journey ...", + "I hope you find what you're looking for ...", + "... Evil is afoot", + "Beware the moon's gaze", + " .. It's dangerous to go alone", +}; + s32 GetNormalizedCost() { s32 obtainedChecks = 0; s32 maxChecks = 0; @@ -62,79 +68,92 @@ RandoCheckId GetRandomCheck(bool repeatableOnlyObtained = false) { } void Rando::ActorBehavior::InitEnGsBehavior() { - readableCheckNamesForGs.clear(); - for (auto& [randoCheckId, randoStaticCheck] : Rando::StaticData::Checks) { - readableCheckNamesForGs[randoCheckId] = convertEnumToReadableName(randoStaticCheck.name); - } + bool shouldRegister = + IS_RANDO && (RANDO_SAVE_OPTIONS[RO_HINTS_GOSSIP_STONES] || RANDO_SAVE_OPTIONS[RO_HINTS_PURCHASEABLE]); - COND_VB_SHOULD(VB_GS_CONSIDER_MASK_OF_TRUTH_EQUIPPED, IS_RANDO, { *should = true; }); + COND_VB_SHOULD(VB_GS_CONSIDER_MASK_OF_TRUTH_EQUIPPED, shouldRegister, { *should = true; }); // Override the message ID so that we can control the text - COND_VB_SHOULD(VB_GS_CONTINUE_TEXTBOX, IS_RANDO, { + COND_VB_SHOULD(VB_GS_CONTINUE_TEXTBOX, shouldRegister, { *should = false; Message_ContinueTextbox(gPlayState, SECOND_GS_MESSAGE); }); - COND_ID_HOOK(OnOpenText, FIRST_GS_MESSAGE, IS_RANDO, [](u16* textId, bool* loadFromMessageTable) { - RandoCheckId randoCheckId = GetRandomCheck(); - if (randoCheckId == RC_UNKNOWN) { - return; - } - + COND_ID_HOOK(OnOpenText, FIRST_GS_MESSAGE, shouldRegister, [](u16* textId, bool* loadFromMessageTable) { auto entry = CustomMessage::LoadVanillaMessageTableEntry(*textId); - entry.autoFormat = false; - auto& saveCheck = RANDO_SAVE_CHECKS[randoCheckId]; - entry.msg = "They say %g{{item}}%w is hidden at %y{{location}}%w."; + if (RANDO_SAVE_OPTIONS[RO_HINTS_GOSSIP_STONES]) { + RandoCheckId randoCheckId = GetRandomCheck(); + if (randoCheckId == RC_UNKNOWN) { + return; + } + + entry.autoFormat = false; + auto& saveCheck = RANDO_SAVE_CHECKS[randoCheckId]; - CustomMessage::Replace(&entry.msg, "{{item}}", Rando::StaticData::GetItemName(saveCheck.randoItemId)); - CustomMessage::Replace(&entry.msg, "{{location}}", - Ship_GetSceneName(Rando::StaticData::Checks[randoCheckId].sceneId)); + entry.msg = "They say %g{{item}}%w is hidden at %y{{location}}%w."; - // Replace colors before line break calculation - CustomMessage::ReplaceColorChars(&entry.msg); + CustomMessage::Replace(&entry.msg, "{{item}}", Rando::StaticData::GetItemName(saveCheck.randoItemId)); + CustomMessage::Replace(&entry.msg, "{{location}}", + Ship_GetSceneName(Rando::StaticData::Checks[randoCheckId].sceneId)); - CustomMessage::AddLineBreaks(&entry.msg); + // Replace colors before line break calculation + CustomMessage::ReplaceColorChars(&entry.msg); - // Eventually this part should be opt-in, but for now it's always on - entry.msg += "\x10...\x13\x12Trade %r{{rupees}} Rupees%w for another hint?\x02\x11\xC2No\x11Yes"; - s32 cost = GetNormalizedCost(); - CustomMessage::Replace(&entry.msg, "{{rupees}}", std::to_string(cost)); + CustomMessage::AddLineBreaks(&entry.msg); + + if (RANDO_SAVE_OPTIONS[RO_HINTS_PURCHASEABLE]) { + entry.msg += "\x10...\x13\x12"; + } + } else { + entry.msg = ""; + } + + if (RANDO_SAVE_OPTIONS[RO_HINTS_PURCHASEABLE]) { + entry.msg += "Trade %r{{rupees}} Rupees%w for a hint?\x02\x11\xC2No\x11Yes"; + s32 cost = GetNormalizedCost(); + CustomMessage::Replace(&entry.msg, "{{rupees}}", std::to_string(cost)); + + CustomMessage::ReplaceColorChars(&entry.msg); + } - CustomMessage::ReplaceColorChars(&entry.msg); CustomMessage::EnsureMessageEnd(&entry.msg); CustomMessage::LoadCustomMessageIntoFont(entry); *loadFromMessageTable = false; }); - COND_ID_HOOK(OnOpenText, SECOND_GS_MESSAGE, IS_RANDO, [](u16* textId, bool* loadFromMessageTable) { + COND_ID_HOOK(OnOpenText, SECOND_GS_MESSAGE, shouldRegister, [](u16* textId, bool* loadFromMessageTable) { MessageContext* msgCtx = &gPlayState->msgCtx; - auto entry = CustomMessage::LoadVanillaMessageTableEntry(*textId); - if (msgCtx->choiceIndex == 1) { - s32 cost = GetNormalizedCost(); + if (RANDO_SAVE_OPTIONS[RO_HINTS_PURCHASEABLE]) { + if (msgCtx->choiceIndex == 1) { + s32 cost = GetNormalizedCost(); - RandoCheckId randoCheckId = GetRandomCheck(true); - if (gSaveContext.save.saveInfo.playerData.rupees < cost) { - entry.msg = "Foolish... You don't have enough rupees..."; - } else if (randoCheckId == RC_UNKNOWN) { - entry.msg = "I have no more hints for you..."; - } else { - RandoSaveCheck saveCheck = RANDO_SAVE_CHECKS[randoCheckId]; + RandoCheckId randoCheckId = GetRandomCheck(true); + if (gSaveContext.save.saveInfo.playerData.rupees < cost) { + entry.msg = "Foolish... You don't have enough rupees..."; + } else if (randoCheckId == RC_UNKNOWN) { + entry.msg = "I have no more hints for you..."; + } else { + RandoSaveCheck saveCheck = RANDO_SAVE_CHECKS[randoCheckId]; - entry.msg = "Wise choice... They say %g{{item}}%w is hidden at %y{{location}}%w."; + entry.msg = "Wise choice... They say %g{{item}}%w is hidden at %y{{location}}%w."; - CustomMessage::Replace(&entry.msg, "{{item}}", Rando::StaticData::GetItemName(saveCheck.randoItemId)); - CustomMessage::Replace(&entry.msg, "{{location}}", - Ship_GetSceneName(Rando::StaticData::Checks[randoCheckId].sceneId)); + CustomMessage::Replace(&entry.msg, "{{item}}", + Rando::StaticData::GetItemName(saveCheck.randoItemId)); + CustomMessage::Replace(&entry.msg, "{{location}}", + Ship_GetSceneName(Rando::StaticData::Checks[randoCheckId].sceneId)); - gSaveContext.rupeeAccumulator -= cost; - cost *= 2; + gSaveContext.rupeeAccumulator -= cost; + cost *= 2; + } + } else { + entry.msg = "Foolish... Come back later when you have more sense."; } } else { - entry.msg = "Foolish... Come back later when you have more sense."; + entry.msg = flavorText[Ship_Random(0, flavorText.size() - 1)]; } CustomMessage::LoadCustomMessageIntoFont(entry); |
