Home | History | Annotate | Line # | Download | only in hack
hack.read.c revision 1.3
      1  1.2  mycroft /*
      2  1.2  mycroft  * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
      3  1.2  mycroft  */
      4  1.2  mycroft 
      5  1.2  mycroft #ifndef lint
      6  1.3      cgd static char rcsid[] = "$NetBSD: hack.read.c,v 1.3 1995/03/23 08:31:22 cgd Exp $";
      7  1.2  mycroft #endif /* not lint */
      8  1.1      cgd 
      9  1.1      cgd #include "hack.h"
     10  1.1      cgd 
     11  1.1      cgd extern struct monst *makemon();
     12  1.1      cgd extern struct obj *mkobj_at();
     13  1.1      cgd int identify();
     14  1.1      cgd 
     15  1.1      cgd doread() {
     16  1.1      cgd 	register struct obj *scroll;
     17  1.1      cgd 	register boolean confused = (Confusion != 0);
     18  1.1      cgd 	register boolean known = FALSE;
     19  1.1      cgd 	extern struct obj *some_armor();
     20  1.1      cgd 
     21  1.1      cgd 	scroll = getobj("?", "read");
     22  1.1      cgd 	if(!scroll) return(0);
     23  1.1      cgd 	if(!scroll->dknown && Blind) {
     24  1.1      cgd 	    pline("Being blind, you cannot read the formula on the scroll.");
     25  1.1      cgd 	    return(0);
     26  1.1      cgd 	}
     27  1.1      cgd 	if(Blind)
     28  1.1      cgd 	  pline("As you pronounce the formula on it, the scroll disappears.");
     29  1.1      cgd 	else
     30  1.1      cgd 	  pline("As you read the scroll, it disappears.");
     31  1.1      cgd 	if(confused)
     32  1.1      cgd 	  pline("Being confused, you mispronounce the magic words ... ");
     33  1.1      cgd 
     34  1.1      cgd 	switch(scroll->otyp) {
     35  1.1      cgd #ifdef MAIL
     36  1.1      cgd 	case SCR_MAIL:
     37  1.1      cgd 		readmail(/* scroll */);
     38  1.1      cgd 		break;
     39  1.1      cgd #endif MAIL
     40  1.1      cgd 	case SCR_ENCHANT_ARMOR:
     41  1.1      cgd 	    {	register struct obj *otmp = some_armor();
     42  1.1      cgd 		if(!otmp) {
     43  1.1      cgd 			strange_feeling(scroll,"Your skin glows then fades.");
     44  1.1      cgd 			return(1);
     45  1.1      cgd 		}
     46  1.1      cgd 		if(confused) {
     47  1.1      cgd 			pline("Your %s glows silver for a moment.",
     48  1.1      cgd 				objects[otmp->otyp].oc_name);
     49  1.1      cgd 			otmp->rustfree = 1;
     50  1.1      cgd 			break;
     51  1.1      cgd 		}
     52  1.1      cgd 		if(otmp->spe > 3 && rn2(otmp->spe)) {
     53  1.1      cgd 	pline("Your %s glows violently green for a while, then evaporates.",
     54  1.1      cgd 			objects[otmp->otyp].oc_name);
     55  1.1      cgd 			useup(otmp);
     56  1.1      cgd 			break;
     57  1.1      cgd 		}
     58  1.1      cgd 		pline("Your %s glows green for a moment.",
     59  1.1      cgd 			objects[otmp->otyp].oc_name);
     60  1.1      cgd 		otmp->cursed = 0;
     61  1.1      cgd 		otmp->spe++;
     62  1.1      cgd 		break;
     63  1.1      cgd 	    }
     64  1.1      cgd 	case SCR_DESTROY_ARMOR:
     65  1.1      cgd 		if(confused) {
     66  1.1      cgd 			register struct obj *otmp = some_armor();
     67  1.1      cgd 			if(!otmp) {
     68  1.1      cgd 				strange_feeling(scroll,"Your bones itch.");
     69  1.1      cgd 				return(1);
     70  1.1      cgd 			}
     71  1.1      cgd 			pline("Your %s glows purple for a moment.",
     72  1.1      cgd 				objects[otmp->otyp].oc_name);
     73  1.1      cgd 			otmp->rustfree = 0;
     74  1.1      cgd 			break;
     75  1.1      cgd 		}
     76  1.1      cgd 		if(uarm) {
     77  1.1      cgd 		    pline("Your armor turns to dust and falls to the floor!");
     78  1.1      cgd 		    useup(uarm);
     79  1.1      cgd 		} else if(uarmh) {
     80  1.1      cgd 		    pline("Your helmet turns to dust and is blown away!");
     81  1.1      cgd 		    useup(uarmh);
     82  1.1      cgd 		} else if(uarmg) {
     83  1.1      cgd 			pline("Your gloves vanish!");
     84  1.1      cgd 			useup(uarmg);
     85  1.1      cgd 			selftouch("You");
     86  1.1      cgd 		} else {
     87  1.1      cgd 			strange_feeling(scroll,"Your skin itches.");
     88  1.1      cgd 			return(1);
     89  1.1      cgd 		}
     90  1.1      cgd 		break;
     91  1.1      cgd 	case SCR_CONFUSE_MONSTER:
     92  1.1      cgd 		if(confused) {
     93  1.1      cgd 			pline("Your hands begin to glow purple.");
     94  1.1      cgd 			Confusion += rnd(100);
     95  1.1      cgd 		} else {
     96  1.1      cgd 			pline("Your hands begin to glow blue.");
     97  1.1      cgd 			u.umconf = 1;
     98  1.1      cgd 		}
     99  1.1      cgd 		break;
    100  1.1      cgd 	case SCR_SCARE_MONSTER:
    101  1.1      cgd 	    {	register int ct = 0;
    102  1.1      cgd 		register struct monst *mtmp;
    103  1.1      cgd 
    104  1.1      cgd 		for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
    105  1.1      cgd 			if(cansee(mtmp->mx,mtmp->my)) {
    106  1.1      cgd 				if(confused)
    107  1.1      cgd 					mtmp->mflee = mtmp->mfroz =
    108  1.1      cgd 					mtmp->msleep = 0;
    109  1.1      cgd 				else
    110  1.1      cgd 					mtmp->mflee = 1;
    111  1.1      cgd 				ct++;
    112  1.1      cgd 			}
    113  1.1      cgd 		if(!ct) {
    114  1.1      cgd 		    if(confused)
    115  1.1      cgd 			pline("You hear sad wailing in the distance.");
    116  1.1      cgd 		    else
    117  1.1      cgd 			pline("You hear maniacal laughter in the distance.");
    118  1.1      cgd 		}
    119  1.1      cgd 		break;
    120  1.1      cgd 	    }
    121  1.1      cgd 	case SCR_BLANK_PAPER:
    122  1.1      cgd 		if(confused)
    123  1.1      cgd 		    pline("You see strange patterns on this scroll.");
    124  1.1      cgd 		else
    125  1.1      cgd 		    pline("This scroll seems to be blank.");
    126  1.1      cgd 		break;
    127  1.1      cgd 	case SCR_REMOVE_CURSE:
    128  1.1      cgd 	    {	register struct obj *obj;
    129  1.1      cgd 		if(confused)
    130  1.1      cgd 		  pline("You feel like you need some help.");
    131  1.1      cgd 		else
    132  1.1      cgd 		  pline("You feel like someone is helping you.");
    133  1.1      cgd 		for(obj = invent; obj ; obj = obj->nobj)
    134  1.1      cgd 			if(obj->owornmask)
    135  1.1      cgd 				obj->cursed = confused;
    136  1.1      cgd 		if(Punished && !confused) {
    137  1.1      cgd 			Punished = 0;
    138  1.1      cgd 			freeobj(uchain);
    139  1.1      cgd 			unpobj(uchain);
    140  1.1      cgd 			free((char *) uchain);
    141  1.1      cgd 			uball->spe = 0;
    142  1.1      cgd 			uball->owornmask &= ~W_BALL;
    143  1.1      cgd 			uchain = uball = (struct obj *) 0;
    144  1.1      cgd 		}
    145  1.1      cgd 		break;
    146  1.1      cgd 	    }
    147  1.1      cgd 	case SCR_CREATE_MONSTER:
    148  1.1      cgd 	    {	register int cnt = 1;
    149  1.1      cgd 
    150  1.1      cgd 		if(!rn2(73)) cnt += rnd(4);
    151  1.1      cgd 		if(confused) cnt += 12;
    152  1.1      cgd 		while(cnt--)
    153  1.1      cgd 		    (void) makemon(confused ? PM_ACID_BLOB :
    154  1.1      cgd 			(struct permonst *) 0, u.ux, u.uy);
    155  1.1      cgd 		break;
    156  1.1      cgd 	    }
    157  1.1      cgd 	case SCR_ENCHANT_WEAPON:
    158  1.1      cgd 		if(uwep && confused) {
    159  1.1      cgd 			pline("Your %s glows silver for a moment.",
    160  1.1      cgd 				objects[uwep->otyp].oc_name);
    161  1.1      cgd 			uwep->rustfree = 1;
    162  1.1      cgd 		} else
    163  1.1      cgd 			if(!chwepon(scroll, 1))		/* tests for !uwep */
    164  1.1      cgd 				return(1);
    165  1.1      cgd 		break;
    166  1.1      cgd 	case SCR_DAMAGE_WEAPON:
    167  1.1      cgd 		if(uwep && confused) {
    168  1.1      cgd 			pline("Your %s glows purple for a moment.",
    169  1.1      cgd 				objects[uwep->otyp].oc_name);
    170  1.1      cgd 			uwep->rustfree = 0;
    171  1.1      cgd 		} else
    172  1.1      cgd 			if(!chwepon(scroll, -1))	/* tests for !uwep */
    173  1.1      cgd 				return(1);
    174  1.1      cgd 		break;
    175  1.1      cgd 	case SCR_TAMING:
    176  1.1      cgd 	    {	register int i,j;
    177  1.1      cgd 		register int bd = confused ? 5 : 1;
    178  1.1      cgd 		register struct monst *mtmp;
    179  1.1      cgd 
    180  1.1      cgd 		for(i = -bd; i <= bd; i++) for(j = -bd; j <= bd; j++)
    181  1.1      cgd 		if(mtmp = m_at(u.ux+i, u.uy+j))
    182  1.1      cgd 			(void) tamedog(mtmp, (struct obj *) 0);
    183  1.1      cgd 		break;
    184  1.1      cgd 	    }
    185  1.1      cgd 	case SCR_GENOCIDE:
    186  1.1      cgd 	    {	extern char genocided[], fut_geno[];
    187  1.1      cgd 		char buf[BUFSZ];
    188  1.1      cgd 		register struct monst *mtmp, *mtmp2;
    189  1.1      cgd 
    190  1.1      cgd 		pline("You have found a scroll of genocide!");
    191  1.1      cgd 		known = TRUE;
    192  1.1      cgd 		if(confused)
    193  1.1      cgd 			*buf = u.usym;
    194  1.1      cgd 		else do {
    195  1.1      cgd 	    pline("What monster do you want to genocide (Type the letter)? ");
    196  1.1      cgd 			getlin(buf);
    197  1.1      cgd 		} while(strlen(buf) != 1 || !monstersym(*buf));
    198  1.1      cgd 		if(!index(fut_geno, *buf))
    199  1.1      cgd 			charcat(fut_geno, *buf);
    200  1.1      cgd 		if(!index(genocided, *buf))
    201  1.1      cgd 			charcat(genocided, *buf);
    202  1.1      cgd 		else {
    203  1.1      cgd 			pline("Such monsters do not exist in this world.");
    204  1.1      cgd 			break;
    205  1.1      cgd 		}
    206  1.1      cgd 		for(mtmp = fmon; mtmp; mtmp = mtmp2){
    207  1.1      cgd 			mtmp2 = mtmp->nmon;
    208  1.1      cgd 			if(mtmp->data->mlet == *buf)
    209  1.1      cgd 				mondead(mtmp);
    210  1.1      cgd 		}
    211  1.1      cgd 		pline("Wiped out all %c's.", *buf);
    212  1.1      cgd 		if(*buf == u.usym) {
    213  1.1      cgd 			killer = "scroll of genocide";
    214  1.1      cgd 			u.uhp = -1;
    215  1.1      cgd 		}
    216  1.1      cgd 		break;
    217  1.1      cgd 		}
    218  1.1      cgd 	case SCR_LIGHT:
    219  1.1      cgd 		if(!Blind) known = TRUE;
    220  1.1      cgd 		litroom(!confused);
    221  1.1      cgd 		break;
    222  1.1      cgd 	case SCR_TELEPORTATION:
    223  1.1      cgd 		if(confused)
    224  1.1      cgd 			level_tele();
    225  1.1      cgd 		else {
    226  1.1      cgd #ifdef QUEST
    227  1.1      cgd 			register int oux = u.ux, ouy = u.uy;
    228  1.1      cgd 			tele();
    229  1.1      cgd 			if(dist(oux, ouy) > 100) known = TRUE;
    230  1.1      cgd #else QUEST
    231  1.1      cgd 			register int uroom = inroom(u.ux, u.uy);
    232  1.1      cgd 			tele();
    233  1.1      cgd 			if(uroom != inroom(u.ux, u.uy)) known = TRUE;
    234  1.1      cgd #endif QUEST
    235  1.1      cgd 		}
    236  1.1      cgd 		break;
    237  1.1      cgd 	case SCR_GOLD_DETECTION:
    238  1.1      cgd 	    /* Unfortunately this code has become slightly less elegant,
    239  1.1      cgd 	       now that gold and traps no longer are of the same type. */
    240  1.1      cgd 	    if(confused) {
    241  1.1      cgd 		register struct trap *ttmp;
    242  1.1      cgd 
    243  1.1      cgd 		if(!ftrap) {
    244  1.1      cgd 			strange_feeling(scroll, "Your toes stop itching.");
    245  1.1      cgd 			return(1);
    246  1.1      cgd 		} else {
    247  1.1      cgd 			for(ttmp = ftrap; ttmp; ttmp = ttmp->ntrap)
    248  1.1      cgd 				if(ttmp->tx != u.ux || ttmp->ty != u.uy)
    249  1.1      cgd 					goto outtrapmap;
    250  1.1      cgd 			/* only under me - no separate display required */
    251  1.1      cgd 			pline("Your toes itch!");
    252  1.1      cgd 			break;
    253  1.1      cgd 		outtrapmap:
    254  1.1      cgd 			cls();
    255  1.1      cgd 			for(ttmp = ftrap; ttmp; ttmp = ttmp->ntrap)
    256  1.1      cgd 				at(ttmp->tx, ttmp->ty, '$');
    257  1.1      cgd 			prme();
    258  1.1      cgd 			pline("You feel very greedy!");
    259  1.1      cgd 		}
    260  1.1      cgd 	    } else {
    261  1.1      cgd 		register struct gold *gtmp;
    262  1.1      cgd 
    263  1.1      cgd 		if(!fgold) {
    264  1.1      cgd 			strange_feeling(scroll, "You feel materially poor.");
    265  1.1      cgd 			return(1);
    266  1.1      cgd 		} else {
    267  1.1      cgd 			known = TRUE;
    268  1.1      cgd 			for(gtmp = fgold; gtmp; gtmp = gtmp->ngold)
    269  1.1      cgd 				if(gtmp->gx != u.ux || gtmp->gy != u.uy)
    270  1.1      cgd 					goto outgoldmap;
    271  1.1      cgd 			/* only under me - no separate display required */
    272  1.1      cgd 			pline("You notice some gold between your feet.");
    273  1.1      cgd 			break;
    274  1.1      cgd 		outgoldmap:
    275  1.1      cgd 			cls();
    276  1.1      cgd 			for(gtmp = fgold; gtmp; gtmp = gtmp->ngold)
    277  1.1      cgd 				at(gtmp->gx, gtmp->gy, '$');
    278  1.1      cgd 			prme();
    279  1.1      cgd 			pline("You feel very greedy, and sense gold!");
    280  1.1      cgd 		}
    281  1.1      cgd 	    }
    282  1.1      cgd 		/* common sequel */
    283  1.1      cgd 		more();
    284  1.1      cgd 		docrt();
    285  1.1      cgd 		break;
    286  1.1      cgd 	case SCR_FOOD_DETECTION:
    287  1.1      cgd 	    {	register ct = 0, ctu = 0;
    288  1.1      cgd 		register struct obj *obj;
    289  1.1      cgd 		register char foodsym = confused ? POTION_SYM : FOOD_SYM;
    290  1.1      cgd 
    291  1.1      cgd 		for(obj = fobj; obj; obj = obj->nobj)
    292  1.1      cgd 			if(obj->olet == FOOD_SYM) {
    293  1.1      cgd 				if(obj->ox == u.ux && obj->oy == u.uy) ctu++;
    294  1.1      cgd 				else ct++;
    295  1.1      cgd 			}
    296  1.1      cgd 		if(!ct && !ctu) {
    297  1.1      cgd 			strange_feeling(scroll,"Your nose twitches.");
    298  1.1      cgd 			return(1);
    299  1.1      cgd 		} else if(!ct) {
    300  1.1      cgd 			known = TRUE;
    301  1.1      cgd 			pline("You smell %s close nearby.",
    302  1.1      cgd 				confused ? "something" : "food");
    303  1.1      cgd 
    304  1.1      cgd 		} else {
    305  1.1      cgd 			known = TRUE;
    306  1.1      cgd 			cls();
    307  1.1      cgd 			for(obj = fobj; obj; obj = obj->nobj)
    308  1.1      cgd 			    if(obj->olet == foodsym)
    309  1.1      cgd 				at(obj->ox, obj->oy, FOOD_SYM);
    310  1.1      cgd 			prme();
    311  1.1      cgd 			pline("Your nose tingles and you smell %s!",
    312  1.1      cgd 				confused ? "something" : "food");
    313  1.1      cgd 			more();
    314  1.1      cgd 			docrt();
    315  1.1      cgd 		}
    316  1.1      cgd 		break;
    317  1.1      cgd 	    }
    318  1.1      cgd 	case SCR_IDENTIFY:
    319  1.1      cgd 		/* known = TRUE; */
    320  1.1      cgd 		if(confused)
    321  1.1      cgd 			pline("You identify this as an identify scroll.");
    322  1.1      cgd 		else
    323  1.1      cgd 			pline("This is an identify scroll.");
    324  1.1      cgd 		useup(scroll);
    325  1.1      cgd 		objects[SCR_IDENTIFY].oc_name_known = 1;
    326  1.1      cgd 		if(!confused)
    327  1.1      cgd 		    while(
    328  1.1      cgd 			!ggetobj("identify", identify, rn2(5) ? 1 : rn2(5))
    329  1.1      cgd 			&& invent
    330  1.1      cgd 		    );
    331  1.1      cgd 		return(1);
    332  1.1      cgd 	case SCR_MAGIC_MAPPING:
    333  1.1      cgd 	    {	register struct rm *lev;
    334  1.1      cgd 		register int num, zx, zy;
    335  1.1      cgd 
    336  1.1      cgd 		known = TRUE;
    337  1.1      cgd 		pline("On this scroll %s a map!",
    338  1.1      cgd 			confused ? "was" : "is");
    339  1.1      cgd 		for(zy = 0; zy < ROWNO; zy++)
    340  1.1      cgd 			for(zx = 0; zx < COLNO; zx++) {
    341  1.1      cgd 				if(confused && rn2(7)) continue;
    342  1.1      cgd 				lev = &(levl[zx][zy]);
    343  1.1      cgd 				if((num = lev->typ) == 0)
    344  1.1      cgd 					continue;
    345  1.1      cgd 				if(num == SCORR) {
    346  1.1      cgd 					lev->typ = CORR;
    347  1.1      cgd 					lev->scrsym = CORR_SYM;
    348  1.1      cgd 				} else
    349  1.1      cgd 				if(num == SDOOR) {
    350  1.1      cgd 					lev->typ = DOOR;
    351  1.1      cgd 					lev->scrsym = '+';
    352  1.1      cgd 					/* do sth in doors ? */
    353  1.1      cgd 				} else if(lev->seen) continue;
    354  1.1      cgd #ifndef QUEST
    355  1.1      cgd 				if(num != ROOM)
    356  1.1      cgd #endif QUEST
    357  1.1      cgd 				{
    358  1.1      cgd 				  lev->seen = lev->new = 1;
    359  1.1      cgd 				  if(lev->scrsym == ' ' || !lev->scrsym)
    360  1.1      cgd 				    newsym(zx,zy);
    361  1.1      cgd 				  else
    362  1.1      cgd 				    on_scr(zx,zy);
    363  1.1      cgd 				}
    364  1.1      cgd 			}
    365  1.1      cgd 		break;
    366  1.1      cgd 	    }
    367  1.1      cgd 	case SCR_AMNESIA:
    368  1.1      cgd 	    {	register int zx, zy;
    369  1.1      cgd 
    370  1.1      cgd 		known = TRUE;
    371  1.1      cgd 		for(zx = 0; zx < COLNO; zx++) for(zy = 0; zy < ROWNO; zy++)
    372  1.1      cgd 		    if(!confused || rn2(7))
    373  1.1      cgd 			if(!cansee(zx,zy))
    374  1.1      cgd 			    levl[zx][zy].seen = 0;
    375  1.1      cgd 		docrt();
    376  1.1      cgd 		pline("Thinking of Maud you forget everything else.");
    377  1.1      cgd 		break;
    378  1.1      cgd 	    }
    379  1.1      cgd 	case SCR_FIRE:
    380  1.1      cgd 	    {	register int num;
    381  1.1      cgd 		register struct monst *mtmp;
    382  1.1      cgd 
    383  1.1      cgd 		known = TRUE;
    384  1.1      cgd 		if(confused) {
    385  1.1      cgd 		    pline("The scroll catches fire and you burn your hands.");
    386  1.1      cgd 		    losehp(1, "scroll of fire");
    387  1.1      cgd 		} else {
    388  1.1      cgd 		    pline("The scroll erupts in a tower of flame!");
    389  1.1      cgd 		    if(Fire_resistance)
    390  1.1      cgd 			pline("You are uninjured.");
    391  1.1      cgd 		    else {
    392  1.1      cgd 			num = rnd(6);
    393  1.1      cgd 			u.uhpmax -= num;
    394  1.1      cgd 			losehp(num, "scroll of fire");
    395  1.1      cgd 		    }
    396  1.1      cgd 		}
    397  1.1      cgd 		num = (2*num + 1)/3;
    398  1.1      cgd 		for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
    399  1.1      cgd 		    if(dist(mtmp->mx,mtmp->my) < 3) {
    400  1.1      cgd 			mtmp->mhp -= num;
    401  1.1      cgd 			if(index("FY", mtmp->data->mlet))
    402  1.1      cgd 			    mtmp->mhp -= 3*num;	/* this might well kill 'F's */
    403  1.1      cgd 			if(mtmp->mhp < 1) {
    404  1.1      cgd 			    killed(mtmp);
    405  1.1      cgd 			    break;		/* primitive */
    406  1.1      cgd 			}
    407  1.1      cgd 		    }
    408  1.1      cgd 		}
    409  1.1      cgd 		break;
    410  1.1      cgd 	    }
    411  1.1      cgd 	case SCR_PUNISHMENT:
    412  1.1      cgd 		known = TRUE;
    413  1.1      cgd 		if(confused) {
    414  1.1      cgd 			pline("You feel guilty.");
    415  1.1      cgd 			break;
    416  1.1      cgd 		}
    417  1.1      cgd 		pline("You are being punished for your misbehaviour!");
    418  1.1      cgd 		if(Punished){
    419  1.1      cgd 			pline("Your iron ball gets heavier.");
    420  1.1      cgd 			uball->owt += 15;
    421  1.1      cgd 			break;
    422  1.1      cgd 		}
    423  1.1      cgd 		Punished = INTRINSIC;
    424  1.1      cgd 		setworn(mkobj_at(CHAIN_SYM, u.ux, u.uy), W_CHAIN);
    425  1.1      cgd 		setworn(mkobj_at(BALL_SYM, u.ux, u.uy), W_BALL);
    426  1.1      cgd 		uball->spe = 1;		/* special ball (see save) */
    427  1.1      cgd 		break;
    428  1.1      cgd 	default:
    429  1.1      cgd 		impossible("What weird language is this written in? (%u)",
    430  1.1      cgd 			scroll->otyp);
    431  1.1      cgd 	}
    432  1.1      cgd 	if(!objects[scroll->otyp].oc_name_known) {
    433  1.1      cgd 		if(known && !confused) {
    434  1.1      cgd 			objects[scroll->otyp].oc_name_known = 1;
    435  1.1      cgd 			more_experienced(0,10);
    436  1.1      cgd 		} else if(!objects[scroll->otyp].oc_uname)
    437  1.1      cgd 			docall(scroll);
    438  1.1      cgd 	}
    439  1.1      cgd 	useup(scroll);
    440  1.1      cgd 	return(1);
    441  1.1      cgd }
    442  1.1      cgd 
    443  1.1      cgd identify(otmp)		/* also called by newmail() */
    444  1.1      cgd register struct obj *otmp;
    445  1.1      cgd {
    446  1.1      cgd 	objects[otmp->otyp].oc_name_known = 1;
    447  1.1      cgd 	otmp->known = otmp->dknown = 1;
    448  1.1      cgd 	prinv(otmp);
    449  1.1      cgd 	return(1);
    450  1.1      cgd }
    451  1.1      cgd 
    452  1.1      cgd litroom(on)
    453  1.1      cgd register boolean on;
    454  1.1      cgd {
    455  1.1      cgd 	register num,zx,zy;
    456  1.1      cgd 
    457  1.1      cgd 	/* first produce the text (provided he is not blind) */
    458  1.1      cgd 	if(Blind) goto do_it;
    459  1.1      cgd 	if(!on) {
    460  1.1      cgd 		if(u.uswallow || !xdnstair || levl[u.ux][u.uy].typ == CORR ||
    461  1.1      cgd 		    !levl[u.ux][u.uy].lit) {
    462  1.1      cgd 			pline("It seems even darker in here than before.");
    463  1.1      cgd 			return;
    464  1.1      cgd 		} else
    465  1.1      cgd 			pline("It suddenly becomes dark in here.");
    466  1.1      cgd 	} else {
    467  1.1      cgd 		if(u.uswallow){
    468  1.1      cgd 			pline("%s's stomach is lit.", Monnam(u.ustuck));
    469  1.1      cgd 			return;
    470  1.1      cgd 		}
    471  1.1      cgd 		if(!xdnstair){
    472  1.1      cgd 			pline("Nothing Happens.");
    473  1.1      cgd 			return;
    474  1.1      cgd 		}
    475  1.1      cgd #ifdef QUEST
    476  1.1      cgd 		pline("The cave lights up around you, then fades.");
    477  1.1      cgd 		return;
    478  1.1      cgd #else QUEST
    479  1.1      cgd 		if(levl[u.ux][u.uy].typ == CORR) {
    480  1.1      cgd 		    pline("The corridor lights up around you, then fades.");
    481  1.1      cgd 		    return;
    482  1.1      cgd 		} else if(levl[u.ux][u.uy].lit) {
    483  1.1      cgd 		    pline("The light here seems better now.");
    484  1.1      cgd 		    return;
    485  1.1      cgd 		} else
    486  1.1      cgd 		    pline("The room is lit.");
    487  1.1      cgd #endif QUEST
    488  1.1      cgd 	}
    489  1.1      cgd 
    490  1.1      cgd do_it:
    491  1.1      cgd #ifdef QUEST
    492  1.1      cgd 	return;
    493  1.1      cgd #else QUEST
    494  1.1      cgd 	if(levl[u.ux][u.uy].lit == on)
    495  1.1      cgd 		return;
    496  1.1      cgd 	if(levl[u.ux][u.uy].typ == DOOR) {
    497  1.1      cgd 		if(IS_ROOM(levl[u.ux][u.uy+1].typ)) zy = u.uy+1;
    498  1.1      cgd 		else if(IS_ROOM(levl[u.ux][u.uy-1].typ)) zy = u.uy-1;
    499  1.1      cgd 		else zy = u.uy;
    500  1.1      cgd 		if(IS_ROOM(levl[u.ux+1][u.uy].typ)) zx = u.ux+1;
    501  1.1      cgd 		else if(IS_ROOM(levl[u.ux-1][u.uy].typ)) zx = u.ux-1;
    502  1.1      cgd 		else zx = u.ux;
    503  1.1      cgd 	} else {
    504  1.1      cgd 		zx = u.ux;
    505  1.1      cgd 		zy = u.uy;
    506  1.1      cgd 	}
    507  1.1      cgd 	for(seelx = u.ux; (num = levl[seelx-1][zy].typ) != CORR && num != 0;
    508  1.1      cgd 		seelx--);
    509  1.1      cgd 	for(seehx = u.ux; (num = levl[seehx+1][zy].typ) != CORR && num != 0;
    510  1.1      cgd 		seehx++);
    511  1.1      cgd 	for(seely = u.uy; (num = levl[zx][seely-1].typ) != CORR && num != 0;
    512  1.1      cgd 		seely--);
    513  1.1      cgd 	for(seehy = u.uy; (num = levl[zx][seehy+1].typ) != CORR && num != 0;
    514  1.1      cgd 		seehy++);
    515  1.1      cgd 	for(zy = seely; zy <= seehy; zy++)
    516  1.1      cgd 		for(zx = seelx; zx <= seehx; zx++) {
    517  1.1      cgd 			levl[zx][zy].lit = on;
    518  1.1      cgd 			if(!Blind && dist(zx,zy) > 2)
    519  1.1      cgd 				if(on) prl(zx,zy); else nosee(zx,zy);
    520  1.1      cgd 		}
    521  1.1      cgd 	if(!on) seehx = 0;
    522  1.1      cgd #endif	QUEST
    523  1.1      cgd }
    524  1.1      cgd 
    525  1.1      cgd /* Test whether we may genocide all monsters with symbol  ch  */
    526  1.1      cgd monstersym(ch)				/* arnold@ucsfcgl */
    527  1.1      cgd register char ch;
    528  1.1      cgd {
    529  1.1      cgd 	register struct permonst *mp;
    530  1.1      cgd 	extern struct permonst pm_eel;
    531  1.1      cgd 
    532  1.1      cgd 	/*
    533  1.1      cgd 	 * can't genocide certain monsters
    534  1.1      cgd 	 */
    535  1.1      cgd 	if (index("12 &:", ch))
    536  1.1      cgd 		return FALSE;
    537  1.1      cgd 
    538  1.1      cgd 	if (ch == pm_eel.mlet)
    539  1.1      cgd 		return TRUE;
    540  1.1      cgd 	for (mp = mons; mp < &mons[CMNUM+2]; mp++)
    541  1.1      cgd 		if (mp->mlet == ch)
    542  1.1      cgd 			return TRUE;
    543  1.1      cgd 	return FALSE;
    544  1.1      cgd }
    545