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