Home | History | Annotate | Line # | Download | only in larn
object.c revision 1.8
      1 /*	$NetBSD: object.c,v 1.8 1997/10/18 20:03:38 christos 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.8 1997/10/18 20:03:38 christos 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 = getchar();
    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 = getchar();
    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 = getchar();
    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 = getchar();
    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 = getchar();
    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 = getchar();
    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 = getchar();
    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 = getchar();
    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 = getchar();
    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 = getchar();
    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 = getchar();
    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(itm)
    502 	int             itm;
    503 {
    504 	int             tmp, i;
    505 	lprintf("\n\nYou have found %s ", objectname[itm]);
    506 	tmp = iarg[playerx][playery];
    507 	switch (itm) {
    508 	case ODIAMOND:
    509 	case ORUBY:
    510 	case OEMERALD:
    511 	case OSAPPHIRE:
    512 	case OSPIRITSCARAB:
    513 	case OORBOFDRAGON:
    514 	case OCUBEofUNDEAD:
    515 	case ONOTHEFT:
    516 		break;
    517 
    518 	default:
    519 		if (tmp > 0)
    520 			lprintf("+ %d", (long) tmp);
    521 		else if (tmp < 0)
    522 			lprintf(" %d", (long) tmp);
    523 	}
    524 	lprcat("\nDo you want to (t) take it");
    525 	iopts();
    526 	i = 0;
    527 	while (i != 't' && i != 'i' && i != '\33')
    528 		i = getchar();
    529 	if (i == 't') {
    530 		lprcat("take");
    531 		if (take(itm, tmp) == 0)
    532 			forget();
    533 		return;
    534 	}
    535 	ignore();
    536 }
    537 
    538 
    539 
    540 /*
    541 	*******
    542 	OSTAIRS
    543 	*******
    544 
    545 	subroutine to process the stair cases
    546 	if dir > 0 the up else down
    547  */
    548 void
    549 ostairs(dir)
    550 	int             dir;
    551 {
    552 	int    k;
    553 	lprcat("\nDo you (s) stay here  ");
    554 	if (dir > 0)
    555 		lprcat("(u) go up  ");
    556 	else
    557 		lprcat("(d) go down  ");
    558 	lprcat("or (f) kick stairs? ");
    559 
    560 	while (1)
    561 		switch (getchar()) {
    562 		case '\33':
    563 		case 's':
    564 		case 'i':
    565 			lprcat("stay here");
    566 			return;
    567 
    568 		case 'f':
    569 			lprcat("kick stairs");
    570 			if (rnd(2) == 1)
    571 				lprcat("\nI hope you feel better.  Showing anger rids you of frustration.");
    572 			else {
    573 				k = rnd((level + 1) << 1);
    574 				lprintf("\nYou hurt your foot dumb dumb!  You suffer %d hit points", (long) k);
    575 				lastnum = 276;
    576 				losehp(k);
    577 				bottomline();
    578 			}
    579 			return;
    580 
    581 		case 'u':
    582 			lprcat("go up");
    583 			if (dir < 0)
    584 				lprcat("\nThe stairs don't go up!");
    585 			else if (level >= 2 && level != 11) {
    586 				k = level;
    587 				newcavelevel(level - 1);
    588 				draws(0, MAXX, 0, MAXY);
    589 				bot_linex();
    590 			} else
    591 				lprcat("\nThe stairs lead to a dead end!");
    592 			return;
    593 
    594 		case 'd':
    595 			lprcat("go down");
    596 			if (dir > 0)
    597 				lprcat("\nThe stairs don't go down!");
    598 			else if (level != 0 && level != 10 && level != 13) {
    599 				k = level;
    600 				newcavelevel(level + 1);
    601 				draws(0, MAXX, 0, MAXY);
    602 				bot_linex();
    603 			} else
    604 				lprcat("\nThe stairs lead to a dead end!");
    605 			return;
    606 		};
    607 }
    608 
    609 
    610 
    611 /*
    612 	*********
    613 	OTELEPORTER
    614 	*********
    615 
    616 	subroutine to handle a teleport trap +/- 1 level maximum
    617  */
    618 void
    619 oteleport(err)
    620 	int             err;
    621 {
    622 	int    tmp;
    623 	if (err)
    624 		if (rnd(151) < 3)
    625 			died(264);	/* stuck in a rock */
    626 	c[TELEFLAG] = 1;	/* show ?? on bottomline if been teleported	 */
    627 	if (level == 0)
    628 		tmp = 0;
    629 	else if (level < MAXLEVEL) {
    630 		tmp = rnd(5) + level - 3;
    631 		if (tmp >= MAXLEVEL)
    632 			tmp = MAXLEVEL - 1;
    633 		if (tmp < 1)
    634 			tmp = 1;
    635 	} else {
    636 		tmp = rnd(3) + level - 2;
    637 		if (tmp >= MAXLEVEL + MAXVLEVEL)
    638 			tmp = MAXLEVEL + MAXVLEVEL - 1;
    639 		if (tmp < MAXLEVEL)
    640 			tmp = MAXLEVEL;
    641 	}
    642 	playerx = rnd(MAXX - 2);
    643 	playery = rnd(MAXY - 2);
    644 	if (level != tmp)
    645 		newcavelevel(tmp);
    646 	positionplayer();
    647 	draws(0, MAXX, 0, MAXY);
    648 	bot_linex();
    649 }
    650 
    651 
    652 /*
    653 	*******
    654 	OPOTION
    655 	*******
    656 
    657 	function to process a potion
    658  */
    659 void
    660 opotion(pot)
    661 	int             pot;
    662 {
    663 	lprcat("\nDo you (d) drink it, (t) take it");
    664 	iopts();
    665 	while (1)
    666 		switch (getchar()) {
    667 		case '\33':
    668 		case 'i':
    669 			ignore();
    670 			return;
    671 
    672 		case 'd':
    673 			lprcat("drink\n");
    674 			forget();	/* destroy potion	 */
    675 			quaffpotion(pot);
    676 			return;
    677 
    678 		case 't':
    679 			lprcat("take\n");
    680 			if (take(OPOTION, pot) == 0)
    681 				forget();
    682 			return;
    683 		};
    684 }
    685 
    686 /*
    687 	function to drink a potion
    688  */
    689 void
    690 quaffpotion(pot)
    691 	int             pot;
    692 {
    693 	int    i, j, k;
    694 	if (pot < 0 || pot >= MAXPOTION)
    695 		return;		/* check for within bounds */
    696 	potionname[pot] = potionhide[pot];
    697 	switch (pot) {
    698 	case 9:
    699 		lprcat("\nYou feel greedy . . .");
    700 		nap(2000);
    701 		for (i = 0; i < MAXY; i++)
    702 			for (j = 0; j < MAXX; j++)
    703 				if ((item[j][i] == OGOLDPILE) || (item[j][i] == OMAXGOLD)) {
    704 					know[j][i] = 1;
    705 					show1cell(j, i);
    706 				}
    707 		showplayer();
    708 		return;
    709 
    710 	case 19:
    711 		lprcat("\nYou feel greedy . . .");
    712 		nap(2000);
    713 		for (i = 0; i < MAXY; i++)
    714 			for (j = 0; j < MAXX; j++) {
    715 				k = item[j][i];
    716 				if ((k == ODIAMOND) || (k == ORUBY) || (k == OEMERALD) || (k == OMAXGOLD)
    717 				    || (k == OSAPPHIRE) || (k == OLARNEYE) || (k == OGOLDPILE)) {
    718 					know[j][i] = 1;
    719 					show1cell(j, i);
    720 				}
    721 			}
    722 		showplayer();
    723 		return;
    724 
    725 	case 20:
    726 		c[HP] = c[HPMAX];
    727 		break;		/* instant healing */
    728 
    729 	case 1:
    730 		lprcat("\nYou feel better");
    731 		if (c[HP] == c[HPMAX])
    732 			raisemhp(1);
    733 		else if ((c[HP] += rnd(20) + 20 + c[LEVEL]) > c[HPMAX])
    734 			c[HP] = c[HPMAX];
    735 		break;
    736 
    737 	case 2:
    738 		lprcat("\nSuddenly, you feel much more skillful!");
    739 		raiselevel();
    740 		raisemhp(1);
    741 		return;
    742 
    743 	case 3:
    744 		lprcat("\nYou feel strange for a moment");
    745 		c[rund(6)]++;
    746 		break;
    747 
    748 	case 4:
    749 		lprcat("\nYou feel more self confident!");
    750 		c[WISDOM] += rnd(2);
    751 		break;
    752 
    753 	case 5:
    754 		lprcat("\nWow!  You feel great!");
    755 		if (c[STRENGTH] < 12)
    756 			c[STRENGTH] = 12;
    757 		else
    758 			c[STRENGTH]++;
    759 		break;
    760 
    761 	case 6:
    762 		lprcat("\nYour charm went up by one!");
    763 		c[CHARISMA]++;
    764 		break;
    765 
    766 	case 8:
    767 		lprcat("\nYour intelligence went up by one!");
    768 		c[INTELLIGENCE]++;
    769 		break;
    770 
    771 	case 10:
    772 		for (i = 0; i < MAXY; i++)
    773 			for (j = 0; j < MAXX; j++)
    774 				if (mitem[j][i]) {
    775 					know[j][i] = 1;
    776 					show1cell(j, i);
    777 				}
    778 		 /* monster detection	 */ return;
    779 
    780 	case 12:
    781 		lprcat("\nThis potion has no taste to it");
    782 		return;
    783 
    784 	case 15:
    785 		lprcat("\nWOW!!!  You feel Super-fantastic!!!");
    786 		if (c[HERO] == 0)
    787 			for (i = 0; i < 6; i++)
    788 				c[i] += 11;
    789 		c[HERO] += 250;
    790 		break;
    791 
    792 	case 16:
    793 		lprcat("\nYou have a greater intestinal constitude!");
    794 		c[CONSTITUTION]++;
    795 		break;
    796 
    797 	case 17:
    798 		lprcat("\nYou now have incredibly bulging muscles!!!");
    799 		if (c[GIANTSTR] == 0)
    800 			c[STREXTRA] += 21;
    801 		c[GIANTSTR] += 700;
    802 		break;
    803 
    804 	case 18:
    805 		lprcat("\nYou feel a chill run up your spine!");
    806 		c[FIRERESISTANCE] += 1000;
    807 		break;
    808 
    809 	case 0:
    810 		lprcat("\nYou fall asleep. . .");
    811 		i = rnd(11) - (c[CONSTITUTION] >> 2) + 2;
    812 		while (--i > 0) {
    813 			parse2();
    814 			nap(1000);
    815 		}
    816 		cursors();
    817 		lprcat("\nYou woke up!");
    818 		return;
    819 
    820 	case 7:
    821 		lprcat("\nYou become dizzy!");
    822 		if (--c[STRENGTH] < 3)
    823 			c[STRENGTH] = 3;
    824 		break;
    825 
    826 	case 11:
    827 		lprcat("\nYou stagger for a moment . .");
    828 		for (i = 0; i < MAXY; i++)
    829 			for (j = 0; j < MAXX; j++)
    830 				know[j][i] = 0;
    831 		nap(2000);
    832 		draws(0, MAXX, 0, MAXY);	/* potion of forgetfulness */
    833 		return;
    834 
    835 	case 13:
    836 		lprcat("\nYou can't see anything!");	/* blindness */
    837 		c[BLINDCOUNT] += 500;
    838 		return;
    839 
    840 	case 14:
    841 		lprcat("\nYou feel confused");
    842 		c[CONFUSE] += 20 + rnd(9);
    843 		return;
    844 
    845 	case 21:
    846 		lprcat("\nYou don't seem to be affected");
    847 		return;		/* cure dianthroritis */
    848 
    849 	case 22:
    850 		lprcat("\nYou feel a sickness engulf you");	/* poison */
    851 		c[HALFDAM] += 200 + rnd(200);
    852 		return;
    853 
    854 	case 23:
    855 		lprcat("\nYou feel your vision sharpen");	/* see invisible */
    856 		c[SEEINVISIBLE] += rnd(1000) + 400;
    857 		monstnamelist[INVISIBLESTALKER] = 'I';
    858 		return;
    859 	};
    860 	bottomline();		/* show new stats		 */
    861 	return;
    862 }
    863 
    864 
    865 /*
    866 	*******
    867 	OSCROLL
    868 	*******
    869 
    870 	function to process a magic scroll
    871  */
    872 void
    873 oscroll(typ)
    874 	int             typ;
    875 {
    876 	lprcat("\nDo you ");
    877 	if (c[BLINDCOUNT] == 0)
    878 		lprcat("(r) read it, ");
    879 	lprcat("(t) take it");
    880 	iopts();
    881 	while (1)
    882 		switch (getchar()) {
    883 		case '\33':
    884 		case 'i':
    885 			ignore();
    886 			return;
    887 
    888 		case 'r':
    889 			if (c[BLINDCOUNT])
    890 				break;
    891 			lprcat("read");
    892 			forget();
    893 			if (typ == 2 || typ == 15) {
    894 				show1cell(playerx, playery);
    895 				cursors();
    896 			}
    897 			 /* destroy it	 */ read_scroll(typ);
    898 			return;
    899 
    900 		case 't':
    901 			lprcat("take");
    902 			if (take(OSCROLL, typ) == 0)
    903 				forget();	/* destroy it	 */
    904 			return;
    905 		};
    906 }
    907 
    908 /*
    909 	data for the function to read a scroll
    910  */
    911 static int      xh, yh, yl, xl;
    912 static u_char     curse[] = {
    913 	BLINDCOUNT, CONFUSE, AGGRAVATE, HASTEMONST, ITCHING,
    914 	LAUGHING, DRAINSTRENGTH, CLUMSINESS, INFEEBLEMENT, HALFDAM
    915 };
    916 
    917 static u_char     exten[] = {
    918 	PROTECTIONTIME, DEXCOUNT, STRCOUNT, CHARMCOUNT, INVISIBILITY,
    919 	CANCELLATION, HASTESELF, GLOBE, SCAREMONST, HOLDMONST, TIMESTOP
    920 };
    921 
    922 u_char time_change[] = {
    923 	HASTESELF, HERO, ALTPRO, PROTECTIONTIME, DEXCOUNT, STRCOUNT,
    924 	GIANTSTR, CHARMCOUNT, INVISIBILITY, CANCELLATION, HASTESELF,
    925 	AGGRAVATE, SCAREMONST, STEALTH, AWARENESS, HOLDMONST,
    926 	HASTEMONST, FIRERESISTANCE, GLOBE, SPIRITPRO, UNDEADPRO,
    927 	HALFDAM, SEEINVISIBLE, ITCHING, CLUMSINESS, WTW
    928 };
    929 
    930 /*
    931  *	function to adjust time when time warping and taking courses in school
    932  */
    933 void
    934 adjusttime(tim)
    935 	long   tim;
    936 {
    937 	int    j;
    938 	for (j = 0; j < 26; j++)/* adjust time related parameters */
    939 		if (c[time_change[j]])
    940 			if ((c[time_change[j]] -= tim) < 1)
    941 				c[time_change[j]] = 1;
    942 	regen();
    943 }
    944 
    945 /*
    946 	function to read a scroll
    947  */
    948 void
    949 read_scroll(typ)
    950 	int             typ;
    951 {
    952 	int    i, j;
    953 	if (typ < 0 || typ >= MAXSCROLL)
    954 		return;		/* be sure we are within bounds */
    955 	scrollname[typ] = scrollhide[typ];
    956 	switch (typ) {
    957 	case 0:
    958 		lprcat("\nYour armor glows for a moment");
    959 		enchantarmor();
    960 		return;
    961 
    962 	case 1:
    963 		lprcat("\nYour weapon glows for a moment");
    964 		enchweapon();
    965 		return;		/* enchant weapon */
    966 
    967 	case 2:
    968 		lprcat("\nYou have been granted enlightenment!");
    969 		yh = min(playery + 7, MAXY);
    970 		xh = min(playerx + 25, MAXX);
    971 		yl = max(playery - 7, 0);
    972 		xl = max(playerx - 25, 0);
    973 		for (i = yl; i < yh; i++)
    974 			for (j = xl; j < xh; j++)
    975 				know[j][i] = 1;
    976 		nap(2000);
    977 		draws(xl, xh, yl, yh);
    978 		return;
    979 
    980 	case 3:
    981 		lprcat("\nThis scroll seems to be blank");
    982 		return;
    983 
    984 	case 4:
    985 		createmonster(makemonst(level + 1));
    986 		return;		/* this one creates a monster  */
    987 
    988 	case 5:
    989 		something(level);	/* create artifact		 */
    990 		return;
    991 
    992 	case 6:
    993 		c[AGGRAVATE] += 800;
    994 		return;		/* aggravate monsters */
    995 
    996 	case 7:
    997 		gltime += (i = rnd(1000) - 850);	/* time warp */
    998 		if (i >= 0)
    999 			lprintf("\nYou went forward in time by %d mobuls", (long) ((i + 99) / 100));
   1000 		else
   1001 			lprintf("\nYou went backward in time by %d mobuls", (long) (-(i + 99) / 100));
   1002 		adjusttime((long) i);	/* adjust time for time warping */
   1003 		return;
   1004 
   1005 	case 8:
   1006 		oteleport(0);
   1007 		return;		/* teleportation */
   1008 
   1009 	case 9:
   1010 		c[AWARENESS] += 1800;
   1011 		return;		/* expanded awareness	 */
   1012 
   1013 	case 10:
   1014 		c[HASTEMONST] += rnd(55) + 12;
   1015 		return;		/* haste monster */
   1016 
   1017 	case 11:
   1018 		for (i = 0; i < MAXY; i++)
   1019 			for (j = 0; j < MAXX; j++)
   1020 				if (mitem[j][i])
   1021 					hitp[j][i] = monster[mitem[j][i]].hitpoints;
   1022 		return;		/* monster healing */
   1023 	case 12:
   1024 		c[SPIRITPRO] += 300 + rnd(200);
   1025 		bottomline();
   1026 		return;		/* spirit protection */
   1027 
   1028 	case 13:
   1029 		c[UNDEADPRO] += 300 + rnd(200);
   1030 		bottomline();
   1031 		return;		/* undead protection */
   1032 
   1033 	case 14:
   1034 		c[STEALTH] += 250 + rnd(250);
   1035 		bottomline();
   1036 		return;		/* stealth */
   1037 
   1038 	case 15:
   1039 		lprcat("\nYou have been granted enlightenment!");	/* magic mapping */
   1040 		for (i = 0; i < MAXY; i++)
   1041 			for (j = 0; j < MAXX; j++)
   1042 				know[j][i] = 1;
   1043 		nap(2000);
   1044 		draws(0, MAXX, 0, MAXY);
   1045 		return;
   1046 
   1047 	case 16:
   1048 		c[HOLDMONST] += 30;
   1049 		bottomline();
   1050 		return;		/* hold monster */
   1051 
   1052 	case 17:
   1053 		for (i = 0; i < 26; i++)	/* gem perfection */
   1054 			switch (iven[i]) {
   1055 			case ODIAMOND:
   1056 			case ORUBY:
   1057 			case OEMERALD:
   1058 			case OSAPPHIRE:
   1059 				j = ivenarg[i];
   1060 				j &= 255;
   1061 				j <<= 1;
   1062 				if (j > 255)
   1063 					j = 255;	/* double value */
   1064 				ivenarg[i] = j;
   1065 				break;
   1066 			}
   1067 		break;
   1068 
   1069 	case 18:
   1070 		for (i = 0; i < 11; i++)
   1071 			c[exten[i]] <<= 1;	/* spell extension */
   1072 		break;
   1073 
   1074 	case 19:
   1075 		for (i = 0; i < 26; i++) {	/* identify */
   1076 			if (iven[i] == OPOTION)
   1077 				potionname[ivenarg[i]] = potionhide[ivenarg[i]];
   1078 			if (iven[i] == OSCROLL)
   1079 				scrollname[ivenarg[i]] = scrollhide[ivenarg[i]];
   1080 		}
   1081 		break;
   1082 
   1083 	case 20:
   1084 		for (i = 0; i < 10; i++)	/* remove curse */
   1085 			if (c[curse[i]])
   1086 				c[curse[i]] = 1;
   1087 		break;
   1088 
   1089 	case 21:
   1090 		annihilate();
   1091 		break;		/* scroll of annihilation */
   1092 
   1093 	case 22:
   1094 		godirect(22, 150, "The ray hits the %s", 0, ' ');	/* pulverization */
   1095 		break;
   1096 	case 23:
   1097 		c[LIFEPROT]++;
   1098 		break;		/* life protection */
   1099 	};
   1100 }
   1101 
   1102 
   1103 
   1104 void
   1105 oorb()
   1106 {
   1107 }
   1108 
   1109 void
   1110 opit()
   1111 {
   1112 	int    i;
   1113 	if (rnd(101) < 81)
   1114 		if (rnd(70) > 9 * c[DEXTERITY] - packweight() || rnd(101) < 5)
   1115 			if (level == MAXLEVEL - 1)
   1116 				obottomless();
   1117 			else if (level == MAXLEVEL + MAXVLEVEL - 1)
   1118 				obottomless();
   1119 			else {
   1120 				if (rnd(101) < 20) {
   1121 					i = 0;
   1122 					lprcat("\nYou fell into a pit!  Your fall is cushioned by an unknown force\n");
   1123 				} else {
   1124 					i = rnd(level * 3 + 3);
   1125 					lprintf("\nYou fell into a pit!  You suffer %d hit points damage", (long) i);
   1126 					lastnum = 261;	/* if he dies scoreboard
   1127 							 * will say so */
   1128 				}
   1129 				losehp(i);
   1130 				nap(2000);
   1131 				newcavelevel(level + 1);
   1132 				draws(0, MAXX, 0, MAXY);
   1133 			}
   1134 }
   1135 
   1136 void
   1137 obottomless()
   1138 {
   1139 	lprcat("\nYou fell into a bottomless pit!");
   1140 	beep();
   1141 	nap(3000);
   1142 	died(262);
   1143 }
   1144 void
   1145 oelevator(dir)
   1146 	int             dir;
   1147 {
   1148 #ifdef lint
   1149 	int             x;
   1150 	x = dir;
   1151 	dir = x;
   1152 #endif	/* lint */
   1153 }
   1154 
   1155 void
   1156 ostatue()
   1157 {
   1158 }
   1159 
   1160 void
   1161 omirror()
   1162 {
   1163 }
   1164 
   1165 void
   1166 obook()
   1167 {
   1168 	lprcat("\nDo you ");
   1169 	if (c[BLINDCOUNT] == 0)
   1170 		lprcat("(r) read it, ");
   1171 	lprcat("(t) take it");
   1172 	iopts();
   1173 	while (1)
   1174 		switch (getchar()) {
   1175 		case '\33':
   1176 		case 'i':
   1177 			ignore();
   1178 			return;
   1179 
   1180 		case 'r':
   1181 			if (c[BLINDCOUNT])
   1182 				break;
   1183 			lprcat("read");
   1184 			 /* no more book	 */ readbook(iarg[playerx][playery]);
   1185 			forget();
   1186 			return;
   1187 
   1188 		case 't':
   1189 			lprcat("take");
   1190 			if (take(OBOOK, iarg[playerx][playery]) == 0)
   1191 				forget();	/* no more book	 */
   1192 			return;
   1193 		};
   1194 }
   1195 
   1196 /*
   1197 	function to read a book
   1198  */
   1199 void
   1200 readbook(lev)
   1201 	int    lev;
   1202 {
   1203 	int    i, tmp;
   1204 	if (lev <= 3)
   1205 		i = rund((tmp = splev[lev]) ? tmp : 1);
   1206 	else
   1207 		i = rnd((tmp = splev[lev] - 9) ? tmp : 1) + 9;
   1208 	spelknow[i] = 1;
   1209 	lprintf("\nSpell \"%s\":  %s\n%s", spelcode[i], spelname[i], speldescript[i]);
   1210 	if (rnd(10) == 4) {
   1211 		lprcat("\nYour int went up by one!");
   1212 		c[INTELLIGENCE]++;
   1213 		bottomline();
   1214 	}
   1215 }
   1216 
   1217 void
   1218 ocookie()
   1219 {
   1220 	char           *p;
   1221 	lprcat("\nDo you (e) eat it, (t) take it");
   1222 	iopts();
   1223 	while (1)
   1224 		switch (getchar()) {
   1225 		case '\33':
   1226 		case 'i':
   1227 			ignore();
   1228 			return;
   1229 
   1230 		case 'e':
   1231 			lprcat("eat\nThe cookie tasted good.");
   1232 			forget();	/* no more cookie	 */
   1233 			if (c[BLINDCOUNT])
   1234 				return;
   1235 			if (!(p = fortune()))
   1236 				return;
   1237 			lprcat("  A message inside the cookie reads:\n");
   1238 			lprcat(p);
   1239 			return;
   1240 
   1241 		case 't':
   1242 			lprcat("take");
   1243 			if (take(OCOOKIE, 0) == 0)
   1244 				forget();	/* no more book	 */
   1245 			return;
   1246 		};
   1247 }
   1248 
   1249 
   1250 /*
   1251  * routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth
   1252  * 100* the argument
   1253  */
   1254 void
   1255 ogold(arg)
   1256 	int             arg;
   1257 {
   1258 	long   i;
   1259 	i = iarg[playerx][playery];
   1260 	if (arg == OMAXGOLD)
   1261 		i *= 100;
   1262 	else if (arg == OKGOLD)
   1263 		i *= 1000;
   1264 	else if (arg == ODGOLD)
   1265 		i *= 10;
   1266 	lprintf("\nIt is worth %d!", (long) i);
   1267 	c[GOLD] += i;
   1268 	bottomgold();
   1269 	item[playerx][playery] = know[playerx][playery] = 0;	/* destroy gold	 */
   1270 }
   1271 
   1272 void
   1273 ohome()
   1274 {
   1275 	int    i;
   1276 	nosignal = 1;		/* disable signals */
   1277 	for (i = 0; i < 26; i++)
   1278 		if (iven[i] == OPOTION)
   1279 			if (ivenarg[i] == 21) {
   1280 				iven[i] = 0;	/* remove the potion of cure
   1281 						 * dianthroritis from
   1282 						 * inventory */
   1283 				clear();
   1284 				lprcat("Congratulations.  You found a potion of cure dianthroritis.\n");
   1285 				lprcat("\nFrankly, No one thought you could do it.  Boy!  Did you surprise them!\n");
   1286 				if (gltime > TIMELIMIT) {
   1287 					lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
   1288 					lprcat("You didn't make it in time.  In your agony, you kill the doctor,\nyour wife, and yourself!  Too bad!\n");
   1289 					nap(5000);
   1290 					died(269);
   1291 				} else {
   1292 					lprcat("\nThe doctor is now administering the potion, and in a few moments\n");
   1293 					lprcat("Your daughter should be well on her way to recovery.\n");
   1294 					nap(6000);
   1295 					lprcat("\nThe potion is");
   1296 					nap(3000);
   1297 					lprcat(" working!  The doctor thinks that\n");
   1298 					lprcat("your daughter will recover in a few days.  Congratulations!\n");
   1299 					beep();
   1300 					nap(5000);
   1301 					died(263);
   1302 				}
   1303 			}
   1304 	while (1) {
   1305 		clear();
   1306 		lprintf("Welcome home %s.  Latest word from the doctor is not good.\n", logname);
   1307 
   1308 		if (gltime > TIMELIMIT) {
   1309 			lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
   1310 			lprcat("You didn't make it in time.  In your agony, you kill the doctor,\nyour wife, and yourself!  Too bad!\n");
   1311 			nap(5000);
   1312 			died(269);
   1313 		}
   1314 		lprcat("\nThe diagnosis is confirmed as dianthroritis.  He guesses that\n");
   1315 		lprintf("your daughter has only %d mobuls left in this world.  It's up to you,\n", (long) ((TIMELIMIT - gltime + 99) / 100));
   1316 		lprintf("%s, to find the only hope for your daughter, the very rare\n", logname);
   1317 		lprcat("potion of cure dianthroritis.  It is rumored that only deep in the\n");
   1318 		lprcat("depths of the caves can this potion be found.\n\n\n");
   1319 		lprcat("\n     ----- press ");
   1320 		standout("return");
   1321 		lprcat(" to continue, ");
   1322 		standout("escape");
   1323 		lprcat(" to leave ----- ");
   1324 		i = getchar();
   1325 		while (i != '\33' && i != '\n')
   1326 			i = getchar();
   1327 		if (i == '\33') {
   1328 			drawscreen();
   1329 			nosignal = 0;	/* enable signals */
   1330 			return;
   1331 		}
   1332 	}
   1333 }
   1334 
   1335 /* routine to save program space	 */
   1336 void
   1337 iopts()
   1338 {
   1339 	lprcat(", or (i) ignore it? ");
   1340 }
   1341 
   1342 void
   1343 ignore()
   1344 {
   1345 	lprcat("ignore\n");
   1346 }
   1347