2 * The author - Don Woods - apologises for the style of the code; it
3 * is a result of running the original Fortran IV source through a
4 * home-brew Fortran-to-C converter.)
14 long ABB[186], ATAB[331], ATLOC[186],
16 KTAB[331], *LINES, LINK[201], LNLENG, LNPOSN,
17 PARMS[26], PLACE[101], PTEXT[101], RTEXT[278],
18 SETUP = 0, TABSIZ = 330;
19 signed char INLINE[LINESIZE+1], MAP1[129], MAP2[129];
21 long ACTSPK[36], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD,
22 BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2,
23 CLAM, CLSHNT, CLSMAX = 12, CLSSES,
24 COINS, COND[186], CONDS, CTEXT[13], CVAL[13], DALTLC,
25 DOOR, DPRSSN, DRAGON, DSEEN[7], DWARF, EGGS,
26 EMRALD, ENTER, ENTRNC, FIND, FISSUR, FIXD[101], FOOD,
27 GRATE, HINT, HINTED[21], HINTLC[21], HINTS[21][5], HNTMAX,
28 HNTSIZ = 20, I, INVENT, IGO, J, JADE, K, K2, KEY[186], KEYS, KK,
29 KNIFE, KQ, L, LAMP, LINSIZ = 12500, LINUSE, LL,
30 LOC, LOCK, LOCSIZ = 185, LOCSND[186], LOOK, LTEXT[186],
31 MAGZIN, MAXDIE, MAXTRS, MESH = 123456789,
32 MESSAG, MIRROR, MXSCOR,
33 NOVICE, NUGGET, NUL, OBJ, OBJSND[101],
34 OBJTXT[101], ODLOC[7], OGRE, OIL, OLDLC2, OLDLOC, OLDOBJ, OYSTER,
35 PANIC, PEARL, PILLOW, PLAC[101], PLANT, PLANT2, PROP[101], PYRAM,
36 RESER, ROD, ROD2, RTXSIZ = 277, RUBY, RUG, SAPPH, SAVED, SAY,
37 SCORE, SECT, SIGN, SNAKE, SPK, STEPS, STEXT[186], STICK,
38 STREAM, TABNDX, TALLY, THRESH, THROW, TK[21], TRAVEL[886], TRIDNT,
39 TRNDEX, TRNLUZ, TRNSIZ = 5, TRNVAL[6], TRNVLS, TROLL, TROLL2, TRVS,
40 TRVSIZ = 885, TTEXT[6], TURNS, URN, V1, V2, VASE, VEND, VERB,
41 VOLCAN, VRBSIZ = 35, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X,
43 struct game_t game = {.blklin = true};
45 bool oldstyle = false;
47 extern void initialise();
48 extern void score(long);
49 extern int action(FILE *, long);
55 static void do_command(FILE *);
57 int main(int argc, char *argv[]) {
60 /* Adventure (rev 2: 20 treasures) */
62 /* History: Original idea & 5-treasure version (adventures) by Willie Crowther
63 * 15-treasure version (adventure) by Don Woods, April-June 1977
64 * 20-treasure version (rev 2) by Don Woods, August 1978
65 * Errata fixed: 78/12/25 */
70 while ((ch = getopt(argc, argv, "l:o")) != EOF) {
73 logfp = fopen(optarg, "w+");
76 "advent: can't open logfile %s for write\n",
87 * game.closed says whether we're all the way closed
88 * game.closng says whether it's closing time yet
89 * CLSHNT says whether he's read the clue in the endgame
90 * game.lmwarn says whether he's been warned about lamp going dim
91 * NOVICE says whether he asked for instructions at start-up
92 * PANIC says whether he's found out he's trapped in the cave
93 * game.wzdark says whether the loc he's leaving was dark */
97 /* Read the database if we have not yet done so */
99 LINES = (long *)calloc(LINSIZ+1,sizeof(long));
101 printf("Not enough memory!\n");
106 if(!SETUP)initialise();
107 if(SETUP > 0) goto L1;
109 /* Unlike earlier versions, adventure is no longer restartable. (This
110 * lets us get away with modifying things such as OBJSND(BIRD) without
111 * having to be able to undo the changes later.) If a "used" copy is
112 * rerun, we come here and tell the player to run a fresh copy. */
117 /* Start-up, dwarf stuff */
121 ZZWORD=RNDVOC(3,0)+MESH*2;
122 NOVICE=YES(stdin, 65,1,0);
126 if(NOVICE)game.limit=1000;
133 static void do_command(FILE *cmdin) {
135 /* Can't leave cave once it's closing (except by main office). */
137 L2: if(!OUTSID(game.newloc) || game.newloc == 0 || !game.closng) goto L71;
140 if(!PANIC)game.clock2=15;
143 /* See if a dwarf has seen him and has come from where he wants to go. If so,
144 * the dwarf's blocking his way. If coming from place forbidden to pirate
145 * (dwarves rooted in place) let him get out (and attacked). */
147 L71: if(game.newloc == LOC || FORCED(LOC) || CNDBIT(LOC,3)) goto L74;
148 /* 73 */ for (I=1; I<=5; I++) {
149 if(ODLOC[I] != game.newloc || !DSEEN[I]) goto L73;
155 L74: LOC=game.newloc;
157 /* Dwarf stuff. See earlier comments for description of variables. Remember
158 * sixth dwarf is pirate and is thus very different except for motion rules. */
160 /* First off, don't let the dwarves follow him into a pit or a wall. Activate
161 * the whole mess the first time he gets as far as the hall of mists (loc 15).
162 * If game.newloc is forbidden to pirate (in particular, if it's beyond the troll
163 * bridge), bypass dwarf stuff. That way pirate can't steal return toll, and
164 * dwarves can't meet the bear. Also means dwarves won't follow him into dead
165 * end in maze, but c'est la vie. They'll wait for him outside the dead end. */
167 if(LOC == 0 || FORCED(LOC) || CNDBIT(game.newloc,3)) goto L2000;
168 if(game.dflag != 0) goto L6000;
169 if(INDEEP(LOC))game.dflag=1;
172 /* When we encounter the first dwarf, we kill 0, 1, or 2 of the 5 dwarves. If
173 * any of the survivors is at loc, replace him with the alternate. */
175 L6000: if(game.dflag != 1) goto L6010;
176 if(!INDEEP(LOC) || (PCT(95) && (!CNDBIT(LOC,4) || PCT(85)))) goto L2000;
178 for (I=1; I<=2; I++) {
180 if(PCT(50))DLOC[J]=0;
182 for (I=1; I<=5; I++) {
183 if(DLOC[I] == LOC)DLOC[I]=DALTLC;
190 /* Things are in full swing. Move each dwarf at random, except if he's seen us
191 * he sticks with us. Dwarves stay deep inside. If wandering at random,
192 * they don't back up unless there's no alternative. If they don't have to
193 * move, they attack. And, of course, dead dwarves don't do much of anything. */
195 L6010: game.dtotal=0;
198 /* 6030 */ for (I=1; I<=6; I++) {
199 if(DLOC[I] == 0) goto L6030;
200 /* Fill TK array with all the places this dwarf might go. */
204 if(KK == 0) goto L6016;
205 L6012: game.newloc=MOD(IABS(TRAVEL[KK])/1000,1000);
207 if(game.newloc > 300 || !INDEEP(game.newloc) || game.newloc == ODLOC[I] || (J > 1 &&
208 game.newloc == TK[x]) || J >= 20 || game.newloc == DLOC[I] ||
209 FORCED(game.newloc) || (I == 6 && CNDBIT(game.newloc,3)) ||
210 IABS(TRAVEL[KK])/1000000 == 100) goto L6014;}
214 {long x = KK-1; if(TRAVEL[x] >= 0) goto L6012;}
215 L6016: TK[J]=ODLOC[I];
220 DSEEN[I]=(DSEEN[I] && INDEEP(LOC)) || (DLOC[I] == LOC || ODLOC[I] == LOC);
221 if(!DSEEN[I]) goto L6030;
223 if(I != 6) goto L6027;
225 /* The pirate's spotted him. He leaves him alone once we've found chest. K
226 * counts if a treasure is here. If not, and tally=1 for an unseen chest, let
227 * the pirate be spotted. Note that PLACE(CHEST)=0 might mean that he's
228 * thrown it to the troll, but in that case he's seen the chest (PROP=0). */
230 if(LOC == CHLOC || PROP[CHEST] >= 0) goto L6030;
232 /* 6020 */ for (J=50; J<=MAXTRS; J++) {
233 /* Pirate won't take pyramid from plover room or dark room (too easy!). */
234 if(J == PYRAM && (LOC == PLAC[PYRAM] || LOC == PLAC[EMRALD])) goto L6020;
235 if(TOTING(J)) goto L6021;
236 L6020: if(HERE(J))K=1;
238 if(TALLY == 1 && K == 0 && PLACE[CHEST] == 0 && HERE(LAMP) && PROP[LAMP]
240 if(ODLOC[6] != DLOC[6] && PCT(20))RSPEAK(127);
243 L6021: if(PLACE[CHEST] != 0) goto L6022;
244 /* Install chest only once, to insure it is the last treasure in the list. */
248 /* 6023 */ for (J=50; J<=MAXTRS; J++) {
249 if(J == PYRAM && (LOC == PLAC[PYRAM] || LOC == PLAC[EMRALD])) goto L6023;
250 if(AT(J) && FIXED[J] == 0)CARRY(J,LOC);
251 if(TOTING(J))DROP(J,CHLOC);
254 L6024: DLOC[6]=CHLOC;
264 /* This threatening little dwarf is in the room with him! */
266 L6027: game.dtotal=game.dtotal+1;
267 if(ODLOC[I] != DLOC[I]) goto L6030;
269 if(game.knfloc >= 0)game.knfloc=LOC;
270 if(RAN(1000) < 95*(game.dflag-2))STICK=STICK+1;
274 /* Now we know what's happening. Let's tell the poor sucker about it.
275 * Note that various of the "knife" messages must have specific relative
276 * positions in the RSPEAK database. */
278 if(game.dtotal == 0) goto L2000;
279 SETPRM(1,game.dtotal,0);
280 RSPEAK(4+1/game.dtotal);
281 if(ATTACK == 0) goto L2000;
282 if(game.dflag == 2)game.dflag=3;
288 RSPEAK(K+1+2/(1+STICK));
289 if(STICK == 0) goto L2000;
298 /* Describe the current location and (maybe) get next command. */
300 /* Print text for current loc. */
302 L2000: if(LOC == 0) goto L99;
304 if(MOD(ABB[LOC],game.abbnum) == 0 || KK == 0)KK=LTEXT[LOC];
305 if(FORCED(LOC) || !DARK(0)) goto L2001;
306 if(game.wzdark && PCT(35)) goto L90;
308 L2001: if(TOTING(BEAR))RSPEAK(141);
311 if(FORCED(LOC)) goto L8;
312 if(LOC == 33 && PCT(25) && !game.closng)RSPEAK(7);
314 /* Print out descriptions of objects at this location. If not closing and
315 * property value is negative, tally off another treasure. Rug is special
316 * case; once seen, its PROP is 1 (dragon on it) till dragon is killed.
317 * Similarly for chain; PROP is initially 1 (locked to bear). These hacks
318 * are because PROP=0 is needed to get full score. */
320 if(DARK(0)) goto L2012;
323 L2004: if(I == 0) goto L2012;
325 if(OBJ > 100)OBJ=OBJ-100;
326 if(OBJ == STEPS && TOTING(NUGGET)) goto L2008;
327 if(PROP[OBJ] >= 0) goto L2006;
328 if(game.closed) goto L2008;
330 if(OBJ == RUG || OBJ == CHAIN)PROP[OBJ]=1;
332 /* Note: There used to be a test here to see whether the player had blown it
333 * so badly that he could never ever see the remaining treasures, and if so
334 * the lamp was zapped to 35 turns. But the tests were too simple-minded;
335 * things like killing the bird before the snake was gone (can never see
336 * jewelry), and doing it "right" was hopeless. E.G., could cross troll
337 * bridge several times, using up all available treasures, breaking vase,
338 * using coins to buy batteries, etc., and eventually never be able to get
339 * across again. If bottle were left on far side, could then never get eggs
340 * or trident, and the effects propagate. So the whole thing was flushed.
341 * anyone who makes such a gross blunder isn't likely to find everything
342 * else anyway (so goes the rationalisation). */
344 if(OBJ == STEPS && LOC == FIXED[STEPS])KK=1;
357 /* Check if this loc is eligible for any hints. If been here long enough,
358 * branch to help section (on later page). Hints all come back here eventually
359 * to finish the loop. Ignore "HINTS" < 4 (special stuff, see database notes).
362 L2600: if(COND[LOC] < CONDS) goto L2603;
363 /* 2602 */ for (HINT=1; HINT<=HNTMAX; HINT++) {
364 if(HINTED[HINT]) goto L2602;
365 if(!CNDBIT(LOC,HINT+10))HINTLC[HINT]= -1;
366 HINTLC[HINT]=HINTLC[HINT]+1;
367 if(HINTLC[HINT] >= HINTS[HINT][1]) goto L40000;
371 /* Kick the random number generator just to add variety to the chase. Also,
372 * if closing time, check for any objects being toted with PROP < 0 and set
373 * the prop to -1-PROP. This way objects won't be described until they've
374 * been picked up and put down separate from their respective piles. Don't
375 * tick game.clock1 unless well into cave (and not at Y2). */
377 L2603: if(!game.closed) goto L2605;
378 if(PROP[OYSTER] < 0 && TOTING(OYSTER))PSPEAK(OYSTER,1);
379 for (I=1; I<=100; I++) {
380 if(TOTING(I) && PROP[I] < 0)PROP[I]= -1-PROP[I];
382 L2605: game.wzdark=DARK(0);
383 if(game.knfloc > 0 && game.knfloc != LOC)game.knfloc=0;
385 GETIN(cmdin, WD1,WD1X,WD2,WD2X);
387 /* Every input, check "game.foobar" flag. If zero, nothing's going on. If pos,
388 * make neg. If neg, he skipped a word, so make it zero. */
390 L2607: game.foobar=(game.foobar>0 ? -game.foobar : 0);
392 if(TURNS != THRESH) goto L2608;
393 SPEAK(TTEXT[TRNDEX]);
394 TRNLUZ=TRNLUZ+TRNVAL[TRNDEX]/100000;
397 if(TRNDEX <= TRNVLS)THRESH=MOD(TRNVAL[TRNDEX],100000)+1;
398 L2608: if(VERB == SAY && WD2 > 0)VERB=0;
399 if(VERB == SAY) goto L4090;
400 if(TALLY == 0 && INDEEP(LOC) && LOC != 33)game.clock1=game.clock1-1;
401 if(game.clock1 == 0) goto L10000;
402 if(game.clock1 < 0)game.clock2=game.clock2-1;
403 if(game.clock2 == 0) goto L11000;
404 if(PROP[LAMP] == 1)game.limit=game.limit-1;
405 if(game.limit <= 30 && HERE(BATTER) && PROP[BATTER] == 0 && HERE(LAMP)) goto
407 if(game.limit == 0) goto L12400;
408 if(game.limit <= 30) goto L12200;
410 if(LIQLOC(LOC) == WATER)K=70;
413 if(V1 == ENTER && (V2 == STREAM || V2 == 1000+WATER)) goto L2010;
414 if(V1 == ENTER && WD2 > 0) goto L2800;
415 if((V1 != 1000+WATER && V1 != 1000+OIL) || (V2 != 1000+PLANT && V2 !=
416 1000+DOOR)) goto L2610;
417 {long x = V2-1000; if(AT(x))WD2=MAKEWD(16152118);}
418 L2610: if(V1 == 1000+CAGE && V2 == 1000+BIRD && HERE(CAGE) &&
419 HERE(BIRD))WD1=MAKEWD(301200308);
420 L2620: if(WD1 != MAKEWD(23051920)) goto L2625;
421 game.iwest=game.iwest+1;
422 if(game.iwest == 10)RSPEAK(17);
423 L2625: if(WD1 != MAKEWD( 715) || WD2 == 0) goto L2630;
425 if(IGO == 10)RSPEAK(276);
426 L2630: I=VOCAB(WD1,-1);
427 if(I == -1) goto L3000;
430 switch (KQ-1) { case 0: goto L8; case 1: goto L5000; case 2: goto L4000;
431 case 3: goto L2010; }
434 /* Get second word for analysis. */
441 /* Gee, I don't understand. */
443 L3000: SETPRM(1,WD1,WD1X);
447 /* Verb and object analysis moved to separate module. */
449 L4000: I=4000; goto Laction;
450 L4090: I=4090; goto Laction;
453 switch (action(cmdin, I)) {
456 case 2000: goto L2000;
457 case 2009: goto L2009;
458 case 2010: goto L2010;
459 case 2011: goto L2011;
460 case 2012: goto L2012;
461 case 2600: goto L2600;
462 case 2607: goto L2607;
463 case 2630: goto L2630;
464 case 2800: goto L2800;
465 case 8000: goto L8000;
466 case 18999: goto L18999;
467 case 19000: goto L19000;
471 /* Random intransitive verbs come here. Clear obj just in case (see "attack").
474 L8000: SETPRM(1,WD1,WD1X);
479 /* Figure out the new location
481 * Given the current location in "LOC", and a motion verb number in "K", put
482 * the new location in "game.newloc". The current loc is saved in "OLDLOC" in case
483 * he wants to retreat. The current OLDLOC is saved in OLDLC2, in case he
484 * dies. (if he does, game.newloc will be limbo, and OLDLOC will be what killed
485 * him, so we need OLDLC2, which is the last place he was safe.) */
491 if(K == BACK) goto L20;
492 if(K == LOOK) goto L30;
493 if(K == CAVE) goto L40;
497 L9: LL=IABS(TRAVEL[KK]);
498 if(MOD(LL,1000) == 1 || MOD(LL,1000) == K) goto L10;
499 if(TRAVEL[KK] < 0) goto L50;
504 L11: game.newloc=LL/1000;
505 K=MOD(game.newloc,100);
506 if(game.newloc <= 300) goto L13;
507 if(PROP[K] != game.newloc/100-3) goto L16;
508 L12: if(TRAVEL[KK] < 0)BUG(25);
510 game.newloc=IABS(TRAVEL[KK])/1000;
511 if(game.newloc == LL) goto L12;
515 L13: if(game.newloc <= 100) goto L14;
516 if(TOTING(K) || (game.newloc > 200 && AT(K))) goto L16;
519 L14: if(game.newloc != 0 && !PCT(game.newloc)) goto L12;
520 L16: game.newloc=MOD(LL,1000);
521 if(game.newloc <= 300) return;
522 if(game.newloc <= 500) goto L30000;
523 RSPEAK(game.newloc-500);
527 /* Special motions come here. Labelling convention: statement numbers NNNXX
528 * (XX=00-99) are used for special case number NNN (NNN=301-500). */
530 L30000: game.newloc=game.newloc-300;
531 switch (game.newloc) { case 1: goto L30100; case 2: goto L30200; case 3: goto
535 /* Travel 301. Plover-alcove passage. Can carry only emerald. Note: travel
536 * table must include "useless" entries going through passage, which can never
537 * be used for actual motion, but can be spotted by "go back". */
539 L30100: game.newloc=99+100-LOC;
540 if(game.holdng == 0 || (game.holdng == 1 && TOTING(EMRALD))) return;
545 /* Travel 302. Plover transport. Drop the emerald (only use special travel if
546 * toting it), so he's forced to use the plover-passage to get it out. Having
547 * dropped it, go back and pretend he wasn't carrying it after all. */
549 L30200: DROP(EMRALD,LOC);
552 /* Travel 303. Troll bridge. Must be done only as special motion so that
553 * dwarves won't wander across and encounter the bear. (They won't follow the
554 * player there because that region is forbidden to the pirate.) If
555 * PROP(TROLL)=1, he's crossed since paying, so step out and block him.
556 * (standard travel entries check for PROP(TROLL)=0.) Special stuff for bear. */
558 L30300: if(PROP[TROLL] != 1) goto L30310;
563 MOVE(TROLL,PLAC[TROLL]);
564 MOVE(TROLL+100,FIXD[TROLL]);
569 L30310: game.newloc=PLAC[TROLL]+FIXD[TROLL]-LOC;
570 if(PROP[TROLL] == 0)PROP[TROLL]=1;
571 if(!TOTING(BEAR)) return;
575 DROP(BEAR,game.newloc);
581 /* End of specials. */
583 /* Handle "go back". Look for verb which goes from LOC to OLDLOC, or to OLDLC2
584 * If OLDLOC has forced-motion. K2 saves entry -> forced loc -> previous loc. */
587 if(FORCED(K))K=OLDLC2;
592 if(CNDBIT(LOC,4))K2=274;
593 if(K2 == 0) goto L21;
597 L21: LL=MOD((IABS(TRAVEL[KK])/1000),1000);
598 if(LL == K) goto L25;
599 if(LL > 300) goto L22;
601 if(FORCED(LL) && MOD((IABS(TRAVEL[J])/1000),1000) == K)K2=KK;
602 L22: if(TRAVEL[KK] < 0) goto L23;
607 if(KK != 0) goto L25;
611 L25: K=MOD(IABS(TRAVEL[KK]),1000);
615 /* Look. Can't give more detail. Pretend it wasn't dark (though it may "now"
616 * be dark) so he won't fall into a pit while staring into the gloom. */
618 L30: if(game.detail < 3)RSPEAK(15);
619 game.detail=game.detail+1;
624 /* Cave. Different messages depending on whether above ground. */
627 if(OUTSID(LOC) && LOC != 8)K=57;
631 /* Non-applicable motion. Various messages depending on word given. */
634 if(K >= 43 && K <= 50)SPK=52;
635 if(K == 29 || K == 30)SPK=52;
636 if(K == 7 || K == 36 || K == 37)SPK=10;
637 if(K == 11 || K == 19)SPK=11;
638 if(VERB == FIND || VERB == INVENT)SPK=59;
639 if(K == 62 || K == 65)SPK=42;
648 /* "You're dead, Jim."
650 * If the current loc is zero, it means the clown got himself killed. We'll
651 * allow this maxdie times. MAXDIE is automatically set based on the number of
652 * snide messages available. Each death results in a message (81, 83, etc.)
653 * which offers reincarnation; if accepted, this results in message 82, 84,
654 * etc. The last time, if he wants another chance, he gets a snide remark as
655 * we exit. When reincarnated, all objects being carried get dropped at OLDLC2
656 * (presumably the last place prior to being killed) without change of props.
657 * the loop runs backwards to assure that the bird is dropped before the cage.
658 * (this kluge could be changed once we're sure all references to bird and cage
659 * are done by keywords.) The lamp is a special case (it wouldn't do to leave
660 * it in the cave). It is turned off and left outside the building (only if he
661 * was carrying it, of course). He himself is left inside the building (and
662 * heaven help him if he tries to xyzzy back into the cave without the lamp!).
663 * OLDLOC is zapped so he can't just "retreat". */
665 /* The easiest way to get killed is to fall into a pit in pitch darkness. */
670 /* Okay, he's dead. Let's get on with it. */
672 L99: if(game.closng) goto L95;
673 game.numdie=game.numdie+1;
674 if(!YES(cmdin,79+game.numdie*2,80+game.numdie*2,54)) score(0);
675 if(game.numdie == MAXDIE) score(0);
678 if(TOTING(LAMP))PROP[LAMP]=0;
679 /* 98 */ for (J=1; J<=100; J++) {
681 if(!TOTING(I)) goto L98;
691 /* He died during closing time. No resurrection. Tally up a death and exit. */
694 game.numdie=game.numdie+1;
702 /* Come here if he's been long enough at required loc(s) for some unused hint.
703 * hint number is in variable "hint". Branch to quick test for additional
704 * conditions, then come back to do neat stuff. Goto 40010 if conditions are
705 * met and we want to offer the hint. Goto 40020 to clear HINTLC back to zero,
706 * 40030 to take no action yet. */
708 L40000: switch (HINT-1) { case 0: goto L40100; case 1: goto L40200; case 2: goto
709 L40300; case 3: goto L40400; case 4: goto L40500; case 5: goto
710 L40600; case 6: goto L40700; case 7: goto L40800; case 8: goto
711 L40900; case 9: goto L41000; }
712 /* CAVE BIRD SNAKE MAZE DARK WITT URN WOODS OGRE
716 L40010: HINTLC[HINT]=0;
717 if(!YES(cmdin,HINTS[HINT][3],0,54)) goto L2602;
718 SETPRM(1,HINTS[HINT][2],HINTS[HINT][2]);
720 HINTED[HINT]=YES(cmdin,175,HINTS[HINT][4],54);
721 if(HINTED[HINT] && game.limit > 30)game.limit=game.limit+30*HINTS[HINT][2];
722 L40020: HINTLC[HINT]=0;
725 /* Now for the quick tests. See database description for one-line notes. */
727 L40100: if(PROP[GRATE] == 0 && !HERE(KEYS)) goto L40010;
730 L40200: if(PLACE[BIRD] == LOC && TOTING(ROD) && OLDOBJ == BIRD) goto L40010;
733 L40300: if(HERE(SNAKE) && !HERE(BIRD)) goto L40010;
736 L40400: if(ATLOC[LOC] == 0 && ATLOC[OLDLOC] == 0 && ATLOC[OLDLC2] == 0 && game.holdng >
740 L40500: if(PROP[EMRALD] != -1 && PROP[PYRAM] == -1) goto L40010;
745 L40700: if(game.dflag == 0) goto L40010;
748 L40800: if(ATLOC[LOC] == 0 && ATLOC[OLDLOC] == 0 && ATLOC[OLDLC2] == 0) goto
752 L40900: I=ATDWRF(LOC);
753 if(I < 0) goto L40020;
754 if(HERE(OGRE) && I == 0) goto L40010;
757 L41000: if(TALLY == 1 && PROP[JADE] < 0) goto L40010;
764 /* Cave closing and scoring */
767 /* These sections handle the closing of the cave. The cave closes "game.clock1"
768 * turns after the last treasure has been located (including the pirate's
769 * chest, which may of course never show up). Note that the treasures need not
770 * have been taken yet, just located. Hence game.clock1 must be large enough to get
771 * out of the cave (it only ticks while inside the cave). When it hits zero,
772 * we branch to 10000 to start closing the cave, and then sit back and wait for
773 * him to try to get out. If he doesn't within game.clock2 turns, we close the
774 * cave; if he does try, we assume he panics, and give him a few additional
775 * turns to get frantic before we close. When game.clock2 hits zero, we branch to
776 * 11000 to transport him into the final puzzle. Note that the puzzle depends
777 * upon all sorts of random things. For instance, there must be no water or
778 * oil, since there are beanstalks which we don't want to be able to water,
779 * since the code can't handle it. Also, we can have no keys, since there is a
780 * grate (having moved the fixed object!) there separating him from all the
781 * treasures. Most of these problems arise from the use of negative prop
782 * numbers to suppress the object descriptions until he's actually moved the
785 /* When the first warning comes, we lock the grate, destroy the bridge, kill
786 * all the dwarves (and the pirate), remove the troll and bear (unless dead),
787 * and set "game.closng" to true. Leave the dragon; too much trouble to move it.
788 * from now until game.clock2 runs out, he cannot unlock the grate, move to any
789 * location outside the cave, or create the bridge. Nor can he be
790 * resurrected if he dies. Note that the snake is already gone, since he got
791 * to the treasure accessible only via the hall of the mountain king. Also, he's
792 * been in giant room (to get eggs), so we can refer to it. Also also, he's
793 * gotten the pearl, so we know the bivalve is an oyster. *And*, the dwarves
794 * must have been activated, since we've found chest. */
796 L10000: PROP[GRATE]=0;
798 for (I=1; I<=6; I++) {
804 MOVE(TROLL2,PLAC[TROLL]);
805 MOVE(TROLL2+100,FIXD[TROLL]);
807 if(PROP[BEAR] != 3)DSTROY(BEAR);
817 /* ONCE HE'S PANICKED, AND game.clock2 HAS RUN OUT, WE COME HERE TO SET UP THE
818 * STORAGE ROOM. THE ROOM HAS TWO LOCS, HARDWIRED AS 115 (NE) AND 116 (SW).
819 * AT THE NE END, WE PLACE EMPTY BOTTLES, A NURSERY OF PLANTS, A BED OF
820 * OYSTERS, A PILE OF LAMPS, RODS WITH STARS, SLEEPING DWARVES, AND HIM. AT
821 * THE SW END WE PLACE GRATE OVER TREASURES, SNAKE PIT, COVEY OF CAGED BIRDS,
822 * MORE RODS, AND PILLOWS. A MIRROR STRETCHES ACROSS ONE WALL. MANY OF THE
823 * OBJECTS COME FROM KNOWN LOCATIONS AND/OR STATES (E.G. THE SNAKE IS KNOWN TO
824 * HAVE BEEN DESTROYED AND NEEDN'T BE CARRIED AWAY FROM ITS OLD "PLACE"),
825 * MAKING THE VARIOUS OBJECTS BE HANDLED DIFFERENTLY. WE ALSO DROP ALL OTHER
826 * OBJECTS HE MIGHT BE CARRYING (LEST HE HAVE SOME WHICH COULD CAUSE TROUBLE,
827 * SUCH AS THE KEYS). WE DESCRIBE THE FLASH OF LIGHT AND TRUNDLE BACK. */
829 L11000: PROP[BOTTLE]=PUT(BOTTLE,115,1);
830 PROP[PLANT]=PUT(PLANT,115,0);
831 PROP[OYSTER]=PUT(OYSTER,115,0);
833 PROP[LAMP]=PUT(LAMP,115,0);
834 PROP[ROD]=PUT(ROD,115,0);
835 PROP[DWARF]=PUT(DWARF,115,0);
840 /* Leave the grate with normal (non-negative) property. Reuse sign. */
844 OBJTXT[SIGN]=OBJTXT[SIGN]+1;
845 PROP[SNAKE]=PUT(SNAKE,116,1);
846 PROP[BIRD]=PUT(BIRD,116,1);
847 PROP[CAGE]=PUT(CAGE,116,0);
848 PROP[ROD2]=PUT(ROD2,116,0);
849 PROP[PILLOW]=PUT(PILLOW,116,0);
851 PROP[MIRROR]=PUT(MIRROR,115,0);
854 for (I=1; I<=100; I++) {
855 if(TOTING(I))DSTROY(I);
862 /* Another way we can force an end to things is by having the lamp give out.
863 * When it gets close, we come here to warn him. We go to 12000 if the lamp
864 * and fresh batteries are here, in which case we replace the batteries and
865 * continue. 12200 is for other cases of lamp dying. 12400 is when it goes
866 * out. Even then, he can explore outside for a while if desired. */
870 if(TOTING(BATTER))DROP(BATTER,LOC);
871 game.limit=game.limit+2500;
875 L12200: if(game.lmwarn || !HERE(LAMP)) goto L19999;
878 if(PLACE[BATTER] == 0)SPK=183;
879 if(PROP[BATTER] == 1)SPK=189;
883 L12400: game.limit= -1;
885 if(HERE(LAMP))RSPEAK(184);
888 /* Oh dear, he's disturbed the dwarves. */