Home | History | Annotate | Line # | Download | only in larn
object.c revision 1.16.32.1
      1  1.16.32.1  christos /*	$NetBSD: object.c,v 1.16.32.1 2019/06/10 22:05:11 christos Exp $	*/
      2        1.8  christos 
      3        1.8  christos /* object.c		Larn is copyrighted 1986 by Noah Morgan. */
      4        1.8  christos 
      5        1.8  christos #include <sys/cdefs.h>
      6        1.3   mycroft #ifndef lint
      7  1.16.32.1  christos __RCSID("$NetBSD: object.c,v 1.16.32.1 2019/06/10 22:05:11 christos Exp $");
      8        1.8  christos #endif				/* not lint */
      9        1.1       cgd #include "header.h"
     10        1.8  christos #include "extern.h"
     11        1.1       cgd 
     12       1.15  dholland static void finditem(int);
     13       1.15  dholland static void ostairs(int);
     14       1.15  dholland static void opotion(int);
     15       1.15  dholland static void oscroll(int);
     16       1.15  dholland static void oorb(void);
     17       1.15  dholland static void opit(void);
     18       1.15  dholland static void obottomless(void);
     19       1.15  dholland static void oelevator(int);
     20       1.15  dholland static void ostatue(void);
     21       1.15  dholland static void omirror(void);
     22       1.15  dholland static void obook(void);
     23       1.15  dholland static void ocookie(void);
     24       1.15  dholland static void ogold(int);
     25       1.15  dholland static void ohome(void);
     26       1.15  dholland 
     27        1.1       cgd /*
     28       1.14  dholland 	lookforobject
     29        1.1       cgd 
     30        1.1       cgd 	subroutine to look for an object and give the player his options
     31        1.1       cgd 	if an object was found.
     32        1.1       cgd  */
     33        1.8  christos void
     34       1.16  dholland lookforobject(void)
     35        1.1       cgd {
     36        1.8  christos 	int    i, j;
     37        1.8  christos 	if (c[TIMESTOP])
     38       1.14  dholland 		return;		/* can't find objects if time is stopped	 */
     39        1.8  christos 	i = item[playerx][playery];
     40        1.8  christos 	if (i == 0)
     41        1.8  christos 		return;
     42        1.8  christos 	showcell(playerx, playery);
     43        1.8  christos 	cursors();
     44        1.8  christos 	yrepcount = 0;
     45        1.8  christos 	switch (i) {
     46        1.8  christos 	case OGOLDPILE:
     47        1.8  christos 	case OMAXGOLD:
     48        1.8  christos 	case OKGOLD:
     49        1.8  christos 	case ODGOLD:
     50        1.8  christos 		lprcat("\n\nYou have found some gold!");
     51        1.8  christos 		ogold(i);
     52        1.8  christos 		break;
     53        1.8  christos 
     54        1.8  christos 	case OPOTION:
     55        1.8  christos 		lprcat("\n\nYou have found a magic potion");
     56        1.8  christos 		i = iarg[playerx][playery];
     57        1.8  christos 		if (potionname[i][0] != 0)
     58        1.8  christos 			lprintf(" of%s", potionname[i]);
     59        1.8  christos 		opotion(i);
     60        1.8  christos 		break;
     61        1.8  christos 
     62        1.8  christos 	case OSCROLL:
     63        1.8  christos 		lprcat("\n\nYou have found a magic scroll");
     64        1.8  christos 		i = iarg[playerx][playery];
     65        1.8  christos 		if (scrollname[i][0] != 0)
     66        1.8  christos 			lprintf(" of%s", scrollname[i]);
     67        1.8  christos 		oscroll(i);
     68        1.8  christos 		break;
     69        1.8  christos 
     70        1.8  christos 	case OALTAR:
     71        1.8  christos 		if (nearbymonst())
     72        1.8  christos 			return;
     73        1.8  christos 		lprcat("\n\nThere is a Holy Altar here!");
     74        1.8  christos 		oaltar();
     75        1.8  christos 		break;
     76        1.8  christos 
     77        1.8  christos 	case OBOOK:
     78        1.8  christos 		lprcat("\n\nYou have found a book.");
     79        1.8  christos 		obook();
     80        1.8  christos 		break;
     81        1.8  christos 
     82        1.8  christos 	case OCOOKIE:
     83        1.8  christos 		lprcat("\n\nYou have found a fortune cookie.");
     84        1.8  christos 		ocookie();
     85        1.8  christos 		break;
     86        1.8  christos 
     87        1.8  christos 	case OTHRONE:
     88        1.8  christos 		if (nearbymonst())
     89        1.8  christos 			return;
     90        1.8  christos 		lprintf("\n\nThere is %s here!", objectname[i]);
     91        1.8  christos 		othrone(0);
     92        1.8  christos 		break;
     93        1.8  christos 
     94        1.8  christos 	case OTHRONE2:
     95        1.8  christos 		if (nearbymonst())
     96        1.8  christos 			return;
     97        1.8  christos 		lprintf("\n\nThere is %s here!", objectname[i]);
     98        1.8  christos 		othrone(1);
     99        1.8  christos 		break;
    100        1.8  christos 
    101        1.8  christos 	case ODEADTHRONE:
    102        1.8  christos 		lprintf("\n\nThere is %s here!", objectname[i]);
    103        1.8  christos 		odeadthrone();
    104        1.8  christos 		break;
    105        1.8  christos 
    106        1.8  christos 	case OORB:
    107        1.8  christos 		lprcat("\n\nYou have found the Orb!!!!!");
    108        1.8  christos 		oorb();
    109        1.8  christos 		break;
    110        1.8  christos 
    111        1.8  christos 	case OPIT:
    112        1.8  christos 		lprcat("\n\nYou're standing at the top of a pit.");
    113        1.8  christos 		opit();
    114        1.8  christos 		break;
    115        1.8  christos 
    116        1.8  christos 	case OSTAIRSUP:
    117        1.8  christos 		lprcat("\n\nThere is a circular staircase here");
    118        1.8  christos 		ostairs(1);	/* up */
    119        1.8  christos 		break;
    120        1.8  christos 
    121        1.8  christos 	case OELEVATORUP:
    122        1.8  christos 		lprcat("\n\nYou feel heavy for a moment, but the feeling disappears");
    123        1.8  christos 		oelevator(1);	/* up  */
    124        1.8  christos 		break;
    125        1.8  christos 
    126        1.8  christos 	case OFOUNTAIN:
    127        1.8  christos 		if (nearbymonst())
    128        1.8  christos 			return;
    129        1.8  christos 		lprcat("\n\nThere is a fountain here");
    130        1.8  christos 		ofountain();
    131        1.8  christos 		break;
    132        1.8  christos 
    133        1.8  christos 	case OSTATUE:
    134        1.8  christos 		if (nearbymonst())
    135        1.8  christos 			return;
    136        1.8  christos 		lprcat("\n\nYou are standing in front of a statue");
    137        1.8  christos 		ostatue();
    138        1.8  christos 		break;
    139        1.8  christos 
    140        1.8  christos 	case OCHEST:
    141        1.8  christos 		lprcat("\n\nThere is a chest here");
    142        1.8  christos 		ochest();
    143        1.8  christos 		break;
    144        1.8  christos 
    145        1.8  christos 	case OIVTELETRAP:
    146        1.8  christos 		if (rnd(11) < 6)
    147        1.8  christos 			return;
    148        1.8  christos 		item[playerx][playery] = OTELEPORTER;
    149        1.8  christos 		know[playerx][playery] = 1;
    150        1.8  christos 
    151  1.16.32.1  christos 		/* FALLTHROUGH */
    152        1.8  christos 	case OTELEPORTER:
    153        1.8  christos 		lprcat("\nZaaaappp!  You've been teleported!\n");
    154        1.8  christos 		beep();
    155        1.8  christos 		nap(3000);
    156        1.8  christos 		oteleport(0);
    157        1.8  christos 		break;
    158        1.8  christos 
    159        1.8  christos 	case OSCHOOL:
    160        1.8  christos 		if (nearbymonst())
    161        1.8  christos 			return;
    162        1.8  christos 		lprcat("\n\nYou have found the College of Larn.");
    163        1.8  christos 		lprcat("\nDo you (g) go inside, or (i) stay here? ");
    164        1.8  christos 		i = 0;
    165        1.8  christos 		while ((i != 'g') && (i != 'i') && (i != '\33'))
    166       1.13  dholland 			i = ttgetch();
    167        1.8  christos 		if (i == 'g') {
    168        1.8  christos 			oschool();	/* the college of larn	 */
    169        1.8  christos 		} else
    170        1.8  christos 			lprcat(" stay here");
    171        1.8  christos 		break;
    172        1.8  christos 
    173        1.8  christos 	case OMIRROR:
    174        1.8  christos 		if (nearbymonst())
    175        1.8  christos 			return;
    176        1.8  christos 		lprcat("\n\nThere is a mirror here");
    177        1.8  christos 		omirror();
    178        1.8  christos 		break;
    179        1.1       cgd 
    180        1.1       cgd 	case OBANK2:
    181        1.8  christos 	case OBANK:
    182        1.8  christos 		if (nearbymonst())
    183        1.8  christos 			return;
    184        1.8  christos 		if (i == OBANK)
    185        1.8  christos 			lprcat("\n\nYou have found the bank of Larn.");
    186        1.8  christos 		else
    187        1.8  christos 			lprcat("\n\nYou have found a branch office of the bank of Larn.");
    188        1.8  christos 		lprcat("\nDo you (g) go inside, or (i) stay here? ");
    189        1.8  christos 		j = 0;
    190        1.8  christos 		while ((j != 'g') && (j != 'i') && (j != '\33'))
    191       1.13  dholland 			j = ttgetch();
    192        1.8  christos 		if (j == 'g') {
    193        1.8  christos 			if (i == OBANK)
    194        1.8  christos 				obank();
    195        1.8  christos 			else
    196        1.8  christos 				obank2();	/* the bank of larn  */
    197        1.8  christos 		} else
    198        1.8  christos 			lprcat(" stay here");
    199        1.8  christos 		break;
    200        1.8  christos 
    201        1.8  christos 	case ODEADFOUNTAIN:
    202        1.8  christos 		if (nearbymonst())
    203        1.8  christos 			return;
    204        1.8  christos 		lprcat("\n\nThere is a dead fountain here");
    205        1.8  christos 		break;
    206        1.8  christos 
    207        1.8  christos 	case ODNDSTORE:
    208        1.8  christos 		if (nearbymonst())
    209        1.8  christos 			return;
    210        1.8  christos 		lprcat("\n\nThere is a DND store here.");
    211        1.8  christos 		lprcat("\nDo you (g) go inside, or (i) stay here? ");
    212        1.8  christos 		i = 0;
    213        1.8  christos 		while ((i != 'g') && (i != 'i') && (i != '\33'))
    214       1.13  dholland 			i = ttgetch();
    215        1.8  christos 		if (i == 'g')
    216        1.8  christos 			dndstore();	/* the dnd adventurers store  */
    217        1.8  christos 		else
    218        1.8  christos 			lprcat(" stay here");
    219        1.8  christos 		break;
    220        1.1       cgd 
    221        1.8  christos 	case OSTAIRSDOWN:
    222        1.8  christos 		lprcat("\n\nThere is a circular staircase here");
    223        1.8  christos 		ostairs(-1);	/* down */
    224        1.8  christos 		break;
    225        1.8  christos 
    226        1.8  christos 	case OELEVATORDOWN:
    227        1.8  christos 		lprcat("\n\nYou feel light for a moment, but the feeling disappears");
    228        1.8  christos 		oelevator(-1);	/* down	 */
    229        1.8  christos 		break;
    230        1.8  christos 
    231        1.8  christos 	case OOPENDOOR:
    232        1.8  christos 		lprintf("\n\nYou have found %s", objectname[i]);
    233        1.8  christos 		lprcat("\nDo you (c) close it");
    234        1.8  christos 		iopts();
    235        1.8  christos 		i = 0;
    236        1.8  christos 		while ((i != 'c') && (i != 'i') && (i != '\33'))
    237       1.13  dholland 			i = ttgetch();
    238        1.8  christos 		if ((i == '\33') || (i == 'i')) {
    239        1.8  christos 			ignore();
    240        1.8  christos 			break;
    241        1.8  christos 		}
    242        1.8  christos 		lprcat("close");
    243        1.8  christos 		forget();
    244        1.8  christos 		item[playerx][playery] = OCLOSEDDOOR;
    245        1.8  christos 		iarg[playerx][playery] = 0;
    246        1.8  christos 		playerx = lastpx;
    247        1.8  christos 		playery = lastpy;
    248        1.8  christos 		break;
    249        1.8  christos 
    250        1.8  christos 	case OCLOSEDDOOR:
    251        1.8  christos 		lprintf("\n\nYou have found %s", objectname[i]);
    252        1.8  christos 		lprcat("\nDo you (o) try to open it");
    253        1.8  christos 		iopts();
    254        1.8  christos 		i = 0;
    255        1.8  christos 		while ((i != 'o') && (i != 'i') && (i != '\33'))
    256       1.13  dholland 			i = ttgetch();
    257        1.8  christos 		if ((i == '\33') || (i == 'i')) {
    258        1.8  christos 			ignore();
    259        1.8  christos 			playerx = lastpx;
    260        1.8  christos 			playery = lastpy;
    261        1.8  christos 			break;
    262        1.8  christos 		} else {
    263        1.8  christos 			lprcat("open");
    264        1.8  christos 			if (rnd(11) < 7) {
    265        1.8  christos 				switch (iarg[playerx][playery]) {
    266        1.8  christos 				case 6:
    267        1.8  christos 					c[AGGRAVATE] += rnd(400);
    268        1.8  christos 					break;
    269        1.1       cgd 
    270        1.8  christos 				case 7:
    271        1.8  christos 					lprcat("\nYou are jolted by an electric shock ");
    272        1.8  christos 					lastnum = 274;
    273        1.8  christos 					losehp(rnd(20));
    274        1.8  christos 					bottomline();
    275        1.1       cgd 					break;
    276        1.1       cgd 
    277        1.8  christos 				case 8:
    278        1.8  christos 					loselevel();
    279        1.8  christos 					break;
    280        1.1       cgd 
    281        1.8  christos 				case 9:
    282        1.8  christos 					lprcat("\nYou suddenly feel weaker ");
    283        1.8  christos 					if (c[STRENGTH] > 3)
    284        1.8  christos 						c[STRENGTH]--;
    285        1.8  christos 					bottomline();
    286        1.8  christos 					break;
    287        1.1       cgd 
    288        1.8  christos 				default:
    289        1.1       cgd 					break;
    290        1.8  christos 				}
    291        1.8  christos 				playerx = lastpx;
    292        1.8  christos 				playery = lastpy;
    293        1.8  christos 			} else {
    294        1.8  christos 				forget();
    295        1.8  christos 				item[playerx][playery] = OOPENDOOR;
    296        1.8  christos 			}
    297        1.8  christos 		}
    298        1.8  christos 		break;
    299        1.1       cgd 
    300        1.8  christos 	case OENTRANCE:
    301        1.8  christos 		lprcat("\nYou have found ");
    302        1.8  christos 		lprcat(objectname[OENTRANCE]);
    303        1.8  christos 		lprcat("\nDo you (g) go inside");
    304        1.8  christos 		iopts();
    305        1.8  christos 		i = 0;
    306        1.8  christos 		while ((i != 'g') && (i != 'i') && (i != '\33'))
    307       1.13  dholland 			i = ttgetch();
    308        1.8  christos 		if (i == 'g') {
    309        1.8  christos 			newcavelevel(1);
    310        1.8  christos 			playerx = 33;
    311        1.8  christos 			playery = MAXY - 2;
    312        1.8  christos 			item[33][MAXY - 1] = know[33][MAXY - 1] = mitem[33][MAXY - 1] = 0;
    313        1.8  christos 			draws(0, MAXX, 0, MAXY);
    314        1.8  christos 			bot_linex();
    315        1.8  christos 			return;
    316        1.8  christos 		} else
    317        1.8  christos 			ignore();
    318        1.8  christos 		break;
    319        1.8  christos 
    320        1.8  christos 	case OVOLDOWN:
    321        1.8  christos 		lprcat("\nYou have found ");
    322        1.8  christos 		lprcat(objectname[OVOLDOWN]);
    323        1.8  christos 		lprcat("\nDo you (c) climb down");
    324        1.8  christos 		iopts();
    325        1.8  christos 		i = 0;
    326        1.8  christos 		while ((i != 'c') && (i != 'i') && (i != '\33'))
    327       1.13  dholland 			i = ttgetch();
    328        1.8  christos 		if ((i == '\33') || (i == 'i')) {
    329        1.8  christos 			ignore();
    330        1.8  christos 			break;
    331        1.8  christos 		}
    332        1.8  christos 		if (level != 0) {
    333        1.8  christos 			lprcat("\nThe shaft only extends 5 feet downward!");
    334        1.8  christos 			return;
    335        1.8  christos 		}
    336        1.8  christos 		if (packweight() > 45 + 3 * (c[STRENGTH] + c[STREXTRA])) {
    337        1.8  christos 			lprcat("\nYou slip and fall down the shaft");
    338        1.8  christos 			beep();
    339        1.8  christos 			lastnum = 275;
    340        1.8  christos 			losehp(30 + rnd(20));
    341        1.8  christos 			bottomhp();
    342        1.8  christos 		} else
    343        1.8  christos 			lprcat("climb down");
    344        1.8  christos 		nap(3000);
    345        1.8  christos 		newcavelevel(MAXLEVEL);
    346        1.8  christos 		for (i = 0; i < MAXY; i++)
    347        1.8  christos 			for (j = 0; j < MAXX; j++)	/* put player near
    348        1.8  christos 							 * volcano shaft */
    349        1.8  christos 				if (item[j][i] == OVOLUP) {
    350        1.8  christos 					playerx = j;
    351        1.8  christos 					playery = i;
    352        1.8  christos 					j = MAXX;
    353        1.8  christos 					i = MAXY;
    354        1.8  christos 					positionplayer();
    355        1.8  christos 				}
    356        1.8  christos 		draws(0, MAXX, 0, MAXY);
    357        1.8  christos 		bot_linex();
    358        1.8  christos 		return;
    359        1.8  christos 
    360        1.8  christos 	case OVOLUP:
    361        1.8  christos 		lprcat("\nYou have found ");
    362        1.8  christos 		lprcat(objectname[OVOLUP]);
    363        1.8  christos 		lprcat("\nDo you (c) climb up");
    364        1.8  christos 		iopts();
    365        1.8  christos 		i = 0;
    366        1.8  christos 		while ((i != 'c') && (i != 'i') && (i != '\33'))
    367       1.13  dholland 			i = ttgetch();
    368        1.8  christos 		if ((i == '\33') || (i == 'i')) {
    369        1.8  christos 			ignore();
    370        1.8  christos 			break;
    371        1.8  christos 		}
    372        1.8  christos 		if (level != 11) {
    373        1.8  christos 			lprcat("\nThe shaft only extends 8 feet upwards before you find a blockage!");
    374        1.8  christos 			return;
    375        1.8  christos 		}
    376        1.8  christos 		if (packweight() > 45 + 5 * (c[STRENGTH] + c[STREXTRA])) {
    377        1.8  christos 			lprcat("\nYou slip and fall down the shaft");
    378        1.8  christos 			beep();
    379        1.8  christos 			lastnum = 275;
    380        1.8  christos 			losehp(15 + rnd(20));
    381        1.8  christos 			bottomhp();
    382        1.8  christos 			return;
    383        1.8  christos 		}
    384        1.8  christos 		lprcat("climb up");
    385        1.8  christos 		lflush();
    386        1.8  christos 		nap(3000);
    387        1.8  christos 		newcavelevel(0);
    388        1.8  christos 		for (i = 0; i < MAXY; i++)
    389        1.8  christos 			for (j = 0; j < MAXX; j++)	/* put player near
    390        1.8  christos 							 * volcano shaft */
    391        1.8  christos 				if (item[j][i] == OVOLDOWN) {
    392        1.8  christos 					playerx = j;
    393        1.8  christos 					playery = i;
    394        1.8  christos 					j = MAXX;
    395        1.8  christos 					i = MAXY;
    396        1.8  christos 					positionplayer();
    397        1.8  christos 				}
    398        1.8  christos 		draws(0, MAXX, 0, MAXY);
    399        1.8  christos 		bot_linex();
    400        1.8  christos 		return;
    401        1.8  christos 
    402        1.8  christos 	case OTRAPARROWIV:
    403        1.8  christos 		if (rnd(17) < 13)
    404        1.8  christos 			return;	/* for an arrow trap */
    405        1.8  christos 		item[playerx][playery] = OTRAPARROW;
    406        1.8  christos 		know[playerx][playery] = 0;
    407        1.8  christos 
    408  1.16.32.1  christos 		/* FALLTHROUGH */
    409        1.8  christos 	case OTRAPARROW:
    410        1.8  christos 		lprcat("\nYou are hit by an arrow");
    411        1.8  christos 		beep();		/* for an arrow trap */
    412        1.8  christos 		lastnum = 259;
    413        1.8  christos 		losehp(rnd(10) + level);
    414        1.8  christos 		bottomhp();
    415        1.8  christos 		return;
    416        1.8  christos 
    417        1.8  christos 	case OIVDARTRAP:
    418        1.8  christos 		if (rnd(17) < 13)
    419        1.8  christos 			return;	/* for a dart trap */
    420        1.8  christos 		item[playerx][playery] = ODARTRAP;
    421        1.8  christos 		know[playerx][playery] = 0;
    422        1.8  christos 
    423  1.16.32.1  christos 		/* FALLTHROUGH */
    424        1.8  christos 	case ODARTRAP:
    425        1.8  christos 		lprcat("\nYou are hit by a dart");
    426        1.8  christos 		beep();		/* for a dart trap */
    427        1.8  christos 		lastnum = 260;
    428        1.8  christos 		losehp(rnd(5));
    429        1.8  christos 		if ((--c[STRENGTH]) < 3)
    430        1.8  christos 			c[STRENGTH] = 3;
    431        1.8  christos 		bottomline();
    432        1.8  christos 		return;
    433        1.8  christos 
    434        1.8  christos 	case OIVTRAPDOOR:
    435        1.8  christos 		if (rnd(17) < 13)
    436        1.8  christos 			return;	/* for a trap door */
    437        1.8  christos 		item[playerx][playery] = OTRAPDOOR;
    438        1.8  christos 		know[playerx][playery] = 1;
    439        1.8  christos 
    440  1.16.32.1  christos 		/* FALLTHROUGH */
    441        1.8  christos 	case OTRAPDOOR:
    442        1.8  christos 		lastnum = 272;	/* a trap door */
    443        1.8  christos 		if ((level == MAXLEVEL - 1) || (level == MAXLEVEL + MAXVLEVEL - 1)) {
    444        1.8  christos 			lprcat("\nYou fell through a bottomless trap door!");
    445        1.8  christos 			beep();
    446        1.8  christos 			nap(3000);
    447        1.8  christos 			died(271);
    448        1.8  christos 		}
    449        1.8  christos 		lprcat("\nYou fall through a trap door!");
    450        1.8  christos 		beep();		/* for a trap door */
    451        1.8  christos 		losehp(rnd(5 + level));
    452        1.8  christos 		nap(2000);
    453        1.8  christos 		newcavelevel(level + 1);
    454        1.8  christos 		draws(0, MAXX, 0, MAXY);
    455        1.8  christos 		bot_linex();
    456        1.8  christos 		return;
    457        1.8  christos 
    458        1.8  christos 
    459        1.8  christos 	case OTRADEPOST:
    460        1.8  christos 		if (nearbymonst())
    461        1.8  christos 			return;
    462        1.8  christos 		lprcat("\nYou have found the Larn trading Post.");
    463        1.8  christos 		lprcat("\nDo you (g) go inside, or (i) stay here? ");
    464        1.8  christos 		i = 0;
    465        1.8  christos 		while ((i != 'g') && (i != 'i') && (i != '\33'))
    466       1.13  dholland 			i = ttgetch();
    467        1.8  christos 		if (i == 'g')
    468        1.8  christos 			otradepost();
    469        1.8  christos 		else
    470        1.8  christos 			lprcat("stay here");
    471        1.8  christos 		return;
    472        1.1       cgd 
    473        1.8  christos 	case OHOME:
    474        1.8  christos 		if (nearbymonst())
    475        1.8  christos 			return;
    476        1.8  christos 		lprcat("\nYou have found your way home.");
    477        1.8  christos 		lprcat("\nDo you (g) go inside, or (i) stay here? ");
    478        1.8  christos 		i = 0;
    479        1.8  christos 		while ((i != 'g') && (i != 'i') && (i != '\33'))
    480       1.13  dholland 			i = ttgetch();
    481        1.8  christos 		if (i == 'g')
    482        1.8  christos 			ohome();
    483        1.8  christos 		else
    484        1.8  christos 			lprcat("stay here");
    485        1.8  christos 		return;
    486        1.1       cgd 
    487        1.8  christos 	case OWALL:
    488        1.8  christos 		break;
    489        1.1       cgd 
    490        1.8  christos 	case OANNIHILATION:
    491        1.8  christos 		died(283);
    492        1.8  christos 		return;		/* annihilated by sphere of annihilation */
    493        1.8  christos 
    494        1.8  christos 	case OLRS:
    495        1.8  christos 		if (nearbymonst())
    496        1.8  christos 			return;
    497        1.8  christos 		lprcat("\n\nThere is an LRS office here.");
    498        1.8  christos 		lprcat("\nDo you (g) go inside, or (i) stay here? ");
    499        1.8  christos 		i = 0;
    500        1.8  christos 		while ((i != 'g') && (i != 'i') && (i != '\33'))
    501       1.13  dholland 			i = ttgetch();
    502        1.8  christos 		if (i == 'g')
    503        1.8  christos 			olrs();	/* the larn revenue service */
    504        1.8  christos 		else
    505        1.8  christos 			lprcat(" stay here");
    506        1.8  christos 		break;
    507        1.1       cgd 
    508        1.8  christos 	default:
    509        1.8  christos 		finditem(i);
    510        1.8  christos 		break;
    511        1.1       cgd 	};
    512        1.1       cgd }
    513        1.1       cgd 
    514        1.1       cgd /*
    515        1.1       cgd 	function to say what object we found and ask if player wants to take it
    516        1.1       cgd  */
    517       1.15  dholland static void
    518       1.12  dholland finditem(int theitem)
    519        1.8  christos {
    520        1.8  christos 	int             tmp, i;
    521       1.12  dholland 	lprintf("\n\nYou have found %s ", objectname[theitem]);
    522        1.8  christos 	tmp = iarg[playerx][playery];
    523       1.12  dholland 	switch (theitem) {
    524        1.8  christos 	case ODIAMOND:
    525        1.8  christos 	case ORUBY:
    526        1.8  christos 	case OEMERALD:
    527        1.8  christos 	case OSAPPHIRE:
    528        1.8  christos 	case OSPIRITSCARAB:
    529        1.8  christos 	case OORBOFDRAGON:
    530        1.8  christos 	case OCUBEofUNDEAD:
    531        1.8  christos 	case ONOTHEFT:
    532        1.8  christos 		break;
    533        1.8  christos 
    534        1.8  christos 	default:
    535        1.8  christos 		if (tmp > 0)
    536       1.11  dholland 			lprintf("+ %ld", (long) tmp);
    537        1.8  christos 		else if (tmp < 0)
    538       1.11  dholland 			lprintf(" %ld", (long) tmp);
    539        1.8  christos 	}
    540        1.8  christos 	lprcat("\nDo you want to (t) take it");
    541        1.8  christos 	iopts();
    542        1.8  christos 	i = 0;
    543        1.8  christos 	while (i != 't' && i != 'i' && i != '\33')
    544       1.13  dholland 		i = ttgetch();
    545        1.8  christos 	if (i == 't') {
    546        1.8  christos 		lprcat("take");
    547       1.12  dholland 		if (take(theitem, tmp) == 0)
    548        1.8  christos 			forget();
    549        1.8  christos 		return;
    550        1.8  christos 	}
    551        1.1       cgd 	ignore();
    552        1.8  christos }
    553        1.8  christos 
    554        1.8  christos 
    555        1.1       cgd 
    556        1.1       cgd /*
    557        1.1       cgd 	subroutine to process the stair cases
    558        1.1       cgd 	if dir > 0 the up else down
    559        1.1       cgd  */
    560       1.15  dholland static void
    561       1.16  dholland ostairs(int dir)
    562        1.8  christos {
    563        1.8  christos 	int    k;
    564        1.1       cgd 	lprcat("\nDo you (s) stay here  ");
    565        1.8  christos 	if (dir > 0)
    566        1.8  christos 		lprcat("(u) go up  ");
    567        1.8  christos 	else
    568        1.8  christos 		lprcat("(d) go down  ");
    569        1.1       cgd 	lprcat("or (f) kick stairs? ");
    570        1.1       cgd 
    571        1.8  christos 	while (1)
    572       1.13  dholland 		switch (ttgetch()) {
    573        1.1       cgd 		case '\33':
    574        1.8  christos 		case 's':
    575        1.8  christos 		case 'i':
    576        1.8  christos 			lprcat("stay here");
    577        1.8  christos 			return;
    578        1.8  christos 
    579        1.8  christos 		case 'f':
    580        1.8  christos 			lprcat("kick stairs");
    581        1.8  christos 			if (rnd(2) == 1)
    582        1.8  christos 				lprcat("\nI hope you feel better.  Showing anger rids you of frustration.");
    583        1.8  christos 			else {
    584        1.8  christos 				k = rnd((level + 1) << 1);
    585       1.11  dholland 				lprintf("\nYou hurt your foot dumb dumb!  You suffer %ld hit points", (long) k);
    586        1.8  christos 				lastnum = 276;
    587        1.8  christos 				losehp(k);
    588        1.8  christos 				bottomline();
    589        1.8  christos 			}
    590        1.8  christos 			return;
    591        1.1       cgd 
    592        1.8  christos 		case 'u':
    593        1.8  christos 			lprcat("go up");
    594        1.8  christos 			if (dir < 0)
    595        1.8  christos 				lprcat("\nThe stairs don't go up!");
    596        1.8  christos 			else if (level >= 2 && level != 11) {
    597        1.8  christos 				k = level;
    598        1.8  christos 				newcavelevel(level - 1);
    599        1.8  christos 				draws(0, MAXX, 0, MAXY);
    600        1.8  christos 				bot_linex();
    601        1.8  christos 			} else
    602        1.8  christos 				lprcat("\nThe stairs lead to a dead end!");
    603        1.8  christos 			return;
    604        1.8  christos 
    605        1.8  christos 		case 'd':
    606        1.8  christos 			lprcat("go down");
    607        1.8  christos 			if (dir > 0)
    608        1.8  christos 				lprcat("\nThe stairs don't go down!");
    609        1.8  christos 			else if (level != 0 && level != 10 && level != 13) {
    610        1.8  christos 				k = level;
    611        1.8  christos 				newcavelevel(level + 1);
    612        1.8  christos 				draws(0, MAXX, 0, MAXY);
    613        1.8  christos 				bot_linex();
    614        1.8  christos 			} else
    615        1.8  christos 				lprcat("\nThe stairs lead to a dead end!");
    616        1.8  christos 			return;
    617        1.1       cgd 		};
    618        1.8  christos }
    619        1.8  christos 
    620        1.8  christos 
    621        1.1       cgd 
    622        1.1       cgd /*
    623        1.1       cgd 	subroutine to handle a teleport trap +/- 1 level maximum
    624        1.1       cgd  */
    625        1.8  christos void
    626       1.16  dholland oteleport(int err)
    627        1.8  christos {
    628        1.8  christos 	int    tmp;
    629        1.8  christos 	if (err)
    630        1.8  christos 		if (rnd(151) < 3)
    631        1.8  christos 			died(264);	/* stuck in a rock */
    632        1.8  christos 	c[TELEFLAG] = 1;	/* show ?? on bottomline if been teleported	 */
    633        1.8  christos 	if (level == 0)
    634        1.8  christos 		tmp = 0;
    635        1.8  christos 	else if (level < MAXLEVEL) {
    636        1.8  christos 		tmp = rnd(5) + level - 3;
    637        1.8  christos 		if (tmp >= MAXLEVEL)
    638        1.8  christos 			tmp = MAXLEVEL - 1;
    639        1.8  christos 		if (tmp < 1)
    640        1.8  christos 			tmp = 1;
    641        1.8  christos 	} else {
    642        1.8  christos 		tmp = rnd(3) + level - 2;
    643        1.8  christos 		if (tmp >= MAXLEVEL + MAXVLEVEL)
    644        1.8  christos 			tmp = MAXLEVEL + MAXVLEVEL - 1;
    645        1.8  christos 		if (tmp < MAXLEVEL)
    646        1.8  christos 			tmp = MAXLEVEL;
    647        1.1       cgd 	}
    648        1.8  christos 	playerx = rnd(MAXX - 2);
    649        1.8  christos 	playery = rnd(MAXY - 2);
    650        1.8  christos 	if (level != tmp)
    651        1.8  christos 		newcavelevel(tmp);
    652        1.8  christos 	positionplayer();
    653        1.8  christos 	draws(0, MAXX, 0, MAXY);
    654        1.8  christos 	bot_linex();
    655        1.8  christos }
    656        1.8  christos 
    657        1.8  christos 
    658        1.1       cgd /*
    659        1.1       cgd 	function to process a potion
    660        1.1       cgd  */
    661       1.15  dholland static void
    662       1.16  dholland opotion(int pot)
    663        1.8  christos {
    664        1.8  christos 	lprcat("\nDo you (d) drink it, (t) take it");
    665        1.8  christos 	iopts();
    666        1.8  christos 	while (1)
    667       1.13  dholland 		switch (ttgetch()) {
    668        1.1       cgd 		case '\33':
    669        1.8  christos 		case 'i':
    670        1.8  christos 			ignore();
    671        1.8  christos 			return;
    672        1.8  christos 
    673        1.8  christos 		case 'd':
    674        1.8  christos 			lprcat("drink\n");
    675        1.8  christos 			forget();	/* destroy potion	 */
    676        1.8  christos 			quaffpotion(pot);
    677        1.8  christos 			return;
    678        1.8  christos 
    679        1.8  christos 		case 't':
    680        1.8  christos 			lprcat("take\n");
    681        1.8  christos 			if (take(OPOTION, pot) == 0)
    682        1.8  christos 				forget();
    683        1.8  christos 			return;
    684        1.8  christos 		};
    685        1.8  christos }
    686        1.1       cgd 
    687        1.1       cgd /*
    688        1.1       cgd 	function to drink a potion
    689        1.1       cgd  */
    690        1.8  christos void
    691       1.16  dholland quaffpotion(int pot)
    692        1.8  christos {
    693        1.8  christos 	int    i, j, k;
    694        1.8  christos 	if (pot < 0 || pot >= MAXPOTION)
    695        1.8  christos 		return;		/* check for within bounds */
    696        1.2   mycroft 	potionname[pot] = potionhide[pot];
    697        1.8  christos 	switch (pot) {
    698        1.8  christos 	case 9:
    699        1.8  christos 		lprcat("\nYou feel greedy . . .");
    700        1.8  christos 		nap(2000);
    701        1.8  christos 		for (i = 0; i < MAXY; i++)
    702        1.8  christos 			for (j = 0; j < MAXX; j++)
    703        1.8  christos 				if ((item[j][i] == OGOLDPILE) || (item[j][i] == OMAXGOLD)) {
    704        1.8  christos 					know[j][i] = 1;
    705        1.8  christos 					show1cell(j, i);
    706        1.8  christos 				}
    707        1.8  christos 		showplayer();
    708        1.8  christos 		return;
    709        1.8  christos 
    710        1.8  christos 	case 19:
    711        1.8  christos 		lprcat("\nYou feel greedy . . .");
    712        1.8  christos 		nap(2000);
    713        1.8  christos 		for (i = 0; i < MAXY; i++)
    714        1.8  christos 			for (j = 0; j < MAXX; j++) {
    715        1.8  christos 				k = item[j][i];
    716        1.8  christos 				if ((k == ODIAMOND) || (k == ORUBY) || (k == OEMERALD) || (k == OMAXGOLD)
    717        1.8  christos 				    || (k == OSAPPHIRE) || (k == OLARNEYE) || (k == OGOLDPILE)) {
    718        1.8  christos 					know[j][i] = 1;
    719        1.8  christos 					show1cell(j, i);
    720        1.8  christos 				}
    721        1.8  christos 			}
    722        1.8  christos 		showplayer();
    723        1.8  christos 		return;
    724        1.8  christos 
    725        1.8  christos 	case 20:
    726        1.8  christos 		c[HP] = c[HPMAX];
    727        1.8  christos 		break;		/* instant healing */
    728        1.8  christos 
    729        1.8  christos 	case 1:
    730        1.8  christos 		lprcat("\nYou feel better");
    731        1.8  christos 		if (c[HP] == c[HPMAX])
    732        1.8  christos 			raisemhp(1);
    733        1.8  christos 		else if ((c[HP] += rnd(20) + 20 + c[LEVEL]) > c[HPMAX])
    734        1.8  christos 			c[HP] = c[HPMAX];
    735        1.8  christos 		break;
    736        1.8  christos 
    737        1.8  christos 	case 2:
    738        1.8  christos 		lprcat("\nSuddenly, you feel much more skillful!");
    739        1.8  christos 		raiselevel();
    740        1.8  christos 		raisemhp(1);
    741        1.8  christos 		return;
    742        1.8  christos 
    743        1.8  christos 	case 3:
    744        1.8  christos 		lprcat("\nYou feel strange for a moment");
    745        1.8  christos 		c[rund(6)]++;
    746        1.8  christos 		break;
    747        1.8  christos 
    748        1.8  christos 	case 4:
    749        1.8  christos 		lprcat("\nYou feel more self confident!");
    750        1.8  christos 		c[WISDOM] += rnd(2);
    751        1.8  christos 		break;
    752        1.8  christos 
    753        1.8  christos 	case 5:
    754        1.8  christos 		lprcat("\nWow!  You feel great!");
    755        1.8  christos 		if (c[STRENGTH] < 12)
    756        1.8  christos 			c[STRENGTH] = 12;
    757        1.8  christos 		else
    758        1.8  christos 			c[STRENGTH]++;
    759        1.8  christos 		break;
    760        1.8  christos 
    761        1.8  christos 	case 6:
    762        1.8  christos 		lprcat("\nYour charm went up by one!");
    763        1.8  christos 		c[CHARISMA]++;
    764        1.8  christos 		break;
    765        1.8  christos 
    766        1.8  christos 	case 8:
    767        1.8  christos 		lprcat("\nYour intelligence went up by one!");
    768        1.8  christos 		c[INTELLIGENCE]++;
    769        1.8  christos 		break;
    770        1.8  christos 
    771        1.8  christos 	case 10:
    772        1.8  christos 		for (i = 0; i < MAXY; i++)
    773        1.8  christos 			for (j = 0; j < MAXX; j++)
    774        1.8  christos 				if (mitem[j][i]) {
    775        1.8  christos 					know[j][i] = 1;
    776        1.8  christos 					show1cell(j, i);
    777        1.8  christos 				}
    778        1.8  christos 		 /* monster detection	 */ return;
    779        1.8  christos 
    780        1.8  christos 	case 12:
    781        1.8  christos 		lprcat("\nThis potion has no taste to it");
    782        1.8  christos 		return;
    783        1.8  christos 
    784        1.8  christos 	case 15:
    785        1.8  christos 		lprcat("\nWOW!!!  You feel Super-fantastic!!!");
    786        1.8  christos 		if (c[HERO] == 0)
    787        1.8  christos 			for (i = 0; i < 6; i++)
    788        1.8  christos 				c[i] += 11;
    789        1.8  christos 		c[HERO] += 250;
    790        1.8  christos 		break;
    791        1.8  christos 
    792        1.8  christos 	case 16:
    793        1.8  christos 		lprcat("\nYou have a greater intestinal constitude!");
    794        1.8  christos 		c[CONSTITUTION]++;
    795        1.8  christos 		break;
    796        1.8  christos 
    797        1.8  christos 	case 17:
    798        1.8  christos 		lprcat("\nYou now have incredibly bulging muscles!!!");
    799        1.8  christos 		if (c[GIANTSTR] == 0)
    800        1.8  christos 			c[STREXTRA] += 21;
    801        1.8  christos 		c[GIANTSTR] += 700;
    802        1.8  christos 		break;
    803        1.8  christos 
    804        1.8  christos 	case 18:
    805        1.8  christos 		lprcat("\nYou feel a chill run up your spine!");
    806        1.8  christos 		c[FIRERESISTANCE] += 1000;
    807        1.8  christos 		break;
    808        1.8  christos 
    809        1.8  christos 	case 0:
    810        1.8  christos 		lprcat("\nYou fall asleep. . .");
    811        1.8  christos 		i = rnd(11) - (c[CONSTITUTION] >> 2) + 2;
    812        1.8  christos 		while (--i > 0) {
    813        1.8  christos 			parse2();
    814        1.8  christos 			nap(1000);
    815        1.8  christos 		}
    816        1.8  christos 		cursors();
    817        1.8  christos 		lprcat("\nYou woke up!");
    818        1.8  christos 		return;
    819        1.8  christos 
    820        1.8  christos 	case 7:
    821        1.8  christos 		lprcat("\nYou become dizzy!");
    822        1.8  christos 		if (--c[STRENGTH] < 3)
    823        1.8  christos 			c[STRENGTH] = 3;
    824        1.8  christos 		break;
    825        1.8  christos 
    826        1.8  christos 	case 11:
    827        1.8  christos 		lprcat("\nYou stagger for a moment . .");
    828        1.8  christos 		for (i = 0; i < MAXY; i++)
    829        1.8  christos 			for (j = 0; j < MAXX; j++)
    830        1.8  christos 				know[j][i] = 0;
    831        1.8  christos 		nap(2000);
    832        1.8  christos 		draws(0, MAXX, 0, MAXY);	/* potion of forgetfulness */
    833        1.8  christos 		return;
    834        1.8  christos 
    835        1.8  christos 	case 13:
    836        1.8  christos 		lprcat("\nYou can't see anything!");	/* blindness */
    837        1.8  christos 		c[BLINDCOUNT] += 500;
    838        1.8  christos 		return;
    839        1.8  christos 
    840        1.8  christos 	case 14:
    841        1.8  christos 		lprcat("\nYou feel confused");
    842        1.8  christos 		c[CONFUSE] += 20 + rnd(9);
    843        1.8  christos 		return;
    844        1.8  christos 
    845        1.8  christos 	case 21:
    846        1.8  christos 		lprcat("\nYou don't seem to be affected");
    847        1.8  christos 		return;		/* cure dianthroritis */
    848        1.8  christos 
    849        1.8  christos 	case 22:
    850        1.8  christos 		lprcat("\nYou feel a sickness engulf you");	/* poison */
    851        1.8  christos 		c[HALFDAM] += 200 + rnd(200);
    852        1.8  christos 		return;
    853        1.8  christos 
    854        1.8  christos 	case 23:
    855        1.8  christos 		lprcat("\nYou feel your vision sharpen");	/* see invisible */
    856        1.8  christos 		c[SEEINVISIBLE] += rnd(1000) + 400;
    857        1.8  christos 		monstnamelist[INVISIBLESTALKER] = 'I';
    858        1.8  christos 		return;
    859        1.8  christos 	};
    860        1.8  christos 	bottomline();		/* show new stats		 */
    861        1.8  christos 	return;
    862        1.8  christos }
    863        1.8  christos 
    864        1.8  christos 
    865        1.1       cgd /*
    866        1.1       cgd 	function to process a magic scroll
    867        1.1       cgd  */
    868       1.15  dholland static void
    869       1.16  dholland oscroll(int typ)
    870        1.8  christos {
    871        1.1       cgd 	lprcat("\nDo you ");
    872        1.8  christos 	if (c[BLINDCOUNT] == 0)
    873        1.8  christos 		lprcat("(r) read it, ");
    874        1.8  christos 	lprcat("(t) take it");
    875        1.8  christos 	iopts();
    876        1.8  christos 	while (1)
    877       1.13  dholland 		switch (ttgetch()) {
    878        1.1       cgd 		case '\33':
    879        1.8  christos 		case 'i':
    880        1.8  christos 			ignore();
    881        1.8  christos 			return;
    882        1.1       cgd 
    883        1.8  christos 		case 'r':
    884        1.8  christos 			if (c[BLINDCOUNT])
    885        1.8  christos 				break;
    886        1.8  christos 			lprcat("read");
    887        1.8  christos 			forget();
    888        1.8  christos 			if (typ == 2 || typ == 15) {
    889        1.8  christos 				show1cell(playerx, playery);
    890        1.8  christos 				cursors();
    891        1.8  christos 			}
    892        1.8  christos 			 /* destroy it	 */ read_scroll(typ);
    893        1.8  christos 			return;
    894        1.1       cgd 
    895        1.8  christos 		case 't':
    896        1.8  christos 			lprcat("take");
    897        1.8  christos 			if (take(OSCROLL, typ) == 0)
    898        1.8  christos 				forget();	/* destroy it	 */
    899        1.8  christos 			return;
    900        1.1       cgd 		};
    901        1.8  christos }
    902        1.1       cgd 
    903        1.1       cgd /*
    904        1.1       cgd 	data for the function to read a scroll
    905        1.1       cgd  */
    906        1.8  christos static int      xh, yh, yl, xl;
    907        1.8  christos static u_char     curse[] = {
    908        1.8  christos 	BLINDCOUNT, CONFUSE, AGGRAVATE, HASTEMONST, ITCHING,
    909        1.8  christos 	LAUGHING, DRAINSTRENGTH, CLUMSINESS, INFEEBLEMENT, HALFDAM
    910        1.8  christos };
    911        1.8  christos 
    912        1.8  christos static u_char     exten[] = {
    913        1.8  christos 	PROTECTIONTIME, DEXCOUNT, STRCOUNT, CHARMCOUNT, INVISIBILITY,
    914        1.8  christos 	CANCELLATION, HASTESELF, GLOBE, SCAREMONST, HOLDMONST, TIMESTOP
    915        1.8  christos };
    916        1.8  christos 
    917       1.15  dholland static u_char time_change[] = {
    918        1.8  christos 	HASTESELF, HERO, ALTPRO, PROTECTIONTIME, DEXCOUNT, STRCOUNT,
    919        1.8  christos 	GIANTSTR, CHARMCOUNT, INVISIBILITY, CANCELLATION, HASTESELF,
    920        1.8  christos 	AGGRAVATE, SCAREMONST, STEALTH, AWARENESS, HOLDMONST,
    921        1.8  christos 	HASTEMONST, FIRERESISTANCE, GLOBE, SPIRITPRO, UNDEADPRO,
    922        1.8  christos 	HALFDAM, SEEINVISIBLE, ITCHING, CLUMSINESS, WTW
    923        1.8  christos };
    924        1.8  christos 
    925        1.1       cgd /*
    926        1.1       cgd  *	function to adjust time when time warping and taking courses in school
    927        1.1       cgd  */
    928        1.8  christos void
    929       1.16  dholland adjusttime(long tim)
    930        1.8  christos {
    931        1.8  christos 	int    j;
    932        1.8  christos 	for (j = 0; j < 26; j++)/* adjust time related parameters */
    933        1.1       cgd 		if (c[time_change[j]])
    934        1.8  christos 			if ((c[time_change[j]] -= tim) < 1)
    935        1.8  christos 				c[time_change[j]] = 1;
    936        1.1       cgd 	regen();
    937        1.8  christos }
    938        1.1       cgd 
    939        1.1       cgd /*
    940        1.1       cgd 	function to read a scroll
    941        1.1       cgd  */
    942        1.8  christos void
    943       1.16  dholland read_scroll(int typ)
    944        1.8  christos {
    945        1.8  christos 	int    i, j;
    946        1.8  christos 	if (typ < 0 || typ >= MAXSCROLL)
    947        1.8  christos 		return;		/* be sure we are within bounds */
    948        1.2   mycroft 	scrollname[typ] = scrollhide[typ];
    949        1.8  christos 	switch (typ) {
    950        1.8  christos 	case 0:
    951        1.8  christos 		lprcat("\nYour armor glows for a moment");
    952        1.8  christos 		enchantarmor();
    953        1.8  christos 		return;
    954        1.8  christos 
    955        1.8  christos 	case 1:
    956        1.8  christos 		lprcat("\nYour weapon glows for a moment");
    957        1.8  christos 		enchweapon();
    958        1.8  christos 		return;		/* enchant weapon */
    959        1.8  christos 
    960        1.8  christos 	case 2:
    961        1.8  christos 		lprcat("\nYou have been granted enlightenment!");
    962        1.8  christos 		yh = min(playery + 7, MAXY);
    963        1.8  christos 		xh = min(playerx + 25, MAXX);
    964        1.8  christos 		yl = max(playery - 7, 0);
    965        1.8  christos 		xl = max(playerx - 25, 0);
    966        1.8  christos 		for (i = yl; i < yh; i++)
    967        1.8  christos 			for (j = xl; j < xh; j++)
    968        1.8  christos 				know[j][i] = 1;
    969        1.8  christos 		nap(2000);
    970        1.8  christos 		draws(xl, xh, yl, yh);
    971        1.8  christos 		return;
    972        1.8  christos 
    973        1.8  christos 	case 3:
    974        1.8  christos 		lprcat("\nThis scroll seems to be blank");
    975        1.8  christos 		return;
    976        1.8  christos 
    977        1.8  christos 	case 4:
    978        1.8  christos 		createmonster(makemonst(level + 1));
    979        1.8  christos 		return;		/* this one creates a monster  */
    980        1.8  christos 
    981        1.8  christos 	case 5:
    982        1.8  christos 		something(level);	/* create artifact		 */
    983        1.8  christos 		return;
    984        1.8  christos 
    985        1.8  christos 	case 6:
    986        1.8  christos 		c[AGGRAVATE] += 800;
    987        1.8  christos 		return;		/* aggravate monsters */
    988        1.8  christos 
    989        1.8  christos 	case 7:
    990        1.8  christos 		gltime += (i = rnd(1000) - 850);	/* time warp */
    991        1.8  christos 		if (i >= 0)
    992       1.11  dholland 			lprintf("\nYou went forward in time by %ld mobuls", (long) ((i + 99) / 100));
    993        1.8  christos 		else
    994       1.11  dholland 			lprintf("\nYou went backward in time by %ld mobuls", (long) (-(i + 99) / 100));
    995        1.8  christos 		adjusttime((long) i);	/* adjust time for time warping */
    996        1.8  christos 		return;
    997        1.8  christos 
    998        1.8  christos 	case 8:
    999        1.8  christos 		oteleport(0);
   1000        1.8  christos 		return;		/* teleportation */
   1001        1.8  christos 
   1002        1.8  christos 	case 9:
   1003        1.8  christos 		c[AWARENESS] += 1800;
   1004        1.8  christos 		return;		/* expanded awareness	 */
   1005        1.8  christos 
   1006        1.8  christos 	case 10:
   1007        1.8  christos 		c[HASTEMONST] += rnd(55) + 12;
   1008        1.8  christos 		return;		/* haste monster */
   1009        1.8  christos 
   1010        1.8  christos 	case 11:
   1011        1.8  christos 		for (i = 0; i < MAXY; i++)
   1012        1.8  christos 			for (j = 0; j < MAXX; j++)
   1013        1.8  christos 				if (mitem[j][i])
   1014        1.8  christos 					hitp[j][i] = monster[mitem[j][i]].hitpoints;
   1015        1.8  christos 		return;		/* monster healing */
   1016        1.8  christos 	case 12:
   1017        1.8  christos 		c[SPIRITPRO] += 300 + rnd(200);
   1018        1.8  christos 		bottomline();
   1019        1.8  christos 		return;		/* spirit protection */
   1020        1.8  christos 
   1021        1.8  christos 	case 13:
   1022        1.8  christos 		c[UNDEADPRO] += 300 + rnd(200);
   1023        1.8  christos 		bottomline();
   1024        1.8  christos 		return;		/* undead protection */
   1025        1.8  christos 
   1026        1.8  christos 	case 14:
   1027        1.8  christos 		c[STEALTH] += 250 + rnd(250);
   1028        1.8  christos 		bottomline();
   1029        1.8  christos 		return;		/* stealth */
   1030        1.8  christos 
   1031        1.8  christos 	case 15:
   1032        1.8  christos 		lprcat("\nYou have been granted enlightenment!");	/* magic mapping */
   1033        1.8  christos 		for (i = 0; i < MAXY; i++)
   1034        1.8  christos 			for (j = 0; j < MAXX; j++)
   1035        1.8  christos 				know[j][i] = 1;
   1036        1.8  christos 		nap(2000);
   1037        1.8  christos 		draws(0, MAXX, 0, MAXY);
   1038        1.8  christos 		return;
   1039        1.8  christos 
   1040        1.8  christos 	case 16:
   1041        1.8  christos 		c[HOLDMONST] += 30;
   1042        1.8  christos 		bottomline();
   1043        1.8  christos 		return;		/* hold monster */
   1044        1.8  christos 
   1045        1.8  christos 	case 17:
   1046        1.8  christos 		for (i = 0; i < 26; i++)	/* gem perfection */
   1047        1.8  christos 			switch (iven[i]) {
   1048        1.8  christos 			case ODIAMOND:
   1049        1.8  christos 			case ORUBY:
   1050        1.8  christos 			case OEMERALD:
   1051        1.8  christos 			case OSAPPHIRE:
   1052        1.8  christos 				j = ivenarg[i];
   1053        1.8  christos 				j &= 255;
   1054        1.8  christos 				j <<= 1;
   1055        1.8  christos 				if (j > 255)
   1056        1.8  christos 					j = 255;	/* double value */
   1057        1.8  christos 				ivenarg[i] = j;
   1058        1.1       cgd 				break;
   1059        1.8  christos 			}
   1060        1.8  christos 		break;
   1061        1.1       cgd 
   1062        1.8  christos 	case 18:
   1063        1.8  christos 		for (i = 0; i < 11; i++)
   1064        1.8  christos 			c[exten[i]] <<= 1;	/* spell extension */
   1065        1.8  christos 		break;
   1066        1.8  christos 
   1067        1.8  christos 	case 19:
   1068        1.8  christos 		for (i = 0; i < 26; i++) {	/* identify */
   1069        1.8  christos 			if (iven[i] == OPOTION)
   1070        1.8  christos 				potionname[ivenarg[i]] = potionhide[ivenarg[i]];
   1071        1.8  christos 			if (iven[i] == OSCROLL)
   1072        1.8  christos 				scrollname[ivenarg[i]] = scrollhide[ivenarg[i]];
   1073        1.8  christos 		}
   1074        1.8  christos 		break;
   1075        1.1       cgd 
   1076        1.8  christos 	case 20:
   1077        1.8  christos 		for (i = 0; i < 10; i++)	/* remove curse */
   1078        1.8  christos 			if (c[curse[i]])
   1079        1.8  christos 				c[curse[i]] = 1;
   1080        1.8  christos 		break;
   1081        1.8  christos 
   1082        1.8  christos 	case 21:
   1083        1.8  christos 		annihilate();
   1084        1.8  christos 		break;		/* scroll of annihilation */
   1085        1.8  christos 
   1086        1.8  christos 	case 22:
   1087        1.8  christos 		godirect(22, 150, "The ray hits the %s", 0, ' ');	/* pulverization */
   1088        1.8  christos 		break;
   1089        1.8  christos 	case 23:
   1090        1.8  christos 		c[LIFEPROT]++;
   1091        1.8  christos 		break;		/* life protection */
   1092        1.8  christos 	};
   1093        1.8  christos }
   1094        1.1       cgd 
   1095        1.1       cgd 
   1096        1.1       cgd 
   1097       1.15  dholland static void
   1098       1.16  dholland oorb(void)
   1099        1.8  christos {
   1100        1.8  christos }
   1101        1.1       cgd 
   1102       1.15  dholland static void
   1103       1.16  dholland opit(void)
   1104        1.8  christos {
   1105        1.8  christos 	int    i;
   1106        1.9     veego 	if (rnd(101) < 81) {
   1107        1.9     veego 		if (rnd(70) > 9 * c[DEXTERITY] - packweight() || rnd(101) < 5) {
   1108        1.8  christos 			if (level == MAXLEVEL - 1)
   1109        1.8  christos 				obottomless();
   1110        1.8  christos 			else if (level == MAXLEVEL + MAXVLEVEL - 1)
   1111        1.8  christos 				obottomless();
   1112        1.8  christos 			else {
   1113        1.8  christos 				if (rnd(101) < 20) {
   1114        1.8  christos 					i = 0;
   1115        1.8  christos 					lprcat("\nYou fell into a pit!  Your fall is cushioned by an unknown force\n");
   1116        1.8  christos 				} else {
   1117        1.8  christos 					i = rnd(level * 3 + 3);
   1118       1.11  dholland 					lprintf("\nYou fell into a pit!  You suffer %ld hit points damage", (long) i);
   1119        1.8  christos 					lastnum = 261;	/* if he dies scoreboard
   1120        1.8  christos 							 * will say so */
   1121        1.1       cgd 				}
   1122        1.8  christos 				losehp(i);
   1123        1.8  christos 				nap(2000);
   1124        1.8  christos 				newcavelevel(level + 1);
   1125        1.8  christos 				draws(0, MAXX, 0, MAXY);
   1126        1.1       cgd 			}
   1127        1.9     veego 		}
   1128        1.9     veego 	}
   1129        1.8  christos }
   1130        1.1       cgd 
   1131       1.15  dholland static void
   1132       1.16  dholland obottomless(void)
   1133        1.8  christos {
   1134        1.8  christos 	lprcat("\nYou fell into a bottomless pit!");
   1135        1.8  christos 	beep();
   1136        1.8  christos 	nap(3000);
   1137        1.8  christos 	died(262);
   1138        1.8  christos }
   1139       1.15  dholland 
   1140       1.15  dholland static void
   1141       1.16  dholland oelevator(int dir)
   1142        1.8  christos {
   1143        1.1       cgd #ifdef lint
   1144        1.8  christos 	int             x;
   1145        1.8  christos 	x = dir;
   1146        1.8  christos 	dir = x;
   1147        1.8  christos #endif	/* lint */
   1148        1.8  christos }
   1149        1.1       cgd 
   1150       1.15  dholland static void
   1151       1.16  dholland ostatue(void)
   1152        1.8  christos {
   1153        1.8  christos }
   1154        1.1       cgd 
   1155       1.15  dholland static void
   1156       1.16  dholland omirror(void)
   1157        1.8  christos {
   1158        1.8  christos }
   1159        1.1       cgd 
   1160       1.15  dholland static void
   1161       1.16  dholland obook(void)
   1162        1.8  christos {
   1163        1.1       cgd 	lprcat("\nDo you ");
   1164        1.8  christos 	if (c[BLINDCOUNT] == 0)
   1165        1.8  christos 		lprcat("(r) read it, ");
   1166        1.8  christos 	lprcat("(t) take it");
   1167        1.8  christos 	iopts();
   1168        1.8  christos 	while (1)
   1169       1.13  dholland 		switch (ttgetch()) {
   1170        1.1       cgd 		case '\33':
   1171        1.8  christos 		case 'i':
   1172        1.8  christos 			ignore();
   1173        1.8  christos 			return;
   1174        1.1       cgd 
   1175        1.8  christos 		case 'r':
   1176        1.8  christos 			if (c[BLINDCOUNT])
   1177        1.8  christos 				break;
   1178        1.8  christos 			lprcat("read");
   1179        1.8  christos 			 /* no more book	 */ readbook(iarg[playerx][playery]);
   1180        1.8  christos 			forget();
   1181        1.8  christos 			return;
   1182        1.8  christos 
   1183        1.8  christos 		case 't':
   1184        1.8  christos 			lprcat("take");
   1185        1.8  christos 			if (take(OBOOK, iarg[playerx][playery]) == 0)
   1186        1.8  christos 				forget();	/* no more book	 */
   1187        1.8  christos 			return;
   1188        1.1       cgd 		};
   1189        1.8  christos }
   1190        1.1       cgd 
   1191        1.1       cgd /*
   1192        1.1       cgd 	function to read a book
   1193        1.1       cgd  */
   1194        1.8  christos void
   1195       1.16  dholland readbook(int lev)
   1196        1.8  christos {
   1197        1.8  christos 	int    i, tmp;
   1198        1.8  christos 	if (lev <= 3)
   1199        1.8  christos 		i = rund((tmp = splev[lev]) ? tmp : 1);
   1200        1.8  christos 	else
   1201        1.8  christos 		i = rnd((tmp = splev[lev] - 9) ? tmp : 1) + 9;
   1202        1.8  christos 	spelknow[i] = 1;
   1203        1.8  christos 	lprintf("\nSpell \"%s\":  %s\n%s", spelcode[i], spelname[i], speldescript[i]);
   1204        1.8  christos 	if (rnd(10) == 4) {
   1205        1.8  christos 		lprcat("\nYour int went up by one!");
   1206        1.8  christos 		c[INTELLIGENCE]++;
   1207        1.8  christos 		bottomline();
   1208        1.1       cgd 	}
   1209        1.8  christos }
   1210        1.1       cgd 
   1211       1.15  dholland static void
   1212       1.12  dholland ocookie(void)
   1213        1.8  christos {
   1214       1.12  dholland 	const char *p;
   1215       1.12  dholland 
   1216        1.8  christos 	lprcat("\nDo you (e) eat it, (t) take it");
   1217        1.8  christos 	iopts();
   1218        1.8  christos 	while (1)
   1219       1.13  dholland 		switch (ttgetch()) {
   1220        1.1       cgd 		case '\33':
   1221        1.8  christos 		case 'i':
   1222        1.8  christos 			ignore();
   1223        1.8  christos 			return;
   1224        1.8  christos 
   1225        1.8  christos 		case 'e':
   1226        1.8  christos 			lprcat("eat\nThe cookie tasted good.");
   1227        1.8  christos 			forget();	/* no more cookie	 */
   1228        1.8  christos 			if (c[BLINDCOUNT])
   1229        1.8  christos 				return;
   1230        1.8  christos 			if (!(p = fortune()))
   1231        1.8  christos 				return;
   1232        1.8  christos 			lprcat("  A message inside the cookie reads:\n");
   1233        1.8  christos 			lprcat(p);
   1234        1.8  christos 			return;
   1235        1.8  christos 
   1236        1.8  christos 		case 't':
   1237        1.8  christos 			lprcat("take");
   1238        1.8  christos 			if (take(OCOOKIE, 0) == 0)
   1239        1.8  christos 				forget();	/* no more book	 */
   1240        1.8  christos 			return;
   1241        1.1       cgd 		};
   1242        1.8  christos }
   1243        1.1       cgd 
   1244        1.1       cgd 
   1245        1.8  christos /*
   1246        1.8  christos  * routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth
   1247        1.8  christos  * 100* the argument
   1248        1.8  christos  */
   1249       1.15  dholland static void
   1250       1.16  dholland ogold(int arg)
   1251        1.8  christos {
   1252        1.8  christos 	long   i;
   1253        1.1       cgd 	i = iarg[playerx][playery];
   1254        1.8  christos 	if (arg == OMAXGOLD)
   1255        1.8  christos 		i *= 100;
   1256        1.8  christos 	else if (arg == OKGOLD)
   1257        1.8  christos 		i *= 1000;
   1258        1.8  christos 	else if (arg == ODGOLD)
   1259        1.8  christos 		i *= 10;
   1260       1.11  dholland 	lprintf("\nIt is worth %ld!", (long) i);
   1261        1.8  christos 	c[GOLD] += i;
   1262        1.8  christos 	bottomgold();
   1263        1.8  christos 	item[playerx][playery] = know[playerx][playery] = 0;	/* destroy gold	 */
   1264        1.8  christos }
   1265        1.1       cgd 
   1266       1.15  dholland static void
   1267       1.16  dholland ohome(void)
   1268        1.8  christos {
   1269        1.8  christos 	int    i;
   1270        1.8  christos 	nosignal = 1;		/* disable signals */
   1271        1.8  christos 	for (i = 0; i < 26; i++)
   1272        1.8  christos 		if (iven[i] == OPOTION)
   1273        1.8  christos 			if (ivenarg[i] == 21) {
   1274        1.8  christos 				iven[i] = 0;	/* remove the potion of cure
   1275        1.8  christos 						 * dianthroritis from
   1276        1.8  christos 						 * inventory */
   1277        1.8  christos 				clear();
   1278        1.8  christos 				lprcat("Congratulations.  You found a potion of cure dianthroritis.\n");
   1279        1.8  christos 				lprcat("\nFrankly, No one thought you could do it.  Boy!  Did you surprise them!\n");
   1280        1.8  christos 				if (gltime > TIMELIMIT) {
   1281        1.8  christos 					lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
   1282        1.8  christos 					lprcat("You didn't make it in time.  In your agony, you kill the doctor,\nyour wife, and yourself!  Too bad!\n");
   1283        1.8  christos 					nap(5000);
   1284        1.8  christos 					died(269);
   1285        1.8  christos 				} else {
   1286        1.8  christos 					lprcat("\nThe doctor is now administering the potion, and in a few moments\n");
   1287        1.8  christos 					lprcat("Your daughter should be well on her way to recovery.\n");
   1288        1.8  christos 					nap(6000);
   1289        1.8  christos 					lprcat("\nThe potion is");
   1290        1.8  christos 					nap(3000);
   1291        1.8  christos 					lprcat(" working!  The doctor thinks that\n");
   1292        1.8  christos 					lprcat("your daughter will recover in a few days.  Congratulations!\n");
   1293        1.8  christos 					beep();
   1294        1.8  christos 					nap(5000);
   1295        1.8  christos 					died(263);
   1296        1.8  christos 				}
   1297        1.1       cgd 			}
   1298        1.8  christos 	while (1) {
   1299        1.8  christos 		clear();
   1300        1.8  christos 		lprintf("Welcome home %s.  Latest word from the doctor is not good.\n", logname);
   1301        1.1       cgd 
   1302        1.8  christos 		if (gltime > TIMELIMIT) {
   1303        1.1       cgd 			lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
   1304        1.1       cgd 			lprcat("You didn't make it in time.  In your agony, you kill the doctor,\nyour wife, and yourself!  Too bad!\n");
   1305        1.8  christos 			nap(5000);
   1306        1.8  christos 			died(269);
   1307        1.8  christos 		}
   1308        1.1       cgd 		lprcat("\nThe diagnosis is confirmed as dianthroritis.  He guesses that\n");
   1309       1.11  dholland 		lprintf("your daughter has only %ld mobuls left in this world.  It's up to you,\n", (long) ((TIMELIMIT - gltime + 99) / 100));
   1310        1.8  christos 		lprintf("%s, to find the only hope for your daughter, the very rare\n", logname);
   1311        1.1       cgd 		lprcat("potion of cure dianthroritis.  It is rumored that only deep in the\n");
   1312        1.1       cgd 		lprcat("depths of the caves can this potion be found.\n\n\n");
   1313        1.8  christos 		lprcat("\n     ----- press ");
   1314        1.8  christos 		standout("return");
   1315        1.8  christos 		lprcat(" to continue, ");
   1316        1.8  christos 		standout("escape");
   1317        1.1       cgd 		lprcat(" to leave ----- ");
   1318       1.13  dholland 		i = ttgetch();
   1319        1.8  christos 		while (i != '\33' && i != '\n')
   1320       1.13  dholland 			i = ttgetch();
   1321        1.8  christos 		if (i == '\33') {
   1322        1.8  christos 			drawscreen();
   1323        1.8  christos 			nosignal = 0;	/* enable signals */
   1324        1.8  christos 			return;
   1325        1.1       cgd 		}
   1326        1.1       cgd 	}
   1327        1.8  christos }
   1328        1.1       cgd 
   1329        1.8  christos /* routine to save program space	 */
   1330        1.8  christos void
   1331       1.16  dholland iopts(void)
   1332        1.8  christos {
   1333        1.8  christos 	lprcat(", or (i) ignore it? ");
   1334        1.8  christos }
   1335        1.8  christos 
   1336        1.8  christos void
   1337       1.16  dholland ignore(void)
   1338        1.8  christos {
   1339        1.8  christos 	lprcat("ignore\n");
   1340        1.8  christos }
   1341