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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
/* 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 "titanic/game/transport/lift.h"
#include "titanic/pet_control/pet_control.h"
#include "titanic/titanic.h"
namespace Titanic {
BEGIN_MESSAGE_MAP(CLift, CTransport)
ON_MESSAGE(StatusChangeMsg)
ON_MESSAGE(MovieEndMsg)
ON_MESSAGE(EnterViewMsg)
ON_MESSAGE(EnterRoomMsg)
ON_MESSAGE(LeaveRoomMsg)
ON_MESSAGE(ActMsg)
END_MESSAGE_MAP()
bool CLift::_hasHead;
bool CLift::_hasCorrectHead;
int CLift::_elevator1Floor;
int CLift::_elevator2Floor;
int CLift::_elevator3Floor;
int CLift::_elevator4Floor;
void CLift::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_hasHead, indent);
file->writeNumberLine(_elevator1Floor, indent);
file->writeNumberLine(_elevator2Floor, indent);
file->writeNumberLine(_elevator3Floor, indent);
file->writeNumberLine(_elevator4Floor, indent);
file->writeNumberLine(_liftNum, indent);
file->writeNumberLine(_hasCorrectHead, indent);
CTransport::save(file, indent);
}
void CLift::load(SimpleFile *file) {
file->readNumber();
_hasHead = file->readNumber();
_elevator1Floor = file->readNumber();
_elevator2Floor = file->readNumber();
_elevator3Floor = file->readNumber();
_elevator4Floor = file->readNumber();
_liftNum = file->readNumber();
_hasCorrectHead = file->readNumber();
CTransport::load(file);
}
bool CLift::StatusChangeMsg(CStatusChangeMsg *msg) {
CPetControl *pet = getPetControl();
if ((!_hasHead && pet->getRoomsElevatorNum() == 4) ||
(!_hasCorrectHead && pet->getRoomsElevatorNum() == 4))
return true;
int oldFloorNum = msg->_oldStatus;
int floorNum = msg->_newStatus;
int oldClass = 1, newClass = 1;
if (oldFloorNum > 27)
oldClass = 3;
else if (oldFloorNum > 19)
oldClass = 2;
if (floorNum > 27)
newClass = 3;
else if (floorNum > 19)
newClass = 2;
static const int UP_FRAME_NUMBERS[40] = {
0, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58,
63, 68, 73, 78, 83, 88, 93, 118, 123, 128, 133,
138, 143, 148, 153, 228, 233, 238, 243, 248, 253,
258, 263, 268, 273, 278, 298, 299
};
static const int DOWN_FRAME_NUMBERS[39] = {
598, 589, 584, 579, 574, 569, 564, 559, 554, 549,
544, 539, 534, 529, 524, 519, 514, 509, 504, 479,
474, 469, 464, 459, 454, 449, 444, 369, 364, 359,
354, 349, 344, 339, 334, 329, 324, 319, 299
};
if (pet)
pet->setRoomsFloorNum(floorNum);
if (pet->getRoomsElevatorNum() == 2 || pet->getRoomsElevatorNum() == 4) {
if (floorNum > 27)
floorNum = 27;
if (oldFloorNum > 27)
oldFloorNum = 27;
}
changeView("Lift.Node 1.N");
CTurnOn onMsg;
onMsg.execute("LiftHood");
CString debugStr;
if (floorNum > oldFloorNum) {
// Animate lift going up
_startFrame = UP_FRAME_NUMBERS[oldFloorNum - 1];
_endFrame = UP_FRAME_NUMBERS[floorNum - 1];
if (oldClass == newClass) {
debugStr = CString::format("Same (%d-%d)", _startFrame, _endFrame);
playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
} else if (oldClass == 1 && newClass == 2) {
debugStr = CString::format("1 to 2 (%d-108, 108-%d)", _startFrame, _endFrame);
playMovie(_startFrame, 108, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
playMovie(108, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
} else if (oldClass == 1 && newClass == 3) {
debugStr = CString::format("1 to 3 (%d-108, 108-190, 190-%d)", _startFrame, _endFrame);
playMovie(_startFrame, 108, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
playMovie(108, 190, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
playMovie(190, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
} else {
debugStr = CString::format("2 to 3 (%d-190, 190-%d)", _startFrame, _endFrame);
playMovie(_startFrame, 190, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
playMovie(190, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
}
}
if (floorNum < oldFloorNum) {
// Animate lift going down
_startFrame = DOWN_FRAME_NUMBERS[oldFloorNum - 1];
_endFrame = DOWN_FRAME_NUMBERS[floorNum - 1];
if (oldClass == newClass) {
debugStr = CString::format("Same (%d-%d)", _startFrame, _endFrame);
playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
} else if (oldClass == 3 && newClass == 2) {
debugStr = CString::format("3 to 2 (%d-407, 407-%d)", _startFrame, _endFrame);
playMovie(_startFrame, 407, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
playMovie(407, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
} else if (oldClass == 3 && newClass == 1) {
debugStr = CString::format("3 to 1 (%d-407, 407-489, 489-%d)", _startFrame, _endFrame);
playMovie(_startFrame, 407, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
playMovie(407, 489, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
playMovie(489, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
} else {
debugStr = CString::format("2 to 1 (%d-489, 489-%d)", _startFrame, _endFrame);
playMovie(_startFrame, 489, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
playMovie(489, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH);
}
}
CShipSettingMsg settingMsg;
switch (pet->getRoomsElevatorNum()) {
case 1:
_elevator1Floor = floorNum;
break;
case 2:
_elevator2Floor = floorNum;
_elevator4Floor = oldFloorNum;
settingMsg._value = oldFloorNum;
settingMsg.execute("SGTStateroomTV");
break;
case 3:
_elevator3Floor = floorNum;
break;
case 4:
_elevator4Floor = floorNum;
break;
default:
break;
}
debugC(1, kDebugScripts, "%s", debugStr.c_str());
return true;
}
bool CLift::MovieEndMsg(CMovieEndMsg *msg) {
switch (msg->_endFrame) {
case 108:
setGlobalSoundVolume(-4, 1, 2);
setGlobalSoundVolume(-2, 1, 1);
break;
case 190:
setGlobalSoundVolume(-4, 1, 1);
setGlobalSoundVolume(-2, 1, 2);
break;
case 407:
setGlobalSoundVolume(-4, 1, 0);
setGlobalSoundVolume(-2, 1, 1);
break;
case 489:
setGlobalSoundVolume(-4, 1, 1);
setGlobalSoundVolume(-2, 1, 0);
break;
default: {
CActMsg actMsg("LiftArrive");
actMsg.execute("Liftbot");
sleep(500);
playSound("352 gp button 1.wav");
CTurnOff offMsg;
offMsg.execute("LiftHood");
changeView("Lift.Node 1.W");
break;
}
}
return true;
}
bool CLift::EnterViewMsg(CEnterViewMsg *msg) {
static const int FRAME_NUMBERS[40] = {
0, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73,
78, 83, 88, 93, 118, 123, 128, 133, 138, 143, 148, 153,
228, 233, 238, 243, 248, 253, 258, 263, 268, 273, 278, 298
};
CPetControl *pet = getPetControl();
loadFrame(FRAME_NUMBERS[pet->getRoomsFloorNum() - 1]);
return true;
}
bool CLift::EnterRoomMsg(CEnterRoomMsg *msg) {
if (isEquals("Well")) {
CPetControl *pet = getPetControl();
int floorNum = pet->getRoomsFloorNum();
int elevNum = pet->getRoomsElevatorNum();
loadSound("z#520.wav");
loadSound("z#519.wav");
loadSound("z#518.wav");
if (elevNum == 4 && _hasHead && !_hasCorrectHead) {
CVisibleMsg visibleMsg;
visibleMsg.execute("GetLiftEye");
}
if (floorNum < 20) {
playGlobalSound("z#520.wav", -2, true, true, 0);
playGlobalSound("z#519.wav", -4, false, true, 1);
playGlobalSound("z#518.wav", -4, false, true, 2);
} else if (floorNum < 28) {
playGlobalSound("z#520.wav", -4, false, true, 0);
playGlobalSound("z#519.wav", -2, true, true, 1);
playGlobalSound("z#518.wav", -4, false, true, 2);
} else {
playGlobalSound("z#520.wav", -4, false, true, 0);
playGlobalSound("z#519.wav", -4, false, true, 1);
playGlobalSound("z#518.wav", -2, true, true, 2);
}
}
return true;
}
bool CLift::LeaveRoomMsg(CLeaveRoomMsg *msg) {
stopGlobalSound(true, -1);
CPetControl *pet = getPetControl();
if (pet->getRoomsElevatorNum() == 4 && _hasHead && !_hasCorrectHead) {
CVisibleMsg visibleMsg(false);
visibleMsg.execute("Eye2");
}
return true;
}
bool CLift::ActMsg(CActMsg *msg) {
if (msg->_action == "LoseHead") {
_hasHead = false;
_hasCorrectHead = false;
CActMsg actMsg1("Lift.Node 2.N");
actMsg1.execute("RPanInLiftW");
CActMsg actMsg2("Lift.Node 2.S");
actMsg2.execute("LPanInLiftW");
} else if (msg->_action == "AddWrongHead") {
_hasHead = true;
_hasCorrectHead = false;
CActMsg actMsg1("Lift.Node 1.N");
actMsg1.execute("RPanInLiftW");
CActMsg actMsg2("Lift.Node 1.S");
actMsg2.execute("LPanInLiftW");
} else if (msg->_action == "AddRightHead") {
_hasHead = true;
_hasCorrectHead = true;
petSetRoomsElevatorBroken(false);
CActMsg actMsg1("Lift.Node 1.N");
actMsg1.execute("RPanInLiftW");
CActMsg actMsg2("Lift.Node 1.S");
actMsg2.execute("LPanInLiftW");
CActMsg actMsg3("ActivateLift");
actMsg3.execute("Liftbot");
}
CVisibleMsg visibleMsg;
visibleMsg.execute("LiftbotWithoutHead");
return true;
}
} // End of namespace Titanic
|