Home | History | Annotate | Line # | Download | only in larn
object.c revision 1.4
      1 #ifndef lint
      2 static char rcsid[] = "$Id: object.c,v 1.4 1994/10/21 21:26:12 mycroft Exp $";
      3 #endif /* not lint */
      4 
      5 /*	object.c		Larn is copyrighted 1986 by Noah Morgan. */
      6 #include "header.h"
      7 
      8 /*
      9 	***************
     10 	LOOK_FOR_OBJECT
     11 	***************
     12 
     13 	subroutine to look for an object and give the player his options
     14 	if an object was found.
     15  */
     16 lookforobject()
     17 {
     18 register int i,j;
     19 if (c[TIMESTOP])  return;	/* can't find objects is time is stopped	*/
     20 i=item[playerx][playery];	if (i==0) return;
     21 showcell(playerx,playery);  cursors();  yrepcount=0;
     22 switch(i)
     23 	{
     24 	case OGOLDPILE:	case OMAXGOLD:
     25 	case OKGOLD:	case ODGOLD:	lprcat("\n\nYou have found some gold!");	ogold(i);	break;
     26 
     27 	case OPOTION:	lprcat("\n\nYou have found a magic potion");
     28 				i = iarg[playerx][playery];
     29 				if (potionname[i][0]!=0)	lprintf(" of%s", potionname[i]);
     30 				opotion(i);  break;
     31 
     32 	case OSCROLL:	lprcat("\n\nYou have found a magic scroll");
     33 				i = iarg[playerx][playery];
     34 				if (scrollname[i][0]!=0)	lprintf(" of%s", scrollname[i]);
     35 				oscroll(i);  break;
     36 
     37 	case OALTAR:	if (nearbymonst()) return;
     38 					lprcat("\n\nThere is a Holy Altar here!"); oaltar(); break;
     39 
     40 	case OBOOK:	lprcat("\n\nYou have found a book."); obook(); break;
     41 
     42 	case OCOOKIE:	lprcat("\n\nYou have found a fortune cookie."); ocookie(); break;
     43 
     44 	case OTHRONE:	if (nearbymonst()) return;
     45 					lprintf("\n\nThere is %s here!",objectname[i]); othrone(0); break;
     46 
     47 	case OTHRONE2:	if (nearbymonst()) return;
     48 					lprintf("\n\nThere is %s here!",objectname[i]); othrone(1); break;
     49 
     50 	case ODEADTHRONE: lprintf("\n\nThere is %s here!",objectname[i]); odeadthrone(); break;
     51 
     52 	case OORB:		lprcat("\n\nYou have found the Orb!!!!!"); oorb(); break;
     53 
     54 	case OPIT:		lprcat("\n\nYou're standing at the top of a pit."); opit(); break;
     55 
     56 	case OSTAIRSUP:		lprcat("\n\nThere is a circular staircase here"); ostairs(1);  /* up */ break;
     57 
     58 	case OELEVATORUP:	lprcat("\n\nYou feel heavy for a moment, but the feeling disappears");
     59 				oelevator(1);  /*  up  */  break;
     60 
     61 	case OFOUNTAIN:	if (nearbymonst()) return;
     62 					lprcat("\n\nThere is a fountain here"); ofountain(); break;
     63 
     64 	case OSTATUE:	if (nearbymonst()) return;
     65 					lprcat("\n\nYou are standing in front of a statue"); ostatue(); break;
     66 
     67 	case OCHEST:	lprcat("\n\nThere is a chest here");  ochest();  break;
     68 
     69 	case OIVTELETRAP:	if (rnd(11)<6) return;
     70 						item[playerx][playery] = OTELEPORTER;
     71 						know[playerx][playery] = 1;
     72 
     73 	case OTELEPORTER:	lprcat("\nZaaaappp!  You've been teleported!\n");
     74 						beep(); nap(3000); oteleport(0);
     75 						break;
     76 
     77 	case OSCHOOL:	if (nearbymonst()) return;
     78 				lprcat("\n\nYou have found the College of Larn.");
     79 				lprcat("\nDo you (g) go inside, or (i) stay here? ");
     80 				i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
     81 				if (i == 'g') { oschool();  /*	the college of larn	*/ }
     82 				else	lprcat(" stay here");
     83 				break;
     84 
     85 	case OMIRROR:	if (nearbymonst()) return;
     86 					lprcat("\n\nThere is a mirror here");	omirror();	break;
     87 
     88 	case OBANK2:
     89 	case OBANK:	if (nearbymonst()) return;
     90 				if (i==OBANK) lprcat("\n\nYou have found the bank of Larn.");
     91 				else lprcat("\n\nYou have found a branch office of the bank of Larn.");
     92 				lprcat("\nDo you (g) go inside, or (i) stay here? ");
     93 				j=0; while ((j!='g') && (j!='i') && (j!='\33')) j=getchar();
     94 				if (j == 'g') {  if (i==OBANK) obank(); else obank2(); /*  the bank of larn  */  }
     95 				else   lprcat(" stay here");
     96 				break;
     97 
     98 	case ODEADFOUNTAIN:	if (nearbymonst()) return;
     99 						lprcat("\n\nThere is a dead fountain here"); break;
    100 
    101 	case ODNDSTORE:	if (nearbymonst()) return;
    102 					lprcat("\n\nThere is a DND store here.");
    103 					lprcat("\nDo you (g) go inside, or (i) stay here? ");
    104 					i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
    105 					if (i == 'g')
    106 						dndstore();  /*  the dnd adventurers store  */
    107 					else  lprcat(" stay here");
    108 					break;
    109 
    110 	case OSTAIRSDOWN:	lprcat("\n\nThere is a circular staircase here"); ostairs(-1); /* down */ break;
    111 
    112 	case OELEVATORDOWN:	lprcat("\n\nYou feel light for a moment, but the feeling disappears");
    113 				oelevator(-1);	/*	down	*/
    114 				break;
    115 
    116 	case OOPENDOOR:		lprintf("\n\nYou have found %s",objectname[i]);
    117 						lprcat("\nDo you (c) close it"); iopts();
    118 						i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar();
    119 						if ((i=='\33') || (i=='i')) { ignore();  break; }
    120 						lprcat("close");  forget();
    121 						item[playerx][playery]=OCLOSEDDOOR;
    122 						iarg[playerx][playery]=0;
    123 						playerx = lastpx;  playery = lastpy;
    124 						break;
    125 
    126 	case OCLOSEDDOOR:	lprintf("\n\nYou have found %s",objectname[i]);
    127 						lprcat("\nDo you (o) try to open it"); iopts();
    128 						i=0; while ((i!='o') && (i!='i') && (i!='\33')) i=getchar();
    129 						if ((i=='\33') || (i=='i'))
    130 							{ ignore();  playerx = lastpx;
    131 							playery = lastpy; break; }
    132 						else
    133 						{
    134 						lprcat("open");
    135 						if (rnd(11)<7)
    136 						  {
    137 						  switch(iarg[playerx][playery])
    138 							{
    139 							case 6: c[AGGRAVATE] += rnd(400);	break;
    140 
    141 							case 7:	lprcat("\nYou are jolted by an electric shock ");
    142 									lastnum=274; losehp(rnd(20));  bottomline();  break;
    143 
    144 							case 8:	loselevel();  break;
    145 
    146 							case 9:	lprcat("\nYou suddenly feel weaker ");
    147 									if (c[STRENGTH]>3) c[STRENGTH]--;
    148 									bottomline();  break;
    149 
    150 							default:	break;
    151 							}
    152 						  playerx = lastpx;  playery = lastpy;
    153 						  }
    154 						else
    155 						  {
    156 						  forget();  item[playerx][playery]=OOPENDOOR;
    157 						  }
    158 						}
    159 						break;
    160 
    161 	case OENTRANCE:	lprcat("\nYou have found "); lprcat(objectname[OENTRANCE]);
    162 					lprcat("\nDo you (g) go inside"); iopts();
    163 					i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
    164 					if (i == 'g')
    165 						{
    166 						newcavelevel(1); playerx=33; playery=MAXY-2;
    167 						item[33][MAXY-1]=know[33][MAXY-1]=mitem[33][MAXY-1]=0;
    168 						draws(0,MAXX,0,MAXY); bot_linex(); return;
    169 						}
    170 					else   ignore();
    171 					break;
    172 
    173 	case OVOLDOWN:	lprcat("\nYou have found "); lprcat(objectname[OVOLDOWN]);
    174 						lprcat("\nDo you (c) climb down"); iopts();
    175 						i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar();
    176 						if ((i=='\33') || (i=='i')) { ignore();  break; }
    177 					if (level!=0) { lprcat("\nThe shaft only extends 5 feet downward!"); return; }
    178 					if (packweight() > 45+3*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft"); beep();
    179 											  lastnum=275;  losehp(30+rnd(20)); bottomhp(); }
    180 
    181 					else lprcat("climb down");  nap(3000);  newcavelevel(MAXLEVEL);
    182 					for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++) /* put player near volcano shaft */
    183 						if (item[j][i]==OVOLUP) { playerx=j; playery=i; j=MAXX; i=MAXY; positionplayer(); }
    184 					draws(0,MAXX,0,MAXY); bot_linex(); return;
    185 
    186 	case OVOLUP:	lprcat("\nYou have found "); lprcat(objectname[OVOLUP]);
    187 						lprcat("\nDo you (c) climb up"); iopts();
    188 						i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar();
    189 						if ((i=='\33') || (i=='i')) { ignore();  break; }
    190 					if (level!=11) { lprcat("\nThe shaft only extends 8 feet upwards before you find a blockage!"); return; }
    191 					if (packweight() > 45+5*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft"); beep();
    192 											  lastnum=275; losehp(15+rnd(20)); bottomhp(); return; }
    193 					lprcat("climb up"); lflush(); nap(3000); newcavelevel(0);
    194 					for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++) /* put player near volcano shaft */
    195 						if (item[j][i]==OVOLDOWN) { playerx=j; playery=i; j=MAXX; i=MAXY; positionplayer(); }
    196 					draws(0,MAXX,0,MAXY); bot_linex(); return;
    197 
    198 	case OTRAPARROWIV:	if (rnd(17)<13) return;	/* for an arrow trap */
    199 						item[playerx][playery] = OTRAPARROW;
    200 						know[playerx][playery] = 0;
    201 
    202 	case OTRAPARROW:	lprcat("\nYou are hit by an arrow"); beep();	/* for an arrow trap */
    203 						lastnum=259;	losehp(rnd(10)+level);
    204 						bottomhp();	return;
    205 
    206 	case OIVDARTRAP:	if (rnd(17)<13) return;		/* for a dart trap */
    207 						item[playerx][playery] = ODARTRAP;
    208 						know[playerx][playery] = 0;
    209 
    210 	case ODARTRAP:		lprcat("\nYou are hit by a dart"); beep();	/* for a dart trap */
    211 						lastnum=260;	losehp(rnd(5));
    212 						if ((--c[STRENGTH]) < 3) c[STRENGTH] = 3;
    213 						bottomline();	return;
    214 
    215 	case OIVTRAPDOOR:	if (rnd(17)<13) return;		/* for a trap door */
    216 						item[playerx][playery] = OTRAPDOOR;
    217 						know[playerx][playery] = 1;
    218 
    219 	case OTRAPDOOR:		lastnum = 272; /* a trap door */
    220 						if ((level==MAXLEVEL-1) || (level==MAXLEVEL+MAXVLEVEL-1))
    221 							{ lprcat("\nYou fell through a bottomless trap door!"); beep();  nap(3000);  died(271); }
    222 						lprcat("\nYou fall through a trap door!"); beep();	/* for a trap door */
    223 						losehp(rnd(5+level));
    224 						nap(2000);  newcavelevel(level+1);  draws(0,MAXX,0,MAXY); bot_linex();
    225 						return;
    226 
    227 
    228 	case OTRADEPOST:	if (nearbymonst()) return;
    229 				lprcat("\nYou have found the Larn trading Post.");
    230 				lprcat("\nDo you (g) go inside, or (i) stay here? ");
    231 				i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
    232 				if (i == 'g')  otradepost();  else  lprcat("stay here");
    233 				return;
    234 
    235 	case OHOME:	if (nearbymonst()) return;
    236 				lprcat("\nYou have found your way home.");
    237 				lprcat("\nDo you (g) go inside, or (i) stay here? ");
    238 				i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
    239 				if (i == 'g')  ohome();  else  lprcat("stay here");
    240 				return;
    241 
    242 	case OWALL:	break;
    243 
    244 	case OANNIHILATION:	died(283); return; 	/* annihilated by sphere of annihilation */
    245 
    246 	case OLRS:	if (nearbymonst()) return;
    247 				lprcat("\n\nThere is an LRS office here.");
    248 				lprcat("\nDo you (g) go inside, or (i) stay here? ");
    249 				i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
    250 				if (i == 'g')
    251 					olrs();  /*  the larn revenue service */
    252 				else  lprcat(" stay here");
    253 				break;
    254 
    255 	default:	finditem(i); break;
    256 	};
    257 }
    258 
    259 /*
    260 	function to say what object we found and ask if player wants to take it
    261  */
    262 finditem(itm)
    263 	int itm;
    264 	{
    265 	int tmp,i;
    266 	lprintf("\n\nYou have found %s ",objectname[itm]);
    267 	tmp=iarg[playerx][playery];
    268 	switch(itm)
    269 		{
    270 		case ODIAMOND:		case ORUBY:			case OEMERALD:
    271 		case OSAPPHIRE:		case OSPIRITSCARAB:	case OORBOFDRAGON:
    272 		case OCUBEofUNDEAD:	case ONOTHEFT:	break;
    273 
    274 		default:
    275 		if (tmp>0) lprintf("+ %d",(long)tmp); else if (tmp<0) lprintf(" %d",(long)tmp);
    276 		}
    277 	lprcat("\nDo you want to (t) take it"); iopts();
    278 	i=0; while (i!='t' && i!='i' && i!='\33') i=getchar();
    279 	if (i == 't')
    280 		{	lprcat("take");  if (take(itm,tmp)==0)  forget();	return;	}
    281 	ignore();
    282 	}
    283 
    284 
    285 /*
    287 	*******
    288 	OSTAIRS
    289 	*******
    290 
    291 	subroutine to process the stair cases
    292 	if dir > 0 the up else down
    293  */
    294 ostairs(dir)
    295 	int dir;
    296 	{
    297 	register int k;
    298 	lprcat("\nDo you (s) stay here  ");
    299 	if (dir > 0)	lprcat("(u) go up  ");	else	lprcat("(d) go down  ");
    300 	lprcat("or (f) kick stairs? ");
    301 
    302 	while (1) switch(getchar())
    303 		{
    304 		case '\33':
    305 		case 's':	case 'i':	lprcat("stay here");	return;
    306 
    307 		case 'f':	lprcat("kick stairs");
    308 					if (rnd(2) == 1)
    309 						lprcat("\nI hope you feel better.  Showing anger rids you of frustration.");
    310 					else
    311 						{
    312 						k=rnd((level+1)<<1);
    313 						lprintf("\nYou hurt your foot dumb dumb!  You suffer %d hit points",(long)k);
    314 						lastnum=276;  losehp(k);  bottomline();
    315 						}
    316 					return;
    317 
    318 		case 'u':	lprcat("go up");
    319 					if (dir < 0)	lprcat("\nThe stairs don't go up!");
    320 					else
    321 					  if (level>=2 && level!=11)
    322 						{
    323 						k = level;  newcavelevel(level-1);
    324 						draws(0,MAXX,0,MAXY); bot_linex();
    325 						}
    326 					  else lprcat("\nThe stairs lead to a dead end!");
    327 					return;
    328 
    329 		case 'd':	lprcat("go down");
    330 					if (dir > 0)	lprcat("\nThe stairs don't go down!");
    331 					else
    332 					  if (level!=0 && level!=10 && level!=13)
    333 						{
    334 						k = level;  newcavelevel(level+1);
    335 						draws(0,MAXX,0,MAXY); bot_linex();
    336 						}
    337 					  else lprcat("\nThe stairs lead to a dead end!");
    338 					return;
    339 		};
    340 	}
    341 
    342 
    343 /*
    345 	*********
    346 	OTELEPORTER
    347 	*********
    348 
    349 	subroutine to handle a teleport trap +/- 1 level maximum
    350  */
    351 oteleport(err)
    352 	int err;
    353 	{
    354 	register int tmp;
    355 	if (err) if (rnd(151)<3)  died(264);  /*	stuck in a rock */
    356 	c[TELEFLAG]=1;	/*	show ?? on bottomline if been teleported	*/
    357 	if (level==0) tmp=0;
    358 	else if (level < MAXLEVEL)
    359 		{ tmp=rnd(5)+level-3; if (tmp>=MAXLEVEL) tmp=MAXLEVEL-1;
    360 			if (tmp<1) tmp=1; }
    361 	else
    362 		{ tmp=rnd(3)+level-2; if (tmp>=MAXLEVEL+MAXVLEVEL) tmp=MAXLEVEL+MAXVLEVEL-1;
    363 			if (tmp<MAXLEVEL) tmp=MAXLEVEL; }
    364 	playerx = rnd(MAXX-2);	playery = rnd(MAXY-2);
    365 	if (level != tmp)	newcavelevel(tmp);  positionplayer();
    366 	draws(0,MAXX,0,MAXY); bot_linex();
    367 	}
    368 
    369 /*
    371 	*******
    372 	OPOTION
    373 	*******
    374 
    375 	function to process a potion
    376  */
    377 opotion(pot)
    378 	int pot;
    379 	{
    380 	lprcat("\nDo you (d) drink it, (t) take it"); iopts();
    381 	while (1) switch(getchar())
    382 		{
    383 		case '\33':
    384 		case 'i':	ignore();  return;
    385 
    386 		case 'd':	lprcat("drink\n");	forget();	/*	destroy potion	*/
    387 					quaffpotion(pot);		return;
    388 
    389 		case 't':	lprcat("take\n");	if (take(OPOTION,pot)==0)  forget();
    390 					return;
    391 		};
    392 	}
    393 
    394 /*
    395 	function to drink a potion
    396  */
    397 quaffpotion(pot)
    398 	int pot;
    399 	{
    400 	register int i,j,k;
    401 	if (pot<0 || pot>=MAXPOTION) return; /* check for within bounds */
    402 	potionname[pot] = potionhide[pot];
    403 	switch(pot)
    404 		{
    405 		case 9: lprcat("\nYou feel greedy . . .");   nap(2000);
    406 				for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
    407 				  if ((item[j][i]==OGOLDPILE) || (item[j][i]==OMAXGOLD))
    408 					{
    409 					know[j][i]=1; show1cell(j,i);
    410 					}
    411 				showplayer();  return;
    412 
    413 		case 19: lprcat("\nYou feel greedy . . .");   nap(2000);
    414 				for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
    415 					{
    416 					k=item[j][i];
    417 					if ((k==ODIAMOND) || (k==ORUBY) || (k==OEMERALD) || (k==OMAXGOLD)
    418 						 || (k==OSAPPHIRE) || (k==OLARNEYE) || (k==OGOLDPILE))
    419 						 {
    420 						 know[j][i]=1; show1cell(j,i);
    421 						 }
    422 					}
    423 				showplayer();  return;
    424 
    425 		case 20: c[HP] = c[HPMAX]; break;	/* instant healing */
    426 
    427 		case 1:	lprcat("\nYou feel better");
    428 				if (c[HP] == c[HPMAX])  raisemhp(1);
    429 				else if ((c[HP] += rnd(20)+20+c[LEVEL]) > c[HPMAX]) c[HP]=c[HPMAX];  break;
    430 
    431 		case 2:	lprcat("\nSuddenly, you feel much more skillful!");
    432 				raiselevel();  raisemhp(1); return;
    433 
    434 		case 3:	lprcat("\nYou feel strange for a moment");
    435 				c[rund(6)]++;  break;
    436 
    437 		case 4:	lprcat("\nYou feel more self confident!");
    438 				c[WISDOM] += rnd(2);  break;
    439 
    440 		case 5:	lprcat("\nWow!  You feel great!");
    441 				if (c[STRENGTH]<12) c[STRENGTH]=12; else c[STRENGTH]++;  break;
    442 
    443 		case 6:	lprcat("\nYour charm went up by one!");  c[CHARISMA]++;  break;
    444 
    445 		case 8:	lprcat("\nYour intelligence went up by one!");
    446 				c[INTELLIGENCE]++;  break;
    447 
    448 		case 10: for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
    449 				   if (mitem[j][i])
    450 					{
    451 					know[j][i]=1; show1cell(j,i);
    452 					}
    453 				 /*	monster detection	*/  return;
    454 
    455 		case 12: lprcat("\nThis potion has no taste to it");  return;
    456 
    457 		case 15: lprcat("\nWOW!!!  You feel Super-fantastic!!!");
    458 				 if (c[HERO]==0) for (i=0; i<6; i++) c[i] += 11;
    459 					c[HERO] += 250;  break;
    460 
    461 		case 16: lprcat("\nYou have a greater intestinal constitude!");
    462 				 c[CONSTITUTION]++;  break;
    463 
    464 		case 17: lprcat("\nYou now have incredibly bulging muscles!!!");
    465 				 if (c[GIANTSTR]==0) c[STREXTRA] += 21;
    466 				 c[GIANTSTR] += 700;  break;
    467 
    468 		case 18: lprcat("\nYou feel a chill run up your spine!");
    469 				 c[FIRERESISTANCE] += 1000;  break;
    470 
    471 		case 0:	lprcat("\nYou fall asleep. . .");
    472 				i=rnd(11)-(c[CONSTITUTION]>>2)+2;  while(--i>0) { parse2();  nap(1000); }
    473 				cursors();  lprcat("\nYou woke up!");  return;
    474 
    475 		case 7:	lprcat("\nYou become dizzy!");
    476 				if (--c[STRENGTH] < 3) c[STRENGTH]=3;  break;
    477 
    478 		case 11: lprcat("\nYou stagger for a moment . .");
    479 				 for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
    480 					know[j][i]=0;
    481 				 nap(2000);	draws(0,MAXX,0,MAXY); /* potion of forgetfulness */  return;
    482 
    483 		case 13: lprcat("\nYou can't see anything!");  /* blindness */
    484 				 c[BLINDCOUNT]+=500;  return;
    485 
    486 		case 14: lprcat("\nYou feel confused"); c[CONFUSE]+= 20+rnd(9); return;
    487 
    488 		case 21: lprcat("\nYou don't seem to be affected");  return; /* cure dianthroritis */
    489 
    490 		case 22: lprcat("\nYou feel a sickness engulf you"); /* poison */
    491 				 c[HALFDAM] += 200 + rnd(200);  return;
    492 
    493 		case 23: lprcat("\nYou feel your vision sharpen");	/* see invisible */
    494 				 c[SEEINVISIBLE] += rnd(1000)+400;
    495 				 monstnamelist[INVISIBLESTALKER] = 'I';  return;
    496 		};
    497 	bottomline();		/*	show new stats		*/  return;
    498 	}
    499 
    500 /*
    502 	*******
    503 	OSCROLL
    504 	*******
    505 
    506 	function to process a magic scroll
    507  */
    508 oscroll(typ)
    509 	int typ;
    510 	{
    511 	lprcat("\nDo you ");
    512 	if (c[BLINDCOUNT]==0) lprcat("(r) read it, "); lprcat("(t) take it"); iopts();
    513 	while (1) switch(getchar())
    514 		{
    515 		case '\33':
    516 		case 'i':	ignore();  return;
    517 
    518 		case 'r':	if (c[BLINDCOUNT]) break;
    519 					lprcat("read"); forget();
    520 					if (typ==2 || typ==15)  { show1cell(playerx,playery); cursors(); }
    521 					/*	destroy it	*/	read_scroll(typ);  return;
    522 
    523 		case 't':	lprcat("take"); if (take(OSCROLL,typ)==0)	forget();	/*	destroy it	*/
    524 					return;
    525 		};
    526 	}
    527 
    528 /*
    529 	data for the function to read a scroll
    530  */
    531 static int xh,yh,yl,xl;
    532 static char curse[] = { BLINDCOUNT, CONFUSE, AGGRAVATE, HASTEMONST, ITCHING,
    533 	LAUGHING, DRAINSTRENGTH, CLUMSINESS, INFEEBLEMENT, HALFDAM };
    534 static char exten[] = { PROTECTIONTIME, DEXCOUNT, STRCOUNT, CHARMCOUNT,
    535 	INVISIBILITY, CANCELLATION, HASTESELF, GLOBE, SCAREMONST, HOLDMONST, TIMESTOP };
    536 char time_change[] = { HASTESELF,HERO,ALTPRO,PROTECTIONTIME,DEXCOUNT,
    537 	STRCOUNT,GIANTSTR,CHARMCOUNT,INVISIBILITY,CANCELLATION,
    538 	HASTESELF,AGGRAVATE,SCAREMONST,STEALTH,AWARENESS,HOLDMONST,HASTEMONST,
    539 	FIRERESISTANCE,GLOBE,SPIRITPRO,UNDEADPRO,HALFDAM,SEEINVISIBLE,
    540 	ITCHING,CLUMSINESS, WTW };
    541 /*
    542  *	function to adjust time when time warping and taking courses in school
    543  */
    544 adjtime(tim)
    545 	register long tim;
    546 	{
    547 	register int j;
    548 	for (j=0; j<26; j++)	/* adjust time related parameters */
    549 		if (c[time_change[j]])
    550 			if ((c[time_change[j]] -= tim) < 1) c[time_change[j]]=1;
    551 	regen();
    552 	}
    553 
    554 /*
    555 	function to read a scroll
    556  */
    557 read_scroll(typ)
    558 	int typ;
    559 	{
    560 	register int i,j;
    561 	if (typ<0 || typ>=MAXSCROLL) return;  /* be sure we are within bounds */
    562 	scrollname[typ] = scrollhide[typ];
    563 	switch(typ)
    564 	  {
    565 	  case 0:	lprcat("\nYour armor glows for a moment");  enchantarmor(); return;
    566 
    567 	  case 1:	lprcat("\nYour weapon glows for a moment"); enchweapon(); return;  /* enchant weapon */
    568 
    569 	  case 2:	lprcat("\nYou have been granted enlightenment!");
    570 				yh = min(playery+7,MAXY);	xh = min(playerx+25,MAXX);
    571 				yl = max(playery-7,0);		xl = max(playerx-25,0);
    572 				for (i=yl; i<yh; i++) for (j=xl; j<xh; j++)  know[j][i]=1;
    573 				nap(2000);	draws(xl,xh,yl,yh);	return;
    574 
    575 	  case 3:	lprcat("\nThis scroll seems to be blank");	return;
    576 
    577 	  case 4:	createmonster(makemonst(level+1));  return;  /*  this one creates a monster  */
    578 
    579 	  case 5:	something(level);	/*	create artifact		*/  return;
    580 
    581 	  case 6:	c[AGGRAVATE]+=800; return; /* aggravate monsters */
    582 
    583 	  case 7:	gtime += (i = rnd(1000) - 850); /* time warp */
    584 				if (i>=0) lprintf("\nYou went forward in time by %d mobuls",(long)((i+99)/100));
    585 				else lprintf("\nYou went backward in time by %d mobuls",(long)(-(i+99)/100));
    586 				adjtime((long)i);	/* adjust time for time warping */
    587 				return;
    588 
    589 	  case 8:	oteleport(0);	  return;	/*	teleportation */
    590 
    591 	  case 9:	c[AWARENESS] += 1800;  return;	/* expanded awareness	*/
    592 
    593 	  case 10:	c[HASTEMONST] += rnd(55)+12; return;	/* haste monster */
    594 
    595 	  case 11:	for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
    596 					if (mitem[j][i])
    597 						hitp[j][i] = monster[mitem[j][i]].hitpoints;
    598 				return;	/* monster healing */
    599 	  case 12:	c[SPIRITPRO] += 300 + rnd(200); bottomline(); return; /* spirit protection */
    600 
    601 	  case 13:	c[UNDEADPRO] += 300 + rnd(200); bottomline(); return; /* undead protection */
    602 
    603 	  case 14:	c[STEALTH] += 250 + rnd(250);  bottomline(); return; /* stealth */
    604 
    605 	  case 15:	lprcat("\nYou have been granted enlightenment!"); /* magic mapping */
    606 				for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++)  know[j][i]=1;
    607 				nap(2000);	draws(0,MAXX,0,MAXY);	return;
    608 
    609 	  case 16:	c[HOLDMONST] += 30; bottomline(); return; /* hold monster */
    610 
    611 	  case 17:	for (i=0; i<26; i++)	/* gem perfection */
    612 					switch(iven[i])
    613 						{
    614 						case ODIAMOND:	case ORUBY:
    615 						case OEMERALD:	case OSAPPHIRE:
    616 							j = ivenarg[i];  j &= 255;  j <<= 1;
    617 							if (j  > 255) j=255; /* double value */
    618 							ivenarg[i] = j;	break;
    619 						}
    620 				break;
    621 
    622 	  case 18:	for (i=0; i<11; i++)	c[exten[i]] <<= 1; /* spell extension */
    623 				break;
    624 
    625 	  case 19:	for (i=0; i<26; i++)	/* identify */
    626 					{
    627 					if (iven[i]==OPOTION)  potionname[ivenarg[i]] = potionhide[ivenarg[i]];
    628 					if (iven[i]==OSCROLL)  scrollname[ivenarg[i]] = scrollhide[ivenarg[i]];
    629 					}
    630 				break;
    631 
    632 	  case 20:	for (i=0; i<10; i++)	/* remove curse */
    633 					if (c[curse[i]]) c[curse[i]] = 1;
    634 				break;
    635 
    636 	  case 21:	annihilate();	break;	/* scroll of annihilation */
    637 
    638 	  case 22:	godirect(22,150,"The ray hits the %s",0,' ');	/* pulverization */
    639 				break;
    640 	  case 23:  c[LIFEPROT]++;  break; /* life protection */
    641 	  };
    642 	}
    643 
    644 
    645 oorb()
    647 	{
    648 	}
    649 
    650 opit()
    651 	{
    652 	register int i;
    653 	if (rnd(101)<81)
    654 	  if (rnd(70) > 9*c[DEXTERITY]-packweight() || rnd(101)<5)
    655 		if (level==MAXLEVEL-1) obottomless(); else
    656 		if (level==MAXLEVEL+MAXVLEVEL-1) obottomless(); else
    657 			{
    658 			if (rnd(101)<20)
    659 				{
    660 				i=0; lprcat("\nYou fell into a pit!  Your fall is cushioned by an unknown force\n");
    661 				}
    662 			else
    663 				{
    664 				i = rnd(level*3+3);
    665 				lprintf("\nYou fell into a pit!  You suffer %d hit points damage",(long)i);
    666 				lastnum=261; 	/*	if he dies scoreboard will say so */
    667 				}
    668 			losehp(i); nap(2000);  newcavelevel(level+1);  draws(0,MAXX,0,MAXY);
    669 			}
    670 	}
    671 
    672 obottomless()
    673 	{
    674 	lprcat("\nYou fell into a bottomless pit!");  beep(); nap(3000);  died(262);
    675 	}
    676 oelevator(dir)
    677 	int dir;
    678 	{
    679 #ifdef lint
    680 	int x;
    681 	x=dir;
    682 	dir=x;
    683 #endif lint
    684 	}
    685 
    686 ostatue()
    687 	{
    688 	}
    689 
    690 omirror()
    691 	{
    692 	}
    693 
    694 obook()
    695 	{
    696 	lprcat("\nDo you ");
    697 	if (c[BLINDCOUNT]==0) lprcat("(r) read it, "); lprcat("(t) take it"); iopts();
    698 	while (1) switch(getchar())
    699 		{
    700 		case '\33':
    701 		case 'i':	ignore();	return;
    702 
    703 		case 'r':	if (c[BLINDCOUNT]) break;
    704 					lprcat("read");
    705 					/* no more book	*/	readbook(iarg[playerx][playery]);  forget(); return;
    706 
    707 		case 't':	lprcat("take");  if (take(OBOOK,iarg[playerx][playery])==0)  forget();	/* no more book	*/
    708 					return;
    709 		};
    710 	}
    711 
    712 /*
    713 	function to read a book
    714  */
    715 readbook(lev)
    716 	register int lev;
    717 	{
    718 	register int i,tmp;
    719 	if (lev<=3) i = rund((tmp=splev[lev])?tmp:1); else
    720 		i = rnd((tmp=splev[lev]-9)?tmp:1) + 9;
    721 	spelknow[i]=1;
    722 	lprintf("\nSpell \"%s\":  %s\n%s",spelcode[i],spelname[i],speldescript[i]);
    723 	if (rnd(10)==4)
    724 	 { lprcat("\nYour int went up by one!"); c[INTELLIGENCE]++; bottomline(); }
    725 	}
    726 
    727 ocookie()
    728 	{
    729 	char *p;
    730 	lprcat("\nDo you (e) eat it, (t) take it"); iopts();
    731 	while (1) switch(getchar())
    732 		{
    733 		case '\33':
    734 		case 'i':	ignore();	return;
    735 
    736 		case 'e':	lprcat("eat\nThe cookie tasted good.");
    737 					forget(); /* no more cookie	*/
    738 					if (c[BLINDCOUNT]) return;
    739 					if (!(p=fortune(fortfile))) return;
    740 					lprcat("  A message inside the cookie reads:\n"); lprcat(p);
    741 					return;
    742 
    743 		case 't':	lprcat("take");  if (take(OCOOKIE,0)==0) forget();	/* no more book	*/
    744 					return;
    745 		};
    746 	}
    747 
    748 
    749 /* routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth 100* the argument */
    750 ogold(arg)
    751 	int arg;
    752 	{
    753 	register long i;
    754 	i = iarg[playerx][playery];
    755 	if (arg==OMAXGOLD) i *= 100;
    756 		else if (arg==OKGOLD) i *= 1000;
    757 			else if (arg==ODGOLD) i *= 10;
    758 	lprintf("\nIt is worth %d!",(long)i);	c[GOLD] += i;  bottomgold();
    759 	item[playerx][playery] = know[playerx][playery] = 0; /*	destroy gold	*/
    760 	}
    761 
    762 ohome()
    763 	{
    764 	register int i;
    765 	nosignal = 1;	/* disable signals */
    766 	for (i=0; i<26; i++) if (iven[i]==OPOTION) if (ivenarg[i]==21)
    767 		{
    768 		iven[i]=0;	/* remove the potion of cure dianthroritis from inventory */
    769 		clear(); lprcat("Congratulations.  You found a potion of cure dianthroritis.\n");
    770 		lprcat("\nFrankly, No one thought you could do it.  Boy!  Did you surprise them!\n");
    771 		if (gtime>TIMELIMIT)
    772 			{
    773 			lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
    774 			lprcat("You didn't make it in time.  In your agony, you kill the doctor,\nyour wife, and yourself!  Too bad!\n");
    775 			nap(5000); died(269);
    776 			}
    777 		else
    778 			{
    779 			lprcat("\nThe doctor is now administering the potion, and in a few moments\n");
    780 			lprcat("Your daughter should be well on her way to recovery.\n");
    781 			nap(6000);
    782 			lprcat("\nThe potion is"); nap(3000); lprcat(" working!  The doctor thinks that\n");
    783 			lprcat("your daughter will recover in a few days.  Congratulations!\n");
    784 			beep(); nap(5000); died(263);
    785 			}
    786 		}
    787 
    788 	while (1)
    789 		{
    790 		clear(); lprintf("Welcome home %s.  Latest word from the doctor is not good.\n",logname);
    791 
    792 		if (gtime>TIMELIMIT)
    793 			{
    794 			lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
    795 			lprcat("You didn't make it in time.  In your agony, you kill the doctor,\nyour wife, and yourself!  Too bad!\n");
    796 			nap(5000); died(269);
    797 			}
    798 
    799 		lprcat("\nThe diagnosis is confirmed as dianthroritis.  He guesses that\n");
    800 		lprintf("your daughter has only %d mobuls left in this world.  It's up to you,\n",(long)((TIMELIMIT-gtime+99)/100));
    801 		lprintf("%s, to find the only hope for your daughter, the very rare\n",logname);
    802 		lprcat("potion of cure dianthroritis.  It is rumored that only deep in the\n");
    803 		lprcat("depths of the caves can this potion be found.\n\n\n");
    804 		lprcat("\n     ----- press "); standout("return");
    805 		lprcat(" to continue, "); standout("escape");
    806 		lprcat(" to leave ----- ");
    807 		i=getchar();  while (i!='\33' && i!='\n') i=getchar();
    808 		if (i=='\33') { drawscreen(); nosignal = 0; /* enable signals */ return; }
    809 		}
    810 	}
    811 
    812 /*	routine to save program space	*/
    813 iopts()
    814 	{	lprcat(", or (i) ignore it? ");	}
    815 ignore()
    816 	{	lprcat("ignore\n");	}
    817 
    818