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