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
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "common/textconsole.h"
#include "titanic/true_talk/doorbot_script.h"
#include "titanic/true_talk/tt_room_script.h"
#include "titanic/true_talk/true_talk_manager.h"
namespace Titanic {
static const int STATE_ARRAY[9] = {
0x2E2A, 0x2E2B, 0x2E2C, 0x2E2D, 0x2E2E, 0x2E2F, 0x2E30, 0x2E31, 0x2E32
};
DoorbotScript::DoorbotScript(int val1, const char *charClass, int v2,
const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) :
TTnpcScript(val1, charClass, v2, charName, v3, val2, v4, v5, v6, v7) {
loadRanges("Ranges/Doorbot");
loadResponses("Responses/Doorbot");
setupSentences();
_tagMappings.load("TagMap/Doorbot");
_words.load("Words/Doorbot");
}
void DoorbotScript::setupSentences() {
for (int idx = 35; idx < 40; ++idx)
CTrueTalkManager::setFlags(idx, 0);
_state = 1;
_dialValues[0] = _dialValues[1] = 100;
_mappings.load("Mappings/Doorbot", 4);
_entries.load("Sentences/Doorbot");
_field68 = 0;
_entryCount = 0;
}
int DoorbotScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag) {
if (tag == MKTAG('D', 'N', 'A', '1') || tag == MKTAG('H', 'H', 'G', 'Q') ||
tag == MKTAG('A', 'N', 'S', 'W') || tag == MKTAG('S', 'U', 'M', 'S')) {
if (_state > 9)
_state = 0;
addResponse(STATE_ARRAY[_state]);
applyResponse();
if (STATE_ARRAY[_state] == 11826)
set34(1);
++_state;
return 2;
}
if (tag == MKTAG('C', 'H', 'S', 'E') || tag == MKTAG('C', 'M', 'N', 'T') ||
tag == MKTAG('J', 'F', 'O', 'D'))
tag = MKTAG('F', 'O', 'O', 'D');
if (tag == MKTAG('F', 'O', 'O', 'D') && roomScript->_scriptId == 132) {
return setResponse(getDialogueId(220818));
}
if (tag == MKTAG('T', 'R', 'A', 'V')) {
return setResponse(11858 - getRandomBit());
} else if (tag == MKTAG('C', 'S', 'P', 'Y')) {
return setResponse(10405, 3);
} else if (tag == MKTAG('S', 'C', 'I', 'T')) {
return setResponse(10410, 14);
} else if (tag == MKTAG('L', 'I', 'T', 'E')) {
return setResponse(10296, 17);
} else if (tag == MKTAG('D', 'O', 'R', '1')) {
return setResponse(getDialogueId(222034));
} else if (tag == MKTAG('W', 'T', 'H', 'R')) {
return setResponse(getDialogueId(222126));
} else if (tag == MKTAG('N', 'A', 'U', 'T')) {
return setResponse(getDialogueId(222259));
} else if (tag == MKTAG('T', 'R', 'A', '2')) {
return setResponse(getRandomBit() ? 11860 : 11859);
} else if (tag == MKTAG('T', 'R', 'A', '3')) {
return setResponse(getRandomBit() ? 11859 : 11858);
} else if (tag == MKTAG('B', 'R', 'N', 'D')) {
switch (getRandomNumber(3)) {
case 1:
tag = MKTAG('B', 'R', 'N', '2');
break;
case 2:
tag = MKTAG('B', 'R', 'N', '3');
break;
default:
break;
}
}
return TTnpcScript::chooseResponse(roomScript, sentence, tag);
}
int DoorbotScript::process(TTroomScript *roomScript, TTsentence *sentence) {
// TODO
return 0;
}
ScriptChangedResult DoorbotScript::scriptChanged(TTscriptBase *roomScript, uint id) {
warning("TODO");
return SCR_1;
}
bool DoorbotScript::handleQuote(TTroomScript *roomScript, TTsentence *sentence,
int val, uint tagId, uint remainder) const {
warning("TODO");
return 0;
}
int DoorbotScript::proc21(int v1, int v2, int v3) {
warning("TODO");
return 0;
}
int DoorbotScript::proc22(int id) const {
warning("TODO");
return 0;
}
uint DoorbotScript::getDialsBitset() const {
uint bits = 0;
if (!getDialRegion(1))
bits = 1;
if (!getDialRegion(0))
bits |= 2;
return bits;
}
int DoorbotScript::proc25(int val1, int val2, TTroomScript *roomScript, TTsentence *sentence) const {
warning("TODO");
return 0;
}
void DoorbotScript::proc26(int v1, const TTsentenceEntry *entry, TTroomScript *roomScript, TTsentence *sentence) {
}
void DoorbotScript::setDialRegion(int dialNum, int region) {
TTnpcScript::setDialRegion(dialNum, region);
if (dialNum == 1 && region != 1) {
CTrueTalkManager::setFlags(37, dialNum);
} else {
addResponse(getDialogueId(221777));
applyResponse();
}
}
int DoorbotScript::proc36(int id) const {
warning("TODO");
return 0;
}
int DoorbotScript::setResponse(int dialogueId, int v34) {
addResponse(dialogueId);
applyResponse();
if (v34 != -1)
set34(v34);
return 2;
}
} // End of namespace Titanic
|