aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/game/transport/pellerator.cpp
blob: 0228f9bc8b02ae7b654dde84b8c2751dc2f70b54 (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
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
/* 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/pellerator.h"
#include "titanic/core/room_item.h"

namespace Titanic {

static const char *const WAVE_NAMES[10] = {
	"z#465.wav", "z#456.wav", "z#455.wav", "z#453.wav",
	"z#452.wav", "NoStandingInFunnyWays", "z#450.wav",
	"z#449.wav", "z#435.wav", "z#434.wav"
};

BEGIN_MESSAGE_MAP(CPellerator, CTransport)
	ON_MESSAGE(StatusChangeMsg)
	ON_MESSAGE(EnterRoomMsg)
	ON_MESSAGE(MovieEndMsg)
	ON_MESSAGE(TimerMsg)
END_MESSAGE_MAP()

int CPellerator::_soundHandle;
int CPellerator::_destination;

CPellerator::CPellerator() : CTransport() {
}

void CPellerator::save(SimpleFile *file, int indent) {
	file->writeNumberLine(1, indent);
	file->writeNumberLine(_soundHandle, indent);
	file->writeNumberLine(_destination, indent);

	CTransport::save(file, indent);
}

void CPellerator::load(SimpleFile *file) {
	file->readNumber();
	_soundHandle = file->readNumber();
	_destination = file->readNumber();

	CTransport::load(file);
}

bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) {
	setVisible(true);
	playGlobalSound("z#74.wav", -2, true, true, 0);
	int classNum = getPassengerClass();
	int newDest = msg->_newStatus;

	if (msg->_newStatus == _destination) {
		petDisplayMessage(1, ALREADY_AT_DESTINATION);
	} else if (classNum == 3 || (msg->_newStatus > 4 && classNum != 1)) {
		petDisplayMessage(1, CLASS_NOT_ALLOWED_AT_DEST);
	} else if (newDest > _destination) {
		CString name = getName();
		changeView(name == "PelleratorObject2" ?
			"Pellerator.Node 1.N" : "Pellerator.Node 1.S");

		if (name == "PelleratorObject") {
			for (; _destination < newDest; ++_destination) {
				switch (_destination) {
				case 0:
				case 1:
					playMovie(315, 323, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(299, 304, 0);
					playMovie(305, 313, MOVIE_WAIT_FOR_FINISH);
					break;

				case 2:
					playMovie(315, 323, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(299, 304, 0);
					for (int idx = 0; idx < 5; ++idx)
						playMovie(253, 263, 0);
					playMovie(153, 197, 0);
					for (int idx = 0; idx < 5; ++idx)
						playMovie(253, 263, 0);
					playMovie(290, 293, MOVIE_WAIT_FOR_FINISH);
					break;

				case 4:
					playMovie(267, 270, 0);
					for (int idx = 0; idx < 5; ++idx)
						playMovie(253, 263, 0);
					playMovie(3, 71, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(253, 263, 0);
					for (int idx = 0; idx < 7; ++idx)
						playMovie(336, 341, 0);
					playMovie(342, 348, MOVIE_WAIT_FOR_FINISH);
					break;

				case 5:
					playMovie(315, 323, 0);
					for (int idx = 0; idx < 7; ++idx)
						playMovie(299, 304, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(253, 263, 0);
					playMovie(3, 71, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(299, 304, 0);

				}
			}
		} else {
			for (; _destination < newDest; ++_destination) {
				switch (_destination) {
				case 0:
				case 1:
					playMovie(315, 323, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(299, 304, 0);
					playMovie(305, 313, MOVIE_WAIT_FOR_FINISH);
					break;

				case 2:
					playMovie(315, 323, 0);
					for (int idx = 0; idx < 4; ++idx)
						playMovie(299, 304, 0);
					for (int idx = 0; idx < 15; ++idx)
						playMovie(245, 255, 0);
					playMovie(264, 267, MOVIE_WAIT_FOR_FINISH);
					++_destination;
					break;

				case 4:
					playMovie(241, 244, 0);
					for (int idx = 0; idx < 15; ++idx)
						playMovie(245, 255, 0);
					for (int idx = 0; idx < 7; ++idx)
						playMovie(336, 341, 0);
					playMovie(342, 348, MOVIE_WAIT_FOR_FINISH);
					break;

				case 5:
					playMovie(315, 323, 0);
					for (int idx = 0; idx < 7; ++idx)
						playMovie(229, 304, 0);
					for (int idx = 0; idx < 12; ++idx)
						playMovie(245, 255, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(299, 304, 0);
					playMovie(305, 313, MOVIE_WAIT_FOR_FINISH);
					break;

				default:
					break;
				}
			}
		}

		playMovie(264, 264, MOVIE_NOTIFY_OBJECT);
		_destination = newDest;
	} else if (newDest < _destination) {
		CString name = getName();
		changeView(name == "PelleratorObject2" ?
			"Pellerator.Node 1.N" : "Pellerator.Node 1.S");

		if (name == "PelleratorObject") {
			for (--_destination; _destination > newDest; --_destination) {
				switch (_destination) {
				case 0:
				case 1:
					playMovie(351, 359, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(336, 341, 0);
					playMovie(342, 348, MOVIE_WAIT_FOR_FINISH);
					break;

				case 3:
					playMovie(241, 244, 0);
					for (int idx = 0; idx < 5; ++idx)
						playMovie(245, 255, 0);
					playMovie(197, 239, 0);
					for (int idx = 0; idx < 5; ++idx)
						playMovie(245, 255, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(336, 341, 0);
					playMovie(342, 348, MOVIE_WAIT_FOR_FINISH);
					--_destination;
					break;

				case 4:
					playMovie(315, 323, 0);
					for (int idx = 0; idx < 7; ++idx)
						playMovie(299, 304, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(245, 255, 0);
					playMovie(78, 149, 0);
					for (int idx = 0; idx < 5; ++idx)
						playMovie(245, 255, 0);
					playMovie(264, 267, MOVIE_WAIT_FOR_FINISH);
					break;

				case 5:
					playMovie(351, 359, 0);
					for (int idx = 0; idx < 7; ++idx)
						playMovie(336, 341, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(245, 255, 0);
					playMovie(78, 149, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(336, 341, 0);
					playMovie(342, 348, MOVIE_WAIT_FOR_FINISH);
					break;

				default:
					break;
				}
			}
		} else {
			for (--_destination; _destination > newDest; --_destination) {
				switch (_destination) {
				case 0:
				case 1:
					playMovie(351, 359, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(336, 341, 0);
					playMovie(342, 348, MOVIE_WAIT_FOR_FINISH);
					break;

				case 3:
					playMovie(267, 270, 0);
					for (int idx = 0; idx < 15; ++idx)
						playMovie(253, 263, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(336, 341, 0);
					playMovie(342, 348, MOVIE_WAIT_FOR_FINISH);
					--_destination;
					break;

				case 4:
					playMovie(315, 323, 0);
					for (int idx = 0; idx < 7; ++idx)
						playMovie(299, 304, 0);
					for (int idx = 0; idx < 15; ++idx)
						playMovie(253, 263, 0);
					playMovie(290, 293, MOVIE_WAIT_FOR_FINISH);
					break;

				case 5:
					playMovie(351, 359, 0);
					for (int idx = 0; idx < 7; ++idx)
						playMovie(336, 341, 0);
					for (int idx = 0; idx < 13; ++idx)
						playMovie(253, 263, 0);
					for (int idx = 0; idx < 3; ++idx)
						playMovie(336, 341, 0);
					playMovie(342, 348, MOVIE_WAIT_FOR_FINISH);
					break;

				default:
					break;
				}
			}
		}

		playMovie(264, 264, MOVIE_NOTIFY_OBJECT);
		_destination = newDest;
	}

	CStatusChangeMsg statusMsg;
	statusMsg._newStatus = _destination;
	statusMsg.execute("ExitPellerator");

	return true;
}

bool CPellerator::EnterRoomMsg(CEnterRoomMsg *msg) {
	if (isEquals("PelleratorObject")) {
		for (int idx = 0; idx < 10; ++idx)
			loadSound(WAVE_NAMES[idx]);
		addTimer(10000);
	}

	CString name = msg->_oldRoom ? msg->_oldRoom->getName() : "";
	int oldVal = _destination;

	if (name.empty()) {
		_destination = 4;
		oldVal = 4;
	} else if (name == "PromenadeDeck") {
		_destination = 0;
	} else if (name == "MusicRoomLobby") {
		_destination = 1;
	} else if (name == "Bar") {
		_destination = 2;
	} else if (name == "TopOfWell") {
		_destination = 4;
	} else if (name == "1stClassRestaurant") {
		_destination = 5;
	} else if (name == "Arboretum" || name == "FrozenArboretum") {
		_destination = 6;
	}

	if (_destination != oldVal) {
		CStatusChangeMsg statusMsg;
		statusMsg._newStatus = _destination;
		statusMsg.execute("ExitPellerator");
	}

	loadFrame(264);
	return true;
}

bool CPellerator::MovieEndMsg(CMovieEndMsg *msg) {
	setVisible(false);
	stopGlobalSound(true, -1);

	switch (_destination) {
	case 0:
		_soundHandle = queueSound("z#429.wav", _soundHandle);
		break;
	case 1:
		_soundHandle = queueSound("z#430.wav", _soundHandle);
		break;
	case 2:
		_soundHandle = queueSound("z#431.wav", _soundHandle);
		break;
	case 4:
		_soundHandle = queueSound("z#428.wav", _soundHandle);
		break;
	case 5:
		_soundHandle = queueSound("z#433.wav", _soundHandle);
		break;
	case 6:
		_soundHandle = queueSound("z#432.wav", _soundHandle);
		break;
	default:
		break;
	}

	return true;
}

bool CPellerator::TimerMsg(CTimerMsg *msg) {
	if (compareRoomNameTo("Pellerator")) {
		_soundHandle = queueSound(WAVE_NAMES[getRandomNumber(9)], _soundHandle);
		addTimer(20000 + getRandomNumber(10000));
	}

	return true;
}

} // End of namespace Titanic