8 /* This stuff was broken off as part of an effort to get the main program
9 * to compile without running out of memory. We're called with a number
10 * that says what label the caller wanted to "goto", and we return a
11 * similar label number for the caller to "goto".
14 /* Analyse a verb. Remember what it was, go back for object if second word
15 * unless verb is "say", which snarfs arbitrary second word. */
17 int action(FILE *input, long STARTAT) {
19 case 4000: goto L4000;
20 case 4090: goto L4090;
21 case 5000: goto L5000;
26 game.spk=ACTVERB[VERB];
27 if(WD2 > 0 && VERB != SAY) return(2800);
28 if(VERB == SAY)OBJ=WD2;
29 if(OBJ > 0) goto L4090;
31 /* Analyse an intransitive verb (ie, no object given yet). */
33 switch (VERB-1) { case 0: goto L8010; case 1: return(8000); case 2:
34 return(8000); case 3: goto L8040; case 4: return(2009); case 5: goto L8040;
35 case 6: goto L8070; case 7: goto L8080; case 8: return(8000); case
36 9: return(8000); case 10: return(2011); case 11: goto L9120; case 12:
37 goto L9130; case 13: goto L8140; case 14: goto L9150; case 15:
38 return(8000); case 16: return(8000); case 17: goto L8180; case 18:
39 return(8000); case 19: goto L8200; case 20: return(8000); case 21:
40 goto L9220; case 22: goto L9230; case 23: goto L8240; case 24:
41 goto L8250; case 25: goto L8260; case 26: goto L8270; case 27:
42 return(8000); case 28: return(8000); case 29: goto L8300; case 30:
43 goto L8310; case 31: goto L8320; case 32: goto L8330; case 33:
45 /* TAKE DROP SAY OPEN NOTH LOCK ON OFF WAVE CALM
46 * WALK KILL POUR EAT DRNK RUB TOSS QUIT FIND INVN
47 * FEED FILL BLST SCOR FOO BRF READ BREK WAKE SUSP
48 * RESU FLY LSTN ZZZZ */
51 /* Analyse a transitive verb. */
53 L4090: switch (VERB-1) { case 0: goto L9010; case 1: goto L9020; case 2: goto
54 L9030; case 3: goto L9040; case 4: return(2009); case 5: goto L9040;
55 case 6: goto L9070; case 7: goto L9080; case 8: goto L9090; case
56 9: return(2011); case 10: return(2011); case 11: goto L9120; case 12:
57 goto L9130; case 13: goto L9140; case 14: goto L9150; case 15:
58 goto L9160; case 16: goto L9170; case 17: return(2011); case 18:
59 goto L9190; case 19: goto L9190; case 20: goto L9210; case 21:
60 goto L9220; case 22: goto L9230; case 23: return(2011); case 24:
61 return(2011); case 25: return(2011); case 26: goto L9270; case 27:
62 goto L9280; case 28: goto L9290; case 29: return(2011); case 30:
63 return(2011); case 31: goto L9320; case 32: return(2011); case 33:
65 /* TAKE DROP SAY OPEN NOTH LOCK ON OFF WAVE CALM
66 * WALK KILL POUR EAT DRNK RUB TOSS QUIT FIND INVN
67 * FEED FILL BLST SCOR FOO BRF READ BREK WAKE SUSP
68 * RESU FLY LSTN ZZZZ */
71 /* Analyse an object word. See if the thing is here, whether we've got a verb
72 * yet, and so on. Object must be here unless verb is "find" or "invent(ory)"
73 * (and no new verb yet to be analysed). Water and oil are also funny, since
74 * they are never actually dropped at any location, but might be here inside
75 * the bottle or urn or as a feature of the location. */
78 if(!HERE(K)) goto L5100;
79 L5010: if(WD2 > 0) return(2800);
80 if(VERB != 0) goto L4090;
85 L5100: if(K != GRATE) goto L5110;
86 if(LOC == 1 || LOC == 4 || LOC == 7)K=DPRSSN;
87 if(LOC > 9 && LOC < 15)K=ENTRNC;
88 if(K != GRATE) return(8);
89 L5110: if(K == DWARF && ATDWRF(LOC) > 0) goto L5010;
90 if((LIQ(0) == K && HERE(BOTTLE)) || K == LIQLOC(LOC)) goto L5010;
91 if(OBJ != OIL || !HERE(URN) || PROP[URN] == 0) goto L5120;
94 L5120: if(OBJ != PLANT || !AT(PLANT2) || PROP[PLANT2] == 0) goto L5130;
97 L5130: if(OBJ != KNIFE || game.knfloc != LOC) goto L5140;
101 L5140: if(OBJ != ROD || !HERE(ROD2)) goto L5190;
104 L5190: if((VERB == FIND || VERB == INVENT) && WD2 <= 0) goto L5010;
112 /* Routines for performing the various action verbs */
114 /* Statement numbers in this section are 8000 for intransitive verbs, 9000 for
115 * transitive, plus ten times the verb number. Many intransitive verbs use the
116 * transitive code, and some verbs use code for other verbs, as noted below. */
118 /* Carry, no object given yet. OK if only one object present. */
120 L8010: if(ATLOC[LOC] == 0 || LINK[ATLOC[LOC]] != 0 || ATDWRF(LOC) > 0) return(8000);
123 /* Transitive carry/drop are in separate file. */
125 L9010: return(carry());
126 L9020: return(discard(false));
128 /* SAY. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
130 L9030: SETPRM(1,WD2,WD2X);
131 if(WD2 <= 0)SETPRM(1,WD1,WD1X);
134 if(I == 62 || I == 65 || I == 71 || I == 2025 || I == 2034) goto L9035;
142 /* Lock, unlock, no object given. Assume various things if present. */
145 if(HERE(CLAM))OBJ=CLAM;
146 if(HERE(OYSTER))OBJ=OYSTER;
147 if(AT(DOOR))OBJ=DOOR;
148 if(AT(GRATE))OBJ=GRATE;
149 if(OBJ != 0 && HERE(CHAIN)) return(8000);
150 if(HERE(CHAIN))OBJ=CHAIN;
151 if(OBJ == 0) return(2011);
153 /* Lock, unlock object. Special stuff for opening clam/oyster and for chain. */
155 L9040: if(OBJ == CLAM || OBJ == OYSTER) goto L9046;
156 if(OBJ == DOOR)game.spk=111;
157 if(OBJ == DOOR && PROP[DOOR] == 1)game.spk=54;
158 if(OBJ == CAGE)game.spk=32;
159 if(OBJ == KEYS)game.spk=55;
160 if(OBJ == GRATE || OBJ == CHAIN)game.spk=31;
161 if(game.spk != 31 || !HERE(KEYS)) return(2011);
162 if(OBJ == CHAIN) goto L9048;
163 if(!game.closng) goto L9043;
165 if(!game.panic)game.clock2=15;
169 L9043: K=34+PROP[GRATE];
171 if(VERB == LOCK)PROP[GRATE]=0;
177 if(OBJ == OYSTER)K=1;
179 if(TOTING(OBJ))game.spk=120+K;
180 if(!TOTING(TRIDNT))game.spk=122+K;
181 if(VERB == LOCK)game.spk=61;
182 if(game.spk != 124) return(2011);
189 L9048: if(VERB == LOCK) goto L9049;
191 if(PROP[BEAR] == 0)game.spk=41;
192 if(PROP[CHAIN] == 0)game.spk=37;
193 if(game.spk != 171) return(2011);
196 if(PROP[BEAR] != 3)PROP[BEAR]=2;
197 FIXED[BEAR]=2-PROP[BEAR];
201 if(PROP[CHAIN] != 0)game.spk=34;
202 if(LOC != PLAC[CHAIN])game.spk=173;
203 if(game.spk != 172) return(2011);
205 if(TOTING(CHAIN))DROP(CHAIN,LOC);
209 /* Light. Applicable only to lamp and urn. */
211 L8070: if(HERE(LAMP) && PROP[LAMP] == 0 && game.limit >= 0)OBJ=LAMP;
212 if(HERE(URN) && PROP[URN] == 1)OBJ=OBJ*100+URN;
213 if(OBJ == 0 || OBJ > 100) return(8000);
215 L9070: if(OBJ == URN) goto L9073;
216 if(OBJ != LAMP) return(2011);
218 if(game.limit < 0) return(2011);
221 if(game.wzdark) return(2000);
225 if(PROP[URN] == 0) return(2011);
230 /* Extinguish. Lamp, urn, dragon/volcano (nice try). */
232 L8080: if(HERE(LAMP) && PROP[LAMP] == 1)OBJ=LAMP;
233 if(HERE(URN) && PROP[URN] == 2)OBJ=OBJ*100+URN;
234 if(OBJ == 0 || OBJ > 100) return(8000);
236 L9080: if(OBJ == URN) goto L9083;
237 if(OBJ == LAMP) goto L9086;
238 if(OBJ == DRAGON || OBJ == VOLCAN)game.spk=146;
241 L9083: PROP[URN]=PROP[URN]/2;
247 if(DARK(0))RSPEAK(16);
250 /* Wave. No effect unless waving rod at fissure or at bird. */
252 L9090: if((!TOTING(OBJ)) && (OBJ != ROD || !TOTING(ROD2)))game.spk=29;
253 if(OBJ != ROD || !TOTING(OBJ) || (!HERE(BIRD) && (game.closng || !AT(FISSUR))))
255 if(HERE(BIRD))game.spk=206+MOD(PROP[BIRD],2);
256 if(game.spk == 206 && LOC == PLACE[STEPS] && PROP[JADE] < 0) goto L9094;
257 if(game.closed) return(18999);
258 if(game.closng || !AT(FISSUR)) return(2011);
259 if(HERE(BIRD))RSPEAK(game.spk);
260 PROP[FISSUR]=1-PROP[FISSUR];
261 PSPEAK(FISSUR,2-PROP[FISSUR]);
264 L9094: DROP(JADE,LOC);
266 game.tally=game.tally-1;
270 /* Attack also moved into separate module. */
272 L9120: return(attack(input));
274 /* Pour. If no object, or object is bottle, assume contents of bottle.
275 * special tests for pouring water or oil on plant or rusty door. */
277 L9130: if(OBJ == BOTTLE || OBJ == 0)OBJ=LIQ(0);
278 if(OBJ == 0) return(8000);
279 if(!TOTING(OBJ)) return(2011);
281 if(OBJ != OIL && OBJ != WATER) return(2011);
282 if(HERE(URN) && PROP[URN] == 0) goto L9134;
286 if(!(AT(PLANT) || AT(DOOR))) return(2011);
288 if(AT(DOOR)) goto L9132;
290 if(OBJ != WATER) return(2011);
291 PSPEAK(PLANT,PROP[PLANT]+3);
292 PROP[PLANT]=MOD(PROP[PLANT]+1,3);
293 PROP[PLANT2]=PROP[PLANT];
298 if(OBJ == OIL)PROP[DOOR]=1;
299 game.spk=113+PROP[DOOR];
305 /* Eat. Intransitive: assume food if present, else ask what. Transitive: food
306 * ok, some things lose appetite, rest are ridiculous. */
308 L8140: if(!HERE(FOOD)) return(8000);
313 L9140: if(OBJ == FOOD) goto L8142;
314 if(OBJ == BIRD || OBJ == SNAKE || OBJ == CLAM || OBJ == OYSTER || OBJ ==
315 DWARF || OBJ == DRAGON || OBJ == TROLL || OBJ == BEAR || OBJ ==
319 /* Drink. If no object, assume water and look for it here. If water is in
320 * the bottle, drink that, else must be at a water loc, so drink stream. */
322 L9150: if(OBJ == 0 && LIQLOC(LOC) != WATER && (LIQ(0) != WATER || !HERE(BOTTLE)))
324 if(OBJ == BLOOD) goto L9153;
325 if(OBJ != 0 && OBJ != WATER)game.spk=110;
326 if(game.spk == 110 || LIQ(0) != WATER || !HERE(BOTTLE)) return(2011);
332 L9153: DSTROY(BLOOD);
334 OBJSND[BIRD]=OBJSND[BIRD]+3;
338 /* Rub. Yields various snide remarks except for lit urn. */
340 L9160: if(OBJ != LAMP)game.spk=76;
341 if(OBJ != URN || PROP[URN] != 2) return(2011);
345 game.tally=game.tally-1;
350 /* Throw moved into separate module. */
352 L9170: return(throw(input));
354 /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
356 L8180: if(YES(input,22,54,54)) score(1);
359 /* Find. Might be carrying it, or it might be here. Else give caveat. */
361 L9190: if(AT(OBJ) || (LIQ(0) == OBJ && AT(BOTTLE)) || K == LIQLOC(LOC) || (OBJ ==
362 DWARF && ATDWRF(LOC) > 0))game.spk=94;
363 if(game.closed)game.spk=138;
364 if(TOTING(OBJ))game.spk=24;
367 /* Inventory. If object, treat same as find. Else report on current burden. */
370 /* 8201 */ for (I=1; I<=100; I++) {
371 if(I == BEAR || !TOTING(I)) goto L8201;
372 if(game.spk == 98)RSPEAK(99);
379 if(TOTING(BEAR))game.spk=141;
382 /* Feed/fill are in the other module. */
384 L9210: return(feed());
385 L9220: return(fill());
387 /* Blast. No effect unless you've got dynamite, which is a neat trick! */
389 L9230: if(PROP[ROD2] < 0 || !game.closed) return(2011);
391 if(LOC == 115)game.bonus=134;
392 if(HERE(ROD2))game.bonus=135;
396 /* Score. Call scoring routine but tell it to return. */
399 SETPRM(1,SCORE,MXSCOR);
400 SETPRM(3,game.turns,game.turns);
404 /* FEE FIE FOE FOO (AND FUM). ADVANCE TO NEXT STATE IF GIVEN IN PROPER ORDER.
405 * LOOK UP WD1 IN SECTION 3 OF VOCAB TO DETERMINE WHICH WORD WE'VE GOT. LAST
406 * WORD ZIPS THE EGGS BACK TO THE GIANT ROOM (UNLESS ALREADY THERE). */
408 L8250: K=VOCAB(WD1,3);
410 if(game.foobar == 1-K) goto L8252;
411 if(game.foobar != 0)game.spk=151;
414 L8252: game.foobar=K;
415 if(K != 4) return(2009);
417 if(PLACE[EGGS] == PLAC[EGGS] || (TOTING(EGGS) && LOC == PLAC[EGGS]))
419 /* Bring back troll if we steal the eggs back from him before crossing. */
420 if(PLACE[EGGS] == 0 && PLACE[TROLL] == 0 && PROP[TROLL] ==
424 if(LOC == PLAC[EGGS])K=0;
425 MOVE(EGGS,PLAC[EGGS]);
429 /* Brief. Intransitive only. Suppress long descriptions after first time. */
436 /* Read. Print stuff based on objtxt. Oyster (?) is special case. */
438 L8270: for (I=1; I<=100; I++) {
439 if(HERE(I) && OBJTXT[I] != 0 && PROP[I] >= 0)OBJ=OBJ*100+I;
441 if(OBJ > 100 || OBJ == 0 || DARK(0)) return(8000);
443 L9270: if(DARK(0)) goto L5190;
444 if(OBJTXT[OBJ] == 0 || PROP[OBJ] < 0) return(2011);
445 if(OBJ == OYSTER && !game.clshint) goto L9275;
446 PSPEAK(OBJ,OBJTXT[OBJ]+PROP[OBJ]);
449 L9275: game.clshint=YES(input,192,193,54);
452 /* Break. Only works for mirror in repository and, of course, the vase. */
454 L9280: if(OBJ == MIRROR)game.spk=148;
455 if(OBJ == VASE && PROP[VASE] == 0) goto L9282;
456 if(OBJ != MIRROR || !game.closed) return(2011);
461 if(TOTING(VASE))DROP(VASE,LOC);
466 /* Wake. Only use is to disturb the dwarves. */
468 L9290: if(OBJ != DWARF || !game.closed) return(2011);
472 /* Suspend. Offer to save things in a file, but charging some points (so
473 * can't win by using saved games to retry battles or to start over after
474 * learning zzword). */
478 if(!YES(input,200,54,54)) return(2012);
479 game.saved=game.saved+5;
482 /* This next part is shared with the "resume" code. The two cases are
483 * distinguished by the value of kk (-1 for suspend, +1 for resume). */
490 if(K != VRSION) goto L8312;
491 /* Herewith are all the variables whose values can change during a game,
492 * omitting a few (such as I, J, ATTACK) whose values between turns are
493 * irrelevant and some whose values when a game is
494 * suspended or resumed are guaranteed to match. If unsure whether a value
495 * needs to be saved, include it. Overkill can't hurt. Pad the last savwds
496 * with junk variables to bring it up to 7 values. */
497 SAVWDS(game.abbnum,game.blklin,game.bonus,game.clock1,game.clock2,game.closed,game.closng);
498 SAVWDS(game.detail,game.dflag,game.dkill,game.dtotal,game.foobar,game.holdng,game.iwest);
499 SAVWDS(game.knfloc,game.limit,LL,game.lmwarn,LOC,game.newloc,game.numdie);
500 SAVWDS(OBJ,game.oldlc2,game.oldloc,game.oldobj,game.panic,game.saved,game.setup);
501 SAVWDS(game.spk,game.tally,game.thresh,game.trndex,game.trnluz,game.turns,OBJTXT[OYSTER]);
502 SAVWDS(VERB,WD1,WD1X,WD2,game.wzdark,game.zzword,OBJSND[BIRD]);
503 SAVWDS(OBJTXT[SIGN],game.clshint,game.novice,K,K,K,K);
505 SAVARR(ATLOC,LOCSIZ);
507 SAVARR(game.dseen,6);
509 SAVARR(HINTED,HNTSIZ);
510 SAVARR(HINTLC,HNTSIZ);
516 if(K != 0) goto L8318;
518 game.zzword=RNDVOC(3,game.zzword-MESH*2)+MESH*2;
519 if(KK > 0) return(8);
523 /* Resume. Read a suspended game back from a file. */
526 if(LOC == 1 && ABB[1] == 1) goto L8305;
528 if(!YES(input,200,54,54)) return(2012);
531 L8312: SETPRM(1,K/10,MOD(K,10));
532 SETPRM(3,VRSION/10,MOD(VRSION,10));
539 /* Fly. Snide remarks unless hovering rug is here. */
541 L8320: if(PROP[RUG] != 2)game.spk=224;
542 if(!HERE(RUG))game.spk=225;
543 if(game.spk/2 == 112) return(2011);
546 L9320: if(OBJ != RUG) return(2011);
548 if(PROP[RUG] != 2) return(2011);
549 game.oldlc2=game.oldloc;
551 game.newloc=PLACE[RUG]+FIXED[RUG]-LOC;
553 if(PROP[SAPPH] >= 0)game.spk=227;
557 /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
561 if(K == 0) goto L8332;
563 if(K < 0) return(2012);
565 L8332: SETPRM(1,game.zzword-MESH*2,0);
566 /* 8335 */ for (I=1; I<=100; I++) {
567 if(!HERE(I) || OBJSND[I] == 0 || PROP[I] < 0) goto L8335;
568 PSPEAK(I,OBJSND[I]+PROP[I]);
570 if(I == BIRD && OBJSND[I]+PROP[I] == 8)DSTROY(BIRD);
575 /* Z'ZZZ (word gets recomputed at startup; different each game). */
577 L8340: if(!AT(RESER) && LOC != FIXED[RESER]-1) return(2011);
578 PSPEAK(RESER,PROP[RESER]+1);
579 PROP[RESER]=1-PROP[RESER];
580 if(AT(RESER)) return(2012);