/
avalot.cpp
1755 lines (1509 loc) · 44.2 KB
/
avalot.cpp
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
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* 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.
*
*/
/*
* This code is based on the original source code of Lord Avalot d'Argent version 1.3.
* Copyright (c) 1994-1995 Mike: Mark and Thomas Thurman.
*/
/* AVALOT The kernel of the program. */
#include "avalanche/avalanche.h"
#include "common/random.h"
#include "common/system.h"
#include "common/config-manager.h"
#include "graphics/palette.h"
namespace Avalanche {
// vv Stairs trap.
/* Explanation: $NSEW.
Nibble N: North.
0 = no connection,
2 = (left,) middle(, right) door with left-hand handle,
5 = (left,) middle(, right) door with right-hand handle,
7 = arch,
8 = arch and 1 north of it,
9 = arch and 2 north of it,
D = no connection + WINDOW,
E = no connection + TORCH,
F = recessed door (to Geida's room.)
Nibble S: South.
0 = no connection,
1,2,3 = left, middle, right door.
Nibble E: East.
0 = no connection (wall),
1 = no connection (wall + window),
2 = wall with door,
3 = wall with door and window,
6 = wall with candles,
7 = wall with door and candles,
F = straight-through corridor.
Nibble W: West.
0 = no connection (wall),
1 = no connection (wall + shield),
2 = wall with door,
3 = wall with door and shield,
4 = no connection (window),
5 = wall with door and window,
6 = wall with candles,
7 = wall with door and candles,
F = straight-through corridor. */
const char AvalancheEngine::kSpludwicksOrder[3] = {kObjectOnion, kObjectInk, kObjectMushroom};
const uint16 AvalancheEngine::kNotes[12] = {196, 220, 247, 262, 294, 330, 350, 392, 440, 494, 523, 587};
const TuneType AvalancheEngine::kTune = {
kPitchHigher, kPitchHigher, kPitchLower, kPitchSame, kPitchHigher, kPitchHigher, kPitchLower, kPitchHigher, kPitchHigher, kPitchHigher,
kPitchLower, kPitchHigher, kPitchHigher, kPitchSame, kPitchHigher, kPitchLower, kPitchLower, kPitchLower, kPitchLower, kPitchHigher,
kPitchHigher, kPitchLower, kPitchLower, kPitchLower, kPitchLower, kPitchSame, kPitchLower, kPitchHigher, kPitchSame, kPitchLower, kPitchHigher
};
Room AvalancheEngine::_whereIs[29] = {
// The Lads
kRoomYours, // Avvy
kRoomSpludwicks, // Spludwick
kRoomOutsideYours, // Crapulus
kRoomDucks, // Duck - r__DucksRoom's not defined yet.
kRoomArgentPub, // Malagauche
kRoomRobins, // Friar Tuck.
kRoomDummy, // Robin Hood - can't meet him at the start.
kRoomBrummieRoad, // Cwytalot
kRoomLustiesRoom, // Baron du Lustie.
kRoomOutsideCardiffCastle, // The Duke of Cardiff.
kRoomArgentPub, // Dogfood
kRoomOutsideDucks, // Trader
kRoomArgentPub, // Ibythneth
kRoomAylesOffice, // Ayles
kRoomNottsPub, // Port
kRoomNottsPub, // Spurge
kRoomMusicRoom, // Jacques
kRoomNowhere,
kRoomNowhere,
kRoomNowhere,
kRoomNowhere,
kRoomNowhere,
kRoomNowhere,
kRoomNowhere,
kRoomNowhere,
// The Lasses
kRoomYours, // Arkata
kRoomGeidas, // Geida
kRoomDummy, // nobody allocated here!
kRoomWiseWomans // The Wise Woman.
};
Clock::Clock(AvalancheEngine *vm) {
_vm = vm;
// Magic value to determine if we just created the instance
_oldHour = _oldHourAngle = _oldMinute = 17717;
_hour = _minute = _second = 0;
_hourAngle = 0;
}
void Clock::update() {
TimeDate t;
_vm->_system->getTimeAndDate(t);
_hour = t.tm_hour;
_minute = t.tm_min;
_second = t.tm_sec;
_hourAngle = (_hour % 12) * 30 + _minute / 2;
if (_oldHour != _hour) {
plotHands();
chime();
}
if (_oldMinute != _minute)
plotHands();
if ((_hour == 0) && (_oldHour != 0) && (_oldHour != 17717)) {
Common::String tmpStr = Common::String::format("Good morning!%c%cYes, it's just past " \
"midnight. Are you having an all-night Avvy session? Glad you like the game that much!",
kControlNewLine, kControlNewLine);
_vm->_dialogs->displayText(tmpStr);
}
_oldHour = _hour;
_oldHourAngle = _hourAngle;
_oldMinute = _minute;
}
Common::Point Clock::calcHand(uint16 angle, uint16 length, Color color) {
if (angle > 900) {
return(Common::Point(177, 177));
}
return(_vm->_graphics->drawScreenArc(kCenterX, kCenterY, 449 - angle, 450 - angle, length, color));
}
void Clock::drawHand(const Common::Point &endPoint, Color color) {
if (endPoint.x == 177)
return;
_vm->_graphics->drawScreenLine(kCenterX, kCenterY, endPoint.x, endPoint.y, color);
}
void Clock::plotHands() {
_clockHandHour = calcHand(_oldHourAngle, 14, kColorYellow);
_clockHandMinute = calcHand(_oldMinute * 6, 17, kColorYellow);
drawHand(_clockHandHour, kColorBrown);
drawHand(_clockHandMinute, kColorBrown);
_clockHandHour = calcHand(_hourAngle, 14, kColorBrown);
_clockHandMinute = calcHand(_minute * 6, 17, kColorBrown);
drawHand(_clockHandHour, kColorYellow);
drawHand(_clockHandMinute, kColorYellow);
}
void Clock::chime() {
// Too high - must be first time around
// Mute - skip the sound generation
if ((_oldHour == 17717) || (!_vm->_soundFx))
return;
byte hour = _hour % 12;
if (hour == 0)
hour = 12;
_vm->_graphics->loadMouse(kCurWait);
for (int i = 1; i <= hour; i++) {
for (int j = 1; j <= 3; j++)
_vm->_sound->playNote((i % 3) * 64 + 140 - j * 30, 50 - j * 12);
if (i != hour)
_vm->_system->delayMillis(100);
}
}
void AvalancheEngine::handleKeyDown(Common::Event &event) {
_sound->click();
if ((Common::KEYCODE_F1 <= event.kbd.keycode) && (event.kbd.keycode <= Common::KEYCODE_F15))
_parser->handleFunctionKey(event);
else if ((32 <= event.kbd.ascii) && (event.kbd.ascii <= 128) && (event.kbd.ascii != 47))
_parser->handleInputText(event);
else
switch (event.kbd.keycode) { // We can control Avvy with the numpad as well.
case Common::KEYCODE_KP8:
event.kbd.keycode = Common::KEYCODE_UP;
break;
case Common::KEYCODE_KP2:
event.kbd.keycode = Common::KEYCODE_DOWN;
break;
case Common::KEYCODE_KP6:
event.kbd.keycode = Common::KEYCODE_RIGHT;
break;
case Common::KEYCODE_KP4:
event.kbd.keycode = Common::KEYCODE_LEFT;
break;
case Common::KEYCODE_KP9:
event.kbd.keycode = Common::KEYCODE_PAGEUP;
break;
case Common::KEYCODE_KP3:
event.kbd.keycode = Common::KEYCODE_PAGEDOWN;
break;
case Common::KEYCODE_KP7:
event.kbd.keycode = Common::KEYCODE_HOME;
break;
case Common::KEYCODE_KP1:
event.kbd.keycode = Common::KEYCODE_END;
break;
default:
break;
}
switch (event.kbd.keycode) {
case Common::KEYCODE_UP:
case Common::KEYCODE_DOWN:
case Common::KEYCODE_RIGHT:
case Common::KEYCODE_LEFT:
case Common::KEYCODE_PAGEUP:
case Common::KEYCODE_PAGEDOWN:
case Common::KEYCODE_HOME:
case Common::KEYCODE_END:
case Common::KEYCODE_KP5:
if (_alive && _avvyIsAwake) {
_animation->handleMoveKey(event); // Fallthroughs are intended.
drawDirection();
return;
}
case Common::KEYCODE_BACKSPACE:
_parser->handleBackspace();
break;
case Common::KEYCODE_RETURN:
_parser->handleReturn();
break;
default:
break;
}
drawDirection();
}
void AvalancheEngine::setup() {
init();
_dialogs->reset();
fadeOut();
_graphics->loadDigits();
_parser->_inputTextPos = 0;
_parser->_quote = true;
_animation->resetAnims();
drawToolbar();
_dialogs->setReadyLight(2);
fadeIn();
_parser->_cursorState = false;
_parser->cursorOn();
_animation->_sprites[0]->_speedX = kWalk;
_animation->updateSpeed();
_menu->init();
int16 loadSlot = ConfMan.instance().getInt("save_slot");
if (loadSlot >= 0) {
_thinks = 2; // You always have money.
thinkAbout(kObjectMoney, kThing);
loadGame(loadSlot);
} else {
newGame();
_soundFx = !_soundFx;
fxToggle();
thinkAbout(kObjectMoney, kThing);
_dialogs->displayScrollChain('q', 83); // Info on the game, etc.
}
}
void AvalancheEngine::runAvalot() {
setup();
do {
uint32 beginLoop = _system->getMillis();
updateEvents(); // The event handler.
_clock->update();
_menu->update();
_background->update();
_animation->animLink();
checkClick();
_timer->updateTimer();
_graphics->drawDebugLines();
_graphics->refreshScreen();
uint32 delay = _system->getMillis() - beginLoop;
if (delay <= 55)
_system->delayMillis(55 - delay); // Replaces slowdown(); 55 comes from 18.2 Hz (B Flight).
} while (!_letMeOut && !shouldQuit());
warning("STUB: run()");
_closing->exitGame();
}
void AvalancheEngine::init() {
for (int i = 0; i < 31; i++) {
for (int j = 0; j < 2; j++)
_also[i][j] = nullptr;
}
#if 0
if (_vm->_enhanced->atbios)
atkey = "f1";
else
atkey = "alt-";
#endif
_letMeOut = false;
_currentMouse = 177;
_dropsOk = true;
_mouseText = "";
_cheat = false;
_cp = 0;
_ledStatus = 177;
for (int i = 0; i < 3; i++)
_scoreToDisplay[i] = -1; // Impossible digits.
_holdTheDawn = false;
_graphics->loadMouse(kCurWait);
CursorMan.showMouse(true);
}
/**
* Call a given Verb
* @remarks Originally called 'callverb'
*/
void AvalancheEngine::callVerb(VerbCode id) {
if (id == _parser->kPardon) {
Common::String tmpStr = Common::String::format("The f5 key lets you do a particular action in certain " \
"situations. However, at the moment there is nothing assigned to it. You may press alt-A to see " \
"what the current setting of this key is.");
_dialogs->displayText(tmpStr);
} else
_parser->doVerb(id);
}
/**
* Check is it's possible to give something to Spludwick
* @remarks Originally called 'nextstring'
*/
Common::String AvalancheEngine::readAlsoStringFromFile(Common::File &file) {
Common::String str;
byte length = file.readByte();
for (int i = 0; i < length; i++)
str += file.readByte();
return str;
}
void AvalancheEngine::scram(Common::String &str) {
for (uint i = 0; i < str.size(); i++)
str.setChar(str[i] ^ 177, i);
}
void AvalancheEngine::unScramble() {
for (int i = 0; i < 31; i++) {
for (int j = 0; j < 2; j++) {
if (_also[i][j] != nullptr)
scram(*_also[i][j]);
}
}
scram(_listen);
scram(_flags);
}
void AvalancheEngine::loadAlso(byte num) {
for (int i = 0; i < 31; i++) {
for (int j = 0; j < 2; j++) {
if (_also[i][j] != nullptr) {
delete _also[i][j];
_also[i][j] = nullptr;
}
}
}
Common::String filename;
filename = Common::String::format("also%d.avd", num);
Common::File file;
if (!file.open(filename))
error("AVALANCHE: File not found: %s", filename.c_str());
file.seek(128);
byte alsoNum = file.readByte();
Common::String tmpStr;
for (int i = 0; i <= alsoNum; i++) {
for (int j = 0; j < 2; j++) {
_also[i][j] = new Common::String;
*_also[i][j] = readAlsoStringFromFile(file);
}
tmpStr = Common::String::format("\x9D%s\x9D", _also[i][0]->c_str());
*_also[i][0] = tmpStr;
}
memset(_lines, 0xFF, sizeof(_lines));
_lineNum = file.readByte();
for (int i = 0; i < _lineNum; i++) {
LineType *curLine = &_lines[i];
curLine->_x1 = file.readSint16LE();
curLine->_y1 = file.readSint16LE();
curLine->_x2 = file.readSint16LE();
curLine->_y2 = file.readSint16LE();
curLine->_color = (Color)file.readByte();
}
memset(_peds, 177, sizeof(_peds));
byte pedNum = file.readByte();
for (int i = 0; i < pedNum; i++) {
PedType *curPed = &_peds[i];
curPed->_x = file.readSint16LE();
curPed->_y = file.readSint16LE();
curPed->_direction = (Direction)file.readByte();
}
_fieldNum = file.readByte();
for (int i = 0; i < _fieldNum; i++) {
FieldType *curField = &_fields[i];
curField->_x1 = file.readSint16LE();
curField->_y1 = file.readSint16LE();
curField->_x2 = file.readSint16LE();
curField->_y2 = file.readSint16LE();
}
for (int i = 0; i < 15; i++) {
MagicType *magic = &_magics[i];
magic->_operation = file.readByte();
magic->_data = file.readUint16LE();
}
for (int i = 0; i < 7; i++) {
MagicType *portal = &_portals[i];
portal->_operation = file.readByte();
portal->_data = file.readUint16LE();
}
_flags.clear();
for (int i = 0; i < 26; i++)
_flags += file.readByte();
int16 size = file.readByte();
_listen.clear();
for (int i = 0; i < size; i++)
_listen += file.readByte();
_graphics->clearAlso();
CursorMan.showMouse(false);
for (int i = 0; i < _lineNum; i++) {
// We had to check if the lines are within the borders of the screen.
if ((_lines[i]._x1 >= 0) && (_lines[i]._x1 < kScreenWidth) && (_lines[i]._y1 >= 0) && (_lines[i]._y1 < kScreenHeight)
&& (_lines[i]._x2 >= 0) && (_lines[i]._x2 < kScreenWidth) && (_lines[i]._y2 >= 0) && (_lines[i]._y2 < kScreenHeight))
_graphics->setAlsoLine(_lines[i]._x1, _lines[i]._y1, _lines[i]._x2, _lines[i]._y2, _lines[i]._color);
}
CursorMan.showMouse(true);
file.close();
unScramble();
for (int i = 0; i <= alsoNum; i++) {
tmpStr = Common::String::format(",%s,", _also[i][0]->c_str());
*_also[i][0] = tmpStr;
}
}
void AvalancheEngine::loadRoom(byte num) {
CursorMan.showMouse(false);
Common::String filename = Common::String::format("place%d.avd", num);
Common::File file;
if (!file.open(filename))
error("AVALANCHE: File not found: %s", filename.c_str());
file.seek(146);
if (!_roomnName.empty())
_roomnName.clear();
for (int i = 0; i < 30; i++) {
char actChar = file.readByte();
if ((32 <= actChar) && (actChar <= 126))
_roomnName += actChar;
}
// Compression method byte follows this...
file.seek(177);
_graphics->loadBackground(file);
_graphics->refreshBackground();
file.close();
loadAlso(num);
_background->load(num);
CursorMan.showMouse(true);
}
void AvalancheEngine::findPeople(byte room) {
for (int i = 1; i < 29; i++) {
if (_whereIs[i] == room) {
if (i < 25)
_him = (People)(150 + i);
else
_her = (People)(150 + i);
}
}
}
void AvalancheEngine::exitRoom(byte x) {
_sound->stopSound();
_background->release();
_seeScroll = true; // This stops the trippancy system working over the length of this procedure.
switch (x) {
case kRoomSpludwicks:
_timer->loseTimer(Timer::kReasonAvariciusTalks);
_avariciusTalk = 0;
// He doesn't HAVE to be talking for this to work. It just deletes it IF it exists.
break;
case kRoomBridge:
if (_drawbridgeOpen > 0) {
_drawbridgeOpen = 4; // Fully open.
_timer->loseTimer(Timer::kReasonDrawbridgeFalls);
}
break;
case kRoomOutsideCardiffCastle:
_timer->loseTimer(Timer::kReasonCardiffsurvey);
break;
case kRoomRobins:
_timer->loseTimer(Timer::kReasonGettingTiedUp);
break;
}
_interrogation = 0; // Leaving the room cancels all the questions automatically.
_seeScroll = false; // Now it can work again!
_lastRoom = _room;
if (_room != kRoomMap)
_lastRoomNotMap = _room;
}
/**
* Only when entering a NEW town! Not returning to the last one,
* but choosing another from the map.
* @remarks Originally called 'new_town'
*/
void AvalancheEngine::enterNewTown() {
_menu->setup();
switch (_room) {
case kRoomOutsideNottsPub: // Entry into Nottingham.
if ((_roomCount[kRoomRobins] > 0) && (_beenTiedUp) && (!_takenMushroom))
_mushroomGrowing = true;
break;
case kRoomWiseWomans: // Entry into Argent.
if (_talkedToCrapulus && (!_lustieIsAsleep)) {
_spludwickAtHome = !((_roomCount[kRoomWiseWomans] % 3) == 1);
_crapulusWillTell = !_spludwickAtHome;
} else {
_spludwickAtHome = true;
_crapulusWillTell = false;
}
if (_boxContent == kObjectWine)
_wineState = 3; // Vinegar
break;
default:
break;
}
if ((_room != kRoomOutsideDucks) && (_objects[kObjectOnion - 1]) && !(_onionInVinegar))
_rottenOnion = true; // You're holding the onion
}
void AvalancheEngine::putGeidaAt(byte whichPed, byte ped) {
if (ped == 0)
return;
AnimationType *spr1 = _animation->_sprites[1];
spr1->init(5, false); // load Geida
_animation->appearPed(1, whichPed);
spr1->_callEachStepFl = true;
spr1->_eachStepProc = Animation::kProcGeida;
}
void AvalancheEngine::enterRoom(Room roomId, byte ped) {
_seeScroll = true; // This stops the trippancy system working over the length of this procedure.
findPeople(roomId);
_room = roomId;
if (ped != 0)
_roomCount[roomId]++;
loadRoom(roomId);
if ((_roomCount[roomId] == 0) && (!getFlag('S')))
incScore(1);
_whereIs[kPeopleAvalot - 150] = _room;
if (_geidaFollows)
_whereIs[kPeopleGeida - 150] = roomId;
_roomCycles = 0;
if ((_lastRoom == kRoomMap) && (_lastRoomNotMap != _room))
enterNewTown();
switch (roomId) {
case kRoomYours:
if (_avvyInBed) {
_background->draw(-1, -1, 2);
_graphics->refreshBackground();
_timer->addTimer(100, Timer::kProcArkataShouts, Timer::kReasonArkataShouts);
}
break;
case kRoomOutsideYours:
if (ped > 0) {
AnimationType *spr1 = _animation->_sprites[1];
if (!_talkedToCrapulus) {
_whereIs[kPeopleCrapulus - 150] = kRoomOutsideYours;
spr1->init(8, false); // load Crapulus
if (_roomCount[kRoomOutsideYours] == 1) {
_animation->appearPed(1, 3); // Start on the right-hand side of the screen.
spr1->walkTo(4); // Walks up to greet you.
} else {
_animation->appearPed(1, 4); // Starts where he was before.
spr1->_facingDir = kDirLeft;
}
spr1->_callEachStepFl = true;
spr1->_eachStepProc = Animation::kProcFaceAvvy; // He always faces Avvy.
} else
_whereIs[kPeopleCrapulus - 150] = kRoomNowhere;
if (_crapulusWillTell) {
spr1->init(8, false);
_animation->appearPed(1, 1);
spr1->walkTo(3);
_timer->addTimer(20, Timer::kProcCrapulusSpludOut, Timer::kReasonCrapulusSaysSpludwickOut);
_crapulusWillTell = false;
}
}
break;
case kRoomOutsideSpludwicks:
if ((_roomCount[kRoomOutsideSpludwicks] == 1) && (ped == 1)) {
_timer->addTimer(20, Timer::kProcBang, Timer::kReasonExplosion);
_spludwickAtHome = true;
}
break;
case kRoomSpludwicks:
if (_spludwickAtHome) {
AnimationType *spr1 = _animation->_sprites[1];
if (ped > 0) {
spr1->init(2, false); // load Spludwick
_animation->appearPed(1, 1);
_whereIs[kPeopleSpludwick - 150] = kRoomSpludwicks;
}
spr1->_callEachStepFl = true;
spr1->_eachStepProc = Animation::kProcGeida;
} else
_whereIs[kPeopleSpludwick - 150] = kRoomNowhere;
break;
case kRoomBrummieRoad:
if (_geidaFollows)
putGeidaAt(4, ped);
if (_cwytalotGone) {
_magics[kColorLightred - 1]._operation = kMagicNothing;
_whereIs[kPeopleCwytalot - 150] = kRoomNowhere;
} else if (ped > 0) {
AnimationType *spr1 = _animation->_sprites[1];
spr1->init(4, false); // 4 = Cwytalot
spr1->_callEachStepFl = true;
spr1->_eachStepProc = Animation::kProcFollowAvvyY;
_whereIs[kPeopleCwytalot - 150] = kRoomBrummieRoad;
if (_roomCount[kRoomBrummieRoad] == 1) { // First time here...
_animation->appearPed(1, 1); // He appears on the right of the screen...
spr1->walkTo(3); // ...and he walks up...
} else {
// You've been here before.
_animation->appearPed(1, 3); // He's standing in your way straight away...
spr1->_facingDir = kDirLeft;
}
}
break;
case kRoomArgentRoad:
if ((_cwytalotGone) && (!_passedCwytalotInHerts) && (ped == 2) && (_roomCount[kRoomArgentRoad] > 3)) {
AnimationType *spr1 = _animation->_sprites[1];
spr1->init(4, false); // 4 = Cwytalot again
_animation->appearPed(1, 0);
spr1->walkTo(1);
spr1->_vanishIfStill = true;
_passedCwytalotInHerts = true;
// whereis[#157] = r__Nowhere; // can we fit this in?
_timer->addTimer(20, Timer::kProcCwytalotInHerts, Timer::kReasonCwytalotInHerts);
}
break;
case kRoomBridge:
if (_drawbridgeOpen == 4) { // open
_background->draw(-1, -1, 2); // Position of drawbridge
_graphics->refreshBackground();
_magics[kColorGreen - 1]._operation = kMagicNothing; // You may enter the drawbridge.
}
if (_geidaFollows)
putGeidaAt(ped + 2, ped); // load Geida
break;
case kRoomRobins:
if ((ped > 0) && (!_beenTiedUp)) {
// A welcome party... or maybe not...
AnimationType *spr1 = _animation->_sprites[1];
spr1->init(6, false);
_animation->appearPed(1, 1);
spr1->walkTo(2);
_timer->addTimer(36, Timer::kProcGetTiedUp, Timer::kReasonGettingTiedUp);
}
if (_beenTiedUp) {
_whereIs[kPeopleRobinHood - 150] = kRoomNowhere;
_whereIs[kPeopleFriarTuck - 150] = kRoomNowhere;
}
if (_tiedUp)
_background->draw(-1, -1, 1);
if (!_mushroomGrowing)
_background->draw(-1, -1, 2);
_graphics->refreshBackground();
break;
case kRoomOutsideCardiffCastle:
if (ped > 0) {
AnimationType *spr1 = _animation->_sprites[1];
switch (_cardiffQuestionNum) {
case 0 : // You've answered NONE of his questions.
spr1->init(9, false);
_animation->appearPed(1, 1);
spr1->walkTo(2);
_timer->addTimer(47, Timer::kProcCardiffSurvey, Timer::kReasonCardiffsurvey);
break;
case 5 :
_magics[1]._operation = kMagicNothing;
break; // You've answered ALL his questions. => nothing happens.
default: // You've answered SOME of his questions.
spr1->init(9, false);
_animation->appearPed(1, 2);
spr1->_facingDir = kDirRight;
_timer->addTimer(3, Timer::kProcCardiffReturn, Timer::kReasonCardiffsurvey);
}
}
if (_cardiffQuestionNum < 5)
_interrogation = _cardiffQuestionNum;
else
_interrogation = 0;
break;
case kRoomMap:
// You're entering the map.
fadeIn();
if (ped > 0)
_graphics->zoomOut(_peds[ped - 1]._x, _peds[ped - 1]._y);
if ((_objects[kObjectWine - 1]) && (_wineState != 3)) {
_dialogs->displayScrollChain('q', 9); // Don't want to waste the wine!
_objects[kObjectWine - 1] = false;
refreshObjectList();
}
_dialogs->displayScrollChain('q', 69);
break;
case kRoomCatacombs:
if ((ped == 0) || (ped == 3) || (ped == 5) || (ped == 6)) {
switch (ped) {
case 3: // Enter from oubliette
_catacombX = 8;
_catacombY = 4;
break;
case 5: // Enter from du Lustie's
_catacombX = 8;
_catacombY = 7;
break;
case 6: // Enter from Geida's
_catacombX = 4;
_catacombY = 1;
break;
}
_enterCatacombsFromLustiesRoom = true;
_animation->catacombMove(ped);
_enterCatacombsFromLustiesRoom = false;
}
break;
case kRoomArgentPub:
if (_wonNim)
_background->draw(-1, -1, 0); // No lute by the settle.
_malagauche = 0; // Ready to boot Malagauche
if (_givenBadgeToIby) {
_background->draw(-1, -1, 7);
_background->draw(-1, -1, 8);
}
_graphics->refreshBackground();
break;
case kRoomLustiesRoom:
_npcFacing = 1; // du Lustie.
if (_animation->getAvvyClothes() == 0) // Avvy in his normal clothes
_timer->addTimer(3, Timer::kProcCallsGuards, Timer::kReasonDuLustieTalks);
else if (!_enteredLustiesRoomAsMonk) // already
// Presumably, Avvy dressed as a monk.
_timer->addTimer(3, Timer::kProcGreetsMonk, Timer::kReasonDuLustieTalks);
if (_geidaFollows) {
putGeidaAt(4, ped);
if (_lustieIsAsleep) {
_background->draw(-1, -1, 4);
_graphics->refreshBackground();
}
}
break;
case kRoomMusicRoom:
if (_jacquesState > 0) {
_jacquesState = 5;
_background->draw(-1, -1, 1);
_graphics->refreshBackground();
_background->draw(-1, -1, 3);
_magics[kColorBrown - 1]._operation = kMagicNothing;
_whereIs[kPeopleJacques - 150] = kRoomNowhere;
}
if (ped != 0) {
_background->draw(-1, -1, 5);
_graphics->refreshBackground();
_sequence->startMusicRoomSeq();
}
break;
case kRoomOutsideNottsPub:
if (ped == 2) {
_background->draw(-1, -1, 2);
_graphics->refreshBackground();
_sequence->startDuckSeq();
}
break;
case kRoomOutsideArgentPub:
if (ped == 2) {
_background->draw(-1, -1, 5);
_graphics->refreshBackground();
_sequence->startMusicRoomSeq();
}
break;
case kRoomWiseWomans: {
AnimationType *spr1 = _animation->_sprites[1];
spr1->init(11, false);
if ((_roomCount[kRoomWiseWomans] == 1) && (ped > 0)) {
_animation->appearPed(1, 1); // Start on the right-hand side of the screen.
spr1->walkTo(3); // Walks up to greet you.
} else {
_animation->appearPed(1, 3); // Starts where she was before.
spr1->_facingDir = kDirLeft;
}
spr1->_callEachStepFl = true;
spr1->_eachStepProc = Animation::kProcFaceAvvy; // She always faces Avvy.
}
break;
case kRoomInsideCardiffCastle:
if (ped > 0) {
_animation->_sprites[1]->init(10, false); // Define the dart.
_background->draw(-1, -1, 0);
_graphics->refreshBackground();
_sequence->startCardiffSeq2();
} else {
_background->draw(-1, -1, 0);
if (_arrowInTheDoor)
_background->draw(-1, -1, 2);
else
_background->draw(-1, -1, 1);
_graphics->refreshBackground();
}
break;
case kRoomAvvysGarden:
if (ped == 1) {
_background->draw(-1, -1, 1);
_graphics->refreshBackground();
_sequence->startGardenSeq();
}
break;
case kRoomEntranceHall:
case kRoomInsideAbbey:
case kRoomYourHall:
if (ped == 2) {
#if 0
// It was the original:
_celer->show_one(-1, -1, 2);
_sequence->first_show(1);
_sequence->then_show(3);
_sequence->start_to_close();
#endif
_background->draw(-1, -1, 1);
_graphics->refreshBackground();
_sequence->startGardenSeq();
}
break;
case kRoomAylesOffice:
if (_aylesIsAwake)
_background->draw(-1, -1, 1);
_graphics->refreshBackground();
break; // Ayles awake.
case kRoomGeidas:
putGeidaAt(1, ped);
break; // load Geida
case kRoomEastHall:
case kRoomWestHall:
if (_geidaFollows)
putGeidaAt(ped + 1, ped);
break;
case kRoomLusties:
if (_geidaFollows)
putGeidaAt(ped + 5, ped);
break;
case kRoomNottsPub:
if (_sittingInPub)
_background->draw(-1, -1, 2);
_npcFacing = 1; // Port.
break;
case kRoomOutsideDucks:
if (ped == 2) {
// Shut the door
_background->draw(-1, -1, 2);
_graphics->refreshBackground();
_sequence->startDuckSeq();
}
break;
case kRoomDucks:
_npcFacing = 1; // Duck.
break;