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