Wikia

Wikihack

Source:NetHack 3.3.0/do wear.c

2,032pages on
this wiki
Talk0

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

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

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

Around Wikia's network

Random Wiki