Source:NetHack 3.6.2/src/do wear.c
Jump to navigation
Jump to search
Below is the full text to do_wear.c from the source code of NetHack 3.6.2. To link to a particular line, write [[Source:NetHack 3.6.2/src/do_wear.c#line12]], for example.
The NetHack General Public License applies to screenshots, source code and other content from NetHack.
This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.
1. /* NetHack 3.6 do_wear.c $NHDT-Date: 1551138255 2019/02/25 23:44:15 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.108 $ */ 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /*-Copyright (c) Robert Patrick Rankin, 2012. */ 4. /* NetHack may be freely redistributed. See license for details. */ 5. 6. #include "hack.h" 7. 8. static NEARDATA const char see_yourself[] = "see yourself"; 9. static NEARDATA const char unknown_type[] = "Unknown type of %s (%d)"; 10. static NEARDATA const char c_armor[] = "armor", c_suit[] = "suit", 11. c_shirt[] = "shirt", c_cloak[] = "cloak", 12. c_gloves[] = "gloves", c_boots[] = "boots", 13. c_helmet[] = "helmet", c_shield[] = "shield", 14. c_weapon[] = "weapon", c_sword[] = "sword", 15. c_axe[] = "axe", c_that_[] = "that"; 16. 17. static NEARDATA const long takeoff_order[] = { 18. WORN_BLINDF, W_WEP, WORN_SHIELD, WORN_GLOVES, LEFT_RING, 19. RIGHT_RING, WORN_CLOAK, WORN_HELMET, WORN_AMUL, WORN_ARMOR, 20. WORN_SHIRT, WORN_BOOTS, W_SWAPWEP, W_QUIVER, 0L 21. }; 22. 23. STATIC_DCL void FDECL(on_msg, (struct obj *)); 24. STATIC_DCL void FDECL(toggle_stealth, (struct obj *, long, BOOLEAN_P)); 25. STATIC_DCL void FDECL(toggle_displacement, (struct obj *, long, BOOLEAN_P)); 26. STATIC_PTR int NDECL(Armor_on); 27. /* int NDECL(Boots_on); -- moved to extern.h */ 28. STATIC_PTR int NDECL(Cloak_on); 29. STATIC_PTR int NDECL(Helmet_on); 30. STATIC_PTR int NDECL(Gloves_on); 31. STATIC_DCL void FDECL(wielding_corpse, (struct obj *, BOOLEAN_P)); 32. STATIC_PTR int NDECL(Shield_on); 33. STATIC_PTR int NDECL(Shirt_on); 34. STATIC_DCL void NDECL(Amulet_on); 35. STATIC_DCL void FDECL(learnring, (struct obj *, BOOLEAN_P)); 36. STATIC_DCL void FDECL(Ring_off_or_gone, (struct obj *, BOOLEAN_P)); 37. STATIC_PTR int FDECL(select_off, (struct obj *)); 38. STATIC_DCL struct obj *NDECL(do_takeoff); 39. STATIC_PTR int NDECL(take_off); 40. STATIC_DCL int FDECL(menu_remarm, (int)); 41. STATIC_DCL void FDECL(count_worn_stuff, (struct obj **, BOOLEAN_P)); 42. STATIC_PTR int FDECL(armor_or_accessory_off, (struct obj *)); 43. STATIC_PTR int FDECL(accessory_or_armor_on, (struct obj *)); 44. STATIC_DCL void FDECL(already_wearing, (const char *)); 45. STATIC_DCL void FDECL(already_wearing2, (const char *, const char *)); 46. 47. void 48. off_msg(otmp) 49. struct obj *otmp; 50. { 51. if (flags.verbose) 52. You("were wearing %s.", doname(otmp)); 53. } 54. 55. /* for items that involve no delay */ 56. STATIC_OVL void 57. on_msg(otmp) 58. struct obj *otmp; 59. { 60. if (flags.verbose) { 61. char how[BUFSZ]; 62. /* call xname() before obj_is_pname(); formatting obj's name 63. might set obj->dknown and that affects the pname test */ 64. const char *otmp_name = xname(otmp); 65. 66. how[0] = '\0'; 67. if (otmp->otyp == TOWEL) 68. Sprintf(how, " around your %s", body_part(HEAD)); 69. You("are now wearing %s%s.", 70. obj_is_pname(otmp) ? the(otmp_name) : an(otmp_name), how); 71. } 72. } 73. 74. /* starting equipment gets auto-worn at beginning of new game, 75. and we don't want stealth or displacement feedback then */ 76. static boolean initial_don = FALSE; /* manipulated in set_wear() */ 77. 78. /* putting on or taking off an item which confers stealth; 79. give feedback and discover it iff stealth state is changing */ 80. STATIC_OVL 81. void 82. toggle_stealth(obj, oldprop, on) 83. struct obj *obj; 84. long oldprop; /* prop[].extrinsic, with obj->owornmask stripped by caller */ 85. boolean on; 86. { 87. if (on ? initial_don : context.takeoff.cancelled_don) 88. return; 89. 90. if (!oldprop /* extrinsic stealth from something else */ 91. && !HStealth /* intrinsic stealth */ 92. && !BStealth) { /* stealth blocked by something */ 93. if (obj->otyp == RIN_STEALTH) 94. learnring(obj, TRUE); 95. else 96. makeknown(obj->otyp); 97. 98. if (on) { 99. if (!is_boots(obj)) 100. You("move very quietly."); 101. else if (Levitation || Flying) 102. You("float imperceptibly."); 103. else 104. You("walk very quietly."); 105. } else { 106. You("sure are noisy."); 107. } 108. } 109. } 110. 111. /* putting on or taking off an item which confers displacement; 112. give feedback and discover it iff displacement state is changing *and* 113. hero is able to see self (or sense monsters) */ 114. STATIC_OVL 115. void 116. toggle_displacement(obj, oldprop, on) 117. struct obj *obj; 118. long oldprop; /* prop[].extrinsic, with obj->owornmask stripped by caller */ 119. boolean on; 120. { 121. if (on ? initial_don : context.takeoff.cancelled_don) 122. return; 123. 124. if (!oldprop /* extrinsic displacement from something else */ 125. && !(u.uprops[DISPLACED].intrinsic) /* (theoretical) */ 126. && !(u.uprops[DISPLACED].blocked) /* (also theoretical) */ 127. /* we don't use canseeself() here because it augments vision 128. with touch, which isn't appropriate for deciding whether 129. we'll notice that monsters have trouble spotting the hero */ 130. && ((!Blind /* see anything */ 131. && !u.uswallow /* see surroundings */ 132. && !Invisible) /* see self */ 133. /* actively sensing nearby monsters via telepathy or extended 134. monster detection overrides vision considerations because 135. hero also senses self in this situation */ 136. || (Unblind_telepat 137. || (Blind_telepat && Blind) 138. || Detect_monsters))) { 139. makeknown(obj->otyp); 140. 141. You_feel("that monsters%s have difficulty pinpointing your location.", 142. on ? "" : " no longer"); 143. } 144. } 145. 146. /* 147. * The Type_on() functions should be called *after* setworn(). 148. * The Type_off() functions call setworn() themselves. 149. * [Blindf_on() is an exception and calls setworn() itself.] 150. */ 151. 152. int 153. Boots_on(VOID_ARGS) 154. { 155. long oldprop = 156. u.uprops[objects[uarmf->otyp].oc_oprop].extrinsic & ~WORN_BOOTS; 157. 158. switch (uarmf->otyp) { 159. case LOW_BOOTS: 160. case IRON_SHOES: 161. case HIGH_BOOTS: 162. case JUMPING_BOOTS: 163. case KICKING_BOOTS: 164. break; 165. case WATER_WALKING_BOOTS: 166. if (u.uinwater) 167. spoteffects(TRUE); 168. /* (we don't need a lava check here since boots can't be 169. put on while feet are stuck) */ 170. break; 171. case SPEED_BOOTS: 172. /* Speed boots are still better than intrinsic speed, */ 173. /* though not better than potion speed */ 174. if (!oldprop && !(HFast & TIMEOUT)) { 175. makeknown(uarmf->otyp); 176. You_feel("yourself speed up%s.", 177. (oldprop || HFast) ? " a bit more" : ""); 178. } 179. break; 180. case ELVEN_BOOTS: 181. toggle_stealth(uarmf, oldprop, TRUE); 182. break; 183. case FUMBLE_BOOTS: 184. if (!oldprop && !(HFumbling & ~TIMEOUT)) 185. incr_itimeout(&HFumbling, rnd(20)); 186. break; 187. case LEVITATION_BOOTS: 188. if (!oldprop && !HLevitation && !(BLevitation & FROMOUTSIDE)) { 189. makeknown(uarmf->otyp); 190. float_up(); 191. if (Levitation) 192. spoteffects(FALSE); /* for sink effect */ 193. } else { 194. float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */ 195. } 196. break; 197. default: 198. impossible(unknown_type, c_boots, uarmf->otyp); 199. } 200. uarmf->known = 1; /* boots' +/- evident because of status line AC */ 201. return 0; 202. } 203. 204. int 205. Boots_off(VOID_ARGS) 206. { 207. struct obj *otmp = uarmf; 208. int otyp = otmp->otyp; 209. long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_BOOTS; 210. 211. context.takeoff.mask &= ~W_ARMF; 212. /* For levitation, float_down() returns if Levitation, so we 213. * must do a setworn() _before_ the levitation case. 214. */ 215. setworn((struct obj *) 0, W_ARMF); 216. switch (otyp) { 217. case SPEED_BOOTS: 218. if (!Very_fast && !context.takeoff.cancelled_don) { 219. makeknown(otyp); 220. You_feel("yourself slow down%s.", Fast ? " a bit" : ""); 221. } 222. break; 223. case WATER_WALKING_BOOTS: 224. /* check for lava since fireproofed boots make it viable */ 225. if ((is_pool(u.ux, u.uy) || is_lava(u.ux, u.uy)) 226. && !Levitation && !Flying && !is_clinger(youmonst.data) 227. && !context.takeoff.cancelled_don 228. /* avoid recursive call to lava_effects() */ 229. && !iflags.in_lava_effects) { 230. /* make boots known in case you survive the drowning */ 231. makeknown(otyp); 232. spoteffects(TRUE); 233. } 234. break; 235. case ELVEN_BOOTS: 236. toggle_stealth(otmp, oldprop, FALSE); 237. break; 238. case FUMBLE_BOOTS: 239. if (!oldprop && !(HFumbling & ~TIMEOUT)) 240. HFumbling = EFumbling = 0; 241. break; 242. case LEVITATION_BOOTS: 243. if (!oldprop && !HLevitation && !(BLevitation & FROMOUTSIDE) 244. && !context.takeoff.cancelled_don) { 245. (void) float_down(0L, 0L); 246. makeknown(otyp); 247. } else { 248. float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */ 249. } 250. break; 251. case LOW_BOOTS: 252. case IRON_SHOES: 253. case HIGH_BOOTS: 254. case JUMPING_BOOTS: 255. case KICKING_BOOTS: 256. break; 257. default: 258. impossible(unknown_type, c_boots, otyp); 259. } 260. context.takeoff.cancelled_don = FALSE; 261. return 0; 262. } 263. 264. STATIC_PTR int 265. Cloak_on(VOID_ARGS) 266. { 267. long oldprop = 268. u.uprops[objects[uarmc->otyp].oc_oprop].extrinsic & ~WORN_CLOAK; 269. 270. switch (uarmc->otyp) { 271. case ORCISH_CLOAK: 272. case DWARVISH_CLOAK: 273. case CLOAK_OF_MAGIC_RESISTANCE: 274. case ROBE: 275. case LEATHER_CLOAK: 276. break; 277. case CLOAK_OF_PROTECTION: 278. makeknown(uarmc->otyp); 279. break; 280. case ELVEN_CLOAK: 281. toggle_stealth(uarmc, oldprop, TRUE); 282. break; 283. case CLOAK_OF_DISPLACEMENT: 284. toggle_displacement(uarmc, oldprop, TRUE); 285. break; 286. case MUMMY_WRAPPING: 287. /* Note: it's already being worn, so we have to cheat here. */ 288. if ((HInvis || EInvis) && !Blind) { 289. newsym(u.ux, u.uy); 290. You("can %s!", See_invisible ? "no longer see through yourself" 291. : see_yourself); 292. } 293. break; 294. case CLOAK_OF_INVISIBILITY: 295. /* since cloak of invisibility was worn, we know mummy wrapping 296. wasn't, so no need to check `oldprop' against blocked */ 297. if (!oldprop && !HInvis && !Blind) { 298. makeknown(uarmc->otyp); 299. newsym(u.ux, u.uy); 300. pline("Suddenly you can%s yourself.", 301. See_invisible ? " see through" : "not see"); 302. } 303. break; 304. case OILSKIN_CLOAK: 305. pline("%s very tightly.", Tobjnam(uarmc, "fit")); 306. break; 307. /* Alchemy smock gives poison _and_ acid resistance */ 308. case ALCHEMY_SMOCK: 309. EAcid_resistance |= WORN_CLOAK; 310. break; 311. default: 312. impossible(unknown_type, c_cloak, uarmc->otyp); 313. } 314. uarmc->known = 1; /* cloak's +/- evident because of status line AC */ 315. return 0; 316. } 317. 318. int 319. Cloak_off(VOID_ARGS) 320. { 321. struct obj *otmp = uarmc; 322. int otyp = otmp->otyp; 323. long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_CLOAK; 324. 325. context.takeoff.mask &= ~W_ARMC; 326. /* For mummy wrapping, taking it off first resets `Invisible'. */ 327. setworn((struct obj *) 0, W_ARMC); 328. switch (otyp) { 329. case ORCISH_CLOAK: 330. case DWARVISH_CLOAK: 331. case CLOAK_OF_PROTECTION: 332. case CLOAK_OF_MAGIC_RESISTANCE: 333. case OILSKIN_CLOAK: 334. case ROBE: 335. case LEATHER_CLOAK: 336. break; 337. case ELVEN_CLOAK: 338. toggle_stealth(otmp, oldprop, FALSE); 339. break; 340. case CLOAK_OF_DISPLACEMENT: 341. toggle_displacement(otmp, oldprop, FALSE); 342. break; 343. case MUMMY_WRAPPING: 344. if (Invis && !Blind) { 345. newsym(u.ux, u.uy); 346. You("can %s.", See_invisible ? "see through yourself" 347. : "no longer see yourself"); 348. } 349. break; 350. case CLOAK_OF_INVISIBILITY: 351. if (!oldprop && !HInvis && !Blind) { 352. makeknown(CLOAK_OF_INVISIBILITY); 353. newsym(u.ux, u.uy); 354. pline("Suddenly you can %s.", 355. See_invisible ? "no longer see through yourself" 356. : see_yourself); 357. } 358. break; 359. /* Alchemy smock gives poison _and_ acid resistance */ 360. case ALCHEMY_SMOCK: 361. EAcid_resistance &= ~WORN_CLOAK; 362. break; 363. default: 364. impossible(unknown_type, c_cloak, otyp); 365. } 366. return 0; 367. } 368. 369. STATIC_PTR 370. int 371. Helmet_on(VOID_ARGS) 372. { 373. switch (uarmh->otyp) { 374. case FEDORA: 375. case HELMET: 376. case DENTED_POT: 377. case ELVEN_LEATHER_HELM: 378. case DWARVISH_IRON_HELM: 379. case ORCISH_HELM: 380. case HELM_OF_TELEPATHY: 381. break; 382. case HELM_OF_BRILLIANCE: 383. adj_abon(uarmh, uarmh->spe); 384. break; 385. case CORNUTHAUM: 386. /* people think marked wizards know what they're talking 387. * about, but it takes trained arrogance to pull it off, 388. * and the actual enchantment of the hat is irrelevant. 389. */ 390. ABON(A_CHA) += (Role_if(PM_WIZARD) ? 1 : -1); 391. context.botl = 1; 392. makeknown(uarmh->otyp); 393. break; 394. case HELM_OF_OPPOSITE_ALIGNMENT: 395. /* changing alignment can toggle off active artifact 396. properties, including levitation; uarmh could get 397. dropped or destroyed here */ 398. uchangealign((u.ualign.type != A_NEUTRAL) 399. ? -u.ualign.type 400. : (uarmh->o_id % 2) ? A_CHAOTIC : A_LAWFUL, 401. 1); 402. /* makeknown(uarmh->otyp); -- moved below, after xname() */ 403. /*FALLTHRU*/ 404. case DUNCE_CAP: 405. if (uarmh && !uarmh->cursed) { 406. if (Blind) 407. pline("%s for a moment.", Tobjnam(uarmh, "vibrate")); 408. else 409. pline("%s %s for a moment.", Tobjnam(uarmh, "glow"), 410. hcolor(NH_BLACK)); 411. curse(uarmh); 412. } 413. context.botl = 1; /* reveal new alignment or INT & WIS */ 414. if (Hallucination) { 415. pline("My brain hurts!"); /* Monty Python's Flying Circus */ 416. } else if (uarmh && uarmh->otyp == DUNCE_CAP) { 417. You_feel("%s.", /* track INT change; ignore WIS */ 418. ACURR(A_INT) 419. <= (ABASE(A_INT) + ABON(A_INT) + ATEMP(A_INT)) 420. ? "like sitting in a corner" 421. : "giddy"); 422. } else { 423. /* [message moved to uchangealign()] */ 424. makeknown(HELM_OF_OPPOSITE_ALIGNMENT); 425. } 426. break; 427. default: 428. impossible(unknown_type, c_helmet, uarmh->otyp); 429. } 430. uarmh->known = 1; /* helmet's +/- evident because of status line AC */ 431. return 0; 432. } 433. 434. int 435. Helmet_off(VOID_ARGS) 436. { 437. context.takeoff.mask &= ~W_ARMH; 438. 439. switch (uarmh->otyp) { 440. case FEDORA: 441. case HELMET: 442. case DENTED_POT: 443. case ELVEN_LEATHER_HELM: 444. case DWARVISH_IRON_HELM: 445. case ORCISH_HELM: 446. break; 447. case DUNCE_CAP: 448. context.botl = 1; 449. break; 450. case CORNUTHAUM: 451. if (!context.takeoff.cancelled_don) { 452. ABON(A_CHA) += (Role_if(PM_WIZARD) ? -1 : 1); 453. context.botl = 1; 454. } 455. break; 456. case HELM_OF_TELEPATHY: 457. /* need to update ability before calling see_monsters() */ 458. setworn((struct obj *) 0, W_ARMH); 459. see_monsters(); 460. return 0; 461. case HELM_OF_BRILLIANCE: 462. if (!context.takeoff.cancelled_don) 463. adj_abon(uarmh, -uarmh->spe); 464. break; 465. case HELM_OF_OPPOSITE_ALIGNMENT: 466. /* changing alignment can toggle off active artifact 467. properties, including levitation; uarmh could get 468. dropped or destroyed here */ 469. uchangealign(u.ualignbase[A_CURRENT], 2); 470. break; 471. default: 472. impossible(unknown_type, c_helmet, uarmh->otyp); 473. } 474. setworn((struct obj *) 0, W_ARMH); 475. context.takeoff.cancelled_don = FALSE; 476. return 0; 477. } 478. 479. STATIC_PTR 480. int 481. Gloves_on(VOID_ARGS) 482. { 483. long oldprop = 484. u.uprops[objects[uarmg->otyp].oc_oprop].extrinsic & ~WORN_GLOVES; 485. 486. switch (uarmg->otyp) { 487. case LEATHER_GLOVES: 488. break; 489. case GAUNTLETS_OF_FUMBLING: 490. if (!oldprop && !(HFumbling & ~TIMEOUT)) 491. incr_itimeout(&HFumbling, rnd(20)); 492. break; 493. case GAUNTLETS_OF_POWER: 494. makeknown(uarmg->otyp); 495. context.botl = 1; /* taken care of in attrib.c */ 496. break; 497. case GAUNTLETS_OF_DEXTERITY: 498. adj_abon(uarmg, uarmg->spe); 499. break; 500. default: 501. impossible(unknown_type, c_gloves, uarmg->otyp); 502. } 503. uarmg->known = 1; /* gloves' +/- evident because of status line AC */ 504. return 0; 505. } 506. 507. STATIC_OVL void 508. wielding_corpse(obj, voluntary) 509. struct obj *obj; 510. boolean voluntary; /* taking gloves off on purpose? */ 511. { 512. char kbuf[BUFSZ]; 513. 514. if (!obj || obj->otyp != CORPSE) 515. return; 516. if (obj != uwep && (obj != uswapwep || !u.twoweap)) 517. return; 518. 519. if (touch_petrifies(&mons[obj->corpsenm]) && !Stone_resistance) { 520. You("now wield %s in your bare %s.", 521. corpse_xname(obj, (const char *) 0, CXN_ARTICLE), 522. makeplural(body_part(HAND))); 523. Sprintf(kbuf, "%s gloves while wielding %s", 524. voluntary ? "removing" : "losing", killer_xname(obj)); 525. instapetrify(kbuf); 526. /* life-saved; can't continue wielding cockatrice corpse though */ 527. remove_worn_item(obj, FALSE); 528. } 529. } 530. 531. int 532. Gloves_off(VOID_ARGS) 533. { 534. long oldprop = 535. u.uprops[objects[uarmg->otyp].oc_oprop].extrinsic & ~WORN_GLOVES; 536. boolean on_purpose = !context.mon_moving && !uarmg->in_use; 537. 538. context.takeoff.mask &= ~W_ARMG; 539. 540. switch (uarmg->otyp) { 541. case LEATHER_GLOVES: 542. break; 543. case GAUNTLETS_OF_FUMBLING: 544. if (!oldprop && !(HFumbling & ~TIMEOUT)) 545. HFumbling = EFumbling = 0; 546. break; 547. case GAUNTLETS_OF_POWER: 548. makeknown(uarmg->otyp); 549. context.botl = 1; /* taken care of in attrib.c */ 550. break; 551. case GAUNTLETS_OF_DEXTERITY: 552. if (!context.takeoff.cancelled_don) 553. adj_abon(uarmg, -uarmg->spe); 554. break; 555. default: 556. impossible(unknown_type, c_gloves, uarmg->otyp); 557. } 558. setworn((struct obj *) 0, W_ARMG); 559. context.takeoff.cancelled_don = FALSE; 560. (void) encumber_msg(); /* immediate feedback for GoP */ 561. 562. /* prevent wielding cockatrice when not wearing gloves */ 563. if (uwep && uwep->otyp == CORPSE) 564. wielding_corpse(uwep, on_purpose); 565. 566. /* KMH -- ...or your secondary weapon when you're wielding it 567. [This case can't actually happen; twoweapon mode won't 568. engage if a corpse has been set up as the alternate weapon.] */ 569. if (u.twoweap && uswapwep && uswapwep->otyp == CORPSE) 570. wielding_corpse(uswapwep, on_purpose); 571. 572. return 0; 573. } 574. 575. STATIC_PTR int 576. Shield_on(VOID_ARGS) 577. { 578. /* no shield currently requires special handling when put on, but we 579. keep this uncommented in case somebody adds a new one which does 580. [reflection is handled by setting u.uprops[REFLECTION].extrinsic 581. in setworn() called by armor_or_accessory_on() before Shield_on()] */ 582. switch (uarms->otyp) { 583. case SMALL_SHIELD: 584. case ELVEN_SHIELD: 585. case URUK_HAI_SHIELD: 586. case ORCISH_SHIELD: 587. case DWARVISH_ROUNDSHIELD: 588. case LARGE_SHIELD: 589. case SHIELD_OF_REFLECTION: 590. break; 591. default: 592. impossible(unknown_type, c_shield, uarms->otyp); 593. } 594. uarms->known = 1; /* shield's +/- evident because of status line AC */ 595. return 0; 596. } 597. 598. int 599. Shield_off(VOID_ARGS) 600. { 601. context.takeoff.mask &= ~W_ARMS; 602. 603. /* no shield currently requires special handling when taken off, but we 604. keep this uncommented in case somebody adds a new one which does */ 605. switch (uarms->otyp) { 606. case SMALL_SHIELD: 607. case ELVEN_SHIELD: 608. case URUK_HAI_SHIELD: 609. case ORCISH_SHIELD: 610. case DWARVISH_ROUNDSHIELD: 611. case LARGE_SHIELD: 612. case SHIELD_OF_REFLECTION: 613. break; 614. default: 615. impossible(unknown_type, c_shield, uarms->otyp); 616. } 617. 618. setworn((struct obj *) 0, W_ARMS); 619. return 0; 620. } 621. 622. STATIC_PTR int 623. Shirt_on(VOID_ARGS) 624. { 625. /* no shirt currently requires special handling when put on, but we 626. keep this uncommented in case somebody adds a new one which does */ 627. switch (uarmu->otyp) { 628. case HAWAIIAN_SHIRT: 629. case T_SHIRT: 630. break; 631. default: 632. impossible(unknown_type, c_shirt, uarmu->otyp); 633. } 634. uarmu->known = 1; /* shirt's +/- evident because of status line AC */ 635. return 0; 636. } 637. 638. int 639. Shirt_off(VOID_ARGS) 640. { 641. context.takeoff.mask &= ~W_ARMU; 642. 643. /* no shirt currently requires special handling when taken off, but we 644. keep this uncommented in case somebody adds a new one which does */ 645. switch (uarmu->otyp) { 646. case HAWAIIAN_SHIRT: 647. case T_SHIRT: 648. break; 649. default: 650. impossible(unknown_type, c_shirt, uarmu->otyp); 651. } 652. 653. setworn((struct obj *) 0, W_ARMU); 654. return 0; 655. } 656. 657. STATIC_PTR 658. int 659. Armor_on(VOID_ARGS) 660. { 661. /* 662. * No suits require special handling. Special properties conferred by 663. * suits are set up as intrinsics (actually 'extrinsics') by setworn() 664. * which is called by armor_or_accessory_on() before Armor_on(). 665. */ 666. uarm->known = 1; /* suit's +/- evident because of status line AC */ 667. return 0; 668. } 669. 670. int 671. Armor_off(VOID_ARGS) 672. { 673. context.takeoff.mask &= ~W_ARM; 674. setworn((struct obj *) 0, W_ARM); 675. context.takeoff.cancelled_don = FALSE; 676. return 0; 677. } 678. 679. /* The gone functions differ from the off functions in that if you die from 680. * taking it off and have life saving, you still die. [Obsolete reference 681. * to lack of fire resistance being fatal in hell (nethack 3.0) and life 682. * saving putting a removed item back on to prevent that from immediately 683. * repeating.] 684. */ 685. int 686. Armor_gone() 687. { 688. context.takeoff.mask &= ~W_ARM; 689. setnotworn(uarm); 690. context.takeoff.cancelled_don = FALSE; 691. return 0; 692. } 693. 694. STATIC_OVL void 695. Amulet_on() 696. { 697. /* make sure amulet isn't wielded; can't use remove_worn_item() 698. here because it has already been set worn in amulet slot */ 699. if (uamul == uwep) 700. setuwep((struct obj *) 0); 701. else if (uamul == uswapwep) 702. setuswapwep((struct obj *) 0); 703. else if (uamul == uquiver) 704. setuqwep((struct obj *) 0); 705. 706. switch (uamul->otyp) { 707. case AMULET_OF_ESP: 708. case AMULET_OF_LIFE_SAVING: 709. case AMULET_VERSUS_POISON: 710. case AMULET_OF_REFLECTION: 711. case AMULET_OF_MAGICAL_BREATHING: 712. case FAKE_AMULET_OF_YENDOR: 713. break; 714. case AMULET_OF_UNCHANGING: 715. if (Slimed) 716. make_slimed(0L, (char *) 0); 717. break; 718. case AMULET_OF_CHANGE: { 719. int orig_sex = poly_gender(); 720. 721. if (Unchanging) 722. break; 723. change_sex(); 724. /* Don't use same message as polymorph */ 725. if (orig_sex != poly_gender()) { 726. makeknown(AMULET_OF_CHANGE); 727. You("are suddenly very %s!", 728. flags.female ? "feminine" : "masculine"); 729. context.botl = 1; 730. } else 731. /* already polymorphed into single-gender monster; only 732. changed the character's base sex */ 733. You("don't feel like yourself."); 734. pline_The("amulet disintegrates!"); 735. if (orig_sex == poly_gender() && uamul->dknown 736. && !objects[AMULET_OF_CHANGE].oc_name_known 737. && !objects[AMULET_OF_CHANGE].oc_uname) 738. docall(uamul); 739. useup(uamul); 740. break; 741. } 742. case AMULET_OF_STRANGULATION: 743. if (can_be_strangled(&youmonst)) { 744. makeknown(AMULET_OF_STRANGULATION); 745. Strangled = 6L; 746. context.botl = TRUE; 747. pline("It constricts your throat!"); 748. } 749. break; 750. case AMULET_OF_RESTFUL_SLEEP: { 751. long newnap = (long) rnd(100), oldnap = (HSleepy & TIMEOUT); 752. 753. /* avoid clobbering FROMOUTSIDE bit, which might have 754. gotten set by previously eating one of these amulets */ 755. if (newnap < oldnap || oldnap == 0L) 756. HSleepy = (HSleepy & ~TIMEOUT) | newnap; 757. } break; 758. case AMULET_OF_YENDOR: 759. break; 760. } 761. } 762. 763. void 764. Amulet_off() 765. { 766. context.takeoff.mask &= ~W_AMUL; 767. 768. switch (uamul->otyp) { 769. case AMULET_OF_ESP: 770. /* need to update ability before calling see_monsters() */ 771. setworn((struct obj *) 0, W_AMUL); 772. see_monsters(); 773. return; 774. case AMULET_OF_LIFE_SAVING: 775. case AMULET_VERSUS_POISON: 776. case AMULET_OF_REFLECTION: 777. case AMULET_OF_CHANGE: 778. case AMULET_OF_UNCHANGING: 779. case FAKE_AMULET_OF_YENDOR: 780. break; 781. case AMULET_OF_MAGICAL_BREATHING: 782. if (Underwater) { 783. /* HMagical_breathing must be set off 784. before calling drown() */ 785. setworn((struct obj *) 0, W_AMUL); 786. if (!breathless(youmonst.data) && !amphibious(youmonst.data) 787. && !Swimming) { 788. You("suddenly inhale an unhealthy amount of %s!", 789. hliquid("water")); 790. (void) drown(); 791. } 792. return; 793. } 794. break; 795. case AMULET_OF_STRANGULATION: 796. if (Strangled) { 797. Strangled = 0L; 798. context.botl = TRUE; 799. if (Breathless) 800. Your("%s is no longer constricted!", body_part(NECK)); 801. else 802. You("can breathe more easily!"); 803. } 804. break; 805. case AMULET_OF_RESTFUL_SLEEP: 806. setworn((struct obj *) 0, W_AMUL); 807. /* HSleepy = 0L; -- avoid clobbering FROMOUTSIDE bit */ 808. if (!ESleepy && !(HSleepy & ~TIMEOUT)) 809. HSleepy &= ~TIMEOUT; /* clear timeout bits */ 810. return; 811. case AMULET_OF_YENDOR: 812. break; 813. } 814. setworn((struct obj *) 0, W_AMUL); 815. return; 816. } 817. 818. /* handle ring discovery; comparable to learnwand() */ 819. STATIC_OVL void 820. learnring(ring, observed) 821. struct obj *ring; 822. boolean observed; 823. { 824. int ringtype = ring->otyp; 825. 826. /* if effect was observeable then we usually discover the type */ 827. if (observed) { 828. /* if we already know the ring type which accomplishes this 829. effect (assumes there is at most one type for each effect), 830. mark this ring as having been seen (no need for makeknown); 831. otherwise if we have seen this ring, discover its type */ 832. if (objects[ringtype].oc_name_known) 833. ring->dknown = 1; 834. else if (ring->dknown) 835. makeknown(ringtype); 836. #if 0 /* see learnwand() */ 837. else 838. ring->eknown = 1; 839. #endif 840. } 841. 842. /* make enchantment of charged ring known (might be +0) and update 843. perm invent window if we've seen this ring and know its type */ 844. if (ring->dknown && objects[ringtype].oc_name_known) { 845. if (objects[ringtype].oc_charged) 846. ring->known = 1; 847. update_inventory(); 848. } 849. } 850. 851. void 852. Ring_on(obj) 853. register struct obj *obj; 854. { 855. long oldprop = u.uprops[objects[obj->otyp].oc_oprop].extrinsic; 856. int old_attrib, which; 857. boolean observable; 858. 859. /* make sure ring isn't wielded; can't use remove_worn_item() 860. here because it has already been set worn in a ring slot */ 861. if (obj == uwep) 862. setuwep((struct obj *) 0); 863. else if (obj == uswapwep) 864. setuswapwep((struct obj *) 0); 865. else if (obj == uquiver) 866. setuqwep((struct obj *) 0); 867. 868. /* only mask out W_RING when we don't have both 869. left and right rings of the same type */ 870. if ((oldprop & W_RING) != W_RING) 871. oldprop &= ~W_RING; 872. 873. switch (obj->otyp) { 874. case RIN_TELEPORTATION: 875. case RIN_REGENERATION: 876. case RIN_SEARCHING: 877. case RIN_HUNGER: 878. case RIN_AGGRAVATE_MONSTER: 879. case RIN_POISON_RESISTANCE: 880. case RIN_FIRE_RESISTANCE: 881. case RIN_COLD_RESISTANCE: 882. case RIN_SHOCK_RESISTANCE: 883. case RIN_CONFLICT: 884. case RIN_TELEPORT_CONTROL: 885. case RIN_POLYMORPH: 886. case RIN_POLYMORPH_CONTROL: 887. case RIN_FREE_ACTION: 888. case RIN_SLOW_DIGESTION: 889. case RIN_SUSTAIN_ABILITY: 890. case MEAT_RING: 891. break; 892. case RIN_STEALTH: 893. toggle_stealth(obj, oldprop, TRUE); 894. break; 895. case RIN_WARNING: 896. see_monsters(); 897. break; 898. case RIN_SEE_INVISIBLE: 899. /* can now see invisible monsters */ 900. set_mimic_blocking(); /* do special mimic handling */ 901. see_monsters(); 902. 903. if (Invis && !oldprop && !HSee_invisible && !Blind) { 904. newsym(u.ux, u.uy); 905. pline("Suddenly you are transparent, but there!"); 906. learnring(obj, TRUE); 907. } 908. break; 909. case RIN_INVISIBILITY: 910. if (!oldprop && !HInvis && !BInvis && !Blind) { 911. learnring(obj, TRUE); 912. newsym(u.ux, u.uy); 913. self_invis_message(); 914. } 915. break; 916. case RIN_LEVITATION: 917. if (!oldprop && !HLevitation && !(BLevitation & FROMOUTSIDE)) { 918. float_up(); 919. learnring(obj, TRUE); 920. if (Levitation) 921. spoteffects(FALSE); /* for sinks */ 922. } else { 923. float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */ 924. } 925. break; 926. case RIN_GAIN_STRENGTH: 927. which = A_STR; 928. goto adjust_attrib; 929. case RIN_GAIN_CONSTITUTION: 930. which = A_CON; 931. goto adjust_attrib; 932. case RIN_ADORNMENT: 933. which = A_CHA; 934. adjust_attrib: 935. old_attrib = ACURR(which); 936. ABON(which) += obj->spe; 937. observable = (old_attrib != ACURR(which)); 938. /* if didn't change, usually means ring is +0 but might 939. be because nonzero couldn't go below min or above max; 940. learn +0 enchantment if attribute value is not stuck 941. at a limit [and ring has been seen and its type is 942. already discovered, both handled by learnring()] */ 943. if (observable || !extremeattr(which)) 944. learnring(obj, observable); 945. context.botl = 1; 946. break; 947. case RIN_INCREASE_ACCURACY: /* KMH */ 948. u.uhitinc += obj->spe; 949. break; 950. case RIN_INCREASE_DAMAGE: 951. u.udaminc += obj->spe; 952. break; 953. case RIN_PROTECTION_FROM_SHAPE_CHAN: 954. rescham(); 955. break; 956. case RIN_PROTECTION: 957. /* usually learn enchantment and discover type; 958. won't happen if ring is unseen or if it's +0 959. and the type hasn't been discovered yet */ 960. observable = (obj->spe != 0); 961. learnring(obj, observable); 962. if (obj->spe) 963. find_ac(); /* updates botl */ 964. break; 965. } 966. } 967. 968. STATIC_OVL void 969. Ring_off_or_gone(obj, gone) 970. register struct obj *obj; 971. boolean gone; 972. { 973. long mask = (obj->owornmask & W_RING); 974. int old_attrib, which; 975. boolean observable; 976. 977. context.takeoff.mask &= ~mask; 978. if (!(u.uprops[objects[obj->otyp].oc_oprop].extrinsic & mask)) 979. impossible("Strange... I didn't know you had that ring."); 980. if (gone) 981. setnotworn(obj); 982. else 983. setworn((struct obj *) 0, obj->owornmask); 984. 985. switch (obj->otyp) { 986. case RIN_TELEPORTATION: 987. case RIN_REGENERATION: 988. case RIN_SEARCHING: 989. case RIN_HUNGER: 990. case RIN_AGGRAVATE_MONSTER: 991. case RIN_POISON_RESISTANCE: 992. case RIN_FIRE_RESISTANCE: 993. case RIN_COLD_RESISTANCE: 994. case RIN_SHOCK_RESISTANCE: 995. case RIN_CONFLICT: 996. case RIN_TELEPORT_CONTROL: 997. case RIN_POLYMORPH: 998. case RIN_POLYMORPH_CONTROL: 999. case RIN_FREE_ACTION: 1000. case RIN_SLOW_DIGESTION: 1001. case RIN_SUSTAIN_ABILITY: 1002. case MEAT_RING: 1003. break; 1004. case RIN_STEALTH: 1005. toggle_stealth(obj, (EStealth & ~mask), FALSE); 1006. break; 1007. case RIN_WARNING: 1008. see_monsters(); 1009. break; 1010. case RIN_SEE_INVISIBLE: 1011. /* Make invisible monsters go away */ 1012. if (!See_invisible) { 1013. set_mimic_blocking(); /* do special mimic handling */ 1014. see_monsters(); 1015. } 1016. 1017. if (Invisible && !Blind) { 1018. newsym(u.ux, u.uy); 1019. pline("Suddenly you cannot see yourself."); 1020. learnring(obj, TRUE); 1021. } 1022. break; 1023. case RIN_INVISIBILITY: 1024. if (!Invis && !BInvis && !Blind) { 1025. newsym(u.ux, u.uy); 1026. Your("body seems to unfade%s.", 1027. See_invisible ? " completely" : ".."); 1028. learnring(obj, TRUE); 1029. } 1030. break; 1031. case RIN_LEVITATION: 1032. if (!(BLevitation & FROMOUTSIDE)) { 1033. (void) float_down(0L, 0L); 1034. if (!Levitation) 1035. learnring(obj, TRUE); 1036. } else { 1037. float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */ 1038. } 1039. break; 1040. case RIN_GAIN_STRENGTH: 1041. which = A_STR; 1042. goto adjust_attrib; 1043. case RIN_GAIN_CONSTITUTION: 1044. which = A_CON; 1045. goto adjust_attrib; 1046. case RIN_ADORNMENT: 1047. which = A_CHA; 1048. adjust_attrib: 1049. old_attrib = ACURR(which); 1050. ABON(which) -= obj->spe; 1051. observable = (old_attrib != ACURR(which)); 1052. /* same criteria as Ring_on() */ 1053. if (observable || !extremeattr(which)) 1054. learnring(obj, observable); 1055. context.botl = 1; 1056. break; 1057. case RIN_INCREASE_ACCURACY: /* KMH */ 1058. u.uhitinc -= obj->spe; 1059. break; 1060. case RIN_INCREASE_DAMAGE: 1061. u.udaminc -= obj->spe; 1062. break; 1063. case RIN_PROTECTION: 1064. /* might have been put on while blind and we can now see 1065. or perhaps been forgotten due to amnesia */ 1066. observable = (obj->spe != 0); 1067. learnring(obj, observable); 1068. if (obj->spe) 1069. find_ac(); /* updates botl */ 1070. break; 1071. case RIN_PROTECTION_FROM_SHAPE_CHAN: 1072. /* If you're no longer protected, let the chameleons 1073. * change shape again -dgk 1074. */ 1075. restartcham(); 1076. break; 1077. } 1078. } 1079. 1080. void 1081. Ring_off(obj) 1082. struct obj *obj; 1083. { 1084. Ring_off_or_gone(obj, FALSE); 1085. } 1086. 1087. void 1088. Ring_gone(obj) 1089. struct obj *obj; 1090. { 1091. Ring_off_or_gone(obj, TRUE); 1092. } 1093. 1094. void 1095. Blindf_on(otmp) 1096. struct obj *otmp; 1097. { 1098. boolean already_blind = Blind, changed = FALSE; 1099. 1100. /* blindfold might be wielded; release it for wearing */ 1101. if (otmp->owornmask & W_WEAPON) 1102. remove_worn_item(otmp, FALSE); 1103. setworn(otmp, W_TOOL); 1104. on_msg(otmp); 1105. 1106. if (Blind && !already_blind) { 1107. changed = TRUE; 1108. if (flags.verbose) 1109. You_cant("see any more."); 1110. /* set ball&chain variables before the hero goes blind */ 1111. if (Punished) 1112. set_bc(0); 1113. } else if (already_blind && !Blind) { 1114. changed = TRUE; 1115. /* "You are now wearing the Eyes of the Overworld." */ 1116. if (u.uroleplay.blind) { 1117. /* this can only happen by putting on the Eyes of the Overworld; 1118. that shouldn't actually produce a permanent cure, but we 1119. can't let the "blind from birth" conduct remain intact */ 1120. pline("For the first time in your life, you can see!"); 1121. u.uroleplay.blind = FALSE; 1122. } else 1123. You("can see!"); 1124. } 1125. if (changed) { 1126. toggle_blindness(); /* potion.c */ 1127. } 1128. } 1129. 1130. void 1131. Blindf_off(otmp) 1132. struct obj *otmp; 1133. { 1134. boolean was_blind = Blind, changed = FALSE; 1135. 1136. if (!otmp) { 1137. impossible("Blindf_off without otmp"); 1138. return; 1139. } 1140. context.takeoff.mask &= ~W_TOOL; 1141. setworn((struct obj *) 0, otmp->owornmask); 1142. off_msg(otmp); 1143. 1144. if (Blind) { 1145. if (was_blind) { 1146. /* "still cannot see" makes no sense when removing lenses 1147. since they can't have been the cause of your blindness */ 1148. if (otmp->otyp != LENSES) 1149. You("still cannot see."); 1150. } else { 1151. changed = TRUE; /* !was_blind */ 1152. /* "You were wearing the Eyes of the Overworld." */ 1153. You_cant("see anything now!"); 1154. /* set ball&chain variables before the hero goes blind */ 1155. if (Punished) 1156. set_bc(0); 1157. } 1158. } else if (was_blind) { 1159. if (!gulp_blnd_check()) { 1160. changed = TRUE; /* !Blind */ 1161. You("can see again."); 1162. } 1163. } 1164. if (changed) { 1165. toggle_blindness(); /* potion.c */ 1166. } 1167. } 1168. 1169. /* called in moveloop()'s prologue to set side-effects of worn start-up items; 1170. also used by poly_obj() when a worn item gets transformed */ 1171. void 1172. set_wear(obj) 1173. struct obj *obj; /* if null, do all worn items; otherwise just obj itself */ 1174. { 1175. initial_don = !obj; 1176. 1177. if (!obj ? ublindf != 0 : (obj == ublindf)) 1178. (void) Blindf_on(ublindf); 1179. if (!obj ? uright != 0 : (obj == uright)) 1180. (void) Ring_on(uright); 1181. if (!obj ? uleft != 0 : (obj == uleft)) 1182. (void) Ring_on(uleft); 1183. if (!obj ? uamul != 0 : (obj == uamul)) 1184. (void) Amulet_on(); 1185. 1186. if (!obj ? uarmu != 0 : (obj == uarmu)) 1187. (void) Shirt_on(); 1188. if (!obj ? uarm != 0 : (obj == uarm)) 1189. (void) Armor_on(); 1190. if (!obj ? uarmc != 0 : (obj == uarmc)) 1191. (void) Cloak_on(); 1192. if (!obj ? uarmf != 0 : (obj == uarmf)) 1193. (void) Boots_on(); 1194. if (!obj ? uarmg != 0 : (obj == uarmg)) 1195. (void) Gloves_on(); 1196. if (!obj ? uarmh != 0 : (obj == uarmh)) 1197. (void) Helmet_on(); 1198. if (!obj ? uarms != 0 : (obj == uarms)) 1199. (void) Shield_on(); 1200. 1201. initial_don = FALSE; 1202. } 1203. 1204. /* check whether the target object is currently being put on (or taken off-- 1205. also checks for doffing--[why?]) */ 1206. boolean 1207. donning(otmp) 1208. struct obj *otmp; 1209. { 1210. boolean result = FALSE; 1211. 1212. /* 'W' (or 'P' used for armor) sets afternmv */ 1213. if (doffing(otmp)) 1214. result = TRUE; 1215. else if (otmp == uarm) 1216. result = (afternmv == Armor_on); 1217. else if (otmp == uarmu) 1218. result = (afternmv == Shirt_on); 1219. else if (otmp == uarmc) 1220. result = (afternmv == Cloak_on); 1221. else if (otmp == uarmf) 1222. result = (afternmv == Boots_on); 1223. else if (otmp == uarmh) 1224. result = (afternmv == Helmet_on); 1225. else if (otmp == uarmg) 1226. result = (afternmv == Gloves_on); 1227. else if (otmp == uarms) 1228. result = (afternmv == Shield_on); 1229. 1230. return result; 1231. } 1232. 1233. /* check whether the target object is currently being taken off, 1234. so that stop_donning() and steal() can vary messages and doname() 1235. can vary "(being worn)" suffix */ 1236. boolean 1237. doffing(otmp) 1238. struct obj *otmp; 1239. { 1240. long what = context.takeoff.what; 1241. boolean result = FALSE; 1242. 1243. /* 'T' (or 'R' used for armor) sets afternmv, 'A' sets takeoff.what */ 1244. if (otmp == uarm) 1245. result = (afternmv == Armor_off || what == WORN_ARMOR); 1246. else if (otmp == uarmu) 1247. result = (afternmv == Shirt_off || what == WORN_SHIRT); 1248. else if (otmp == uarmc) 1249. result = (afternmv == Cloak_off || what == WORN_CLOAK); 1250. else if (otmp == uarmf) 1251. result = (afternmv == Boots_off || what == WORN_BOOTS); 1252. else if (otmp == uarmh) 1253. result = (afternmv == Helmet_off || what == WORN_HELMET); 1254. else if (otmp == uarmg) 1255. result = (afternmv == Gloves_off || what == WORN_GLOVES); 1256. else if (otmp == uarms) 1257. result = (afternmv == Shield_off || what == WORN_SHIELD); 1258. /* these 1-turn items don't need 'afternmv' checks */ 1259. else if (otmp == uamul) 1260. result = (what == WORN_AMUL); 1261. else if (otmp == uleft) 1262. result = (what == LEFT_RING); 1263. else if (otmp == uright) 1264. result = (what == RIGHT_RING); 1265. else if (otmp == ublindf) 1266. result = (what == WORN_BLINDF); 1267. else if (otmp == uwep) 1268. result = (what == W_WEP); 1269. else if (otmp == uswapwep) 1270. result = (what == W_SWAPWEP); 1271. else if (otmp == uquiver) 1272. result = (what == W_QUIVER); 1273. 1274. return result; 1275. } 1276. 1277. /* despite their names, cancel_don() and cancel_doff() both apply to both 1278. donning and doffing... */ 1279. void 1280. cancel_doff(obj, slotmask) 1281. struct obj *obj; 1282. long slotmask; 1283. { 1284. /* Called by setworn() for old item in specified slot or by setnotworn() 1285. * for specified item. We don't want to call cancel_don() if we got 1286. * here via <X>_off() -> setworn((struct obj *)0) -> cancel_doff() 1287. * because that would stop the 'A' command from continuing with next 1288. * selected item. So do_takeoff() sets a flag in takeoff.mask for us. 1289. * [For taking off an individual item with 'T'/'R'/'w-', it doesn't 1290. * matter whether cancel_don() gets called here--the item has already 1291. * been removed by now.] 1292. */ 1293. if (!(context.takeoff.mask & I_SPECIAL) && donning(obj)) 1294. cancel_don(); /* applies to doffing too */ 1295. context.takeoff.mask &= ~slotmask; 1296. } 1297. 1298. /* despite their names, cancel_don() and cancel_doff() both apply to both 1299. donning and doffing... */ 1300. void 1301. cancel_don() 1302. { 1303. /* the piece of armor we were donning/doffing has vanished, so stop 1304. * wasting time on it (and don't dereference it when donning would 1305. * otherwise finish) 1306. */ 1307. context.takeoff.cancelled_don = 1308. (afternmv == Boots_on || afternmv == Helmet_on 1309. || afternmv == Gloves_on || afternmv == Armor_on); 1310. afternmv = (int NDECL((*))) 0; 1311. nomovemsg = (char *) 0; 1312. multi = 0; 1313. context.takeoff.delay = 0; 1314. context.takeoff.what = 0L; 1315. } 1316. 1317. /* called by steal() during theft from hero; interrupt donning/doffing */ 1318. int 1319. stop_donning(stolenobj) 1320. struct obj *stolenobj; /* no message if stolenobj is already being doffing */ 1321. { 1322. char buf[BUFSZ]; 1323. struct obj *otmp; 1324. boolean putting_on; 1325. int result = 0; 1326. 1327. for (otmp = invent; otmp; otmp = otmp->nobj) 1328. if ((otmp->owornmask & W_ARMOR) && donning(otmp)) 1329. break; 1330. /* at most one item will pass donning() test at any given time */ 1331. if (!otmp) 1332. return 0; 1333. 1334. /* donning() returns True when doffing too; doffing() is more specific */ 1335. putting_on = !doffing(otmp); 1336. /* cancel_don() looks at afternmv; it can also cancel doffing */ 1337. cancel_don(); 1338. /* don't want <armor>_on() or <armor>_off() being called 1339. by unmul() since the on or off action isn't completing */ 1340. afternmv = (int NDECL((*))) 0; 1341. if (putting_on || otmp != stolenobj) { 1342. Sprintf(buf, "You stop %s %s.", 1343. putting_on ? "putting on" : "taking off", 1344. thesimpleoname(otmp)); 1345. } else { 1346. buf[0] = '\0'; /* silently stop doffing stolenobj */ 1347. result = -multi; /* remember this before calling unmul() */ 1348. } 1349. unmul(buf); 1350. /* while putting on, item becomes worn immediately but side-effects are 1351. deferred until the delay expires; when interrupted, make it unworn 1352. (while taking off, item stays worn until the delay expires; when 1353. interrupted, leave it worn) */ 1354. if (putting_on) 1355. remove_worn_item(otmp, FALSE); 1356. 1357. return result; 1358. } 1359. 1360. /* both 'clothes' and 'accessories' now include both armor and accessories; 1361. TOOL_CLASS is for eyewear, FOOD_CLASS is for MEAT_RING */ 1362. static NEARDATA const char clothes[] = { 1363. ARMOR_CLASS, RING_CLASS, AMULET_CLASS, TOOL_CLASS, FOOD_CLASS, 0 1364. }; 1365. static NEARDATA const char accessories[] = { 1366. RING_CLASS, AMULET_CLASS, TOOL_CLASS, FOOD_CLASS, ARMOR_CLASS, 0 1367. }; 1368. STATIC_VAR NEARDATA int Narmorpieces, Naccessories; 1369. 1370. /* assign values to Narmorpieces and Naccessories */ 1371. STATIC_OVL void 1372. count_worn_stuff(which, accessorizing) 1373. struct obj **which; /* caller wants this when count is 1 */ 1374. boolean accessorizing; 1375. { 1376. struct obj *otmp; 1377. 1378. Narmorpieces = Naccessories = 0; 1379. 1380. #define MOREWORN(x,wtyp) do { if (x) { wtyp++; otmp = x; } } while (0) 1381. otmp = 0; 1382. MOREWORN(uarmh, Narmorpieces); 1383. MOREWORN(uarms, Narmorpieces); 1384. MOREWORN(uarmg, Narmorpieces); 1385. MOREWORN(uarmf, Narmorpieces); 1386. /* for cloak/suit/shirt, we only count the outermost item so that it 1387. can be taken off without confirmation if final count ends up as 1 */ 1388. if (uarmc) 1389. MOREWORN(uarmc, Narmorpieces); 1390. else if (uarm) 1391. MOREWORN(uarm, Narmorpieces); 1392. else if (uarmu) 1393. MOREWORN(uarmu, Narmorpieces); 1394. if (!accessorizing) 1395. *which = otmp; /* default item iff Narmorpieces is 1 */ 1396. 1397. otmp = 0; 1398. MOREWORN(uleft, Naccessories); 1399. MOREWORN(uright, Naccessories); 1400. MOREWORN(uamul, Naccessories); 1401. MOREWORN(ublindf, Naccessories); 1402. if (accessorizing) 1403. *which = otmp; /* default item iff Naccessories is 1 */ 1404. #undef MOREWORN 1405. } 1406. 1407. /* take off one piece or armor or one accessory; 1408. shared by dotakeoff('T') and doremring('R') */ 1409. STATIC_OVL int 1410. armor_or_accessory_off(obj) 1411. struct obj *obj; 1412. { 1413. if (!(obj->owornmask & (W_ARMOR | W_ACCESSORY))) { 1414. You("are not wearing that."); 1415. return 0; 1416. } 1417. if (obj == uskin 1418. || ((obj == uarm) && uarmc) 1419. || ((obj == uarmu) && (uarmc || uarm))) { 1420. char why[QBUFSZ], what[QBUFSZ]; 1421. 1422. why[0] = what[0] = '\0'; 1423. if (obj != uskin) { 1424. if (uarmc) 1425. Strcat(what, cloak_simple_name(uarmc)); 1426. if ((obj == uarmu) && uarm) { 1427. if (uarmc) 1428. Strcat(what, " and "); 1429. Strcat(what, suit_simple_name(uarm)); 1430. } 1431. Sprintf(why, " without taking off your %s first", what); 1432. } else { 1433. Strcpy(why, "; it's embedded"); 1434. } 1435. You_cant("take that off%s.", why); 1436. return 0; 1437. } 1438. 1439. reset_remarm(); /* clear context.takeoff.mask and context.takeoff.what */ 1440. (void) select_off(obj); 1441. if (!context.takeoff.mask) 1442. return 0; 1443. /* none of armoroff()/Ring_/Amulet/Blindf_off() use context.takeoff.mask */ 1444. reset_remarm(); 1445. 1446. if (obj->owornmask & W_ARMOR) { 1447. (void) armoroff(obj); 1448. } else if (obj == uright || obj == uleft) { 1449. /* Sometimes we want to give the off_msg before removing and 1450. * sometimes after; for instance, "you were wearing a moonstone 1451. * ring (on right hand)" is desired but "you were wearing a 1452. * square amulet (being worn)" is not because of the redundant 1453. * "being worn". 1454. */ 1455. off_msg(obj); 1456. Ring_off(obj); 1457. } else if (obj == uamul) { 1458. Amulet_off(); 1459. off_msg(obj); 1460. } else if (obj == ublindf) { 1461. Blindf_off(obj); /* does its own off_msg */ 1462. } else { 1463. impossible("removing strange accessory?"); 1464. if (obj->owornmask) 1465. remove_worn_item(obj, FALSE); 1466. } 1467. return 1; 1468. } 1469. 1470. /* the 'T' command */ 1471. int 1472. dotakeoff() 1473. { 1474. struct obj *otmp = (struct obj *) 0; 1475. 1476. count_worn_stuff(&otmp, FALSE); 1477. if (!Narmorpieces && !Naccessories) { 1478. /* assert( GRAY_DRAGON_SCALES > YELLOW_DRAGON_SCALE_MAIL ); */ 1479. if (uskin) 1480. pline_The("%s merged with your skin!", 1481. uskin->otyp >= GRAY_DRAGON_SCALES 1482. ? "dragon scales are" 1483. : "dragon scale mail is"); 1484. else 1485. pline("Not wearing any armor or accessories."); 1486. return 0; 1487. } 1488. if (Narmorpieces != 1 || ParanoidRemove) 1489. otmp = getobj(clothes, "take off"); 1490. if (!otmp) 1491. return 0; 1492. 1493. return armor_or_accessory_off(otmp); 1494. } 1495. 1496. /* the 'R' command */ 1497. int 1498. doremring() 1499. { 1500. struct obj *otmp = 0; 1501. 1502. count_worn_stuff(&otmp, TRUE); 1503. if (!Naccessories && !Narmorpieces) { 1504. pline("Not wearing any accessories or armor."); 1505. return 0; 1506. } 1507. if (Naccessories != 1 || ParanoidRemove) 1508. otmp = getobj(accessories, "remove"); 1509. if (!otmp) 1510. return 0; 1511. 1512. return armor_or_accessory_off(otmp); 1513. } 1514. 1515. /* Check if something worn is cursed _and_ unremovable. */ 1516. int 1517. cursed(otmp) 1518. register struct obj *otmp; 1519. { 1520. if (!otmp) { 1521. impossible("cursed without otmp"); 1522. return 0; 1523. } 1524. /* Curses, like chickens, come home to roost. */ 1525. if ((otmp == uwep) ? welded(otmp) : (int) otmp->cursed) { 1526. boolean use_plural = (is_boots(otmp) || is_gloves(otmp) 1527. || otmp->otyp == LENSES || otmp->quan > 1L); 1528. 1529. You("can't. %s cursed.", use_plural ? "They are" : "It is"); 1530. otmp->bknown = TRUE; 1531. return 1; 1532. } 1533. return 0; 1534. } 1535. 1536. int 1537. armoroff(otmp) 1538. register struct obj *otmp; 1539. { 1540. register int delay = -objects[otmp->otyp].oc_delay; 1541. 1542. if (cursed(otmp)) 1543. return 0; 1544. if (delay) { 1545. nomul(delay); 1546. multi_reason = "disrobing"; 1547. if (is_helmet(otmp)) { 1548. /* ick... */ 1549. nomovemsg = !strcmp(helm_simple_name(otmp), "hat") 1550. ? "You finish taking off your hat." 1551. : "You finish taking off your helmet."; 1552. afternmv = Helmet_off; 1553. } else if (is_gloves(otmp)) { 1554. nomovemsg = "You finish taking off your gloves."; 1555. afternmv = Gloves_off; 1556. } else if (is_boots(otmp)) { 1557. nomovemsg = "You finish taking off your boots."; 1558. afternmv = Boots_off; 1559. } else { 1560. nomovemsg = "You finish taking off your suit."; 1561. afternmv = Armor_off; 1562. } 1563. } else { 1564. /* Be warned! We want off_msg after removing the item to 1565. * avoid "You were wearing ____ (being worn)." However, an 1566. * item which grants fire resistance might cause some trouble 1567. * if removed in Hell and lifesaving puts it back on; in this 1568. * case the message will be printed at the wrong time (after 1569. * the messages saying you died and were lifesaved). Luckily, 1570. * no cloak, shield, or fast-removable armor grants fire 1571. * resistance, so we can safely do the off_msg afterwards. 1572. * Rings do grant fire resistance, but for rings we want the 1573. * off_msg before removal anyway so there's no problem. Take 1574. * care in adding armors granting fire resistance; this code 1575. * might need modification. 1576. * 3.2 (actually 3.1 even): that comment is obsolete since 1577. * fire resistance is not required for Gehennom so setworn() 1578. * doesn't force the resistance granting item to be re-worn 1579. * after being lifesaved anymore. 1580. */ 1581. if (is_cloak(otmp)) 1582. (void) Cloak_off(); 1583. else if (is_shield(otmp)) 1584. (void) Shield_off(); 1585. else 1586. setworn((struct obj *) 0, otmp->owornmask & W_ARMOR); 1587. off_msg(otmp); 1588. } 1589. context.takeoff.mask = context.takeoff.what = 0L; 1590. return 1; 1591. } 1592. 1593. STATIC_OVL void 1594. already_wearing(cc) 1595. const char *cc; 1596. { 1597. You("are already wearing %s%c", cc, (cc == c_that_) ? '!' : '.'); 1598. } 1599. 1600. STATIC_OVL void 1601. already_wearing2(cc1, cc2) 1602. const char *cc1, *cc2; 1603. { 1604. You_cant("wear %s because you're wearing %s there already.", cc1, cc2); 1605. } 1606. 1607. /* 1608. * canwearobj checks to see whether the player can wear a piece of armor 1609. * 1610. * inputs: otmp (the piece of armor) 1611. * noisy (if TRUE give error messages, otherwise be quiet about it) 1612. * output: mask (otmp's armor type) 1613. */ 1614. int 1615. canwearobj(otmp, mask, noisy) 1616. struct obj *otmp; 1617. long *mask; 1618. boolean noisy; 1619. { 1620. int err = 0; 1621. const char *which; 1622. 1623. /* this is the same check as for 'W' (dowear), but different message, 1624. in case we get here via 'P' (doputon) */ 1625. if (verysmall(youmonst.data) || nohands(youmonst.data)) { 1626. if (noisy) 1627. You("can't wear any armor in your current form."); 1628. return 0; 1629. } 1630. 1631. which = is_cloak(otmp) 1632. ? c_cloak 1633. : is_shirt(otmp) 1634. ? c_shirt 1635. : is_suit(otmp) 1636. ? c_suit 1637. : 0; 1638. if (which && cantweararm(youmonst.data) 1639. /* same exception for cloaks as used in m_dowear() */ 1640. && (which != c_cloak || youmonst.data->msize != MZ_SMALL) 1641. && (racial_exception(&youmonst, otmp) < 1)) { 1642. if (noisy) 1643. pline_The("%s will not fit on your body.", which); 1644. return 0; 1645. } else if (otmp->owornmask & W_ARMOR) { 1646. if (noisy) 1647. already_wearing(c_that_); 1648. return 0; 1649. } 1650. 1651. if (welded(uwep) && bimanual(uwep) && (is_suit(otmp) || is_shirt(otmp))) { 1652. if (noisy) 1653. You("cannot do that while holding your %s.", 1654. is_sword(uwep) ? c_sword : c_weapon); 1655. return 0; 1656. } 1657. 1658. if (is_helmet(otmp)) { 1659. if (uarmh) { 1660. if (noisy) 1661. already_wearing(an(helm_simple_name(uarmh))); 1662. err++; 1663. } else if (Upolyd && has_horns(youmonst.data) && !is_flimsy(otmp)) { 1664. /* (flimsy exception matches polyself handling) */ 1665. if (noisy) 1666. pline_The("%s won't fit over your horn%s.", 1667. helm_simple_name(otmp), 1668. plur(num_horns(youmonst.data))); 1669. err++; 1670. } else 1671. *mask = W_ARMH; 1672. } else if (is_shield(otmp)) { 1673. if (uarms) { 1674. if (noisy) 1675. already_wearing(an(c_shield)); 1676. err++; 1677. } else if (uwep && bimanual(uwep)) { 1678. if (noisy) 1679. You("cannot wear a shield while wielding a two-handed %s.", 1680. is_sword(uwep) ? c_sword : (uwep->otyp == BATTLE_AXE) 1681. ? c_axe 1682. : c_weapon); 1683. err++; 1684. } else if (u.twoweap) { 1685. if (noisy) 1686. You("cannot wear a shield while wielding two weapons."); 1687. err++; 1688. } else 1689. *mask = W_ARMS; 1690. } else if (is_boots(otmp)) { 1691. if (uarmf) { 1692. if (noisy) 1693. already_wearing(c_boots); 1694. err++; 1695. } else if (Upolyd && slithy(youmonst.data)) { 1696. if (noisy) 1697. You("have no feet..."); /* not body_part(FOOT) */ 1698. err++; 1699. } else if (Upolyd && youmonst.data->mlet == S_CENTAUR) { 1700. /* break_armor() pushes boots off for centaurs, 1701. so don't let dowear() put them back on... */ 1702. if (noisy) 1703. pline("You have too many hooves to wear %s.", 1704. c_boots); /* makeplural(body_part(FOOT)) yields 1705. "rear hooves" which sounds odd */ 1706. err++; 1707. } else if (u.utrap 1708. && (u.utraptype == TT_BEARTRAP || u.utraptype == TT_INFLOOR 1709. || u.utraptype == TT_LAVA 1710. || u.utraptype == TT_BURIEDBALL)) { 1711. if (u.utraptype == TT_BEARTRAP) { 1712. if (noisy) 1713. Your("%s is trapped!", body_part(FOOT)); 1714. } else if (u.utraptype == TT_INFLOOR || u.utraptype == TT_LAVA) { 1715. if (noisy) 1716. Your("%s are stuck in the %s!", 1717. makeplural(body_part(FOOT)), surface(u.ux, u.uy)); 1718. } else { /*TT_BURIEDBALL*/ 1719. if (noisy) 1720. Your("%s is attached to the buried ball!", 1721. body_part(LEG)); 1722. } 1723. err++; 1724. } else 1725. *mask = W_ARMF; 1726. } else if (is_gloves(otmp)) { 1727. if (uarmg) { 1728. if (noisy) 1729. already_wearing(c_gloves); 1730. err++; 1731. } else if (welded(uwep)) { 1732. if (noisy) 1733. You("cannot wear gloves over your %s.", 1734. is_sword(uwep) ? c_sword : c_weapon); 1735. err++; 1736. } else 1737. *mask = W_ARMG; 1738. } else if (is_shirt(otmp)) { 1739. if (uarm || uarmc || uarmu) { 1740. if (uarmu) { 1741. if (noisy) 1742. already_wearing(an(c_shirt)); 1743. } else { 1744. if (noisy) 1745. You_cant("wear that over your %s.", 1746. (uarm && !uarmc) ? c_armor 1747. : cloak_simple_name(uarmc)); 1748. } 1749. err++; 1750. } else 1751. *mask = W_ARMU; 1752. } else if (is_cloak(otmp)) { 1753. if (uarmc) { 1754. if (noisy) 1755. already_wearing(an(cloak_simple_name(uarmc))); 1756. err++; 1757. } else 1758. *mask = W_ARMC; 1759. } else if (is_suit(otmp)) { 1760. if (uarmc) { 1761. if (noisy) 1762. You("cannot wear armor over a %s.", cloak_simple_name(uarmc)); 1763. err++; 1764. } else if (uarm) { 1765. if (noisy) 1766. already_wearing("some armor"); 1767. err++; 1768. } else 1769. *mask = W_ARM; 1770. } else { 1771. /* getobj can't do this after setting its allow_all flag; that 1772. happens if you have armor for slots that are covered up or 1773. extra armor for slots that are filled */ 1774. if (noisy) 1775. silly_thing("wear", otmp); 1776. err++; 1777. } 1778. /* Unnecessary since now only weapons and special items like pick-axes get 1779. * welded to your hand, not armor 1780. if (welded(otmp)) { 1781. if (!err++) { 1782. if (noisy) weldmsg(otmp); 1783. } 1784. } 1785. */ 1786. return !err; 1787. } 1788. 1789. STATIC_OVL int 1790. accessory_or_armor_on(obj) 1791. struct obj *obj; 1792. { 1793. long mask = 0L; 1794. boolean armor, ring, eyewear; 1795. 1796. if (obj->owornmask & (W_ACCESSORY | W_ARMOR)) { 1797. already_wearing(c_that_); 1798. return 0; 1799. } 1800. armor = (obj->oclass == ARMOR_CLASS); 1801. ring = (obj->oclass == RING_CLASS || obj->otyp == MEAT_RING); 1802. eyewear = (obj->otyp == BLINDFOLD || obj->otyp == TOWEL 1803. || obj->otyp == LENSES); 1804. /* checks which are performed prior to actually touching the item */ 1805. if (armor) { 1806. if (!canwearobj(obj, &mask, TRUE)) 1807. return 0; 1808. 1809. if (obj->otyp == HELM_OF_OPPOSITE_ALIGNMENT 1810. && qstart_level.dnum == u.uz.dnum) { /* in quest */ 1811. if (u.ualignbase[A_CURRENT] == u.ualignbase[A_ORIGINAL]) 1812. You("narrowly avoid losing all chance at your goal."); 1813. else /* converted */ 1814. You("are suddenly overcome with shame and change your mind."); 1815. u.ublessed = 0; /* lose your god's protection */ 1816. makeknown(obj->otyp); 1817. context.botl = 1; /*for AC after zeroing u.ublessed */ 1818. return 1; 1819. } 1820. } else { 1821. /* accessory */ 1822. if (ring) { 1823. char answer, qbuf[QBUFSZ]; 1824. int res = 0; 1825. 1826. if (nolimbs(youmonst.data)) { 1827. You("cannot make the ring stick to your body."); 1828. return 0; 1829. } 1830. if (uleft && uright) { 1831. There("are no more %s%s to fill.", 1832. humanoid(youmonst.data) ? "ring-" : "", 1833. makeplural(body_part(FINGER))); 1834. return 0; 1835. } 1836. if (uleft) { 1837. mask = RIGHT_RING; 1838. } else if (uright) { 1839. mask = LEFT_RING; 1840. } else { 1841. do { 1842. Sprintf(qbuf, "Which %s%s, Right or Left?", 1843. humanoid(youmonst.data) ? "ring-" : "", 1844. body_part(FINGER)); 1845. answer = yn_function(qbuf, "rl", '\0'); 1846. switch (answer) { 1847. case '\0': 1848. return 0; 1849. case 'l': 1850. case 'L': 1851. mask = LEFT_RING; 1852. break; 1853. case 'r': 1854. case 'R': 1855. mask = RIGHT_RING; 1856. break; 1857. } 1858. } while (!mask); 1859. } 1860. if (uarmg && uarmg->cursed) { 1861. res = !uarmg->bknown; 1862. uarmg->bknown = 1; 1863. You("cannot remove your gloves to put on the ring."); 1864. return res; /* uses move iff we learned gloves are cursed */ 1865. } 1866. if (uwep) { 1867. res = !uwep->bknown; /* check this before calling welded() */ 1868. if ((mask == RIGHT_RING || bimanual(uwep)) && welded(uwep)) { 1869. const char *hand = body_part(HAND); 1870. 1871. /* welded will set bknown */ 1872. if (bimanual(uwep)) 1873. hand = makeplural(hand); 1874. You("cannot free your weapon %s to put on the ring.", 1875. hand); 1876. return res; /* uses move iff we learned weapon is cursed */ 1877. } 1878. } 1879. } else if (obj->oclass == AMULET_CLASS) { 1880. if (uamul) { 1881. already_wearing("an amulet"); 1882. return 0; 1883. } 1884. } else if (eyewear) { 1885. if (ublindf) { 1886. if (ublindf->otyp == TOWEL) 1887. Your("%s is already covered by a towel.", 1888. body_part(FACE)); 1889. else if (ublindf->otyp == BLINDFOLD) { 1890. if (obj->otyp == LENSES) 1891. already_wearing2("lenses", "a blindfold"); 1892. else 1893. already_wearing("a blindfold"); 1894. } else if (ublindf->otyp == LENSES) { 1895. if (obj->otyp == BLINDFOLD) 1896. already_wearing2("a blindfold", "some lenses"); 1897. else 1898. already_wearing("some lenses"); 1899. } else { 1900. already_wearing(something); /* ??? */ 1901. } 1902. return 0; 1903. } 1904. } else { 1905. /* neither armor nor accessory */ 1906. You_cant("wear that!"); 1907. return 0; 1908. } 1909. } 1910. 1911. if (!retouch_object(&obj, FALSE)) 1912. return 1; /* costs a turn even though it didn't get worn */ 1913. 1914. if (armor) { 1915. int delay; 1916. 1917. /* if the armor is wielded, release it for wearing (won't be 1918. welded even if cursed; that only happens for weapons/weptools) */ 1919. if (obj->owornmask & W_WEAPON) 1920. remove_worn_item(obj, FALSE); 1921. /* 1922. * Setting obj->known=1 is done because setworn() causes hero's AC 1923. * to change so armor's +/- value is evident via the status line. 1924. * We used to set it here because of that, but then it would stick 1925. * if a nymph stole the armor before it was fully worn. Delay it 1926. * until the aftermv action. The player may still know this armor's 1927. * +/- amount if donning gets interrupted, but the hero won't. 1928. * 1929. obj->known = 1; 1930. */ 1931. setworn(obj, mask); 1932. /* if there's no delay, we'll execute 'aftermv' immediately */ 1933. if (obj == uarm) 1934. afternmv = Armor_on; 1935. else if (obj == uarmh) 1936. afternmv = Helmet_on; 1937. else if (obj == uarmg) 1938. afternmv = Gloves_on; 1939. else if (obj == uarmf) 1940. afternmv = Boots_on; 1941. else if (obj == uarms) 1942. afternmv = Shield_on; 1943. else if (obj == uarmc) 1944. afternmv = Cloak_on; 1945. else if (obj == uarmu) 1946. afternmv = Shirt_on; 1947. else 1948. panic("wearing armor not worn as armor? [%08lx]", obj->owornmask); 1949. 1950. delay = -objects[obj->otyp].oc_delay; 1951. if (delay) { 1952. nomul(delay); 1953. multi_reason = "dressing up"; 1954. nomovemsg = "You finish your dressing maneuver."; 1955. } else { 1956. unmul(""); /* call (*aftermv)(), clear it+nomovemsg+multi_reason */ 1957. on_msg(obj); 1958. } 1959. context.takeoff.mask = context.takeoff.what = 0L; 1960. } else { /* not armor */ 1961. boolean give_feedback = FALSE; 1962. 1963. /* [releasing wielded accessory handled in Xxx_on()] */ 1964. if (ring) { 1965. setworn(obj, mask); 1966. Ring_on(obj); 1967. give_feedback = TRUE; 1968. } else if (obj->oclass == AMULET_CLASS) { 1969. setworn(obj, W_AMUL); 1970. Amulet_on(); 1971. /* no feedback here if amulet of change got used up */ 1972. give_feedback = (uamul != 0); 1973. } else if (eyewear) { 1974. /* setworn() handled by Blindf_on() */ 1975. Blindf_on(obj); 1976. /* message handled by Blindf_on(); leave give_feedback False */ 1977. } 1978. /* feedback for ring or for amulet other than 'change' */ 1979. if (give_feedback && is_worn(obj)) 1980. prinv((char *) 0, obj, 0L); 1981. } 1982. return 1; 1983. } 1984. 1985. /* the 'W' command */ 1986. int 1987. dowear() 1988. { 1989. struct obj *otmp; 1990. 1991. /* cantweararm() checks for suits of armor, not what we want here; 1992. verysmall() or nohands() checks for shields, gloves, etc... */ 1993. if (verysmall(youmonst.data) || nohands(youmonst.data)) { 1994. pline("Don't even bother."); 1995. return 0; 1996. } 1997. if (uarm && uarmu && uarmc && uarmh && uarms && uarmg && uarmf 1998. && uleft && uright && uamul && ublindf) { 1999. /* 'W' message doesn't mention accessories */ 2000. You("are already wearing a full complement of armor."); 2001. return 0; 2002. } 2003. otmp = getobj(clothes, "wear"); 2004. return otmp ? accessory_or_armor_on(otmp) : 0; 2005. } 2006. 2007. /* the 'P' command */ 2008. int 2009. doputon() 2010. { 2011. struct obj *otmp; 2012. 2013. if (uleft && uright && uamul && ublindf 2014. && uarm && uarmu && uarmc && uarmh && uarms && uarmg && uarmf) { 2015. /* 'P' message doesn't mention armor */ 2016. Your("%s%s are full, and you're already wearing an amulet and %s.", 2017. humanoid(youmonst.data) ? "ring-" : "", 2018. makeplural(body_part(FINGER)), 2019. (ublindf->otyp == LENSES) ? "some lenses" : "a blindfold"); 2020. return 0; 2021. } 2022. otmp = getobj(accessories, "put on"); 2023. return otmp ? accessory_or_armor_on(otmp) : 0; 2024. } 2025. 2026. /* calculate current armor class */ 2027. void 2028. find_ac() 2029. { 2030. int uac = mons[u.umonnum].ac; /* base armor class for current form */ 2031. 2032. /* armor class from worn gear */ 2033. if (uarm) 2034. uac -= ARM_BONUS(uarm); 2035. if (uarmc) 2036. uac -= ARM_BONUS(uarmc); 2037. if (uarmh) 2038. uac -= ARM_BONUS(uarmh); 2039. if (uarmf) 2040. uac -= ARM_BONUS(uarmf); 2041. if (uarms) 2042. uac -= ARM_BONUS(uarms); 2043. if (uarmg) 2044. uac -= ARM_BONUS(uarmg); 2045. if (uarmu) 2046. uac -= ARM_BONUS(uarmu); 2047. if (uleft && uleft->otyp == RIN_PROTECTION) 2048. uac -= uleft->spe; 2049. if (uright && uright->otyp == RIN_PROTECTION) 2050. uac -= uright->spe; 2051. 2052. /* armor class from other sources */ 2053. if (HProtection & INTRINSIC) 2054. uac -= u.ublessed; 2055. uac -= u.uspellprot; 2056. 2057. /* [The magic binary numbers 127 and -128 should be replaced with the 2058. * mystic decimal numbers 99 and -99 which require no explanation to 2059. * the uninitiated and would cap the width of a status line value at 2060. * one less character.] 2061. */ 2062. if (uac < -128) 2063. uac = -128; /* u.uac is an schar */ 2064. else if (uac > 127) 2065. uac = 127; /* for completeness */ 2066. 2067. if (uac != u.uac) { 2068. u.uac = uac; 2069. context.botl = 1; 2070. } 2071. } 2072. 2073. void 2074. glibr() 2075. { 2076. register struct obj *otmp; 2077. int xfl = 0; 2078. boolean leftfall, rightfall, wastwoweap = FALSE; 2079. const char *otherwep = 0, *thiswep, *which, *hand; 2080. 2081. leftfall = (uleft && !uleft->cursed 2082. && (!uwep || !welded(uwep) || !bimanual(uwep))); 2083. rightfall = (uright && !uright->cursed && (!welded(uwep))); 2084. if (!uarmg && (leftfall || rightfall) && !nolimbs(youmonst.data)) { 2085. /* changed so cursed rings don't fall off, GAN 10/30/86 */ 2086. Your("%s off your %s.", 2087. (leftfall && rightfall) ? "rings slip" : "ring slips", 2088. (leftfall && rightfall) ? makeplural(body_part(FINGER)) 2089. : body_part(FINGER)); 2090. xfl++; 2091. if (leftfall) { 2092. otmp = uleft; 2093. Ring_off(uleft); 2094. dropx(otmp); 2095. } 2096. if (rightfall) { 2097. otmp = uright; 2098. Ring_off(uright); 2099. dropx(otmp); 2100. } 2101. } 2102. 2103. otmp = uswapwep; 2104. if (u.twoweap && otmp) { 2105. /* secondary weapon doesn't need nearly as much handling as 2106. primary; when in two-weapon mode, we know it's one-handed 2107. with something else in the other hand and also that it's 2108. a weapon or weptool rather than something unusual, plus 2109. we don't need to compare its type with the primary */ 2110. otherwep = is_sword(otmp) ? c_sword : weapon_descr(otmp); 2111. if (otmp->quan > 1L) 2112. otherwep = makeplural(otherwep); 2113. hand = body_part(HAND); 2114. which = "left "; 2115. Your("%s %s%s from your %s%s.", otherwep, xfl ? "also " : "", 2116. otense(otmp, "slip"), which, hand); 2117. xfl++; 2118. wastwoweap = TRUE; 2119. setuswapwep((struct obj *) 0); /* clears u.twoweap */ 2120. if (canletgo(otmp, "")) 2121. dropx(otmp); 2122. } 2123. otmp = uwep; 2124. if (otmp && !welded(otmp)) { 2125. long savequan = otmp->quan; 2126. 2127. /* nice wording if both weapons are the same type */ 2128. thiswep = is_sword(otmp) ? c_sword : weapon_descr(otmp); 2129. if (otherwep && strcmp(thiswep, makesingular(otherwep))) 2130. otherwep = 0; 2131. if (otmp->quan > 1L) { 2132. /* most class names for unconventional wielded items 2133. are ok, but if wielding multiple apples or rations 2134. we don't want "your foods slip", so force non-corpse 2135. food to be singular; skipping makeplural() isn't 2136. enough--we need to fool otense() too */ 2137. if (!strcmp(thiswep, "food")) 2138. otmp->quan = 1L; 2139. else 2140. thiswep = makeplural(thiswep); 2141. } 2142. hand = body_part(HAND); 2143. which = ""; 2144. if (bimanual(otmp)) 2145. hand = makeplural(hand); 2146. else if (wastwoweap) 2147. which = "right "; /* preceding msg was about left */ 2148. pline("%s %s%s %s%s from your %s%s.", 2149. !strncmp(thiswep, "corpse", 6) ? "The" : "Your", 2150. otherwep ? "other " : "", thiswep, xfl ? "also " : "", 2151. otense(otmp, "slip"), which, hand); 2152. /* xfl++; */ 2153. otmp->quan = savequan; 2154. setuwep((struct obj *) 0); 2155. if (canletgo(otmp, "")) 2156. dropx(otmp); 2157. } 2158. } 2159. 2160. struct obj * 2161. some_armor(victim) 2162. struct monst *victim; 2163. { 2164. register struct obj *otmph, *otmp; 2165. 2166. otmph = (victim == &youmonst) ? uarmc : which_armor(victim, W_ARMC); 2167. if (!otmph) 2168. otmph = (victim == &youmonst) ? uarm : which_armor(victim, W_ARM); 2169. if (!otmph) 2170. otmph = (victim == &youmonst) ? uarmu : which_armor(victim, W_ARMU); 2171. 2172. otmp = (victim == &youmonst) ? uarmh : which_armor(victim, W_ARMH); 2173. if (otmp && (!otmph || !rn2(4))) 2174. otmph = otmp; 2175. otmp = (victim == &youmonst) ? uarmg : which_armor(victim, W_ARMG); 2176. if (otmp && (!otmph || !rn2(4))) 2177. otmph = otmp; 2178. otmp = (victim == &youmonst) ? uarmf : which_armor(victim, W_ARMF); 2179. if (otmp && (!otmph || !rn2(4))) 2180. otmph = otmp; 2181. otmp = (victim == &youmonst) ? uarms : which_armor(victim, W_ARMS); 2182. if (otmp && (!otmph || !rn2(4))) 2183. otmph = otmp; 2184. return otmph; 2185. } 2186. 2187. /* used for praying to check and fix levitation trouble */ 2188. struct obj * 2189. stuck_ring(ring, otyp) 2190. struct obj *ring; 2191. int otyp; 2192. { 2193. if (ring != uleft && ring != uright) { 2194. impossible("stuck_ring: neither left nor right?"); 2195. return (struct obj *) 0; 2196. } 2197. 2198. if (ring && ring->otyp == otyp) { 2199. /* reasons ring can't be removed match those checked by select_off(); 2200. limbless case has extra checks because ordinarily it's temporary */ 2201. if (nolimbs(youmonst.data) && uamul 2202. && uamul->otyp == AMULET_OF_UNCHANGING && uamul->cursed) 2203. return uamul; 2204. if (welded(uwep) && (ring == uright || bimanual(uwep))) 2205. return uwep; 2206. if (uarmg && uarmg->cursed) 2207. return uarmg; 2208. if (ring->cursed) 2209. return ring; 2210. } 2211. /* either no ring or not right type or nothing prevents its removal */ 2212. return (struct obj *) 0; 2213. } 2214. 2215. /* also for praying; find worn item that confers "Unchanging" attribute */ 2216. struct obj * 2217. unchanger() 2218. { 2219. if (uamul && uamul->otyp == AMULET_OF_UNCHANGING) 2220. return uamul; 2221. return 0; 2222. } 2223. 2224. STATIC_PTR 2225. int 2226. select_off(otmp) 2227. register struct obj *otmp; 2228. { 2229. struct obj *why; 2230. char buf[BUFSZ]; 2231. 2232. if (!otmp) 2233. return 0; 2234. *buf = '\0'; /* lint suppression */ 2235. 2236. /* special ring checks */ 2237. if (otmp == uright || otmp == uleft) { 2238. if (nolimbs(youmonst.data)) { 2239. pline_The("ring is stuck."); 2240. return 0; 2241. } 2242. why = 0; /* the item which prevents ring removal */ 2243. if (welded(uwep) && (otmp == uright || bimanual(uwep))) { 2244. Sprintf(buf, "free a weapon %s", body_part(HAND)); 2245. why = uwep; 2246. } else if (uarmg && uarmg->cursed) { 2247. Sprintf(buf, "take off your %s", c_gloves); 2248. why = uarmg; 2249. } 2250. if (why) { 2251. You("cannot %s to remove the ring.", buf); 2252. why->bknown = TRUE; 2253. return 0; 2254. } 2255. } 2256. /* special glove checks */ 2257. if (otmp == uarmg) { 2258. if (welded(uwep)) { 2259. You("are unable to take off your %s while wielding that %s.", 2260. c_gloves, is_sword(uwep) ? c_sword : c_weapon); 2261. uwep->bknown = TRUE; 2262. return 0; 2263. } else if (Glib) { 2264. You_cant("take off the slippery %s with your slippery %s.", 2265. c_gloves, makeplural(body_part(FINGER))); 2266. return 0; 2267. } 2268. } 2269. /* special boot checks */ 2270. if (otmp == uarmf) { 2271. if (u.utrap && u.utraptype == TT_BEARTRAP) { 2272. pline_The("bear trap prevents you from pulling your %s out.", 2273. body_part(FOOT)); 2274. return 0; 2275. } else if (u.utrap && u.utraptype == TT_INFLOOR) { 2276. You("are stuck in the %s, and cannot pull your %s out.", 2277. surface(u.ux, u.uy), makeplural(body_part(FOOT))); 2278. return 0; 2279. } 2280. } 2281. /* special suit and shirt checks */ 2282. if (otmp == uarm || otmp == uarmu) { 2283. why = 0; /* the item which prevents disrobing */ 2284. if (uarmc && uarmc->cursed) { 2285. Sprintf(buf, "remove your %s", cloak_simple_name(uarmc)); 2286. why = uarmc; 2287. } else if (otmp == uarmu && uarm && uarm->cursed) { 2288. Sprintf(buf, "remove your %s", c_suit); 2289. why = uarm; 2290. } else if (welded(uwep) && bimanual(uwep)) { 2291. Sprintf(buf, "release your %s", 2292. is_sword(uwep) ? c_sword : (uwep->otyp == BATTLE_AXE) 2293. ? c_axe 2294. : c_weapon); 2295. why = uwep; 2296. } 2297. if (why) { 2298. You("cannot %s to take off %s.", buf, the(xname(otmp))); 2299. why->bknown = TRUE; 2300. return 0; 2301. } 2302. } 2303. /* basic curse check */ 2304. if (otmp == uquiver || (otmp == uswapwep && !u.twoweap)) { 2305. ; /* some items can be removed even when cursed */ 2306. } else { 2307. /* otherwise, this is fundamental */ 2308. if (cursed(otmp)) 2309. return 0; 2310. } 2311. 2312. if (otmp == uarm) 2313. context.takeoff.mask |= WORN_ARMOR; 2314. else if (otmp == uarmc) 2315. context.takeoff.mask |= WORN_CLOAK; 2316. else if (otmp == uarmf) 2317. context.takeoff.mask |= WORN_BOOTS; 2318. else if (otmp == uarmg) 2319. context.takeoff.mask |= WORN_GLOVES; 2320. else if (otmp == uarmh) 2321. context.takeoff.mask |= WORN_HELMET; 2322. else if (otmp == uarms) 2323. context.takeoff.mask |= WORN_SHIELD; 2324. else if (otmp == uarmu) 2325. context.takeoff.mask |= WORN_SHIRT; 2326. else if (otmp == uleft) 2327. context.takeoff.mask |= LEFT_RING; 2328. else if (otmp == uright) 2329. context.takeoff.mask |= RIGHT_RING; 2330. else if (otmp == uamul) 2331. context.takeoff.mask |= WORN_AMUL; 2332. else if (otmp == ublindf) 2333. context.takeoff.mask |= WORN_BLINDF; 2334. else if (otmp == uwep) 2335. context.takeoff.mask |= W_WEP; 2336. else if (otmp == uswapwep) 2337. context.takeoff.mask |= W_SWAPWEP; 2338. else if (otmp == uquiver) 2339. context.takeoff.mask |= W_QUIVER; 2340. 2341. else 2342. impossible("select_off: %s???", doname(otmp)); 2343. 2344. return 0; 2345. } 2346. 2347. STATIC_OVL struct obj * 2348. do_takeoff() 2349. { 2350. struct obj *otmp = (struct obj *) 0; 2351. struct takeoff_info *doff = &context.takeoff; 2352. 2353. context.takeoff.mask |= I_SPECIAL; /* set flag for cancel_doff() */ 2354. if (doff->what == W_WEP) { 2355. if (!cursed(uwep)) { 2356. setuwep((struct obj *) 0); 2357. You("are empty %s.", body_part(HANDED)); 2358. u.twoweap = FALSE; 2359. } 2360. } else if (doff->what == W_SWAPWEP) { 2361. setuswapwep((struct obj *) 0); 2362. You("no longer have a second weapon readied."); 2363. u.twoweap = FALSE; 2364. } else if (doff->what == W_QUIVER) { 2365. setuqwep((struct obj *) 0); 2366. You("no longer have ammunition readied."); 2367. } else if (doff->what == WORN_ARMOR) { 2368. otmp = uarm; 2369. if (!cursed(otmp)) 2370. (void) Armor_off(); 2371. } else if (doff->what == WORN_CLOAK) { 2372. otmp = uarmc; 2373. if (!cursed(otmp)) 2374. (void) Cloak_off(); 2375. } else if (doff->what == WORN_BOOTS) { 2376. otmp = uarmf; 2377. if (!cursed(otmp)) 2378. (void) Boots_off(); 2379. } else if (doff->what == WORN_GLOVES) { 2380. otmp = uarmg; 2381. if (!cursed(otmp)) 2382. (void) Gloves_off(); 2383. } else if (doff->what == WORN_HELMET) { 2384. otmp = uarmh; 2385. if (!cursed(otmp)) 2386. (void) Helmet_off(); 2387. } else if (doff->what == WORN_SHIELD) { 2388. otmp = uarms; 2389. if (!cursed(otmp)) 2390. (void) Shield_off(); 2391. } else if (doff->what == WORN_SHIRT) { 2392. otmp = uarmu; 2393. if (!cursed(otmp)) 2394. (void) Shirt_off(); 2395. } else if (doff->what == WORN_AMUL) { 2396. otmp = uamul; 2397. if (!cursed(otmp)) 2398. Amulet_off(); 2399. } else if (doff->what == LEFT_RING) { 2400. otmp = uleft; 2401. if (!cursed(otmp)) 2402. Ring_off(uleft); 2403. } else if (doff->what == RIGHT_RING) { 2404. otmp = uright; 2405. if (!cursed(otmp)) 2406. Ring_off(uright); 2407. } else if (doff->what == WORN_BLINDF) { 2408. if (!cursed(ublindf)) 2409. Blindf_off(ublindf); 2410. } else { 2411. impossible("do_takeoff: taking off %lx", doff->what); 2412. } 2413. context.takeoff.mask &= ~I_SPECIAL; /* clear cancel_doff() flag */ 2414. 2415. return otmp; 2416. } 2417. 2418. /* occupation callback for 'A' */ 2419. STATIC_PTR 2420. int 2421. take_off(VOID_ARGS) 2422. { 2423. register int i; 2424. register struct obj *otmp; 2425. struct takeoff_info *doff = &context.takeoff; 2426. 2427. if (doff->what) { 2428. if (doff->delay > 0) { 2429. doff->delay--; 2430. return 1; /* still busy */ 2431. } 2432. if ((otmp = do_takeoff()) != 0) 2433. off_msg(otmp); 2434. doff->mask &= ~doff->what; 2435. doff->what = 0L; 2436. } 2437. 2438. for (i = 0; takeoff_order[i]; i++) 2439. if (doff->mask & takeoff_order[i]) { 2440. doff->what = takeoff_order[i]; 2441. break; 2442. } 2443. 2444. otmp = (struct obj *) 0; 2445. doff->delay = 0; 2446. 2447. if (doff->what == 0L) { 2448. You("finish %s.", doff->disrobing); 2449. return 0; 2450. } else if (doff->what == W_WEP) { 2451. doff->delay = 1; 2452. } else if (doff->what == W_SWAPWEP) { 2453. doff->delay = 1; 2454. } else if (doff->what == W_QUIVER) { 2455. doff->delay = 1; 2456. } else if (doff->what == WORN_ARMOR) { 2457. otmp = uarm; 2458. /* If a cloak is being worn, add the time to take it off and put 2459. * it back on again. Kludge alert! since that time is 0 for all 2460. * known cloaks, add 1 so that it actually matters... 2461. */ 2462. if (uarmc) 2463. doff->delay += 2 * objects[uarmc->otyp].oc_delay + 1; 2464. } else if (doff->what == WORN_CLOAK) { 2465. otmp = uarmc; 2466. } else if (doff->what == WORN_BOOTS) { 2467. otmp = uarmf; 2468. } else if (doff->what == WORN_GLOVES) { 2469. otmp = uarmg; 2470. } else if (doff->what == WORN_HELMET) { 2471. otmp = uarmh; 2472. } else if (doff->what == WORN_SHIELD) { 2473. otmp = uarms; 2474. } else if (doff->what == WORN_SHIRT) { 2475. otmp = uarmu; 2476. /* add the time to take off and put back on armor and/or cloak */ 2477. if (uarm) 2478. doff->delay += 2 * objects[uarm->otyp].oc_delay; 2479. if (uarmc) 2480. doff->delay += 2 * objects[uarmc->otyp].oc_delay + 1; 2481. } else if (doff->what == WORN_AMUL) { 2482. doff->delay = 1; 2483. } else if (doff->what == LEFT_RING) { 2484. doff->delay = 1; 2485. } else if (doff->what == RIGHT_RING) { 2486. doff->delay = 1; 2487. } else if (doff->what == WORN_BLINDF) { 2488. /* [this used to be 2, but 'R' (and 'T') only require 1 turn to 2489. remove a blindfold, so 'A' shouldn't have been requiring 2] */ 2490. doff->delay = 1; 2491. } else { 2492. impossible("take_off: taking off %lx", doff->what); 2493. return 0; /* force done */ 2494. } 2495. 2496. if (otmp) 2497. doff->delay += objects[otmp->otyp].oc_delay; 2498. 2499. /* Since setting the occupation now starts the counter next move, that 2500. * would always produce a delay 1 too big per item unless we subtract 2501. * 1 here to account for it. 2502. */ 2503. if (doff->delay > 0) 2504. doff->delay--; 2505. 2506. set_occupation(take_off, doff->disrobing, 0); 2507. return 1; /* get busy */ 2508. } 2509. 2510. /* clear saved context to avoid inappropriate resumption of interrupted 'A' */ 2511. void 2512. reset_remarm() 2513. { 2514. context.takeoff.what = context.takeoff.mask = 0L; 2515. context.takeoff.disrobing[0] = '\0'; 2516. } 2517. 2518. /* the 'A' command -- remove multiple worn items */ 2519. int 2520. doddoremarm() 2521. { 2522. int result = 0; 2523. 2524. if (context.takeoff.what || context.takeoff.mask) { 2525. You("continue %s.", context.takeoff.disrobing); 2526. set_occupation(take_off, context.takeoff.disrobing, 0); 2527. return 0; 2528. } else if (!uwep && !uswapwep && !uquiver && !uamul && !ublindf && !uleft 2529. && !uright && !wearing_armor()) { 2530. You("are not wearing anything."); 2531. return 0; 2532. } 2533. 2534. add_valid_menu_class(0); /* reset */ 2535. if (flags.menu_style != MENU_TRADITIONAL 2536. || (result = ggetobj("take off", select_off, 0, FALSE, 2537. (unsigned *) 0)) < -1) 2538. result = menu_remarm(result); 2539. 2540. if (context.takeoff.mask) { 2541. /* default activity for armor and/or accessories, 2542. possibly combined with weapons */ 2543. (void) strncpy(context.takeoff.disrobing, "disrobing", CONTEXTVERBSZ); 2544. /* specific activity when handling weapons only */ 2545. if (!(context.takeoff.mask & ~W_WEAPON)) 2546. (void) strncpy(context.takeoff.disrobing, "disarming", 2547. CONTEXTVERBSZ); 2548. (void) take_off(); 2549. } 2550. /* The time to perform the command is already completely accounted for 2551. * in take_off(); if we return 1, that would add an extra turn to each 2552. * disrobe. 2553. */ 2554. return 0; 2555. } 2556. 2557. STATIC_OVL int 2558. menu_remarm(retry) 2559. int retry; 2560. { 2561. int n, i = 0; 2562. menu_item *pick_list; 2563. boolean all_worn_categories = TRUE; 2564. 2565. if (retry) { 2566. all_worn_categories = (retry == -2); 2567. } else if (flags.menu_style == MENU_FULL) { 2568. all_worn_categories = FALSE; 2569. n = query_category("What type of things do you want to take off?", 2570. invent, (WORN_TYPES | ALL_TYPES 2571. | UNPAID_TYPES | BUCX_TYPES), 2572. &pick_list, PICK_ANY); 2573. if (!n) 2574. return 0; 2575. for (i = 0; i < n; i++) { 2576. if (pick_list[i].item.a_int == ALL_TYPES_SELECTED) 2577. all_worn_categories = TRUE; 2578. else 2579. add_valid_menu_class(pick_list[i].item.a_int); 2580. } 2581. free((genericptr_t) pick_list); 2582. } else if (flags.menu_style == MENU_COMBINATION) { 2583. unsigned ggofeedback = 0; 2584. 2585. i = ggetobj("take off", select_off, 0, TRUE, &ggofeedback); 2586. if (ggofeedback & ALL_FINISHED) 2587. return 0; 2588. all_worn_categories = (i == -2); 2589. } 2590. if (menu_class_present('u') 2591. || menu_class_present('B') || menu_class_present('U') 2592. || menu_class_present('C') || menu_class_present('X')) 2593. all_worn_categories = FALSE; 2594. 2595. n = query_objlist("What do you want to take off?", &invent, 2596. (SIGNAL_NOMENU | USE_INVLET | INVORDER_SORT), 2597. &pick_list, PICK_ANY, 2598. all_worn_categories ? is_worn : is_worn_by_type); 2599. if (n > 0) { 2600. for (i = 0; i < n; i++) 2601. (void) select_off(pick_list[i].item.a_obj); 2602. free((genericptr_t) pick_list); 2603. } else if (n < 0 && flags.menu_style != MENU_COMBINATION) { 2604. There("is nothing else you can remove or unwield."); 2605. } 2606. return 0; 2607. } 2608. 2609. /* hit by destroy armor scroll/black dragon breath/monster spell */ 2610. int 2611. destroy_arm(atmp) 2612. register struct obj *atmp; 2613. { 2614. register struct obj *otmp; 2615. #define DESTROY_ARM(o) \ 2616. ((otmp = (o)) != 0 && (!atmp || atmp == otmp) \ 2617. && (!obj_resists(otmp, 0, 90)) \ 2618. ? (otmp->in_use = TRUE) \ 2619. : FALSE) 2620. 2621. if (DESTROY_ARM(uarmc)) { 2622. if (donning(otmp)) 2623. cancel_don(); 2624. Your("%s crumbles and turns to dust!", cloak_simple_name(uarmc)); 2625. (void) Cloak_off(); 2626. useup(otmp); 2627. } else if (DESTROY_ARM(uarm)) { 2628. if (donning(otmp)) 2629. cancel_don(); 2630. Your("armor turns to dust and falls to the %s!", surface(u.ux, u.uy)); 2631. (void) Armor_gone(); 2632. useup(otmp); 2633. } else if (DESTROY_ARM(uarmu)) { 2634. if (donning(otmp)) 2635. cancel_don(); 2636. Your("shirt crumbles into tiny threads and falls apart!"); 2637. (void) Shirt_off(); 2638. useup(otmp); 2639. } else if (DESTROY_ARM(uarmh)) { 2640. if (donning(otmp)) 2641. cancel_don(); 2642. Your("%s turns to dust and is blown away!", helm_simple_name(uarmh)); 2643. (void) Helmet_off(); 2644. useup(otmp); 2645. } else if (DESTROY_ARM(uarmg)) { 2646. if (donning(otmp)) 2647. cancel_don(); 2648. Your("gloves vanish!"); 2649. (void) Gloves_off(); 2650. useup(otmp); 2651. selftouch("You"); 2652. } else if (DESTROY_ARM(uarmf)) { 2653. if (donning(otmp)) 2654. cancel_don(); 2655. Your("boots disintegrate!"); 2656. (void) Boots_off(); 2657. useup(otmp); 2658. } else if (DESTROY_ARM(uarms)) { 2659. if (donning(otmp)) 2660. cancel_don(); 2661. Your("shield crumbles away!"); 2662. (void) Shield_off(); 2663. useup(otmp); 2664. } else { 2665. return 0; /* could not destroy anything */ 2666. } 2667. 2668. #undef DESTROY_ARM 2669. stop_occupation(); 2670. return 1; 2671. } 2672. 2673. void 2674. adj_abon(otmp, delta) 2675. register struct obj *otmp; 2676. register schar delta; 2677. { 2678. if (uarmg && uarmg == otmp && otmp->otyp == GAUNTLETS_OF_DEXTERITY) { 2679. if (delta) { 2680. makeknown(uarmg->otyp); 2681. ABON(A_DEX) += (delta); 2682. } 2683. context.botl = 1; 2684. } 2685. if (uarmh && uarmh == otmp && otmp->otyp == HELM_OF_BRILLIANCE) { 2686. if (delta) { 2687. makeknown(uarmh->otyp); 2688. ABON(A_INT) += (delta); 2689. ABON(A_WIS) += (delta); 2690. } 2691. context.botl = 1; 2692. } 2693. } 2694. 2695. /* decide whether a worn item is covered up by some other worn item, 2696. used for dipping into liquid and applying grease; 2697. some criteria are different than select_off()'s */ 2698. boolean 2699. inaccessible_equipment(obj, verb, only_if_known_cursed) 2700. struct obj *obj; 2701. const char *verb; /* "dip" or "grease", or null to avoid messages */ 2702. boolean only_if_known_cursed; /* ignore covering unless known to be cursed */ 2703. { 2704. static NEARDATA const char need_to_take_off_outer_armor[] = 2705. "need to take off %s to %s %s."; 2706. char buf[BUFSZ]; 2707. boolean anycovering = !only_if_known_cursed; /* more comprehensible... */ 2708. #define BLOCKSACCESS(x) (anycovering || ((x)->cursed && (x)->bknown)) 2709. 2710. if (!obj || !obj->owornmask) 2711. return FALSE; /* not inaccessible */ 2712. 2713. /* check for suit covered by cloak */ 2714. if (obj == uarm && uarmc && BLOCKSACCESS(uarmc)) { 2715. if (verb) { 2716. Strcpy(buf, yname(uarmc)); 2717. You(need_to_take_off_outer_armor, buf, verb, yname(obj)); 2718. } 2719. return TRUE; 2720. } 2721. /* check for shirt covered by suit and/or cloak */ 2722. if (obj == uarmu 2723. && ((uarm && BLOCKSACCESS(uarm)) || (uarmc && BLOCKSACCESS(uarmc)))) { 2724. if (verb) { 2725. char cloaktmp[QBUFSZ], suittmp[QBUFSZ]; 2726. /* if sameprefix, use yname and xname to get "your cloak and suit" 2727. or "Manlobbi's cloak and suit"; otherwise, use yname and yname 2728. to get "your cloak and Manlobbi's suit" or vice versa */ 2729. boolean sameprefix = (uarm && uarmc 2730. && !strcmp(shk_your(cloaktmp, uarmc), 2731. shk_your(suittmp, uarm))); 2732. 2733. *buf = '\0'; 2734. if (uarmc) 2735. Strcat(buf, yname(uarmc)); 2736. if (uarm && uarmc) 2737. Strcat(buf, " and "); 2738. if (uarm) 2739. Strcat(buf, sameprefix ? xname(uarm) : yname(uarm)); 2740. You(need_to_take_off_outer_armor, buf, verb, yname(obj)); 2741. } 2742. return TRUE; 2743. } 2744. /* check for ring covered by gloves */ 2745. if ((obj == uleft || obj == uright) && uarmg && BLOCKSACCESS(uarmg)) { 2746. if (verb) { 2747. Strcpy(buf, yname(uarmg)); 2748. You(need_to_take_off_outer_armor, buf, verb, yname(obj)); 2749. } 2750. return TRUE; 2751. } 2752. /* item is not inaccessible */ 2753. return FALSE; 2754. } 2755. 2756. /*do_wear.c*/