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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
|
/* 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 "startrek/room.h"
namespace StarTrek {
#define OBJECT_ELASI_1 8
#define OBJECT_ELASI_2 9
#define OBJECT_ELASI_3 10
#define OBJECT_ELASI_4 11
#define OBJECT_12 12
#define OBJECT_13 13
#define OBJECT_14 14
#define OBJECT_15 15
#define GUARDSTAT_UP 0
#define GUARDSTAT_STUNNED 1
#define GUARDSTAT_DEAD 2
#define GUARDSTAT_SURRENDERED 4
#define GUARDSTAT_TIED 8
void Room::tug3Tick1() {
playVoc("TUG3LOOP");
_awayMission->disableWalking = true;
loadActorAnim2(OBJECT_ELASI_1, "p1turn", 0xa4, 0x98, 0);
loadActorAnim2(OBJECT_ELASI_2, "p2turn", 0xd1, 0x88, 0);
loadActorAnim2(OBJECT_ELASI_3, "p3turn", 0xfb, 0xc4, 0);
loadActorAnim2(OBJECT_ELASI_4, "p4turn", 0x5a, 0x9e, 0);
}
void Room::tug3Tick40() {
loadActorAnim2(OBJECT_KIRK, "kdraws", -1, -1, 0); // Draw phaser
}
void Room::tug3LookAnywhere() {
showDescription(7, true);
}
void Room::tug3ElasiSurrendered() {
// BUGFIX: the original game had the condition below. However, this would cause
// problems if you start shooting, then get them to surrender; if timed correctly,
// they could shoot Kirk as he's beaming out and the mission is "successful". To
// prevent that, the below condition is removed in ScummVM.
/*
if (_awayMission->tug.bridgeElasiDrewPhasers)
return;
*/
// Also part of the bugfix (stop shooting)
_awayMission->timers[0] = 0;
_awayMission->tug.elasiSurrendered = true;
loadActorAnim2(OBJECT_ELASI_1, "p1surr", -1, -1, 0);
_awayMission->tug.bridgeElasi1Status = GUARDSTAT_SURRENDERED;
if (_awayMission->tug.bridgeElasi2Status == GUARDSTAT_UP) {
loadActorAnim2(OBJECT_ELASI_2, "p2surr", -1, -1, 0);
_awayMission->tug.bridgeElasi2Status = GUARDSTAT_SURRENDERED;
}
if (_awayMission->tug.bridgeElasi3Status == GUARDSTAT_UP) {
loadActorAnim2(OBJECT_ELASI_3, "p3surr", -1, -1, 0);
_awayMission->tug.bridgeElasi3Status = GUARDSTAT_SURRENDERED;
}
if (_awayMission->tug.bridgeElasi4Status == GUARDSTAT_UP) {
loadActorAnim2(OBJECT_ELASI_4, "p4surr", -1, -1, 0);
_awayMission->tug.bridgeElasi4Status = GUARDSTAT_SURRENDERED;
}
_awayMission->tug.missionScore += 4;
}
void Room::tug3UsePhaserAnywhere() {
// Stub function to suppress "you can't do that" messages
}
void Room::tug3ElasiDrawPhasers() {
if (_awayMission->tug.bridgeElasiDrewPhasers)
return;
_awayMission->tug.bridgeElasiDrewPhasers = true;
// If brig guards are alive & untied, kill the hostages
if (_awayMission->tug.guard1Status == 0 || _awayMission->tug.guard2Status == 0) {
showText(TX_SPEAKER_ELASI_CLANSMAN, 81, true, true);
_awayMission->tug.missionScore = 0;
}
if (_awayMission->timers[0] == 0)
_awayMission->timers[0] = 10;
// Make all elasi draw their phasers
if (_awayMission->tug.bridgeElasi1Status == 0)
loadActorAnim2(OBJECT_ELASI_1, "p1draw", -1, -1, 0);
if (_awayMission->tug.bridgeElasi2Status == 0)
loadActorAnim2(OBJECT_ELASI_2, "p2draw", -1, -1, 0);
if (_awayMission->tug.bridgeElasi3Status == 0)
loadActorAnim2(OBJECT_ELASI_3, "p3draw", -1, -1, 0);
if (_awayMission->tug.bridgeElasi4Status == 0)
loadActorAnim2(OBJECT_ELASI_4, "p4draw", -1, -1, 0);
}
void Room::tug3UseStunPhaserOnElasi1() {
if (_awayMission->tug.crewmanKilled[OBJECT_KIRK] || _awayMission->tug.bridgeElasi1Status != GUARDSTAT_UP)
return;
loadActorAnim2(OBJECT_ELASI_1, "p1stun", -1, -1, 12);
playSoundEffectIndex(SND_PHASSHOT);
showBitmapFor5Ticks("t3beem05", 5);
_awayMission->tug.bridgeElasi1Status = GUARDSTAT_STUNNED;
tug3ElasiDrawPhasers();
}
void Room::tug3UseStunPhaserOnElasi2() {
if (_awayMission->tug.crewmanKilled[OBJECT_KIRK] || _awayMission->tug.bridgeElasi2Status != GUARDSTAT_UP)
return;
loadActorAnim2(OBJECT_ELASI_2, "p2stun", -1, -1, 12);
playSoundEffectIndex(SND_PHASSHOT);
showBitmapFor5Ticks("t3beem06", 5);
_awayMission->tug.bridgeElasi2Status = GUARDSTAT_STUNNED;
tug3ElasiDrawPhasers();
}
void Room::tug3UseStunPhaserOnElasi3() {
if (_awayMission->tug.crewmanKilled[OBJECT_KIRK] || _awayMission->tug.bridgeElasi3Status != GUARDSTAT_UP)
return;
loadActorAnim2(OBJECT_ELASI_3, "p3stun", -1, -1, 12);
playSoundEffectIndex(SND_PHASSHOT);
showBitmapFor5Ticks("t3beem07", 5);
_awayMission->tug.bridgeElasi3Status = GUARDSTAT_STUNNED;
tug3ElasiDrawPhasers();
}
void Room::tug3UseStunPhaserOnElasi4() {
if (_awayMission->tug.crewmanKilled[OBJECT_KIRK] || _awayMission->tug.bridgeElasi4Status != GUARDSTAT_UP)
return;
loadActorAnim2(OBJECT_ELASI_4, "p4stun", -1, -1, 12);
playSoundEffectIndex(SND_PHASSHOT);
showBitmapFor5Ticks("t3beem04", 5);
_awayMission->tug.bridgeElasi4Status = GUARDSTAT_STUNNED;
tug3ElasiDrawPhasers();
}
void Room::tug3UseKillPhaserOnElasi1() {
if (_awayMission->tug.crewmanKilled[OBJECT_KIRK] || _awayMission->tug.bridgeElasi1Status != GUARDSTAT_UP)
return;
loadActorAnim2(OBJECT_ELASI_1, "p1Kill", -1, -1, 12);
playSoundEffectIndex(SND_PHASSHOT);
showBitmapFor5Ticks("t3beem25", 5);
_awayMission->tug.bridgeElasi1Status = GUARDSTAT_DEAD;
_awayMission->tug.missionScore -= 2;
tug3ElasiDrawPhasers();
}
void Room::tug3UseKillPhaserOnElasi2() {
if (_awayMission->tug.crewmanKilled[OBJECT_KIRK] || _awayMission->tug.bridgeElasi2Status != GUARDSTAT_UP)
return;
loadActorAnim2(OBJECT_ELASI_2, "p2Kill", -1, -1, 12);
playSoundEffectIndex(SND_PHASSHOT);
showBitmapFor5Ticks("t3beem27", 5);
_awayMission->tug.bridgeElasi2Status = GUARDSTAT_DEAD;
_awayMission->tug.missionScore -= 2;
tug3ElasiDrawPhasers();
}
void Room::tug3UseKillPhaserOnElasi3() {
if (_awayMission->tug.crewmanKilled[OBJECT_KIRK] || _awayMission->tug.bridgeElasi3Status != GUARDSTAT_UP)
return;
loadActorAnim2(OBJECT_ELASI_3, "p3Kill", -1, -1, 12);
playSoundEffectIndex(SND_PHASSHOT);
showBitmapFor5Ticks("t3beem26", 5);
_awayMission->tug.bridgeElasi3Status = GUARDSTAT_DEAD;
_awayMission->tug.missionScore -= 2;
tug3ElasiDrawPhasers();
}
void Room::tug3UseKillPhaserOnElasi4() {
if (_awayMission->tug.crewmanKilled[OBJECT_KIRK] || _awayMission->tug.bridgeElasi4Status != GUARDSTAT_UP)
return;
loadActorAnim2(OBJECT_ELASI_4, "p4Kill", -1, -1, 12);
playSoundEffectIndex(SND_PHASSHOT);
showBitmapFor5Ticks("t3beem24", 5);
_awayMission->tug.bridgeElasi4Status = GUARDSTAT_DEAD;
_awayMission->tug.missionScore -= 2;
tug3ElasiDrawPhasers();
}
void Room::tug3ElasiStunnedOrKilled() {
if (_awayMission->tug.bridgeWinMethod == 1)
return;
if (_awayMission->tug.bridgeElasi1Status == GUARDSTAT_UP || _awayMission->tug.bridgeElasi2Status == GUARDSTAT_UP
|| _awayMission->tug.bridgeElasi3Status == GUARDSTAT_UP || _awayMission->tug.bridgeElasi4Status == GUARDSTAT_UP)
return;
// BUGFIX: if the ship is deorbiting, the mission isn't won yet.
if (_awayMission->tug.orbitalDecayCounter != 0)
return;
_awayMission->tug.bridgeWinMethod = 1;
tug3EndMission();
}
void Room::tug3TalkToElasi1() {
if (_awayMission->tug.bridgeElasi1Status != GUARDSTAT_UP || _awayMission->tug.talkedToCereth)
return;
_awayMission->tug.talkedToCereth = true;
const TextRef choices[] = {
TX_SPEAKER_KIRK,
4,
3,
2,
TX_BLANK
};
int choice = showMultipleTexts(choices, true);
switch (choice) {
case 0: // They surrender
showText(TX_SPEAKER_ELASI_CERETH, 84, true, true);
_awayMission->tug.bridgeElasi1Status = GUARDSTAT_SURRENDERED;
loadActorAnim2(OBJECT_ELASI_1, "p1surr", -1, -1, 0);
tug3ElasiSurrendered();
_awayMission->tug.bridgeWinMethod = 2;
_awayMission->tug.missionScore += 8;
tug3EndMission();
break;
case 1: // Cereth shoots console, doesn't surrender
_awayMission->disableInput = true;
showText(TX_SPEAKER_ELASI_CERETH, 27 + FOLLOWUP_MESSAGE_OFFSET, true);
loadActorAnim2(OBJECT_ELASI_1, "p1draw", -1, -1, 3);
break;
case 2: // Cereth shoots console and surrenders
_awayMission->disableInput = true;
showText(TX_SPEAKER_ELASI_CERETH, 83, true, true);
loadActorAnim2(OBJECT_ELASI_1, "p1draw", -1, -1, 5);
// BUGFIX: they're going to surrender, so stop the firefight.
_awayMission->timers[0] = 0;
break;
}
}
void Room::tug3Elasi1DrewPhaser() {
playSoundEffectIndex(SND_PHASSHOT);
showBitmapFor5Ticks("t3beem41", 13);
playSoundEffectIndex(SND_BLANK_16);
loadActorAnim2(OBJECT_12, "sparks", 0xa0, 0xad, 4);
}
void Room::tug3Elasi1ShotConsole() {
tug3ElasiDrawPhasers();
_awayMission->disableInput = false;
_awayMission->tug.bridgeWinMethod = 3;
_awayMission->timers[1] = 10;
}
void Room::tug3Elasi1DrewPhaser2() {
playSoundEffectIndex(SND_PHASSHOT);
showBitmapFor5Ticks("t3beem41", 13);
loadActorAnim2(OBJECT_12, "sparks", 0xa0, 0xad, 6);
}
void Room::tug3Elasi1ShotConsoleAndSurrenders() {
showText(TX_SPEAKER_ELASI_CERETH, 80, true, true);
tug3ElasiSurrendered();
_awayMission->disableInput = false;
_awayMission->tug.bridgeWinMethod = 3;
_awayMission->timers[1] = 10;
}
void Room::tug3LookAtMccoy() {
showDescription(0, true);
}
void Room::tug3LookAtSpock() {
showDescription(2, true);
}
void Room::tug3LookAtRedshirt() {
showDescription(1, true);
}
void Room::tug3LookAtElasi1() {
// BUGFIX: there were two implementations of this function; the first was the same as
// the other 3 elasi, the second was specific to the captain. The second was never
// called in the original game, but it's used here instead for more variety.
// The function itself is changed by checking both if he's stunned or if he's dead,
// instead of just checking if he's stunned.
if (_awayMission->tug.bridgeElasi1Status == GUARDSTAT_STUNNED || _awayMission->tug.bridgeElasi1Status == GUARDSTAT_DEAD)
showDescription(3, true);
else
showDescription(8, true);
}
void Room::tug3LookAtElasi2() {
// BUGFIX: also check if stunned. They can't "glare at the crewmembers" if they're
// unconscious. (applies to below functions too.)
if (_awayMission->tug.bridgeElasi2Status == GUARDSTAT_DEAD || _awayMission->tug.bridgeElasi2Status == GUARDSTAT_STUNNED)
showDescription(4, true);
else
showDescription(5, true);
}
void Room::tug3LookAtElasi3() {
if (_awayMission->tug.bridgeElasi3Status == GUARDSTAT_DEAD || _awayMission->tug.bridgeElasi2Status == GUARDSTAT_STUNNED)
showDescription(4, true);
else
showDescription(5, true);
}
void Room::tug3LookAtElasi4() {
if (_awayMission->tug.bridgeElasi4Status == GUARDSTAT_DEAD || _awayMission->tug.bridgeElasi2Status == GUARDSTAT_STUNNED)
showDescription(4, true);
else
showDescription(5, true);
}
void Room::tug3TalkToMccoy() {
if (_awayMission->tug.orbitalDecayCounter != 0 || _awayMission->tug.bridgeElasi1Status != GUARDSTAT_UP) {
if (_awayMission->tug.orbitalDecayCounter >= 10) {
if (_awayMission->tug.orbitalDecayCounter < 16)
showText(TX_SPEAKER_MCCOY, 11, true);
} else if (_awayMission->tug.orbitalDecayCounter != 0) {
// BUGFIX: original game displays a blank textbox. An appropriate audio file
// exists, but the corresponding text was written from scratch for ScummVM.
// TODO: check if original floppy version has text for this.
showText(TX_SPEAKER_MCCOY, 12, true);
}
} else
showText(TX_SPEAKER_MCCOY, 13, true);
}
void Room::tug3TalkToSpock() {
if (_awayMission->tug.orbitalDecayCounter != 0) {
if (_awayMission->tug.orbitalDecayCounter >= 10) {
if (_awayMission->tug.orbitalDecayCounter < 16)
showText(TX_SPEAKER_SPOCK, 8, true);
} else
showText(TX_SPEAKER_SPOCK, 9, true);
}
}
void Room::tug3TalkToRedshirt() {
showText(TX_SPEAKER_CHRISTENSEN, 3, true, true);
}
void Room::tug3UseCommunicator() {
if (_awayMission->tug.orbitalDecayCounter == 0)
return;
if (_awayMission->tug.orbitalDecayCounter < 10) {
showText(TX_SPEAKER_KIRK, 7, true);
showText(TX_SPEAKER_SULU, 15, true);
showText(TX_SPEAKER_SHIPS_COMPUTER, TX_COMPA180);
_awayMission->timers[1] = 0;
// BUGFIX: if still fighting the elasi, the mission isn't done yet.
_awayMission->tug.orbitalDecayCounter = 0;
if (!_awayMission->tug.elasiSurrendered &&
(_awayMission->tug.bridgeElasi1Status == GUARDSTAT_UP
|| _awayMission->tug.bridgeElasi2Status == GUARDSTAT_UP
|| _awayMission->tug.bridgeElasi3Status == GUARDSTAT_UP
|| _awayMission->tug.bridgeElasi4Status == GUARDSTAT_UP))
return;
tug3EndMission();
} else {
if (_awayMission->tug.orbitalDecayCounter < 16) {
showText(TX_SPEAKER_KIRK, 6, true);
showText(TX_SPEAKER_SCOTT, 7 + SCOTTY_MESSAGE_OFFSET, true);
playMidiMusicTracks(-1, -1);
_awayMission->disableInput = true;
if (_awayMission->tug.missionScore < 0)
_awayMission->tug.missionScore = 0;
endMission(_awayMission->tug.missionScore, _awayMission->tug.field2b, _awayMission->tug.field2d);
}
}
}
// One of the elasi shoots one of the crewmen
void Room::tug3Timer0Expired() {
const char *beamAnims[][4] = {
{ "t3beem33", "t3beem35", "t3beem34", "t3beem32" },
{ "t3beem37", "t3beem39", "t3beem38", "t3beem36" },
{ "t3beem29", "t3beem31", "t3beem30", "t3beem28" },
};
int elasiShooter, elasiTarget;
if (_awayMission->tug.bridgeElasi2Status == GUARDSTAT_UP)
elasiShooter = 0;
else if (_awayMission->tug.bridgeElasi3Status == GUARDSTAT_UP)
elasiShooter = 1;
else if (_awayMission->tug.bridgeElasi4Status == GUARDSTAT_UP)
elasiShooter = 2;
else
return;
if (!_awayMission->tug.crewmanKilled[OBJECT_REDSHIRT]) {
_awayMission->tug.crewmanKilled[OBJECT_REDSHIRT] = 2;
_awayMission->redshirtDead = true;
loadActorAnim2(OBJECT_REDSHIRT, "rkills", -1, -1, 0);
elasiTarget = OBJECT_REDSHIRT;
} else if (!_awayMission->tug.crewmanKilled[OBJECT_KIRK]) {
_awayMission->tug.crewmanKilled[OBJECT_KIRK] = 2;
_awayMission->disableInput = true;
loadActorAnim2(OBJECT_KIRK, "kkills", -1, -1, 0);
elasiTarget = OBJECT_KIRK;
} else if (!_awayMission->tug.crewmanKilled[OBJECT_SPOCK]) {
_awayMission->tug.crewmanKilled[OBJECT_SPOCK] = 2;
loadActorAnim2(OBJECT_SPOCK, "skills", -1, -1, 0);
elasiTarget = OBJECT_SPOCK;
} else if (!_awayMission->tug.crewmanKilled[OBJECT_MCCOY]) {
_awayMission->tug.crewmanKilled[OBJECT_MCCOY] = 2;
loadActorAnim2(OBJECT_MCCOY, "mkills", -1, -1, 13);
elasiTarget = OBJECT_MCCOY;
} else
return;
playSoundEffectIndex(SND_PHASSHOT);
showBitmapFor5Ticks(beamAnims[elasiShooter][elasiTarget], 5);
_awayMission->timers[0] = 50;
}
void Room::tug3AllCrewmenDead() {
playMidiMusicTracks(2, -1);
showGameOverMenu();
}
// "Orbital decay" countdown timer
void Room::tug3Timer1Expired() {
if (_awayMission->tug.orbitalDecayCounter < 10) { // Decay still preventable
showText(TX_SPEAKER_SHIPS_COMPUTER, TX_COMPU182);
_awayMission->timers[1] = 100;
_awayMission->tug.orbitalDecayCounter++;
} else if (_awayMission->tug.orbitalDecayCounter < 16) { // Decay now unavoidable
showText(TX_SPEAKER_SHIPS_COMPUTER, TX_COMPU181);
_awayMission->timers[1] = 100;
_awayMission->tug.orbitalDecayCounter++;
} else { // Game over
showDescription(6, true);
showGameOverMenu();
}
}
void Room::tug3EndMission() {
playMidiMusicTracks(28, -1);
showText(TX_SPEAKER_KIRK, 1, true);
playSoundEffectIndex(SND_TRANSMAT);
loadActorAnim2(OBJECT_13, "rteleb", 0x14, 0xa0, 7);
loadActorAnim2(OBJECT_14, "rteleb", 0x118, 0xa0, 0);
loadActorAnim2(OBJECT_15, "rteleb", 0x96, 0xbe, 0);
}
void Room::tug3SecurityTeamBeamedIn() {
loadActorAnim2(OBJECT_13, "rdrawe", -1, -1, 8);
loadActorAnim2(OBJECT_14, "rdraws", -1, -1, 9);
loadActorAnim2(OBJECT_15, "rfiren", -1, -1, 10);
showText(TX_SPEAKER_KIRK, 5, true);
showText(TX_SPEAKER_SCOTT, 8 + SCOTTY_MESSAGE_OFFSET, true);
playMidiMusicTracks(-1, -1);
_awayMission->disableInput = true;
if (_awayMission->tug.missionScore < 0)
_awayMission->tug.missionScore = 0;
endMission(_awayMission->tug.missionScore, _awayMission->tug.field2b, _awayMission->tug.field2d);
}
}
|