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