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