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