Source:NetHack 3.4.0/do wear.c

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

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

1.   /*	SCCS Id: @(#)do_wear.c	3.4	2002/02/23	*/ 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.   #ifndef OVLB 8.    9.    STATIC_DCL long takeoff_mask, taking_off; 10.   11.   #else /* OVLB */ 12.   13.   STATIC_OVL NEARDATA long takeoff_mask = 0L, taking_off = 0L; 14.   15.   static NEARDATA int todelay; 16.  static boolean cancelled_don = FALSE; 17.   18.   static NEARDATA const char see_yourself[] = "see yourself"; 19.  static NEARDATA const char unknown_type[] = "Unknown type of %s (%d)"; 20.  static NEARDATA const char *c_armor  = "armor", 21.  			   *c_suit   = "suit", 22.  #ifdef TOURIST 23.  			   *c_shirt  = "shirt", 24.  #endif 25.  			   *c_cloak  = "cloak", 26.  			   *c_gloves = "gloves", 27.  			   *c_boots  = "boots", 28.  			   *c_helmet = "helmet", 29.  			   *c_shield = "shield", 30.  			   *c_weapon = "weapon", 31.  			   *c_sword  = "sword", 32.  			   *c_axe    = "axe", 33.  			   *c_that_  = "that"; 34.   35.   static NEARDATA const long takeoff_order[] = { WORN_BLINDF, W_WEP, 36.  	WORN_SHIELD, WORN_GLOVES, LEFT_RING, RIGHT_RING, WORN_CLOAK, 37.  	WORN_HELMET, WORN_AMUL, WORN_ARMOR, 38.  #ifdef TOURIST 39.  	WORN_SHIRT, 40.  #endif 41.  	WORN_BOOTS, W_SWAPWEP, W_QUIVER, 0L }; 42.   43.   STATIC_DCL void FDECL(on_msg, (struct obj *)); 44.  STATIC_PTR int NDECL(Armor_on); 45.  STATIC_PTR int NDECL(Boots_on); 46.  STATIC_DCL int NDECL(Cloak_on); 47.  STATIC_PTR int NDECL(Helmet_on); 48.  STATIC_PTR int NDECL(Gloves_on); 49.  STATIC_DCL void NDECL(Amulet_on); 50.  STATIC_DCL void FDECL(Ring_off_or_gone, (struct obj *, BOOLEAN_P)); 51.  STATIC_PTR int FDECL(select_off, (struct obj *)); 52.  STATIC_DCL struct obj *NDECL(do_takeoff); 53.  STATIC_PTR int NDECL(take_off); 54.  STATIC_DCL int FDECL(menu_remarm, (int)); 55.  STATIC_DCL void FDECL(already_wearing, (const char*)); 56.  STATIC_DCL void FDECL(already_wearing2, (const char*, const char*)); 57.   58.   void 59.  off_msg(otmp) 60.  register struct obj *otmp; 61.  {  62.   	if(flags.verbose) 63.  	    You("were wearing %s.", doname(otmp)); 64.  }  65.    66.   /* for items that involve no delay */ 67.  STATIC_OVL void 68.  on_msg(otmp) 69.  register struct obj *otmp; 70.  {  71.   	if (flags.verbose) { 72.  	    char how[BUFSZ]; 73.   74.   	    how[0] = '\0'; 75.  	    if (otmp->otyp == TOWEL) 76.  		Sprintf(how, " around your %s", body_part(HEAD)); 77.  	    You("are now wearing %s%s.",  78.   		obj_is_pname(otmp) ? the(xname(otmp)) : an(xname(otmp)),  79.   		how); 80.  	}  81.   }  82.    83.   /*  84.    * The Type_on functions should be called *after* setworn. 85.   * The Type_off functions call setworn themselves. 86.   */  87.    88.   STATIC_PTR 89.  int 90.  Boots_on 91.  {  92.       long oldprop = 93.  	u.uprops[objects[uarmf->otyp].oc_oprop].extrinsic & ~WORN_BOOTS; 94.   95.       switch(uarmf->otyp) { 96.  	case LOW_BOOTS: 97.  	case IRON_SHOES: 98.  	case HIGH_BOOTS: 99.  	case JUMPING_BOOTS: 100. 	case KICKING_BOOTS: 101. 		break; 102. 	case WATER_WALKING_BOOTS: 103. 		if (u.uinwater) spoteffects(TRUE); 104. 		break; 105. 	case SPEED_BOOTS: 106. 		/* Speed boots are still better than intrinsic speed, */ 107. 		/* though not better than potion speed */ 108. 		if (!oldprop && !(HFast & TIMEOUT)) { 109. 			makeknown(uarmf->otyp); 110. 			You_feel("yourself speed up%s.",  111.  				(oldprop || HFast) ? " a bit more" : ""); 112. 		}  113.  		break; 114. 	case ELVEN_BOOTS: 115. 		if (!oldprop && !HStealth && !BStealth) { 116. 			makeknown(uarmf->otyp); 117. 			You("walk very quietly."); 118. 		}  119.  		break; 120. 	case FUMBLE_BOOTS: 121. 		if (!oldprop && !(HFumbling & ~TIMEOUT)) 122. 			incr_itimeout(&HFumbling, rnd(20)); 123. 		break; 124. 	case LEVITATION_BOOTS: 125. 		if (!oldprop && !HLevitation) { 126. 			makeknown(uarmf->otyp); 127. 			float_up; 128. 			spoteffects(FALSE); 129. 		}  130.  		break; 131. 	default: impossible(unknown_type, c_boots, uarmf->otyp); 132.     }  133.      return 0; 134. }  135.   136.  int 137. Boots_off 138. {  139.      int otyp = uarmf->otyp; 140.     long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_BOOTS; 141.  142.   143.  	/* For levitation, float_down returns if Levitation, so we  144. * must do a setworn _before_ the levitation case. 145. 	 */  146.      setworn((struct obj *)0, W_ARMF); 147.     switch (otyp) { 148. 	case SPEED_BOOTS: 149. 		if (!Very_fast && !cancelled_don) { 150. 			makeknown(otyp); 151. 			You_feel("yourself slow down%s.",  152.  				Fast ? " a bit" : ""); 153. 		}  154.  		break; 155. 	case WATER_WALKING_BOOTS: 156. 		if (is_pool(u.ux,u.uy) && !Levitation && !Flying &&  157.  		    !is_clinger(youmonst.data) && !cancelled_don) { 158. 			makeknown(otyp); 159. 			/* make boots known in case you survive the drowning */ 160. 			spoteffects(TRUE); 161. 		}  162.  		break; 163. 	case ELVEN_BOOTS: 164. 		if (!oldprop && !HStealth && !BStealth && !cancelled_don) { 165. 			makeknown(otyp); 166. 			You("sure are noisy."); 167. 		}  168.  		break; 169. 	case FUMBLE_BOOTS: 170. 		if (!oldprop && !(HFumbling & ~TIMEOUT)) 171. 			HFumbling = EFumbling = 0; 172. 		break; 173. 	case LEVITATION_BOOTS: 174. 		if (!oldprop && !HLevitation && !cancelled_don) { 175. 			(void) float_down(0L, 0L); 176. 			makeknown(otyp); 177. 		}  178.  		break; 179. 	case LOW_BOOTS: 180. 	case IRON_SHOES: 181. 	case HIGH_BOOTS: 182. 	case JUMPING_BOOTS: 183. 	case KICKING_BOOTS: 184. 		break; 185. 	default: impossible(unknown_type, c_boots, otyp); 186.     }  187.      cancelled_don = FALSE; 188.     return 0; 189. }  190.   191.  STATIC_OVL int 192. Cloak_on 193. {  194.      long oldprop = 195. 	u.uprops[objects[uarmc->otyp].oc_oprop].extrinsic & ~WORN_CLOAK; 196.  197.      switch(uarmc->otyp) { 198. 	case ELVEN_CLOAK: 199. 	case CLOAK_OF_PROTECTION: 200. 	case CLOAK_OF_DISPLACEMENT: 201. 		makeknown(uarmc->otyp); 202. 		break; 203. 	case ORCISH_CLOAK: 204. 	case DWARVISH_CLOAK: 205. 	case CLOAK_OF_MAGIC_RESISTANCE: 206. 	case ROBE: 207. 	case LEATHER_CLOAK: 208. 		break; 209. 	case MUMMY_WRAPPING: 210. 		/* Note: it's already being worn, so we have to cheat here. */ 211.  		if ((HInvis || EInvis || pm_invisible(youmonst.data)) && !Blind) { 212. 		    newsym(u.ux,u.uy); 213. 		    You("can %s!",  214.  			See_invisible ? "no longer see through yourself"  215.  			: see_yourself); 216. 		}  217.  		break; 218. 	case CLOAK_OF_INVISIBILITY: 219. 		/* since cloak of invisibility was worn, we know mummy wrapping 220. 		   wasn't, so no need to check `oldprop' against blocked */ 221. 		if (!oldprop && !HInvis && !Blind) { 222. 		    makeknown(uarmc->otyp); 223. 		    newsym(u.ux,u.uy); 224. 		    pline("Suddenly you can%s yourself.",  225.  			See_invisible ? " see through" : "not see"); 226. 		}  227.  		break; 228. 	case OILSKIN_CLOAK: 229. 		pline("%s very tightly.", Tobjnam(uarmc, "fit")); 230. 		break; 231. 	/* Alchemy smock gives poison _and_ acid resistance */ 232. 	case ALCHEMY_SMOCK: 233. 		EAcid_resistance |= WORN_CLOAK; 234.   		break; 235. 	default: impossible(unknown_type, c_cloak, uarmc->otyp); 236.     }  237.      return 0; 238. }  239.   240.  int 241. Cloak_off 242. {  243.      int otyp = uarmc->otyp; 244.     long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_CLOAK; 245.  246.   247.  	/* For mummy wrapping, taking it off first resets `Invisible'. */ 248.      setworn((struct obj *)0, W_ARMC); 249.     switch (otyp) { 250. 	case ELVEN_CLOAK: 251. 	case ORCISH_CLOAK: 252. 	case DWARVISH_CLOAK: 253. 	case CLOAK_OF_PROTECTION: 254. 	case CLOAK_OF_MAGIC_RESISTANCE: 255. 	case CLOAK_OF_DISPLACEMENT: 256. 	case OILSKIN_CLOAK: 257. 	case ROBE: 258. 	case LEATHER_CLOAK: 259. 		break; 260. 	case MUMMY_WRAPPING: 261. 		if (Invis && !Blind) { 262. 		    newsym(u.ux,u.uy); 263. 		    You("can %s.",  264.  			See_invisible ? "see through yourself"  265.  			: "no longer see yourself"); 266. 		}  267.  		break; 268. 	case CLOAK_OF_INVISIBILITY: 269. 		if (!oldprop && !HInvis && !Blind) { 270. 		    makeknown(CLOAK_OF_INVISIBILITY); 271. 		    newsym(u.ux,u.uy); 272. 		    pline("Suddenly you can %s.",  273.  			See_invisible ? "no longer see through yourself"  274.  			: see_yourself); 275. 		}  276.  		break; 277. 	/* Alchemy smock gives poison _and_ acid resistance */ 278. 	case ALCHEMY_SMOCK: 279. 		EAcid_resistance &= ~WORN_CLOAK; 280.   		break; 281. 	default: impossible(unknown_type, c_cloak, otyp); 282.     }  283.      return 0; 284. }  285.   286.  STATIC_PTR 287. int 288. Helmet_on 289. {  290.      switch(uarmh->otyp) { 291. 	case FEDORA: 292. 	case HELMET: 293. 	case DENTED_POT: 294. 	case ELVEN_LEATHER_HELM: 295. 	case DWARVISH_IRON_HELM: 296. 	case ORCISH_HELM: 297. 	case HELM_OF_TELEPATHY: 298. 		break; 299. 	case HELM_OF_BRILLIANCE: 300. 		adj_abon(uarmh, uarmh->spe); 301. 		break; 302. 	case CORNUTHAUM: 303. 		/* people think marked wizards know what they're talking 304. 		 * about, but it takes trained arrogance to pull it off, 305. 		 * and the actual enchantment of the hat is irrelevant. 306. 		 */  307.  		ABON(A_CHA) += (Role_if(PM_WIZARD) ? 1 : -1); 308. 		flags.botl = 1; 309. 		makeknown(uarmh->otyp); 310. 		break; 311. 	case HELM_OF_OPPOSITE_ALIGNMENT: 312. 		if (u.ualign.type == A_NEUTRAL) 313. 		    u.ualign.type = rn2(2) ? A_CHAOTIC : A_LAWFUL; 314. 		else u.ualign.type = -(u.ualign.type); 315. 		u.ublessed = 0; /* lose your god's protection */ 316. 	     /* makeknown(uarmh->otyp);   -- moved below, after xname */ 317. 		/*FALLTHRU*/ 318. 	case DUNCE_CAP: 319. 		if (!uarmh->cursed) { 320. 		    if (Blind) 321. 			pline("%s for a moment.", Tobjnam(uarmh, "vibrate")); 322. 		    else 323. 			pline("%s %s for a moment.",  324.  			      Tobjnam(uarmh, "glow"), hcolor(Black)); 325. 		    curse(uarmh); 326. 		}  327.  		flags.botl = 1;		/* reveal new alignment or INT & WIS */ 328. 		if (Hallucination) { 329. 		    pline("My brain hurts!"); /* Monty Python's Flying Circus */ 330. 		} else if (uarmh->otyp == DUNCE_CAP) { 331. 		    You_feel("%s.",	/* track INT change; ignore WIS */  332.  		  ACURR(A_INT) <= (ABASE(A_INT) + ABON(A_INT) + ATEMP(A_INT)) ?  333.  			     "like sitting in a corner" : "giddy"); 334. 		} else { 335. 		    Your("mind oscillates briefly."); 336. 		    makeknown(HELM_OF_OPPOSITE_ALIGNMENT); 337. 		}  338.  		break; 339. 	default: impossible(unknown_type, c_helmet, uarmh->otyp); 340.     }  341.      return 0; 342. }  343.   344.  int 345. Helmet_off 346. {  347.      switch(uarmh->otyp) { 348. 	case FEDORA: 349. 	case HELMET: 350. 	case DENTED_POT: 351. 	case ELVEN_LEATHER_HELM: 352. 	case DWARVISH_IRON_HELM: 353. 	case ORCISH_HELM: 354. 	    break; 355. 	case DUNCE_CAP: 356. 	    flags.botl = 1; 357. 	    break; 358. 	case CORNUTHAUM: 359. 	    if (!cancelled_don) { 360. 		ABON(A_CHA) += (Role_if(PM_WIZARD) ? -1 : 1); 361. 		flags.botl = 1; 362. 	    }  363.  	    break; 364. 	case HELM_OF_TELEPATHY: 365. 	    /* need to update ability before calling see_monsters */ 366. 	    setworn((struct obj *)0, W_ARMH); 367. 	    see_monsters; 368. 	    return 0; 369. 	case HELM_OF_BRILLIANCE: 370. 	    if (!cancelled_don) adj_abon(uarmh, -uarmh->spe); 371. 	    break; 372. 	case HELM_OF_OPPOSITE_ALIGNMENT: 373. 	    u.ualign.type = u.ualignbase[A_CURRENT]; 374. 	    u.ublessed = 0; /* lose the other god's protection */ 375. 	    flags.botl = 1; 376. 	    break; 377. 	default: impossible(unknown_type, c_helmet, uarmh->otyp); 378.     }  379.      setworn((struct obj *)0, W_ARMH); 380.     cancelled_don = FALSE; 381.     return 0; 382. }  383.   384.  STATIC_PTR 385. int 386. Gloves_on 387. {  388.      long oldprop = 389. 	u.uprops[objects[uarmg->otyp].oc_oprop].extrinsic & ~WORN_GLOVES; 390.  391.      switch(uarmg->otyp) { 392. 	case LEATHER_GLOVES: 393. 		break; 394. 	case GAUNTLETS_OF_FUMBLING: 395. 		if (!oldprop && !(HFumbling & ~TIMEOUT)) 396. 			incr_itimeout(&HFumbling, rnd(20)); 397. 		break; 398. 	case GAUNTLETS_OF_POWER: 399. 		makeknown(uarmg->otyp); 400. 		flags.botl = 1; /* taken care of in attrib.c */ 401. 		break; 402. 	case GAUNTLETS_OF_DEXTERITY: 403. 		adj_abon(uarmg, uarmg->spe); 404. 		break; 405. 	default: impossible(unknown_type, c_gloves, uarmg->otyp); 406.     }  407.      return 0; 408. }  409.   410.  int 411. Gloves_off 412. {  413.      long oldprop = 414. 	u.uprops[objects[uarmg->otyp].oc_oprop].extrinsic & ~WORN_GLOVES; 415.  416.      switch(uarmg->otyp) { 417. 	case LEATHER_GLOVES: 418. 	    break; 419. 	case GAUNTLETS_OF_FUMBLING: 420. 	    if (!oldprop && !(HFumbling & ~TIMEOUT)) 421. 		HFumbling = EFumbling = 0; 422. 	    break; 423. 	case GAUNTLETS_OF_POWER: 424. 	    makeknown(uarmg->otyp); 425. 	    flags.botl = 1; /* taken care of in attrib.c */ 426. 	    break; 427. 	case GAUNTLETS_OF_DEXTERITY: 428. 	    if (!cancelled_don) adj_abon(uarmg, -uarmg->spe); 429. 	    break; 430. 	default: impossible(unknown_type, c_gloves, uarmg->otyp); 431.     }  432.      setworn((struct obj *)0, W_ARMG); 433.     cancelled_don = FALSE; 434.  435.      /* Prevent wielding cockatrice when not wearing gloves */ 436.     if (uwep && uwep->otyp == CORPSE &&  437.  		touch_petrifies(&mons[uwep->corpsenm])) { 438. 	char kbuf[BUFSZ]; 439.  440.  	You("wield the %s in your bare %s.",  441.  	    corpse_xname(uwep, TRUE), makeplural(body_part(HAND))); 442. 	Strcpy(kbuf, an(corpse_xname(uwep, TRUE))); 443. 	instapetrify(kbuf); 444. 	uwepgone;  /* life-saved still doesn't allow touching cockatrice */ 445.     }  446.   447.      /* KMH -- ...or your secondary weapon when you're wielding it */ 448.     if (u.twoweap && uswapwep && uswapwep->otyp == CORPSE &&  449.  	touch_petrifies(&mons[uswapwep->corpsenm])) { 450. 	char kbuf[BUFSZ]; 451.  452.  	You("wield the %s in your bare %s.",  453.  	    corpse_xname(uswapwep, TRUE), body_part(HAND)); 454.  455.  	Strcpy(kbuf, an(corpse_xname(uswapwep, TRUE))); 456. 	instapetrify(kbuf); 457. 	uswapwepgone;	/* lifesaved still doesn't allow touching cockatrice */ 458.     }  459.   460.      return 0; 461. }  462.   463.  /*  464.  STATIC_OVL int 465. Shield_on 466. {  467.      switch(uarms->otyp) { 468. 	case SMALL_SHIELD: 469. 	case ELVEN_SHIELD: 470. 	case URUK_HAI_SHIELD: 471. 	case ORCISH_SHIELD: 472. 	case DWARVISH_ROUNDSHIELD: 473. 	case LARGE_SHIELD: 474. 	case SHIELD_OF_REFLECTION: 475. 		break; 476. 	default: impossible(unknown_type, c_shield, uarms->otyp); 477.     }  478.      return 0; 479. }  480.  */  481.   482.  int 483. Shield_off 484. {  485.  /*  486.      switch(uarms->otyp) { 487. 	case SMALL_SHIELD: 488. 	case ELVEN_SHIELD: 489. 	case URUK_HAI_SHIELD: 490. 	case ORCISH_SHIELD: 491. 	case DWARVISH_ROUNDSHIELD: 492. 	case LARGE_SHIELD: 493. 	case SHIELD_OF_REFLECTION: 494. 		break; 495. 	default: impossible(unknown_type, c_shield, uarms->otyp); 496.     }  497.  */  498.      setworn((struct obj *)0, W_ARMS); 499.     return 0; 500. }  501.   502.  /* This must be done in worn.c, because one of the possible intrinsics conferred 503.  * is fire resistance, and we have to immediately set HFire_resistance in worn.c  504. * since worn.c will check it before returning. 505.  */  506.  STATIC_PTR 507. int 508. Armor_on 509. {  510.      return 0; 511. }  512.   513.  int 514. Armor_off 515. {  516.      setworn((struct obj *)0, W_ARM); 517.     cancelled_don = FALSE; 518.     return 0; 519. }  520.   521.  /* The gone functions differ from the off functions in that if you die from 522.  * taking it off and have life saving, you still die. 523.  */  524.  int 525. Armor_gone 526. {  527.      setnotworn(uarm); 528.     cancelled_don = FALSE; 529.     return 0; 530. }  531.   532.  STATIC_OVL void 533. Amulet_on 534. {  535.      switch(uamul->otyp) { 536. 	case AMULET_OF_ESP: 537. 	case AMULET_OF_LIFE_SAVING: 538. 	case AMULET_VERSUS_POISON: 539. 	case AMULET_OF_REFLECTION: 540. 	case AMULET_OF_MAGICAL_BREATHING: 541. 	case FAKE_AMULET_OF_YENDOR: 542. 		break; 543. 	case AMULET_OF_UNCHANGING: 544. 		if (Slimed) { 545. 		    Slimed = 0; 546. 		    flags.botl = 1; 547. 		}  548.  		break; 549. 	case AMULET_OF_CHANGE: 550. 	    {  551.  		int orig_sex = poly_gender; 552.  553.  		if (Unchanging) break; 554. 		change_sex; 555. 		/* Don't use same message as polymorph */ 556. 		if (orig_sex != poly_gender) { 557. 		    makeknown(AMULET_OF_CHANGE); 558. 		    You("are suddenly very %s!", flags.female ? "feminine"  559.  			: "masculine"); 560. 		    flags.botl = 1; 561. 		} else 562. 		    /* already polymorphed into single-gender monster; only 563. 		       changed the character's base sex */ 564. 		    You("don't feel like yourself."); 565. 		pline_The("amulet disintegrates!"); 566. 		if (orig_sex == poly_gender && uamul->dknown &&  567.  			!objects[AMULET_OF_CHANGE].oc_name_known &&  568.  			!objects[AMULET_OF_CHANGE].oc_uname) 569. 		    docall(uamul); 570. 		useup(uamul); 571. 		break; 572. 	    }  573.  	case AMULET_OF_STRANGULATION: 574. 		makeknown(AMULET_OF_STRANGULATION); 575. 		pline("It constricts your throat!"); 576. 		Strangled = 6; 577. 		break; 578. 	case AMULET_OF_RESTFUL_SLEEP: 579. 		HSleeping = rnd(100); 580. 		break; 581. 	case AMULET_OF_YENDOR: 582. 		break; 583.     }  584.  }  585.   586.  void 587. Amulet_off 588. {  589.      switch(uamul->otyp) { 590. 	case AMULET_OF_ESP: 591. 		/* need to update ability before calling see_monsters */ 592. 		setworn((struct obj *)0, W_AMUL); 593. 		see_monsters; 594. 		return; 595. 	case AMULET_OF_LIFE_SAVING: 596. 	case AMULET_VERSUS_POISON: 597. 	case AMULET_OF_REFLECTION: 598. 	case AMULET_OF_CHANGE: 599. 	case AMULET_OF_UNCHANGING: 600. 	case FAKE_AMULET_OF_YENDOR: 601. 		break; 602. 	case AMULET_OF_MAGICAL_BREATHING: 603. 		if (Underwater) { 604. 		    /* HMagical_breathing must be set off 605. 			before calling drown */ 606. 		    setworn((struct obj *)0, W_AMUL); 607. 		    if (!breathless(youmonst.data) && !amphibious(youmonst.data)  608.  						&& !Swimming) { 609. 			You("suddenly inhale an unhealthy amount of water!"); 610. 		    	(void) drown; 611. 		    }  612.  		    return; 613. 		}  614.  		break; 615. 	case AMULET_OF_STRANGULATION: 616. 		if (Strangled) { 617. 			You("can breathe more easily!"); 618. 			Strangled = 0; 619. 		}  620.  		break; 621. 	case AMULET_OF_RESTFUL_SLEEP: 622. 		setworn((struct obj *)0, W_AMUL); 623. 		if (!ESleeping) 624. 			HSleeping = 0; 625. 		return; 626. 	case AMULET_OF_YENDOR: 627. 		break; 628.     }  629.      setworn((struct obj *)0, W_AMUL); 630.     return; 631. }  632.   633.  void 634. Ring_on(obj) 635. register struct obj *obj; 636. {  637.      long oldprop = u.uprops[objects[obj->otyp].oc_oprop].extrinsic; 638.     int old_attrib; 639.  640.      if (obj == uwep) setuwep((struct obj *) 0); 641.     if (obj == uswapwep) setuswapwep((struct obj *) 0); 642.     if (obj == uquiver) setuqwep((struct obj *) 0); 643.  644.      /* only mask out W_RING when we don't have both 645.        left and right rings of the same type */ 646.     if ((oldprop & W_RING) != W_RING) oldprop &= ~W_RING; 647.  648.      switch(obj->otyp){ 649. 	case RIN_TELEPORTATION: 650. 	case RIN_REGENERATION: 651. 	case RIN_SEARCHING: 652. 	case RIN_STEALTH: 653. 	case RIN_HUNGER: 654. 	case RIN_AGGRAVATE_MONSTER: 655. 	case RIN_POISON_RESISTANCE: 656. 	case RIN_FIRE_RESISTANCE: 657. 	case RIN_COLD_RESISTANCE: 658. 	case RIN_SHOCK_RESISTANCE: 659. 	case RIN_CONFLICT: 660. 	case RIN_TELEPORT_CONTROL: 661. 	case RIN_POLYMORPH: 662. 	case RIN_POLYMORPH_CONTROL: 663. 	case RIN_FREE_ACTION: 664. 	case RIN_SLOW_DIGESTION: 665. 	case RIN_SUSTAIN_ABILITY: 666. 	case MEAT_RING: 667. 		break; 668. 	case RIN_WARNING: 669. 		see_monsters; 670. 		break; 671. 	case RIN_SEE_INVISIBLE: 672. 		/* can now see invisible monsters */ 673. 		set_mimic_blocking; /* do special mimic handling */ 674. 		see_monsters; 675. #ifdef INVISIBLE_OBJECTS 676. 		see_objects; 677. #endif 678.  679.  		if (Invis && !oldprop && !HSee_invisible &&  680.  				!perceives(youmonst.data) && !Blind) { 681. 		    newsym(u.ux,u.uy); 682. 		    pline("Suddenly you are transparent, but there!"); 683. 		    makeknown(RIN_SEE_INVISIBLE); 684. 		}  685.  		break; 686. 	case RIN_INVISIBILITY: 687. 		if (!oldprop && !HInvis && !BInvis && !Blind) { 688. 		    makeknown(RIN_INVISIBILITY); 689. 		    newsym(u.ux,u.uy); 690. 		    self_invis_message; 691. 		}  692.  		break; 693. 	case RIN_ADORNMENT: 694. 		old_attrib = ACURR(A_CHA); 695. 		ABON(A_CHA) += obj->spe; 696. 		flags.botl = 1; 697. 		if (ACURR(A_CHA) != old_attrib ||  698.  		    (objects[RIN_ADORNMENT].oc_name_known && 699. 		     old_attrib != 25 && old_attrib != 3)) { 700. 			makeknown(RIN_ADORNMENT); 701. 			obj->known = TRUE; 702. 		}  703.  		break; 704. 	case RIN_LEVITATION: 705. 		if(!oldprop && !HLevitation) { 706. 			float_up; 707. 			makeknown(RIN_LEVITATION); 708. 			obj->known = TRUE; 709. 			spoteffects(FALSE);	/* for sinks */ 710. 		}  711.  		break; 712. 	case RIN_GAIN_STRENGTH: 713. 		old_attrib = ACURR(A_STR); 714. 		ABON(A_STR) += obj->spe; 715. 		flags.botl = 1; 716. 		if (ACURR(A_STR) != old_attrib ||  717.  		    (objects[RIN_GAIN_STRENGTH].oc_name_known && 718. 		     old_attrib != STR19(25) && old_attrib != 3)) { 719. 			makeknown(RIN_GAIN_STRENGTH); 720. 			obj->known = TRUE; 721. 		}  722.  		break; 723. 	case RIN_GAIN_CONSTITUTION: 724. 		old_attrib = ACURR(A_CON); 725. 		ABON(A_CON) += obj->spe; 726. 		flags.botl = 1; 727. 		if (ACURR(A_CON) != old_attrib ||  728.  		    objects[RIN_GAIN_CONSTITUTION].oc_name_known) { 729. 			makeknown(RIN_GAIN_CONSTITUTION); 730. 			obj->known = TRUE; 731. 		}  732.  		break; 733. 	case RIN_INCREASE_ACCURACY:	/* KMH */ 734. 		u.uhitinc += obj->spe; 735. 		break; 736. 	case RIN_INCREASE_DAMAGE: 737. 		u.udaminc += obj->spe; 738. 		break; 739. 	case RIN_PROTECTION_FROM_SHAPE_CHAN: 740. 		rescham; 741. 		break; 742. 	case RIN_PROTECTION: 743. 		flags.botl = 1; 744. 		if (obj->spe || objects[RIN_PROTECTION].oc_name_known) { 745. 			makeknown(RIN_PROTECTION); 746. 			obj->known = TRUE; 747. 			update_inventory; 748. 		}  749.  		break; 750.     }  751.  }  752.   753.  STATIC_OVL void 754. Ring_off_or_gone(obj,gone) 755. register struct obj *obj; 756. boolean gone; 757. {  758.      register long mask = obj->owornmask & W_RING; 759.     int old_attrib; 760.  761.      if(!(u.uprops[objects[obj->otyp].oc_oprop].extrinsic & mask)) 762. 	impossible("Strange... I didn't know you had that ring."); 763.     if(gone) setnotworn(obj); 764.     else setworn((struct obj *)0, obj->owornmask); 765.     switch(obj->otyp) { 766. 	case RIN_TELEPORTATION: 767. 	case RIN_REGENERATION: 768. 	case RIN_SEARCHING: 769. 	case RIN_STEALTH: 770. 	case RIN_HUNGER: 771. 	case RIN_AGGRAVATE_MONSTER: 772. 	case RIN_POISON_RESISTANCE: 773. 	case RIN_FIRE_RESISTANCE: 774. 	case RIN_COLD_RESISTANCE: 775. 	case RIN_SHOCK_RESISTANCE: 776. 	case RIN_CONFLICT: 777. 	case RIN_TELEPORT_CONTROL: 778. 	case RIN_POLYMORPH: 779. 	case RIN_POLYMORPH_CONTROL: 780. 	case RIN_FREE_ACTION: 781. 	case RIN_SLOW_DIGESTION: 782. 	case RIN_SUSTAIN_ABILITY: 783. 	case MEAT_RING: 784. 		break; 785. 	case RIN_WARNING: 786. 		see_monsters; 787. 		break; 788. 	case RIN_SEE_INVISIBLE: 789. 		/* Make invisible monsters go away */ 790. 		if (!See_invisible) { 791. 		    set_mimic_blocking; /* do special mimic handling */ 792. 		    see_monsters; 793. #ifdef INVISIBLE_OBJECTS 794. 		    see_objects; 795. #endif 796. 		}  797.   798.  		if (Invisible && !Blind) { 799. 			newsym(u.ux,u.uy); 800. 			pline("Suddenly you cannot see yourself."); 801. 			makeknown(RIN_SEE_INVISIBLE); 802. 		}  803.  		break; 804. 	case RIN_INVISIBILITY: 805. 		if (!Invis && !BInvis && !Blind) { 806. 			newsym(u.ux,u.uy); 807. 			Your("body seems to unfade%s.",  808.  			    See_invisible ? " completely" : ".."); 809. 			makeknown(RIN_INVISIBILITY); 810. 		}  811.  		break; 812. 	case RIN_ADORNMENT: 813. 		old_attrib = ACURR(A_CHA); 814. 		ABON(A_CHA) -= obj->spe; 815. 		if (ACURR(A_CHA) != old_attrib) makeknown(RIN_ADORNMENT); 816. 		flags.botl = 1; 817. 		break; 818. 	case RIN_LEVITATION: 819. 		(void) float_down(0L, 0L); 820. 		if (!Levitation) makeknown(RIN_LEVITATION); 821. 		break; 822. 	case RIN_GAIN_STRENGTH: 823. 		old_attrib = ACURR(A_STR); 824. 		ABON(A_STR) -= obj->spe; 825. 		if (ACURR(A_STR) != old_attrib) makeknown(RIN_GAIN_STRENGTH); 826. 		flags.botl = 1; 827. 		break; 828. 	case RIN_GAIN_CONSTITUTION: 829. 		old_attrib = ACURR(A_CON); 830. 		ABON(A_CON) -= obj->spe; 831. 		flags.botl = 1; 832. 		if (ACURR(A_CON) != old_attrib) makeknown(RIN_GAIN_CONSTITUTION); 833. 		break; 834. 	case RIN_INCREASE_ACCURACY:	/* KMH */ 835. 		u.uhitinc -= obj->spe; 836. 		break; 837. 	case RIN_INCREASE_DAMAGE: 838. 		u.udaminc -= obj->spe; 839. 		break; 840. 	case RIN_PROTECTION_FROM_SHAPE_CHAN: 841. 		/* If you're no longer protected, let the chameleons 842. 		 * change shape again -dgk 843. 		 */  844.  		restartcham; 845. 		break; 846.     }  847.  }  848.   849.  void 850. Ring_off(obj) 851. struct obj *obj; 852. {  853.  	Ring_off_or_gone(obj,FALSE); 854. }  855.   856.  void 857. Ring_gone(obj) 858. struct obj *obj; 859. {  860.  	Ring_off_or_gone(obj,TRUE); 861. }  862.   863.  void 864. Blindf_on(otmp) 865. register struct obj *otmp; 866. {  867.  	boolean already_blind = Blind, changed = FALSE; 868.  869.  	if (otmp == uwep) 870. 	    setuwep((struct obj *) 0); 871. 	if (otmp == uswapwep) 872. 	    setuswapwep((struct obj *) 0); 873. 	if (otmp == uquiver) 874. 	    setuqwep((struct obj *) 0); 875. 	setworn(otmp, W_TOOL); 876. 	on_msg(otmp); 877.  878.  	if (Blind && !already_blind) { 879. 	    changed = TRUE; 880. 	    if (flags.verbose) You_cant("see any more."); 881. 	    /* set ball&chain variables before the hero goes blind */ 882. 	    if (Punished) set_bc(0); 883. 	} else if (already_blind && !Blind) { 884. 	    changed = TRUE; 885. 	    /* "You are now wearing the Eyes of the Overworld." */ 886.  	    You("can see!"); 887. 	}  888.  	if (changed) { 889. 	    /* blindness has just been toggled */ 890. 	    if (Blind_telepat || Infravision) see_monsters; 891. 	    vision_full_recalc = 1;	/* recalc vision limits */ 892. 	    flags.botl = 1; 893. 	}  894.  }  895.   896.  void 897. Blindf_off(otmp) 898. register struct obj *otmp; 899. {  900.  	boolean was_blind = Blind, changed = FALSE; 901.  902.  	setworn((struct obj *)0, otmp->owornmask); 903. 	off_msg(otmp); 904.  905.  	if (Blind) { 906. 	    if (was_blind) { 907. 		/* "still cannot see" makes no sense when removing lenses 908. 		   since they can't have been the cause of your blindness */ 909. 		if (otmp->otyp != LENSES) 910. 		    You("still cannot see."); 911. 	    } else { 912. 		changed = TRUE;	/* !was_blind */ 913. 		/* "You were wearing the Eyes of the Overworld." */ 914.  		You_cant("see anything now!"); 915. 		/* set ball&chain variables before the hero goes blind */ 916. 		if (Punished) set_bc(0); 917. 	    }  918.  	} else if (was_blind) { 919. 	    changed = TRUE;	/* !Blind */ 920. 	    You("can see again."); 921. 	}  922.  	if (changed) { 923. 	    /* blindness has just been toggled */ 924. 	    if (Blind_telepat || Infravision) see_monsters; 925. 	    vision_full_recalc = 1;	/* recalc vision limits */ 926. 	    flags.botl = 1; 927. 	}  928.  }  929.   930.  /* called in main to set intrinsics of worn start-up items */ 931. void 932. set_wear 933. {  934.  	if (uarm)  (void) Armor_on; 935. 	if (uarmc) (void) Cloak_on; 936. 	if (uarmf) (void) Boots_on; 937. 	if (uarmg) (void) Gloves_on; 938. 	if (uarmh) (void) Helmet_on; 939. /*	if (uarms) (void) Shield_on; */ 940. }  941.   942.  boolean 943. donning(otmp) 944. register struct obj *otmp; 945. {  946.      return((boolean)((otmp == uarmf && (afternmv == Boots_on || afternmv == Boots_off)) 947. 	|| (otmp == uarmh && (afternmv == Helmet_on || afternmv == Helmet_off)) 948. 	|| (otmp == uarmg && (afternmv == Gloves_on || afternmv == Gloves_off)) 949. 	|| (otmp == uarm && (afternmv == Armor_on || afternmv == Armor_off)))); 950. }  951.   952.  void 953. cancel_don 954. {  955.  	/* the piece of armor we were donning/doffing has vanished, so stop 956. 	 * wasting time on it (and don't dereference it when donning would  957.  	 * otherwise finish) 958. 	 */  959.  	cancelled_don = (afternmv == Boots_on || afternmv == Helmet_on ||  960.  			 afternmv == Gloves_on || afternmv == Armor_on); 961. 	afternmv = 0; 962. 	nomovemsg = (char *)0; 963. 	multi = 0; 964. }  965.   966.  static NEARDATA const char clothes[] = {ARMOR_CLASS, 0}; 967. static NEARDATA const char accessories[] = {RING_CLASS, AMULET_CLASS, TOOL_CLASS, FOOD_CLASS, 0}; 968.  969.  int 970. dotakeoff 971. {  972.  	register struct obj *otmp = (struct obj *)0; 973. 	int armorpieces = 0; 974.  975.  #define MOREARM(x) if (x) { armorpieces++; otmp = x; } 976. 	MOREARM(uarmh); 977. 	MOREARM(uarms); 978. 	MOREARM(uarmg); 979. 	MOREARM(uarmf); 980. 	if (uarmc) { 981. 		armorpieces++; 982. 		otmp = uarmc; 983. 	} else if (uarm) { 984. 		armorpieces++; 985. 		otmp = uarm; 986. #ifdef TOURIST 987. 	} else if (uarmu) { 988. 		armorpieces++; 989. 		otmp = uarmu; 990. #endif 991. 	}  992.  	if (!armorpieces) { 993. 	     /* assert( GRAY_DRAGON_SCALES > YELLOW_DRAGON_SCALE_MAIL ); */ 994. 		if (uskin) 995. 		    pline_The("%s merged with your skin!",  996.  			      uskin->otyp >= GRAY_DRAGON_SCALES ?  997.  				"dragon scales are" : "dragon scale mail is"); 998. 		else 999. 		    pline("Not wearing any armor."); 1000. 		return 0; 1001. 	} 1002. 	if (armorpieces > 1) 1003. 		otmp = getobj(clothes, "take off"); 1004. 	if (otmp == 0) return(0); 1005. 	if (!(otmp->owornmask & W_ARMOR)) { 1006. 		You("are not wearing that."); 1007. 		return(0); 1008. 	} 1009. 	/* note: the `uskin' case shouldn't be able to happen here; dragons 1010. 	  can't wear any armor so will end up with `armorpieces == 0' above */ 1011. 	if (otmp == uskin || ((otmp == uarm) && uarmc) 1012. #ifdef TOURIST  1013. 			  || ((otmp == uarmu) && (uarmc || uarm))  1014. #endif  1015. 		) { 1016. 	   You_cant("take that off."); 1017. 	   return 0; 1018. 	} 1019. 	if (otmp == uarmg && welded(uwep)) { 1020. 	   You("seem unable to take off the gloves while holding your %s.",  1021. 		is_sword(uwep) ? c_sword : c_weapon); 1022. 	   uwep->bknown = TRUE; 1023. 	   return 0; 1024. 	} else if (welded(uwep) && bimanual(uwep) && 1025. 		   (otmp == uarm 1026. #ifdef TOURIST 1027. 		   || otmp == uarmu 1028. #endif 1029. 		   )) {  1030. 	    You("seem unable to take off %s while holding your %s.",  1031. 		the(xname(otmp)), is_sword(uwep) ? c_sword : c_weapon); 1032. 	   uwep->bknown = TRUE; 1033. 	   return 0; 1034. 	} 1035. 	if (otmp == uarmg && Glib) { 1036. 	   You_cant("remove the slippery gloves with your slippery fingers."); 1037. 	   return 0; 1038. 	} 1039. 	if (otmp == uarmf && u.utrap && (u.utraptype == TT_BEARTRAP || 1040. 					u.utraptype == TT_INFLOOR)) { /* -3. */ 1041. 	    if(u.utraptype == TT_BEARTRAP) 1042. 		pline_The("bear trap prevents you from pulling your %s out.", 1043. 		      body_part(FOOT)); 1044. 	   else 1045. 		You("are stuck in the %s, and cannot pull your %s out.", 1046. 		    surface(u.ux, u.uy), makeplural(body_part(FOOT))); 1047. 		return(0); 1048. 	} 1049. 	reset_remarm;			/* since you may change ordering */ 1050. 	(void) armoroff(otmp); 1051. 	return(1); 1052. } 1053.  1054. int 1055. doremring 1056. { 1057. 	register struct obj *otmp = 0; 1058. 	int Accessories = 0; 1059. 1060. #define MOREACC(x) if (x) { Accessories++; otmp = x; } 1061. 	MOREACC(uleft); 1062. 	MOREACC(uright); 1063. 	MOREACC(uamul); 1064. 	MOREACC(ublindf); 1065. 1066. 	if(!Accessories) { 1067. 		pline("Not wearing any accessories."); 1068. 		return(0); 1069. 	} 1070. 	if (Accessories != 1) otmp = getobj(accessories, "remove"); 1071. 	if(!otmp) return(0); 1072. 	if(!(otmp->owornmask & (W_RING | W_AMUL | W_TOOL))) { 1073. 		You("are not wearing that."); 1074. 		return(0); 1075. 	} 1076. 	if(cursed(otmp)) return(0); 1077. 	if(otmp->oclass == RING_CLASS || otmp->otyp == MEAT_RING) { 1078. 		if (nolimbs(youmonst.data)) { 1079. 			pline("It seems to be stuck."); 1080. 			return(0); 1081. 		} 1082. 		if (uarmg && uarmg->cursed) { 1083. 			uarmg->bknown = TRUE; 1084. 			You( 1085. 	    "seem unable to remove your ring without taking off your gloves."); 1086. 			return(0); 1087. 		} 1088. 		if (welded(uwep) && bimanual(uwep)) { 1089. 			uwep->bknown = TRUE; 1090. 			You( 1091. 	       "seem unable to remove the ring while your hands hold your %s.",  1092. 			    is_sword(uwep) ? c_sword : c_weapon); 1093. 			return(0); 1094. 		} 1095. 		if (welded(uwep) && otmp==uright) { 1096. 			uwep->bknown = TRUE; 1097. 			You( 1098. 	 "seem unable to remove the ring while your right hand holds your %s.",  1099. 			    is_sword(uwep) ? c_sword : c_weapon); 1100. 			return(0); 1101. 		} 1102. 		/* Sometimes we want to give the off_msg before removing and 1103. 		 * sometimes after; for instance, "you were wearing a moonstone 1104. 		 * ring (on right hand)" is desired but "you were wearing a  1105. 		 * square amulet (being worn)" is not because of the redundant 1106. 		 * "being worn". 1107. 		 */ 1108. 		off_msg(otmp); 1109. 		Ring_off(otmp); 1110. 	} else if(otmp->oclass == AMULET_CLASS) { 1111. 		Amulet_off; 1112. 		off_msg(otmp); 1113. 	} else Blindf_off(otmp); /* does its own off_msg */ 1114. 	return(1); 1115. } 1116.  1117. /* Check if something worn is cursed _and_ unremovable. */ 1118. int 1119. cursed(otmp) 1120. register struct obj *otmp; 1121. { 1122. 	/* Curses, like chickens, come home to roost. */ 1123. 	if((otmp == uwep) ? welded(otmp) : (int)otmp->cursed) { 1124. 		You("can't. %s to be cursed.",  1125. 			(is_boots(otmp) || is_gloves(otmp) || otmp->quan > 1L)  1126. 			? "They seem" : "It seems"); 1127. 		otmp->bknown = TRUE; 1128. 		return(1); 1129. 	} 1130. 	return(0); 1131. } 1132.  1133. int 1134. armoroff(otmp) 1135. register struct obj *otmp; 1136. { 1137. 	register int delay = -objects[otmp->otyp].oc_delay; 1138. 1139. 	if(cursed(otmp)) return(0); 1140. 	if(delay) { 1141. 		nomul(delay); 1142. 		if (is_helmet(otmp)) { 1143. 			nomovemsg = "You finish taking off your helmet."; 1144. 			afternmv = Helmet_off; 1145. 		    }  1146. 		else if (is_gloves(otmp)) { 1147. 			nomovemsg = "You finish taking off your gloves."; 1148. 			afternmv = Gloves_off; 1149. 		    }  1150. 		else if (is_boots(otmp)) { 1151. 			nomovemsg = "You finish taking off your boots."; 1152. 			afternmv = Boots_off; 1153. 		    }  1154. 		else { 1155. 			nomovemsg = "You finish taking off your suit."; 1156. 			afternmv = Armor_off; 1157. 		} 1158. 	} else { 1159. 		/* Be warned! We want off_msg after removing the item to 1160. * avoid "You were wearing ____ (being worn)." However, an 1161. * item which grants fire resistance might cause some trouble 1162. 		 * if removed in Hell and lifesaving puts it back on; in this 1163. 		 * case the message will be printed at the wrong time (after 1164. 		 * the messages saying you died and were lifesaved). Luckily, 1165. 		 * no cloak, shield, or fast-removable armor grants fire 1166. 		 * resistance, so we can safely do the off_msg afterwards. 1167. 		 * Rings do grant fire resistance, but for rings we want the 1168. 		 * off_msg before removal anyway so there's no problem. Take 1169. 		 * care in adding armors granting fire resistance; this code 1170. 		 * might need modification. 1171. 		 * 3.2 (actually 3.1 even): this comment is obsolete since 1172. 		 * fire resistance is not needed for Gehennom. 1173. 		 */ 1174. 		if(is_cloak(otmp)) 1175. 			(void) Cloak_off; 1176. 		else if(is_shield(otmp)) 1177. 			(void) Shield_off; 1178. 		else setworn((struct obj *)0, otmp->owornmask & W_ARMOR); 1179. 		off_msg(otmp); 1180. 	} 1181. 	takeoff_mask = taking_off = 0L; 1182. 	return(1); 1183. } 1184.  1185. STATIC_OVL void 1186. already_wearing(cc) 1187. const char *cc; 1188. { 1189. 	You("are already wearing %s%c", cc, (cc == c_that_) ? '!' : '.'); 1190. } 1191.  1192. STATIC_OVL void 1193. already_wearing2(cc1, cc2) 1194. const char *cc1, *cc2; 1195. { 1196. 	You_cant("wear %s because you're wearing %s there already.", cc1, cc2); 1197. } 1198.  1199. /*  1200.  * canwearobj checks to see whether the player can wear a piece of armor 1201. *  1202.  * inputs: otmp (the piece of armor) 1203. *         noisy (if TRUE give error messages, otherwise be quiet about it) 1204. * output: mask (otmp's armor type) 1205. */  1206. int 1207. canwearobj(otmp,mask,noisy) 1208. struct obj *otmp; 1209. long *mask; 1210. boolean noisy; 1211. { 1212.     int err = 0; 1213.    const char *which; 1214. 1215.     which = is_cloak(otmp) ? c_cloak : 1216. #ifdef TOURIST 1217. 	   is_shirt(otmp) ? c_shirt : 1218. #endif 1219. 	   is_suit(otmp) ? c_suit : 0; 1220.    if (which && cantweararm(youmonst.data) &&  1221. 	    /* same exception for cloaks as used in m_dowear */  1222. 	    (which != c_cloak || youmonst.data->msize != MZ_SMALL)) { 1223. 	if (noisy) pline_The("%s will not fit on your body.", which); 1224. 	return 0; 1225.    } else if (otmp->owornmask & W_ARMOR) { 1226. 	if (noisy) already_wearing(c_that_); 1227. 	return 0; 1228.    }  1229.  1230.     if (welded(uwep) && bimanual(uwep) &&  1231. 	(otmp == uarm 1232. #ifdef TOURIST 1233. 	 || otmp == uarmu 1234. #endif 1235. 	 )) { 1236. 	if (noisy) 1237. 	   You("cannot do that while holding your %s.",  1238. 		is_sword(uwep) ? c_sword : c_weapon); 1239. 	return 0; 1240.    }  1241.  1242.     if (is_helmet(otmp)) { 1243. 	if (uarmh) { 1244. 	   if (noisy) already_wearing(an(c_helmet)); 1245. 	   err++; 1246. 	} else 1247. 	   *mask = W_ARMH; 1248.    } else if (is_shield(otmp)) { 1249. 	if (uarms) { 1250. 	   if (noisy) already_wearing(an(c_shield)); 1251. 	   err++; 1252. 	} else if (uwep && bimanual(uwep)) { 1253. 	   if (noisy) 1254. 		You("cannot wear a shield while wielding a two-handed %s.", 1255. 		    is_sword(uwep) ? c_sword :  1256. 		    (uwep->otyp == BATTLE_AXE) ? c_axe : c_weapon); 1257. 	   err++; 1258. 	} else if (u.twoweap) { 1259. 	   if (noisy) 1260. 		You("cannot wear a shield while wielding two weapons."); 1261. 	   err++; 1262. 	} else 1263. 	   *mask = W_ARMS; 1264.    } else if (is_boots(otmp)) { 1265. 	if (uarmf) { 1266. 	   if (noisy) already_wearing(c_boots); 1267. 	   err++; 1268. 	} else if (Upolyd && slithy(youmonst.data)) { 1269. 	   if (noisy) You("have no feet...");	/* not body_part(FOOT) */ 1270. 	   err++; 1271. 	} else if (u.utrap && (u.utraptype == TT_BEARTRAP || 1272. 				u.utraptype == TT_INFLOOR)) { 1273. 	   if (u.utraptype == TT_BEARTRAP) { 1274. 		if (noisy) Your("%s is trapped!", body_part(FOOT)); 1275. 	   } else { 1276. 		if (noisy) Your("%s are stuck in the %s!", 1277. 				makeplural(body_part(FOOT)),  1278. 				surface(u.ux, u.uy)); 1279. 	   }  1280. 	    err++; 1281. 	} else 1282. 	   *mask = W_ARMF; 1283.    } else if (is_gloves(otmp)) { 1284. 	if (uarmg) { 1285. 	   if (noisy) already_wearing(c_gloves); 1286. 	   err++; 1287. 	} else if (welded(uwep)) { 1288. 	   if (noisy) You("cannot wear gloves over your %s.",  1289. 			   is_sword(uwep) ? c_sword : c_weapon); 1290. 	   err++; 1291. 	} else 1292. 	   *mask = W_ARMG; 1293. #ifdef TOURIST 1294.    } else if (is_shirt(otmp)) { 1295. 	if (uarm || uarmc || uarmu) { 1296. 	   if (uarmu) { 1297. 		if (noisy) already_wearing(an(c_shirt)); 1298. 	   } else { 1299. 		if (noisy) You_cant("wear that over your %s.", 1300. 			           (uarm && !uarmc) ? c_armor : cloak_simple_name(uarmc)); 1301. 	   }  1302. 	    err++; 1303. 	} else 1304. 	   *mask = W_ARMU; 1305. #endif 1306.    } else if (is_cloak(otmp)) { 1307. 	if (uarmc) { 1308. 	   if (noisy) already_wearing(an(cloak_simple_name(uarmc))); 1309. 	   err++; 1310. 	} else 1311. 	   *mask = W_ARMC; 1312.    } else if (is_suit(otmp)) { 1313. 	if (uarmc) { 1314. 	   if (noisy) You("cannot wear armor over a %s.", cloak_simple_name(uarmc)); 1315. 	   err++; 1316. 	} else if (uarm) { 1317. 	   if (noisy) already_wearing("some armor"); 1318. 	   err++; 1319. 	} else 1320. 	   *mask = W_ARM; 1321.    } else { 1322. 	/* getobj can't do this after setting its allow_all flag; that 1323. 	  happens if you have armor for slots that are covered up or  1324. extra armor for slots that are filled */ 1325. 	if (noisy) pline(silly_thing_to, "wear"); 1326. 	err++; 1327.    }  1328. /* Unnecessary since now only weapons and special items like pick-axes get 1329. * welded to your hand, not armor 1330.    if (welded(otmp)) { 1331. 	if (!err++) { 1332. 	   if (noisy) weldmsg(otmp); 1333. 	} 1334.     }  1335.  */  1336.     return !err; 1337. } 1338.  1339. /* the 'W' command */ 1340. int 1341. dowear 1342. { 1343. 	struct obj *otmp; 1344. 	int delay; 1345. 	long mask = 0; 1346. 1347. 	/* cantweararm checks for suits of armor */ 1348. 	/* verysmall or nohands checks for shields, gloves, etc... */ 1349. 	if ((verysmall(youmonst.data) || nohands(youmonst.data))) { 1350. 		pline("Don't even bother."); 1351. 		return(0); 1352. 	} 1353.  1354. 	otmp = getobj(clothes, "wear"); 1355. 	if(!otmp) return(0); 1356. 1357. 	if (!canwearobj(otmp,&mask,TRUE)) return(0); 1358. 1359. 	if (otmp->oartifact && !touch_artifact(otmp, &youmonst)) 1360. 	   return 1;	/* costs a turn even though it didn't get worn */ 1361. 1362. 	if (otmp->otyp == HELM_OF_OPPOSITE_ALIGNMENT &&  1363. 			qstart_level.dnum == u.uz.dnum) {	/* in quest */ 1364. 		You("narrowly avoid losing all chance at your goal."); 1365. 		u.ublessed = 0; /* lose your god's protection */ 1366. 		makeknown(otmp->otyp); 1367. 		flags.botl = 1; 1368. 		return 1; 1369. 	} 1370.  1371. 	otmp->known = TRUE; 1372. 	if(otmp == uwep) 1373. 		setuwep((struct obj *)0); 1374. 	if (otmp == uswapwep) 1375. 		setuswapwep((struct obj *) 0); 1376. 	if (otmp == uquiver) 1377. 		setuqwep((struct obj *) 0); 1378. 	setworn(otmp, mask); 1379. 	delay = -objects[otmp->otyp].oc_delay; 1380. 	if(delay){ 1381. 		nomul(delay); 1382. 		if(is_boots(otmp)) afternmv = Boots_on; 1383. 		if(is_helmet(otmp)) afternmv = Helmet_on; 1384. 		if(is_gloves(otmp)) afternmv = Gloves_on; 1385. 		if(otmp == uarm) afternmv = Armor_on; 1386. 		nomovemsg = "You finish your dressing maneuver."; 1387. 	} else { 1388. 		if(is_cloak(otmp)) (void) Cloak_on; 1389. /*		if(is_shield(otmp)) (void) Shield_on; */ 1390. 		on_msg(otmp); 1391. 	} 1392. 	takeoff_mask = taking_off = 0L; 1393. 	return(1); 1394. } 1395.  1396. int 1397. doputon 1398. { 1399. 	register struct obj *otmp; 1400. 	long mask = 0L; 1401. 1402. 	if(uleft && uright && uamul && ublindf) { 1403. 		Your("%s%s are full, and you're already wearing an amulet and %s.", 1404. 			humanoid(youmonst.data) ? "ring-" : "",  1405. 			makeplural(body_part(FINGER)),  1406. 			ublindf->otyp==LENSES ? "some lenses" : "a blindfold"); 1407. 		return(0); 1408. 	} 1409. 	otmp = getobj(accessories, "put on"); 1410. 	if(!otmp) return(0); 1411. 	if(otmp->owornmask & (W_RING | W_AMUL | W_TOOL)) { 1412. 		already_wearing(c_that_); 1413. 		return(0); 1414. 	} 1415. 	if(welded(otmp)) { 1416. 		weldmsg(otmp); 1417. 		return(0); 1418. 	} 1419. 	if(otmp == uwep) 1420. 		setuwep((struct obj *)0); 1421. 	if(otmp == uswapwep) 1422. 		setuswapwep((struct obj *) 0); 1423. 	if(otmp == uquiver) 1424. 		setuqwep((struct obj *) 0); 1425. 	if(otmp->oclass == RING_CLASS || otmp->otyp == MEAT_RING) { 1426. 		if(nolimbs(youmonst.data)) { 1427. 			You("cannot make the ring stick to your body."); 1428. 			return(0); 1429. 		} 1430. 		if(uleft && uright){ 1431. 			There("are no more %s%s to fill.", 1432. 				humanoid(youmonst.data) ? "ring-" : "",  1433. 				makeplural(body_part(FINGER))); 1434. 			return(0); 1435. 		} 1436. 		if(uleft) mask = RIGHT_RING; 1437. 		else if(uright) mask = LEFT_RING; 1438. 		else do { 1439. 			char qbuf[QBUFSZ]; 1440. 			char answer; 1441. 1442. 			Sprintf(qbuf, "Which %s%s, Right or Left?",  1443. 				humanoid(youmonst.data) ? "ring-" : "",  1444. 				body_part(FINGER)); 1445. 			if(!(answer = yn_function(qbuf, "rl", '\0'))) 1446. 				return(0); 1447. 			switch(answer){ 1448. 			case 'l': 1449. 			case 'L': 1450. 				mask = LEFT_RING; 1451. 				break; 1452. 			case 'r': 1453. 			case 'R': 1454. 				mask = RIGHT_RING; 1455. 				break; 1456. 			} 1457. 		} while(!mask); 1458. 		if (uarmg && uarmg->cursed) { 1459. 			uarmg->bknown = TRUE; 1460. 		   You("cannot remove your gloves to put on the ring."); 1461. 			return(0); 1462. 		} 1463. 		if (welded(uwep) && bimanual(uwep)) { 1464. 			/* welded will set bknown */ 1465. 	   You("cannot free your weapon hands to put on the ring."); 1466. 			return(0); 1467. 		} 1468. 		if (welded(uwep) && mask==RIGHT_RING) { 1469. 			/* welded will set bknown */ 1470. 	   You("cannot free your weapon hand to put on the ring."); 1471. 			return(0); 1472. 		} 1473. 		setworn(otmp, mask); 1474. 		Ring_on(otmp); 1475. 	} else if (otmp->oclass == AMULET_CLASS) { 1476. 		if(uamul) { 1477. 			already_wearing("an amulet"); 1478. 			return(0); 1479. 		} 1480. 		setworn(otmp, W_AMUL); 1481. 		if (otmp->otyp == AMULET_OF_CHANGE) { 1482. 			Amulet_on; 1483. 			/* Don't do a prinv since the amulet is now gone */ 1484. 			return(1); 1485. 		} 1486. 		Amulet_on; 1487. 	} else {	/* it's a blindfold, towel, or lenses */ 1488. 		if (ublindf) { 1489. 			if (ublindf->otyp == TOWEL) 1490. 				Your("%s is already covered by a towel.", 1491. 					body_part(FACE)); 1492. 			else if (ublindf->otyp == BLINDFOLD) { 1493. 				if (otmp->otyp == LENSES) 1494. 					already_wearing2("lenses", "a blindfold"); 1495. 				else 1496. 					already_wearing("a blindfold"); 1497. 			} else if (ublindf->otyp == LENSES) { 1498. 				if (otmp->otyp == BLINDFOLD) 1499. 					already_wearing2("a blindfold", "some lenses"); 1500. 				else 1501. 					already_wearing("some lenses"); 1502. 			} else 1503. 				already_wearing(something); /* ??? */ 1504. 			return(0); 1505. 		} 1506. 		if (otmp->otyp != BLINDFOLD && otmp->otyp != TOWEL && otmp->otyp != LENSES) { 1507. 			You_cant("wear that!"); 1508. 			return(0); 1509. 		} 1510. 		Blindf_on(otmp); 1511. 		return(1); 1512. 	} 1513. 	if (is_worn(otmp)) 1514. 	   prinv((char *)0, otmp, 0L); 1515. 	return(1); 1516. } 1517.  1518. #endif /* OVLB */ 1519. 1520. #ifdef OVL0 1521. 1522. void 1523. find_ac 1524. { 1525. 	int uac = mons[u.umonnum].ac; 1526. 1527. 	if(uarm) uac -= ARM_BONUS(uarm); 1528. 	if(uarmc) uac -= ARM_BONUS(uarmc); 1529. 	if(uarmh) uac -= ARM_BONUS(uarmh); 1530. 	if(uarmf) uac -= ARM_BONUS(uarmf); 1531. 	if(uarms) uac -= ARM_BONUS(uarms); 1532. 	if(uarmg) uac -= ARM_BONUS(uarmg); 1533. #ifdef TOURIST 1534. 	if(uarmu) uac -= ARM_BONUS(uarmu); 1535. #endif 1536. 	if(uleft && uleft->otyp == RIN_PROTECTION) uac -= uleft->spe; 1537. 	if(uright && uright->otyp == RIN_PROTECTION) uac -= uright->spe; 1538. 	if (HProtection & INTRINSIC) uac -= u.ublessed; 1539. 	uac -= u.uspellprot; 1540. 	if (uac < -128) uac = -128;	/* u.uac is an schar */ 1541. 	if(uac != u.uac){ 1542. 		u.uac = uac; 1543. 		flags.botl = 1; 1544. 	} 1545. }  1546.  1547. #endif /* OVL0 */ 1548. #ifdef OVLB 1549. 1550. void 1551. glibr 1552. { 1553. 	register struct obj *otmp; 1554. 	int xfl = 0; 1555. 	boolean leftfall, rightfall; 1556. 1557. 	leftfall = (uleft && !uleft->cursed &&  1558. 		    (!uwep || !welded(uwep) || !bimanual(uwep))); 1559. 	rightfall = (uright && !uright->cursed && (!welded(uwep))); 1560. 	if (!uarmg && (leftfall || rightfall) && !nolimbs(youmonst.data)) { 1561. 		/* changed so cursed rings don't fall off, GAN 10/30/86 */ 1562. 		Your("%s off your %s.", 1563. 			(leftfall && rightfall) ? "rings slip" : "ring slips",  1564. 			makeplural(body_part(FINGER))); 1565. 		xfl++; 1566. 		if (leftfall) { 1567. 			otmp = uleft; 1568. 			Ring_off(uleft); 1569. 			dropx(otmp); 1570. 		} 1571. 		if (rightfall) { 1572. 			otmp = uright; 1573. 			Ring_off(uright); 1574. 			dropx(otmp); 1575. 		} 1576. 	}  1577.  1578. 	otmp = uswapwep; 1579. 	if (u.twoweap && otmp) { 1580. 		Your("%s %sslips from your %s.", 1581. 			is_sword(otmp) ? c_sword :  1582. 				makesingular(oclass_names[(int)otmp->oclass]),  1583. 			xfl ? "also " : "",  1584. 			makeplural(body_part(HAND))); 1585. 		setuswapwep((struct obj *)0); 1586. 		xfl++; 1587. 		if (otmp->otyp != LOADSTONE || !otmp->cursed) 1588. 			dropx(otmp); 1589. 	} 1590. 	otmp = uwep; 1591. 	if (otmp && !welded(otmp)) { 1592. 		/* changed so cursed weapons don't fall, GAN 10/30/86 */ 1593. 		Your("%s %sslips from your %s.", 1594. 			is_sword(otmp) ? c_sword :  1595. 				makesingular(oclass_names[(int)otmp->oclass]),  1596. 			xfl ? "also " : "",  1597. 			makeplural(body_part(HAND))); 1598. 		setuwep((struct obj *)0); 1599. 		if (otmp->otyp != LOADSTONE || !otmp->cursed) 1600. 			dropx(otmp); 1601. 	} 1602. }  1603.  1604. struct obj * 1605. some_armor(victim) 1606. struct monst *victim; 1607. { 1608. 	register struct obj *otmph, *otmp; 1609. 1610. 	otmph = (victim == &youmonst) ? uarmc : which_armor(victim, W_ARMC); 1611. 	if (!otmph) 1612. 	   otmph = (victim == &youmonst) ? uarm : which_armor(victim, W_ARM); 1613. #ifdef TOURIST 1614. 	if (!otmph) 1615. 	   otmph = (victim == &youmonst) ? uarmu : which_armor(victim, W_ARMU); 1616. #endif 1617. 	 1618. 	otmp = (victim == &youmonst) ? uarmh : which_armor(victim, W_ARMH); 1619. 	if(otmp && (!otmph || !rn2(4))) otmph = otmp; 1620. 	otmp = (victim == &youmonst) ? uarmg : which_armor(victim, W_ARMG); 1621. 	if(otmp && (!otmph || !rn2(4))) otmph = otmp; 1622. 	otmp = (victim == &youmonst) ? uarmf : which_armor(victim, W_ARMF); 1623. 	if(otmp && (!otmph || !rn2(4))) otmph = otmp; 1624. 	otmp = (victim == &youmonst) ? uarms : which_armor(victim, W_ARMS); 1625. 	if(otmp && (!otmph || !rn2(4))) otmph = otmp; 1626. 	return(otmph); 1627. } 1628.  1629. /* erode some arbitrary armor worn by the victim */ 1630. void 1631. erode_armor(victim, acid_dmg) 1632. struct monst *victim; 1633. boolean acid_dmg; 1634. { 1635. 	struct obj *otmph = some_armor(victim); 1636. 1637. 	if (otmph && (otmph != uarmf)) { 1638. 	   erode_obj(otmph, acid_dmg, FALSE); 1639. 	   if (carried(otmph)) update_inventory; 1640. 	} 1641. }  1642.  1643. STATIC_PTR 1644. int 1645. select_off(otmp) 1646. register struct obj *otmp; 1647. { 1648. 	char buf[BUFSZ]; 1649. 1650. 	if(!otmp) return(0); 1651. 	if(cursed(otmp)) return(0); 1652. 	if((otmp->oclass==RING_CLASS || otmp->otyp == MEAT_RING) 1653. 				&& nolimbs(youmonst.data)) 1654. 		return(0); 1655. 	if(welded(uwep) && (otmp==uarmg || otmp==uright || (otmp==uleft 1656. 			&& bimanual(uwep)))) { 1657. 		You("cannot free a weapon hand to take off the ring."); 1658. 		return(0); 1659. 	} 1660. 	if(uarmg && uarmg->cursed && (otmp==uright || otmp==uleft)) { 1661. 		uarmg->bknown = TRUE; 1662. 		You("cannot remove your gloves to take off the ring."); 1663. 		return(0); 1664. 	} 1665. 	if(otmp == uarmf && u.utrap && (u.utraptype == TT_BEARTRAP || 1666. 					u.utraptype == TT_INFLOOR)) { 1667. 		return (0); 1668. 	} 1669. 	if((otmp==uarm 1670. #ifdef TOURIST 1671. 			|| otmp==uarmu 1672. #endif 1673. 					) && uarmc && uarmc->cursed) { 1674. 		Strcpy(buf, the(xname(uarmc))); 1675. 		You("cannot remove %s to take off %s.", buf, the(xname(otmp))); 1676. 		uarmc->bknown = TRUE; 1677. 		return(0); 1678. 	} 1679. #ifdef TOURIST 1680. 	if(otmp==uarmu && uarm && uarm->cursed) { 1681. 		Strcpy(buf, the(xname(uarm))); 1682. 		You("cannot remove %s to take off %s.", buf, the(xname(otmp))); 1683. 		uarm->bknown = TRUE; 1684. 		return(0); 1685. 	} 1686. #endif 1687. 1688. 	if(otmp == uarm) takeoff_mask |= WORN_ARMOR; 1689. 	else if(otmp == uarmc) takeoff_mask |= WORN_CLOAK; 1690. 	else if(otmp == uarmf) takeoff_mask |= WORN_BOOTS; 1691. 	else if(otmp == uarmg) takeoff_mask |= WORN_GLOVES; 1692. 	else if(otmp == uarmh) takeoff_mask |= WORN_HELMET; 1693. 	else if(otmp == uarms) takeoff_mask |= WORN_SHIELD; 1694. #ifdef TOURIST 1695. 	else if(otmp == uarmu) takeoff_mask |= WORN_SHIRT; 1696. #endif 1697. 	else if(otmp == uleft) takeoff_mask |= LEFT_RING; 1698. 	else if(otmp == uright) takeoff_mask |= RIGHT_RING; 1699. 	else if(otmp == uamul) takeoff_mask |= WORN_AMUL; 1700. 	else if(otmp == ublindf) takeoff_mask |= WORN_BLINDF; 1701. 	else if(otmp == uwep) takeoff_mask |= W_WEP; 1702. 	else if(otmp == uswapwep) takeoff_mask |= W_SWAPWEP; 1703. 	else if(otmp == uquiver) takeoff_mask |= W_QUIVER; 1704. 1705. 	else impossible("select_off: %s???", doname(otmp)); 1706. 1707. 	return(0); 1708. } 1709.  1710. STATIC_OVL struct obj * 1711. do_takeoff 1712. { 1713. 	register struct obj *otmp = (struct obj *)0; 1714. 1715. 	if (taking_off == W_WEP) { 1716. 	 if(!cursed(uwep)) { 1717. 	   setuwep((struct obj *) 0); 1718. 	   You("are empty %s.", body_part(HANDED)); 1719. 	   u.twoweap = FALSE; 1720. 	 }  1721. 	} else if (taking_off == W_SWAPWEP) { 1722. 	 setuswapwep((struct obj *) 0); 1723. 	 You("no longer have a second weapon readied."); 1724. 	 u.twoweap = FALSE; 1725. 	} else if (taking_off == W_QUIVER) { 1726. 	 setuqwep((struct obj *) 0); 1727. 	 You("no longer have ammunition readied."); 1728. 	} else if (taking_off == WORN_ARMOR) { 1729. 	 otmp = uarm; 1730. 	 if(!cursed(otmp)) (void) Armor_off; 1731. 	} else if (taking_off == WORN_CLOAK) { 1732. 	 otmp = uarmc; 1733. 	 if(!cursed(otmp)) (void) Cloak_off; 1734. 	} else if (taking_off == WORN_BOOTS) { 1735. 	 otmp = uarmf; 1736. 	 if(!cursed(otmp)) (void) Boots_off; 1737. 	} else if (taking_off == WORN_GLOVES) { 1738. 	 otmp = uarmg; 1739. 	 if(!cursed(otmp)) (void) Gloves_off; 1740. 	} else if (taking_off == WORN_HELMET) { 1741. 	 otmp = uarmh; 1742. 	 if(!cursed(otmp)) (void) Helmet_off; 1743. 	} else if (taking_off == WORN_SHIELD) { 1744. 	 otmp = uarms; 1745. 	 if(!cursed(otmp)) (void) Shield_off; 1746. #ifdef TOURIST 1747. 	} else if (taking_off == WORN_SHIRT) { 1748. 	 otmp = uarmu; 1749. 	 if(!cursed(otmp)) 1750. 	   setworn((struct obj *)0, uarmu->owornmask & W_ARMOR); 1751. #endif 1752. 	} else if (taking_off == WORN_AMUL) { 1753. 	 otmp = uamul; 1754. 	 if(!cursed(otmp)) Amulet_off; 1755. 	} else if (taking_off == LEFT_RING) { 1756. 	 otmp = uleft; 1757. 	 if(!cursed(otmp)) Ring_off(uleft); 1758. 	} else if (taking_off == RIGHT_RING) { 1759. 	 otmp = uright; 1760. 	 if(!cursed(otmp)) Ring_off(uright); 1761. 	} else if (taking_off == WORN_BLINDF) { 1762. 	 if (!cursed(ublindf)) Blindf_off(ublindf); 1763. 	} else impossible("do_takeoff: taking off %lx", taking_off); 1764. 1765. 	return(otmp); 1766. } 1767.  1768. STATIC_PTR 1769. int 1770. take_off 1771. { 1772. 	register int i;  1773. register struct obj *otmp; 1774. 1775. 	if(taking_off) { 1776. 	   if(todelay > 0) { 1777. 1778. 		todelay--; 1779. 		return(1);	/* still busy */ 1780. 	   } else if((otmp = do_takeoff)) off_msg(otmp); 1781. 1782. 	    takeoff_mask &= ~taking_off; 1783. 	   taking_off = 0L; 1784. 	} 1785.  1786. 	for(i = 0; takeoff_order[i]; i++) 1787. 	   if(takeoff_mask & takeoff_order[i]) { 1788. 		taking_off = takeoff_order[i]; 1789. 		break; 1790. 	   }  1791.  1792. 	otmp = (struct obj *) 0; 1793. 	todelay = 0; 1794. 1795. 	if (taking_off == 0L) { 1796. 	 You("finish disrobing."); 1797. 	 return 0; 1798. 	} else if (taking_off == W_WEP) { 1799. 	 todelay = 1; 1800. 	} else if (taking_off == W_SWAPWEP) { 1801. 	 todelay = 1; 1802. 	} else if (taking_off == W_QUIVER) { 1803. 	 todelay = 1; 1804. 	} else if (taking_off == WORN_ARMOR) { 1805. 	 otmp = uarm; 1806. 	 /* If a cloak is being worn, add the time to take it off and put 1807. 	  * it back on again. Kludge alert! since that time is 0 for all 1808. 	  * known cloaks, add 1 so that it actually matters...  1809. */ 1810. 	  if (uarmc) todelay += 2 * objects[uarmc->otyp].oc_delay + 1; 1811. 	} else if (taking_off == WORN_CLOAK) { 1812. 	 otmp = uarmc; 1813. 	} else if (taking_off == WORN_BOOTS) { 1814. 	 otmp = uarmf; 1815. 	} else if (taking_off == WORN_GLOVES) { 1816. 	 otmp = uarmg; 1817. 	} else if (taking_off == WORN_HELMET) { 1818. 	 otmp = uarmh; 1819. 	} else if (taking_off == WORN_SHIELD) { 1820. 	 otmp = uarms; 1821. #ifdef TOURIST 1822. 	} else if (taking_off == WORN_SHIRT) { 1823. 	 otmp = uarmu; 1824. 	 /* add the time to take off and put back on armor and/or cloak */ 1825. 	 if (uarm)  todelay += 2 * objects[uarm->otyp].oc_delay; 1826. 	 if (uarmc) todelay += 2 * objects[uarmc->otyp].oc_delay + 1; 1827. #endif 1828. 	} else if (taking_off == WORN_AMUL) { 1829. 	 todelay = 1; 1830. 	} else if (taking_off == LEFT_RING) { 1831. 	 todelay = 1; 1832. 	} else if (taking_off == RIGHT_RING) { 1833. 	 todelay = 1; 1834. 	} else if (taking_off == WORN_BLINDF) { 1835. 	 todelay = 2; 1836. 	} else { 1837. 	 impossible("take_off: taking off %lx", taking_off); 1838. 	 return 0;	/* force done */ 1839. 	} 1840.  1841. 	if (otmp) todelay += objects[otmp->otyp].oc_delay; 1842. 1843. 	/* Since setting the occupation now starts the counter next move, that 1844.         * would always produce a delay 1 too big per item unless we subtract 1845. 	 * 1 here to account for it. 1846. 	 */ 1847. 	if (todelay>0) todelay--; 1848. 1849. 	set_occupation(take_off, "disrobing", 0); 1850. 	return(1);		/* get busy */ 1851. } 1852.  1853. #endif /* OVLB */ 1854. #ifdef OVL1 1855. 1856. void 1857. reset_remarm 1858. { 1859. 	taking_off = takeoff_mask = 0L; 1860. } 1861.  1862. #endif /* OVL1 */ 1863. #ifdef OVLB 1864. 1865. int 1866. doddoremarm 1867. { 1868.     int result = 0; 1869. 1870.     if (taking_off || takeoff_mask) { 1871. 	You("continue disrobing."); 1872. 	set_occupation(take_off, "disrobing", 0); 1873. 	(void) take_off; 1874. 	return 0; 1875.    } else if (!uwep && !uswapwep && !uquiver && !uamul && !ublindf &&  1876. 		!uleft && !uright && !wearing_armor) { 1877. 	You("are not wearing anything."); 1878. 	return 0; 1879.    }  1880.  1881.     add_valid_menu_class(0); /* reset */ 1882.    if (flags.menu_style != MENU_TRADITIONAL ||  1883. 	    (result = ggetobj("take off", select_off, 0, FALSE, (unsigned *)0)) < -1) 1884. 	result = menu_remarm(result); 1885. 1886.     if (takeoff_mask) 1887. 	(void) take_off; 1888.    /* The time to perform the command is already completely accounted for 1889.     * in take_off; if we return 1, that would add an extra turn to each 1890.     * disrobe. 1891.     */  1892.     return 0; 1893. } 1894.  1895. STATIC_OVL int 1896. menu_remarm(retry) 1897. int retry; 1898. { 1899.     int n, i = 0; 1900.    menu_item *pick_list; 1901.    boolean all_worn_categories = TRUE; 1902. 1903.     if (retry) { 1904. 	all_worn_categories = (retry == -2); 1905.    } else if (flags.menu_style == MENU_FULL) { 1906. 	all_worn_categories = FALSE; 1907. 	n = query_category("What type of things do you want to take off?", 1908. 			   invent, WORN_TYPES|ALL_TYPES, &pick_list, PICK_ANY); 1909. 	if (!n) return 0; 1910. 	for (i = 0; i < n; i++) { 1911. 	   if (pick_list[i].item.a_int == ALL_TYPES_SELECTED) 1912. 		all_worn_categories = TRUE; 1913. 	   else 1914. 		add_valid_menu_class(pick_list[i].item.a_int); 1915. 	} 1916. 	free((genericptr_t) pick_list); 1917.    } else if (flags.menu_style == MENU_COMBINATION) { 1918. 	all_worn_categories = FALSE; 1919. 	if (ggetobj("take off", select_off, 0, TRUE, (unsigned *)0) == -2) 1920. 	   all_worn_categories = TRUE; 1921.    }  1922.  1923.     n = query_objlist("What do you want to take off?", invent,  1924. 			SIGNAL_NOMENU|USE_INVLET|INVORDER_SORT,  1925. 			&pick_list, PICK_ANY,  1926. 			all_worn_categories ? is_worn : is_worn_by_type); 1927.    if (n > 0) { 1928. 	for (i = 0; i < n; i++) 1929. 	   (void) select_off(pick_list[i].item.a_obj); 1930. 	free((genericptr_t) pick_list); 1931.    } else if (n < 0 && flags.menu_style != MENU_COMBINATION) { 1932. 	There("is nothing else you can remove or unwield."); 1933.    }  1934.     return 0; 1935. } 1936.  1937. int 1938. destroy_arm(atmp) 1939. register struct obj *atmp; 1940. { 1941. 	register struct obj *otmp; 1942. #define DESTROY_ARM(o) ((otmp = (o)) != 0 && \ 1943. 			(!atmp || atmp == otmp) && \  1944. 			(!obj_resists(otmp, 0, 90))) 1945. 1946. 	if (DESTROY_ARM(uarmc)) { 1947. 		Your("%s crumbles and turns to dust!", cloak_simple_name(uarmc)); 1948. 		(void) Cloak_off; 1949. 		useup(otmp); 1950. 	} else if (DESTROY_ARM(uarm)) { 1951. 		/* may be disintegrated by spell or dragon breath... */ 1952. 		if (donning(otmp)) cancel_don; 1953. 		Your("armor turns to dust and falls to the %s!", 1954. 			surface(u.ux,u.uy)); 1955. 		(void) Armor_gone; 1956. 		useup(otmp); 1957. #ifdef TOURIST 1958. 	} else if (DESTROY_ARM(uarmu)) { 1959. 		Your("shirt crumbles into tiny threads and falls apart!"); 1960. 		useup(otmp); 1961. #endif 1962. 	} else if (DESTROY_ARM(uarmh)) { 1963. 		if (donning(otmp)) cancel_don; 1964. 		Your("helmet turns to dust and is blown away!"); 1965. 		(void) Helmet_off; 1966. 		useup(otmp); 1967. 	} else if (DESTROY_ARM(uarmg)) { 1968. 		if (donning(otmp)) cancel_don; 1969. 		Your("gloves vanish!"); 1970. 		(void) Gloves_off; 1971. 		useup(otmp); 1972. 		selftouch("You"); 1973. 	} else if (DESTROY_ARM(uarmf)) { 1974. 		if (donning(otmp)) cancel_don; 1975. 		Your("boots disintegrate!"); 1976. 		(void) Boots_off; 1977. 		useup(otmp); 1978. 	} else if (DESTROY_ARM(uarms)) { 1979. 		Your("shield crumbles away!"); 1980. 		(void) Shield_off; 1981. 		useup(otmp); 1982. 	} else	return(0);		/* could not destroy anything */ 1983. 1984. #undef DESTROY_ARM 1985. 	return(1); 1986. } 1987.  1988. void 1989. adj_abon(otmp, delta) 1990. register struct obj *otmp; 1991. register schar delta; 1992. { 1993. 	if (uarmg && uarmg == otmp && otmp->otyp == GAUNTLETS_OF_DEXTERITY) { 1994. 		if (delta) { 1995. 			makeknown(uarmg->otyp); 1996. 			ABON(A_DEX) += (delta); 1997. 		} 1998. 		flags.botl = 1; 1999. 	} 2000. 	if (uarmh && uarmh == otmp && otmp->otyp == HELM_OF_BRILLIANCE) { 2001. 		if (delta) { 2002. 			makeknown(uarmh->otyp); 2003. 			ABON(A_INT) += (delta); 2004. 			ABON(A_WIS) += (delta); 2005. 		} 2006. 		flags.botl = 1; 2007. 	} 2008. }  2009.  2010. #endif /* OVLB */ 2011. 2012. /*do_wear.c*/