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