Source:NetHack 3.4.0/read.c

Below is the full text to read.c from the source code of NetHack 3.4.0. To link to a particular line, write [[NetHack 3.4.0/read.c#line123 ]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

1.   /*	SCCS Id: @(#)read.c	3.4	2001/12/03	*/ 2.   /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3.    /* NetHack may be freely redistributed. See license for details. */ 4.     5.    #include "hack.h"  6. 7.   /* KMH -- Copied from pray.c; this really belongs in a header file */ 8.   #define DEVOUT 14 9.   #define STRIDENT 4 10.   11.   #define Your_Own_Role(mndx) \ 12.  	((mndx) == urole.malenum || \  13.   	 (urole.femalenum != NON_PM && (mndx) == urole.femalenum)) 14.  #define Your_Own_Race(mndx) \ 15.  	((mndx) == urace.malenum || \  16.   	 (urace.femalenum != NON_PM && (mndx) == urace.femalenum)) 17.   18.   #ifdef OVLB 19.   20.   /* elven armor vibrates warningly when enchanted beyond a limit */ 21.  #define is_elven_armor(optr)	((optr)->otyp == ELVEN_LEATHER_HELM\  22.   				|| (optr)->otyp == ELVEN_MITHRIL_COAT\  23.   				|| (optr)->otyp == ELVEN_CLOAK\  24.   				|| (optr)->otyp == ELVEN_SHIELD\  25.   				|| (optr)->otyp == ELVEN_BOOTS) 26.   27.   boolean	known; 28.   29.   static NEARDATA const char readable[] = 30.  		   { ALL_CLASSES, SCROLL_CLASS, SPBOOK_CLASS, 0 }; 31.  static const char all_count[] = { ALLOW_COUNT, ALL_CLASSES, 0 }; 32.   33.   static void FDECL(wand_explode, (struct obj *)); 34.  static void NDECL(do_class_genocide); 35.  static void FDECL(stripspe,(struct obj *)); 36.  static void FDECL(p_glow1,(struct obj *)); 37.  static void FDECL(p_glow2,(struct obj *,const char *)); 38.  static void FDECL(randomize,(int *, int)); 39.  static void FDECL(forget_single_object, (int)); 40.  static void FDECL(forget, (int)); 41.  static void FDECL(maybe_tame, (struct monst *,struct obj *)); 42.   43.   STATIC_PTR void FDECL(set_lit, (int,int,genericptr_t)); 44.   45.   int 46.  doread 47.  {  48.   	register struct obj *scroll; 49.  	register boolean confused; 50.   51.   	known = FALSE; 52.  	if(check_capacity((char *)0)) return (0); 53.  	scroll = getobj(readable, "read"); 54.  	if(!scroll) return(0); 55.   56.   	/* outrumor has its own blindness check */ 57.  	if(scroll->otyp == FORTUNE_COOKIE) { 58.  	    if(flags.verbose) 59.  		You("break up the cookie and throw away the pieces."); 60.  	    outrumor(bcsign(scroll), BY_COOKIE); 61.  	    if (!Blind) u.uconduct.literate++; 62.  	    useup(scroll); 63.  	    return(1); 64.  #ifdef TOURIST 65.  	} else if (scroll->otyp == T_SHIRT) { 66.  	    static const char *shirt_msgs[] = { /* Scott Bigham */ 67.      "I explored the Dungeons of Doom and all I got was this lousy T-shirt!", 68.      "Is that Mjollnir in your pocket or are you just happy to see me?", 69.      "It's not the size of your sword, it's how #enhance'd you are with it.", 70.      "Madame Elvira's House O' Succubi Lifetime Customer", 71.      "Madame Elvira's House O' Succubi Employee of the Month", 72.      "Ludios Vault Guards Do It In Small, Dark Rooms", 73.      "Yendor Military Soldiers Do It In Large Groups", 74.      "I survived Yendor Military Boot Camp", 75.      "Ludios Accounting School Intra-Mural Lacrosse Team", 76.      "Oracle(TM) Fountains 10th Annual Wet T-Shirt Contest", 77.      "Hey, black dragon!  Disintegrate THIS!", 78.      "I'm With Stupid -->", 79.      "Don't blame me, I voted for Izchak!", 80.      "Don't Panic",				/* HHGTTG */ 81.      "Furinkan High School Athletic Dept.",	/* Ranma 1/2 */ 82.      "Hel-LOOO, Nurse!",			/* Animaniacs */ 83.  	    };  84.   	    char buf[BUFSZ]; 85.  	    int erosion; 86.   87.   	    if (Blind) { 88.  		You_cant("feel any Braille writing."); 89.  		return 0; 90.  	    }  91.   	    u.uconduct.literate++; 92.  	    if(flags.verbose) 93.  		pline("It reads:"); 94.  	    Strcpy(buf, shirt_msgs[scroll->o_id % SIZE(shirt_msgs)]); 95.  	    erosion = greatest_erosion(scroll); 96.  	    if (erosion) 97.  		wipeout_text(buf,  98.   			(int)(strlen(buf) * erosion / (2*MAX_ERODE)),  99.   			     scroll->o_id ^ (unsigned)u.ubirthday); 100. 	    pline("\"%s\"", buf); 101. 	    return 1; 102. #endif	/* TOURIST */ 103. 	} else if (scroll->oclass != SCROLL_CLASS  104.  		&& scroll->oclass != SPBOOK_CLASS) { 105. 	    pline(silly_thing_to, "read"); 106. 	    return(0); 107. 	} else if (Blind) { 108. 	    const char *what = 0; 109. 	    if (scroll->oclass == SPBOOK_CLASS) 110. 		what = "mystic runes"; 111. 	    else if (!scroll->dknown) 112. 		what = "formula on the scroll"; 113. 	    if (what) { 114. 		pline("Being blind, you cannot read the %s.", what); 115. 		return(0); 116. 	    }  117.  	}  118.   119.  	/* Actions required to win the game aren't counted towards conduct */ 120. 	if (scroll->otyp != SPE_BOOK_OF_THE_DEAD &&  121.  		scroll->otyp != SPE_BLANK_PAPER &&  122.  		scroll->otyp != SCR_BLANK_PAPER) 123. 	    u.uconduct.literate++; 124.  125.  	confused = (Confusion != 0); 126. #ifdef MAIL 127. 	if (scroll->otyp == SCR_MAIL) confused = FALSE; 128. #endif 129. 	if(scroll->oclass == SPBOOK_CLASS) { 130. 	    if(confused) { 131. 		You("cannot grasp the meaning of this tome."); 132. 		return(0); 133. 	    } else 134. 		return(study_book(scroll)); 135. 	}  136.  	scroll->in_use = TRUE;	/* scroll, not spellbook, now being read */ 137. 	if(scroll->otyp != SCR_BLANK_PAPER) { 138. 	  if(Blind) 139. 	    pline("As you %s the formula on it, the scroll disappears.",  140.  			is_silent(youmonst.data) ? "cogitate" : "pronounce"); 141. 	  else 142. 	    pline("As you read the scroll, it disappears."); 143. 	  if(confused) { 144. 	    if (Hallucination) 145. 		pline("Being so trippy, you screw up..."); 146. 	    else 147. 		pline("Being confused, you mis%s the magic words...",  148.  			is_silent(youmonst.data) ? "understand" : "pronounce"); 149. 	  }  150.  	}  151.  	if(!seffects(scroll))  { 152. 		if(!objects[scroll->otyp].oc_name_known) { 153. 		    if(known) { 154. 			makeknown(scroll->otyp); 155. 			more_experienced(0,10); 156. 		    } else if(!objects[scroll->otyp].oc_uname) 157. 			docall(scroll); 158. 		}  159.  		if(scroll->otyp != SCR_BLANK_PAPER) 160. 			useup(scroll); 161. 		else scroll->in_use = FALSE; 162. 	}  163.  	return(1); 164. }  165.   166.  static void 167. stripspe(obj) 168. register struct obj *obj; 169. {  170.  	if (obj->blessed) pline(nothing_happens); 171. 	else { 172. 		if (obj->spe > 0) { 173. 		    obj->spe = 0; 174. 		    if (obj->otyp == OIL_LAMP || obj->otyp == BRASS_LANTERN) 175. 			obj->age = 0; 176. 		    Your("%s %s briefly.",xname(obj), otense(obj, "vibrate")); 177. 		} else pline(nothing_happens); 178. 	}  179.  }  180.   181.  static void 182. p_glow1(otmp) 183. register struct obj	*otmp; 184. {  185.  	Your("%s %s briefly.", xname(otmp),  186.  	     otense(otmp, Blind ? "vibrate" : "glow")); 187. }  188.   189.  static void 190. p_glow2(otmp,color) 191. register struct obj	*otmp; 192. register const char *color; 193. {  194.  	Your("%s %s%s%s for a moment.",  195.  		xname(otmp),  196.  		otense(otmp, Blind ? "vibrate" : "glow"), 197.  		Blind ? "" : " ",  198.  		Blind ? nul : hcolor(color)); 199. }  200.   201.  /* Is the object chargeable? For purposes of inventory display; it is */ 202. /* possible to be able to charge things for which this returns FALSE. */ 203.  boolean 204. is_chargeable(obj) 205. struct obj *obj; 206. {  207.  	if (obj->oclass == WAND_CLASS) return TRUE; 208. 	/* known && !uname is possible after amnesia/mind flayer */ 209. 	if (obj->oclass == RING_CLASS) 210. 	    return (boolean)(objects[obj->otyp].oc_charged &&  211.  			(obj->known || objects[obj->otyp].oc_uname)); 212. 	if (is_weptool(obj))	/* specific check before general tools */ 213. 	    return FALSE; 214. 	if (obj->oclass == TOOL_CLASS) 215. 	    return (boolean)(objects[obj->otyp].oc_charged); 216. 	return FALSE; /* why are weapons/armor considered charged anyway? */ 217.  }  218.   219.  /*  220.   * recharge an object; curse_bless is -1 if the recharging implement 221.  * was cursed, +1 if blessed, 0 otherwise. 222.  */  223.  void 224. recharge(obj, curse_bless) 225. struct obj *obj; 226. int curse_bless; 227. {  228.  	register int n;  229. boolean is_cursed, is_blessed; 230.  231.  	is_cursed = curse_bless < 0; 232. 	is_blessed = curse_bless > 0; 233.  234.  	if (obj->oclass == WAND_CLASS) { 235. 	    /* undo any prior cancellation, even when is_cursed */ 236. 	    if (obj->spe == -1) obj->spe = 0; 237.  238.  	    /*  239.  	     * Recharging might cause wands to explode. 240. 	     *	v = number of previous recharges 241. 	     *	      v = percentage chance to explode on this attempt 242. 	     *		      v = cumulative odds for exploding 243. 	     *	0 :   0       0  244.  	     *	1 :   0.29    0.29  245.  	     *	2 :   2.33    2.62  246.  	     *	3 :   7.87   10.28  247.  	     *	4 :  18.66   27.02  248.  	     *	5 :  36.44   53.62  249.  	     *	6 :  62.97   82.83  250.  	     *	7 : 100     100  251.  	     */  252.  	    n = (int)obj->recharged; 253. 	    if (n > 0 && (obj->otyp == WAN_WISHING || 254. 		    (n * n * n > rn2(7*7*7)))) {	/* recharge_limit */ 255. 		wand_explode(obj); 256. 		return; 257. 	    }  258.  	    /* didn't explode, so increment the recharge count */ 259. 	    obj->recharged = (unsigned)(n + 1); 260.  261.  	    /* now handle the actual recharging */ 262. 	    if (is_cursed) { 263. 		stripspe(obj); 264. 	    } else { 265. 		int lim = (obj->otyp == WAN_WISHING) ? 3 : 266.  			(objects[obj->otyp].oc_dir != NODIR) ? 8 : 15; 267.   268.  		n = (lim == 3) ? 3 : rn1(5, lim + 1 - 5); 269. 		if (!is_blessed) n = rnd(n); 270.  271.  		if (obj->spe < n) obj->spe = n;  272. else obj->spe++; 273. 		if (obj->otyp == WAN_WISHING && obj->spe > 3) { 274. 		    wand_explode(obj); 275. 		    return; 276. 		}  277.  		if (obj->spe >= lim) p_glow2(obj,blue); 278. 		else p_glow1(obj); 279. 	    }  280.   281.  	} else if (obj->oclass == RING_CLASS &&  282.  					objects[obj->otyp].oc_charged) { 283. 	    /* charging does not affect ring's curse/bless status */ 284. 	    int s = is_blessed ? rnd(3) : is_cursed ? -rnd(2) : 1; 285. 	    boolean is_on = (obj == uleft || obj == uright); 286.  287.  	    /* destruction depends on current state, not adjustment */ 288. 	    if (obj->spe > rn2(7) || obj->spe <= -5) { 289. 		Your("%s %s momentarily, then %s!",  290.  		     xname(obj), otense(obj,"pulsate"), otense(obj,"explode")); 291. 		if (is_on) Ring_gone(obj); 292. 		s = rnd(3 * abs(obj->spe));	/* amount of damage */ 293. 		useup(obj); 294. 		losehp(s, "exploding ring", KILLED_BY_AN); 295. 	    } else { 296. 		long mask = is_on ? (obj == uleft ? LEFT_RING : 297.  				     RIGHT_RING) : 0L; 298. 		Your("%s spins %sclockwise for a moment.",  299.  		     xname(obj), s < 0 ? "counter" : ""); 300. 		/* cause attributes and/or properties to be updated */ 301. 		if (is_on) Ring_off(obj); 302. 		obj->spe += s;	/* update the ring while it's off */ 303. 		if (is_on) setworn(obj, mask), Ring_on(obj); 304. 		/* oartifact: if a touch-sensitive artifact ring is  305. ever created the above will need to be revised */ 306. 	    }  307.   308.  	} else if (obj->oclass == TOOL_CLASS) { 309. 	    int rechrg = (int)obj->recharged; 310.  311.  	    if (objects[obj->otyp].oc_charged) { 312. 		/* tools don't have a limit, but the counter used does */ 313. 		if (rechrg < 7)	/* recharge_limit */ 314. 		    obj->recharged++; 315. 	    }  316.  	    switch(obj->otyp) { 317. 	    case BELL_OF_OPENING: 318. 		if (is_cursed) stripspe(obj); 319. 		else if (is_blessed) obj->spe += rnd(3); 320. 		else obj->spe += 1; 321. 		if (obj->spe > 5) obj->spe = 5; 322. 		break; 323. 	    case MAGIC_MARKER: 324. 	    case TINNING_KIT: 325. #ifdef TOURIST 326. 	    case EXPENSIVE_CAMERA: 327. #endif 328. 		if (is_cursed) stripspe(obj); 329. 		else if (rechrg && obj->otyp == MAGIC_MARKER) {	/* previously recharged */ 330. 		    obj->recharged = 1;	/* override increment done above */ 331. 		    if (obj->spe < 3) 332. 			Your("marker seems permanently dried out."); 333. 		    else 334. 			pline(nothing_happens); 335. 		} else if (is_blessed) { 336. 		    n = rn1(10,16);		/* 10..25 */ 337. 		    if (obj->spe + n <= 50) 338. 			obj->spe = 50; 339. 		    else if (obj->spe + n <= 75) 340. 			obj->spe = 75; 341. 		    else { 342. 		    	int chrg = (int)obj->spe; 343. 			if ((chrg + n) > 127) 344. 				obj->spe = 127; 345. 			else 346. 				obj->spe += n;  347. } 348.  		    p_glow2(obj,blue); 349. 		} else { 350. 		    n = rn1(5,10);		/* 5..15 */ 351. 		    if (obj->spe + n <= 50) 352. 			obj->spe = 50; 353. 		    else { 354. 		    	int chrg = (int)obj->spe; 355. 			if ((chrg + n) > 127) 356. 				obj->spe = 127; 357. 			else 358. 				obj->spe += n;  359. } 360.  		    p_glow2(obj,White); 361. 		}  362.  		break; 363. 	    case OIL_LAMP: 364. 	    case BRASS_LANTERN: 365. 		if (is_cursed) { 366. 		    stripspe(obj); 367. 		    if (obj->lamplit) { 368. 			if (!Blind) 369. 			    pline("%s out!", Tobjnam(obj, "go")); 370. 			end_burn(obj, TRUE); 371. 		    }  372.  		} else if (is_blessed) { 373. 		    obj->spe = 1; 374. 		    obj->age = 1500; 375. 		    p_glow2(obj,blue); 376. 		} else { 377. 		    obj->spe = 1; 378. 		    obj->age += 750; 379. 		    if (obj->age > 1500) obj->age = 1500; 380. 		    p_glow1(obj); 381. 		}  382.  		break; 383. 	    case CRYSTAL_BALL: 384. 		if (is_cursed) stripspe(obj); 385. 		else if (is_blessed) { 386. 		    obj->spe = 6; 387. 		    p_glow2(obj,blue); 388. 		} else { 389. 		    if (obj->spe < 5) { 390. 			obj->spe++; 391. 			p_glow1(obj); 392. 		    } else pline(nothing_happens); 393. 		}  394.  		break; 395. 	    case HORN_OF_PLENTY: 396. 	    case BAG_OF_TRICKS: 397. 	    case CAN_OF_GREASE: 398. 		if (is_cursed) stripspe(obj); 399. 		else if (is_blessed) { 400. 		    if (obj->spe <= 10) 401. 			obj->spe += rn1(10, 6); 402. 		    else obj->spe += rn1(5, 6); 403. 		    if (obj->spe > 50) obj->spe = 50; 404. 		    p_glow2(obj,blue); 405. 		} else { 406. 		    obj->spe += rnd(5); 407. 		    if (obj->spe > 50) obj->spe = 50; 408. 		    p_glow1(obj); 409. 		}  410.  		break; 411. 	    case MAGIC_FLUTE: 412. 	    case MAGIC_HARP: 413. 	    case FROST_HORN: 414. 	    case FIRE_HORN: 415. 	    case DRUM_OF_EARTHQUAKE: 416. 		if (is_cursed) { 417. 		    stripspe(obj); 418. 		} else if (is_blessed) { 419. 		    obj->spe += d(2,4); 420. 		    if (obj->spe > 20) obj->spe = 20; 421. 		    p_glow2(obj,blue); 422. 		} else { 423. 		    obj->spe += rnd(4); 424. 		    if (obj->spe > 20) obj->spe = 20; 425. 		    p_glow1(obj); 426. 		}  427.  		break; 428. 	    default: 429. 		goto not_chargable; 430. 		/*NOTREACHED*/ 431. 		break; 432. 	    } /* switch */ 433.  434.  	} else { 435.  not_chargable: 436. 	    You("have a feeling of loss."); 437. 	}  438.  }  439.   440.   441.  /* Forget known information about this object class. */ 442.  static void 443. forget_single_object(obj_id) 444. 	int obj_id; 445. {  446.  	objects[obj_id].oc_name_known = 0; 447. 	objects[obj_id].oc_pre_discovered = 0;	/* a discovery when relearned */ 448. 	if (objects[obj_id].oc_uname) { 449. 	    free((genericptr_t)objects[obj_id].oc_uname); 450. 	    objects[obj_id].oc_uname = 0; 451. 	}  452.  	undiscover_object(obj_id);	/* after clearing oc_name_known */ 453.  454.  	/* clear & free object names from matching inventory items too? */ 455.  }  456.   457.   458.  #if 0	/* here if anyone wants it.... */ 459.  /* Forget everything known about a particular object class. */ 460.  static void 461. forget_objclass(oclass) 462. 	int oclass; 463. {  464.  	int i;  465. 466. 	for (i=bases[oclass];  467.  		i < NUM_OBJECTS && objects[i].oc_class==oclass; i++) 468. 	    forget_single_object(i); 469. }  470.  #endif 471.  472.   473.  /* randomize the given list of numbers  0 <= i < count */ 474. static void 475. randomize(indices, count) 476. 	int *indices; 477. 	int count; 478. {  479.  	int i, iswap, temp; 480.  481.  	for (i = count - 1; i > 0; i--) { 482. 	    if ((iswap = rn2(i + 1)) == i) continue; 483. 	    temp = indices[i]; 484. 	    indices[i] = indices[iswap]; 485. 	    indices[iswap] = temp; 486. 	}  487.  }  488.   489.   490.  /* Forget % of known objects. */ 491.  void 492. forget_objects(percent) 493. 	int percent; 494. {  495.  	int i, count; 496. 	int indices[NUM_OBJECTS]; 497.  498.  	if (percent == 0) return; 499. 	if (percent <= 0 || percent > 100) { 500. 	    impossible("forget_objects: bad percent %d", percent); 501. 	    return; 502. 	}  503.   504.  	for (count = 0, i = 1; i < NUM_OBJECTS; i++) 505. 	    if (OBJ_DESCR(objects[i]) &&  506.  		    (objects[i].oc_name_known || objects[i].oc_uname)) 507. 		indices[count++] = i;  508. 509. 	randomize(indices, count); 510.  511.  	/* forget first % of randomized indices */ 512. 	count = ((count * percent) + 50) / 100; 513. 	for (i = 0; i < count; i++) 514. 	    forget_single_object(indices[i]); 515. }  516.   517.   518.  /* Forget some or all of map (depends on parameters). */ 519.  void 520. forget_map(howmuch) 521. 	int howmuch; 522. {  523.  	register int zx, zy; 524.  525.  	if (In_sokoban(&u.uz)) 526. 	    return; 527.  528.  	known = TRUE; 529. 	for(zx = 0; zx < COLNO; zx++) for(zy = 0; zy < ROWNO; zy++) 530. 	    if (howmuch & ALL_MAP || rn2(7)) { 531. 		/* Zonk all memory of this location. */ 532.  		levl[zx][zy].seenv = 0; 533. 		levl[zx][zy].waslit = 0; 534. 		levl[zx][zy].glyph = cmap_to_glyph(S_stone); 535. 	    }  536.  }  537.   538.  /* Forget all traps on the level. */ 539.  void 540. forget_traps 541. {  542.  	register struct trap *trap; 543.  544.  	/* forget all traps (except the one the hero is in :-) */ 545. 	for (trap = ftrap; trap; trap = trap->ntrap) 546. 	    if ((trap->tx != u.ux || trap->ty != u.uy) && (trap->ttyp != HOLE)) 547. 		trap->tseen = 0; 548. }  549.   550.  /*  551.   * Forget given % of all levels that the hero has visited and not forgotten, 552.  * except this one. 553.  */  554.  void 555. forget_levels(percent) 556. 	int percent; 557. {  558.  	int i, count; 559. 	xchar  maxl, this_lev; 560. 	int indices[MAXLINFO]; 561.  562.  	if (percent == 0) return; 563.  564.  	if (percent <= 0 || percent > 100) { 565. 	    impossible("forget_levels: bad percent %d", percent); 566. 	    return; 567. 	}  568.   569.  	this_lev = ledger_no(&u.uz); 570. 	maxl = maxledgerno; 571.  572.  	/* count & save indices of non-forgotten visited levels */ 573. 	/* Sokoban levels are pre-mapped for the player, and should stay 574. 	 * so, or they become nearly impossible to solve. But try to 575. * shift the forgetting elsewhere by fiddling with percent 576. 	 * instead of forgetting fewer levels. 577. 	 */  578.  	for (count = 0, i = 0; i <= maxl; i++) 579. 	    if ((level_info[i].flags & VISITED) &&  580.  			!(level_info[i].flags & FORGOTTEN) && i != this_lev) { 581. 		if (ledger_to_dnum(i) == sokoban_dnum) 582. 		    percent += 2; 583. 		else 584. 		    indices[count++] = i;  585. } 586.  	  587.  	if (percent > 100) percent = 100; 588.  589.  	randomize(indices, count); 590.  591.  	/* forget first % of randomized indices */ 592. 	count = ((count * percent) + 50) / 100; 593. 	for (i = 0; i < count; i++) { 594. 	    level_info[indices[i]].flags |= FORGOTTEN; 595. 	}  596.  }  597.   598.  /*  599.   * Forget some things (e.g. after reading a scroll of amnesia). When called, 600.  * the following are always forgotten: 601.  *  602.   *	- felt ball & chain 603.  *	- traps 604.  *	- part (6 out of 7) of the map 605.  *  606.   * Other things are subject to flags: 607.  *  608.   *	howmuch & ALL_MAP	= forget whole map 609.  *	howmuch & ALL_SPELLS	= forget all spells 610.  */  611.  static void 612. forget(howmuch) 613. int howmuch; 614. {  615.   616.  	if (Punished) u.bc_felt = 0;	/* forget felt ball&chain */ 617.  618.  	forget_map(howmuch); 619. 	forget_traps; 620.  621.  	/* 1 in 3 chance of forgetting some levels */ 622. 	if (!rn2(3)) forget_levels(rn2(25)); 623.  624.  	/* 1 in 3 chance of forgeting some objects */ 625. 	if (!rn2(3)) forget_objects(rn2(25)); 626.  627.  	if (howmuch & ALL_SPELLS) losespells; 628. 	/*  629.  	 * Make sure that what was seen is restored correctly. To do this, 630. 	 * we need to go blind for an instant --- turn off the display, 631. 	 * then restart it. All this work is needed to correctly handle 632. 	 * walls which are stone on one side and wall on the other. Turning 633. 	 * off the seen bits above will make the wall revert to stone,  but 634. 	 * there are cases where we don't want this to happen. The easiest 635. 	 * thing to do is to run it through the vision system again, which 636. 	 * is always correct. 637. 	 */  638.  	docrt;		/* this correctly will reset vision */ 639. }  640.   641.  /* monster is hit by scroll of taming's effect */ 642. static void 643. maybe_tame(mtmp, sobj) 644. struct monst *mtmp; 645. struct obj *sobj; 646. {  647.  	if (sobj->cursed) { 648. 	    setmangry(mtmp); 649. 	} else { 650. 	    if (mtmp->isshk) 651. 		make_happy_shk(mtmp, FALSE); 652. 	    else if (!resist(mtmp, sobj->oclass, 0, NOTELL)) 653. 		(void) tamedog(mtmp, (struct obj *) 0); 654. 	}  655.  }  656.   657.  int 658. seffects(sobj) 659. register struct obj	*sobj; 660. {  661.  	register int cval; 662. 	register boolean confused = (Confusion != 0); 663. 	register struct obj *otmp; 664.  665.  	if (objects[sobj->otyp].oc_magic) 666. 		exercise(A_WIS, TRUE);		/* just for trying */ 667. 	switch(sobj->otyp) { 668. #ifdef MAIL 669. 	case SCR_MAIL: 670. 		known = TRUE; 671. 		if (sobj->spe) 672. 		    pline("This seems to be junk mail addressed to the finder of the Eye of Larn."); 673. 		/* note to the puzzled: the game Larn actually sends you junk 674. 		 * mail if you win! 675. 		 */  676.  		else readmail(sobj); 677. 		break; 678. #endif 679. 	case SCR_ENCHANT_ARMOR: 680. 	    {  681.  		register schar s;  682. boolean special_armor; 683. 		boolean same_color; 684.  685.  		otmp = some_armor(&youmonst); 686. 		if(!otmp) { 687. 			strange_feeling(sobj,  688.  					!Blind ? "Your skin glows then fades." :  689.  					"Your skin feels warm for a moment."); 690. 			exercise(A_CON, !sobj->cursed); 691. 			exercise(A_STR, !sobj->cursed); 692. 			return(1); 693. 		}  694.  		if(confused) { 695. 			otmp->oerodeproof = !(sobj->cursed); 696. 			if(Blind) { 697. 			    otmp->rknown = FALSE; 698. 			    Your("%s %s warm for a moment.",  699.  				xname(otmp), otense(otmp, "feel")); 700. 			} else { 701. 			    otmp->rknown = TRUE; 702. 			    Your("%s %s covered by a %s %s %s!",  703.  				xname(otmp), otense(otmp, "are"),  704.  				sobj->cursed ? "mottled" : "shimmering",  705.  				hcolor(sobj->cursed ? Black : golden), 706.  				sobj->cursed ? "glow" :  707.  				  (is_shield(otmp) ? "layer" : "shield")); 708. 			}  709.  			if (otmp->oerodeproof &&  710.  			    (otmp->oeroded || otmp->oeroded2)) { 711. 			    otmp->oeroded = otmp->oeroded2 = 0; 712. 			    Your("%s %s as good as new!",  713.  				 xname(otmp),  714.  				 otense(otmp, Blind ? "feel" : "look")); 715. 			}  716.  			break; 717. 		}  718.  		special_armor = is_elven_armor(otmp) || 719. 			(Role_if(PM_WIZARD) && otmp->otyp == CORNUTHAUM); 720. 		if (sobj->cursed) 721. 		    same_color = 722. 			(otmp->otyp == BLACK_DRAGON_SCALE_MAIL ||  723.  			 otmp->otyp == BLACK_DRAGON_SCALES); 724. 		else 725. 		    same_color = 726. 			(otmp->otyp == SILVER_DRAGON_SCALE_MAIL ||  727.  			 otmp->otyp == SILVER_DRAGON_SCALES ||  728.  			 otmp->otyp == SHIELD_OF_REFLECTION); 729. 		if (Blind) same_color = FALSE; 730.  731.  		/* KMH -- catch underflow */ 732. 		s = sobj->cursed ? -otmp->spe : otmp->spe; 733. 		if (s > (special_armor ? 5 : 3) && rn2(s)) { 734. 		Your("%s violently %s%s%s for a while, then %s.",  735.  		     xname(otmp),  736.  		     otense(otmp, Blind ? "vibrate" : "glow"), 737.  		     (!Blind && !same_color) ? " " : nul,  738.  		     (Blind || same_color) ? nul :  739.  			hcolor(sobj->cursed ? Black : silver), 740.  		     otense(otmp, "evaporate")); 741. 			if(is_cloak(otmp)) (void) Cloak_off; 742. 			if(is_boots(otmp)) (void) Boots_off; 743. 			if(is_helmet(otmp)) (void) Helmet_off; 744. 			if(is_gloves(otmp)) (void) Gloves_off; 745. 			if(is_shield(otmp)) (void) Shield_off; 746. 			if(otmp == uarm) (void) Armor_gone; 747. 			useup(otmp); 748. 			break; 749. 		}  750.  		s = sobj->cursed ? -1 : 751.  		    otmp->spe >= 9 ? (rn2(otmp->spe) == 0) : 752. 		    sobj->blessed ? rnd(3-otmp->spe/3) : 1; 753. 		if (s >= 0 && otmp->otyp >= GRAY_DRAGON_SCALES &&  754.  					otmp->otyp <= YELLOW_DRAGON_SCALES) { 755. 			/* dragon scales get turned into dragon scale mail */ 756. 			Your("%s merges and hardens!", xname(otmp)); 757. 			setworn((struct obj *)0, W_ARM); 758. 			/* assumes same order */ 759. 			otmp->otyp = GRAY_DRAGON_SCALE_MAIL + 760. 						otmp->otyp - GRAY_DRAGON_SCALES; 761. 			otmp->cursed = 0; 762. 			if (sobj->blessed) { 763. 				otmp->spe++; 764. 				otmp->blessed = 1; 765. 			}  766.  			otmp->known = 1; 767. 			setworn(otmp, W_ARM); 768. 			break; 769. 		}  770.  		Your("%s %s%s%s%s for a %s.",  771.  			xname(otmp),  772.  		        s == 0 ? "violently " : nul,  773.  			otense(otmp, Blind ? "vibrate" : "glow"), 774.  			(!Blind && !same_color) ? " " : nul,  775.  			(Blind || same_color) ? nul : hcolor(sobj->cursed ? Black : silver), 776.  			  (s*s>1) ? "while" : "moment"); 777. 		otmp->cursed = sobj->cursed; 778. 		if (!otmp->blessed || sobj->cursed) 779. 			otmp->blessed = sobj->blessed; 780. 		if (s) { 781. 			otmp->spe += s;  782. adj_abon(otmp, s); 783. 			known = otmp->known; 784. 		}  785.   786.  		if ((otmp->spe > (special_armor ? 5 : 3)) &&  787.  		    (special_armor || !rn2(7))) 788. 			Your("%s suddenly %s %s.",  789.  				xname(otmp), otense(otmp, "vibrate"),  790.  				Blind ? "again" : "unexpectedly"); 791. 		break; 792. 	    }  793.  	case SCR_DESTROY_ARMOR: 794. 	    {  795.  		otmp = some_armor(&youmonst); 796. 		if(confused) { 797. 			if(!otmp) { 798. 				strange_feeling(sobj,"Your bones itch."); 799. 				exercise(A_STR, FALSE); 800. 				exercise(A_CON, FALSE); 801. 				return(1); 802. 			}  803.  			otmp->oerodeproof = sobj->cursed; 804. 			p_glow2(otmp,purple); 805. 			break; 806. 		}  807.  		if(!sobj->cursed || !otmp || !otmp->cursed) { 808. 		    if(!destroy_arm(otmp)) { 809. 			strange_feeling(sobj,"Your skin itches."); 810. 			exercise(A_STR, FALSE); 811. 			exercise(A_CON, FALSE); 812. 			return(1); 813. 		    } else 814. 			known = TRUE; 815. 		} else {	/* armor and scroll both cursed */ 816. 		    Your("%s %s.", xname(otmp), otense(otmp, "vibrate")); 817. 		    if (otmp->spe >= -6) otmp->spe--; 818. 		    make_stunned(HStun + rn1(10, 10), TRUE); 819. 		}  820.  	    }  821.  	    break; 822. 	case SCR_CONFUSE_MONSTER: 823. 	case SPE_CONFUSE_MONSTER: 824. 		if(youmonst.data->mlet != S_HUMAN || sobj->cursed) { 825. 			if(!HConfusion) You_feel("confused."); 826. 			make_confused(HConfusion + rnd(100),FALSE); 827. 		} else  if(confused) { 828. 		    if(!sobj->blessed) { 829. 			Your("%s begin to %s%s.",  830.  			    makeplural(body_part(HAND)),  831.  			    Blind ? "tingle" : "glow ",  832.  			    Blind ? nul : hcolor(purple)); 833. 			make_confused(HConfusion + rnd(100),FALSE); 834. 		    } else { 835. 			pline("A %s%s surrounds your %s.",  836.  			    Blind ? nul : hcolor(red),  837.  			    Blind ? "faint buzz" : " glow",  838.  			    body_part(HEAD)); 839. 			make_confused(0L,TRUE); 840. 		    }  841.  		} else { 842. 		    if (!sobj->blessed) { 843. 			Your("%s%s %s%s.",  844.  			makeplural(body_part(HAND)),  845.  			Blind ? "" : " begin to glow",  846.  			Blind ? (const char *)"tingle" : hcolor(red),  847.  			u.umconf ? " even more" : ""); 848. 			u.umconf++; 849. 		    } else { 850. 			if (Blind) 851. 			    Your("%s tingle %s sharply.",  852.  				makeplural(body_part(HAND)),  853.  				u.umconf ? "even more" : "very"); 854. 			else 855. 			    Your("%s glow a%s brilliant %s.",  856.  				makeplural(body_part(HAND)),  857.  				u.umconf ? "n even more" : "",  858.  				hcolor(red)); 859. 			/* after a while, repeated uses become less effective */ 860. 			if (u.umconf >= 40) 861. 			    u.umconf++; 862. 			else 863. 			    u.umconf += rn1(8, 2); 864. 		    }  865.  		}  866.  		break; 867. 	case SCR_SCARE_MONSTER: 868. 	case SPE_CAUSE_FEAR: 869. 	    {	register int ct = 0; 870. 		register struct monst *mtmp; 871.  872.  		for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 873. 		    if (DEADMONSTER(mtmp)) continue; 874. 		    if(cansee(mtmp->mx,mtmp->my)) { 875. 			if(confused || sobj->cursed) { 876. 			    mtmp->mflee = mtmp->mfrozen = mtmp->msleeping = 0; 877. 			    mtmp->mcanmove = 1; 878. 			} else 879. 			    if (! resist(mtmp, sobj->oclass, 0, NOTELL)) 880. 				monflee(mtmp, 0, FALSE, FALSE); 881. 			if(!mtmp->mtame) ct++;	/* pets don't laugh at you */ 882. 		    }  883.  		}  884.  		if(!ct) 885. 		      You_hear("%s in the distance.",  886.  			       (confused || sobj->cursed) ? "sad wailing" :  887.  							"maniacal laughter"); 888. 		else if(sobj->otyp == SCR_SCARE_MONSTER) 889. 			You_hear("%s close by.",  890.  				  (confused || sobj->cursed) ? "sad wailing" :  891.  						 "maniacal laughter"); 892. 		break; 893. 	    }  894.  	case SCR_BLANK_PAPER: 895. 	    if (Blind) 896. 		You("don't remember there being any magic words on this scroll."); 897. 	    else 898. 		pline("This scroll seems to be blank."); 899. 	    known = TRUE; 900. 	    break; 901. 	case SCR_REMOVE_CURSE: 902. 	case SPE_REMOVE_CURSE: 903. 	    {	register struct obj *obj; 904. 		if(confused) 905. 		    if (Hallucination) 906. 			You_feel("the power of the Force against you!"); 907. 		    else 908. 			You_feel("like you need some help."); 909. 		else 910. 		    if (Hallucination) 911. 			You_feel("in touch with the Universal Oneness."); 912. 		    else 913. 			You_feel("like someone is helping you."); 914.  915.  		if (sobj->cursed) { 916. 		    pline_The("scroll disintegrates."); 917. 		} else { 918. 		    for (obj = invent; obj; obj = obj->nobj) 919. 			if (sobj->blessed ||  920.  			     (obj->owornmask && 921. 			       ((obj->owornmask & ~W_SWAPWEP) || u.twoweap)) ||  922.  			     obj->otyp == LOADSTONE ||  923.  			     (obj->otyp == LEASH && obj->leashmon)) { 924. 			    if(confused) blessorcurse(obj, 2); 925. 			    else uncurse(obj); 926. 			}  927.  		}  928.  		if(Punished && !confused) unpunish; 929. 		update_inventory; 930. 		break; 931. 	    }  932.  	case SCR_CREATE_MONSTER: 933. 	case SPE_CREATE_MONSTER: 934. 	    if (create_critters(1 + ((confused || sobj->cursed) ? 12 : 0) + 935. 				((sobj->blessed || rn2(73)) ? 0 : rnd(4)), 936. 			confused ? &mons[PM_ACID_BLOB] : (struct permonst *)0)) 937. 		known = TRUE; 938. 	    /* no need to flush monsters; we ask for identification only if the 939. 	     * monsters are not visible 940. 	     */  941.  	    break; 942. 	case SCR_ENCHANT_WEAPON: 943. 		if(uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))  944.  			&& confused) { 945. 		/* oclass check added 10/25/86 GAN */ 946. 			uwep->oerodeproof = !(sobj->cursed); 947. 			if (Blind) { 948. 			    uwep->rknown = FALSE; 949. 			    Your("weapon feels warm for a moment."); 950. 			} else { 951. 			    uwep->rknown = TRUE; 952. 			    Your("%s covered by a %s %s %s!",  953.  				aobjnam(uwep, "are"),  954.  				sobj->cursed ? "mottled" : "shimmering",  955.  				hcolor(sobj->cursed ? purple : golden), 956.  				sobj->cursed ? "glow" : "shield"); 957. 			}  958.  			if (uwep->oerodeproof && (uwep->oeroded || uwep->oeroded2)) { 959. 			    uwep->oeroded = uwep->oeroded2 = 0; 960. 			    Your("%s as good as new!",  961.  				 aobjnam(uwep, Blind ? "feel" : "look")); 962. 			}  963.  		} else return !chwepon(sobj,  964.  				       sobj->cursed ? -1 :  965.  				       !uwep ? 1 :  966.  				       uwep->spe >= 9 ? (rn2(uwep->spe) == 0) :  967.  				       sobj->blessed ? rnd(3-uwep->spe/3) : 1); 968. 		break; 969. 	case SCR_TAMING: 970. 	case SPE_CHARM_MONSTER: 971. 		if (u.uswallow) { 972. 		    maybe_tame(u.ustuck, sobj); 973. 		} else { 974. 		    int i, j, bd = confused ? 5 : 1; 975.  		    struct monst *mtmp; 976.  977.  		    for (i = -bd; i <= bd; i++) for(j = -bd; j <= bd; j++) { 978. 			if (!isok(u.ux + i, u.uy + j)) continue; 979. 			if ((mtmp = m_at(u.ux + i, u.uy + j)) != 0) 980. 			    maybe_tame(mtmp, sobj); 981. 		    }  982.  		}  983.  		break; 984. 	case SCR_GENOCIDE: 985. 		You("have found a scroll of genocide!"); 986. 		known = TRUE; 987. 		if (sobj->blessed) do_class_genocide; 988. 		else do_genocide(!sobj->cursed | (2 * !!Confusion)); 989. 		break; 990. 	case SCR_LIGHT: 991. 		if(!Blind) known = TRUE; 992. 		litroom(!confused && !sobj->cursed, sobj); 993. 		break; 994. 	case SCR_TELEPORTATION: 995. 		if(confused || sobj->cursed) level_tele; 996. 		else { 997. 			if (sobj->blessed && !Teleport_control) { 998. 				known = TRUE; 999. 				if (yn("Do you wish to teleport?")=='n') 1000. 					break; 1001. 			} 1002. 			tele; 1003. 			if(Teleport_control || !couldsee(u.ux0, u.uy0) || 1004. 			   (distu(u.ux0, u.uy0) >= 16)) 1005. 				known = TRUE; 1006. 		} 1007. 		break; 1008. 	case SCR_GOLD_DETECTION: 1009. 		if (confused || sobj->cursed) return(trap_detect(sobj)); 1010. 		else return(gold_detect(sobj)); 1011. 	case SCR_FOOD_DETECTION: 1012. 	case SPE_DETECT_FOOD: 1013. 		if (food_detect(sobj)) 1014. 			return(1);	/* nothing detected */ 1015. 		break; 1016. 	case SPE_IDENTIFY: 1017. 		cval = rn2(5); 1018. 		goto id; 1019. 	case SCR_IDENTIFY: 1020. 		/* known = TRUE; */ 1021. 		if(confused) 1022. 			You("identify this as an identify scroll."); 1023. 		else 1024. 			pline("This is an identify scroll."); 1025. 		if (sobj->blessed || (!sobj->cursed && !rn2(5))) { 1026. 			cval = rn2(5); 1027. 			/* Note: if rn2(5)==0, identify all items */ 1028. 			if (cval == 1 && sobj->blessed && Luck > 0) ++cval; 1029. 		} else	cval = 1; 1030. 		if(!objects[sobj->otyp].oc_name_known) more_experienced(0,10); 1031. 		useup(sobj); 1032. 		makeknown(SCR_IDENTIFY); 1033. 	id: 1034. 		if(invent && !confused) { 1035. 		   identify_pack(cval); 1036. 		} 1037. 		return(1); 1038. 	case SCR_CHARGING: 1039. 		if (confused) { 1040. 		   You_feel("charged up!"); 1041. 		   if (u.uen < u.uenmax) 1042. 			u.uen = u.uenmax; 1043. 		   else 1044. 			u.uen = (u.uenmax += d(5,4)); 1045. 		   flags.botl = 1; 1046. 		   break; 1047. 		} 1048. 		known = TRUE; 1049. 		pline("This is a charging scroll."); 1050. 		otmp = getobj(all_count, "charge"); 1051. 		if (!otmp) break; 1052. 		recharge(otmp, sobj->cursed ? -1 : (sobj->blessed ? 1 : 0)); 1053. 		break; 1054. 	case SCR_MAGIC_MAPPING: 1055. 		if (level.flags.nommap) { 1056. 		   Your("mind is filled with crazy lines!"); 1057. 		   if (Hallucination) 1058. 			pline("Wow! Modern art."); 1059. 		   else 1060. 			Your("%s spins in bewilderment.", body_part(HEAD)); 1061. 		   make_confused(HConfusion + rnd(30), FALSE); 1062. 		   break; 1063. 		} 1064. 		if (sobj->blessed) { 1065. 		   register int x, y;  1066. 1067. 		   for (x = 1; x < COLNO; x++) 1068. 		   	for (y = 0; y < ROWNO; y++) 1069. 		   	    if (levl[x][y].typ == SDOOR) 1070. 		   	    	cvt_sdoor_to_door(&levl[x][y]); 1071. 		   /* do_mapping already reveals secret passages */ 1072. 		} 1073. 		known = TRUE; 1074. 	case SPE_MAGIC_MAPPING: 1075. 		if (level.flags.nommap) { 1076. 		   Your("%s spins as %s blocks the spell!", body_part(HEAD), something); 1077. 		   make_confused(HConfusion + rnd(30), FALSE); 1078. 		   break; 1079. 		} 1080. 		pline("A map coalesces in your mind!"); 1081. 		cval = (sobj->cursed && !confused); 1082. 		if(cval) HConfusion = 1;	/* to screw up map */ 1083. 		do_mapping; 1084. 		if(cval) { 1085. 		   HConfusion = 0;		/* restore */ 1086. 		   pline("Unfortunately, you can't grasp the details."); 1087. 		} 1088. 		break; 1089. 	case SCR_AMNESIA: 1090. 		known = TRUE; 1091. 		forget(	(!sobj->blessed ? ALL_SPELLS : 0) | 1092. 			(!confused || sobj->cursed ? ALL_MAP : 0) ); 1093. 		if (Hallucination) /* Ommmmmm! */ 1094. 			Your("mind releases itself from mundane concerns."); 1095. 		else if (!strncmpi(plname, "Maud", 4)) 1096. 			pline("As your mind turns inward on itself, you forget everything else."); 1097. 		else if (rn2(2)) 1098. 			pline("Who was that Maud person anyway?"); 1099. 		else 1100. 			pline("Thinking of Maud you forget everything else."); 1101. 		exercise(A_WIS, FALSE); 1102. 		break; 1103. 	case SCR_FIRE: 1104. 		/* 1105. 		 * Note: Modifications have been made as of 3.0 to allow for 1106. 		 * some damage under all potential cases. 1107. 		 */ 1108. 		cval = bcsign(sobj); 1109. 		if(!objects[sobj->otyp].oc_name_known) more_experienced(0,10); 1110. 		useup(sobj); 1111. 		makeknown(SCR_FIRE); 1112. 		if(confused) { 1113. 		   if(Fire_resistance) { 1114. 			shieldeff(u.ux, u.uy); 1115. 			if(!Blind) 1116. 			   pline("Oh, look, what a pretty fire in your %s.",  1117. 				makeplural(body_part(HAND))); 1118. 			else You_feel("a pleasant warmth in your %s.", 1119. 				makeplural(body_part(HAND))); 1120. 		   } else { 1121. 			pline_The("scroll catches fire and you burn your %s.", 1122. 				makeplural(body_part(HAND))); 1123. 			losehp(1, "scroll of fire", KILLED_BY_AN); 1124. 		   }  1125. 		    return(1); 1126. 		} 1127. 		if (Underwater) 1128. 			pline_The("water around you vaporizes violently!"); 1129. 		else { 1130. 		   pline_The("scroll erupts in a tower of flame!"); 1131. 		   burn_away_slime; 1132. 		} 1133. 		explode(u.ux, u.uy, 11, (2*(rn1(3, 3) + 2 * cval) + 1)/3,  1134. 							SCROLL_CLASS, EXPL_FIERY); 1135. 		return(1); 1136. 	case SCR_EARTH: 1137. 	   /* TODO: handle steeds */ 1138. 	   if (  1139. #ifdef REINCARNATION  1140. 		!Is_rogue_level(&u.uz) &&  1141. #endif  1142. 	    	 (!In_endgame(&u.uz) || Is_earthlevel(&u.uz))) { 1143. 	   	register int x, y;  1144. 1145. 	   	/* Identify the scroll */ 1146. 	   	pline_The("%s rumbles %s you!", ceiling(u.ux,u.uy),  1147. 	    			sobj->blessed ? "around" : "above"); 1148. 	   	known = 1; 1149. 	   	if (In_sokoban(&u.uz)) 1150. 	   	    change_luck(-1);	/* Sokoban guilt */ 1151. 1152. 	    	/* Loop through the surrounding squares */ 1153. 	   	if (!sobj->cursed) for (x = u.ux-1; x <= u.ux+1; x++) { 1154. 	   	    for (y = u.uy-1; y <= u.uy+1; y++) { 1155. 1156. 	    	    	/* Is this a suitable spot? */ 1157. 	    	    	if (isok(x, y) && !closed_door(x, y) &&  1158. 	    	    			!IS_ROCK(levl[x][y].typ) &&  1159. 	    	    			!IS_AIR(levl[x][y].typ) &&  1160. 					(x != u.ux || y != u.uy)) { 1161. 			   register struct obj *otmp2; 1162. 			   register struct monst *mtmp; 1163. 1164. 	    	    	    /* Make the object(s) */ 1165. 	   	    	    otmp2 = mksobj(confused ? ROCK : BOULDER,  1166. 	    	    	    		FALSE, FALSE); 1167. 	   	    	    if (!otmp2) continue;  /* Shouldn't happen */ 1168. 	   	    	    otmp2->quan = confused ? rn1(5,2) : 1; 1169. 	   	    	    otmp2->owt = weight(otmp2); 1170. 1171. 	    	    	    /* Find the monster here (won't be player) */ 1172. 	   	    	    mtmp = m_at(x, y); 1173. 	   	    	    if (mtmp && !amorphous(mtmp->data) &&  1174. 	    	    	    		!passes_walls(mtmp->data) &&  1175. 	    	    	    		!noncorporeal(mtmp->data) &&  1176. 	    	    	    		!unsolid(mtmp->data)) { 1177. 				struct obj *helmet = which_armor(mtmp, W_ARMH); 1178. 				int mdmg; 1179. 1180. 				if (cansee(mtmp->mx, mtmp->my)) { 1181. 				   pline("%s is hit by %s!", Monnam(mtmp),  1182. 	    	    	    			doname(otmp2)); 1183. 				   if (mtmp->minvis && !canspotmon(mtmp)) 1184. 					map_invisible(mtmp->mx, mtmp->my); 1185. 				} 1186. 	    	    	    	mdmg = dmgval(otmp2, mtmp) * otmp2->quan; 1187. 				if (helmet) { 1188. 				   if(is_metallic(helmet)) { 1189. 					if (canspotmon(mtmp)) 1190. 					   pline("Fortunately, %s is wearing a hard helmet.", mon_nam(mtmp)); 1191. 					else if (flags.soundok) 1192. 					   You_hear("a clanging sound."); 1193. 					if (mdmg > 2) mdmg = 2; 1194. 				   } else { 1195. 					if (canspotmon(mtmp)) 1196. 					   pline("%s's %s does not protect %s.",  1197. 						Monnam(mtmp), xname(helmet),  1198. 						mhim(mtmp)); 1199. 				   }  1200. 				}  1201. 	    	    	    	mtmp->mhp -= mdmg; 1202. 	   	    	    	if (mtmp->mhp <= 0) 1203. 	   	    	    	    xkilled(mtmp, 1); 1204. 	   	    	    }  1205. 	    	    	    /* Drop the rock/boulder to the floor */ 1206. 	   	    	    if (!flooreffects(otmp2, x, y, "fall")) { 1207. 	   	    	    	place_object(otmp2, x, y); 1208. 	   	    	    	stackobj(otmp2); 1209. 	   	    	    	newsym(x, y);  /* map the rock */ 1210. 	   	    	    }  1211. 	    	    	}  1212. 		    }  1213. 		}  1214. 		/* Attack the player */ 1215. 		if (!sobj->blessed) { 1216. 		   int dmg; 1217. 		   struct obj *otmp2; 1218. 1219. 		    /* Okay, _you_ write this without repeating the code */ 1220. 		   otmp2 = mksobj(confused ? ROCK : BOULDER,  1221. 				FALSE, FALSE); 1222. 		   if (!otmp2) break; 1223. 		   otmp2->quan = confused ? rn1(5,2) : 1; 1224. 		   otmp2->owt = weight(otmp2); 1225. 		   if (!amorphous(youmonst.data) &&  1226. 				!Passes_walls &&  1227. 				!noncorporeal(youmonst.data) &&  1228. 				!unsolid(youmonst.data)) { 1229. 			You("are hit by %s!", doname(otmp2)); 1230. 			dmg = dmgval(otmp2, &youmonst) * otmp2->quan; 1231. 			if (uarmh && !sobj->cursed) { 1232. 			   if(is_metallic(uarmh)) { 1233. 				pline("Fortunately, you are wearing a hard helmet."); 1234. 				if (dmg > 2) dmg = 2; 1235. 			   } else if (flags.verbose) { 1236. 				Your("%s does not protect you.", 1237. 						xname(uarmh)); 1238. 			   }  1239. 			}  1240. 		    } else 1241. 			dmg = 0; 1242. 		   /* Must be before the losehp, for bones files */ 1243. 		   if (!flooreffects(otmp2, u.ux, u.uy, "fall")) { 1244. 			place_object(otmp2, u.ux, u.uy); 1245. 			stackobj(otmp2); 1246. 			newsym(u.ux, u.uy); 1247. 		   }  1248. 		    if (dmg) losehp(dmg, "scroll of earth", KILLED_BY_AN); 1249. 		} 1250. 	    }  1251. 	    break; 1252. 	case SCR_PUNISHMENT: 1253. 		known = TRUE; 1254. 		if(confused || sobj->blessed) { 1255. 			You_feel("guilty."); 1256. 			break; 1257. 		} 1258. 		punish(sobj); 1259. 		break; 1260. 	case SCR_STINKING_CLOUD: { 1261. 	       coord cc; 1262. 1263. 		You("have found a scroll of stinking cloud!"); 1264. 		known = TRUE; 1265. 		pline("Where do you want to center the cloud?"); 1266. 		cc.x = u.ux; 1267. 		cc.y = u.uy; 1268. 		if (getpos(&cc, TRUE, "the desired position") < 0) { 1269. 		   pline(Never_mind); 1270. 		   return 0; 1271. 		} 1272. 		if (!cansee(cc.x, cc.y) || distu(cc.x, cc.y) >= 32) { 1273. 		   You("smell rotten eggs."); 1274. 		   return 0; 1275. 		} 1276. 		(void) create_gas_cloud(cc.x, cc.y, 3+bcsign(sobj),  1277. 						8+4*bcsign(sobj)); 1278. 		break; 1279. 	} 1280. 	default: 1281. 		impossible("What weird effect is this? (%u)", sobj->otyp); 1282. 	} 1283. 	return(0); 1284. } 1285.  1286. static void 1287. wand_explode(obj) 1288. register struct obj *obj; 1289. { 1290.     obj->in_use = TRUE;	/* in case losehp is fatal */ 1291.    Your("%s vibrates violently, and explodes!",xname(obj)); 1292.    nhbell; 1293.    losehp(rnd(2*(u.uhpmax+1)/3), "exploding wand", KILLED_BY_AN); 1294.    useup(obj); 1295.    exercise(A_STR, FALSE); 1296. } 1297.  1298. /*  1299.  * Low-level lit-field update routine. 1300. */  1301. STATIC_PTR void 1302. set_lit(x,y,val) 1303. int x, y; 1304. genericptr_t val; 1305. { 1306. 	if (val) 1307. 	   levl[x][y].lit = 1; 1308. 	else { 1309. 	   levl[x][y].lit = 0; 1310. 	   snuff_light_source(x, y); 1311. 	} 1312. }  1313.  1314. void 1315. litroom(on,obj) 1316. register boolean on; 1317. struct obj *obj; 1318. { 1319. 	char is_lit;	/* value is irrelevant; we use its address 1320. 			  as a `not null' flag for set_lit */ 1321. 1322. 	/* first produce the text (provided you're not blind) */ 1323. 	if(!on) { 1324. 		register struct obj *otmp; 1325. 1326. 		if (!Blind) { 1327. 		   if(u.uswallow) { 1328. 			pline("It seems even darker in here than before."); 1329. 			return; 1330. 		   }  1331. 		    if (uwep && artifact_light(uwep) && uwep->lamplit) 1332. 			pline("Suddenly, the only light left comes from %s!", 1333. 				the(xname(uwep))); 1334. 		   else 1335. 			You("are surrounded by darkness!"); 1336. 		} 1337.  1338. 		/* the magic douses lamps, et al, too */ 1339. 		for(otmp = invent; otmp; otmp = otmp->nobj) 1340. 		   if (otmp->lamplit) 1341. 			(void) snuff_lit(otmp); 1342. 		if (Blind) goto do_it; 1343. 	} else { 1344. 		if (Blind) goto do_it; 1345. 		if(u.uswallow){ 1346. 			if (is_animal(u.ustuck->data)) 1347. 				pline("%s %s is lit.", 1348. 				        s_suffix(Monnam(u.ustuck)),  1349. 					mbodypart(u.ustuck, STOMACH)); 1350. 			else 1351. 				if (is_whirly(u.ustuck->data)) 1352. 					pline("%s shines briefly.", 1353. 					      Monnam(u.ustuck)); 1354. 				else 1355. 					pline("%s glistens.", Monnam(u.ustuck)); 1356. 			return; 1357. 		} 1358. 		pline("A lit field surrounds you!"); 1359. 	} 1360.  1361. do_it: 1362. 	/* No-op in water - can only see the adjacent squares and that's it! */ 1363. 	if (Underwater || Is_waterlevel(&u.uz)) return; 1364. 	/* 1365. 	 *  If we are darkening the room and the hero is punished but not 1366. 	 * blind, then we have to pick up and replace the ball and chain so  1367. * that we don't remember them if they are out of sight. 1368. 	 */ 1369. 	if (Punished && !on && !Blind) 1370. 	   move_bc(1, 0, uball->ox, uball->oy, uchain->ox, uchain->oy); 1371. 1372. #ifdef REINCARNATION 1373. 	if (Is_rogue_level(&u.uz)) { 1374. 	   /* Can't use do_clear_area because MAX_RADIUS is too small */ 1375. 	   /* rogue lighting must light the entire room */ 1376. 	   int rnum = levl[u.ux][u.uy].roomno - ROOMOFFSET; 1377. 	   int rx, ry; 1378. 	   if(rnum >= 0) { 1379. 		for(rx = rooms[rnum].lx-1; rx <= rooms[rnum].hx+1; rx++) 1380. 		   for(ry = rooms[rnum].ly-1; ry <= rooms[rnum].hy+1; ry++) 1381. 			set_lit(rx, ry, 1382. 				(genericptr_t)(on ? &is_lit : (char *)0)); 1383. 		rooms[rnum].rlit = on; 1384. 	   }  1385. 	    /* hallways remain dark on the rogue level */ 1386. 	} else 1387. #endif 1388. 	   do_clear_area(u.ux,u.uy,  1389. 		(obj && obj->oclass==SCROLL_CLASS && obj->blessed) ? 9 : 5,  1390. 		set_lit, (genericptr_t)(on ? &is_lit : (char *)0)); 1391. 1392. 	/*  1393. 	 *  If we are not blind, then force a redraw on all positions in sight 1394. 	 * by temporarily blinding the hero. The vision recalculation will 1395. 	 * correctly update all previously seen positions *and* correctly 1396. 	 * set the waslit bit [could be messed up from above]. 1397. 	 */ 1398. 	if (!Blind) { 1399. 	   vision_recalc(2); 1400. 1401. 	    /* replace ball&chain */ 1402. 	   if (Punished && !on) 1403. 		move_bc(0, 0, uball->ox, uball->oy, uchain->ox, uchain->oy); 1404. 	} 1405.  1406. 	vision_full_recalc = 1;	/* delayed vision recalculation */ 1407. } 1408.  1409. static void 1410. do_class_genocide 1411. { 1412. 	register int i, j, immunecnt, gonecnt, goodcnt, class; 1413. 	char buf[BUFSZ]; 1414. 	boolean gameover = FALSE;	/* true iff killed self */ 1415. 1416. 	for(j=0; ; j++) { 1417. 		if (j >= 5) { 1418. 			pline(thats_enough_tries); 1419. 			return; 1420. 		} 1421. 		do { 1422. 		   getlin("What class of monsters do you wish to genocide?",  1423. 			buf); 1424. 		   (void)mungspaces(buf); 1425. 		} while (buf[0]=='\033' || !buf[0]); 1426. 		/* choosing "none" preserves genocideless conduct */ 1427. 		if (!strcmpi(buf, "none")) return; 1428. 1429. 		if (strlen(buf) == 1) { 1430. 		   if (buf[0] == ILLOBJ_SYM) 1431. 			buf[0] = def_monsyms[S_MIMIC]; 1432. 		   class = def_char_to_monclass(buf[0]); 1433. 		} else { 1434. 		   char buf2[BUFSZ]; 1435. 1436. 		    class = 0; 1437. 		   Strcpy(buf2, makesingular(buf)); 1438. 		   Strcpy(buf, buf2); 1439. 		} 1440. 		immunecnt = gonecnt = goodcnt = 0; 1441. 		for (i = LOW_PM; i < NUMMONS; i++) { 1442. 		   if (class == 0 &&  1443. 			    strstri(monexplain[(int)mons[i].mlet], buf) != 0) 1444. 			class = mons[i].mlet; 1445. 		   if (mons[i].mlet == class) { 1446. 			if (!(mons[i].geno & G_GENO)) immunecnt++; 1447. 			else if(mvitals[i].mvflags & G_GENOD) gonecnt++; 1448. 			else goodcnt++; 1449. 		   }  1450. 		}  1451. 		/*  1452. 		 * TODO[?]: If user's input doesn't match any class 1453. 		 *	   description, check individual species names. 1454. 		 */ 1455. 		if (!goodcnt && class != mons[urole.malenum].mlet &&  1456. 				class != mons[urace.malenum].mlet) { 1457. 			if (gonecnt) 1458. 	pline("All such monsters are already nonexistent."); 1459. 			else if (immunecnt || 1460. 				(buf[0] == DEF_INVISIBLE && buf[1] == '\0')) 1461. 	You("aren't permitted to genocide such monsters."); 1462. 			else 1463. #ifdef WIZARD	/* to aid in topology testing; remove pesky monsters */ 1464. 			 if (wizard && buf[0] == '*') { 1465. 			   register struct monst *mtmp, *mtmp2; 1466. 1467. 			    gonecnt = 0; 1468. 			   for (mtmp = fmon; mtmp; mtmp = mtmp2) { 1469. 				mtmp2 = mtmp->nmon; 1470. 			   	if (DEADMONSTER(mtmp)) continue; 1471. 				mongone(mtmp); 1472. 				gonecnt++; 1473. 			   }  1474. 	pline("Eliminated %d monster%s.", gonecnt, plur(gonecnt)); 1475. 			   return; 1476. 			} else 1477. #endif 1478. 	pline("That symbol does not represent any monster."); 1479. 			continue; 1480. 		} 1481.  1482. 		for (i = LOW_PM; i < NUMMONS; i++) { 1483. 		   if(mons[i].mlet == class) { 1484. 			char nam[BUFSZ]; 1485. 1486. 			Strcpy(nam, makeplural(mons[i].mname)); 1487. 			/* Although "genus" is Latin for race, the hero benefits 1488. 			 * from both race and role; thus genocide affects either. 1489. 			 */ 1490. 			if (Your_Own_Role(i) || Your_Own_Race(i) ||  1491. 				((mons[i].geno & G_GENO) 1492. 				&& !(mvitals[i].mvflags & G_GENOD))) { 1493. 			/* This check must be first since player monsters might 1494. 			 * have G_GENOD or !G_GENO. 1495. 			 */ 1496. 			    mvitals[i].mvflags |= (G_GENOD|G_NOCORPSE); 1497. 			   reset_rndmonst(i); 1498. 			   kill_genocided_monsters; 1499. 			   update_inventory;		/* eggs & tins */ 1500. 			   pline("Wiped out all %s.", nam); 1501. 			   if (Upolyd && i == u.umonnum) { 1502. 				if (Unchanging) done(GENOCIDED); 1503. 				rehumanize; 1504. 			   }  1505. 			    /* Self-genocide if it matches either your race or role */ 1506. 			   /* Assumption: male and female forms share the same letter */ 1507. 			   if (i == urole.malenum || i == urace.malenum) { 1508. 				u.uhp = -1; 1509. 				killer_format = KILLED_BY_AN; 1510. 				killer = "scroll of genocide"; 1511. 				if (Upolyd) 1512. 				   You_feel("dead inside."); 1513. 				else 1514. 				   gameover = TRUE; 1515. 			   }  1516. 			} else if (mvitals[i].mvflags & G_GENOD) { 1517. 			   if (!gameover) 1518. 				pline("All %s are already nonexistent.", nam); 1519. 			} else if (!gameover) { 1520. 			 /* suppress feedback about quest beings except 1521. 			    for those applicable to our own role */ 1522. 			 if ((mons[i].msound != MS_LEADER || 1523. 			      quest_info(MS_LEADER) == i)  1524. 			   && (mons[i].msound != MS_NEMESIS || 1525. 			      quest_info(MS_NEMESIS) == i)  1526. 			   && (mons[i].msound != MS_GUARDIAN || 1527. 			      quest_info(MS_GUARDIAN) == i)  1528. 			/* non-leader/nemesis/guardian role-specific monster */  1529. 			   && (i != PM_NINJA ||		/* nuisance */ 1530. 			      Role_if(PM_SAMURAI))) { 1531. 				boolean named, uniq; 1532. 1533. 				named = type_is_pname(&mons[i]) ? TRUE : FALSE; 1534. 				uniq = (mons[i].geno & G_UNIQ) ? TRUE : FALSE; 1535. 				/* one special case */ 1536. 				if (i == PM_HIGH_PRIEST) uniq = FALSE; 1537. 1538. 				You("aren't permitted to genocide %s%s.",  1539. 				    (uniq && !named) ? "the " : "",  1540. 				    (uniq || named) ? mons[i].mname : nam); 1541. 			   }  1542. 			}  1543. 		    }  1544. 		}  1545. 		if (gameover) done(GENOCIDED); 1546. 		return; 1547. 	} 1548. }  1549.  1550. #define REALLY 1 1551. #define PLAYER 2 1552. #define ONTHRONE 4 1553. void 1554. do_genocide(how) 1555. int how; 1556. /* 0 = no genocide; create monsters (cursed scroll) */ 1557. /* 1 = normal genocide */ 1558. /* 3 = forced genocide of player */ 1559. /* 5 (4 | 1) = normal genocide from throne */ 1560. { 1561. 	char buf[BUFSZ]; 1562. 	register int	i, killplayer = 0; 1563. 	register int mndx; 1564. 	register struct permonst *ptr; 1565. 	const char *which; 1566. 1567. 	if (how & PLAYER) { 1568. 		mndx = u.umonster;	/* non-polymorphed mon num */ 1569. 		ptr = &mons[mndx]; 1570. 		Strcpy(buf, ptr->mname); 1571. 		killplayer++; 1572. 	} else { 1573. 	   for(i = 0; ; i++) { 1574. 		if(i >= 5) { 1575. 		   pline(thats_enough_tries); 1576. 		   return; 1577. 		} 1578. 		getlin("What monster do you want to genocide? [type the name]",  1579. 			buf); 1580. 		(void)mungspaces(buf); 1581. 		/* choosing "none" preserves genocideless conduct */ 1582. 		if (!strcmpi(buf, "none")) { 1583. 		   /* ... but no free pass if cursed */ 1584. 		   if (!(how & REALLY)) { 1585. 			ptr = rndmonst; 1586. 			if (!ptr) return; /* no message, like normal case */ 1587. 			mndx = monsndx(ptr); 1588. 			break;		/* remaining checks don't apply */ 1589. 		   } else return; 1590. 		} 1591.  1592. 		mndx = name_to_mon(buf); 1593. 		if (mndx == NON_PM || (mvitals[mndx].mvflags & G_GENOD)) { 1594. 			pline("Such creatures %s exist in this world.", 1595. 			      (mndx == NON_PM) ? "do not" : "no longer"); 1596. 			continue; 1597. 		} 1598. 		ptr = &mons[mndx]; 1599. 		/* Although "genus" is Latin for race, the hero benefits 1600. 		 * from both race and role; thus genocide affects either. 1601. 		 */ 1602. 		if (Your_Own_Role(mndx) || Your_Own_Race(mndx)) { 1603. 			killplayer++; 1604. 			break; 1605. 		} 1606. 		if (is_human(ptr)) adjalign(-sgn(u.ualign.type)); 1607. 		if (is_demon(ptr)) adjalign(sgn(u.ualign.type)); 1608. 1609. 		if(!(ptr->geno & G_GENO)) { 1610. 			if(flags.soundok) { 1611. 	/* fixme: unconditional "caverns" will be silly in some circumstances */ 1612. 			   if(flags.verbose) 1613. 			pline("A thunderous voice booms through the caverns:"); 1614. 			   verbalize("No, mortal!  That will not be done."); 1615. 			} 1616. 			continue; 1617. 		} 1618. 		/* KMH -- Unchanging prevents rehumanization */ 1619. 		if (Unchanging && ptr == youmonst.data) 1620. 		   killplayer++; 1621. 		break; 1622. 	   }  1623. 	}  1624.  1625. 	which = "all "; 1626. 	if (Hallucination) { 1627. 	   if (Upolyd) 1628. 		Strcpy(buf,youmonst.data->mname); 1629. 	   else { 1630. 		Strcpy(buf, (flags.female && urole.name.f) ? 1631. 				urole.name.f : urole.name.m); 1632. 		buf[0] = lowc(buf[0]); 1633. 	   }  1634. 	} else { 1635. 	   Strcpy(buf, ptr->mname); /* make sure we have standard singular */ 1636. 	   if ((ptr->geno & G_UNIQ) && ptr != &mons[PM_HIGH_PRIEST]) 1637. 		which = !type_is_pname(ptr) ? "the " : ""; 1638. 	} 1639. 	if (how & REALLY) { 1640. 	   /* setting no-corpse affects wishing and random tin generation */ 1641. 	   mvitals[mndx].mvflags |= (G_GENOD | G_NOCORPSE); 1642. 	   pline("Wiped out %s%s.", which,  1643. 		  (*which != 'a') ? buf : makeplural(buf)); 1644. 1645. 	    if (killplayer) { 1646. 		/* might need to wipe out dual role */ 1647. 		if (urole.femalenum != NON_PM && mndx == urole.malenum) 1648. 		   mvitals[urole.femalenum].mvflags |= (G_GENOD | G_NOCORPSE); 1649. 		if (urole.femalenum != NON_PM && mndx == urole.femalenum) 1650. 		   mvitals[urole.malenum].mvflags |= (G_GENOD | G_NOCORPSE); 1651. 		if (urace.femalenum != NON_PM && mndx == urace.malenum) 1652. 		   mvitals[urace.femalenum].mvflags |= (G_GENOD | G_NOCORPSE); 1653. 		if (urace.femalenum != NON_PM && mndx == urace.femalenum) 1654. 		   mvitals[urace.malenum].mvflags |= (G_GENOD | G_NOCORPSE); 1655. 1656. 		u.uhp = -1; 1657. 		if (how & PLAYER) { 1658. 		   killer_format = KILLED_BY; 1659. 		   killer = "genocidal confusion"; 1660. 		} else if (how & ONTHRONE) { 1661. 		   /* player selected while on a throne */ 1662. 		   killer_format = KILLED_BY_AN; 1663. 		   killer = "imperious order"; 1664. 		} else { /* selected player deliberately, not confused */ 1665. 		   killer_format = KILLED_BY_AN; 1666. 		   killer = "scroll of genocide"; 1667. 		} 1668.  1669. 	/* Polymorphed characters will die as soon as they're rehumanized. */ 1670. 	/* KMH -- Unchanging prevents rehumanization */ 1671. 		if (Upolyd && ptr != youmonst.data) { 1672. 			delayed_killer = killer; 1673. 			killer = 0; 1674. 			You_feel("dead inside."); 1675. 		} else 1676. 			done(GENOCIDED); 1677. 	   } else if (ptr == youmonst.data) { 1678. 		rehumanize; 1679. 	   }  1680. 	    reset_rndmonst(mndx); 1681. 	   kill_genocided_monsters; 1682. 	   update_inventory;	/* in case identified eggs were affected */ 1683. 	} else { 1684. 	   int cnt = 0; 1685. 1686. 	    if (!(mons[mndx].geno & G_UNIQ) &&  1687. 		    !(mvitals[mndx].mvflags & (G_GENOD | G_EXTINCT))) 1688. 		for (i = rn1(3, 4); i > 0; i--) { 1689. 		   if (!makemon(ptr, u.ux, u.uy, NO_MINVENT)) 1690. 			break;	/* couldn't make one */ 1691. 		   ++cnt; 1692. 		   if (mvitals[mndx].mvflags & G_EXTINCT) 1693. 			break;	/* just made last one */ 1694. 		} 1695. 	    if (cnt) 1696. 		pline("Sent in some %s.", makeplural(buf)); 1697. 	   else 1698. 		pline(nothing_happens); 1699. 	} 1700. }  1701.  1702. void 1703. punish(sobj) 1704. register struct obj	*sobj; 1705. { 1706. 	/* KMH -- Punishment is still okay when you are riding */ 1707. 	You("are being punished for your misbehavior!"); 1708. 	if(Punished){ 1709. 		Your("iron ball gets heavier."); 1710. 		uball->owt += 160 * (1 + sobj->cursed); 1711. 		return; 1712. 	} 1713. 	if (amorphous(youmonst.data) || is_whirly(youmonst.data) || unsolid(youmonst.data)) { 1714. 		pline("A ball and chain appears, then falls away."); 1715. 		dropy(mkobj(BALL_CLASS, TRUE)); 1716. 		return; 1717. 	} 1718. 	setworn(mkobj(CHAIN_CLASS, TRUE), W_CHAIN); 1719. 	setworn(mkobj(BALL_CLASS, TRUE), W_BALL); 1720. 	uball->spe = 1;		/* special ball (see save) */ 1721. 1722. 	/*  1723. 	 *  Place ball & chain if not swallowed. If swallowed, the ball & 1724. 	 * chain variables will be set at the next call to placebc. 1725. 	 */ 1726. 	if (!u.uswallow) { 1727. 	   placebc; 1728. 	   if (Blind) set_bc(1);	/* set up ball and chain variables */ 1729. 	   newsym(u.ux,u.uy);		/* see ball&chain if can't see self */ 1730. 	} 1731. }  1732.  1733. void 1734. unpunish 1735. {	   /* remove the ball and chain */ 1736. 	struct obj *savechain = uchain; 1737. 1738. 	obj_extract_self(uchain); 1739. 	newsym(uchain->ox,uchain->oy); 1740. 	setworn((struct obj *)0, W_CHAIN); 1741. 	dealloc_obj(savechain); 1742. 	uball->spe = 0; 1743. 	setworn((struct obj *)0, W_BALL); 1744. } 1745.  1746. /* some creatures have special data structures that only make sense in their 1747. * normal locations -- if the player tries to create one elsewhere, or to revive 1748. * one, the disoriented creature becomes a zombie 1749. */  1750. boolean 1751. cant_create(mtype, revival) 1752. int *mtype; 1753. boolean revival; 1754. { 1755.  1756. 	/* SHOPKEEPERS can be revived now */ 1757. 	if (*mtype==PM_GUARD || (*mtype==PM_SHOPKEEPER && !revival) 1758. 	     || *mtype==PM_ALIGNED_PRIEST || *mtype==PM_ANGEL) { 1759. 		*mtype = PM_HUMAN_ZOMBIE; 1760. 		return TRUE; 1761. 	} else if (*mtype==PM_LONG_WORM_TAIL) {	/* for create_particular */ 1762. 		*mtype = PM_LONG_WORM; 1763. 		return TRUE; 1764. 	} 1765. 	return FALSE; 1766. } 1767.  1768. #ifdef WIZARD 1769. boolean 1770. create_particular 1771. { 1772. 	char buf[BUFSZ], monclass = MAXMCLASSES; 1773. 	int which = PM_PLAYERMON, tries = 0, i; 1774. struct permonst *whichpm = 0; 1775. 	struct monst *mtmp; 1776. 	boolean madeany = FALSE; 1777. 	boolean maketame = FALSE; 1778. 1779. 	do { 1780. 	   getlin("Create what kind of monster? [type the name or symbol]",  1781. 		   buf); 1782. 	   if (buf[0] == '\033') return FALSE; 1783. 	   (void)mungspaces(buf); 1784. 	   if (strlen(buf) == 1) { 1785. 		monclass = def_char_to_monclass(buf[0]); 1786. 		if (monclass == MAXMCLASSES) 1787. 		   pline("I've never heard of such monsters."); 1788. 		else break; 1789. 	   } else { 1790. 		if (!strncmpi(buf, "tame ", 5)) { 1791. 		   which = name_to_mon(buf+5); 1792. 		   maketame = TRUE; 1793. 		} else { 1794. 		   which = name_to_mon(buf); 1795. 		   maketame = FALSE; 1796. 		} 1797. 		if (which < LOW_PM) pline("I've never heard of such monsters."); 1798. 		else { 1799. 		   whichpm = &mons[which]; 1800. 		   break; 1801. 		} 1802. 	    }  1803. 	} while (++tries < 5); 1804. 	if (tries == 5) pline(thats_enough_tries); 1805. 	else { 1806. 	   (void) cant_create(&which, FALSE); 1807. 	   for (i = 0; i <= multi; i++) { 1808. 		if (monclass != MAXMCLASSES) 1809. 		   whichpm = mkclass(monclass, 0); 1810. 		if (maketame) { 1811. 		   mtmp = makemon(whichpm, u.ux, u.uy, MM_EDOG); 1812. 		   if (mtmp) { 1813. 			initedog(mtmp); 1814. 			set_malign(mtmp); 1815. 		   }  1816. 		} else 1817. 		   mtmp = makemon(whichpm, u.ux, u.uy, NO_MM_FLAGS); 1818. 		if (mtmp) madeany = TRUE; 1819. 	   }  1820. 	}  1821. 	return madeany; 1822. } 1823. #endif /* WIZARD */ 1824. 1825. #endif /* OVLB */ 1826. 1827. /*read.c*/