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