summaryrefslogtreecommitdiff
path: root/mm/2s2h/Rando/ActorBehavior/EnTalk.cpp
blob: b1a98988b52074f09225bbddd42e645220cb1a50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include "ActorBehavior.h"
#include "2s2h/CustomMessage/CustomMessage.h"
#include "2s2h/GameInteractor/GameInteractor.h"

extern "C" {
#include "variables.h"
}

void ApplyRemainsHint(u16* textId, bool* loadFromMessageTable) {
    static int remainsHintIndex = 0;

    if (remainsHintIndex > 4) {
        remainsHintIndex = 0;
    }

    u8 icon = 0xFE;
    std::string msg;
    RandoItemId randoItemId = RI_NONE;

    if (remainsHintIndex == 0) {
        msg = "        Witcher Wanted:\n"
              "These monsters are tormenting the "
              "local townfolk, will pay good money "
              "for their remains.";
    } else {
        msg = "         %g{{boss}}%w:\n"
              "Last seen %y{{location}}%w.";

        switch (remainsHintIndex) {
            case 1:
                CustomMessage::Replace(&msg, "{{boss}}", " Odolwa");
                randoItemId = RI_REMAINS_ODOLWA;
                break;
            case 2:
                CustomMessage::Replace(&msg, "{{boss}}", "  Goht");
                randoItemId = RI_REMAINS_GOHT;
                break;
            case 3:
                CustomMessage::Replace(&msg, "{{boss}}", "  Gyorg");
                randoItemId = RI_REMAINS_GYORG;
                break;
            case 4:
                CustomMessage::Replace(&msg, "{{boss}}", "Twinmold");
                randoItemId = RI_REMAINS_TWINMOLD;
                break;
        }

        icon = Rando::StaticData::GetIconForZMessage(randoItemId);
        RandoCheckId randoCheckId = Rando::FindItemPlacement(randoItemId);
        CustomMessage::Replace(&msg, "{{location}}", Rando::StaticData::GetLocationNameForHint(randoCheckId, false));
    }

    CustomMessage::Entry entry = {
        .icon = icon,
        .nextMessageID = remainsHintIndex >= 4 ? (u16)0xFFFF : (u16)0x1C06,
        .msg = msg,
    };

    CustomMessage::LoadCustomMessageIntoFont(entry);
    *loadFromMessageTable = false;
    remainsHintIndex++;
}

void ApplyTransformationHints(u16* textId, bool* loadFromMessageTable) {
    static std::string placeholderMsg = "Last seen in";
    static int transformHintIndex = 0;

    if (transformHintIndex > 3) {
        transformHintIndex = 0;
    }

    u8 icon = 0xFE;
    std::string msg;
    RandoItemId randoItemId = RI_NONE;

    if (transformHintIndex == 0) {
        msg = "   %yDeparted Soul Alert%w!\n"
              "The souls of the departed lay restless, "
              "find and heal them!";
    } else {
        msg = "%g{{mask}}%w:\n"
              "%y{{locations}}%w.";

        switch (transformHintIndex) {
            case 1:
                CustomMessage::Replace(&msg, "{{mask}}", " Butler's Son");
                randoItemId = RI_MASK_DEKU;
                break;
            case 2:
                CustomMessage::Replace(&msg, "{{mask}}", "  Darmani");
                randoItemId = RI_MASK_GORON;
                break;
            case 3:
                CustomMessage::Replace(&msg, "{{mask}}", "  Mikau");
                randoItemId = RI_MASK_ZORA;
                break;
            default:
                break;
        }

        icon = Rando::StaticData::GetIconForZMessage(randoItemId);
        std::vector<RandoCheckId> itemPlacements = Rando::FindMultiItemPlacement(randoItemId);
        std::string locationStr = "";
        if (!itemPlacements.empty()) {
            for (int i = 0; i < itemPlacements.size(); i++) {
                if (RANDO_SAVE_CHECKS[itemPlacements[i]].obtained) {
                    itemPlacements[i] = RC_UNKNOWN;
                }
            }
            for (auto& location : itemPlacements) {
                if (location == RC_UNKNOWN) {
                    locationStr = "%gLink's pocket%w";
                    break;
                }

                if (locationStr != "") {
                    locationStr += " %w&%y\n";
                }

                locationStr += Rando::StaticData::GetLocationNameForHint(location, false);
            }
            CustomMessage::Replace(&msg, "{{locations}}", locationStr);
        } else {
            CustomMessage::Replace(&msg, "{{locations}}", "%gLink's pocket%w");
        }
    }

    CustomMessage::Entry entry = {
        .icon = icon,
        .nextMessageID = transformHintIndex >= 3 ? (u16)0xFFFF : (u16)0x1C18,
        .msg = msg,
    };

    CustomMessage::LoadCustomMessageIntoFont(entry);
    *loadFromMessageTable = false;
    transformHintIndex++;
}

void Rando::ActorBehavior::InitEnTalkBehavior() {
    // "Recruiting Soldiers..." Posters around Clock Town
    COND_ID_HOOK(OnOpenText, 0x1C06, IS_RANDO && RANDO_SAVE_OPTIONS[RO_HINTS_BOSS_REMAINS], ApplyRemainsHint);

    COND_ID_HOOK(OnOpenText, 0x1C18, IS_RANDO && RANDO_SAVE_OPTIONS[RO_HINTS_TRANSFORMATIONS],
                 ApplyTransformationHints);
}