]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - adventure/subr.c
Be more verbose about teleports, and fix a minor problem in autobot mode.
[bsdgames-darwin.git] / adventure / subr.c
1 /* $NetBSD: subr.c,v 1.9 2000/07/03 03:57:39 matt Exp $ */
2
3 /*-
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * The game adventure was originally written in Fortran by Will Crowther
8 * and Don Woods. It was later translated to C and enhanced by Jim
9 * Gillogly. This code is derived from software contributed to Berkeley
10 * by Jim Gillogly at The Rand Corporation.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the University of
23 * California, Berkeley and its contributors.
24 * 4. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 */
40
41 #include <sys/cdefs.h>
42 #ifndef lint
43 #if 0
44 static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 5/31/93";
45 #else
46 __RCSID("$NetBSD: subr.c,v 1.9 2000/07/03 03:57:39 matt Exp $");
47 #endif
48 #endif /* not lint */
49
50 /* Re-coding of advent in C: subroutines from main */
51
52 #include <stdio.h>
53 #include <stdlib.h>
54 #include "hdr.h"
55 #include "extern.h"
56
57 /* Statement functions */
58 int
59 toting(objj)
60 int objj;
61 {
62 if (place[objj] == -1)
63 return (TRUE);
64 else
65 return (FALSE);
66 }
67
68 int
69 here(objj)
70 int objj;
71 {
72 if (place[objj] == loc || toting(objj))
73 return (TRUE);
74 else
75 return (FALSE);
76 }
77
78 int
79 at(objj)
80 int objj;
81 {
82 if (place[objj] == loc || fixed[objj] == loc)
83 return (TRUE);
84 else
85 return (FALSE);
86 }
87
88 int
89 liq2(pbotl)
90 int pbotl;
91 {
92 return ((1 - pbotl) * water + (pbotl / 2) * (water + oil));
93 }
94
95 int
96 liq()
97 {
98 int i;
99 i = prop[bottle];
100 if (i > -1 - i)
101 return (liq2(i));
102 else
103 return (liq2(-1 - i));
104 }
105
106 int
107 liqloc(locc) /* may want to clean this one up a bit */
108 int locc;
109 {
110 int i, j, l;
111 i = cond[locc] / 2;
112 j = ((i * 2) % 8) - 5;
113 l = cond[locc] / 4;
114 l = l % 2;
115 return (liq2(j * l + 1));
116 }
117
118 int
119 bitset(l, n)
120 int l, n;
121 {
122 if (cond[l] & setbit[n])
123 return (TRUE);
124 return (FALSE);
125 }
126
127 int
128 forced(locc)
129 int locc;
130 {
131 if (cond[locc] == 2)
132 return (TRUE);
133 return (FALSE);
134 }
135
136 int
137 dark()
138 {
139 if ((cond[loc] % 2) == 0 && (prop[lamp] == 0 || !here(lamp)))
140 return (TRUE);
141 return (FALSE);
142 }
143
144 int
145 pct(n)
146 int n;
147 {
148 if (ran(100) < n)
149 return (TRUE);
150 return (FALSE);
151 }
152
153
154 int
155 fdwarf()
156 { /* 71 */
157 int i, j;
158 struct travlist *kk;
159
160 if (newloc != loc && !forced(loc) && !bitset(loc, 3)) {
161 for (i = 1; i <= 5; i++) {
162 if (odloc[i] != newloc || !dseen[i])
163 continue;
164 newloc = loc;
165 rspeak(2);
166 break;
167 }
168 }
169 loc = newloc; /* 74 */
170 if (loc == 0 || forced(loc) || bitset(newloc, 3))
171 return (2000);
172 if (dflag == 0) {
173 if (loc >= 15)
174 dflag = 1;
175 return (2000);
176 }
177 if (dflag == 1) { /* 6000 */
178 if (loc < 15 || pct(95))
179 return (2000);
180 dflag = 2;
181 for (i = 1; i <= 2; i++) {
182 j = 1 + ran(5);
183 if (pct(50) && saved == -1)
184 dloc[j] = 0; /* 6001 */
185 }
186 for (i = 1; i <= 5; i++) {
187 if (dloc[i] == loc)
188 dloc[i] = daltlc;
189 odloc[i] = dloc[i]; /* 6002 */
190 }
191 rspeak(3);
192 drop(axe, loc);
193 return (2000);
194 }
195 dtotal = attack = stick = 0; /* 6010 */
196 for (i = 1; i <= 6; i++) { /* loop to 6030 */
197 if (dloc[i] == 0)
198 continue;
199 j = 1;
200 for (kk = travel[dloc[i]]; kk != 0; kk = kk->next) {
201 newloc = kk->tloc;
202 if (newloc > 300 || newloc < 15 || newloc == odloc[i]
203 || (j > 1 && newloc == tk[j - 1]) || j >= 20
204 || newloc == dloc[i] || forced(newloc)
205 || (i == 6 && bitset(newloc, 3))
206 || kk->conditions == 100)
207 continue;
208 tk[j++] = newloc;
209 }
210 tk[j] = odloc[i]; /* 6016 */
211 if (j >= 2)
212 j--;
213 j = 1 + ran(j);
214 odloc[i] = dloc[i];
215 dloc[i] = tk[j];
216 dseen[i] = (dseen[i] && loc >= 15) || (dloc[i] == loc || odloc[i] == loc);
217 if (!dseen[i])
218 continue; /* i.e. goto 6030 */
219 dloc[i] = loc;
220 if (i == 6) { /* pirate's spotted him */
221 if (loc == chloc || prop[chest] >= 0)
222 continue;
223 k = 0;
224 for (j = 50; j <= maxtrs; j++) { /* loop to 6020 */
225 if (j == pyram && (loc == plac[pyram]
226 || loc == plac[emrald]))
227 goto l6020;
228 if (toting(j))
229 goto l6022;
230 l6020: if (here(j))
231 k = 1;
232 } /* 6020 */
233 if (tally == tally2 + 1 && k == 0 && place[chest] == 0
234 && here(lamp) && prop[lamp] == 1)
235 goto l6025;
236 if (odloc[6] != dloc[6] && pct(20))
237 rspeak(127);
238 continue; /* to 6030 */
239 l6022: rspeak(128);
240 if (place[messag] == 0)
241 move(chest, chloc);
242 move(messag, chloc2);
243 for (j = 50; j <= maxtrs; j++) { /* loop to 6023 */
244 if (j == pyram && (loc == plac[pyram]
245 || loc == plac[emrald]))
246 continue;
247 if (at(j) && fixed[j] == 0)
248 carry(j, loc);
249 if (toting(j))
250 drop(j, chloc);
251 }
252 l6024: dloc[6] = odloc[6] = chloc;
253 dseen[6] = FALSE;
254 continue;
255 l6025: rspeak(186);
256 move(chest, chloc);
257 move(messag, chloc2);
258 goto l6024;
259 }
260 dtotal++; /* 6027 */
261 if (odloc[i] != dloc[i])
262 continue;
263 attack++;
264 if (knfloc >= 0)
265 knfloc = loc;
266 if (ran(1000) < 95 * (dflag - 2))
267 stick++;
268 } /* 6030 */
269 if (dtotal == 0)
270 return (2000);
271 if (dtotal != 1) {
272 printf("There are %d threatening little dwarves ", dtotal);
273 printf("in the room with you.\n");
274 } else
275 rspeak(4);
276 if (attack == 0)
277 return (2000);
278 if (dflag == 2)
279 dflag = 3;
280 if (saved != -1)
281 dflag = 20;
282 if (attack != 1) {
283 printf("%d of them throw knives at you!\n", attack);
284 k = 6;
285 l82: if (stick <= 1) { /* 82 */
286 rspeak(k + stick);
287 if (stick == 0)
288 return (2000);
289 } else
290 printf("%d of them get you!\n", stick); /* 83 */
291 oldlc2 = loc;
292 return (99);
293 }
294 rspeak(5);
295 k = 52;
296 goto l82;
297 }
298
299
300 int
301 march()
302 { /* label 8 */
303 int ll1, ll2;
304
305 if ((tkk = travel[newloc = loc]) == 0)
306 bug(26);
307 if (k == null)
308 return (2);
309 if (k == cave) { /* 40 */
310 if (loc < 8)
311 rspeak(57);
312 if (loc >= 8)
313 rspeak(58);
314 return (2);
315 }
316 if (k == look) { /* 30 */
317 if (detail++ < 3)
318 rspeak(15);
319 wzdark = FALSE;
320 abb[loc] = 0;
321 return (2);
322 }
323 if (k == back) { /* 20 */
324 switch (mback()) {
325 case 2:
326 return (2);
327 case 9:
328 goto l9;
329 default:
330 bug(100);
331 }
332 }
333 oldlc2 = oldloc;
334 oldloc = loc;
335 l9:
336 for (; tkk != 0; tkk = tkk->next)
337 if (tkk->tverb == 1 || tkk->tverb == k)
338 break;
339 if (tkk == 0) {
340 badmove();
341 return (2);
342 }
343 l11: ll1 = tkk->conditions; /* 11 */
344 ll2 = tkk->tloc;
345 newloc = ll1; /* newloc=conditions */
346 k = newloc % 100; /* k used for prob */
347 if (newloc <= 300) {
348 if (newloc <= 100) { /* 13 */
349 if (newloc != 0 && !pct(newloc))
350 goto l12; /* 14 */
351 l16: newloc = ll2; /* newloc=location */
352 if (newloc <= 300)
353 return (2);
354 if (newloc <= 500)
355 switch (specials()) { /* to 30000 */
356 case 2:
357 return (2);
358 case 12:
359 goto l12;
360 case 99:
361 return (99);
362 default:
363 bug(101);
364 }
365 rspeak(newloc - 500);
366 newloc = loc;
367 return (2);
368 }
369 if (toting(k) || (newloc > 200 && at(k)))
370 goto l16;
371 goto l12;
372 }
373 if (prop[k] != (newloc / 100) - 3)
374 goto l16; /* newloc still conditions */
375 l12: /* alternative to probability move */
376 for (; tkk != 0; tkk = tkk->next)
377 if (tkk->tloc != ll2 || tkk->conditions != ll1)
378 break;
379 if (tkk == 0)
380 bug(25);
381 goto l11;
382 }
383
384
385
386 int
387 mback()
388 { /* 20 */
389 struct travlist *tk2, *j;
390 int ll;
391 if (forced(k = oldloc))
392 k = oldlc2; /* k=location */
393 oldlc2 = oldloc;
394 oldloc = loc;
395 tk2 = 0;
396 if (k == loc) {
397 rspeak(91);
398 return (2);
399 }
400 for (; tkk != 0; tkk = tkk->next) { /* 21 */
401 ll = tkk->tloc;
402 if (ll == k) {
403 k = tkk->tverb; /* k back to verb */
404 tkk = travel[loc];
405 return (9);
406 }
407 if (ll <= 300) {
408 j = travel[loc];
409 if (forced(ll) && k == j->tloc)
410 tk2 = tkk;
411 }
412 }
413 tkk = tk2; /* 23 */
414 if (tkk != 0) {
415 k = tkk->tverb;
416 tkk = travel[loc];
417 return (9);
418 }
419 rspeak(140);
420 return (2);
421 }
422
423
424 int
425 specials()
426 { /* 30000 */
427 switch (newloc -= 300) {
428 case 1: /* 30100 */
429 newloc = 99 + 100 - loc;
430 if (holdng == 0 || (holdng == 1 && toting(emrald)))
431 return (2);
432 newloc = loc;
433 rspeak(117);
434 return (2);
435 case 2: /* 30200 */
436 drop(emrald, loc);
437 return (12);
438 case 3: /* to 30300 */
439 return (trbridge());
440 default:
441 bug(29);
442 }
443 }
444
445
446 int
447 trbridge()
448 { /* 30300 */
449 if (prop[troll] == 1) {
450 pspeak(troll, 1);
451 prop[troll] = 0;
452 move(troll2, 0);
453 move(troll2 + 100, 0);
454 move(troll, plac[troll]);
455 move(troll + 100, fixd[troll]);
456 juggle(chasm);
457 newloc = loc;
458 return (2);
459 }
460 newloc = plac[troll] + fixd[troll] - loc; /* 30310 */
461 if (prop[troll] == 0)
462 prop[troll] = 1;
463 if (!toting(bear))
464 return (2);
465 rspeak(162);
466 prop[chasm] = 1;
467 prop[troll] = 2;
468 drop(bear, newloc);
469 fixed[bear] = -1;
470 prop[bear] = 3;
471 if (prop[spices] < 0)
472 tally2++;
473 oldlc2 = newloc;
474 return (99);
475 }
476
477
478 void
479 badmove()
480 { /* 20 */
481 spk = 12;
482 if (k >= 43 && k <= 50)
483 spk = 9;
484 if (k == 29 || k == 30)
485 spk = 9;
486 if (k == 7 || k == 36 || k == 37)
487 spk = 10;
488 if (k == 11 || k == 19)
489 spk = 11;
490 if (verb == find || verb == invent)
491 spk = 59;
492 if (k == 62 || k == 65)
493 spk = 42;
494 if (k == 17)
495 spk = 80;
496 rspeak(spk);
497 }
498
499 void
500 bug(n)
501 int n;
502 {
503 printf("Please tell jim@rand.org that fatal bug %d happened.\n", n);
504 exit(1);
505 }
506
507
508 void
509 checkhints()
510 { /* 2600 &c */
511 int hint;
512 for (hint = 4; hint <= hntmax; hint++) {
513 if (hinted[hint])
514 continue;
515 if (!bitset(loc, hint))
516 hintlc[hint] = -1;
517 hintlc[hint]++;
518 if (hintlc[hint] < hints[hint][1])
519 continue;
520 switch (hint) {
521 case 4: /* 40400 */
522 if (prop[grate] == 0 && !here(keys))
523 goto l40010;
524 goto l40020;
525 case 5: /* 40500 */
526 if (here(bird) && toting(rod) && obj == bird)
527 goto l40010;
528 continue; /* i.e. goto l40030 */
529 case 6: /* 40600 */
530 if (here(snake) && !here(bird))
531 goto l40010;
532 goto l40020;
533 case 7: /* 40700 */
534 if (atloc[loc] == 0 && atloc[oldloc] == 0
535 && atloc[oldlc2] == 0 && holdng > 1)
536 goto l40010;
537 goto l40020;
538 case 8: /* 40800 */
539 if (prop[emrald] != -1 && prop[pyram] == -1)
540 goto l40010;
541 goto l40020;
542 case 9:
543 goto l40010; /* 40900 */
544 default:
545 bug(27);
546 }
547 l40010: hintlc[hint] = 0;
548 if (!yes(hints[hint][3], 0, 54))
549 continue;
550 printf("I am prepared to give you a hint, but it will ");
551 printf("cost you %d points.\n", hints[hint][2]);
552 hinted[hint] = yes(175, hints[hint][4], 54);
553 l40020: hintlc[hint] = 0;
554 }
555 }
556
557
558 int
559 trsay()
560 { /* 9030 */
561 int i;
562 if (*wd2 != 0)
563 copystr(wd2, wd1);
564 i = vocab(wd1, -1, 0);
565 if (i == 62 || i == 65 || i == 71 || i == 2025) {
566 *wd2 = 0;
567 obj = 0;
568 return (2630);
569 }
570 printf("\nOkay, \"%s\".\n", wd2);
571 return (2012);
572 }
573
574
575 int
576 trtake()
577 { /* 9010 */
578 if (toting(obj))
579 return (2011); /* 9010 */
580 spk = 25;
581 if (obj == plant && prop[plant] <= 0)
582 spk = 115;
583 if (obj == bear && prop[bear] == 1)
584 spk = 169;
585 if (obj == chain && prop[bear] != 0)
586 spk = 170;
587 if (fixed[obj] != 0)
588 return (2011);
589 if (obj == water || obj == oil) {
590 if (here(bottle) && liq() == obj) {
591 obj = bottle;
592 goto l9017;
593 }
594 obj = bottle;
595 if (toting(bottle) && prop[bottle] == 1)
596 return (9220);
597 if (prop[bottle] != 1)
598 spk = 105;
599 if (!toting(bottle))
600 spk = 104;
601 return (2011);
602 }
603 l9017: if (holdng >= 7) {
604 rspeak(92);
605 return (2012);
606 }
607 if (obj == bird) {
608 if (prop[bird] != 0)
609 goto l9014;
610 if (toting(rod)) {
611 rspeak(26);
612 return (2012);
613 }
614 if (!toting(cage)) { /* 9013 */
615 rspeak(27);
616 return (2012);
617 }
618 prop[bird] = 1; /* 9015 */
619 }
620 l9014: if ((obj == bird || obj == cage) && prop[bird] != 0)
621 carry(bird + cage - obj, loc);
622 carry(obj, loc);
623 k = liq();
624 if (obj == bottle && k != 0)
625 place[k] = -1;
626 return (2009);
627 }
628
629
630 int
631 dropper()
632 { /* 9021 */
633 k = liq();
634 if (k == obj)
635 obj = bottle;
636 if (obj == bottle && k != 0)
637 place[k] = 0;
638 if (obj == cage && prop[bird] != 0)
639 drop(bird, loc);
640 if (obj == bird)
641 prop[bird] = 0;
642 drop(obj, loc);
643 return (2012);
644 }
645
646 int
647 trdrop()
648 { /* 9020 */
649 if (toting(rod2) && obj == rod && !toting(rod))
650 obj = rod2;
651 if (!toting(obj))
652 return (2011);
653 if (obj == bird && here(snake)) {
654 rspeak(30);
655 if (closed)
656 return (19000);
657 dstroy(snake);
658 prop[snake] = 1;
659 return (dropper());
660 }
661 if (obj == coins && here(vend)) { /* 9024 */
662 dstroy(coins);
663 drop(batter, loc);
664 pspeak(batter, 0);
665 return (2012);
666 }
667 if (obj == bird && at(dragon) && prop[dragon] == 0) { /* 9025 */
668 rspeak(154);
669 dstroy(bird);
670 prop[bird] = 0;
671 if (place[snake] == plac[snake])
672 tally2--;
673 return (2012);
674 }
675 if (obj == bear && at(troll)) { /* 9026 */
676 rspeak(163);
677 move(troll, 0);
678 move(troll + 100, 0);
679 move(troll2, plac[troll]);
680 move(troll2 + 100, fixd[troll]);
681 juggle(chasm);
682 prop[troll] = 2;
683 return (dropper());
684 }
685 if (obj != vase || loc == plac[pillow]) { /* 9027 */
686 rspeak(54);
687 return (dropper());
688 }
689 prop[vase] = 2; /* 9028 */
690 if (at(pillow))
691 prop[vase] = 0;
692 pspeak(vase, prop[vase] + 1);
693 if (prop[vase] != 0)
694 fixed[vase] = -1;
695 return (dropper());
696 }
697
698
699 int
700 tropen()
701 { /* 9040 */
702 if (obj == clam || obj == oyster) {
703 k = 0; /* 9046 */
704 if (obj == oyster)
705 k = 1;
706 spk = 124 + k;
707 if (toting(obj))
708 spk = 120 + k;
709 if (!toting(tridnt))
710 spk = 122 + k;
711 if (verb == lock)
712 spk = 61;
713 if (spk != 124)
714 return (2011);
715 dstroy(clam);
716 drop(oyster, loc);
717 drop(pearl, 105);
718 return (2011);
719 }
720 if (obj == door)
721 spk = 111;
722 if (obj == door && prop[door] == 1)
723 spk = 54;
724 if (obj == cage)
725 spk = 32;
726 if (obj == keys)
727 spk = 55;
728 if (obj == grate || obj == chain)
729 spk = 31;
730 if (spk != 31 || !here(keys))
731 return (2011);
732 if (obj == chain) {
733 if (verb == lock) {
734 spk = 172; /* 9049: lock */
735 if (prop[chain] != 0)
736 spk = 34;
737 if (loc != plac[chain])
738 spk = 173;
739 if (spk != 172)
740 return (2011);
741 prop[chain] = 2;
742 if (toting(chain))
743 drop(chain, loc);
744 fixed[chain] = -1;
745 return (2011);
746 }
747 spk = 171;
748 if (prop[bear] == 0)
749 spk = 41;
750 if (prop[chain] == 0)
751 spk = 37;
752 if (spk != 171)
753 return (2011);
754 prop[chain] = 0;
755 fixed[chain] = 0;
756 if (prop[bear] != 3)
757 prop[bear] = 2;
758 fixed[bear] = 2 - prop[bear];
759 return (2011);
760 }
761 if (closng) {
762 k = 130;
763 if (!panic)
764 clock2 = 15;
765 panic = TRUE;
766 return (2010);
767 }
768 k = 34 + prop[grate]; /* 9043 */
769 prop[grate] = 1;
770 if (verb == lock)
771 prop[grate] = 0;
772 k = k + 2 * prop[grate];
773 return (2010);
774 }
775
776
777 int
778 trkill()
779 { /* 9120 */
780 int i;
781 for (i = 1; i <= 5; i++)
782 if (dloc[i] == loc && dflag >= 2)
783 break;
784 if (i == 6)
785 i = 0;
786 if (obj == 0) { /* 9122 */
787 if (i != 0)
788 obj = dwarf;
789 if (here(snake))
790 obj = obj * 100 + snake;
791 if (at(dragon) && prop[dragon] == 0)
792 obj = obj * 100 + dragon;
793 if (at(troll))
794 obj = obj * 100 + troll;
795 if (here(bear) && prop[bear] == 0)
796 obj = obj * 100 + bear;
797 if (obj > 100)
798 return (8000);
799 if (obj == 0) {
800 if (here(bird) && verb != throw)
801 obj = bird;
802 if (here(clam) || here(oyster))
803 obj = 100 * obj + clam;
804 if (obj > 100)
805 return (8000);
806 }
807 }
808 if (obj == bird) { /* 9124 */
809 spk = 137;
810 if (closed)
811 return (2011);
812 dstroy(bird);
813 prop[bird] = 0;
814 if (place[snake] == plac[snake])
815 tally2++;
816 spk = 45;
817 }
818 if (obj == 0)
819 spk = 44; /* 9125 */
820 if (obj == clam || obj == oyster)
821 spk = 150;
822 if (obj == snake)
823 spk = 46;
824 if (obj == dwarf)
825 spk = 49;
826 if (obj == dwarf && closed)
827 return (19000);
828 if (obj == dragon)
829 spk = 147;
830 if (obj == troll)
831 spk = 157;
832 if (obj == bear)
833 spk = 165 + (prop[bear] + 1) / 2;
834 if (obj != dragon || prop[dragon] != 0)
835 return (2011);
836 rspeak(49);
837 verb = 0;
838 obj = 0;
839 getin(&wd1, &wd2);
840 if (!weq(wd1, "y") && !weq(wd1, "yes"))
841 return (2608);
842 pspeak(dragon, 1);
843 prop[dragon] = 2;
844 prop[rug] = 0;
845 k = (plac[dragon] + fixd[dragon]) / 2;
846 move(dragon + 100, -1);
847 move(rug + 100, 0);
848 move(dragon, k);
849 move(rug, k);
850 for (obj = 1; obj <= 100; obj++)
851 if (place[obj] == plac[dragon] || place[obj] == fixd[dragon])
852 move(obj, k);
853 loc = k;
854 k = null;
855 return (8);
856 }
857
858
859 int
860 trtoss()
861 { /* 9170: throw */
862 int i;
863 if (toting(rod2) && obj == rod && !toting(rod))
864 obj = rod2;
865 if (!toting(obj))
866 return (2011);
867 if (obj >= 50 && obj <= maxtrs && at(troll)) {
868 spk = 159; /* 9178 */
869 drop(obj, 0);
870 move(troll, 0);
871 move(troll + 100, 0);
872 drop(troll2, plac[troll]);
873 drop(troll2 + 100, fixd[troll]);
874 juggle(chasm);
875 return (2011);
876 }
877 if (obj == food && here(bear)) {
878 obj = bear; /* 9177 */
879 return (9210);
880 }
881 if (obj != axe)
882 return (9020);
883 for (i = 1; i <= 5; i++) {
884 if (dloc[i] == loc) {
885 spk = 48; /* 9172 */
886 if (ran(3) == 0 || saved != -1)
887 l9175: {
888 rspeak(spk);
889 drop(axe, loc);
890 k = null;
891 return (8);
892 }
893 dseen[i] = FALSE;
894 dloc[i] = 0;
895 spk = 47;
896 dkill++;
897 if (dkill == 1)
898 spk = 149;
899 goto l9175;
900 }
901 }
902 spk = 152;
903 if (at(dragon) && prop[dragon] == 0)
904 goto l9175;
905 spk = 158;
906 if (at(troll))
907 goto l9175;
908 if (here(bear) && prop[bear] == 0) {
909 spk = 164;
910 drop(axe, loc);
911 fixed[axe] = -1;
912 prop[axe] = 1;
913 juggle(bear);
914 return (2011);
915 }
916 obj = 0;
917 return (9120);
918 }
919
920
921 int
922 trfeed()
923 { /* 9210 */
924 if (obj == bird) {
925 spk = 100;
926 return (2011);
927 }
928 if (obj == snake || obj == dragon || obj == troll) {
929 spk = 102;
930 if (obj == dragon && prop[dragon] != 0)
931 spk = 110;
932 if (obj == troll)
933 spk = 182;
934 if (obj != snake || closed || !here(bird))
935 return (2011);
936 spk = 101;
937 dstroy(bird);
938 prop[bird] = 0;
939 tally2++;
940 return (2011);
941 }
942 if (obj == dwarf) {
943 if (!here(food))
944 return (2011);
945 spk = 103;
946 dflag++;
947 return (2011);
948 }
949 if (obj == bear) {
950 if (prop[bear] == 0)
951 spk = 102;
952 if (prop[bear] == 3)
953 spk = 110;
954 if (!here(food))
955 return (2011);
956 dstroy(food);
957 prop[bear] = 1;
958 fixed[axe] = 0;
959 prop[axe] = 0;
960 spk = 168;
961 return (2011);
962 }
963 spk = 14;
964 return (2011);
965 }
966
967
968 int
969 trfill()
970 { /* 9220 */
971 if (obj == vase) {
972 spk = 29;
973 if (liqloc(loc) == 0)
974 spk = 144;
975 if (liqloc(loc) == 0 || !toting(vase))
976 return (2011);
977 rspeak(145);
978 prop[vase] = 2;
979 fixed[vase] = -1;
980 return (9020); /* advent/10 goes to 9024 */
981 }
982 if (obj != 0 && obj != bottle)
983 return (2011);
984 if (obj == 0 && !here(bottle))
985 return (8000);
986 spk = 107;
987 if (liqloc(loc) == 0)
988 spk = 106;
989 if (liq() != 0)
990 spk = 105;
991 if (spk != 107)
992 return (2011);
993 prop[bottle] = ((cond[loc] % 4) / 2) * 2;
994 k = liq();
995 if (toting(bottle))
996 place[k] = -1;
997 if (k == oil)
998 spk = 108;
999 return (2011);
1000 }
1001
1002
1003 void
1004 closing()
1005 { /* 10000 */
1006 int i;
1007
1008 prop[grate] = prop[fissur] = 0;
1009 for (i = 1; i <= 6; i++) {
1010 dseen[i] = FALSE;
1011 dloc[i] = 0;
1012 }
1013 move(troll, 0);
1014 move(troll + 100, 0);
1015 move(troll2, plac[troll]);
1016 move(troll2 + 100, fixd[troll]);
1017 juggle(chasm);
1018 if (prop[bear] != 3)
1019 dstroy(bear);
1020 prop[chain] = 0;
1021 fixed[chain] = 0;
1022 prop[axe] = 0;
1023 fixed[axe] = 0;
1024 rspeak(129);
1025 clock1 = -1;
1026 closng = TRUE;
1027 }
1028
1029
1030 void
1031 caveclose()
1032 { /* 11000 */
1033 int i;
1034 prop[bottle] = put(bottle, 115, 1);
1035 prop[plant] = put(plant, 115, 0);
1036 prop[oyster] = put(oyster, 115, 0);
1037 prop[lamp] = put(lamp, 115, 0);
1038 prop[rod] = put(rod, 115, 0);
1039 prop[dwarf] = put(dwarf, 115, 0);
1040 loc = 115;
1041 oldloc = 115;
1042 newloc = 115;
1043
1044 put(grate, 116, 0);
1045 prop[snake] = put(snake, 116, 1);
1046 prop[bird] = put(bird, 116, 1);
1047 prop[cage] = put(cage, 116, 0);
1048 prop[rod2] = put(rod2, 116, 0);
1049 prop[pillow] = put(pillow, 116, 0);
1050
1051 prop[mirror] = put(mirror, 115, 0);
1052 fixed[mirror] = 116;
1053
1054 for (i = 1; i <= 100; i++)
1055 if (toting(i))
1056 dstroy(i);
1057 rspeak(132);
1058 closed = TRUE;
1059 }