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