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