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