Source:NetHack 3.4.3/src/do_wear.c

From NetHackWiki
Jump to: navigation, search

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

Top of file[edit]

  1. /*	SCCS Id: @(#)do_wear.c	3.4	2003/11/14	*/
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

  1. #include "hack.h"
  2.  
  3. #ifndef OVLB
  4.  
  5. STATIC_DCL long takeoff_mask, taking_off;
  6.  
  7. #else /* OVLB */
  8.  
  9. STATIC_OVL NEARDATA long takeoff_mask = 0L;
  10. static NEARDATA long taking_off = 0L;
  11.  
  12. static NEARDATA int todelay;
  13. static boolean cancelled_don = FALSE;
  14.  
  15. static NEARDATA const char see_yourself[] = "see yourself";
  16. static NEARDATA const char unknown_type[] = "Unknown type of %s (%d)";
  17. static NEARDATA const char c_armor[]  = "armor",
  18. 			   c_suit[]   = "suit",
  19. #ifdef TOURIST
  20. 			   c_shirt[]  = "shirt",
  21. #endif
  22. 			   c_cloak[]  = "cloak",
  23. 			   c_gloves[] = "gloves",
  24. 			   c_boots[]  = "boots",
  25. 			   c_helmet[] = "helmet",
  26. 			   c_shield[] = "shield",
  27. 			   c_weapon[] = "weapon",
  28. 			   c_sword[]  = "sword",
  29. 			   c_axe[]    = "axe",
  30. 			   c_that_[]  = "that";
  31.  
  32. static NEARDATA const long takeoff_order[] = { WORN_BLINDF, W_WEP,
  33. 	WORN_SHIELD, WORN_GLOVES, LEFT_RING, RIGHT_RING, WORN_CLOAK,
  34. 	WORN_HELMET, WORN_AMUL, WORN_ARMOR,
  35. #ifdef TOURIST
  36. 	WORN_SHIRT,
  37. #endif
  38. 	WORN_BOOTS, W_SWAPWEP, W_QUIVER, 0L };
  39.  
  40. STATIC_DCL void FDECL(on_msg, (struct obj *));
  41. STATIC_PTR int NDECL(Armor_on);
  42. STATIC_PTR int NDECL(Boots_on);
  43. STATIC_DCL int NDECL(Cloak_on);
  44. STATIC_PTR int NDECL(Helmet_on);
  45. STATIC_PTR int NDECL(Gloves_on);
  46. STATIC_PTR int NDECL(Shield_on);
  47. #ifdef TOURIST
  48. STATIC_PTR int NDECL(Shirt_on);
  49. #endif
  50. STATIC_DCL void NDECL(Amulet_on);
  51. STATIC_DCL void FDECL(Ring_off_or_gone, (struct obj *, BOOLEAN_P));
  52. STATIC_PTR int FDECL(select_off, (struct obj *));
  53. STATIC_DCL struct obj *NDECL(do_takeoff);
  54. STATIC_PTR int NDECL(take_off);
  55. STATIC_DCL int FDECL(menu_remarm, (int));
  56. STATIC_DCL void FDECL(already_wearing, (const char*));
  57. STATIC_DCL void FDECL(already_wearing2, (const char*, const char*));

off_msg[edit]

  1. void
  2. off_msg(otmp)
  3. register struct obj *otmp;
  4. {
  5. 	if(flags.verbose)
  6. 	    You("were wearing %s.", doname(otmp));
  7. }

on_msg[edit]

  1. /* for items that involve no delay */
  2. STATIC_OVL void
  3. on_msg(otmp)
  4. register struct obj *otmp;
  5. {
  6. 	if (flags.verbose) {
  7. 	    char how[BUFSZ];
  8.  
  9. 	    how[0] = '\0';
  10. 	    if (otmp->otyp == TOWEL)
  11. 		Sprintf(how, " around your %s", body_part(HEAD));
  12. 	    You("are now wearing %s%s.",
  13. 		obj_is_pname(otmp) ? the(xname(otmp)) : an(xname(otmp)),
  14. 		how);
  15. 	}
  16. }

Type_on/Type_off[edit]

  1. /*
  2. * The Type_on() functions should be called *after* setworn().
  3. * The Type_off() functions call setworn() themselves.
  4. */

Boots_on[edit]

  1. STATIC_PTR
  2. int
  3. Boots_on()
  4. {
  5. long oldprop =
  6. 	u.uprops[objects[uarmf->otyp].oc_oprop].extrinsic & ~WORN_BOOTS;
  7.  
  8. switch(uarmf->otyp) {
  9. 	case LOW_BOOTS:
  10. 	case IRON_SHOES:
  11. 	case HIGH_BOOTS:
  12. 	case JUMPING_BOOTS:
  13. 	case KICKING_BOOTS:
  14. 		break;
  15. 	case WATER_WALKING_BOOTS:
  16. 		if (u.uinwater) spoteffects(TRUE);
  17. 		break;
  18. 	case SPEED_BOOTS:
  19. 		/* Speed boots are still better than intrinsic speed, */
  20. 		/* though not better than potion speed */
  21. 		if (!oldprop && !(HFast & TIMEOUT)) {
  22. 			makeknown(uarmf->otyp);
  23. 			You_feel("yourself speed up%s.",
  24. 				(oldprop || HFast) ? " a bit more" : "");
  25. 		}
  26. 		break;
  27. 	case ELVEN_BOOTS:
  28. 		if (!oldprop && !HStealth && !BStealth) {
  29. 			makeknown(uarmf->otyp);
  30. 			You("walk very quietly.");
  31. 		}
  32. 		break;
  33. 	case FUMBLE_BOOTS:
  34. 		if (!oldprop && !(HFumbling & ~TIMEOUT))
  35. 			incr_itimeout(&HFumbling, rnd(20));
  36. 		break;
  37. 	case LEVITATION_BOOTS:
  38. 		if (!oldprop && !HLevitation) {
  39. 			makeknown(uarmf->otyp);
  40. 			float_up();
  41. 			spoteffects(FALSE);
  42. 		}
  43. 		break;
  44. 	default: impossible(unknown_type, c_boots, uarmf->otyp);
  45. }
  46. return 0;
  47. }

Boots_off[edit]

  1. int
  2. Boots_off()
  3. {
  4. int otyp = uarmf->otyp;
  5. long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_BOOTS;
  6.  
  7. takeoff_mask &= ~W_ARMF;
  8. 	/* For levitation, float_down() returns if Levitation, so we
  9. 	 * must do a setworn() _before_ the levitation case.
  10. 	 */
  11. setworn((struct obj *)0, W_ARMF);
  12. switch (otyp) {
  13. 	case SPEED_BOOTS:
  14. 		if (!Very_fast && !cancelled_don) {
  15. 			makeknown(otyp);
  16. 			You_feel("yourself slow down%s.",
  17. 				Fast ? " a bit" : "");
  18. 		}
  19. 		break;
  20. 	case WATER_WALKING_BOOTS:
  21. 		if (is_pool(u.ux,u.uy) && !Levitation && !Flying &&
  22. 		    !is_clinger(youmonst.data) && !cancelled_don) {
  23. 			makeknown(otyp);
  24. 			/* make boots known in case you survive the drowning */
  25. 			spoteffects(TRUE);
  26. 		}
  27. 		break;
  28. 	case ELVEN_BOOTS:
  29. 		if (!oldprop && !HStealth && !BStealth && !cancelled_don) {
  30. 			makeknown(otyp);
  31. 			You("sure are noisy.");
  32. 		}
  33. 		break;
  34. 	case FUMBLE_BOOTS:
  35. 		if (!oldprop && !(HFumbling & ~TIMEOUT))
  36. 			HFumbling = EFumbling = 0;
  37. 		break;
  38. 	case LEVITATION_BOOTS:
  39. 		if (!oldprop && !HLevitation && !cancelled_don) {
  40. 			(void) float_down(0L, 0L);
  41. 			makeknown(otyp);
  42. 		}
  43. 		break;
  44. 	case LOW_BOOTS:
  45. 	case IRON_SHOES:
  46. 	case HIGH_BOOTS:
  47. 	case JUMPING_BOOTS:
  48. 	case KICKING_BOOTS:
  49. 		break;
  50. 	default: impossible(unknown_type, c_boots, otyp);
  51. }
  52. cancelled_don = FALSE;
  53. return 0;
  54. }

Cloak_on[edit]

  1. STATIC_OVL int
  2. Cloak_on()
  3. {
  4. long oldprop =
  5. 	u.uprops[objects[uarmc->otyp].oc_oprop].extrinsic & ~WORN_CLOAK;
  6.  
  7. switch(uarmc->otyp) {
  8. 	case ELVEN_CLOAK:
  9. 	case CLOAK_OF_PROTECTION:
  10. 	case CLOAK_OF_DISPLACEMENT:
  11. 		makeknown(uarmc->otyp);
  12. 		break;
  13. 	case ORCISH_CLOAK:
  14. 	case DWARVISH_CLOAK:
  15. 	case CLOAK_OF_MAGIC_RESISTANCE:
  16. 	case ROBE:
  17. 	case LEATHER_CLOAK:
  18. 		break;
  19. 	case MUMMY_WRAPPING:
  20. 		/* Note: it's already being worn, so we have to cheat here. */
  21. 		if ((HInvis || EInvis || pm_invisible(youmonst.data)) && !Blind) {
  22. 		    newsym(u.ux,u.uy);
  23. 		    You("can %s!",
  24. 			See_invisible ? "no longer see through yourself"
  25. 			: see_yourself);
  26. 		}
  27. 		break;
  28. 	case CLOAK_OF_INVISIBILITY:
  29. 		/* since cloak of invisibility was worn, we know mummy wrapping
  30. 		   wasn't, so no need to check `oldprop' against blocked */
  31. 		if (!oldprop && !HInvis && !Blind) {
  32. 		    makeknown(uarmc->otyp);
  33. 		    newsym(u.ux,u.uy);
  34. 		    pline("Suddenly you can%s yourself.",
  35. 			See_invisible ? " see through" : "not see");
  36. 		}
  37. 		break;
  38. 	case OILSKIN_CLOAK:
  39. 		pline("%s very tightly.", Tobjnam(uarmc, "fit"));
  40. 		break;
  41. 	/* Alchemy smock gives poison _and_ acid resistance */
  42. 	case ALCHEMY_SMOCK:
  43. 		EAcid_resistance |= WORN_CLOAK;
  44. 		break;
  45. 	default: impossible(unknown_type, c_cloak, uarmc->otyp);
  46. }
  47. return 0;
  48. }

Cloak_off[edit]

  1. int
  2. Cloak_off()
  3. {
  4. int otyp = uarmc->otyp;
  5. long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_CLOAK;
  6.  
  7. takeoff_mask &= ~W_ARMC;
  8. 	/* For mummy wrapping, taking it off first resets `Invisible'. */
  9. setworn((struct obj *)0, W_ARMC);
  10. switch (otyp) {
  11. 	case ELVEN_CLOAK:
  12. 	case ORCISH_CLOAK:
  13. 	case DWARVISH_CLOAK:
  14. 	case CLOAK_OF_PROTECTION:
  15. 	case CLOAK_OF_MAGIC_RESISTANCE:
  16. 	case CLOAK_OF_DISPLACEMENT:
  17. 	case OILSKIN_CLOAK:
  18. 	case ROBE:
  19. 	case LEATHER_CLOAK:
  20. 		break;
  21. 	case MUMMY_WRAPPING:
  22. 		if (Invis && !Blind) {
  23. 		    newsym(u.ux,u.uy);
  24. 		    You("can %s.",
  25. 			See_invisible ? "see through yourself"
  26. 			: "no longer see yourself");
  27. 		}
  28. 		break;
  29. 	case CLOAK_OF_INVISIBILITY:
  30. 		if (!oldprop && !HInvis && !Blind) {
  31. 		    makeknown(CLOAK_OF_INVISIBILITY);
  32. 		    newsym(u.ux,u.uy);
  33. 		    pline("Suddenly you can %s.",
  34. 			See_invisible ? "no longer see through yourself"
  35. 			: see_yourself);
  36. 		}
  37. 		break;
  38. 	/* Alchemy smock gives poison _and_ acid resistance */
  39. 	case ALCHEMY_SMOCK:
  40. 		EAcid_resistance &= ~WORN_CLOAK;
  41. 		break;
  42. 	default: impossible(unknown_type, c_cloak, otyp);
  43. }
  44. return 0;
  45. }

Helmet_on[edit]

  1. STATIC_PTR
  2. int
  3. Helmet_on()
  4. {
  5. switch(uarmh->otyp) {
  6. 	case FEDORA:
  7. 	case HELMET:
  8. 	case DENTED_POT:
  9. 	case ELVEN_LEATHER_HELM:
  10. 	case DWARVISH_IRON_HELM:
  11. 	case ORCISH_HELM:
  12. 	case HELM_OF_TELEPATHY:
  13. 		break;
  14. 	case HELM_OF_BRILLIANCE:
  15. 		adj_abon(uarmh, uarmh->spe);
  16. 		break;
  17. 	case CORNUTHAUM:
  18. 		/* people think marked wizards know what they're talking
  19. 		 * about, but it takes trained arrogance to pull it off,
  20. 		 * and the actual enchantment of the hat is irrelevant.
  21. 		 */
  22. 		ABON(A_CHA) += (Role_if(PM_WIZARD) ? 1 : -1);
  23. 		flags.botl = 1;
  24. 		makeknown(uarmh->otyp);
  25. 		break;
  26. 	case HELM_OF_OPPOSITE_ALIGNMENT:
  27. 		if (u.ualign.type == A_NEUTRAL)
  28. 		    u.ualign.type = rn2(2) ? A_CHAOTIC : A_LAWFUL;
  29. 		else u.ualign.type = -(u.ualign.type);
  30. 		u.ublessed = 0; /* lose your god's protection */
  31. 	     /* makeknown(uarmh->otyp);   -- moved below, after xname() */
  32. 		/*FALLTHRU*/
  33. 	case DUNCE_CAP:
  34. 		if (!uarmh->cursed) {
  35. 		    if (Blind)
  36. 			pline("%s for a moment.", Tobjnam(uarmh, "vibrate"));
  37. 		    else
  38. 			pline("%s %s for a moment.",
  39. 			      Tobjnam(uarmh, "glow"), hcolor(NH_BLACK));
  40. 		    curse(uarmh);
  41. 		}
  42. 		flags.botl = 1;		/* reveal new alignment or INT & WIS */
  43. 		if (Hallucination) {
  44. 		    pline("My brain hurts!"); /* Monty Python's Flying Circus */
  45. 		} else if (uarmh->otyp == DUNCE_CAP) {
  46. 		    You_feel("%s.",	/* track INT change; ignore WIS */
  47. 		  ACURR(A_INT) <= (ABASE(A_INT) + ABON(A_INT) + ATEMP(A_INT)) ?
  48. 			     "like sitting in a corner" : "giddy");
  49. 		} else {
  50. 		    Your("mind oscillates briefly.");
  51. 		    makeknown(HELM_OF_OPPOSITE_ALIGNMENT);
  52. 		}
  53. 		break;
  54. 	default: impossible(unknown_type, c_helmet, uarmh->otyp);
  55. }
  56. return 0;
  57. }

Helmet_off[edit]

  1. int
  2. Helmet_off()
  3. {
  4. takeoff_mask &= ~W_ARMH;
  5.  
  6. switch(uarmh->otyp) {
  7. 	case FEDORA:
  8. 	case HELMET:
  9. 	case DENTED_POT:
  10. 	case ELVEN_LEATHER_HELM:
  11. 	case DWARVISH_IRON_HELM:
  12. 	case ORCISH_HELM:
  13. 	    break;
  14. 	case DUNCE_CAP:
  15. 	    flags.botl = 1;
  16. 	    break;
  17. 	case CORNUTHAUM:
  18. 	    if (!cancelled_don) {
  19. 		ABON(A_CHA) += (Role_if(PM_WIZARD) ? -1 : 1);
  20. 		flags.botl = 1;
  21. 	    }
  22. 	    break;
  23. 	case HELM_OF_TELEPATHY:
  24. 	    /* need to update ability before calling see_monsters() */
  25. 	    setworn((struct obj *)0, W_ARMH);
  26. 	    see_monsters();
  27. 	    return 0;
  28. 	case HELM_OF_BRILLIANCE:
  29. 	    if (!cancelled_don) adj_abon(uarmh, -uarmh->spe);
  30. 	    break;
  31. 	case HELM_OF_OPPOSITE_ALIGNMENT:
  32. 	    u.ualign.type = u.ualignbase[A_CURRENT];
  33. 	    u.ublessed = 0; /* lose the other god's protection */
  34. 	    flags.botl = 1;
  35. 	    break;
  36. 	default: impossible(unknown_type, c_helmet, uarmh->otyp);
  37. }
  38. setworn((struct obj *)0, W_ARMH);
  39. cancelled_don = FALSE;
  40. return 0;
  41. }

Gloves_on[edit]

  1. STATIC_PTR
  2. int
  3. Gloves_on()
  4. {
  5. long oldprop =
  6. 	u.uprops[objects[uarmg->otyp].oc_oprop].extrinsic & ~WORN_GLOVES;
  7.  
  8. switch(uarmg->otyp) {
  9. 	case LEATHER_GLOVES:
  10. 		break;
  11. 	case GAUNTLETS_OF_FUMBLING:
  12. 		if (!oldprop && !(HFumbling & ~TIMEOUT))
  13. 			incr_itimeout(&HFumbling, rnd(20));
  14. 		break;
  15. 	case GAUNTLETS_OF_POWER:
  16. 		makeknown(uarmg->otyp);
  17. 		flags.botl = 1; /* taken care of in attrib.c */
  18. 		break;
  19. 	case GAUNTLETS_OF_DEXTERITY:
  20. 		adj_abon(uarmg, uarmg->spe);
  21. 		break;
  22. 	default: impossible(unknown_type, c_gloves, uarmg->otyp);
  23. }
  24. return 0;
  25. }

Gloves_off[edit]

  1. int
  2. Gloves_off()
  3. {
  4. long oldprop =
  5. 	u.uprops[objects[uarmg->otyp].oc_oprop].extrinsic & ~WORN_GLOVES;
  6.  
  7. takeoff_mask &= ~W_ARMG;
  8.  
  9. switch(uarmg->otyp) {
  10. 	case LEATHER_GLOVES:
  11. 	    break;
  12. 	case GAUNTLETS_OF_FUMBLING:
  13. 	    if (!oldprop && !(HFumbling & ~TIMEOUT))
  14. 		HFumbling = EFumbling = 0;
  15. 	    break;
  16. 	case GAUNTLETS_OF_POWER:
  17. 	    makeknown(uarmg->otyp);
  18. 	    flags.botl = 1; /* taken care of in attrib.c */
  19. 	    break;
  20. 	case GAUNTLETS_OF_DEXTERITY:
  21. 	    if (!cancelled_don) adj_abon(uarmg, -uarmg->spe);
  22. 	    break;
  23. 	default: impossible(unknown_type, c_gloves, uarmg->otyp);
  24. }
  25. setworn((struct obj *)0, W_ARMG);
  26. cancelled_don = FALSE;
  27. (void) encumber_msg();		/* immediate feedback for GoP */
  28.  
  29. /* Prevent wielding cockatrice when not wearing gloves */
  30. if (uwep && uwep->otyp == CORPSE &&
  31. 		touch_petrifies(&mons[uwep->corpsenm])) {
  32. 	char kbuf[BUFSZ];
  33.  
  34. 	You("wield the %s in your bare %s.",
  35. 	    corpse_xname(uwep, TRUE), makeplural(body_part(HAND)));
  36. 	Strcpy(kbuf, an(corpse_xname(uwep, TRUE)));
  37. 	instapetrify(kbuf);
  38. 	uwepgone();  /* life-saved still doesn't allow touching cockatrice */
  39. }
  40.  
  41. /* KMH -- ...or your secondary weapon when you're wielding it */
  42. if (u.twoweap && uswapwep && uswapwep->otyp == CORPSE &&
  43. 	touch_petrifies(&mons[uswapwep->corpsenm])) {
  44. 	char kbuf[BUFSZ];
  45.  
  46. 	You("wield the %s in your bare %s.",
  47. 	    corpse_xname(uswapwep, TRUE), body_part(HAND));
  48.  
  49. 	Strcpy(kbuf, an(corpse_xname(uswapwep, TRUE)));
  50. 	instapetrify(kbuf);
  51. 	uswapwepgone();	/* lifesaved still doesn't allow touching cockatrice */
  52. }
  53.  
  54. return 0;
  55. }

Shield_on[edit]

  1. STATIC_OVL int
  2. Shield_on()
  3. {
  4. /*
  5. switch (uarms->otyp) {
  6. 	case SMALL_SHIELD:
  7. 	case ELVEN_SHIELD:
  8. 	case URUK_HAI_SHIELD:
  9. 	case ORCISH_SHIELD:
  10. 	case DWARVISH_ROUNDSHIELD:
  11. 	case LARGE_SHIELD:
  12. 	case SHIELD_OF_REFLECTION:
  13. 		break;
  14. 	default: impossible(unknown_type, c_shield, uarms->otyp);
  15. }
  16. */
  17. return 0;
  18. }

Shield_off[edit]

  1. int
  2. Shield_off()
  3. {
  4. takeoff_mask &= ~W_ARMS;
  5. /*
  6. switch (uarms->otyp) {
  7. 	case SMALL_SHIELD:
  8. 	case ELVEN_SHIELD:
  9. 	case URUK_HAI_SHIELD:
  10. 	case ORCISH_SHIELD:
  11. 	case DWARVISH_ROUNDSHIELD:
  12. 	case LARGE_SHIELD:
  13. 	case SHIELD_OF_REFLECTION:
  14. 		break;
  15. 	default: impossible(unknown_type, c_shield, uarms->otyp);
  16. }
  17. */
  18. setworn((struct obj *)0, W_ARMS);
  19. return 0;
  20. }

Shirt_on[edit]

  1. #ifdef TOURIST
  2. STATIC_OVL int
  3. Shirt_on()
  4. {
  5. /*
  6. switch (uarmu->otyp) {
  7. 	case HAWAIIAN_SHIRT:
  8. 	case T_SHIRT:
  9. 		break;
  10. 	default: impossible(unknown_type, c_shirt, uarmu->otyp);
  11. }
  12. */
  13. return 0;
  14. }

Shirt_off[edit]

  1. int
  2. Shirt_off()
  3. {
  4. takeoff_mask &= ~W_ARMU;
  5. /*
  6. switch (uarmu->otyp) {
  7. 	case HAWAIIAN_SHIRT:
  8. 	case T_SHIRT:
  9. 		break;
  10. 	default: impossible(unknown_type, c_shirt, uarmu->otyp);
  11. }
  12. */
  13. setworn((struct obj *)0, W_ARMU);
  14. return 0;
  15. }
  16. #endif	/*TOURIST*/

Armor_on[edit]

  1. /* This must be done in worn.c, because one of the possible intrinsics conferred
  2. * is fire resistance, and we have to immediately set HFire_resistance in worn.c
  3. * since worn.c will check it before returning.
  4. */
  5. STATIC_PTR
  6. int
  7. Armor_on()
  8. {
  9. return 0;
  10. }

Armor_off[edit]

  1. int
  2. Armor_off()
  3. {
  4. takeoff_mask &= ~W_ARM;
  5. setworn((struct obj *)0, W_ARM);
  6. cancelled_don = FALSE;
  7. return 0;
  8. }

Armor_gone[edit]

  1. /* The gone functions differ from the off functions in that if you die from
  2. * taking it off and have life saving, you still die.
  3. */
  4. int
  5. Armor_gone()
  6. {
  7. takeoff_mask &= ~W_ARM;
  8. setnotworn(uarm);
  9. cancelled_don = FALSE;
  10. return 0;
  11. }

Amulet_on[edit]

  1. STATIC_OVL void
  2. Amulet_on()
  3. {
  4. switch(uamul->otyp) {
  5. 	case AMULET_OF_ESP:
  6. 	case AMULET_OF_LIFE_SAVING:
  7. 	case AMULET_VERSUS_POISON:
  8. 	case AMULET_OF_REFLECTION:
  9. 	case AMULET_OF_MAGICAL_BREATHING:
  10. 	case FAKE_AMULET_OF_YENDOR:
  11. 		break;
  12. 	case AMULET_OF_UNCHANGING:
  13. 		if (Slimed) {
  14. 		    Slimed = 0;
  15. 		    flags.botl = 1;
  16. 		}
  17. 		break;
  18. 	case AMULET_OF_CHANGE:
  19. 	    {
  20. 		int orig_sex = poly_gender();
  21.  
  22. 		if (Unchanging) break;
  23. 		change_sex();
  24. 		/* Don't use same message as polymorph */
  25. 		if (orig_sex != poly_gender()) {
  26. 		    makeknown(AMULET_OF_CHANGE);
  27. 		    You("are suddenly very %s!", flags.female ? "feminine"
  28. 			: "masculine");
  29. 		    flags.botl = 1;
  30. 		} else
  31. 		    /* already polymorphed into single-gender monster; only
  32. 		       changed the character's base sex */
  33. 		    You("don't feel like yourself.");
  34. 		pline_The("amulet disintegrates!");
  35. 		if (orig_sex == poly_gender() && uamul->dknown &&
  36. 			!objects[AMULET_OF_CHANGE].oc_name_known &&
  37. 			!objects[AMULET_OF_CHANGE].oc_uname)
  38. 		    docall(uamul);
  39. 		useup(uamul);
  40. 		break;
  41. 	    }
  42. 	case AMULET_OF_STRANGULATION:
  43. 		makeknown(AMULET_OF_STRANGULATION);
  44. 		pline("It constricts your throat!");
  45. 		Strangled = 6;
  46. 		break;
  47. 	case AMULET_OF_RESTFUL_SLEEP:
  48. 		HSleeping = rnd(100);
  49. 		break;
  50. 	case AMULET_OF_YENDOR:
  51. 		break;
  52. }
  53. }

Amulet_off[edit]

  1. void
  2. Amulet_off()
  3. {
  4. takeoff_mask &= ~W_AMUL;
  5.  
  6. switch(uamul->otyp) {
  7. 	case AMULET_OF_ESP:
  8. 		/* need to update ability before calling see_monsters() */
  9. 		setworn((struct obj *)0, W_AMUL);
  10. 		see_monsters();
  11. 		return;
  12. 	case AMULET_OF_LIFE_SAVING:
  13. 	case AMULET_VERSUS_POISON:
  14. 	case AMULET_OF_REFLECTION:
  15. 	case AMULET_OF_CHANGE:
  16. 	case AMULET_OF_UNCHANGING:
  17. 	case FAKE_AMULET_OF_YENDOR:
  18. 		break;
  19. 	case AMULET_OF_MAGICAL_BREATHING:
  20. 		if (Underwater) {
  21. 		    /* HMagical_breathing must be set off
  22. 			before calling drown() */
  23. 		    setworn((struct obj *)0, W_AMUL);
  24. 		    if (!breathless(youmonst.data) && !amphibious(youmonst.data)
  25. 						&& !Swimming) {
  26. 			You("suddenly inhale an unhealthy amount of water!");
  27. 		    	(void) drown();
  28. 		    }
  29. 		    return;
  30. 		}
  31. 		break;
  32. 	case AMULET_OF_STRANGULATION:
  33. 		if (Strangled) {
  34. 			You("can breathe more easily!");
  35. 			Strangled = 0;
  36. 		}
  37. 		break;
  38. 	case AMULET_OF_RESTFUL_SLEEP:
  39. 		setworn((struct obj *)0, W_AMUL);
  40. 		if (!ESleeping)
  41. 			HSleeping = 0;
  42. 		return;
  43. 	case AMULET_OF_YENDOR:
  44. 		break;
  45. }
  46. setworn((struct obj *)0, W_AMUL);
  47. return;
  48. }

Ring_on[edit]

  1. void
  2. Ring_on(obj)
  3. register struct obj *obj;
  4. {
  5. long oldprop = u.uprops[objects[obj->otyp].oc_oprop].extrinsic;
  6. int old_attrib, which;
  7.  
  8. if (obj == uwep) setuwep((struct obj *) 0);
  9. if (obj == uswapwep) setuswapwep((struct obj *) 0);
  10. if (obj == uquiver) setuqwep((struct obj *) 0);
  11.  
  12. /* only mask out W_RING when we don't have both
  13. left and right rings of the same type */
  14. if ((oldprop & W_RING) != W_RING) oldprop &= ~W_RING;
  15.  
  16. switch(obj->otyp){
  17. 	case RIN_TELEPORTATION:
  18. 	case RIN_REGENERATION:
  19. 	case RIN_SEARCHING:
  20. 	case RIN_STEALTH:
  21. 	case RIN_HUNGER:
  22. 	case RIN_AGGRAVATE_MONSTER:
  23. 	case RIN_POISON_RESISTANCE:
  24. 	case RIN_FIRE_RESISTANCE:
  25. 	case RIN_COLD_RESISTANCE:
  26. 	case RIN_SHOCK_RESISTANCE:
  27. 	case RIN_CONFLICT:
  28. 	case RIN_TELEPORT_CONTROL:
  29. 	case RIN_POLYMORPH:
  30. 	case RIN_POLYMORPH_CONTROL:
  31. 	case RIN_FREE_ACTION:                
  32. 	case RIN_SLOW_DIGESTION:
  33. 	case RIN_SUSTAIN_ABILITY:
  34. 	case MEAT_RING:
  35. 		break;
  36. 	case RIN_WARNING:
  37. 		see_monsters();
  38. 		break;
  39. 	case RIN_SEE_INVISIBLE:
  40. 		/* can now see invisible monsters */
  41. 		set_mimic_blocking(); /* do special mimic handling */
  42. 		see_monsters();
  43. #ifdef INVISIBLE_OBJECTS
  44. 		see_objects();
  45. #endif
  46.  
  47. 		if (Invis && !oldprop && !HSee_invisible &&
  48. 				!perceives(youmonst.data) && !Blind) {
  49. 		    newsym(u.ux,u.uy);
  50. 		    pline("Suddenly you are transparent, but there!");
  51. 		    makeknown(RIN_SEE_INVISIBLE);
  52. 		}
  53. 		break;
  54. 	case RIN_INVISIBILITY:
  55. 		if (!oldprop && !HInvis && !BInvis && !Blind) {
  56. 		    makeknown(RIN_INVISIBILITY);
  57. 		    newsym(u.ux,u.uy);
  58. 		    self_invis_message();
  59. 		}
  60. 		break;
  61. 	case RIN_LEVITATION:
  62. 		if (!oldprop && !HLevitation) {
  63. 		    float_up();
  64. 		    makeknown(RIN_LEVITATION);
  65. 		    spoteffects(FALSE);	/* for sinks */
  66. 		}
  67. 		break;
  68. 	case RIN_GAIN_STRENGTH:
  69. 		which = A_STR;
  70. 		goto adjust_attrib;
  71. 	case RIN_GAIN_CONSTITUTION:
  72. 		which = A_CON;
  73. 		goto adjust_attrib;
  74. 	case RIN_ADORNMENT:
  75. 		which = A_CHA;
  76. adjust_attrib:
  77. 		old_attrib = ACURR(which);
  78. 		ABON(which) += obj->spe;
  79. 		if (ACURR(which) != old_attrib ||
  80. 			(objects[obj->otyp].oc_name_known &&
  81. 			    old_attrib != 25 && old_attrib != 3)) {
  82. 		    flags.botl = 1;
  83. 		    makeknown(obj->otyp);
  84. 		    obj->known = 1;
  85. 		    update_inventory();
  86. 		}
  87. 		break;
  88. 	case RIN_INCREASE_ACCURACY:	/* KMH */
  89. 		u.uhitinc += obj->spe;
  90. 		break;
  91. 	case RIN_INCREASE_DAMAGE:
  92. 		u.udaminc += obj->spe;
  93. 		break;
  94. 	case RIN_PROTECTION_FROM_SHAPE_CHAN:
  95. 		rescham();
  96. 		break;
  97. 	case RIN_PROTECTION:
  98. 		if (obj->spe || objects[RIN_PROTECTION].oc_name_known) {
  99. 		    flags.botl = 1;
  100. 		    makeknown(RIN_PROTECTION);
  101. 		    obj->known = 1;
  102. 		    update_inventory();
  103. 		}
  104. 		break;
  105. }
  106. }

Ring_off_or_gone[edit]

  1. STATIC_OVL void
  2. Ring_off_or_gone(obj,gone)
  3. register struct obj *obj;
  4. boolean gone;
  5. {
  6. long mask = (obj->owornmask & W_RING);
  7. int old_attrib, which;
  8.  
  9. takeoff_mask &= ~mask;
  10. if(!(u.uprops[objects[obj->otyp].oc_oprop].extrinsic & mask))
  11. 	impossible("Strange... I didn't know you had that ring.");
  12. if(gone) setnotworn(obj);
  13. else setworn((struct obj *)0, obj->owornmask);
  14.  
  15. switch(obj->otyp) {
  16. 	case RIN_TELEPORTATION:
  17. 	case RIN_REGENERATION:
  18. 	case RIN_SEARCHING:
  19. 	case RIN_STEALTH:
  20. 	case RIN_HUNGER:
  21. 	case RIN_AGGRAVATE_MONSTER:
  22. 	case RIN_POISON_RESISTANCE:
  23. 	case RIN_FIRE_RESISTANCE:
  24. 	case RIN_COLD_RESISTANCE:
  25. 	case RIN_SHOCK_RESISTANCE:
  26. 	case RIN_CONFLICT:
  27. 	case RIN_TELEPORT_CONTROL:
  28. 	case RIN_POLYMORPH:
  29. 	case RIN_POLYMORPH_CONTROL:
  30. 	case RIN_FREE_ACTION:                
  31. 	case RIN_SLOW_DIGESTION:
  32. 	case RIN_SUSTAIN_ABILITY:
  33. 	case MEAT_RING:
  34. 		break;
  35. 	case RIN_WARNING:
  36. 		see_monsters();
  37. 		break;
  38. 	case RIN_SEE_INVISIBLE:
  39. 		/* Make invisible monsters go away */
  40. 		if (!See_invisible) {
  41. 		    set_mimic_blocking(); /* do special mimic handling */
  42. 		    see_monsters();
  43. #ifdef INVISIBLE_OBJECTS                
  44. 		    see_objects();
  45. #endif
  46. 		}
  47.  
  48. 		if (Invisible && !Blind) {
  49. 		    newsym(u.ux,u.uy);
  50. 		    pline("Suddenly you cannot see yourself.");
  51. 		    makeknown(RIN_SEE_INVISIBLE);
  52. 		}
  53. 		break;
  54. 	case RIN_INVISIBILITY:
  55. 		if (!Invis && !BInvis && !Blind) {
  56. 		    newsym(u.ux,u.uy);
  57. 		    Your("body seems to unfade%s.",
  58. 			 See_invisible ? " completely" : "..");
  59. 		    makeknown(RIN_INVISIBILITY);
  60. 		}
  61. 		break;
  62. 	case RIN_LEVITATION:
  63. 		(void) float_down(0L, 0L);
  64. 		if (!Levitation) makeknown(RIN_LEVITATION);
  65. 		break;
  66. 	case RIN_GAIN_STRENGTH:
  67. 		which = A_STR;
  68. 		goto adjust_attrib;
  69. 	case RIN_GAIN_CONSTITUTION:
  70. 		which = A_CON;
  71. 		goto adjust_attrib;
  72. 	case RIN_ADORNMENT:
  73. 		which = A_CHA;
  74. adjust_attrib:
  75. 		old_attrib = ACURR(which);
  76. 		ABON(which) -= obj->spe;
  77. 		if (ACURR(which) != old_attrib) {
  78. 		    flags.botl = 1;
  79. 		    makeknown(obj->otyp);
  80. 		    obj->known = 1;
  81. 		    update_inventory();
  82. 		}
  83. 		break;
  84. 	case RIN_INCREASE_ACCURACY:	/* KMH */
  85. 		u.uhitinc -= obj->spe;
  86. 		break;
  87. 	case RIN_INCREASE_DAMAGE:
  88. 		u.udaminc -= obj->spe;
  89. 		break;
  90. 	case RIN_PROTECTION:
  91. 		/* might have forgotten it due to amnesia */
  92. 		if (obj->spe) {
  93. 		    flags.botl = 1;
  94. 		    makeknown(RIN_PROTECTION);
  95. 		    obj->known = 1;
  96. 		    update_inventory();
  97. 		}
  98. 	case RIN_PROTECTION_FROM_SHAPE_CHAN:
  99. 		/* If you're no longer protected, let the chameleons
  100. 		 * change shape again -dgk
  101. 		 */
  102. 		restartcham();
  103. 		break;
  104. }
  105. }

Ring_off[edit]

  1. void
  2. Ring_off(obj)
  3. struct obj *obj;
  4. {
  5. 	Ring_off_or_gone(obj,FALSE);
  6. }

Ring_gone[edit]

  1. void
  2. Ring_gone(obj)
  3. struct obj *obj;
  4. {
  5. 	Ring_off_or_gone(obj,TRUE);
  6. }

Blindf_on[edit]

  1. void
  2. Blindf_on(otmp)
  3. register struct obj *otmp;
  4. {
  5. 	boolean already_blind = Blind, changed = FALSE;
  6.  
  7. 	if (otmp == uwep)
  8. 	    setuwep((struct obj *) 0);
  9. 	if (otmp == uswapwep)
  10. 	    setuswapwep((struct obj *) 0);
  11. 	if (otmp == uquiver)
  12. 	    setuqwep((struct obj *) 0);
  13. 	setworn(otmp, W_TOOL);
  14. 	on_msg(otmp);
  15.  
  16. 	if (Blind && !already_blind) {
  17. 	    changed = TRUE;
  18. 	    if (flags.verbose) You_cant("see any more.");
  19. 	    /* set ball&chain variables before the hero goes blind */
  20. 	    if (Punished) set_bc(0);
  21. 	} else if (already_blind && !Blind) {
  22. 	    changed = TRUE;
  23. 	    /* "You are now wearing the Eyes of the Overworld." */
  24. 	    You("can see!");
  25. 	}
  26. 	if (changed) {
  27. 	    /* blindness has just been toggled */
  28. 	    if (Blind_telepat || Infravision) see_monsters();
  29. 	    vision_full_recalc = 1;	/* recalc vision limits */
  30. 	    flags.botl = 1;
  31. 	}
  32. }

Blindf_off[edit]

  1. void
  2. Blindf_off(otmp)
  3. register struct obj *otmp;
  4. {
  5. 	boolean was_blind = Blind, changed = FALSE;
  6.  
  7. 	takeoff_mask &= ~W_TOOL;
  8. 	setworn((struct obj *)0, otmp->owornmask);
  9. 	off_msg(otmp);
  10.  
  11. 	if (Blind) {
  12. 	    if (was_blind) {
  13. 		/* "still cannot see" makes no sense when removing lenses
  14. 		   since they can't have been the cause of your blindness */
  15. 		if (otmp->otyp != LENSES)
  16. 		    You("still cannot see.");
  17. 	    } else {
  18. 		changed = TRUE;	/* !was_blind */
  19. 		/* "You were wearing the Eyes of the Overworld." */
  20. 		You_cant("see anything now!");
  21. 		/* set ball&chain variables before the hero goes blind */
  22. 		if (Punished) set_bc(0);
  23. 	    }
  24. 	} else if (was_blind) {
  25. 	    changed = TRUE;	/* !Blind */
  26. 	    You("can see again.");
  27. 	}
  28. 	if (changed) {
  29. 	    /* blindness has just been toggled */
  30. 	    if (Blind_telepat || Infravision) see_monsters();
  31. 	    vision_full_recalc = 1;	/* recalc vision limits */
  32. 	    flags.botl = 1;
  33. 	}
  34. }

set_wear[edit]

  1. /* called in main to set intrinsics of worn start-up items */
  2. void
  3. set_wear()
  4. {
  5. #ifdef TOURIST
  6. 	if (uarmu) (void) Shirt_on();
  7. #endif
  8. 	if (uarm)  (void) Armor_on();
  9. 	if (uarmc) (void) Cloak_on();
  10. 	if (uarmf) (void) Boots_on();
  11. 	if (uarmg) (void) Gloves_on();
  12. 	if (uarmh) (void) Helmet_on();
  13. 	if (uarms) (void) Shield_on();
  14. }

donning[edit]

  1. /* check whether the target object is currently being put on (or taken off) */
  2. boolean
  3. donning(otmp)		/* also checks for doffing */
  4. register struct obj *otmp;
  5. {
  6. /* long what = (occupation == take_off) ? taking_off : 0L; */
  7. long what = taking_off;	/* if nonzero, occupation is implied */
  8. boolean result = FALSE;
  9.  
  10. if (otmp == uarm)
  11. 	result = (afternmv == Armor_on || afternmv == Armor_off ||
  12. 		  what == WORN_ARMOR);
  13. #ifdef TOURIST
  14. else if (otmp == uarmu)
  15. 	result = (afternmv == Shirt_on || afternmv == Shirt_off ||
  16. 		  what == WORN_SHIRT);
  17. #endif
  18. else if (otmp == uarmc)
  19. 	result = (afternmv == Cloak_on || afternmv == Cloak_off ||
  20. 		  what == WORN_CLOAK);
  21. else if (otmp == uarmf)
  22. 	result = (afternmv == Boots_on || afternmv == Boots_off ||
  23. 		  what == WORN_BOOTS);
  24. else if (otmp == uarmh)
  25. 	result = (afternmv == Helmet_on || afternmv == Helmet_off ||
  26. 		  what == WORN_HELMET);
  27. else if (otmp == uarmg)
  28. 	result = (afternmv == Gloves_on || afternmv == Gloves_off ||
  29. 		  what == WORN_GLOVES);
  30. else if (otmp == uarms)
  31. 	result = (afternmv == Shield_on || afternmv == Shield_off ||
  32. 		  what == WORN_SHIELD);
  33.  
  34. return result;
  35. }

cancel_don[edit]

  1. void
  2. cancel_don()
  3. {
  4. 	/* the piece of armor we were donning/doffing has vanished, so stop
  5. 	 * wasting time on it (and don't dereference it when donning would
  6. 	 * otherwise finish)
  7. 	 */
  8. 	cancelled_don = (afternmv == Boots_on || afternmv == Helmet_on ||
  9. 			 afternmv == Gloves_on || afternmv == Armor_on);
  10. 	afternmv = 0;
  11. 	nomovemsg = (char *)0;
  12. 	multi = 0;
  13. 	todelay = 0;
  14. 	taking_off = 0L;
  15. }

dotakeoff[edit]

  1. static NEARDATA const char clothes[] = {ARMOR_CLASS, 0};
  2. static NEARDATA const char accessories[] = {RING_CLASS, AMULET_CLASS, TOOL_CLASS, FOOD_CLASS, 0};
  3.  
  4. /* the 'T' command */
  5. int
  6. dotakeoff()
  7. {
  8. 	register struct obj *otmp = (struct obj *)0;
  9. 	int armorpieces = 0;
  10.  
  11. #define MOREARM(x) if (x) { armorpieces++; otmp = x; }
  12. 	MOREARM(uarmh);
  13. 	MOREARM(uarms);
  14. 	MOREARM(uarmg);
  15. 	MOREARM(uarmf);
  16. 	if (uarmc) {
  17. 		armorpieces++;
  18. 		otmp = uarmc;
  19. 	} else if (uarm) {
  20. 		armorpieces++;
  21. 		otmp = uarm;
  22. #ifdef TOURIST
  23. 	} else if (uarmu) {
  24. 		armorpieces++;
  25. 		otmp = uarmu;
  26. #endif
  27. 	}
  28. 	if (!armorpieces) {
  29. 	     /* assert( GRAY_DRAGON_SCALES > YELLOW_DRAGON_SCALE_MAIL ); */
  30. 		if (uskin)
  31. 		    pline_The("%s merged with your skin!",
  32. 			      uskin->otyp >= GRAY_DRAGON_SCALES ?
  33. 				"dragon scales are" : "dragon scale mail is");
  34. 		else
  35. 		    pline("Not wearing any armor.%s", (iflags.cmdassist && 
  36. 				(uleft || uright || uamul || ublindf)) ?
  37. 			  "  Use 'R' command to remove accessories." : "");
  38. 		return 0;
  39. 	}
  40. 	if (armorpieces > 1)
  41. 		otmp = getobj(clothes, "take off");
  42. 	if (otmp == 0) return(0);
  43. 	if (!(otmp->owornmask & W_ARMOR)) {
  44. 		You("are not wearing that.");
  45. 		return(0);
  46. 	}
  47. 	/* note: the `uskin' case shouldn't be able to happen here; dragons
  48. 	   can't wear any armor so will end up with `armorpieces == 0' above */
  49. 	if (otmp == uskin || ((otmp == uarm) && uarmc)
  50. #ifdef TOURIST
  51. 			  || ((otmp == uarmu) && (uarmc || uarm))
  52. #endif
  53. 		) {
  54. 	    You_cant("take that off.");
  55. 	    return 0;
  56. 	}
  57.  
  58. 	reset_remarm();		/* clear takeoff_mask and taking_off */
  59. 	(void) select_off(otmp);
  60. 	if (!takeoff_mask) return 0;
  61. 	reset_remarm();		/* armoroff() doesn't use takeoff_mask */
  62.  
  63. 	(void) armoroff(otmp);
  64. 	return(1);
  65. }

doremring[edit]

  1. /* the 'R' command */
  2. int
  3. doremring()
  4. {
  5. 	register struct obj *otmp = 0;
  6. 	int Accessories = 0;
  7.  
  8. #define MOREACC(x) if (x) { Accessories++; otmp = x; }
  9. 	MOREACC(uleft);
  10. 	MOREACC(uright);
  11. 	MOREACC(uamul);
  12. 	MOREACC(ublindf);
  13.  
  14. 	if(!Accessories) {
  15. 		pline("Not wearing any accessories.%s", (iflags.cmdassist &&
  16. 			    (uarm || uarmc ||
  17. #ifdef TOURIST
  18. 			     uarmu ||
  19. #endif
  20. 			     uarms || uarmh || uarmg || uarmf)) ?
  21. 		      "  Use 'T' command to take off armor." : "");
  22. 		return(0);
  23. 	}
  24. 	if (Accessories != 1) otmp = getobj(accessories, "remove");
  25. 	if(!otmp) return(0);
  26. 	if(!(otmp->owornmask & (W_RING | W_AMUL | W_TOOL))) {
  27. 		You("are not wearing that.");
  28. 		return(0);
  29. 	}
  30.  
  31. 	reset_remarm();		/* clear takeoff_mask and taking_off */
  32. 	(void) select_off(otmp);
  33. 	if (!takeoff_mask) return 0;
  34. 	reset_remarm();		/* not used by Ring_/Amulet_/Blindf_off() */
  35.  
  36. 	if (otmp == uright || otmp == uleft) {
  37. 		/* Sometimes we want to give the off_msg before removing and
  38. 		 * sometimes after; for instance, "you were wearing a moonstone
  39. 		 * ring (on right hand)" is desired but "you were wearing a
  40. 		 * square amulet (being worn)" is not because of the redundant
  41. 		 * "being worn".
  42. 		 */
  43. 		off_msg(otmp);
  44. 		Ring_off(otmp);
  45. 	} else if (otmp == uamul) {
  46. 		Amulet_off();
  47. 		off_msg(otmp);
  48. 	} else if (otmp == ublindf) {
  49. 		Blindf_off(otmp);	/* does its own off_msg */
  50. 	} else {
  51. 		impossible("removing strange accessory?");
  52. 	}
  53. 	return(1);
  54. }

cursed[edit]

  1. /* Check if something worn is cursed _and_ unremovable. */
  2. int
  3. cursed(otmp)
  4. register struct obj *otmp;
  5. {
  6. 	/* Curses, like chickens, come home to roost. */
  7. 	if((otmp == uwep) ? welded(otmp) : (int)otmp->cursed) {
  8. 		You("can't.  %s cursed.",
  9. 			(is_boots(otmp) || is_gloves(otmp) || otmp->quan > 1L)
  10. 			? "They are" : "It is");
  11. 		otmp->bknown = TRUE;
  12. 		return(1);
  13. 	}
  14. 	return(0);
  15. }

armoroff[edit]

  1. int
  2. armoroff(otmp)
  3. register struct obj *otmp;
  4. {
  5. 	register int delay = -objects[otmp->otyp].oc_delay;
  6.  
  7. 	if(cursed(otmp)) return(0);
  8. 	if(delay) {
  9. 		nomul(delay);
  10. 		if (is_helmet(otmp)) {
  11. 			nomovemsg = "You finish taking off your helmet.";
  12. 			afternmv = Helmet_off;
  13. 		     }
  14. 		else if (is_gloves(otmp)) {
  15. 			nomovemsg = "You finish taking off your gloves.";
  16. 			afternmv = Gloves_off;
  17. 		     }
  18. 		else if (is_boots(otmp)) {
  19. 			nomovemsg = "You finish taking off your boots.";
  20. 			afternmv = Boots_off;
  21. 		     }
  22. 		else {
  23. 			nomovemsg = "You finish taking off your suit.";
  24. 			afternmv = Armor_off;
  25. 		}
  26. 	} else {
  27. 		/* Be warned!  We want off_msg after removing the item to
  28. 		 * avoid "You were wearing ____ (being worn)."  However, an
  29. 		 * item which grants fire resistance might cause some trouble
  30. 		 * if removed in Hell and lifesaving puts it back on; in this
  31. 		 * case the message will be printed at the wrong time (after
  32. 		 * the messages saying you died and were lifesaved).  Luckily,
  33. 		 * no cloak, shield, or fast-removable armor grants fire
  34. 		 * resistance, so we can safely do the off_msg afterwards.
  35. 		 * Rings do grant fire resistance, but for rings we want the
  36. 		 * off_msg before removal anyway so there's no problem.  Take
  37. 		 * care in adding armors granting fire resistance; this code
  38. 		 * might need modification.
  39. 		 * 3.2 (actually 3.1 even): this comment is obsolete since
  40. 		 * fire resistance is not needed for Gehennom.
  41. 		 */
  42. 		if(is_cloak(otmp))
  43. 			(void) Cloak_off();
  44. 		else if(is_shield(otmp))
  45. 			(void) Shield_off();
  46. 		else setworn((struct obj *)0, otmp->owornmask & W_ARMOR);
  47. 		off_msg(otmp);
  48. 	}
  49. 	takeoff_mask = taking_off = 0L;
  50. 	return(1);
  51. }

already_wearing[edit]

  1. STATIC_OVL void
  2. already_wearing(cc)
  3. const char *cc;
  4. {
  5. 	You("are already wearing %s%c", cc, (cc == c_that_) ? '!' : '.');
  6. }

already_wearing2[edit]

  1. STATIC_OVL void
  2. already_wearing2(cc1, cc2)
  3. const char *cc1, *cc2;
  4. {
  5. 	You_cant("wear %s because you're wearing %s there already.", cc1, cc2);
  6. }

canwearobj[edit]

  1. /*
  2. * canwearobj checks to see whether the player can wear a piece of armor
  3. *
  4. * inputs: otmp (the piece of armor)
  5. *         noisy (if TRUE give error messages, otherwise be quiet about it)
  6. * output: mask (otmp's armor type)
  7. */
  8. int
  9. canwearobj(otmp,mask,noisy)
  10. struct obj *otmp;
  11. long *mask;
  12. boolean noisy;
  13. {
  14. int err = 0;
  15. const char *which;
  16.  
  17. which = is_cloak(otmp) ? c_cloak :
  18. #ifdef TOURIST
  19. 	    is_shirt(otmp) ? c_shirt :
  20. #endif
  21. 	    is_suit(otmp) ? c_suit : 0;
  22. if (which && cantweararm(youmonst.data) &&
  23. 	    /* same exception for cloaks as used in m_dowear() */
  24. 	    (which != c_cloak || youmonst.data->msize != MZ_SMALL) &&
  25. 	    (racial_exception(&youmonst, otmp) < 1)) {
  26. 	if (noisy) pline_The("%s will not fit on your body.", which);
  27. 	return 0;
  28. } else if (otmp->owornmask & W_ARMOR) {
  29. 	if (noisy) already_wearing(c_that_);
  30. 	return 0;
  31. }
  32.  
  33. if (welded(uwep) && bimanual(uwep) &&
  34. 	    (is_suit(otmp)
  35. #ifdef TOURIST
  36. 			|| is_shirt(otmp)
  37. #endif
  38. 	    )) {
  39. 	if (noisy)
  40. 	    You("cannot do that while holding your %s.",
  41. 		is_sword(uwep) ? c_sword : c_weapon);
  42. 	return 0;
  43. }
  44.  
  45. if (is_helmet(otmp)) {
  46. 	if (uarmh) {
  47. 	    if (noisy) already_wearing(an(c_helmet));
  48. 	    err++;
  49. 	} else if (Upolyd && has_horns(youmonst.data) && !is_flimsy(otmp)) {
  50. 	    /* (flimsy exception matches polyself handling) */
  51. 	    if (noisy)
  52. 		pline_The("%s won't fit over your horn%s.",
  53. 			  c_helmet, plur(num_horns(youmonst.data)));
  54. 	    err++;
  55. 	} else
  56. 	    *mask = W_ARMH;
  57. } else if (is_shield(otmp)) {
  58. 	if (uarms) {
  59. 	    if (noisy) already_wearing(an(c_shield));
  60. 	    err++;
  61. 	} else if (uwep && bimanual(uwep)) {
  62. 	    if (noisy) 
  63. 		You("cannot wear a shield while wielding a two-handed %s.",
  64. 		    is_sword(uwep) ? c_sword :
  65. 		    (uwep->otyp == BATTLE_AXE) ? c_axe : c_weapon);
  66. 	    err++;
  67. 	} else if (u.twoweap) {
  68. 	    if (noisy)
  69. 		You("cannot wear a shield while wielding two weapons.");
  70. 	    err++;
  71. 	} else
  72. 	    *mask = W_ARMS;
  73. } else if (is_boots(otmp)) {
  74. 	if (uarmf) {
  75. 	    if (noisy) already_wearing(c_boots);
  76. 	    err++;
  77. 	} else if (Upolyd && slithy(youmonst.data)) {
  78. 	    if (noisy) You("have no feet...");	/* not body_part(FOOT) */
  79. 	    err++;
  80. 	} else if (Upolyd && youmonst.data->mlet == S_CENTAUR) {
  81. 	    /* break_armor() pushes boots off for centaurs,
  82. 	       so don't let dowear() put them back on... */
  83. 	    if (noisy) pline("You have too many hooves to wear %s.",
  84. 			     c_boots);	/* makeplural(body_part(FOOT)) yields
  85. 					   "rear hooves" which sounds odd */
  86. 	    err++;
  87. 	} else if (u.utrap && (u.utraptype == TT_BEARTRAP ||
  88. 				u.utraptype == TT_INFLOOR)) {
  89. 	    if (u.utraptype == TT_BEARTRAP) {
  90. 		if (noisy) Your("%s is trapped!", body_part(FOOT));
  91. 	    } else {
  92. 		if (noisy) Your("%s are stuck in the %s!",
  93. 				makeplural(body_part(FOOT)),
  94. 				surface(u.ux, u.uy));
  95. 	    }
  96. 	    err++;
  97. 	} else
  98. 	    *mask = W_ARMF;
  99. } else if (is_gloves(otmp)) {
  100. 	if (uarmg) {
  101. 	    if (noisy) already_wearing(c_gloves);
  102. 	    err++;
  103. 	} else if (welded(uwep)) {
  104. 	    if (noisy) You("cannot wear gloves over your %s.",
  105. 			   is_sword(uwep) ? c_sword : c_weapon);
  106. 	    err++;
  107. 	} else
  108. 	    *mask = W_ARMG;
  109. #ifdef TOURIST
  110. } else if (is_shirt(otmp)) {
  111. 	if (uarm || uarmc || uarmu) {
  112. 	    if (uarmu) {
  113. 		if (noisy) already_wearing(an(c_shirt));
  114. 	    } else {
  115. 		if (noisy) You_cant("wear that over your %s.",
  116. 			           (uarm && !uarmc) ? c_armor : cloak_simple_name(uarmc));
  117. 	    }
  118. 	    err++;
  119. 	} else
  120. 	    *mask = W_ARMU;
  121. #endif
  122. } else if (is_cloak(otmp)) {
  123. 	if (uarmc) {
  124. 	    if (noisy) already_wearing(an(cloak_simple_name(uarmc)));
  125. 	    err++;
  126. 	} else
  127. 	    *mask = W_ARMC;
  128. } else if (is_suit(otmp)) {
  129. 	if (uarmc) {
  130. 	    if (noisy) You("cannot wear armor over a %s.", cloak_simple_name(uarmc));
  131. 	    err++;
  132. 	} else if (uarm) {
  133. 	    if (noisy) already_wearing("some armor");
  134. 	    err++;
  135. 	} else
  136. 	    *mask = W_ARM;
  137. } else {
  138. 	/* getobj can't do this after setting its allow_all flag; that
  139. 	   happens if you have armor for slots that are covered up or
  140. 	   extra armor for slots that are filled */
  141. 	if (noisy) silly_thing("wear", otmp);
  142. 	err++;
  143. }
  144. /* Unnecessary since now only weapons and special items like pick-axes get
  145. * welded to your hand, not armor
  146. if (welded(otmp)) {
  147. 	if (!err++) {
  148. 	    if (noisy) weldmsg(otmp);
  149. 	}
  150. }
  151. */
  152. return !err;
  153. }

dowear[edit]

  1. /* the 'W' command */
  2. int
  3. dowear()
  4. {
  5. 	struct obj *otmp;
  6. 	int delay;
  7. 	long mask = 0;
  8.  
  9. 	/* cantweararm checks for suits of armor */
  10. 	/* verysmall or nohands checks for shields, gloves, etc... */
  11. 	if ((verysmall(youmonst.data) || nohands(youmonst.data))) {
  12. 		pline("Don't even bother.");
  13. 		return(0);
  14. 	}
  15.  
  16. 	otmp = getobj(clothes, "wear");
  17. 	if(!otmp) return(0);
  18.  
  19. 	if (!canwearobj(otmp,&mask,TRUE)) return(0);
  20.  
  21. 	if (otmp->oartifact && !touch_artifact(otmp, &youmonst))
  22. 	    return 1;	/* costs a turn even though it didn't get worn */
  23.  
  24. 	if (otmp->otyp == HELM_OF_OPPOSITE_ALIGNMENT &&
  25. 			qstart_level.dnum == u.uz.dnum) {	/* in quest */
  26. 		if (u.ualignbase[A_CURRENT] == u.ualignbase[A_ORIGINAL])
  27. 			You("narrowly avoid losing all chance at your goal.");
  28. 		else	/* converted */
  29. 			You("are suddenly overcome with shame and change your mind.");
  30. 		u.ublessed = 0; /* lose your god's protection */
  31. 		makeknown(otmp->otyp);
  32. 		flags.botl = 1;
  33. 		return 1;
  34. 	}
  35.  
  36. 	otmp->known = TRUE;
  37. 	if(otmp == uwep)
  38. 		setuwep((struct obj *)0);
  39. 	if (otmp == uswapwep)
  40. 		setuswapwep((struct obj *) 0);
  41. 	if (otmp == uquiver)
  42. 		setuqwep((struct obj *) 0);
  43. 	setworn(otmp, mask);
  44. 	delay = -objects[otmp->otyp].oc_delay;
  45. 	if(delay){
  46. 		nomul(delay);
  47. 		if(is_boots(otmp)) afternmv = Boots_on;
  48. 		if(is_helmet(otmp)) afternmv = Helmet_on;
  49. 		if(is_gloves(otmp)) afternmv = Gloves_on;
  50. 		if(otmp == uarm) afternmv = Armor_on;
  51. 		nomovemsg = "You finish your dressing maneuver.";
  52. 	} else {
  53. 		if(is_cloak(otmp)) (void) Cloak_on();
  54. 		if (is_shield(otmp)) (void) Shield_on();
  55. #ifdef TOURIST
  56. 		if (is_shirt(otmp)) (void) Shirt_on();
  57. #endif
  58. 		on_msg(otmp);
  59. 	}
  60. 	takeoff_mask = taking_off = 0L;
  61. 	return(1);
  62. }

doputon[edit]

  1. int
  2. doputon()
  3. {
  4. 	register struct obj *otmp;
  5. 	long mask = 0L;
  6.  
  7. 	if(uleft && uright && uamul && ublindf) {
  8. 		Your("%s%s are full, and you're already wearing an amulet and %s.",
  9. 			humanoid(youmonst.data) ? "ring-" : "",
  10. 			makeplural(body_part(FINGER)),
  11. 			ublindf->otyp==LENSES ? "some lenses" : "a blindfold");
  12. 		return(0);
  13. 	}
  14. 	otmp = getobj(accessories, "put on");
  15. 	if(!otmp) return(0);
  16. 	if(otmp->owornmask & (W_RING | W_AMUL | W_TOOL)) {
  17. 		already_wearing(c_that_);
  18. 		return(0);
  19. 	}
  20. 	if(welded(otmp)) {
  21. 		weldmsg(otmp);
  22. 		return(0);
  23. 	}
  24. 	if(otmp == uwep)
  25. 		setuwep((struct obj *)0);
  26. 	if(otmp == uswapwep)
  27. 		setuswapwep((struct obj *) 0);
  28. 	if(otmp == uquiver)
  29. 		setuqwep((struct obj *) 0);
  30. 	if(otmp->oclass == RING_CLASS || otmp->otyp == MEAT_RING) {
  31. 		if(nolimbs(youmonst.data)) {
  32. 			You("cannot make the ring stick to your body.");
  33. 			return(0);
  34. 		}
  35. 		if(uleft && uright){
  36. 			There("are no more %s%s to fill.",
  37. 				humanoid(youmonst.data) ? "ring-" : "",
  38. 				makeplural(body_part(FINGER)));
  39. 			return(0);
  40. 		}
  41. 		if(uleft) mask = RIGHT_RING;
  42. 		else if(uright) mask = LEFT_RING;
  43. 		else do {
  44. 			char qbuf[QBUFSZ];
  45. 			char answer;
  46.  
  47. 			Sprintf(qbuf, "Which %s%s, Right or Left?",
  48. 				humanoid(youmonst.data) ? "ring-" : "",
  49. 				body_part(FINGER));
  50. 			if(!(answer = yn_function(qbuf, "rl", '\0')))
  51. 				return(0);
  52. 			switch(answer){
  53. 			case 'l':
  54. 			case 'L':
  55. 				mask = LEFT_RING;
  56. 				break;
  57. 			case 'r':
  58. 			case 'R':
  59. 				mask = RIGHT_RING;
  60. 				break;
  61. 			}
  62. 		} while(!mask);
  63. 		if (uarmg && uarmg->cursed) {
  64. 			uarmg->bknown = TRUE;
  65. 		    You("cannot remove your gloves to put on the ring.");
  66. 			return(0);
  67. 		}
  68. 		if (welded(uwep) && bimanual(uwep)) {
  69. 			/* welded will set bknown */
  70. 	    You("cannot free your weapon hands to put on the ring.");
  71. 			return(0);
  72. 		}
  73. 		if (welded(uwep) && mask==RIGHT_RING) {
  74. 			/* welded will set bknown */
  75. 	    You("cannot free your weapon hand to put on the ring.");
  76. 			return(0);
  77. 		}
  78. 		if (otmp->oartifact && !touch_artifact(otmp, &youmonst))
  79. 		    return 1; /* costs a turn even though it didn't get worn */
  80. 		setworn(otmp, mask);
  81. 		Ring_on(otmp);
  82. 	} else if (otmp->oclass == AMULET_CLASS) {
  83. 		if(uamul) {
  84. 			already_wearing("an amulet");
  85. 			return(0);
  86. 		}
  87. 		if (otmp->oartifact && !touch_artifact(otmp, &youmonst))
  88. 		    return 1;
  89. 		setworn(otmp, W_AMUL);
  90. 		if (otmp->otyp == AMULET_OF_CHANGE) {
  91. 			Amulet_on();
  92. 			/* Don't do a prinv() since the amulet is now gone */
  93. 			return(1);
  94. 		}
  95. 		Amulet_on();
  96. 	} else {	/* it's a blindfold, towel, or lenses */
  97. 		if (ublindf) {
  98. 			if (ublindf->otyp == TOWEL)
  99. 				Your("%s is already covered by a towel.",
  100. 					body_part(FACE));
  101. 			else if (ublindf->otyp == BLINDFOLD) {
  102. 				if (otmp->otyp == LENSES)
  103. 					already_wearing2("lenses", "a blindfold");
  104. 				else
  105. 					already_wearing("a blindfold");
  106. 			} else if (ublindf->otyp == LENSES) {
  107. 				if (otmp->otyp == BLINDFOLD)
  108. 					already_wearing2("a blindfold", "some lenses");
  109. 				else
  110. 					already_wearing("some lenses");
  111. 			} else
  112. 				already_wearing(something); /* ??? */
  113. 			return(0);
  114. 		}
  115. 		if (otmp->otyp != BLINDFOLD && otmp->otyp != TOWEL && otmp->otyp != LENSES) {
  116. 			You_cant("wear that!");
  117. 			return(0);
  118. 		}
  119. 		if (otmp->oartifact && !touch_artifact(otmp, &youmonst))
  120. 		    return 1;
  121. 		Blindf_on(otmp);
  122. 		return(1);
  123. 	}
  124. 	if (is_worn(otmp))
  125. 	    prinv((char *)0, otmp, 0L);
  126. 	return(1);
  127. }
  128.  
  129. #endif /* OVLB */

find_ac[edit]

  1. #ifdef OVL0
  2.  
  3. void
  4. find_ac()
  5. {
  6. 	int uac = mons[u.umonnum].ac;
  7.  
  8. 	if(uarm) uac -= ARM_BONUS(uarm);
  9. 	if(uarmc) uac -= ARM_BONUS(uarmc);
  10. 	if(uarmh) uac -= ARM_BONUS(uarmh);
  11. 	if(uarmf) uac -= ARM_BONUS(uarmf);
  12. 	if(uarms) uac -= ARM_BONUS(uarms);
  13. 	if(uarmg) uac -= ARM_BONUS(uarmg);
  14. #ifdef TOURIST
  15. 	if(uarmu) uac -= ARM_BONUS(uarmu);
  16. #endif
  17. 	if(uleft && uleft->otyp == RIN_PROTECTION) uac -= uleft->spe;
  18. 	if(uright && uright->otyp == RIN_PROTECTION) uac -= uright->spe;
  19. 	if (HProtection & INTRINSIC) uac -= u.ublessed;
  20. 	uac -= u.uspellprot;
  21. 	if (uac < -128) uac = -128;	/* u.uac is an schar */
  22. 	if(uac != u.uac){
  23. 		u.uac = uac;
  24. 		flags.botl = 1;
  25. 	}
  26. }
  27.  
  28. #endif /* OVL0 */

glibr[edit]

  1. #ifdef OVLB
  2.  
  3. void
  4. glibr()
  5. {
  6. 	register struct obj *otmp;
  7. 	int xfl = 0;
  8. 	boolean leftfall, rightfall;
  9. 	const char *otherwep = 0;
  10.  
  11. 	leftfall = (uleft && !uleft->cursed &&
  12. 		    (!uwep || !welded(uwep) || !bimanual(uwep)));
  13. 	rightfall = (uright && !uright->cursed && (!welded(uwep)));
  14. 	if (!uarmg && (leftfall || rightfall) && !nolimbs(youmonst.data)) {
  15. 		/* changed so cursed rings don't fall off, GAN 10/30/86 */
  16. 		Your("%s off your %s.",
  17. 			(leftfall && rightfall) ? "rings slip" : "ring slips",
  18. 			(leftfall && rightfall) ? makeplural(body_part(FINGER)) :
  19. 			body_part(FINGER));
  20. 		xfl++;
  21. 		if (leftfall) {
  22. 			otmp = uleft;
  23. 			Ring_off(uleft);
  24. 			dropx(otmp);
  25. 		}
  26. 		if (rightfall) {
  27. 			otmp = uright;
  28. 			Ring_off(uright);
  29. 			dropx(otmp);
  30. 		}
  31. 	}
  32.  
  33. 	otmp = uswapwep;
  34. 	if (u.twoweap && otmp) {
  35. 		otherwep = is_sword(otmp) ? c_sword :
  36. 		    makesingular(oclass_names[(int)otmp->oclass]);
  37. 		Your("%s %sslips from your %s.",
  38. 			otherwep,
  39. 			xfl ? "also " : "",
  40. 			makeplural(body_part(HAND)));
  41. 		setuswapwep((struct obj *)0);
  42. 		xfl++;
  43. 		if (otmp->otyp != LOADSTONE || !otmp->cursed)
  44. 			dropx(otmp);
  45. 	}
  46. 	otmp = uwep;
  47. 	if (otmp && !welded(otmp)) {
  48. 		const char *thiswep;
  49.  
  50. 		/* nice wording if both weapons are the same type */
  51. 		thiswep = is_sword(otmp) ? c_sword :
  52. 		    makesingular(oclass_names[(int)otmp->oclass]);
  53. 		if (otherwep && strcmp(thiswep, otherwep)) otherwep = 0;
  54.  
  55. 		/* changed so cursed weapons don't fall, GAN 10/30/86 */
  56. 		Your("%s%s %sslips from your %s.",
  57. 			otherwep ? "other " : "", thiswep,
  58. 			xfl ? "also " : "",
  59. 			makeplural(body_part(HAND)));
  60. 		setuwep((struct obj *)0);
  61. 		if (otmp->otyp != LOADSTONE || !otmp->cursed)
  62. 			dropx(otmp);
  63. 	}
  64. }

some_armor[edit]

  1. struct obj *
  2. some_armor(victim)
  3. struct monst *victim;
  4. {
  5. 	register struct obj *otmph, *otmp;
  6.  
  7. 	otmph = (victim == &youmonst) ? uarmc : which_armor(victim, W_ARMC);
  8. 	if (!otmph)
  9. 	    otmph = (victim == &youmonst) ? uarm : which_armor(victim, W_ARM);
  10. #ifdef TOURIST
  11. 	if (!otmph)
  12. 	    otmph = (victim == &youmonst) ? uarmu : which_armor(victim, W_ARMU);
  13. #endif
  14.  
  15. 	otmp = (victim == &youmonst) ? uarmh : which_armor(victim, W_ARMH);
  16. 	if(otmp && (!otmph || !rn2(4))) otmph = otmp;
  17. 	otmp = (victim == &youmonst) ? uarmg : which_armor(victim, W_ARMG);
  18. 	if(otmp && (!otmph || !rn2(4))) otmph = otmp;
  19. 	otmp = (victim == &youmonst) ? uarmf : which_armor(victim, W_ARMF);
  20. 	if(otmp && (!otmph || !rn2(4))) otmph = otmp;
  21. 	otmp = (victim == &youmonst) ? uarms : which_armor(victim, W_ARMS);
  22. 	if(otmp && (!otmph || !rn2(4))) otmph = otmp;
  23. 	return(otmph);
  24. }

erode_armor[edit]

  1. /* erode some arbitrary armor worn by the victim */
  2. void
  3. erode_armor(victim, acid_dmg)
  4. struct monst *victim;
  5. boolean acid_dmg;
  6. {
  7. 	struct obj *otmph = some_armor(victim);
  8.  
  9. 	if (otmph && (otmph != uarmf)) {
  10. 	    erode_obj(otmph, acid_dmg, FALSE);
  11. 	    if (carried(otmph)) update_inventory();
  12. 	}
  13. }

stuck_ring[edit]

  1. /* used for praying to check and fix levitation trouble */
  2. struct obj *
  3. stuck_ring(ring, otyp)
  4. struct obj *ring;
  5. int otyp;
  6. {
  7. if (ring != uleft && ring != uright) {
  8. 	impossible("stuck_ring: neither left nor right?");
  9. 	return (struct obj *)0;
  10. }
  11.  
  12. if (ring && ring->otyp == otyp) {
  13. 	/* reasons ring can't be removed match those checked by select_off();
  14. 	   limbless case has extra checks because ordinarily it's temporary */
  15. 	if (nolimbs(youmonst.data) &&
  16. 		uamul && uamul->otyp == AMULET_OF_UNCHANGING && uamul->cursed)
  17. 	    return uamul;
  18. 	if (welded(uwep) && (ring == uright || bimanual(uwep))) return uwep;
  19. 	if (uarmg && uarmg->cursed) return uarmg;
  20. 	if (ring->cursed) return ring;
  21. }
  22. /* either no ring or not right type or nothing prevents its removal */
  23. return (struct obj *)0;
  24. }

unchanger[edit]

  1. /* also for praying; find worn item that confers "Unchanging" attribute */
  2. struct obj *
  3. unchanger()
  4. {
  5. if (uamul && uamul->otyp == AMULET_OF_UNCHANGING) return uamul;
  6. return 0;
  7. }

select_off[edit]

  1. /* occupation callback for 'A' */
  2. STATIC_PTR
  3. int
  4. select_off(otmp)
  5. register struct obj *otmp;
  6. {
  7. 	struct obj *why;
  8. 	char buf[BUFSZ];
  9.  
  10. 	if (!otmp) return 0;
  11. 	*buf = '\0';			/* lint suppresion */
  12.  
  13. 	/* special ring checks */
  14. 	if (otmp == uright || otmp == uleft) {
  15. 	    if (nolimbs(youmonst.data)) {
  16. 		pline_The("ring is stuck.");
  17. 		return 0;
  18. 	    }
  19. 	    why = 0;	/* the item which prevents ring removal */
  20. 	    if (welded(uwep) && (otmp == uright || bimanual(uwep))) {
  21. 		Sprintf(buf, "free a weapon %s", body_part(HAND));
  22. 		why = uwep;
  23. 	    } else if (uarmg && uarmg->cursed) {
  24. 		Sprintf(buf, "take off your %s", c_gloves);
  25. 		why = uarmg;
  26. 	    }
  27. 	    if (why) {
  28. 		You("cannot %s to remove the ring.", buf);
  29. 		why->bknown = TRUE;
  30. 		return 0;
  31. 	    }
  32. 	}
  33. 	/* special glove checks */
  34. 	if (otmp == uarmg) {
  35. 	    if (welded(uwep)) {
  36. 		You("are unable to take off your %s while wielding that %s.",
  37. 		    c_gloves, is_sword(uwep) ? c_sword : c_weapon);
  38. 		uwep->bknown = TRUE;
  39. 		return 0;
  40. 	    } else if (Glib) {
  41. 		You_cant("take off the slippery %s with your slippery %s.",
  42. 			 c_gloves, makeplural(body_part(FINGER)));
  43. 		return 0;
  44. 	    }
  45. 	}
  46. 	/* special boot checks */
  47. 	if (otmp == uarmf) {
  48. 	    if (u.utrap && u.utraptype == TT_BEARTRAP) {
  49. 		pline_The("bear trap prevents you from pulling your %s out.",
  50. 			  body_part(FOOT));
  51. 		return 0;
  52. 	    } else if (u.utrap && u.utraptype == TT_INFLOOR) {
  53. 		You("are stuck in the %s, and cannot pull your %s out.",
  54. 		    surface(u.ux, u.uy), makeplural(body_part(FOOT)));
  55. 		return 0;
  56. 	    }
  57. 	}
  58. 	/* special suit and shirt checks */
  59. 	if (otmp == uarm
  60. #ifdef TOURIST
  61. 			|| otmp == uarmu
  62. #endif
  63. 		) {
  64. 	    why = 0;	/* the item which prevents disrobing */
  65. 	    if (uarmc && uarmc->cursed) {
  66. 		Sprintf(buf, "remove your %s", cloak_simple_name(uarmc));
  67. 		why = uarmc;
  68. #ifdef TOURIST
  69. 	    } else if (otmp == uarmu && uarm && uarm->cursed) {
  70. 		Sprintf(buf, "remove your %s", c_suit);
  71. 		why = uarm;
  72. #endif
  73. 	    } else if (welded(uwep) && bimanual(uwep)) {
  74. 		Sprintf(buf, "release your %s",
  75. 			is_sword(uwep) ? c_sword :
  76. 			(uwep->otyp == BATTLE_AXE) ? c_axe : c_weapon);
  77. 		why = uwep;
  78. 	    }
  79. 	    if (why) {
  80. 		You("cannot %s to take off %s.", buf, the(xname(otmp)));
  81. 		why->bknown = TRUE;
  82. 		return 0;
  83. 	    }
  84. 	}
  85. 	/* basic curse check */
  86. 	if (otmp == uquiver || (otmp == uswapwep && !u.twoweap)) {
  87. 	    ;	/* some items can be removed even when cursed */
  88. 	} else {
  89. 	    /* otherwise, this is fundamental */
  90. 	    if (cursed(otmp)) return 0;
  91. 	}
  92.  
  93. 	if(otmp == uarm) takeoff_mask |= WORN_ARMOR;
  94. 	else if(otmp == uarmc) takeoff_mask |= WORN_CLOAK;
  95. 	else if(otmp == uarmf) takeoff_mask |= WORN_BOOTS;
  96. 	else if(otmp == uarmg) takeoff_mask |= WORN_GLOVES;
  97. 	else if(otmp == uarmh) takeoff_mask |= WORN_HELMET;
  98. 	else if(otmp == uarms) takeoff_mask |= WORN_SHIELD;
  99. #ifdef TOURIST
  100. 	else if(otmp == uarmu) takeoff_mask |= WORN_SHIRT;
  101. #endif
  102. 	else if(otmp == uleft) takeoff_mask |= LEFT_RING;
  103. 	else if(otmp == uright) takeoff_mask |= RIGHT_RING;
  104. 	else if(otmp == uamul) takeoff_mask |= WORN_AMUL;
  105. 	else if(otmp == ublindf) takeoff_mask |= WORN_BLINDF;
  106. 	else if(otmp == uwep) takeoff_mask |= W_WEP;
  107. 	else if(otmp == uswapwep) takeoff_mask |= W_SWAPWEP;
  108. 	else if(otmp == uquiver) takeoff_mask |= W_QUIVER;
  109.  
  110. 	else impossible("select_off: %s???", doname(otmp));
  111.  
  112. 	return(0);
  113. }

do_takeoff[edit]

  1. STATIC_OVL struct obj *
  2. do_takeoff()
  3. {
  4. 	register struct obj *otmp = (struct obj *)0;
  5.  
  6. 	if (taking_off == W_WEP) {
  7. 	  if(!cursed(uwep)) {
  8. 	    setuwep((struct obj *) 0);
  9. 	    You("are empty %s.", body_part(HANDED));
  10. 	    u.twoweap = FALSE;
  11. 	  }
  12. 	} else if (taking_off == W_SWAPWEP) {
  13. 	  setuswapwep((struct obj *) 0);
  14. 	  You("no longer have a second weapon readied.");
  15. 	  u.twoweap = FALSE;
  16. 	} else if (taking_off == W_QUIVER) {
  17. 	  setuqwep((struct obj *) 0);
  18. 	  You("no longer have ammunition readied.");
  19. 	} else if (taking_off == WORN_ARMOR) {
  20. 	  otmp = uarm;
  21. 	  if(!cursed(otmp)) (void) Armor_off();
  22. 	} else if (taking_off == WORN_CLOAK) {
  23. 	  otmp = uarmc;
  24. 	  if(!cursed(otmp)) (void) Cloak_off();
  25. 	} else if (taking_off == WORN_BOOTS) {
  26. 	  otmp = uarmf;
  27. 	  if(!cursed(otmp)) (void) Boots_off();
  28. 	} else if (taking_off == WORN_GLOVES) {
  29. 	  otmp = uarmg;
  30. 	  if(!cursed(otmp)) (void) Gloves_off();
  31. 	} else if (taking_off == WORN_HELMET) {
  32. 	  otmp = uarmh;
  33. 	  if(!cursed(otmp)) (void) Helmet_off();
  34. 	} else if (taking_off == WORN_SHIELD) {
  35. 	  otmp = uarms;
  36. 	  if(!cursed(otmp)) (void) Shield_off();
  37. #ifdef TOURIST
  38. 	} else if (taking_off == WORN_SHIRT) {
  39. 	  otmp = uarmu;
  40. 	  if (!cursed(otmp)) (void) Shirt_off();
  41. #endif
  42. 	} else if (taking_off == WORN_AMUL) {
  43. 	  otmp = uamul;
  44. 	  if(!cursed(otmp)) Amulet_off();
  45. 	} else if (taking_off == LEFT_RING) {
  46. 	  otmp = uleft;
  47. 	  if(!cursed(otmp)) Ring_off(uleft);
  48. 	} else if (taking_off == RIGHT_RING) {
  49. 	  otmp = uright;
  50. 	  if(!cursed(otmp)) Ring_off(uright);
  51. 	} else if (taking_off == WORN_BLINDF) {
  52. 	  if (!cursed(ublindf)) Blindf_off(ublindf);
  53. 	} else impossible("do_takeoff: taking off %lx", taking_off);
  54.  
  55. 	return(otmp);
  56. }

take_off[edit]

  1. static const char *disrobing = "";
  2.  
  3. STATIC_PTR
  4. int
  5. take_off()
  6. {
  7. 	register int i;
  8. 	register struct obj *otmp;
  9.  
  10. 	if (taking_off) {
  11. 	    if (todelay > 0) {
  12. 		todelay--;
  13. 		return(1);	/* still busy */
  14. 	    } else {
  15. 		if ((otmp = do_takeoff())) off_msg(otmp);
  16. 	    }
  17. 	    takeoff_mask &= ~taking_off;
  18. 	    taking_off = 0L;
  19. 	}
  20.  
  21. 	for(i = 0; takeoff_order[i]; i++)
  22. 	    if(takeoff_mask & takeoff_order[i]) {
  23. 		taking_off = takeoff_order[i];
  24. 		break;
  25. 	    }
  26.  
  27. 	otmp = (struct obj *) 0;
  28. 	todelay = 0;
  29.  
  30. 	if (taking_off == 0L) {
  31. 	  You("finish %s.", disrobing);
  32. 	  return 0;
  33. 	} else if (taking_off == W_WEP) {
  34. 	  todelay = 1;
  35. 	} else if (taking_off == W_SWAPWEP) {
  36. 	  todelay = 1;
  37. 	} else if (taking_off == W_QUIVER) {
  38. 	  todelay = 1;
  39. 	} else if (taking_off == WORN_ARMOR) {
  40. 	  otmp = uarm;
  41. 	  /* If a cloak is being worn, add the time to take it off and put
  42. 	   * it back on again.  Kludge alert! since that time is 0 for all
  43. 	   * known cloaks, add 1 so that it actually matters...
  44. 	   */
  45. 	  if (uarmc) todelay += 2 * objects[uarmc->otyp].oc_delay + 1;
  46. 	} else if (taking_off == WORN_CLOAK) {
  47. 	  otmp = uarmc;
  48. 	} else if (taking_off == WORN_BOOTS) {
  49. 	  otmp = uarmf;
  50. 	} else if (taking_off == WORN_GLOVES) {
  51. 	  otmp = uarmg;
  52. 	} else if (taking_off == WORN_HELMET) {
  53. 	  otmp = uarmh;
  54. 	} else if (taking_off == WORN_SHIELD) {
  55. 	  otmp = uarms;
  56. #ifdef TOURIST
  57. 	} else if (taking_off == WORN_SHIRT) {
  58. 	  otmp = uarmu;
  59. 	  /* add the time to take off and put back on armor and/or cloak */
  60. 	  if (uarm)  todelay += 2 * objects[uarm->otyp].oc_delay;
  61. 	  if (uarmc) todelay += 2 * objects[uarmc->otyp].oc_delay + 1;
  62. #endif
  63. 	} else if (taking_off == WORN_AMUL) {
  64. 	  todelay = 1;
  65. 	} else if (taking_off == LEFT_RING) {
  66. 	  todelay = 1;
  67. 	} else if (taking_off == RIGHT_RING) {
  68. 	  todelay = 1;
  69. 	} else if (taking_off == WORN_BLINDF) {
  70. 	  todelay = 2;
  71. 	} else {
  72. 	  impossible("take_off: taking off %lx", taking_off);
  73. 	  return 0;	/* force done */
  74. 	}
  75.  
  76. 	if (otmp) todelay += objects[otmp->otyp].oc_delay;
  77.  
  78. 	/* Since setting the occupation now starts the counter next move, that
  79. 	 * would always produce a delay 1 too big per item unless we subtract
  80. 	 * 1 here to account for it.
  81. 	 */
  82. 	if (todelay > 0) todelay--;
  83.  
  84. 	set_occupation(take_off, disrobing, 0);
  85. 	return(1);		/* get busy */
  86. }

reset_remarm[edit]

  1. /* clear saved context to avoid inappropriate resumption of interrupted 'A' */
  2. void
  3. reset_remarm()
  4. {
  5. 	taking_off = takeoff_mask = 0L;
  6. 	disrobing = nul;
  7. }

doddoremarm[edit]

  1. /* the 'A' command -- remove multiple worn items */
  2. int
  3. doddoremarm()
  4. {
  5. int result = 0;
  6.  
  7. if (taking_off || takeoff_mask) {
  8. 	You("continue %s.", disrobing);
  9. 	set_occupation(take_off, disrobing, 0);
  10. 	return 0;
  11. } else if (!uwep && !uswapwep && !uquiver && !uamul && !ublindf &&
  12. 		!uleft && !uright && !wearing_armor()) {
  13. 	You("are not wearing anything.");
  14. 	return 0;
  15. }
  16.  
  17. add_valid_menu_class(0); /* reset */
  18. if (flags.menu_style != MENU_TRADITIONAL ||
  19. 	    (result = ggetobj("take off", select_off, 0, FALSE, (unsigned *)0)) < -1)
  20. 	result = menu_remarm(result);
  21.  
  22. if (takeoff_mask) {
  23. 	/* default activity for armor and/or accessories,
  24. 	   possibly combined with weapons */
  25. 	disrobing = "disrobing";
  26. 	/* specific activity when handling weapons only */
  27. 	if (!(takeoff_mask & ~(W_WEP|W_SWAPWEP|W_QUIVER)))
  28. 	    disrobing = "disarming";
  29. 	(void) take_off();
  30. }
  31. /* The time to perform the command is already completely accounted for
  32. * in take_off(); if we return 1, that would add an extra turn to each
  33. * disrobe.
  34. */
  35. return 0;
  36. }

= menu_remarm[edit]

  1. STATIC_OVL int
  2. menu_remarm(retry)
  3. int retry;
  4. {
  5. int n, i = 0;
  6. menu_item *pick_list;
  7. boolean all_worn_categories = TRUE;
  8.  
  9. if (retry) {
  10. 	all_worn_categories = (retry == -2);
  11. } else if (flags.menu_style == MENU_FULL) {
  12. 	all_worn_categories = FALSE;
  13. 	n = query_category("What type of things do you want to take off?",
  14. 			   invent, WORN_TYPES|ALL_TYPES, &pick_list, PICK_ANY);
  15. 	if (!n) return 0;
  16. 	for (i = 0; i < n; i++) {
  17. 	    if (pick_list[i].item.a_int == ALL_TYPES_SELECTED)
  18. 		all_worn_categories = TRUE;
  19. 	    else
  20. 		add_valid_menu_class(pick_list[i].item.a_int);
  21. 	}
  22. 	free((genericptr_t) pick_list);
  23. } else if (flags.menu_style == MENU_COMBINATION) {
  24. 	all_worn_categories = FALSE;
  25. 	if (ggetobj("take off", select_off, 0, TRUE, (unsigned *)0) == -2)
  26. 	    all_worn_categories = TRUE;
  27. }
  28.  
  29. n = query_objlist("What do you want to take off?", invent,
  30. 			SIGNAL_NOMENU|USE_INVLET|INVORDER_SORT,
  31. 			&pick_list, PICK_ANY,
  32. 			all_worn_categories ? is_worn : is_worn_by_type);
  33. if (n > 0) {
  34. 	for (i = 0; i < n; i++)
  35. 	    (void) select_off(pick_list[i].item.a_obj);
  36. 	free((genericptr_t) pick_list);
  37. } else if (n < 0 && flags.menu_style != MENU_COMBINATION) {
  38. 	There("is nothing else you can remove or unwield.");
  39. }
  40. return 0;
  41. }

destroy_arm[edit]

  1. /* hit by destroy armor scroll/black dragon breath/monster spell */
  2. int
  3. destroy_arm(atmp)
  4. register struct obj *atmp;
  5. {
  6. 	register struct obj *otmp;
  7. #define DESTROY_ARM(o) ((otmp = (o)) != 0 && \
  8. 			(!atmp || atmp == otmp) && \
  9. 			(!obj_resists(otmp, 0, 90)))
  10.  
  11. 	if (DESTROY_ARM(uarmc)) {
  12. 		if (donning(otmp)) cancel_don();
  13. 		Your("%s crumbles and turns to dust!",
  14. 		     cloak_simple_name(uarmc));
  15. 		(void) Cloak_off();
  16. 		useup(otmp);
  17. 	} else if (DESTROY_ARM(uarm)) {
  18. 		if (donning(otmp)) cancel_don();
  19. 		Your("armor turns to dust and falls to the %s!",
  20. 			surface(u.ux,u.uy));
  21. 		(void) Armor_gone();
  22. 		useup(otmp);
  23. #ifdef TOURIST
  24. 	} else if (DESTROY_ARM(uarmu)) {
  25. 		if (donning(otmp)) cancel_don();
  26. 		Your("shirt crumbles into tiny threads and falls apart!");
  27. 		(void) Shirt_off();
  28. 		useup(otmp);
  29. #endif
  30. 	} else if (DESTROY_ARM(uarmh)) {
  31. 		if (donning(otmp)) cancel_don();
  32. 		Your("helmet turns to dust and is blown away!");
  33. 		(void) Helmet_off();
  34. 		useup(otmp);
  35. 	} else if (DESTROY_ARM(uarmg)) {
  36. 		if (donning(otmp)) cancel_don();
  37. 		Your("gloves vanish!");
  38. 		(void) Gloves_off();
  39. 		useup(otmp);
  40. 		selftouch("You");
  41. 	} else if (DESTROY_ARM(uarmf)) {
  42. 		if (donning(otmp)) cancel_don();
  43. 		Your("boots disintegrate!");
  44. 		(void) Boots_off();
  45. 		useup(otmp);
  46. 	} else if (DESTROY_ARM(uarms)) {
  47. 		if (donning(otmp)) cancel_don();
  48. 		Your("shield crumbles away!");
  49. 		(void) Shield_off();
  50. 		useup(otmp);
  51. 	} else {
  52. 		return 0;		/* could not destroy anything */
  53. 	}
  54.  
  55. #undef DESTROY_ARM
  56. 	stop_occupation();
  57. 	return(1);
  58. }

adj_abon[edit]

  1. void
  2. adj_abon(otmp, delta)
  3. register struct obj *otmp;
  4. register schar delta;
  5. {
  6. 	if (uarmg && uarmg == otmp && otmp->otyp == GAUNTLETS_OF_DEXTERITY) {
  7. 		if (delta) {
  8. 			makeknown(uarmg->otyp);
  9. 			ABON(A_DEX) += (delta);
  10. 		}
  11. 		flags.botl = 1;
  12. 	}
  13. 	if (uarmh && uarmh == otmp && otmp->otyp == HELM_OF_BRILLIANCE) {
  14. 		if (delta) {
  15. 			makeknown(uarmh->otyp);
  16. 			ABON(A_INT) += (delta);
  17. 			ABON(A_WIS) += (delta);
  18. 		}
  19. 		flags.botl = 1;
  20. 	}
  21. }
  22.  
  23. #endif /* OVLB */
  24.  
  25. /*do_wear.c*/