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