]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - adventure/subr.c
WARNSify, KNFify
[bsdgames-darwin.git] / adventure / subr.c
1 /* $NetBSD: subr.c,v 1.4 1997/10/10 11:59:53 lukem 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.4 1997/10/10 11:59:53 lukem 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 { if (place[objj] == -1) return(TRUE);
61 else return(FALSE);
62 }
63
64 int
65 here(objj)
66 int objj;
67 { if (place[objj]==loc || toting(objj)) return(TRUE);
68 else return(FALSE);
69 }
70
71 int
72 at(objj)
73 int objj;
74 { if (place[objj]==loc || fixed[objj]==loc) return(TRUE);
75 else return (FALSE);
76 }
77
78 int
79 liq2(pbotl)
80 int pbotl;
81 { return((1-pbotl)*water+(pbotl/2)*(water+oil));
82 }
83
84 int
85 liq(foo)
86 { int i;
87 i=prop[bottle];
88 if (i>-1-i) return(liq2(i));
89 else return(liq2(-1-i));
90 }
91
92 int
93 liqloc(locc) /* may want to clean this one up a bit */
94 int locc;
95 { int i,j,l;
96 i=cond[locc]/2;
97 j=((i*2)%8)-5;
98 l=cond[locc]/4;
99 l=l%2;
100 return(liq2(j*l+1));
101 }
102
103 int
104 bitset(l,n)
105 int l,n;
106 { if (cond[l] & setbit[n]) return(TRUE);
107 return(FALSE);
108 }
109
110 int
111 forced(locc)
112 int locc;
113 { if (cond[locc]==2) return(TRUE);
114 return(FALSE);
115 }
116
117 int
118 dark(foo)
119 { if ((cond[loc]%2)==0 && (prop[lamp]==0 || !here(lamp)))
120 return(TRUE);
121 return(FALSE);
122 }
123
124 int
125 pct(n)
126 int n;
127 { if (ran(100)<n) return(TRUE);
128 return(FALSE);
129 }
130
131
132 int
133 fdwarf() /* 71 */
134 { int i,j;
135 struct travlist *kk;
136
137 if (newloc!=loc&&!forced(loc)&&!bitset(loc,3))
138 { for (i=1; i<=5; i++)
139 { if (odloc[i]!=newloc||!dseen[i]) continue;
140 newloc=loc;
141 rspeak(2);
142 break;
143 }
144 }
145 loc=newloc; /* 74 */
146 if (loc==0||forced(loc)||bitset(newloc,3)) return(2000);
147 if (dflag==0)
148 { if (loc>=15) dflag=1;
149 return(2000);
150 }
151 if (dflag==1) /* 6000 */
152 { if (loc<15||pct(95)) return(2000);
153 dflag=2;
154 for (i=1; i<=2; i++)
155 { j=1+ran(5);
156 if (pct(50)&&saved== -1) dloc[j]=0; /* 6001 */
157 }
158 for (i=1; i<=5; i++)
159 { if (dloc[i]==loc) dloc[i]=daltlc;
160 odloc[i]=dloc[i]; /* 6002 */
161 }
162 rspeak(3);
163 drop(axe,loc);
164 return(2000);
165 }
166 dtotal=attack=stick=0; /* 6010 */
167 for (i=1; i<=6; i++) /* loop to 6030 */
168 { if (dloc[i]==0) continue;
169 j=1;
170 for (kk=travel[dloc[i]]; kk!=0; kk=kk->next)
171 { newloc=kk->tloc;
172 if (newloc>300||newloc<15||newloc==odloc[i]
173 ||(j>1&&newloc==tk[j-1])||j>=20
174 ||newloc==dloc[i]||forced(newloc)
175 ||(i==6&&bitset(newloc,3))
176 ||kk->conditions==100) continue;
177 tk[j++]=newloc;
178 }
179 tk[j]=odloc[i]; /* 6016 */
180 if (j>=2) j--;
181 j=1+ran(j);
182 odloc[i]=dloc[i];
183 dloc[i]=tk[j];
184 dseen[i]=(dseen[i]&&loc>=15)||(dloc[i]==loc||odloc[i]==loc);
185 if (!dseen[i]) continue; /* i.e. goto 6030 */
186 dloc[i]=loc;
187 if (i==6) /* pirate's spotted him */
188 { if (loc==chloc||prop[chest]>=0) continue;
189 k=0;
190 for (j=50; j<=maxtrs; j++) /* loop to 6020 */
191 { if (j==pyram&&(loc==plac[pyram]
192 || loc==plac[emrald])) goto l6020;
193 if (toting(j)) goto l6022;
194 l6020: if (here(j)) k=1;
195 } /* 6020 */
196 if (tally==tally2+1 && k==0 && place[chest]==0
197 &&here(lamp) && prop[lamp]==1) goto l6025;
198 if (odloc[6]!=dloc[6]&&pct(20))
199 rspeak(127);
200 continue; /* to 6030 */
201 l6022: rspeak(128);
202 if (place[messag]==0) move(chest,chloc);
203 move(messag,chloc2);
204 for (j=50; j<=maxtrs; j++) /* loop to 6023 */
205 { if (j==pyram && (loc==plac[pyram]
206 || loc==plac[emrald])) continue;
207 if (at(j)&&fixed[j]==0) carry(j,loc);
208 if (toting(j)) drop(j,chloc);
209 }
210 l6024: dloc[6]=odloc[6]=chloc;
211 dseen[6]=FALSE;
212 continue;
213 l6025: rspeak(186);
214 move(chest,chloc);
215 move(messag,chloc2);
216 goto l6024;
217 }
218 dtotal++; /* 6027 */
219 if (odloc[i]!=dloc[i]) continue;
220 attack++;
221 if (knfloc>=0) knfloc=loc;
222 if (ran(1000)<95*(dflag-2)) stick++;
223 } /* 6030 */
224 if (dtotal==0) return(2000);
225 if (dtotal!=1)
226 { printf("There are %d threatening little dwarves ",dtotal);
227 printf("in the room with you.\n");
228 }
229 else rspeak(4);
230 if (attack==0) return(2000);
231 if (dflag==2) dflag=3;
232 if (saved!= -1) dflag=20;
233 if (attack!=1)
234 { printf("%d of them throw knives at you!\n",attack);
235 k=6;
236 l82: if (stick<=1) /* 82 */
237 { rspeak(k+stick);
238 if (stick==0) return(2000);
239 }
240 else
241 printf("%d of them get you!\n",stick); /* 83 */
242 oldlc2=loc;
243 return(99);
244 }
245 rspeak(5);
246 k=52;
247 goto l82;
248 }
249
250
251 int
252 march() /* label 8 */
253 { int ll1,ll2;
254
255 if ((tkk=travel[newloc=loc])==0) bug(26);
256 if (k==null) return(2);
257 if (k==cave) /* 40 */
258 { if (loc<8) rspeak(57);
259 if (loc>=8) rspeak(58);
260 return(2);
261 }
262 if (k==look) /* 30 */
263 { if (detail++<3) rspeak(15);
264 wzdark=FALSE;
265 abb[loc]=0;
266 return(2);
267 }
268 if (k==back) /* 20 */
269 { switch(mback())
270 { case 2: return(2);
271 case 9: goto l9;
272 default: bug(100);
273 }
274 }
275 oldlc2=oldloc;
276 oldloc=loc;
277 l9:
278 for (; tkk!=0; tkk=tkk->next)
279 if (tkk->tverb==1 || tkk->tverb==k) break;
280 if (tkk==0)
281 { badmove();
282 return(2);
283 }
284 l11: ll1=tkk->conditions; /* 11 */
285 ll2=tkk->tloc;
286 newloc=ll1; /* newloc=conditions */
287 k=newloc%100; /* k used for prob */
288 if (newloc<=300)
289 { if (newloc<=100) /* 13 */
290 { if (newloc!=0&&!pct(newloc)) goto l12; /* 14 */
291 l16: newloc=ll2; /* newloc=location */
292 if (newloc<=300) return(2);
293 if (newloc<=500)
294 switch(specials())/* to 30000 */
295 { case 2: return(2);
296 case 12: goto l12;
297 case 99: return(99);
298 default: bug(101);
299 }
300 rspeak(newloc-500);
301 newloc=loc;
302 return(2);
303 }
304 if (toting(k)||(newloc>200&&at(k))) goto l16;
305 goto l12;
306 }
307 if (prop[k]!=(newloc/100)-3) goto l16; /* newloc still conditions*/
308 l12: /* alternative to probability move */
309 for (; tkk!=0; tkk=tkk->next)
310 if (tkk->tloc!=ll2 || tkk->conditions!=ll1) break;
311 if (tkk==0) bug(25);
312 goto l11;
313 }
314
315
316
317 int
318 mback() /* 20 */
319 { struct travlist *tk2,*j;
320 int ll;
321 if (forced(k=oldloc)) k=oldlc2; /* k=location */
322 oldlc2=oldloc;
323 oldloc=loc;
324 tk2=0;
325 if (k==loc)
326 { rspeak(91);
327 return(2);
328 }
329 for (; tkk!=0; tkk=tkk->next) /* 21 */
330 { ll=tkk->tloc;
331 if (ll==k)
332 { k=tkk->tverb; /* k back to verb */
333 tkk=travel[loc];
334 return(9);
335 }
336 if (ll<=300)
337 { j=travel[loc];
338 if (forced(ll) && k==j->tloc) tk2=tkk;
339 }
340 }
341 tkk=tk2; /* 23 */
342 if (tkk!=0)
343 { k=tkk->tverb;
344 tkk=travel[loc];
345 return(9);
346 }
347 rspeak(140);
348 return(2);
349 }
350
351
352 int
353 specials() /* 30000 */
354 { switch(newloc -= 300)
355 { case 1: /* 30100 */
356 newloc = 99+100-loc;
357 if (holdng==0||(holdng==1&&toting(emrald))) return(2);
358 newloc=loc;
359 rspeak(117);
360 return(2);
361 case 2: /* 30200 */
362 drop(emrald,loc);
363 return(12);
364 case 3: /* to 30300 */
365 return(trbridge());
366 default: bug(29);
367 }
368 }
369
370
371 int
372 trbridge() /* 30300 */
373 { if (prop[troll]==1)
374 { pspeak(troll,1);
375 prop[troll]=0;
376 move(troll2,0);
377 move(troll2+100,0);
378 move(troll,plac[troll]);
379 move(troll+100,fixd[troll]);
380 juggle(chasm);
381 newloc=loc;
382 return(2);
383 }
384 newloc=plac[troll]+fixd[troll]-loc; /* 30310 */
385 if (prop[troll]==0) prop[troll]=1;
386 if (!toting(bear)) return(2);
387 rspeak(162);
388 prop[chasm]=1;
389 prop[troll]=2;
390 drop(bear,newloc);
391 fixed[bear] = -1;
392 prop[bear]=3;
393 if (prop[spices]<0) tally2++;
394 oldlc2=newloc;
395 return(99);
396 }
397
398
399 int
400 badmove() /* 20 */
401 { spk=12;
402 if (k>=43 && k<=50) spk=9;
403 if (k==29||k==30) spk=9;
404 if (k==7||k==36||k==37) spk=10;
405 if (k==11||k==19) spk=11;
406 if (verb==find||verb==invent) spk=59;
407 if (k==62||k==65) spk=42;
408 if (k==17) spk=80;
409 rspeak(spk);
410 return(2);
411 }
412
413 int
414 bug(n)
415 int n;
416 { printf("Please tell jim@rand.org that fatal bug %d happened.\n",n);
417 exit(0);
418 }
419
420
421 int
422 checkhints() /* 2600 &c */
423 { int hint;
424 for (hint=4; hint<=hntmax; hint++)
425 { if (hinted[hint]) continue;
426 if (!bitset(loc,hint)) hintlc[hint]= -1;
427 hintlc[hint]++;
428 if (hintlc[hint]<hints[hint][1]) continue;
429 switch(hint)
430 { case 4: /* 40400 */
431 if (prop[grate]==0&&!here(keys)) goto l40010;
432 goto l40020;
433 case 5: /* 40500 */
434 if (here(bird)&&toting(rod)&&obj==bird) goto l40010;
435 continue; /* i.e. goto l40030 */
436 case 6: /* 40600 */
437 if (here(snake)&&!here(bird)) goto l40010;
438 goto l40020;
439 case 7: /* 40700 */
440 if (atloc[loc]==0&&atloc[oldloc]==0
441 && atloc[oldlc2]==0&&holdng>1) goto l40010;
442 goto l40020;
443 case 8: /* 40800 */
444 if (prop[emrald]!= -1&&prop[pyram]== -1) goto l40010;
445 goto l40020;
446 case 9:
447 goto l40010; /* 40900 */
448 default: bug(27);
449 }
450 l40010: hintlc[hint]=0;
451 if (!yes(hints[hint][3],0,54)) continue;
452 printf("I am prepared to give you a hint, but it will ");
453 printf("cost you %d points.\n",hints[hint][2]);
454 hinted[hint]=yes(175,hints[hint][4],54);
455 l40020: hintlc[hint]=0;
456 }
457 return 0;
458 }
459
460
461 int
462 trsay() /* 9030 */
463 { int i;
464 if (*wd2!=0) copystr(wd2,wd1);
465 i=vocab(wd1,-1,0);
466 if (i==62||i==65||i==71||i==2025)
467 { *wd2=0;
468 obj=0;
469 return(2630);
470 }
471 printf("\nOkay, \"%s\".\n",wd2);
472 return(2012);
473 }
474
475
476 int
477 trtake() /* 9010 */
478 { if (toting(obj)) return(2011); /* 9010 */
479 spk=25;
480 if (obj==plant&&prop[plant]<=0) spk=115;
481 if (obj==bear&&prop[bear]==1) spk=169;
482 if (obj==chain&&prop[bear]!=0) spk=170;
483 if (fixed[obj]!=0) return(2011);
484 if (obj==water||obj==oil)
485 { if (here(bottle)&&liq(0)==obj)
486 { obj=bottle;
487 goto l9017;
488 }
489 obj=bottle;
490 if (toting(bottle)&&prop[bottle]==1)
491 return(9220);
492 if (prop[bottle]!=1) spk=105;
493 if (!toting(bottle)) spk=104;
494 return(2011);
495 }
496 l9017: if (holdng>=7)
497 { rspeak(92);
498 return(2012);
499 }
500 if (obj==bird)
501 { if (prop[bird]!=0) goto l9014;
502 if (toting(rod))
503 { rspeak(26);
504 return(2012);
505 }
506 if (!toting(cage)) /* 9013 */
507 { rspeak(27);
508 return(2012);
509 }
510 prop[bird]=1; /* 9015 */
511 }
512 l9014: if ((obj==bird||obj==cage)&&prop[bird]!=0)
513 carry(bird+cage-obj,loc);
514 carry(obj,loc);
515 k=liq(0);
516 if (obj==bottle && k!=0) place[k] = -1;
517 return(2009);
518 }
519
520
521 int
522 dropper() /* 9021 */
523 { k=liq(0);
524 if (k==obj) obj=bottle;
525 if (obj==bottle&&k!=0) place[k]=0;
526 if (obj==cage&&prop[bird]!=0) drop(bird,loc);
527 if (obj==bird) prop[bird]=0;
528 drop(obj,loc);
529 return(2012);
530 }
531
532 int
533 trdrop() /* 9020 */
534 {
535 if (toting(rod2)&&obj==rod&&!toting(rod)) obj=rod2;
536 if (!toting(obj)) return(2011);
537 if (obj==bird&&here(snake))
538 { rspeak(30);
539 if (closed) return(19000);
540 dstroy(snake);
541 prop[snake]=1;
542 return(dropper());
543 }
544 if (obj==coins&&here(vend)) /* 9024 */
545 { dstroy(coins);
546 drop(batter,loc);
547 pspeak(batter,0);
548 return(2012);
549 }
550 if (obj==bird&&at(dragon)&&prop[dragon]==0) /* 9025 */
551 { rspeak(154);
552 dstroy(bird);
553 prop[bird]=0;
554 if (place[snake]==plac[snake]) tally2--;
555 return(2012);
556 }
557 if (obj==bear&&at(troll)) /* 9026 */
558 { rspeak(163);
559 move(troll,0);
560 move(troll+100,0);
561 move(troll2,plac[troll]);
562 move(troll2+100,fixd[troll]);
563 juggle(chasm);
564 prop[troll]=2;
565 return(dropper());
566 }
567 if (obj!=vase||loc==plac[pillow]) /* 9027 */
568 { rspeak(54);
569 return(dropper());
570 }
571 prop[vase]=2; /* 9028 */
572 if (at(pillow)) prop[vase]=0;
573 pspeak(vase,prop[vase]+1);
574 if (prop[vase]!=0) fixed[vase] = -1;
575 return(dropper());
576 }
577
578
579 int
580 tropen() /* 9040 */
581 { if (obj==clam||obj==oyster)
582 { k=0; /* 9046 */
583 if (obj==oyster) k=1;
584 spk=124+k;
585 if (toting(obj)) spk=120+k;
586 if (!toting(tridnt)) spk=122+k;
587 if (verb==lock) spk=61;
588 if (spk!=124) return(2011);
589 dstroy(clam);
590 drop(oyster,loc);
591 drop(pearl,105);
592 return(2011);
593 }
594 if (obj==door) spk=111;
595 if (obj==door&&prop[door]==1) spk=54;
596 if (obj==cage) spk=32;
597 if (obj==keys) spk=55;
598 if (obj==grate||obj==chain) spk=31;
599 if (spk!=31||!here(keys)) return(2011);
600 if (obj==chain)
601 { if (verb==lock)
602 { spk=172; /* 9049: lock */
603 if (prop[chain]!=0) spk=34;
604 if (loc!=plac[chain]) spk=173;
605 if (spk!=172) return(2011);
606 prop[chain]=2;
607 if (toting(chain)) drop(chain,loc);
608 fixed[chain]= -1;
609 return(2011);
610 }
611 spk=171;
612 if (prop[bear]==0) spk=41;
613 if (prop[chain]==0) spk=37;
614 if (spk!=171) return(2011);
615 prop[chain]=0;
616 fixed[chain]=0;
617 if (prop[bear]!=3) prop[bear]=2;
618 fixed[bear]=2-prop[bear];
619 return(2011);
620 }
621 if (closng)
622 { k=130;
623 if (!panic) clock2=15;
624 panic=TRUE;
625 return(2010);
626 }
627 k=34+prop[grate]; /* 9043 */
628 prop[grate]=1;
629 if (verb==lock) prop[grate]=0;
630 k=k+2*prop[grate];
631 return(2010);
632 }
633
634
635 int
636 trkill() /* 9120 */
637 { int i;
638 for (i=1; i<=5; i++)
639 if (dloc[i]==loc&&dflag>=2) break;
640 if (i==6) i=0;
641 if (obj==0) /* 9122 */
642 { if (i!=0) obj=dwarf;
643 if (here(snake)) obj=obj*100+snake;
644 if (at(dragon)&&prop[dragon]==0) obj=obj*100+dragon;
645 if (at(troll)) obj=obj*100+troll;
646 if (here(bear)&&prop[bear]==0) obj=obj*100+bear;
647 if (obj>100) return(8000);
648 if (obj==0)
649 { if (here(bird)&&verb!=throw) obj=bird;
650 if (here(clam)||here(oyster)) obj=100*obj+clam;
651 if (obj>100) return(8000);
652 }
653 }
654 if (obj==bird) /* 9124 */
655 { spk=137;
656 if (closed) return(2011);
657 dstroy(bird);
658 prop[bird]=0;
659 if (place[snake]==plac[snake]) tally2++;
660 spk=45;
661 }
662 if (obj==0) spk=44; /* 9125 */
663 if (obj==clam||obj==oyster) spk=150;
664 if (obj==snake) spk=46;
665 if (obj==dwarf) spk=49;
666 if (obj==dwarf&&closed) return(19000);
667 if (obj==dragon) spk=147;
668 if (obj==troll) spk=157;
669 if (obj==bear) spk=165+(prop[bear]+1)/2;
670 if (obj!=dragon||prop[dragon]!=0) return(2011);
671 rspeak(49);
672 verb=0;
673 obj=0;
674 getin(&wd1,&wd2);
675 if (!weq(wd1,"y")&&!weq(wd1,"yes")) return(2608);
676 pspeak(dragon,1);
677 prop[dragon]=2;
678 prop[rug]=0;
679 k=(plac[dragon]+fixd[dragon])/2;
680 move(dragon+100,-1);
681 move(rug+100,0);
682 move(dragon,k);
683 move(rug,k);
684 for (obj=1; obj<=100; obj++)
685 if (place[obj]==plac[dragon]||place[obj]==fixd[dragon])
686 move(obj,k);
687 loc=k;
688 k=null;
689 return(8);
690 }
691
692
693 int
694 trtoss() /* 9170: throw */
695 { int i;
696 if (toting(rod2)&&obj==rod&&!toting(rod)) obj=rod2;
697 if (!toting(obj)) return(2011);
698 if (obj>=50&&obj<=maxtrs&&at(troll))
699 { spk=159; /* 9178 */
700 drop(obj,0);
701 move(troll,0);
702 move(troll+100,0);
703 drop(troll2,plac[troll]);
704 drop(troll2+100,fixd[troll]);
705 juggle(chasm);
706 return(2011);
707 }
708 if (obj==food&&here(bear))
709 { obj=bear; /* 9177 */
710 return(9210);
711 }
712 if (obj!=axe) return(9020);
713 for (i=1; i<=5; i++)
714 { if (dloc[i]==loc)
715 { spk=48; /* 9172 */
716 if (ran(3)==0||saved!= -1)
717 l9175: { rspeak(spk);
718 drop(axe,loc);
719 k=null;
720 return(8);
721 }
722 dseen[i]=FALSE;
723 dloc[i]=0;
724 spk=47;
725 dkill++;
726 if (dkill==1) spk=149;
727 goto l9175;
728 }
729 }
730 spk=152;
731 if (at(dragon)&&prop[dragon]==0)
732 goto l9175;
733 spk=158;
734 if (at(troll)) goto l9175;
735 if (here(bear)&&prop[bear]==0)
736 { spk=164;
737 drop(axe,loc);
738 fixed[axe]= -1;
739 prop[axe]=1;
740 juggle(bear);
741 return(2011);
742 }
743 obj=0;
744 return(9120);
745 }
746
747
748 int
749 trfeed() /* 9210 */
750 { if (obj==bird)
751 { spk=100;
752 return(2011);
753 }
754 if (obj==snake||obj==dragon||obj==troll)
755 { spk=102;
756 if (obj==dragon&&prop[dragon]!=0) spk=110;
757 if (obj==troll) spk=182;
758 if (obj!=snake||closed||!here(bird)) return(2011);
759 spk=101;
760 dstroy(bird);
761 prop[bird]=0;
762 tally2++;
763 return(2011);
764 }
765 if (obj==dwarf)
766 { if (!here(food)) return(2011);
767 spk=103;
768 dflag++;
769 return(2011);
770 }
771 if (obj==bear)
772 { if (prop[bear]==0) spk=102;
773 if (prop[bear]==3) spk=110;
774 if (!here(food)) return(2011);
775 dstroy(food);
776 prop[bear]=1;
777 fixed[axe]=0;
778 prop[axe]=0;
779 spk=168;
780 return(2011);
781 }
782 spk=14;
783 return(2011);
784 }
785
786
787 int
788 trfill() /* 9220 */
789 { if (obj==vase)
790 { spk=29;
791 if (liqloc(loc)==0) spk=144;
792 if (liqloc(loc)==0||!toting(vase)) return(2011);
793 rspeak(145);
794 prop[vase]=2;
795 fixed[vase]= -1;
796 return(9020); /* advent/10 goes to 9024 */
797 }
798 if (obj!=0&&obj!=bottle) return(2011);
799 if (obj==0&&!here(bottle)) return(8000);
800 spk=107;
801 if (liqloc(loc)==0) spk=106;
802 if (liq(0)!=0) spk=105;
803 if (spk!=107) return(2011);
804 prop[bottle]=((cond[loc]%4)/2)*2;
805 k=liq(0);
806 if (toting(bottle)) place[k]= -1;
807 if (k==oil) spk=108;
808 return(2011);
809 }
810
811
812 int
813 closing() /* 10000 */
814 { int i;
815
816 prop[grate]=prop[fissur]=0;
817 for (i=1; i<=6; i++)
818 { dseen[i]=FALSE;
819 dloc[i]=0;
820 }
821 move(troll,0);
822 move(troll+100,0);
823 move(troll2,plac[troll]);
824 move(troll2+100,fixd[troll]);
825 juggle(chasm);
826 if(prop[bear]!=3) dstroy(bear);
827 prop[chain]=0;
828 fixed[chain]=0;
829 prop[axe]=0;
830 fixed[axe]=0;
831 rspeak(129);
832 clock1 = -1;
833 closng=TRUE;
834 return(19999);
835 }
836
837
838 int
839 caveclose() /* 11000 */
840 { int i;
841 prop[bottle]=put(bottle,115,1);
842 prop[plant]=put(plant,115,0);
843 prop[oyster]=put(oyster,115,0);
844 prop[lamp]=put(lamp,115,0);
845 prop[rod]=put(rod,115,0);
846 prop[dwarf]=put(dwarf,115,0);
847 loc=115;
848 oldloc=115;
849 newloc=115;
850
851 put(grate,116,0);
852 prop[snake]=put(snake,116,1);
853 prop[bird]=put(bird,116,1);
854 prop[cage]=put(cage,116,0);
855 prop[rod2]=put(rod2,116,0);
856 prop[pillow]=put(pillow,116,0);
857
858 prop[mirror]=put(mirror,115,0);
859 fixed[mirror]=116;
860
861 for (i=1; i<=100; i++)
862 if (toting(i)) dstroy(i);
863 rspeak(132);
864 closed=TRUE;
865 return(2);
866 }