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