Source:NetHack 3.4.3/src/polyself.c

From NetHackWiki
Jump to: navigation, search

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

Top of file[edit]

  1. /*	SCCS Id: @(#)polyself.c	3.4	2003/01/08	*/
  2. /*	Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
  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. /*
  2. * Polymorph self routine.
  3. *
  4. * Note:  the light source handling code assumes that both youmonst.m_id
  5. * and youmonst.mx will always remain 0 when it handles the case of the
  6. * player polymorphed into a light-emitting monster.
  7. */
  8.  
  9. #include "hack.h"
  10.  
  11. #ifdef OVLB
  12. STATIC_DCL void FDECL(polyman, (const char *,const char *));
  13. STATIC_DCL void NDECL(break_armor);
  14. STATIC_DCL void FDECL(drop_weapon,(int));
  15. STATIC_DCL void NDECL(uunstick);
  16. STATIC_DCL int FDECL(armor_to_dragon,(int));
  17. STATIC_DCL void NDECL(newman);

set_uasmon[edit]

  1. /* update the youmonst.data structure pointer */
  2. void
  3. set_uasmon()
  4. {
  5. 	set_mon_data(&youmonst, &mons[u.umonnum], 0);
  6. }

polyman[edit]

  1. /* make a (new) human out of the player */
  2. STATIC_OVL void
  3. polyman(fmt, arg)
  4. const char *fmt, *arg;
  5. {
  6. 	boolean sticky = sticks(youmonst.data) && u.ustuck && !u.uswallow,
  7. 		was_mimicking = (youmonst.m_ap_type == M_AP_OBJECT);
  8. 	boolean could_pass_walls = Passes_walls;
  9. 	boolean was_blind = !!Blind;
  10.  
  11. 	if (Upolyd) {
  12. 		u.acurr = u.macurr;	/* restore old attribs */
  13. 		u.amax = u.mamax;
  14. 		u.umonnum = u.umonster;
  15. 		flags.female = u.mfemale;
  16. 	}
  17. 	set_uasmon();
  18.  
  19. 	u.mh = u.mhmax = 0;
  20. 	u.mtimedone = 0;
  21. 	skinback(FALSE);
  22. 	u.uundetected = 0;
  23.  
  24. 	if (sticky) uunstick();
  25. 	find_ac();
  26. 	if (was_mimicking) {
  27. 	    if (multi < 0) unmul("");
  28. 	    youmonst.m_ap_type = M_AP_NOTHING;
  29. 	}
  30.  
  31. 	newsym(u.ux,u.uy);
  32.  
  33. 	You(fmt, arg);
  34. 	/* check whether player foolishly genocided self while poly'd */
  35. 	if ((mvitals[urole.malenum].mvflags & G_GENOD) ||
  36. 			(urole.femalenum != NON_PM &&
  37. 			(mvitals[urole.femalenum].mvflags & G_GENOD)) ||
  38. 			(mvitals[urace.malenum].mvflags & G_GENOD) ||
  39. 			(urace.femalenum != NON_PM &&
  40. 			(mvitals[urace.femalenum].mvflags & G_GENOD))) {
  41. 	    /* intervening activity might have clobbered genocide info */
  42. 	    killer = delayed_killer;
  43. 	    if (!killer || !strstri(killer, "genocid")) {
  44. 		killer_format = KILLED_BY;
  45. 		killer = "self-genocide";
  46. 	    }
  47. 	    done(GENOCIDED);
  48. 	}
  49.  
  50. 	if (u.twoweap && !could_twoweap(youmonst.data))
  51. 	    untwoweapon();
  52.  
  53. 	if (u.utraptype == TT_PIT) {
  54. 	    if (could_pass_walls) {	/* player forms cannot pass walls */
  55. 		u.utrap = rn1(6,2);
  56. 	    }
  57. 	}
  58. 	if (was_blind && !Blind) {	/* reverting from eyeless */
  59. 	    Blinded = 1L;
  60. 	    make_blinded(0L, TRUE);	/* remove blindness */
  61. 	}
  62.  
  63. 	if(!Levitation && !u.ustuck &&
  64. 	   (is_pool(u.ux,u.uy) || is_lava(u.ux,u.uy)))
  65. 		spoteffects(TRUE);
  66.  
  67. 	see_monsters();
  68. }

change_sex[edit]

  1. void
  2. change_sex()
  3. {
  4. 	/* setting u.umonster for caveman/cavewoman or priest/priestess
  5. 	   swap unintentionally makes `Upolyd' appear to be true */
  6. 	boolean already_polyd = (boolean) Upolyd;
  7.  
  8. 	/* Some monsters are always of one sex and their sex can't be changed */
  9. 	/* succubi/incubi can change, but are handled below */
  10. 	/* !already_polyd check necessary because is_male() and is_female()
  11. are true if the player is a priest/priestess */
  12. 	if (!already_polyd || (!is_male(youmonst.data) && !is_female(youmonst.data) && !is_neuter(youmonst.data)))
  13. 	    flags.female = !flags.female;
  14. 	if (already_polyd)	/* poly'd: also change saved sex */
  15. 	    u.mfemale = !u.mfemale;
  16. 	max_rank_sz();		/* [this appears to be superfluous] */
  17. 	if ((already_polyd ? u.mfemale : flags.female) && urole.name.f)
  18. 	    Strcpy(pl_character, urole.name.f);
  19. 	else
  20. 	    Strcpy(pl_character, urole.name.m);
  21. 	u.umonster = ((already_polyd ? u.mfemale : flags.female) && urole.femalenum != NON_PM) ?
  22. 			urole.femalenum : urole.malenum;
  23. 	if (!already_polyd) {
  24. 	    u.umonnum = u.umonster;
  25. 	} else if (u.umonnum == PM_SUCCUBUS || u.umonnum == PM_INCUBUS) {
  26. 	    flags.female = !flags.female;
  27. 	    /* change monster type to match new sex */
  28. 	    u.umonnum = (u.umonnum == PM_SUCCUBUS) ? PM_INCUBUS : PM_SUCCUBUS;
  29. 	    set_uasmon();
  30. 	}
  31. }

newman[edit]

  1. STATIC_OVL void
  2. newman()
  3. {
  4. 	int tmp, oldlvl;
  5.  
  6. 	tmp = u.uhpmax;
  7. 	oldlvl = u.ulevel;
  8. 	u.ulevel = u.ulevel + rn1(5, -2);
  9. 	if (u.ulevel > 127 || u.ulevel < 1) { /* level went below 0? */
  10. 	    u.ulevel = oldlvl; /* restore old level in case they lifesave */
  11. 	    goto dead;
  12. 	}
  13. 	if (u.ulevel > MAXULEV) u.ulevel = MAXULEV;
  14. 	/* If your level goes down, your peak level goes down by
  15. 	   the same amount so that you can't simply use blessed
  16. 	   full healing to undo the decrease.  But if your level
  17. 	   goes up, your peak level does *not* undergo the same
  18. 	   adjustment; you might end up losing out on the chance
  19. 	   to regain some levels previously lost to other causes. */
  20. 	if (u.ulevel < oldlvl) u.ulevelmax -= (oldlvl - u.ulevel);
  21. 	if (u.ulevelmax < u.ulevel) u.ulevelmax = u.ulevel;
  22.  
  23. 	if (!rn2(10)) change_sex();
  24.  
  25. 	adjabil(oldlvl, (int)u.ulevel);
  26. 	reset_rndmonst(NON_PM);	/* new monster generation criteria */
  27.  
  28. 	/* random experience points for the new experience level */
  29. 	u.uexp = rndexp(FALSE);
  30.  
  31. 	/* u.uhpmax * u.ulevel / oldlvl: proportionate hit points to new level
  32. 	 * -10 and +10: don't apply proportionate HP to 10 of a starting
  33. 	 *   character's hit points (since a starting character's hit points
  34. 	 *   are not on the same scale with hit points obtained through level
  35. 	 *   gain)
  36. 	 * 9 - rn2(19): random change of -9 to +9 hit points
  37. 	 */
  38. #ifndef LINT
  39. 	u.uhpmax = ((u.uhpmax - 10) * (long)u.ulevel / oldlvl + 10) +
  40. 		(9 - rn2(19));
  41. #endif
  42.  
  43. #ifdef LINT
  44. 	u.uhp = u.uhp + tmp;
  45. #else
  46. 	u.uhp = u.uhp * (long)u.uhpmax/tmp;
  47. #endif
  48.  
  49. 	tmp = u.uenmax;
  50. #ifndef LINT
  51. 	u.uenmax = u.uenmax * (long)u.ulevel / oldlvl + 9 - rn2(19);
  52. #endif
  53. 	if (u.uenmax < 0) u.uenmax = 0;
  54. #ifndef LINT
  55. 	u.uen = (tmp ? u.uen * (long)u.uenmax / tmp : u.uenmax);
  56. #endif
  57.  
  58. 	redist_attr();
  59. 	u.uhunger = rn1(500,500);
  60. 	if (Sick) make_sick(0L, (char *) 0, FALSE, SICK_ALL);
  61. 	Stoned = 0;
  62. 	delayed_killer = 0;
  63. 	if (u.uhp <= 0 || u.uhpmax <= 0) {
  64. 		if (Polymorph_control) {
  65. 		    if (u.uhp <= 0) u.uhp = 1;
  66. 		    if (u.uhpmax <= 0) u.uhpmax = 1;
  67. 		} else {
  68. dead: /* we come directly here if their experience level went to 0 or less */
  69. 		    Your("new form doesn't seem healthy enough to survive.");
  70. 		    killer_format = KILLED_BY_AN;
  71. 		    killer="unsuccessful polymorph";
  72. 		    done(DIED);
  73. 		    newuhs(FALSE);
  74. 		    return; /* lifesaved */
  75. 		}
  76. 	}
  77. 	newuhs(FALSE);
  78. 	polyman("feel like a new %s!",
  79. 		(flags.female && urace.individual.f) ? urace.individual.f :
  80. 		(urace.individual.m) ? urace.individual.m : urace.noun);
  81. 	if (Slimed) {
  82. 		Your("body transforms, but there is still slime on you.");
  83. 		Slimed = 10L;
  84. 	}
  85. 	flags.botl = 1;
  86. 	see_monsters();
  87. 	(void) encumber_msg();
  88. }

NetHack calls this function when you try to polymorph into your own race. This implements the "You feel like a new man!" (or elf) process, that permanently changes you into a physically different person.

There is nothing in this part of the source code to cure blindness (is this correct?) or to remove intrinsics that you gained from outside (for example by eating the corpse of a floating eye).

This process has curing effects, but for healthy adventurers, the DevTeam seems to have intentionally designed this function such that there is an equal chance that each adjustment is beneficial or harmful. As xanthian explains to rgrn, the expected value of the level change is zero. Because this function does not call rnl, the luck integer has no effect here. You also cannot use a unicorn horn or other such cure to regain any lost levels or attributes. The comment at line 144 explains how the source code adjusts your peak level to prevent this. The redist_attr function sets both your current and peak attributes, too. The becoming of a new man (or new gnome) many times is no way to raise your experience level or your attributes.

polyself[edit]

  1. void
  2. polyself(forcecontrol)
  3. boolean forcecontrol;     
  4. {
  5. 	char buf[BUFSZ];
  6. 	int old_light, new_light;
  7. 	int mntmp = NON_PM;
  8. 	int tries=0;
  9. 	boolean draconian = (uarm &&
  10. 				uarm->otyp >= GRAY_DRAGON_SCALE_MAIL &&
  11. 				uarm->otyp <= YELLOW_DRAGON_SCALES);
  12. 	boolean iswere = (u.ulycn >= LOW_PM || is_were(youmonst.data));
  13. 	boolean isvamp = (youmonst.data->mlet == S_VAMPIRE || u.umonnum == PM_VAMPIRE_BAT);
  14. 	boolean was_floating = (Levitation || Flying);
  15.  
  16. if(!Polymorph_control && !forcecontrol && !draconian && !iswere && !isvamp) {
  17. 	    if (rn2(20) > ACURR(A_CON)) {
  18. 		You(shudder_for_moment);
  19. 		losehp(rnd(30), "system shock", KILLED_BY_AN);
  20. 		exercise(A_CON, FALSE);
  21. 		return;
  22. 	    }
  23. 	}
  24. 	old_light = Upolyd ? emits_light(youmonst.data) : 0;
  25.  
  26. 	if (Polymorph_control || forcecontrol) {
  27. 		do {
  28. 			getlin("Become what kind of monster? [type the name]",
  29. 				buf);
  30. 			mntmp = name_to_mon(buf);
  31. 			if (mntmp < LOW_PM)
  32. 				pline("I've never heard of such monsters.");
  33. 			/* Note:  humans are illegal as monsters, but an
  34. 			 * illegal monster forces newman(), which is what we
  35. 			 * want if they specified a human.... */
  36. 			else if (!polyok(&mons[mntmp]) && !your_race(&mons[mntmp]))
  37. 				You("cannot polymorph into that.");
  38. 			else break;
  39. 		} while(++tries < 5);
  40. 		if (tries==5) pline(thats_enough_tries);
  41. 		/* allow skin merging, even when polymorph is controlled */
  42. 		if (draconian &&
  43. 		    (mntmp == armor_to_dragon(uarm->otyp) || tries == 5))
  44. 		    goto do_merge;
  45. 	} else if (draconian || iswere || isvamp) {
  46. 		/* special changes that don't require polyok() */
  47. 		if (draconian) {
  48. 		    do_merge:
  49. 			mntmp = armor_to_dragon(uarm->otyp);
  50. 			if (!(mvitals[mntmp].mvflags & G_GENOD)) {
  51. 				/* allow G_EXTINCT */
  52. 				You("merge with your scaly armor.");
  53. 				uskin = uarm;
  54. 				uarm = (struct obj *)0;
  55. 				/* save/restore hack */
  56. 				uskin->owornmask |= I_SPECIAL;
  57. 			}
  58. 		} else if (iswere) {
  59. 			if (is_were(youmonst.data))
  60. 				mntmp = PM_HUMAN; /* Illegal; force newman() */
  61. 			else
  62. 				mntmp = u.ulycn;
  63. 		} else {
  64. 			if (youmonst.data->mlet == S_VAMPIRE)
  65. 				mntmp = PM_VAMPIRE_BAT;
  66. 			else
  67. 				mntmp = PM_VAMPIRE;
  68. 		}
  69. 		/* if polymon fails, "you feel" message has been given
  70. 		   so don't follow up with another polymon or newman */
  71. 		if (mntmp == PM_HUMAN) newman();	/* werecritter */
  72. 		else (void) polymon(mntmp);
  73. 		goto made_change;    /* maybe not, but this is right anyway */
  74. 	}
  75.  
  76. 	if (mntmp < LOW_PM) {
  77. 		tries = 0;
  78. 		do {
  79. 			/* randomly pick an "ordinary" monster */
  80. 			mntmp = rn1(SPECIAL_PM - LOW_PM, LOW_PM);
  81. 		} while((!polyok(&mons[mntmp]) || is_placeholder(&mons[mntmp]))
  82. 				&& tries++ < 200);
  83. 	}
  84.  
  85. 	/* The below polyok() fails either if everything is genocided, or if
  86. 	 * we deliberately chose something illegal to force newman().
  87. 	 */
  88. 	if (!polyok(&mons[mntmp]) || !rn2(5) || your_race(&mons[mntmp]))
  89. 		newman();
  90. 	else if(!polymon(mntmp)) return;
  91.  
  92. 	if (!uarmg) selftouch("No longer petrify-resistant, you");
  93.  
  94. made_change:
  95. 	new_light = Upolyd ? emits_light(youmonst.data) : 0;
  96. 	if (old_light != new_light) {
  97. 	    if (old_light)
  98. 		del_light_source(LS_MONSTER, (genericptr_t)&youmonst);
  99. 	    if (new_light == 1) ++new_light;  /* otherwise it's undetectable */
  100. 	    if (new_light)
  101. 		new_light_source(u.ux, u.uy, new_light,
  102. 				 LS_MONSTER, (genericptr_t)&youmonst);
  103. 	}
  104. 	if (is_pool(u.ux,u.uy) && was_floating && !(Levitation || Flying) &&
  105. 		!breathless(youmonst.data) && !amphibious(youmonst.data) &&
  106. 		!Swimming) drown();
  107. }

polymon[edit]

  1. /* (try to) make a mntmp monster out of the player */
  2. int
  3. polymon(mntmp)	/* returns 1 if polymorph successful */
  4. int	mntmp;
  5. {
  6. 	boolean sticky = sticks(youmonst.data) && u.ustuck && !u.uswallow,
  7. 		was_blind = !!Blind, dochange = FALSE;
  8. 	boolean could_pass_walls = Passes_walls;
  9. 	int mlvl;
  10.  
  11. 	if (mvitals[mntmp].mvflags & G_GENOD) {	/* allow G_EXTINCT */
  12. 		You_feel("rather %s-ish.",mons[mntmp].mname);
  13. 		exercise(A_WIS, TRUE);
  14. 		return(0);
  15. 	}
  16.  
  17. 	/* KMH, conduct */
  18. 	u.uconduct.polyselfs++;
  19.  
  20. 	if (!Upolyd) {
  21. 		/* Human to monster; save human stats */
  22. 		u.macurr = u.acurr;
  23. 		u.mamax = u.amax;
  24. 		u.mfemale = flags.female;
  25. 	} else {
  26. 		/* Monster to monster; restore human stats, to be
  27. 		 * immediately changed to provide stats for the new monster
  28. 		 */
  29. 		u.acurr = u.macurr;
  30. 		u.amax = u.mamax;
  31. 		flags.female = u.mfemale;
  32. 	}
  33.  
  34. 	if (youmonst.m_ap_type) {
  35. 	    /* stop mimicking immediately */
  36. 	    if (multi < 0) unmul("");
  37. 	} else if (mons[mntmp].mlet != S_MIMIC) {
  38. 	    /* as in polyman() */
  39. 	    youmonst.m_ap_type = M_AP_NOTHING;
  40. 	}
  41. 	if (is_male(&mons[mntmp])) {
  42. 		if(flags.female) dochange = TRUE;
  43. 	} else if (is_female(&mons[mntmp])) {
  44. 		if(!flags.female) dochange = TRUE;
  45. 	} else if (!is_neuter(&mons[mntmp]) && mntmp != u.ulycn) {
  46. 		if(!rn2(10)) dochange = TRUE;
  47. 	}
  48. 	if (dochange) {
  49. 		flags.female = !flags.female;
  50. 		You("%s %s%s!",
  51. 		    (u.umonnum != mntmp) ? "turn into a" : "feel like a new",
  52. 		    (is_male(&mons[mntmp]) || is_female(&mons[mntmp])) ? "" :
  53. 			flags.female ? "female " : "male ",
  54. 		    mons[mntmp].mname);
  55. 	} else {
  56. 		if (u.umonnum != mntmp)
  57. 			You("turn into %s!", an(mons[mntmp].mname));
  58. 		else
  59. 			You_feel("like a new %s!", mons[mntmp].mname);
  60. 	}
  61. 	if (Stoned && poly_when_stoned(&mons[mntmp])) {
  62. 		/* poly_when_stoned already checked stone golem genocide */
  63. 		You("turn to stone!");
  64. 		mntmp = PM_STONE_GOLEM;
  65. 		Stoned = 0;
  66. 		delayed_killer = 0;
  67. 	}
  68.  
  69. 	u.mtimedone = rn1(500, 500);
  70. 	u.umonnum = mntmp;
  71. 	set_uasmon();
  72.  
  73. 	/* New stats for monster, to last only as long as polymorphed.
  74. 	 * Currently only strength gets changed.
  75. 	 */
  76. 	if(strongmonst(&mons[mntmp])) ABASE(A_STR) = AMAX(A_STR) = STR18(100);
  77.  
  78. 	if (Stone_resistance && Stoned) { /* parnes@eniac.seas.upenn.edu */
  79. 		Stoned = 0;
  80. 		delayed_killer = 0;
  81. 		You("no longer seem to be petrifying.");
  82. 	}
  83. 	if (Sick_resistance && Sick) {
  84. 		make_sick(0L, (char *) 0, FALSE, SICK_ALL);
  85. 		You("no longer feel sick.");
  86. 	}
  87. 	if (Slimed) {
  88. 	    if (flaming(youmonst.data)) {
  89. 		pline_The("slime burns away!");
  90. 		Slimed = 0L;
  91. 		flags.botl = 1;
  92. 	    } else if (mntmp == PM_GREEN_SLIME) {
  93. 		/* do it silently */
  94. 		Slimed = 0L;
  95. 		flags.botl = 1;
  96. 	    }
  97. 	}
  98. 	if (nohands(youmonst.data)) Glib = 0;
  99.  
  100. 	/*
  101. 	mlvl = adj_lev(&mons[mntmp]);
  102. 	 * We can't do the above, since there's no such thing as an
  103. 	 * "experience level of you as a monster" for a polymorphed character.
  104. 	 */
  105. 	mlvl = (int)mons[mntmp].mlevel;
  106. 	if (youmonst.data->mlet == S_DRAGON && mntmp >= PM_GRAY_DRAGON) {
  107. 		u.mhmax = In_endgame(&u.uz) ? (8*mlvl) : (4*mlvl + d(mlvl,4));
  108. 	} else if (is_golem(youmonst.data)) {
  109. 		u.mhmax = golemhp(mntmp);
  110. 	} else {
  111. 		if (!mlvl) u.mhmax = rnd(4);
  112. 		else u.mhmax = d(mlvl, 8);
  113. 		if (is_home_elemental(&mons[mntmp])) u.mhmax *= 3;
  114. 	}
  115. 	u.mh = u.mhmax;
  116.  
  117. 	if (u.ulevel < mlvl) {
  118. 	/* Low level characters can't become high level monsters for long */
  119. #ifdef DUMB
  120. 		/* DRS/NS 2.2.6 messes up -- Peter Kendell */
  121. 		int mtd = u.mtimedone, ulv = u.ulevel;
  122.  
  123. 		u.mtimedone = mtd * ulv / mlvl;
  124. #else
  125. 		u.mtimedone = u.mtimedone * u.ulevel / mlvl;
  126. #endif
  127. 	}
  128.  
  129. 	if (uskin && mntmp != armor_to_dragon(uskin->otyp))
  130. 		skinback(FALSE);
  131. 	break_armor();
  132. 	drop_weapon(1);
  133. 	if (hides_under(youmonst.data))
  134. 		u.uundetected = OBJ_AT(u.ux, u.uy);
  135. 	else if (youmonst.data->mlet == S_EEL)
  136. 		u.uundetected = is_pool(u.ux, u.uy);
  137. 	else
  138. 		u.uundetected = 0;
  139.  
  140. 	if (u.utraptype == TT_PIT) {
  141. 	    if (could_pass_walls && !Passes_walls) {
  142. 		u.utrap = rn1(6,2);
  143. 	    } else if (!could_pass_walls && Passes_walls) {
  144. 		u.utrap = 0;
  145. 	    }
  146. 	}
  147. 	if (was_blind && !Blind) {	/* previous form was eyeless */
  148. 	    Blinded = 1L;
  149. 	    make_blinded(0L, TRUE);	/* remove blindness */
  150. 	}
  151. 	newsym(u.ux,u.uy);		/* Change symbol */
  152.  
  153. 	if (!sticky && !u.uswallow && u.ustuck && sticks(youmonst.data)) u.ustuck = 0;
  154. 	else if (sticky && !sticks(youmonst.data)) uunstick();
  155. #ifdef STEED
  156. 	if (u.usteed) {
  157. 	    if (touch_petrifies(u.usteed->data) &&
  158. 	    		!Stone_resistance && rnl(3)) {
  159. 	    	char buf[BUFSZ];
  160.  
  161. 	    	pline("No longer petrifying-resistant, you touch %s.",
  162. 	    			mon_nam(u.usteed));
  163. 	    	Sprintf(buf, "riding %s", an(u.usteed->data->mname));
  164. 	    	instapetrify(buf);
  165. 	    }
  166. 	    if (!can_ride(u.usteed)) dismount_steed(DISMOUNT_POLY);
  167. 	}
  168. #endif
  169.  
  170. 	if (flags.verbose) {
  171. 	    static const char use_thec[] = "Use the command #%s to %s.";
  172. 	    static const char monsterc[] = "monster";
  173. 	    if (can_breathe(youmonst.data))
  174. 		pline(use_thec,monsterc,"use your breath weapon");
  175. 	    if (attacktype(youmonst.data, AT_SPIT))
  176. 		pline(use_thec,monsterc,"spit venom");
  177. 	    if (youmonst.data->mlet == S_NYMPH)
  178. 		pline(use_thec,monsterc,"remove an iron ball");
  179. 	    if (attacktype(youmonst.data, AT_GAZE))
  180. 		pline(use_thec,monsterc,"gaze at monsters");
  181. 	    if (is_hider(youmonst.data))
  182. 		pline(use_thec,monsterc,"hide");
  183. 	    if (is_were(youmonst.data))
  184. 		pline(use_thec,monsterc,"summon help");
  185. 	    if (webmaker(youmonst.data))
  186. 		pline(use_thec,monsterc,"spin a web");
  187. 	    if (u.umonnum == PM_GREMLIN)
  188. 		pline(use_thec,monsterc,"multiply in a fountain");
  189. 	    if (is_unicorn(youmonst.data))
  190. 		pline(use_thec,monsterc,"use your horn");
  191. 	    if (is_mind_flayer(youmonst.data))
  192. 		pline(use_thec,monsterc,"emit a mental blast");
  193. 	    if (youmonst.data->msound == MS_SHRIEK) /* worthless, actually */
  194. 		pline(use_thec,monsterc,"shriek");
  195. 	    if (lays_eggs(youmonst.data) && flags.female)
  196. 		pline(use_thec,"sit","lay an egg");
  197. 	}
  198. 	/* you now know what an egg of your type looks like */
  199. 	if (lays_eggs(youmonst.data)) {
  200. 	    learn_egg_type(u.umonnum);
  201. 	    /* make queen bees recognize killer bee eggs */
  202. 	    learn_egg_type(egg_type_from_parent(u.umonnum, TRUE));
  203. 	}
  204. 	find_ac();
  205. 	if((!Levitation && !u.ustuck && !Flying &&
  206. 	    (is_pool(u.ux,u.uy) || is_lava(u.ux,u.uy))) ||
  207. 	   (Underwater && !Swimming))
  208. 	    spoteffects(TRUE);
  209. 	if (Passes_walls && u.utrap && u.utraptype == TT_INFLOOR) {
  210. 	    u.utrap = 0;
  211. 	    pline_The("rock seems to no longer trap you.");
  212. 	} else if (likes_lava(youmonst.data) && u.utrap && u.utraptype == TT_LAVA) {
  213. 	    u.utrap = 0;
  214. 	    pline_The("lava now feels soothing.");
  215. 	}
  216. 	if (amorphous(youmonst.data) || is_whirly(youmonst.data) || unsolid(youmonst.data)) {
  217. 	    if (Punished) {
  218. 		You("slip out of the iron chain.");
  219. 		unpunish();
  220. 	    }
  221. 	}
  222. 	if (u.utrap && (u.utraptype == TT_WEB || u.utraptype == TT_BEARTRAP) &&
  223. 		(amorphous(youmonst.data) || is_whirly(youmonst.data) || unsolid(youmonst.data) ||
  224. 		  (youmonst.data->msize <= MZ_SMALL && u.utraptype == TT_BEARTRAP))) {
  225. 	    You("are no longer stuck in the %s.",
  226. 		    u.utraptype == TT_WEB ? "web" : "bear trap");
  227. 	    /* probably should burn webs too if PM_FIRE_ELEMENTAL */
  228. 	    u.utrap = 0;
  229. 	}
  230. 	if (webmaker(youmonst.data) && u.utrap && u.utraptype == TT_WEB) {
  231. 	    You("orient yourself on the web.");
  232. 	    u.utrap = 0;
  233. 	}
  234. 	flags.botl = 1;
  235. 	vision_full_recalc = 1;
  236. 	see_monsters();
  237. 	exercise(A_CON, FALSE);
  238. 	exercise(A_WIS, TRUE);
  239. 	(void) encumber_msg();
  240. 	return(1);
  241. }

break_armor[edit]

  1. STATIC_OVL void
  2. break_armor()
  3. {
  4. register struct obj *otmp;
  5.  
  6. if (breakarm(youmonst.data)) {
  7. 	if ((otmp = uarm) != 0) {
  8. 		if (donning(otmp)) cancel_don();
  9. 		You("break out of your armor!");
  10. 		exercise(A_STR, FALSE);
  11. 		(void) Armor_gone();
  12. 		useup(otmp);
  13. 	}
  14. 	if ((otmp = uarmc) != 0) {
  15. 	    if(otmp->oartifact) {
  16. 		Your("%s falls off!", cloak_simple_name(otmp));
  17. 		(void) Cloak_off();
  18. 		dropx(otmp);
  19. 	    } else {
  20. 		Your("%s tears apart!", cloak_simple_name(otmp));
  21. 		(void) Cloak_off();
  22. 		useup(otmp);
  23. 	    }
  24. 	}
  25. #ifdef TOURIST
  26. 	if (uarmu) {
  27. 		Your("shirt rips to shreds!");
  28. 		useup(uarmu);
  29. 	}
  30. #endif
  31. } else if (sliparm(youmonst.data)) {
  32. 	if (((otmp = uarm) != 0) && (racial_exception(&youmonst, otmp) < 1)) {
  33. 		if (donning(otmp)) cancel_don();
  34. 		Your("armor falls around you!");
  35. 		(void) Armor_gone();
  36. 		dropx(otmp);
  37. 	}
  38. 	if ((otmp = uarmc) != 0) {
  39. 		if (is_whirly(youmonst.data))
  40. 			Your("%s falls, unsupported!", cloak_simple_name(otmp));
  41. 		else You("shrink out of your %s!", cloak_simple_name(otmp));
  42. 		(void) Cloak_off();
  43. 		dropx(otmp);
  44. 	}
  45. #ifdef TOURIST
  46. 	if ((otmp = uarmu) != 0) {
  47. 		if (is_whirly(youmonst.data))
  48. 			You("seep right through your shirt!");
  49. 		else You("become much too small for your shirt!");
  50. 		setworn((struct obj *)0, otmp->owornmask & W_ARMU);
  51. 		dropx(otmp);
  52. 	}
  53. #endif
  54. }
  55. if (has_horns(youmonst.data)) {
  56. 	if ((otmp = uarmh) != 0) {
  57. 	    if (is_flimsy(otmp) && !donning(otmp)) {
  58. 		char hornbuf[BUFSZ], yourbuf[BUFSZ];
  59.  
  60. 		/* Future possiblities: This could damage/destroy helmet */
  61. 		Sprintf(hornbuf, "horn%s", plur(num_horns(youmonst.data)));
  62. 		Your("%s %s through %s %s.", hornbuf, vtense(hornbuf, "pierce"),
  63. 		     shk_your(yourbuf, otmp), xname(otmp));
  64. 	    } else {
  65. 		if (donning(otmp)) cancel_don();
  66. 		Your("helmet falls to the %s!", surface(u.ux, u.uy));
  67. 		(void) Helmet_off();
  68. 		dropx(otmp);
  69. 	    }
  70. 	}
  71. }
  72. if (nohands(youmonst.data) || verysmall(youmonst.data)) {
  73. 	if ((otmp = uarmg) != 0) {
  74. 	    if (donning(otmp)) cancel_don();
  75. 	    /* Drop weapon along with gloves */
  76. 	    You("drop your gloves%s!", uwep ? " and weapon" : "");
  77. 	    drop_weapon(0);
  78. 	    (void) Gloves_off();
  79. 	    dropx(otmp);
  80. 	}
  81. 	if ((otmp = uarms) != 0) {
  82. 	    You("can no longer hold your shield!");
  83. 	    (void) Shield_off();
  84. 	    dropx(otmp);
  85. 	}
  86. 	if ((otmp = uarmh) != 0) {
  87. 	    if (donning(otmp)) cancel_don();
  88. 	    Your("helmet falls to the %s!", surface(u.ux, u.uy));
  89. 	    (void) Helmet_off();
  90. 	    dropx(otmp);
  91. 	}
  92. }
  93. if (nohands(youmonst.data) || verysmall(youmonst.data) ||
  94. 		slithy(youmonst.data) || youmonst.data->mlet == S_CENTAUR) {
  95. 	if ((otmp = uarmf) != 0) {
  96. 	    if (donning(otmp)) cancel_don();
  97. 	    if (is_whirly(youmonst.data))
  98. 		Your("boots fall away!");
  99. 	    else Your("boots %s off your feet!",
  100. 			verysmall(youmonst.data) ? "slide" : "are pushed");
  101. 	    (void) Boots_off();
  102. 	    dropx(otmp);
  103. 	}
  104. }
  105. }

drop_weapon[edit]

  1. STATIC_OVL void
  2. drop_weapon(alone)
  3. int alone;
  4. {
  5. struct obj *otmp;
  6. struct obj *otmp2;
  7.  
  8. if ((otmp = uwep) != 0) {
  9. 	/* !alone check below is currently superfluous but in the
  10. 	 * future it might not be so if there are monsters which cannot
  11. 	 * wear gloves but can wield weapons
  12. 	 */
  13. 	if (!alone || cantwield(youmonst.data)) {
  14. 	    struct obj *wep = uwep;
  15.  
  16. 	    if (alone) You("find you must drop your weapon%s!",
  17. 			   	u.twoweap ? "s" : "");
  18. 	    otmp2 = u.twoweap ? uswapwep : 0;
  19. 	    uwepgone();
  20. 	    if (!wep->cursed || wep->otyp != LOADSTONE)
  21. 		dropx(otmp);
  22. 	    if (otmp2 != 0) {
  23. 		uswapwepgone();
  24. 		if (!otmp2->cursed || otmp2->otyp != LOADSTONE)
  25. 		    dropx(otmp2);
  26. 	    }
  27. 	    untwoweapon();
  28. 	} else if (!could_twoweap(youmonst.data)) {
  29. 	    untwoweapon();
  30. 	}
  31. }
  32. }

rehumanize[edit]

  1. void
  2. rehumanize()
  3. {
  4. 	/* You can't revert back while unchanging */
  5. 	if (Unchanging && (u.mh < 1)) {
  6. 		killer_format = NO_KILLER_PREFIX;
  7. 		killer = "killed while stuck in creature form";
  8. 		done(DIED);
  9. 	}
  10.  
  11. 	if (emits_light(youmonst.data))
  12. 	    del_light_source(LS_MONSTER, (genericptr_t)&youmonst);
  13. 	polyman("return to %s form!", urace.adj);
  14.  
  15. 	if (u.uhp < 1) {
  16. 	    char kbuf[256];
  17.  
  18. 	    Sprintf(kbuf, "reverting to unhealthy %s form", urace.adj);
  19. 	    killer_format = KILLED_BY;
  20. 	    killer = kbuf;
  21. 	    done(DIED);
  22. 	}
  23. 	if (!uarmg) selftouch("No longer petrify-resistant, you");
  24. 	nomul(0);
  25.  
  26. 	flags.botl = 1;
  27. 	vision_full_recalc = 1;
  28. 	(void) encumber_msg();
  29. }

dobreathe[edit]

  1. int
  2. dobreathe()
  3. {
  4. 	struct attack *mattk;
  5.  
  6. 	if (Strangled) {
  7. 	    You_cant("breathe.  Sorry.");
  8. 	    return(0);
  9. 	}
  10. 	if (u.uen < 15) {
  11. 	    You("don't have enough energy to breathe!");
  12. 	    return(0);
  13. 	}
  14. 	u.uen -= 15;
  15. 	flags.botl = 1;
  16.  
  17. 	if (!getdir((char *)0)) return(0);
  18.  
  19. 	mattk = attacktype_fordmg(youmonst.data, AT_BREA, AD_ANY);
  20. 	if (!mattk)
  21. 	    impossible("bad breath attack?");	/* mouthwash needed... */
  22. 	else
  23. 	    buzz((int) (20 + mattk->adtyp-1), (int)mattk->damn,
  24. 		u.ux, u.uy, u.dx, u.dy);
  25. 	return(1);
  26. }

dospit[edit]

  1. int
  2. dospit()
  3. {
  4. 	struct obj *otmp;
  5.  
  6. 	if (!getdir((char *)0)) return(0);
  7. 	otmp = mksobj(u.umonnum==PM_COBRA ? BLINDING_VENOM : ACID_VENOM,
  8. 			TRUE, FALSE);
  9. 	otmp->spe = 1; /* to indicate it's yours */
  10. 	throwit(otmp, 0L, FALSE);
  11. 	return(1);
  12. }

doremove[edit]

  1. int
  2. doremove()
  3. {
  4. 	if (!Punished) {
  5. 		You("are not chained to anything!");
  6. 		return(0);
  7. 	}
  8. 	unpunish();
  9. 	return(1);
  10. }

dospinweb[edit]

  1. int
  2. dospinweb()
  3. {
  4. 	register struct trap *ttmp = t_at(u.ux,u.uy);
  5.  
  6. 	if (Levitation || Is_airlevel(&u.uz)
  7. 	    || Underwater || Is_waterlevel(&u.uz)) {
  8. 		You("must be on the ground to spin a web.");
  9. 		return(0);
  10. 	}
  11. 	if (u.uswallow) {
  12. 		You("release web fluid inside %s.", mon_nam(u.ustuck));
  13. 		if (is_animal(u.ustuck->data)) {
  14. 			expels(u.ustuck, u.ustuck->data, TRUE);
  15. 			return(0);
  16. 		}
  17. 		if (is_whirly(u.ustuck->data)) {
  18. 			int i;
  19.  
  20. 			for (i = 0; i < NATTK; i++)
  21. 				if (u.ustuck->data->mattk[i].aatyp == AT_ENGL)
  22. 					break;
  23. 			if (i == NATTK)
  24. 			       impossible("Swallower has no engulfing attack?");
  25. 			else {
  26. 				char sweep[30];
  27.  
  28. 				sweep[0] = '\0';
  29. 				switch(u.ustuck->data->mattk[i].adtyp) {
  30. 					case AD_FIRE:
  31. 						Strcpy(sweep, "ignites and ");
  32. 						break;
  33. 					case AD_ELEC:
  34. 						Strcpy(sweep, "fries and ");
  35. 						break;
  36. 					case AD_COLD:
  37. 						Strcpy(sweep,
  38. 						      "freezes, shatters and ");
  39. 						break;
  40. 				}
  41. 				pline_The("web %sis swept away!", sweep);
  42. 			}
  43. 			return(0);
  44. 		}		     /* default: a nasty jelly-like creature */
  45. 		pline_The("web dissolves into %s.", mon_nam(u.ustuck));
  46. 		return(0);
  47. 	}
  48. 	if (u.utrap) {
  49. 		You("cannot spin webs while stuck in a trap.");
  50. 		return(0);
  51. 	}
  52. 	exercise(A_DEX, TRUE);
  53. 	if (ttmp) switch (ttmp->ttyp) {
  54. 		case PIT:
  55. 		case SPIKED_PIT: You("spin a web, covering up the pit.");
  56. 			deltrap(ttmp);
  57. 			bury_objs(u.ux, u.uy);
  58. 			newsym(u.ux, u.uy);
  59. 			return(1);
  60. 		case SQKY_BOARD: pline_The("squeaky board is muffled.");
  61. 			deltrap(ttmp);
  62. 			newsym(u.ux, u.uy);
  63. 			return(1);
  64. 		case TELEP_TRAP:
  65. 		case LEVEL_TELEP:
  66. 		case MAGIC_PORTAL:
  67. 			Your("webbing vanishes!");
  68. 			return(0);
  69. 		case WEB: You("make the web thicker.");
  70. 			return(1);
  71. 		case HOLE:
  72. 		case TRAPDOOR:
  73. 			You("web over the %s.",
  74. 			    (ttmp->ttyp == TRAPDOOR) ? "trap door" : "hole");
  75. 			deltrap(ttmp);
  76. 			newsym(u.ux, u.uy);
  77. 			return 1;
  78. 		case ROLLING_BOULDER_TRAP:
  79. 			You("spin a web, jamming the trigger.");
  80. 			deltrap(ttmp);
  81. 			newsym(u.ux, u.uy);
  82. 			return(1);
  83. 		case ARROW_TRAP:
  84. 		case DART_TRAP:
  85. 		case BEAR_TRAP:
  86. 		case ROCKTRAP:
  87. 		case FIRE_TRAP:
  88. 		case LANDMINE:
  89. 		case SLP_GAS_TRAP:
  90. 		case RUST_TRAP:
  91. 		case MAGIC_TRAP:
  92. 		case ANTI_MAGIC:
  93. 		case POLY_TRAP:
  94. 			You("have triggered a trap!");
  95. 			dotrap(ttmp, 0);
  96. 			return(1);
  97. 		default:
  98. 			impossible("Webbing over trap type %d?", ttmp->ttyp);
  99. 			return(0);
  100. 		}
  101. 	else if (On_stairs(u.ux, u.uy)) {
  102. 	    /* cop out: don't let them hide the stairs */
  103. 	    Your("web fails to impede access to the %s.",
  104. 		 (levl[u.ux][u.uy].typ == STAIRS) ? "stairs" : "ladder");
  105. 	    return(1);
  106.  
  107. 	}
  108. 	ttmp = maketrap(u.ux, u.uy, WEB);
  109. 	if (ttmp) {
  110. 		ttmp->tseen = 1;
  111. 		ttmp->madeby_u = 1;
  112. 	}
  113. 	newsym(u.ux, u.uy);
  114. 	return(1);
  115. }

dosummon[edit]

  1. int
  2. dosummon()
  3. {
  4. 	int placeholder;
  5. 	if (u.uen < 10) {
  6. 	    You("lack the energy to send forth a call for help!");
  7. 	    return(0);
  8. 	}
  9. 	u.uen -= 10;
  10. 	flags.botl = 1;
  11.  
  12. 	You("call upon your brethren for help!");
  13. 	exercise(A_WIS, TRUE);
  14. 	if (!were_summon(youmonst.data, TRUE, &placeholder, (char *)0))
  15. 		pline("But none arrive.");
  16. 	return(1);
  17. }

dogaze[edit]

  1. int
  2. dogaze()
  3. {
  4. 	register struct monst *mtmp;
  5. 	int looked = 0;
  6. 	char qbuf[QBUFSZ];
  7. 	int i;
  8. 	uchar adtyp = 0;
  9.  
  10. 	for (i = 0; i < NATTK; i++) {
  11. 	    if(youmonst.data->mattk[i].aatyp == AT_GAZE) {
  12. 		adtyp = youmonst.data->mattk[i].adtyp;
  13. 		break;
  14. 	    }
  15. 	}
  16. 	if (adtyp != AD_CONF && adtyp != AD_FIRE) {
  17. 	    impossible("gaze attack %d?", adtyp);
  18. 	    return 0;
  19. 	}
  20.  
  21.  
  22. 	if (Blind) {
  23. 	    You_cant("see anything to gaze at.");
  24. 	    return 0;
  25. 	}
  26. 	if (u.uen < 15) {
  27. 	    You("lack the energy to use your special gaze!");
  28. 	    return(0);
  29. 	}
  30. 	u.uen -= 15;
  31. 	flags.botl = 1;
  32.  
  33. 	for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
  34. 	    if (DEADMONSTER(mtmp)) continue;
  35. 	    if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my)) {
  36. 		looked++;
  37. 		if (Invis && !perceives(mtmp->data))
  38. 		    pline("%s seems not to notice your gaze.", Monnam(mtmp));
  39. 		else if (mtmp->minvis && !See_invisible)
  40. 		    You_cant("see where to gaze at %s.", Monnam(mtmp));
  41. 		else if (mtmp->m_ap_type == M_AP_FURNITURE
  42. 			|| mtmp->m_ap_type == M_AP_OBJECT) {
  43. 		    looked--;
  44. 		    continue;
  45. 		} else if (flags.safe_dog && !Confusion && !Hallucination
  46. 		  && mtmp->mtame) {
  47. 		    You("avoid gazing at %s.", y_monnam(mtmp));
  48. 		} else {
  49. 		    if (flags.confirm && mtmp->mpeaceful && !Confusion
  50. 							&& !Hallucination) {
  51. 			Sprintf(qbuf, "Really %s %s?",
  52. 			    (adtyp == AD_CONF) ? "confuse" : "attack",
  53. 			    mon_nam(mtmp));
  54. 			if (yn(qbuf) != 'y') continue;
  55. 			setmangry(mtmp);
  56. 		    }
  57. 		    if (!mtmp->mcanmove || mtmp->mstun || mtmp->msleeping ||
  58. 				    !mtmp->mcansee || !haseyes(mtmp->data)) {
  59. 			looked--;
  60. 			continue;
  61. 		    }
  62. 		    /* No reflection check for consistency with when a monster
  63. 		     * gazes at *you*--only medusa gaze gets reflected then.
  64. 		     */
  65. 		    if (adtyp == AD_CONF) {
  66. 			if (!mtmp->mconf)
  67. 			    Your("gaze confuses %s!", mon_nam(mtmp));
  68. 			else
  69. 			    pline("%s is getting more and more confused.",
  70. 							Monnam(mtmp));
  71. 			mtmp->mconf = 1;
  72. 		    } else if (adtyp == AD_FIRE) {
  73. 			int dmg = d(2,6);
  74. 			You("attack %s with a fiery gaze!", mon_nam(mtmp));
  75. 			if (resists_fire(mtmp)) {
  76. 			    pline_The("fire doesn't burn %s!", mon_nam(mtmp));
  77. 			    dmg = 0;
  78. 			}
  79. 			if((int) u.ulevel > rn2(20))
  80. 			    (void) destroy_mitem(mtmp, SCROLL_CLASS, AD_FIRE);
  81. 			if((int) u.ulevel > rn2(20))
  82. 			    (void) destroy_mitem(mtmp, POTION_CLASS, AD_FIRE);
  83. 			if((int) u.ulevel > rn2(25))
  84. 			    (void) destroy_mitem(mtmp, SPBOOK_CLASS, AD_FIRE);
  85. 			if (dmg && !DEADMONSTER(mtmp)) mtmp->mhp -= dmg;
  86. 			if (mtmp->mhp <= 0) killed(mtmp);
  87. 		    }
  88. 		    /* For consistency with passive() in uhitm.c, this only
  89. 		     * affects you if the monster is still alive.
  90. 		     */
  91. 		    if (!DEADMONSTER(mtmp) &&
  92. 			  (mtmp->data==&mons[PM_FLOATING_EYE]) && !mtmp->mcan) {
  93. 			if (!Free_action) {
  94. 			    You("are frozen by %s gaze!",
  95. 					     s_suffix(mon_nam(mtmp)));
  96. 			    nomul((u.ulevel > 6 || rn2(4)) ?
  97. 				    -d((int)mtmp->m_lev+1,
  98. 					    (int)mtmp->data->mattk[0].damd)
  99. 				    : -200);
  100. 			    return 1;
  101. 			} else
  102. 			    You("stiffen momentarily under %s gaze.",
  103. 				    s_suffix(mon_nam(mtmp)));
  104. 		    }
  105. 		    /* Technically this one shouldn't affect you at all because
  106. 		     * the Medusa gaze is an active monster attack that only
  107. 		     * works on the monster's turn, but for it to *not* have an
  108. 		     * effect would be too weird.
  109. 		     */
  110. 		    if (!DEADMONSTER(mtmp) &&
  111. 			    (mtmp->data == &mons[PM_MEDUSA]) && !mtmp->mcan) {
  112. 			pline(
  113. 			 "Gazing at the awake %s is not a very good idea.",
  114. 			    l_monnam(mtmp));
  115. 			/* as if gazing at a sleeping anything is fruitful... */
  116. 			You("turn to stone...");
  117. 			killer_format = KILLED_BY;
  118. 			killer = "deliberately meeting Medusa's gaze";
  119. 			done(STONING);
  120. 		    }
  121. 		}
  122. 	    }
  123. 	}
  124. 	if (!looked) You("gaze at no place in particular.");
  125. 	return 1;
  126. }

dohide[edit]

  1. int
  2. dohide()
  3. {
  4. 	boolean ismimic = youmonst.data->mlet == S_MIMIC;
  5.  
  6. 	if (u.uundetected || (ismimic && youmonst.m_ap_type != M_AP_NOTHING)) {
  7. 		You("are already hiding.");
  8. 		return(0);
  9. 	}
  10. 	if (ismimic) {
  11. 		/* should bring up a dialog "what would you like to imitate?" */
  12. 		youmonst.m_ap_type = M_AP_OBJECT;
  13. 		youmonst.mappearance = STRANGE_OBJECT;
  14. 	} else
  15. 		u.uundetected = 1;
  16. 	newsym(u.ux,u.uy);
  17. 	return(1);
  18. }

domindblast[edit]

  1. int
  2. domindblast()
  3. {
  4. 	struct monst *mtmp, *nmon;
  5.  
  6. 	if (u.uen < 10) {
  7. 	    You("concentrate but lack the energy to maintain doing so.");
  8. 	    return(0);
  9. 	}
  10. 	u.uen -= 10;
  11. 	flags.botl = 1;
  12.  
  13. 	You("concentrate.");
  14. 	pline("A wave of psychic energy pours out.");
  15. 	for(mtmp=fmon; mtmp; mtmp = nmon) {
  16. 		int u_sen;
  17.  
  18. 		nmon = mtmp->nmon;
  19. 		if (DEADMONSTER(mtmp))
  20. 			continue;
  21. 		if (distu(mtmp->mx, mtmp->my) > BOLT_LIM * BOLT_LIM)
  22. 			continue;
  23. 		if(mtmp->mpeaceful)
  24. 			continue;
  25. 		u_sen = telepathic(mtmp->data) && !mtmp->mcansee;
  26. 		if (u_sen || (telepathic(mtmp->data) && rn2(2)) || !rn2(10)) {
  27. 			You("lock in on %s %s.", s_suffix(mon_nam(mtmp)),
  28. 				u_sen ? "telepathy" :
  29. 				telepathic(mtmp->data) ? "latent telepathy" :
  30. 				"mind");
  31. 			mtmp->mhp -= rnd(15);
  32. 			if (mtmp->mhp <= 0)
  33. 				killed(mtmp);
  34. 		}
  35. 	}
  36. 	return 1;
  37. }

uunstick[edit]

  1. STATIC_OVL void
  2. uunstick()
  3. {
  4. 	pline("%s is no longer in your clutches.", Monnam(u.ustuck));
  5. 	u.ustuck = 0;
  6. }

skinback[edit]

  1. void
  2. skinback(silently)
  3. boolean silently;
  4. {
  5. 	if (uskin) {
  6. 		if (!silently) Your("skin returns to its original form.");
  7. 		uarm = uskin;
  8. 		uskin = (struct obj *)0;
  9. 		/* undo save/restore hack */
  10. 		uarm->owornmask &= ~I_SPECIAL;
  11. 	}
  12. }
  13.  
  14. #endif /* OVLB */
  15. #ifdef OVL1

mbodypart[edit]

  1. const char *
  2. mbodypart(mon, part)
  3. struct monst *mon;
  4. int part;
  5. {
  6. 	static NEARDATA const char
  7. 	*humanoid_parts[] = { "arm", "eye", "face", "finger",
  8. 		"fingertip", "foot", "hand", "handed", "head", "leg",
  9. 		"light headed", "neck", "spine", "toe", "hair",
  10. 		"blood", "lung", "nose", "stomach"},
  11. 	*jelly_parts[] = { "pseudopod", "dark spot", "front",
  12. 		"pseudopod extension", "pseudopod extremity",
  13. 		"pseudopod root", "grasp", "grasped", "cerebral area",
  14. 		"lower pseudopod", "viscous", "middle", "surface",
  15. 		"pseudopod extremity", "ripples", "juices",
  16. 		"surface", "sensor", "stomach" },
  17. 	*animal_parts[] = { "forelimb", "eye", "face", "foreclaw", "claw tip",
  18. 		"rear claw", "foreclaw", "clawed", "head", "rear limb",
  19. 		"light headed", "neck", "spine", "rear claw tip",
  20. 		"fur", "blood", "lung", "nose", "stomach" },
  21. 	*bird_parts[] = { "wing", "eye", "face", "wing", "wing tip",
  22. 		"foot", "wing", "winged", "head", "leg",
  23. 		"light headed", "neck", "spine", "toe",
  24. 		"feathers", "blood", "lung", "bill", "stomach" },
  25. 	*horse_parts[] = { "foreleg", "eye", "face", "forehoof", "hoof tip",
  26. 		"rear hoof", "foreclaw", "hooved", "head", "rear leg",
  27. 		"light headed", "neck", "backbone", "rear hoof tip",
  28. 		"mane", "blood", "lung", "nose", "stomach"},
  29. 	*sphere_parts[] = { "appendage", "optic nerve", "body", "tentacle",
  30. 		"tentacle tip", "lower appendage", "tentacle", "tentacled",
  31. 		"body", "lower tentacle", "rotational", "equator", "body",
  32. 		"lower tentacle tip", "cilia", "life force", "retina",
  33. 		"olfactory nerve", "interior" },
  34. 	*fungus_parts[] = { "mycelium", "visual area", "front", "hypha",
  35. 		"hypha", "root", "strand", "stranded", "cap area",
  36. 		"rhizome", "sporulated", "stalk", "root", "rhizome tip",
  37. 		"spores", "juices", "gill", "gill", "interior" },
  38. 	*vortex_parts[] = { "region", "eye", "front", "minor current",
  39. 		"minor current", "lower current", "swirl", "swirled",
  40. 		"central core", "lower current", "addled", "center",
  41. 		"currents", "edge", "currents", "life force",
  42. 		"center", "leading edge", "interior" },
  43. 	*snake_parts[] = { "vestigial limb", "eye", "face", "large scale",
  44. 		"large scale tip", "rear region", "scale gap", "scale gapped",
  45. 		"head", "rear region", "light headed", "neck", "length",
  46. 		"rear scale", "scales", "blood", "lung", "forked tongue", "stomach" },
  47. 	*fish_parts[] = { "fin", "eye", "premaxillary", "pelvic axillary",
  48. 		"pelvic fin", "anal fin", "pectoral fin", "finned", "head", "peduncle",
  49. 		"played out", "gills", "dorsal fin", "caudal fin",
  50. 		"scales", "blood", "gill", "nostril", "stomach" };
  51. 	/* claw attacks are overloaded in mons[]; most humanoids with
  52. 	   such attacks should still reference hands rather than claws */
  53. 	static const char not_claws[] = {
  54. 		S_HUMAN, S_MUMMY, S_ZOMBIE, S_ANGEL,
  55. 		S_NYMPH, S_LEPRECHAUN, S_QUANTMECH, S_VAMPIRE,
  56. 		S_ORC, S_GIANT,		/* quest nemeses */
  57. 		'\0'		/* string terminator; assert( S_xxx != 0 ); */
  58. 	};
  59. 	struct permonst *mptr = mon->data;
  60.  
  61. 	if (part == HAND || part == HANDED) {	/* some special cases */
  62. 	    if (mptr->mlet == S_DOG || mptr->mlet == S_FELINE ||
  63. 		    mptr->mlet == S_YETI)
  64. 		return part == HAND ? "paw" : "pawed";
  65. 	    if (humanoid(mptr) && attacktype(mptr, AT_CLAW) &&
  66. 		    !index(not_claws, mptr->mlet) &&
  67. 		    mptr != &mons[PM_STONE_GOLEM] &&
  68. 		    mptr != &mons[PM_INCUBUS] && mptr != &mons[PM_SUCCUBUS])
  69. 		return part == HAND ? "claw" : "clawed";
  70. 	}
  71. 	if ((mptr == &mons[PM_MUMAK] || mptr == &mons[PM_MASTODON]) &&
  72. 		part == NOSE)
  73. 	    return "trunk";
  74. 	if (mptr == &mons[PM_SHARK] && part == HAIR)
  75. 	    return "skin";	/* sharks don't have scales */
  76. 	if (mptr == &mons[PM_JELLYFISH] && (part == ARM || part == FINGER ||
  77. 	    part == HAND || part == FOOT || part == TOE))
  78. 	    return "tentacle";
  79. 	if (mptr == &mons[PM_FLOATING_EYE] && part == EYE)
  80. 	    return "cornea";
  81. 	if (humanoid(mptr) &&
  82. 		(part == ARM || part == FINGER || part == FINGERTIP ||
  83. 		    part == HAND || part == HANDED))
  84. 	    return humanoid_parts[part];
  85. 	if (mptr == &mons[PM_RAVEN])
  86. 	    return bird_parts[part];
  87. 	if (mptr->mlet == S_CENTAUR || mptr->mlet == S_UNICORN ||
  88. 		(mptr == &mons[PM_ROTHE] && part != HAIR))
  89. 	    return horse_parts[part];
  90. 	if (mptr->mlet == S_LIGHT) {
  91. 		if (part == HANDED) return "rayed";
  92. 		else if (part == ARM || part == FINGER ||
  93. 				part == FINGERTIP || part == HAND) return "ray";
  94. 		else return "beam";
  95. 	}
  96. 	if (mptr->mlet == S_EEL && mptr != &mons[PM_JELLYFISH])
  97. 	    return fish_parts[part];
  98. 	if (slithy(mptr) || (mptr->mlet == S_DRAGON && part == HAIR))
  99. 	    return snake_parts[part];
  100. 	if (mptr->mlet == S_EYE)
  101. 	    return sphere_parts[part];
  102. 	if (mptr->mlet == S_JELLY || mptr->mlet == S_PUDDING ||
  103. 		mptr->mlet == S_BLOB || mptr == &mons[PM_JELLYFISH])
  104. 	    return jelly_parts[part];
  105. 	if (mptr->mlet == S_VORTEX || mptr->mlet == S_ELEMENTAL)
  106. 	    return vortex_parts[part];
  107. 	if (mptr->mlet == S_FUNGUS)
  108. 	    return fungus_parts[part];
  109. 	if (humanoid(mptr))
  110. 	    return humanoid_parts[part];
  111. 	return animal_parts[part];
  112. }

body_part[edit]

  1. const char *
  2. body_part(part)
  3. int part;
  4. {
  5. 	return mbodypart(&youmonst, part);
  6. }
  7.  
  8. #endif /* OVL1 */
  9. #ifdef OVL0

body_part() returns a string describing a part of the hero's body; this depends on what kind of creature the hero currently is. Takes one parameter, one of the body part macros.

poly_gender[edit]

  1. int
  2. poly_gender()
  3. {
  4. /* Returns gender of polymorphed player; 0/1=same meaning as flags.female,
  5. * 2=none.
  6. */
  7. 	if (is_neuter(youmonst.data) || !humanoid(youmonst.data)) return 2;
  8. 	return flags.female;
  9. }
  10.  
  11. #endif /* OVL0 */
  12. #ifdef OVLB

ugolemeffects[edit]

  1. void
  2. ugolemeffects(damtype, dam)
  3. int damtype, dam;
  4. {
  5. 	int heal = 0;
  6. 	/* We won't bother with "slow"/"haste" since players do not
  7. 	 * have a monster-specific slow/haste so there is no way to
  8. 	 * restore the old velocity once they are back to human.
  9. 	 */
  10. 	if (u.umonnum != PM_FLESH_GOLEM && u.umonnum != PM_IRON_GOLEM)
  11. 		return;
  12. 	switch (damtype) {
  13. 		case AD_ELEC: if (u.umonnum == PM_FLESH_GOLEM)
  14. 				heal = dam / 6; /* Approx 1 per die */
  15. 			break;
  16. 		case AD_FIRE: if (u.umonnum == PM_IRON_GOLEM)
  17. 				heal = dam;
  18. 			break;
  19. 	}
  20. 	if (heal && (u.mh < u.mhmax)) {
  21. 		u.mh += heal;
  22. 		if (u.mh > u.mhmax) u.mh = u.mhmax;
  23. 		flags.botl = 1;
  24. 		pline("Strangely, you feel better than before.");
  25. 		exercise(A_STR, TRUE);
  26. 	}
  27. }

armor_to_dragon[edit]

  1. STATIC_OVL int
  2. armor_to_dragon(atyp)
  3. int atyp;
  4. {
  5. 	switch(atyp) {
  6. 	    case GRAY_DRAGON_SCALE_MAIL:
  7. 	    case GRAY_DRAGON_SCALES:
  8. 		return PM_GRAY_DRAGON;
  9. 	    case SILVER_DRAGON_SCALE_MAIL:
  10. 	    case SILVER_DRAGON_SCALES:
  11. 		return PM_SILVER_DRAGON;
  12. #if 0	/* DEFERRED */
  13. 	    case SHIMMERING_DRAGON_SCALE_MAIL:
  14. 	    case SHIMMERING_DRAGON_SCALES:
  15. 		return PM_SHIMMERING_DRAGON;
  16. #endif
  17. 	    case RED_DRAGON_SCALE_MAIL:
  18. 	    case RED_DRAGON_SCALES:
  19. 		return PM_RED_DRAGON;
  20. 	    case ORANGE_DRAGON_SCALE_MAIL:
  21. 	    case ORANGE_DRAGON_SCALES:
  22. 		return PM_ORANGE_DRAGON;
  23. 	    case WHITE_DRAGON_SCALE_MAIL:
  24. 	    case WHITE_DRAGON_SCALES:
  25. 		return PM_WHITE_DRAGON;
  26. 	    case BLACK_DRAGON_SCALE_MAIL:
  27. 	    case BLACK_DRAGON_SCALES:
  28. 		return PM_BLACK_DRAGON;
  29. 	    case BLUE_DRAGON_SCALE_MAIL:
  30. 	    case BLUE_DRAGON_SCALES:
  31. 		return PM_BLUE_DRAGON;
  32. 	    case GREEN_DRAGON_SCALE_MAIL:
  33. 	    case GREEN_DRAGON_SCALES:
  34. 		return PM_GREEN_DRAGON;
  35. 	    case YELLOW_DRAGON_SCALE_MAIL:
  36. 	    case YELLOW_DRAGON_SCALES:
  37. 		return PM_YELLOW_DRAGON;
  38. 	    default:
  39. 		return -1;
  40. 	}
  41. }
  42.  
  43. #endif /* OVLB */
  44.  
  45. /*polyself.c*/