Wikia

Wikihack

Source:NetHack 3.1.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.1.0. To link to a particular line, write [[NetHack 3.1.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.1	92/12/13	*/
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.    #ifdef OVLB
8.    
9.    static int NEARDATA todelay;
10.   
11.   #endif /*OVLB */
12.   
13.   #ifndef OVLB
14.   
15.   STATIC_DCL long takeoff_mask, taking_off;
16.   
17.   #else /* OVLB */
18.   
19.   STATIC_OVL long NEARDATA takeoff_mask = 0L, NEARDATA taking_off = 0L;
20.   
21.   static const long NEARDATA takeoff_order[] = { WORN_BLINDF, 1L, /* weapon */
22.   	WORN_SHIELD, WORN_GLOVES, LEFT_RING, RIGHT_RING, WORN_CLOAK,
23.   	WORN_HELMET, WORN_AMUL, WORN_ARMOR,
24.   #ifdef TOURIST
25.   	WORN_SHIRT,
26.   #endif
27.   	WORN_BOOTS, 0L };
28.   
29.   static void FDECL(on_msg, (struct obj *));
30.   STATIC_PTR int NDECL(Armor_on);
31.   STATIC_PTR int NDECL(Boots_on);
32.   static int NDECL(Cloak_on);
33.   STATIC_PTR int NDECL(Helmet_on);
34.   STATIC_PTR int NDECL(Gloves_on);
35.   static void NDECL(Amulet_on);
36.   static void FDECL(Ring_off_or_gone, (struct obj *, BOOLEAN_P));
37.   STATIC_PTR int FDECL(select_off, (struct obj *));
38.   static struct obj *NDECL(do_takeoff);
39.   STATIC_PTR int NDECL(take_off);
40.   static void FDECL(already_wearing, (const char*));
41.   
42.   void
43.   off_msg(otmp) register struct obj *otmp; {
44.   	if(flags.verbose)
45.   	    You("were wearing %s.", doname(otmp));
46.   }
47.   
48.   /* for items that involve no delay */
49.   static void
50.   on_msg(otmp)
51.   register struct obj *otmp;
52.   {
53.   	if(flags.verbose)
54.   	    You("are now wearing %s.",
55.   		obj_is_pname(otmp) ? the(xname(otmp)) : an(xname(otmp)));
56.   }
57.   
58.   #endif /* OVLB */
59.   #ifdef OVL2
60.   
61.   boolean
62.   is_boots(otmp) register struct obj *otmp; {
63.   	return(otmp->otyp >= LOW_BOOTS &&
64.   		otmp->otyp <= LEVITATION_BOOTS);
65.   }
66.   
67.   boolean
68.   is_helmet(otmp) register struct obj *otmp; {
69.   	return(otmp->otyp >= ELVEN_LEATHER_HELM &&
70.   		otmp->otyp <= HELM_OF_TELEPATHY);
71.   }
72.   
73.   #endif /* OVLB */
74.   #ifdef OVL2
75.   
76.   boolean
77.   is_gloves(otmp) register struct obj *otmp; {
78.   	return(otmp->otyp >= LEATHER_GLOVES &&
79.   		otmp->otyp <= GAUNTLETS_OF_DEXTERITY);
80.   }
81.   
82.   #endif /* OVL2 */
83.   #ifdef OVLB
84.   
85.   boolean
86.   is_cloak(otmp) register struct obj *otmp; {
87.   	return(otmp->otyp >= MUMMY_WRAPPING &&
88.   		otmp->otyp <= CLOAK_OF_DISPLACEMENT);
89.   }
90.   
91.   boolean
92.   is_shield(otmp) register struct obj *otmp; {
93.   	return(otmp->otyp >= SMALL_SHIELD &&
94.   		otmp->otyp <= SHIELD_OF_REFLECTION);
95.   }
96.   
97.   /*
98.    * The Type_on() functions should be called *after* setworn().
99.    * The Type_off() functions call setworn() themselves.
100.   */
101.  
102.  STATIC_PTR
103.  int
104.  Boots_on() {
105.      long oldprop = u.uprops[objects[uarmf->otyp].oc_oprop].p_flgs & ~WORN_BOOTS;
106.  
107.      switch(uarmf->otyp) {
108.  	case LOW_BOOTS:
109.  	case IRON_SHOES:
110.  	case HIGH_BOOTS:
111.  	case JUMPING_BOOTS:
112.  		break;
113.  	case WATER_WALKING_BOOTS:
114.  		if (u.uinwater) spoteffects();
115.  		break;
116.  	case SPEED_BOOTS:
117.  		/* Speed boots are still better than intrinsic speed, */
118.  		/* though not better than potion speed */
119.  		if (!(oldprop & TIMEOUT)) {
120.  			makeknown(uarmf->otyp);
121.  			You("feel yourself speed up%s.",
122.  				oldprop ? " a bit more" : "");
123.  		}
124.  		break;
125.  	case ELVEN_BOOTS:
126.  		if (!oldprop) {
127.  			makeknown(uarmf->otyp);
128.  			You("walk very quietly.");
129.  		}
130.  		break;
131.  	case FUMBLE_BOOTS:
132.  		if (!(oldprop & ~TIMEOUT))
133.  			Fumbling += rnd(20);
134.  		break;
135.  	case LEVITATION_BOOTS:
136.  		if (!oldprop) {
137.  			makeknown(uarmf->otyp);
138.  			float_up();
139.  		}
140.  		break;
141.  	default: impossible("Unknown type of boots (%d)", uarmf->otyp);
142.      }
143.      return 0;
144.  }
145.  
146.  int
147.  Boots_off() {
148.      register struct obj *obj = uarmf;
149.  	/* For levitation, float_down() returns if Levitation, so we
150.  	 * must do a setworn() _before_ the levitation case.
151.  	 */
152.      long oldprop = u.uprops[objects[uarmf->otyp].oc_oprop].p_flgs & ~WORN_BOOTS;
153.  
154.      setworn((struct obj *)0, W_ARMF);
155.      switch(obj->otyp) {
156.  	case SPEED_BOOTS:
157.  		if (!(oldprop & TIMEOUT)) {
158.  			makeknown(obj->otyp);
159.  			You("feel yourself slow down%s.",
160.  				oldprop ? " a bit" : "");
161.  		}
162.  		break;
163.  	case WATER_WALKING_BOOTS:
164.  		if(is_pool(u.ux,u.uy) && !Levitation
165.  #ifdef POLYSELF
166.  		    && !is_flyer(uasmon) && !is_clinger(uasmon)
167.  #endif
168.  		    ) {
169.  			makeknown(obj->otyp);
170.  			/* make boots known in case you survive the drowning */
171.  			spoteffects();
172.  		}
173.  		break;
174.  	case ELVEN_BOOTS:
175.  		if (!oldprop) {
176.  			makeknown(obj->otyp);
177.  			You("sure are noisy.");
178.  		}
179.  		break;
180.  	case FUMBLE_BOOTS:
181.  		if (!(oldprop & ~TIMEOUT))
182.  			Fumbling = 0;
183.  		break;
184.  	case LEVITATION_BOOTS:
185.  		if (!oldprop) {
186.  			(void) float_down();
187.  			makeknown(obj->otyp);
188.  		}
189.  		break;
190.  	case LOW_BOOTS:
191.  	case IRON_SHOES:
192.  	case HIGH_BOOTS:
193.  	case JUMPING_BOOTS:
194.  		break;
195.  	default: impossible("Unknown type of boots (%d)", obj->otyp);
196.      }
197.      return 0;
198.  }
199.  
200.  static int
201.  Cloak_on() {
202.      long oldprop = u.uprops[objects[uarmc->otyp].oc_oprop].p_flgs & ~WORN_CLOAK;
203.  
204.      switch(uarmc->otyp) {
205.  	case ELVEN_CLOAK:
206.  	case CLOAK_OF_PROTECTION:
207.  	case CLOAK_OF_DISPLACEMENT:
208.  		makeknown(uarmc->otyp);
209.  		break;
210.  	case MUMMY_WRAPPING:
211.  	case ORCISH_CLOAK:
212.  	case DWARVISH_CLOAK:
213.  	case CLOAK_OF_MAGIC_RESISTANCE:
214.  		break;
215.  	case CLOAK_OF_INVISIBILITY:
216.  		if (!oldprop && !See_invisible && !Blind) {
217.  			makeknown(uarmc->otyp);
218.  			newsym(u.ux,u.uy);
219.  			pline("Suddenly you cannot see yourself.");
220.  		}
221.  		break;
222.  	case OILSKIN_CLOAK:
223.  		pline("The %s fits very tightly.",xname(uarmc));
224.  		break;
225.  	default: impossible("Unknown type of cloak (%d)", uarmc->otyp);
226.      }
227.      return 0;
228.  }
229.  
230.  int
231.  Cloak_off() {
232.      long oldprop = u.uprops[objects[uarmc->otyp].oc_oprop].p_flgs & ~WORN_CLOAK;
233.  
234.      switch(uarmc->otyp) {
235.  	case MUMMY_WRAPPING:
236.  	case ELVEN_CLOAK:
237.  	case ORCISH_CLOAK:
238.  	case DWARVISH_CLOAK:
239.  	case CLOAK_OF_PROTECTION:
240.  	case CLOAK_OF_MAGIC_RESISTANCE:
241.  	case CLOAK_OF_DISPLACEMENT:
242.  	case OILSKIN_CLOAK:
243.  		break;
244.  	case CLOAK_OF_INVISIBILITY:
245.  		if (!oldprop && !See_invisible && !Blind) {
246.  			makeknown(uarmc->otyp);
247.  			setworn((struct obj *)0, W_ARMC);
248.  			newsym(u.ux,u.uy);
249.  			pline("Suddenly you can see yourself.");
250.  			return 0;
251.  		}
252.  		break;
253.  	default: impossible("Unknown type of cloak (%d)", uarmc->otyp);
254.      }
255.      setworn((struct obj *)0, W_ARMC);
256.      return 0;
257.  }
258.  
259.  STATIC_PTR
260.  int
261.  Helmet_on()
262.  {
263.      switch(uarmh->otyp) {
264.  	case FEDORA:
265.  	case HELMET:
266.  	case DENTED_POT:
267.  	case ELVEN_LEATHER_HELM:
268.  	case DWARVISH_IRON_HELM:
269.  	case ORCISH_HELM:
270.  	case HELM_OF_TELEPATHY:
271.  		break;
272.  	case HELM_OF_BRILLIANCE:
273.  		if (uarmh->spe) {
274.  			ABON(A_INT) += uarmh->spe;
275.  			ABON(A_WIS) += uarmh->spe;
276.  			flags.botl = 1;
277.  			makeknown(uarmh->otyp);
278.  		}
279.  		break;
280.  	case HELM_OF_OPPOSITE_ALIGNMENT:
281.  		if (u.ualign.type == A_NEUTRAL)
282.  		    u.ualign.type = rn2(2) ? A_CHAOTIC : A_LAWFUL;
283.  		else u.ualign.type = -(u.ualign.type);
284.  		makeknown(uarmh->otyp);
285.  		flags.botl = 1;
286.  		break;
287.  	default: impossible("Unknown type of helm (%d)", uarmh->otyp);
288.      }
289.      return 0;
290.  }
291.  
292.  int
293.  Helmet_off()
294.  {
295.      switch(uarmh->otyp) {
296.  	case FEDORA:
297.  	case HELMET:
298.  	case DENTED_POT:
299.  	case ELVEN_LEATHER_HELM:
300.  	case DWARVISH_IRON_HELM:
301.  	case ORCISH_HELM:
302.  		break;
303.  	case HELM_OF_TELEPATHY:
304.  		/* need to update ability before calling see_monsters() */
305.  		setworn((struct obj *)0, W_ARMH);
306.  		see_monsters();
307.  		return 0;
308.  	case HELM_OF_BRILLIANCE:
309.  		if (uarmh->spe) {
310.  			ABON(A_INT) -= uarmh->spe;
311.  			ABON(A_WIS) -= uarmh->spe;
312.  			flags.botl = 1;
313.  		}
314.  		break;
315.  	case HELM_OF_OPPOSITE_ALIGNMENT:
316.  		u.ualign.type = u.ualignbase[0];
317.  		flags.botl = 1;
318.  		break;
319.  	default: impossible("Unknown type of helm (%d)", uarmh->otyp);
320.      }
321.      setworn((struct obj *)0, W_ARMH);
322.      return 0;
323.  }
324.  
325.  STATIC_PTR
326.  int
327.  Gloves_on() {
328.      long oldprop =
329.  	u.uprops[objects[uarmg->otyp].oc_oprop].p_flgs & ~(WORN_GLOVES | TIMEOUT);
330.  
331.      switch(uarmg->otyp) {
332.  	case LEATHER_GLOVES:
333.  		break;
334.  	case GAUNTLETS_OF_FUMBLING:
335.  		if (!oldprop)
336.  			Fumbling += rnd(20);
337.  		break;
338.  	case GAUNTLETS_OF_POWER:
339.  		makeknown(uarmg->otyp);
340.  		flags.botl = 1; /* taken care of in attrib.c */
341.  		break;
342.  	case GAUNTLETS_OF_DEXTERITY:
343.  		if (uarmg->spe) makeknown(uarmg->otyp);
344.  		ABON(A_DEX) += uarmg->spe;
345.  		flags.botl = 1;
346.  		break;
347.  	default: impossible("Unknown type of gloves (%d)", uarmg->otyp);
348.      }
349.      return 0;
350.  }
351.  
352.  int
353.  Gloves_off() {
354.      long oldprop =
355.  	u.uprops[objects[uarmg->otyp].oc_oprop].p_flgs & ~(WORN_GLOVES | TIMEOUT);
356.  
357.      switch(uarmg->otyp) {
358.  	case LEATHER_GLOVES:
359.  		break;
360.  	case GAUNTLETS_OF_FUMBLING:
361.  		if (!oldprop)
362.  			Fumbling = 0;
363.  		break;
364.  	case GAUNTLETS_OF_POWER:
365.  		makeknown(uarmg->otyp);
366.  		flags.botl = 1; /* taken care of in attrib.c */
367.  		break;
368.  	case GAUNTLETS_OF_DEXTERITY:
369.  		if (uarmg->spe) makeknown(uarmg->otyp);
370.  		ABON(A_DEX) -= uarmg->spe;
371.  		flags.botl = 1;
372.  		break;
373.  	default: impossible("Unknown type of gloves (%d)", uarmg->otyp);
374.      }
375.      setworn((struct obj *)0, W_ARMG);
376.      if (uwep && uwep->otyp == CORPSE && uwep->corpsenm == PM_COCKATRICE
377.  #ifdef POLYSELF
378.  	    && !(poly_when_stoned(uasmon) && polymon(PM_STONE_GOLEM))
379.  #endif
380.  							) {
381.  	/* Prevent wielding cockatrice when not wearing gloves */
382.  	You("wield the cockatrice corpse in your bare %s.",
383.  	    makeplural(body_part(HAND)));
384.  	You("turn to stone...");
385.  	killer_format = KILLED_BY_AN;
386.  	killer = "cockatrice corpse";
387.  	done(STONING);
388.      }
389.      return 0;
390.  }
391.  
392.  /*
393.  static int
394.  Shield_on() {
395.      switch(uarms->otyp) {
396.  	case SMALL_SHIELD:
397.  	case ELVEN_SHIELD:
398.  	case URUK_HAI_SHIELD:
399.  	case ORCISH_SHIELD:
400.  	case DWARVISH_ROUNDSHIELD:
401.  	case LARGE_SHIELD:
402.  	case SHIELD_OF_REFLECTION:
403.  		break;
404.  	default: impossible("Unknown type of shield (%d)", uarms->otyp);
405.      }
406.      return 0;
407.  }
408.  */
409.  
410.  int
411.  Shield_off() {
412.  /*
413.      switch(uarms->otyp) {
414.  	case SMALL_SHIELD:
415.  	case ELVEN_SHIELD:
416.  	case URUK_HAI_SHIELD:
417.  	case ORCISH_SHIELD:
418.  	case DWARVISH_ROUNDSHIELD:
419.  	case LARGE_SHIELD:
420.  	case SHIELD_OF_REFLECTION:
421.  		break;
422.  	default: impossible("Unknown type of shield (%d)", uarms->otyp);
423.      }
424.  */
425.      setworn((struct obj *)0, W_ARMS);
426.      return 0;
427.  }
428.  
429.  /* This must be done in worn.c, because one of the possible intrinsics conferred
430.   * is fire resistance, and we have to immediately set HFire_resistance in worn.c
431.   * since worn.c will check it before returning.
432.   */
433.  STATIC_PTR
434.  int
435.  Armor_on()
436.  {
437.      return 0;
438.  }
439.  
440.  int
441.  Armor_off()
442.  {
443.      setworn((struct obj *)0, W_ARM);
444.      return 0;
445.  }
446.  
447.  /* The gone functions differ from the off functions in that if you die from
448.   * taking it off and have life saving, you still die.
449.   */
450.  int
451.  Armor_gone()
452.  {
453.      setnotworn(uarm);
454.      return 0;
455.  }
456.  
457.  static void
458.  Amulet_on()
459.  {
460.      switch(uamul->otyp) {
461.  	case AMULET_OF_ESP:
462.  	case AMULET_OF_LIFE_SAVING:
463.  	case AMULET_VERSUS_POISON:
464.  	case AMULET_OF_REFLECTION:
465.  	case AMULET_OF_MAGICAL_BREATHING:
466.  	case FAKE_AMULET_OF_YENDOR:
467.  		break;
468.  	case AMULET_OF_CHANGE:
469.  		makeknown(AMULET_OF_CHANGE);
470.  		change_sex();
471.  		/* Don't use same message as polymorph */
472.  		You("are suddenly very %s!", flags.female ? "feminine"
473.  			: "masculine");
474.  		flags.botl = 1;
475.  		pline("The amulet disintegrates!");
476.  		useup(uamul);
477.  		break;
478.  	case AMULET_OF_STRANGULATION:
479.  		makeknown(AMULET_OF_STRANGULATION);
480.  		pline("It constricts your throat!");
481.  		Strangled = 6;
482.  		break;
483.  	case AMULET_OF_RESTFUL_SLEEP:
484.  		Sleeping = rnd(100);
485.  		break;
486.  	case AMULET_OF_YENDOR:
487.  		break;
488.      }
489.  }
490.  
491.  void
492.  Amulet_off()
493.  {
494.      switch(uamul->otyp) {
495.  	case AMULET_OF_ESP:
496.  		/* need to update ability before calling see_monsters() */
497.  		setworn((struct obj *)0, W_AMUL);
498.  		see_monsters();
499.  		return;
500.  	case AMULET_OF_LIFE_SAVING:
501.  	case AMULET_VERSUS_POISON:
502.  	case AMULET_OF_REFLECTION:
503.  	case FAKE_AMULET_OF_YENDOR:
504.  		break;
505.  	case AMULET_OF_MAGICAL_BREATHING:
506.  		if (Underwater) {
507.  			You("suddenly inhale an unhealthy amount of water!");
508.  			/* Magical_breathing has to be set
509.  			   off before calling drown() */
510.  			setworn((struct obj *)0, W_AMUL);
511.  			(void) drown();
512.  			return;
513.  		}
514.  		break;
515.  	case AMULET_OF_CHANGE:
516.  		impossible("Wearing an amulet of change?");
517.  		break;
518.  	case AMULET_OF_STRANGULATION:
519.  		if (Strangled) {
520.  			You("can breathe more easily!");
521.  			Strangled = 0;
522.  		}
523.  		break;
524.  	case AMULET_OF_RESTFUL_SLEEP:
525.  		Sleeping = 0;
526.  		break;
527.  	case AMULET_OF_YENDOR:
528.  		break;
529.      }
530.      setworn((struct obj *)0, W_AMUL);
531.  }
532.  
533.  void
534.  Ring_on(obj)
535.  register struct obj *obj;
536.  {
537.      long oldprop = u.uprops[objects[obj->otyp].oc_oprop].p_flgs & ~W_RING;
538.  
539.      /* might put on two rings of the same type */
540.      if((u.uprops[objects[obj->otyp].oc_oprop].p_flgs & W_RING) == W_RING)
541.  	oldprop = 1;
542.  
543.      switch(obj->otyp){
544.  	case RIN_TELEPORTATION:
545.  	case RIN_REGENERATION:
546.  	case RIN_SEARCHING:
547.  	case RIN_STEALTH:
548.  	case RIN_HUNGER:
549.  	case RIN_AGGRAVATE_MONSTER:
550.  	case RIN_POISON_RESISTANCE:
551.  	case RIN_FIRE_RESISTANCE:
552.  	case RIN_COLD_RESISTANCE:
553.  	case RIN_SHOCK_RESISTANCE:
554.  	case RIN_CONFLICT:
555.  	case RIN_WARNING:
556.  	case RIN_TELEPORT_CONTROL:
557.  #ifdef POLYSELF
558.  	case RIN_POLYMORPH:
559.  	case RIN_POLYMORPH_CONTROL:
560.  #endif
561.  		break;
562.  	case RIN_SEE_INVISIBLE:
563.  		/* can now see invisible monsters */
564.  		set_mimic_blocking(); /* do special mimic handling */
565.  		see_monsters();
566.  
567.  		if (Invis && !oldprop
568.  #ifdef POLYSELF
569.  				&& !perceives(uasmon)
570.  #endif
571.  							&& !Blind) {
572.  			newsym(u.ux,u.uy);
573.  			pline("Suddenly you can see yourself.");
574.  			makeknown(RIN_SEE_INVISIBLE);
575.  		}
576.  		break;
577.  	case RIN_INVISIBILITY:
578.  		if (!oldprop && !See_invisible && !Blind) {
579.  			makeknown(RIN_INVISIBILITY);
580.  			newsym(u.ux,u.uy);
581.  			Your("body takes on a %s transparency...",
582.  				Hallucination ? "normal" : "strange");
583.  		}
584.  		break;
585.  	case RIN_ADORNMENT:
586.  		ABON(A_CHA) += obj->spe;
587.  		flags.botl = 1;
588.  		if (obj->spe || objects[RIN_ADORNMENT].oc_name_known) {
589.  			makeknown(RIN_ADORNMENT);
590.  			obj->known = TRUE;
591.  		}
592.  		break;
593.  	case RIN_LEVITATION:
594.  		if(!oldprop) {
595.  			float_up();
596.  			makeknown(RIN_LEVITATION);
597.  			obj->known = TRUE;
598.  		}
599.  		break;
600.  	case RIN_GAIN_STRENGTH:
601.  		ABON(A_STR) += obj->spe;
602.  		flags.botl = 1;
603.  		if (obj->spe || objects[RIN_GAIN_STRENGTH].oc_name_known) {
604.  			makeknown(RIN_GAIN_STRENGTH);
605.  			obj->known = TRUE;
606.  		}
607.  		break;
608.  	case RIN_INCREASE_DAMAGE:
609.  		u.udaminc += obj->spe;
610.  		break;
611.  	case RIN_PROTECTION_FROM_SHAPE_CHAN:
612.  		rescham();
613.  		break;
614.  	case RIN_PROTECTION:
615.  		flags.botl = 1;
616.  		if (obj->spe || objects[RIN_PROTECTION].oc_name_known) {
617.  			makeknown(RIN_PROTECTION);
618.  			obj->known = TRUE;
619.  		}
620.  		break;
621.      }
622.  }
623.  
624.  static void
625.  Ring_off_or_gone(obj,gone)
626.  register struct obj *obj;
627.  boolean gone;
628.  {
629.      register long mask = obj->owornmask & W_RING;
630.  
631.      if(!(u.uprops[objects[obj->otyp].oc_oprop].p_flgs & mask))
632.  	impossible("Strange... I didn't know you had that ring.");
633.      if(gone) setnotworn(obj);
634.      else setworn((struct obj *)0, obj->owornmask);
635.      switch(obj->otyp) {
636.  	case RIN_TELEPORTATION:
637.  	case RIN_REGENERATION:
638.  	case RIN_SEARCHING:
639.  	case RIN_STEALTH:
640.  	case RIN_HUNGER:
641.  	case RIN_AGGRAVATE_MONSTER:
642.  	case RIN_POISON_RESISTANCE:
643.  	case RIN_FIRE_RESISTANCE:
644.  	case RIN_COLD_RESISTANCE:
645.  	case RIN_SHOCK_RESISTANCE:
646.  	case RIN_CONFLICT:
647.  	case RIN_WARNING:
648.  	case RIN_TELEPORT_CONTROL:
649.  #ifdef POLYSELF
650.  	case RIN_POLYMORPH:
651.  	case RIN_POLYMORPH_CONTROL:
652.  #endif
653.  		break;
654.  	case RIN_SEE_INVISIBLE:
655.  		/* Make invisible monsters go away */
656.  		if (!See_invisible) {
657.  		    set_mimic_blocking(); /* do special mimic handling */
658.  		    see_monsters();
659.  		}
660.  
661.  		if (Invisible && !Blind) {
662.  			newsym(u.ux,u.uy);
663.  			pline("Suddenly you cannot see yourself.");
664.  			makeknown(RIN_SEE_INVISIBLE);
665.  		}
666.  		break;
667.  	case RIN_INVISIBILITY:
668.  		if (!(Invisible & ~W_RING) && !See_invisible && !Blind) {
669.  			newsym(u.ux,u.uy);
670.  			Your("body seems to unfade...");
671.  			makeknown(RIN_INVISIBILITY);
672.  		}
673.  		break;
674.  	case RIN_ADORNMENT:
675.  		ABON(A_CHA) -= obj->spe;
676.  		flags.botl = 1;
677.  		break;
678.  	case RIN_LEVITATION:
679.  		(void) float_down();
680.  		if (!Levitation) makeknown(RIN_LEVITATION);
681.  		break;
682.  	case RIN_GAIN_STRENGTH:
683.  		ABON(A_STR) -= obj->spe;
684.  		flags.botl = 1;
685.  		break;
686.  	case RIN_INCREASE_DAMAGE:
687.  		u.udaminc -= obj->spe;
688.  		break;
689.  	case RIN_PROTECTION_FROM_SHAPE_CHAN:
690.  		/* If you're no longer protected, let the chameleons
691.  		 * change shape again -dgk
692.  		 */
693.  		restartcham();
694.  		break;
695.      }
696.  }
697.  
698.  void
699.  Ring_off(obj)
700.  struct obj *obj;
701.  {
702.  	Ring_off_or_gone(obj,FALSE);
703.  }
704.  
705.  void
706.  Ring_gone(obj)
707.  struct obj *obj;
708.  {
709.  	Ring_off_or_gone(obj,TRUE);
710.  }
711.  
712.  void
713.  Blindf_on(otmp)
714.  register struct obj *otmp;
715.  {
716.  	long already_blinded = Blinded;
717.  	setworn(otmp, W_TOOL);
718.  	if (otmp->otyp == TOWEL && flags.verbose)
719.  	    You("wrap %s around your %s.", an(xname(otmp)), body_part(HEAD));
720.  	on_msg(otmp);
721.  	if (!already_blinded) {
722.  	    if (Punished) set_bc(0);	/* Set ball&chain variables before */
723.  					/* the hero goes blind.		   */
724.  	    if (Telepat) see_monsters();/* sense monsters */
725.  	    vision_full_recalc = 1;	/* recalc vision limits */
726.  	    flags.botl = 1;
727.  	}
728.  }
729.  
730.  void
731.  Blindf_off(otmp)
732.  register struct obj *otmp;
733.  {
734.  	setworn((struct obj *)0, otmp->owornmask);
735.  	off_msg(otmp);
736.  	if (!Blinded) {
737.  	    if (Telepat) see_monsters();/* no longer sense monsters */
738.  	    vision_full_recalc = 1;	/* recalc vision limits */
739.  	    flags.botl = 1;
740.  	} else
741.  	    You("still cannot see.");
742.  }
743.  
744.  /* called in main to set intrinsics of worn start-up items */
745.  void
746.  set_wear() {
747.  	if (uarm)  (void) Armor_on();
748.  	if (uarmc) (void) Cloak_on();
749.  	if (uarmf) (void) Boots_on();
750.  	if (uarmg) (void) Gloves_on();
751.  	if (uarmh) (void) Helmet_on();
752.  /*	if (uarms) (void) Shield_on(); */
753.  }
754.  
755.  boolean
756.  donning(otmp)
757.  register struct obj *otmp;
758.  {
759.      return (otmp == uarmf && (afternmv == Boots_on || afternmv == Boots_off))
760.  	|| (otmp == uarmh && (afternmv == Helmet_on || afternmv == Helmet_off))
761.  	|| (otmp == uarmg && (afternmv == Gloves_on || afternmv == Gloves_off))
762.  	|| (otmp == uarm && (afternmv == Armor_on || afternmv == Armor_off));
763.  }
764.  
765.  void
766.  cancel_don()
767.  {
768.  	/* the piece of armor we were donning/doffing has vanished, so stop
769.  	 * wasting time on it (and don't dereference it when donning would
770.  	 * otherwise finish)
771.  	 */
772.  	afternmv = 0;
773.  	nomovemsg = NULL;
774.  	multi = 0;
775.  }
776.  
777.  static const char NEARDATA clothes[] = {ARMOR_CLASS, 0};
778.  static const char NEARDATA accessories[] = {RING_CLASS, AMULET_CLASS, TOOL_CLASS, 0};
779.  
780.  int
781.  dotakeoff()
782.  {
783.  	register struct obj *otmp = (struct obj *)0;
784.  	int armorpieces = 0;
785.  
786.  #define MOREARM(x) if (x) { armorpieces++; otmp = x; }
787.  	MOREARM(uarmh);
788.  	MOREARM(uarms);
789.  	MOREARM(uarmg);
790.  	MOREARM(uarmf);
791.  	if (uarmc) {
792.  		armorpieces++;
793.  		otmp = uarmc;
794.  	} else if (uarm) {
795.  		armorpieces++;
796.  		otmp = uarm;
797.  #ifdef TOURIST
798.  	} else if (uarmu) {
799.  		armorpieces++;
800.  		otmp = uarmu;
801.  #endif
802.  	}
803.  	if (!armorpieces) {
804.  #ifdef POLYSELF
805.  		if (uskin)
806.  		    pline("The dragon scale mail is merged with your skin!");
807.  		else
808.  #endif
809.  		    pline("Not wearing any armor.");
810.  		return 0;
811.  	}
812.  	if (armorpieces > 1)
813.  		otmp = getobj(clothes, "take off");
814.  	if (otmp == 0) return(0);
815.  	if (!(otmp->owornmask & W_ARMOR)) {
816.  		You("are not wearing that.");
817.  		return(0);
818.  	}
819.  	if (((otmp == uarm) && (uarmc))
820.  #ifdef TOURIST
821.  				|| ((otmp == uarmu) && (uarmc || uarm))
822.  #endif
823.  								) {
824.  		You("can't take that off.");
825.  		return(0);
826.  	}
827.  	if(otmp == uarmg && welded(uwep)) {
828.      You("seem unable to take off the gloves while holding your %s.",
829.  	  is_sword(uwep) ? "sword" : "weapon");
830.  		uwep->bknown = TRUE;
831.  		return(0);
832.  	}
833.  	if(otmp == uarmg && Glib) {
834.      You("can't remove the slippery gloves with your slippery fingers.");
835.  		return(0);
836.  	}
837.  	if(otmp == uarmf && u.utrap && (u.utraptype == TT_BEARTRAP ||
838.  					u.utraptype == TT_INFLOOR)) { /* -3. */
839.  	    if(u.utraptype == TT_BEARTRAP)
840.  		pline("The bear trap prevents you from pulling your %s out.",
841.  		      body_part(FOOT));
842.  	    else
843.  		You("are stuck in the floor, and cannot pull your %s out.",
844.  		     makeplural(body_part(FOOT)));
845.  		return(0);
846.  	}
847.  	reset_remarm();			/* since you may change ordering */
848.  	(void) armoroff(otmp);
849.  	return(1);
850.  }
851.  
852.  int
853.  doremring() {
854.  #ifdef GCC_WARN
855.  	register struct obj *otmp = (struct obj *)0;
856.  		/* suppress "may be used uninitialized" warning */
857.  #else
858.  	register struct obj *otmp;
859.  #endif
860.  	int Accessories = 0;
861.  
862.  #define MOREACC(x) if (x) { Accessories++; otmp = x; }
863.  	MOREACC(uleft);
864.  	MOREACC(uright);
865.  	MOREACC(uamul);
866.  	MOREACC(ublindf);
867.  
868.  	if(!Accessories) {
869.  		pline("Not wearing any accessories.");
870.  		return(0);
871.  	}
872.  	if (Accessories != 1) otmp = getobj(accessories, "take off");
873.  	if(!otmp) return(0);
874.  	if(!(otmp->owornmask & (W_RING | W_AMUL | W_TOOL))) {
875.  		You("are not wearing that.");
876.  		return(0);
877.  	}
878.  	if(cursed(otmp)) return(0);
879.  	if(otmp->oclass == RING_CLASS) {
880.  #ifdef POLYSELF
881.  		if (nolimbs(uasmon)) {
882.  			pline("It seems to be stuck.");
883.  			return(0);
884.  		}
885.  #endif
886.  		if (uarmg && uarmg->cursed) {
887.  			uarmg->bknown = TRUE;
888.  You("seem unable to remove your ring without taking off your gloves.");
889.  			return(0);
890.  		}
891.  		if (welded(uwep) && bimanual(uwep)) {
892.  			uwep->bknown = TRUE;
893.  You("seem unable to remove the ring while your hands hold your %s.",
894.  				is_sword(uwep) ? "sword" : "weapon");
895.  			return(0);
896.  		}
897.  		if (welded(uwep) && otmp==uright) {
898.  			uwep->bknown = TRUE;
899.  You("seem unable to remove the ring while your right hand holds your %s.",
900.  				is_sword(uwep) ? "sword" : "weapon");
901.  			return(0);
902.  		}
903.  		/* Sometimes we want to give the off_msg before removing and
904.  		 * sometimes after; for instance, "you were wearing a moonstone
905.  		 * ring (on right hand)" is desired but "you were wearing a
906.  		 * square amulet (being worn)" is not because of the redundant
907.  		 * "being worn".
908.  		 */
909.  		off_msg(otmp);
910.  		Ring_off(otmp);
911.  	} else if(otmp->oclass == AMULET_CLASS) {
912.  		Amulet_off();
913.  		off_msg(otmp);
914.  	} else Blindf_off(otmp); /* does its own off_msg */
915.  	return(1);
916.  }
917.  
918.  int
919.  cursed(otmp) register struct obj *otmp; {
920.  	/* Curses, like chickens, come home to roost. */
921.  	if(otmp->cursed){
922.  		You("can't.  %s to be cursed.",
923.  			(is_boots(otmp) || is_gloves(otmp) || otmp->quan > 1L)
924.  			? "They seem" : "It seems");
925.  		otmp->bknown = TRUE;
926.  		return(1);
927.  	}
928.  	return(0);
929.  }
930.  
931.  int
932.  armoroff(otmp) register struct obj *otmp; {
933.  	register int delay = -objects[otmp->otyp].oc_delay;
934.  
935.  	if(cursed(otmp)) return(0);
936.  	if(delay) {
937.  		nomul(delay);
938.  		if (is_helmet(otmp)) {
939.  			nomovemsg = "You finish taking off your helmet.";
940.  			afternmv = Helmet_off;
941.  		     }
942.  		else if (is_gloves(otmp)) {
943.  			nomovemsg = "You finish taking off your gloves.";
944.  			afternmv = Gloves_off;
945.  		     }
946.  		else if (is_boots(otmp)) {
947.  			nomovemsg = "You finish taking off your boots.";
948.  			afternmv = Boots_off;
949.  		     }
950.  		else {
951.  			nomovemsg = "You finish taking off your suit.";
952.  			afternmv = Armor_off;
953.  		}
954.  	} else {
955.  		/* Be warned!  We want off_msg after removing the item to
956.  		 * avoid "You were wearing ____ (being worn)."  However, an
957.  		 * item which grants fire resistance might cause some trouble
958.  		 * if removed in Hell and lifesaving puts it back on; in this
959.  		 * case the message will be printed at the wrong time (after
960.  		 * the messages saying you died and were lifesaved).  Luckily,
961.  		 * no cloak, shield, or fast-removable armor grants fire
962.  		 * resistance, so we can safely do the off_msg afterwards.
963.  		 * Rings do grant fire resistance, but for rings we want the
964.  		 * off_msg before removal anyway so there's no problem.  Take
965.  		 * care in adding armors granting fire resistance; this code
966.  		 * might need modification.
967.  		 */
968.  		if(is_cloak(otmp))
969.  			(void) Cloak_off();
970.  		else if(is_shield(otmp))
971.  			(void) Shield_off();
972.  		else setworn((struct obj *)0, otmp->owornmask & W_ARMOR);
973.  		off_msg(otmp);
974.  	}
975.  	takeoff_mask = taking_off = 0L;
976.  	return(1);
977.  }
978.  
979.  static void
980.  already_wearing(cc)
981.  const char *cc;
982.  {
983.  	You("are already wearing %s", cc);
984.  }
985.  
986.  int
987.  dowear()
988.  {
989.  	register struct obj *otmp;
990.  	register int delay;
991.  	register int err = 0;
992.  	long mask = 0;
993.  
994.  #ifdef POLYSELF
995.  	/* cantweararm checks for suits of armor */
996.  	/* verysmall or nohands checks for shields, gloves, etc... */
997.  	if ((verysmall(uasmon) || nohands(uasmon))) {
998.  		pline("Don't even bother.");
999.  		return(0);
1000. 	}
1001. #endif
1002. 	otmp = getobj(clothes, "wear");
1003. 	if(!otmp) return(0);
1004. #ifdef POLYSELF
1005. 	if (cantweararm(uasmon) && !is_shield(otmp) &&
1006. 			!is_helmet(otmp) && !is_gloves(otmp) &&
1007. 			!is_boots(otmp)) {
1008. 		pline("The %s will not fit on your body.",
1009. 			is_cloak(otmp) ? "cloak" :
1010. # ifdef TOURIST
1011. 			otmp->otyp == HAWAIIAN_SHIRT ? "shirt" :
1012. # endif
1013. 			"suit");
1014. 		return(0);
1015. 	}
1016. #endif
1017. 	if(otmp->owornmask & W_ARMOR) {
1018. 		already_wearing("that!");
1019. 		return(0);
1020. 	}
1021. 	if(is_helmet(otmp)) {
1022. 		if(uarmh) {
1023. 			already_wearing("a helmet.");
1024. 			err++;
1025. 		} else
1026. 			mask = W_ARMH;
1027. 	} else if(is_shield(otmp)){
1028. 		if(uarms) {
1029. 			already_wearing("a shield.");
1030. 			err++;
1031. 		}
1032. 		if(uwep && bimanual(uwep)) {
1033. 		    You("cannot wear a shield while wielding a two-handed %s.",
1034. 			is_sword(uwep) ? "sword" :
1035. 				uwep->otyp == BATTLE_AXE ? "axe" : "weapon");
1036. 			err++;
1037. 		}
1038. 		if(!err) mask = W_ARMS;
1039. 	} else if(is_boots(otmp)) {
1040. 		   if(uarmf) {
1041. 			already_wearing("boots.");
1042. 			err++;
1043. 		   } if (u.utrap && (u.utraptype == TT_BEARTRAP ||
1044. 				     u.utraptype == TT_INFLOOR)) {
1045. 		       if (u.utraptype == TT_BEARTRAP)
1046. 			   Your("%s is trapped!", body_part(FOOT));
1047. 		       else
1048. 			   Your("%s are stuck in the floor!",
1049. 				makeplural(body_part(FOOT)));
1050. 		       err++;
1051. 		   } else
1052. 			mask = W_ARMF;
1053. 	} else if(is_gloves(otmp)) {
1054. 		if(uarmg) {
1055. 			already_wearing("gloves.");
1056. 			err++;
1057. 		} else
1058. 		if (welded(uwep)) {
1059. 			You("cannot wear gloves over your %s.",
1060. 			      is_sword(uwep) ? "sword" : "weapon");
1061. 			err++;
1062. 		} else
1063. 			mask = W_ARMG;
1064. #ifdef TOURIST
1065. 	} else if( otmp->otyp == HAWAIIAN_SHIRT ) {
1066. 		if (uarm || uarmc || uarmu) {
1067. 			if(uarmu)
1068. 			   already_wearing("a shirt.");
1069. 			else
1070. 			   You("can't wear that over your %s.",
1071. 				 (uarm && !uarmc) ? "armor" : "cloak");
1072. 			err++;
1073. 		} else
1074. 			mask = W_ARMU;
1075. #endif
1076. 	} else if(is_cloak(otmp)) {
1077. 		if(uarmc) {
1078. 			already_wearing("a cloak.");
1079. 			err++;
1080. 		} else
1081. 			mask = W_ARMC;
1082. 	} else {
1083. 		if(uarmc) {
1084. 			You("cannot wear armor over a cloak.");
1085. 			err++;
1086. 		} else if(uarm) {
1087. 			already_wearing("some armor.");
1088. 			err++;
1089. 		}
1090. 		if(!err) mask = W_ARM;
1091. 	}
1092. /* Unnecessary since now only weapons and special items like pick-axes get
1093.  * welded to your hand, not armor
1094. 	if(welded(otmp)) {
1095. 		if(!err++)
1096. 			weldmsg(otmp, FALSE);
1097. 	}
1098.  */
1099. 	if(err) return(0);
1100. 
1101. 	otmp->known = TRUE;
1102. 	if(otmp == uwep)
1103. 		setuwep((struct obj *)0);
1104. 	setworn(otmp, mask);
1105. 	delay = -objects[otmp->otyp].oc_delay;
1106. 	if(delay){
1107. 		nomul(delay);
1108. 		if(is_boots(otmp)) afternmv = Boots_on;
1109. 		if(is_helmet(otmp)) afternmv = Helmet_on;
1110. 		if(is_gloves(otmp)) afternmv = Gloves_on;
1111. 		if(otmp == uarm) afternmv = Armor_on;
1112. 		nomovemsg = "You finish your dressing maneuver.";
1113. 	} else {
1114. 		if(is_cloak(otmp)) (void) Cloak_on();
1115. /*		if(is_shield(otmp)) (void) Shield_on(); */
1116. 		on_msg(otmp);
1117. 	}
1118. 	takeoff_mask = taking_off = 0L;
1119. 	return(1);
1120. }
1121. 
1122. int
1123. doputon() {
1124. 	register struct obj *otmp;
1125. 	long mask = 0L;
1126. 
1127. 	if(uleft && uright && uamul && ublindf) {
1128. #ifdef POLYSELF
1129. 		Your("%s%s are full, and you're already wearing an amulet and a blindfold.",
1130. 			humanoid(uasmon) ? "ring-" : "",
1131. 			makeplural(body_part(FINGER)));
1132. #else
1133. 		Your("ring-fingers are full, and you're already wearing an amulet and a blindfold.");
1134. #endif
1135. 		return(0);
1136. 	}
1137. 	otmp = getobj(accessories, "wear");
1138. 	if(!otmp) return(0);
1139. 	if(otmp->owornmask & (W_RING | W_AMUL | W_TOOL)) {
1140. 		already_wearing("that!");
1141. 		return(0);
1142. 	}
1143. 	if(welded(otmp)) {
1144. 		weldmsg(otmp, TRUE);
1145. 		return(0);
1146. 	}
1147. 	if(otmp == uwep)
1148. 		setuwep((struct obj *)0);
1149. 	if(otmp->oclass == RING_CLASS) {
1150. #ifdef POLYSELF
1151. 		if(nolimbs(uasmon)) {
1152. 			You("cannot make the ring stick to your body.");
1153. 			return(0);
1154. 		}
1155. #endif
1156. 		if(uleft && uright){
1157. #ifdef POLYSELF
1158. 			pline("There are no more %s%s to fill.",
1159. 				humanoid(uasmon) ? "ring-" : "",
1160. 				makeplural(body_part(FINGER)));
1161. #else
1162. 			pline("There are no more ring-fingers to fill.");
1163. #endif
1164. 			return(0);
1165. 		}
1166. 		if(uleft) mask = RIGHT_RING;
1167. 		else if(uright) mask = LEFT_RING;
1168. 		else do {
1169. 			char qbuf[QBUFSZ];
1170. 			char answer;
1171. 
1172. #ifdef POLYSELF
1173. 			Sprintf(qbuf, "What %s%s, Right or Left?",
1174. 				humanoid(uasmon) ? "ring-" : "",
1175. 				body_part(FINGER));
1176. #else
1177. 			Strcpy(qbuf, "What ring-finger, Right or Left?");
1178. #endif
1179. 			if(!(answer = yn_function(qbuf, "rl", '\0')))
1180. 				return(0);
1181. 			switch(answer){
1182. 			case 'l':
1183. 			case 'L':
1184. 				mask = LEFT_RING;
1185. 				break;
1186. 			case 'r':
1187. 			case 'R':
1188. 				mask = RIGHT_RING;
1189. 				break;
1190. 			}
1191. 		} while(!mask);
1192. 		if (uarmg && uarmg->cursed) {
1193. 			uarmg->bknown = TRUE;
1194. 		    You("cannot remove your gloves to put on the ring.");
1195. 			return(0);
1196. 		}
1197. 		if (welded(uwep) && bimanual(uwep)) {
1198. 			/* welded will set bknown */
1199. 	    You("cannot free your weapon hands to put on the ring.");
1200. 			return(0);
1201. 		}
1202. 		if (welded(uwep) && mask==RIGHT_RING) {
1203. 			/* welded will set bknown */
1204. 	    You("cannot free your weapon hand to put on the ring.");
1205. 			return(0);
1206. 		}
1207. 		setworn(otmp, mask);
1208. 		Ring_on(otmp);
1209. 	} else if (otmp->oclass == AMULET_CLASS) {
1210. 		if(uamul) {
1211. 			already_wearing("an amulet.");
1212. 			return(0);
1213. 		}
1214. 		setworn(otmp, W_AMUL);
1215. 		if (otmp->otyp == AMULET_OF_CHANGE) {
1216. 			Amulet_on();
1217. 			/* Don't do a prinv() since the amulet is now gone */
1218. 			return(1);
1219. 		}
1220. 		Amulet_on();
1221. 	} else {	/* it's a blindfold */
1222. 		if (ublindf) {
1223. 			if (ublindf->otyp == TOWEL)
1224. 				Your("%s is already covered by a towel.",
1225. 					body_part(FACE));
1226. 			else
1227. 				already_wearing("a blindfold.");
1228. 			return(0);
1229. 		}
1230. 		if (otmp->otyp != BLINDFOLD && otmp->otyp != TOWEL) {
1231. 			You("can't wear that!");
1232. 			return(0);
1233. 		}
1234. 		Blindf_on(otmp);
1235. 		return(1);
1236. 	}
1237. 	prinv(NULL, otmp, 0L);
1238. 	return(1);
1239. }
1240. 
1241. #endif /* OVLB */
1242. 
1243. #ifdef OVL0
1244. 
1245. void
1246. find_ac() {
1247. 	register int uac = 10;
1248. #ifdef POLYSELF
1249. 	if (u.mtimedone) uac = mons[u.umonnum].ac;
1250. #endif
1251. 	if(uarm) uac -= ARM_BONUS(uarm);
1252. 	if(uarmc) uac -= ARM_BONUS(uarmc);
1253. 	if(uarmh) uac -= ARM_BONUS(uarmh);
1254. 	if(uarmf) uac -= ARM_BONUS(uarmf);
1255. 	if(uarms) uac -= ARM_BONUS(uarms);
1256. 	if(uarmg) uac -= ARM_BONUS(uarmg);
1257. #ifdef TOURIST
1258. 	if(uarmu) uac -= ARM_BONUS(uarmu);
1259. #endif
1260. 	if(uleft && uleft->otyp == RIN_PROTECTION) uac -= uleft->spe;
1261. 	if(uright && uright->otyp == RIN_PROTECTION) uac -= uright->spe;
1262. 	if (Protection & INTRINSIC) uac -= u.ublessed;
1263. 	if(uac != u.uac){
1264. 		u.uac = uac;
1265. 		flags.botl = 1;
1266. 	}
1267. }
1268. 
1269. #endif /* OVL0 */
1270. #ifdef OVLB
1271. 
1272. void
1273. glibr()
1274. {
1275. 	register struct obj *otmp;
1276. 	int xfl = 0;
1277. 	boolean leftfall, rightfall;
1278. 
1279. 	leftfall = (uleft && !uleft->cursed &&
1280. 		    (!uwep || !welded(uwep) || !bimanual(uwep)));
1281. 	rightfall = (uright && !uright->cursed && (!welded(uwep)));
1282. 	if(!uarmg) if(leftfall || rightfall)
1283. #ifdef POLYSELF
1284. 				if(!nolimbs(uasmon))
1285. #endif
1286. 						{
1287. 		/* changed so cursed rings don't fall off, GAN 10/30/86 */
1288. 		Your("%s off your %s.",
1289. 			(leftfall && rightfall) ? "rings slip" : "ring slips",
1290. 			makeplural(body_part(FINGER)));
1291. 		xfl++;
1292. 		if(leftfall) {
1293. 			otmp = uleft;
1294. 			Ring_off(uleft);
1295. 			dropx(otmp);
1296. 		}
1297. 		if(rightfall) {
1298. 			otmp = uright;
1299. 			Ring_off(uright);
1300. 			dropx(otmp);
1301. 		}
1302. 	}
1303. 	otmp = uwep;
1304. 	if (otmp && !welded(otmp)) {
1305. 		/* changed so cursed weapons don't fall, GAN 10/30/86 */
1306. 		Your("%s %sslips from your %s.",
1307. 			is_sword(otmp) ? "sword" :
1308. 				makesingular(oclass_names[otmp->oclass]),
1309. 			xfl ? "also " : "",
1310. 			makeplural(body_part(HAND)));
1311. 		setuwep((struct obj *)0);
1312. 		dropx(otmp);
1313. 	}
1314. }
1315. 
1316. struct obj *
1317. some_armor(){
1318. register struct obj *otmph = (uarmc ? uarmc : uarm);
1319. 	if(uarmh && (!otmph || !rn2(4))) otmph = uarmh;
1320. 	if(uarmg && (!otmph || !rn2(4))) otmph = uarmg;
1321. 	if(uarmf && (!otmph || !rn2(4))) otmph = uarmf;
1322. 	if(uarms && (!otmph || !rn2(4))) otmph = uarms;
1323. #ifdef TOURIST
1324. 	if(!uarm && !uarmc && uarmu && (!otmph || !rn2(4))) otmph = uarmu;
1325. #endif
1326. 	return(otmph);
1327. }
1328. 
1329. void
1330. erode_armor(acid_dmg)
1331. boolean acid_dmg;
1332. {
1333. register struct obj *otmph = some_armor();
1334. 
1335. 	if (otmph && otmph != uarmf) {
1336. 	    if (otmph->greased) {
1337. 		grease_protect(otmph,NULL,FALSE);
1338. 		return;
1339. 	    }
1340. 	    if (otmph->oerodeproof ||
1341. 		(acid_dmg ? !is_corrodeable(otmph) : !is_rustprone(otmph))) {
1342. 		if (flags.verbose || !(otmph->oerodeproof && otmph->rknown))
1343. 			Your("%s not affected.", aobjnam(otmph, "are"));
1344. 		if (otmph->oerodeproof) otmph->rknown = TRUE;
1345. 		return;
1346. 	    }
1347. 	    if (otmph->oeroded < MAX_ERODE) {
1348. 		Your("%s%s!", aobjnam(otmph, acid_dmg ? "corrode" : "rust"),
1349. 			otmph->oeroded+1 == MAX_ERODE ? " completely" :
1350. 			otmph->oeroded ? " further" : "");
1351. 		otmph->oeroded++;
1352. 		return;
1353. 	    }
1354. 	    if (flags.verbose)
1355. 		Your("%s completely %s.",
1356. 		     aobjnam(otmph, Blind ? "feel" : "look"),
1357. 		     acid_dmg ? "corroded" : "rusty");
1358. 	}
1359. }
1360. 
1361. STATIC_PTR
1362. int
1363. select_off(otmp)
1364. register struct obj *otmp;
1365. {
1366. 	if(!otmp) return(0);
1367. 	if(cursed(otmp)) return(0);
1368. #ifdef POLYSELF
1369. 	if(otmp->oclass==RING_CLASS && nolimbs(uasmon)) return(0);
1370. #endif
1371. 	if(welded(uwep) && (otmp==uarmg || otmp==uright || (otmp==uleft
1372. 			&& bimanual(uwep))))
1373. 		return(0);
1374. 	if(uarmg && uarmg->cursed && (otmp==uright || otmp==uleft)) {
1375. 		uarmg->bknown = TRUE;
1376. 		return(0);
1377. 	}
1378. 	if(otmp == uarmf && u.utrap && (u.utraptype == TT_BEARTRAP ||
1379. 					u.utraptype == TT_INFLOOR)) {
1380. 		return (0);
1381. 	}
1382. 	if((otmp==uarm
1383. #ifdef TOURIST
1384. 			|| otmp==uarmu
1385. #endif
1386. 					) && uarmc && uarmc->cursed) {
1387. 		uarmc->bknown = TRUE;
1388. 		return(0);
1389. 	}
1390. #ifdef TOURIST
1391. 	if(otmp==uarmu && uarm && uarm->cursed) {
1392. 		uarm->bknown = TRUE;
1393. 		return(0);
1394. 	}
1395. #endif
1396. 
1397. 	if(otmp == uarm) takeoff_mask |= WORN_ARMOR;
1398. 	else if(otmp == uarmc) takeoff_mask |= WORN_CLOAK;
1399. 	else if(otmp == uarmf) takeoff_mask |= WORN_BOOTS;
1400. 	else if(otmp == uarmg) takeoff_mask |= WORN_GLOVES;
1401. 	else if(otmp == uarmh) takeoff_mask |= WORN_HELMET;
1402. 	else if(otmp == uarms) takeoff_mask |= WORN_SHIELD;
1403. #ifdef TOURIST
1404. 	else if(otmp == uarmu) takeoff_mask |= WORN_SHIRT;
1405. #endif
1406. 	else if(otmp == uleft) takeoff_mask |= LEFT_RING;
1407. 	else if(otmp == uright) takeoff_mask |= RIGHT_RING;
1408. 	else if(otmp == uamul) takeoff_mask |= WORN_AMUL;
1409. 	else if(otmp == ublindf) takeoff_mask |= WORN_BLINDF;
1410. 	else if(otmp == uwep) takeoff_mask |= 1L;	/* WIELDED_WEAPON */
1411. 
1412. 	else impossible("select_off: %s???", doname(otmp));
1413. 
1414. 	return(0);
1415. }
1416. 
1417. static struct obj *
1418. do_takeoff() {
1419. 
1420. 	register struct obj *otmp = (struct obj *)0;
1421. 
1422. 	if (taking_off == 1L) { /* weapon */
1423. 	  if(!cursed(uwep)) {
1424. 	    setuwep((struct obj *) 0);
1425. 	    You("are empty %s.", body_part(HANDED));
1426. 	  }
1427. 	} else if (taking_off ==  WORN_ARMOR) {
1428. 	  otmp = uarm;
1429. 	  if(!cursed(otmp)) (void) Armor_off();
1430. 	} else if (taking_off == WORN_CLOAK) {
1431. 	  otmp = uarmc;
1432. 	  if(!cursed(otmp)) (void) Cloak_off();
1433. 	} else if (taking_off == WORN_BOOTS) {
1434. 	  otmp = uarmf;
1435. 	  if(!cursed(otmp)) (void) Boots_off();
1436. 	} else if (taking_off == WORN_GLOVES) {
1437. 	  otmp = uarmg;
1438. 	  if(!cursed(otmp)) (void) Gloves_off();
1439. 	} else if (taking_off == WORN_HELMET) {
1440. 	  otmp = uarmh;
1441. 	  if(!cursed(otmp)) (void) Helmet_off();
1442. 	} else if (taking_off == WORN_SHIELD) {
1443. 	  otmp = uarms;
1444. 	  if(!cursed(otmp)) (void) Shield_off();
1445. #ifdef TOURIST
1446. 	} else if (taking_off == WORN_SHIRT) {
1447. 	  otmp = uarmu;
1448. 	  if(!cursed(otmp))
1449. 	    setworn((struct obj *)0, uarmu->owornmask & W_ARMOR);
1450. #endif
1451. 	} else if (taking_off == WORN_AMUL) {
1452. 	  otmp = uamul;
1453. 	  if(!cursed(otmp)) Amulet_off();
1454. 	} else if (taking_off == LEFT_RING) {
1455. 	  otmp = uleft;
1456. 	  if(!cursed(otmp)) Ring_off(uleft);
1457. 	} else if (taking_off == RIGHT_RING) {
1458. 	  otmp = uright;
1459. 	  if(!cursed(otmp)) Ring_off(uright);
1460. 	} else if (taking_off == WORN_BLINDF) {
1461. 	  if(!cursed(ublindf)) {
1462. 	    setworn((struct obj *)0, ublindf->owornmask);
1463. 	    if(!Blinded) make_blinded(1L,FALSE); /* See on next move */
1464. 	    else	 You("still cannot see.");
1465. 	  }
1466. 	} else impossible("do_takeoff: taking off %lx", taking_off);
1467. 
1468. 	return(otmp);
1469. }
1470. 
1471. STATIC_PTR
1472. int
1473. take_off() {
1474. 
1475. 	register int i;
1476. 	register struct obj *otmp;
1477. 
1478. 	if(taking_off) {
1479. 	    if(todelay > 0) {
1480. 
1481. 		todelay--;
1482. 		return(1);	/* still busy */
1483. 	    } else if((otmp = do_takeoff())) off_msg(otmp);
1484. 
1485. 	    takeoff_mask &= ~taking_off;
1486. 	    taking_off = 0L;
1487. 	}
1488. 
1489. 	for(i = 0; takeoff_order[i]; i++)
1490. 	    if(takeoff_mask & takeoff_order[i]) {
1491. 
1492. 		taking_off = takeoff_order[i];
1493. 		break;
1494. 	    }
1495. 
1496. 	otmp = (struct obj *) 0;
1497. 
1498. 	if (taking_off == 0L) {
1499. 	  You("finish disrobing.");
1500. 	  return 0;
1501. 	} else if (taking_off == 1L) {
1502. 	  todelay = 1;
1503. 	} else if (taking_off == WORN_ARMOR) {
1504. 	  otmp = uarm;
1505. 	} else if (taking_off == WORN_CLOAK) {
1506. 	  otmp = uarmc;
1507. 	} else if (taking_off == WORN_BOOTS) {
1508. 	  otmp = uarmf;
1509. 	} else if (taking_off == WORN_GLOVES) {
1510. 	  otmp = uarmg;
1511. 	} else if (taking_off == WORN_HELMET) {
1512. 	  otmp = uarmh;
1513. 	} else if (taking_off == WORN_SHIELD) {
1514. 	  otmp = uarms;
1515. #ifdef TOURIST
1516. 	} else if (taking_off == WORN_SHIRT) {
1517. 	  otmp = uarmu;
1518. #endif
1519. 	} else if (taking_off == WORN_AMUL) {
1520. 	  todelay = 1;
1521. 	} else if (taking_off == LEFT_RING) {
1522. 	  todelay = 1;
1523. 	} else if (taking_off == RIGHT_RING) {
1524. 	  todelay = 1;
1525. 	} else if (taking_off == WORN_BLINDF) {
1526. 	  todelay = 2;
1527. 	} else {
1528. 	  impossible("take_off: taking off %lx", taking_off);
1529. 	  return 0;	/* force done */
1530. 	}
1531. 
1532. 	if(otmp) todelay = objects[otmp->otyp].oc_delay;
1533. 	set_occupation(take_off, "disrobing", 0);
1534. 	return(1);		/* get busy */
1535. }
1536. 
1537. #endif /* OVLB */
1538. #ifdef OVL1
1539. 
1540. void
1541. reset_remarm() { taking_off = takeoff_mask =0L; }
1542. 
1543. #endif /* OVL1 */
1544. #ifdef OVLB
1545. 
1546. int
1547. doddoremarm() {
1548. 
1549. 	if(taking_off || takeoff_mask) {
1550. 
1551. 	    You("continue disrobing.");
1552. 	    set_occupation(take_off, "disrobing", 0);
1553. 	    return(take_off());
1554. 	}
1555. 
1556. 	(void) ggetobj("take off", select_off, 0);
1557. 	if(takeoff_mask) return(take_off());
1558. 	else		 return(0);
1559. }
1560. 
1561. int
1562. destroy_arm(atmp)
1563. register struct obj *atmp;
1564. {
1565. 	register struct obj *otmp;
1566. 
1567. 	if((otmp = uarmc) && (!atmp || atmp == uarmc)) {
1568. 		Your("cloak crumbles and turns to dust!");
1569. 		(void) Cloak_off();
1570. 		useup(otmp);
1571. 	} else if((otmp = uarm) && (!atmp || atmp == uarm)) {
1572. 		/* may be disintegrated by spell or dragon breath... */
1573. 		if (donning(otmp)) cancel_don();
1574. 		Your("armor turns to dust and falls to the floor!");
1575. 		(void) Armor_gone();
1576. 		useup(otmp);
1577. #ifdef TOURIST
1578. 	} else if((otmp = uarmu) && (!atmp || atmp == uarmu)) {
1579. 		Your("shirt crumbles into tiny threads and falls apart!");
1580. 		useup(otmp);
1581. #endif
1582. 	} else if((otmp = uarmh) && (!atmp || atmp == uarmh)) {
1583. 		if (donning(otmp)) cancel_don();
1584. 		Your("helmet turns to dust and is blown away!");
1585. 		(void) Helmet_off();
1586. 		useup(otmp);
1587. 	} else if((otmp = uarmg) && (!atmp || atmp == uarmg)) {
1588. 		if (donning(otmp)) cancel_don();
1589. 		Your("gloves vanish!");
1590. 		(void) Gloves_off();
1591. 		useup(otmp);
1592. 		selftouch("You");
1593. 	} else if((otmp = uarmf) && (!atmp || atmp == uarmf)) {
1594. 		if (donning(otmp)) cancel_don();
1595. 		Your("boots disintegrate!");
1596. 		(void) Boots_off();
1597. 		useup(otmp);
1598. 	} else if((otmp =uarms) && (!atmp || atmp == uarms)) {
1599. 		Your("shield crumbles away!");
1600. 		(void) Shield_off();
1601. 		useup(otmp);
1602. 	} else	return(0);		/* could not destroy anything */
1603. 
1604. 	return(1);
1605. }
1606. 
1607. void
1608. adj_abon(otmp, delta)
1609. register struct obj *otmp;
1610. register schar delta;
1611. {
1612. 	if (uarmg && otmp->otyp == GAUNTLETS_OF_DEXTERITY) {
1613. 		ABON(A_DEX) += (delta);
1614. 		flags.botl = 1;
1615. 	}
1616. 	if (uarmh && otmp->otyp == HELM_OF_BRILLIANCE) {
1617. 		ABON(A_INT) += (delta);
1618. 		ABON(A_WIS) += (delta);
1619. 		flags.botl = 1;
1620. 	}
1621. }
1622. 
1623. #endif /* OVLB */
1624. 
1625. /*do_wear.c*/

Around Wikia's network

Random Wiki