summaryrefslogtreecommitdiff
path: root/src/d/actor/d_a_npc_tc_msg_normal2.inc
blob: 203b5e336cc9209def1f4f5e4f2d1876147e192f (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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// The original name of this file is unknown, but it must exist because d_a_npc_tc's "normal2's" functions
// are in a separate .text section from the rest of its functions.

#include "d/actor/d_a_npc_tc.h"
#include "d/d_com_inf_game.h"

/* 00004BAC-00004E6C       .text next_msgStatusNormal2__10daNpc_Tc_cFPUl */
u16 daNpc_Tc_c::next_msgStatusNormal2(u32* pMsgNo) {
    u16 msgStatus = fopMsgStts_MSG_CONTINUES_e;
    if ((mAnmPrmIdx == ANM_PRM_IDX_DANCE01_TO_TALK01 || mAnmPrmIdx == ANM_PRM_IDX_DANCE02_TO_WAIT03) && !mpMorf->isStop()) {
        msgStatus = fopMsgStts_MSG_DISPLAYED_e;
    } else {
        switch (*pMsgNo) {
#if VERSION > VERSION_JPN
            case 0x38AA:
            case 0x38AB:
                if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_3020)) {
                    *pMsgNo = 0x38AC;
                } else {
                    *pMsgNo = 0x38AD;
                }
                break;
            case 0x38AC:
            case 0x38AD:
                if (existKnownCollectMap()) {
                    *pMsgNo = 0xDBA;
                } else {
                    *pMsgNo = 0xDB5;
                }
                break;
#endif
            case 0xDB2:
            case 0xDB3:
            case 0xDFB:
                *pMsgNo = 0xDB4;
                break;

            case 0xDB4:
                *pMsgNo = getMsgNormal2();
                break;

            case 0xDB5:
                *pMsgNo = 0xDBA;
                break;

            case 0xDBB:
                *pMsgNo = 0xDBC;
                break;

            case 0xDBC:
                *pMsgNo = 0xDBD;
                break;

            case 0xDBD:
                *pMsgNo = 0xDBE;
                break;

            case 0xDBE:
                if (mpCurrMsg->mSelectNum == 0) {
                    if ((u16)dComIfGs_getRupee() >= 398) {
                        mStatus = STATUS_PAY_RUPEE;
                        field_0x80D = true;
                        field_0x80C = true;
                        msgStatus = fopMsgStts_MSG_ENDS_e;
                    } else {
                        *pMsgNo = 0xDC0;
                    }
                } else {
                    *pMsgNo = 0xDBF;
                }
                break;
            
            case 0xDC0:
                if (field_0x80B) {
                    *pMsgNo = 0xDC4;
                } else {
                    *pMsgNo = 0xDC1;
                }
                break;

            case 0xDBF:
                *pMsgNo = 0xDC1;
                break;

            case 0xDC3:
                if (mpCurrMsg->mSelectNum == 0) {
                    if ((u16)dComIfGs_getRupee() >= 398) {
                        mStatus = STATUS_PAY_RUPEE;
                        field_0x80D = true;
                        field_0x80C = true;
                        msgStatus = fopMsgStts_MSG_ENDS_e;
                    } else {
                        field_0x80B = true;
                        *pMsgNo = 0xDC0;
                    }
                } else {
                    *pMsgNo = 0xDC4;
                }
                break;
            case 0xDC4:
                field_0x80D = false;
                field_0x80B = false;
                // fallthrough
            default:
                msgStatus = fopMsgStts_MSG_ENDS_e;
                break;
        }
    }
    return msgStatus;
}

/* 00004E6C-00004F68       .text getMsgNormal2__10daNpc_Tc_cFv */
u32 daNpc_Tc_c::getMsgNormal2() {
    u32 msg;
    stopTower();
    if (field_0x80D) {
        if (existUnknownCollectMap()) {
            msg = 0xDC3;
            field_0x80D = false;
        } else {
            msg = 0xDC4;

        }
    } else if (!field_0x808) {
        field_0x808 = true;
        if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_1A20)) {
            if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_1708)) {
                msg = 0xDB3;
            } else {
                msg = 0xDFB;
            }
        } else {
            msg = 0xDB2;
        }
    } else if (existUnknownCollectMap()) {
        if (!field_0x809) {
            field_0x809 = true;
            msg = 0xDBB;
        } else {
            msg = 0xDBE;
        }
    } else {
#if VERSION <= VERSION_JPN
        if(existKnownCollectMap()) {
            msg = 0xDBA;
        } else {
            msg = 0xDB5;
        }
#else
        msg = setRupeeSizeMsg();
#endif
    }
    return msg;
}

#if VERSION > VERSION_JPN
/* 00004F68-00004FD8       .text setRupeeSizeMsg__10daNpc_Tc_cFv */
u32 daNpc_Tc_c::setRupeeSizeMsg() {
    u32 msgNo = 0xDB5;
    if (dComIfGs_getWalletSize() == 0) {
        msgNo = 0x38AA;
    } else if (dComIfGs_getWalletSize() == 1) {
        msgNo = 0x38AB;
    }
    else if (dComIfGs_getWalletSize() == 2) {
        if (existKnownCollectMap()) {
            msgNo = 0xDBA;
        } else {
            msgNo = 0xDB5;
        }
    }
    return msgNo;
}
#endif

/* 00004FD8-00005054       .text existUnknownCollectMap__10daNpc_Tc_cFv */
bool daNpc_Tc_c::existUnknownCollectMap() {
    for(int i = 1; i <= 8; i++) {
        if(!dComIfGs_isCollectMapTriforce(i) && dComIfGs_isGetCollectMap(i)) {
            return true;
        }
    }
    return false;
}

/* 00005054-000050DC       .text analysisCollectMap__10daNpc_Tc_cFv */
int daNpc_Tc_c::analysisCollectMap() {
    for(int i = 1; i <= 8; i++) {
        if(!dComIfGs_isCollectMapTriforce(i) && dComIfGs_isGetCollectMap(i)) {
            dComIfGs_onCollectMapTriforce(i);
            return i;
        }
    }
    return 0;
}

/* 000050DC-00005158       .text existKnownCollectMap__10daNpc_Tc_cFv */
bool daNpc_Tc_c::existKnownCollectMap() {
    for(int i = 1; i <= 8; i++) {
        if(dComIfGs_isGetCollectMap(i) && dComIfGs_isCollectMapTriforce(i)) {
            return true;
        }
    }
    return false;
}