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