Source:NetHack 3.4.3/src/mhitu.c

From NetHackWiki
Jump to: navigation, search

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

Top of file[edit]

  1. /*	SCCS Id: @(#)mhitu.c	3.4	2003/11/26	*/
  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. #include "artifact.h"
  3.  
  4. STATIC_VAR NEARDATA struct obj *otmp;
  5.  
  6. STATIC_DCL void FDECL(urustm, (struct monst *, struct obj *));
  7. # ifdef OVL1
  8. STATIC_DCL boolean FDECL(u_slip_free, (struct monst *,struct attack *));
  9. STATIC_DCL int FDECL(passiveum, (struct permonst *,struct monst *,struct attack *));
  10. # endif /* OVL1 */
  11.  
  12. #ifdef OVLB
  13. # ifdef SEDUCE
  14. STATIC_DCL void FDECL(mayberem, (struct obj *, const char *));
  15. # endif
  16. #endif /* OVLB */
  17.  
  18. STATIC_DCL boolean FDECL(diseasemu, (struct permonst *));
  19. STATIC_DCL int FDECL(hitmu, (struct monst *,struct attack *));
  20. STATIC_DCL int FDECL(gulpmu, (struct monst *,struct attack *));
  21. STATIC_DCL int FDECL(explmu, (struct monst *,struct attack *,BOOLEAN_P));
  22. STATIC_DCL void FDECL(missmu,(struct monst *,BOOLEAN_P,struct attack *));
  23. STATIC_DCL void FDECL(mswings,(struct monst *,struct obj *));
  24. STATIC_DCL void FDECL(wildmiss, (struct monst *,struct attack *));
  25.  
  26. STATIC_DCL void FDECL(hurtarmor,(int));
  27. STATIC_DCL void FDECL(hitmsg,(struct monst *,struct attack *));
  28.  
  29. /* See comment in mhitm.c.  If we use this a lot it probably should be */
  30. /* changed to a parameter to mhitu. */
  31. static int dieroll;

hitmsg[edit]

  1. #ifdef OVL1
  2.  
  3.  
  4. STATIC_OVL void
  5. hitmsg(mtmp, mattk)
  6. register struct monst *mtmp;
  7. register struct attack *mattk;
  8. {
  9. 	int compat;
  10.  
  11. 	/* Note: if opposite gender, "seductively" */
  12. 	/* If same gender, "engagingly" for nymph, normal msg for others */
  13. 	if((compat = could_seduce(mtmp, &youmonst, mattk))
  14. 			&& !mtmp->mcan && !mtmp->mspec_used) {
  15. 		pline("%s %s you %s.", Monnam(mtmp),
  16. 			Blind ? "talks to" : "smiles at",
  17. 			compat == 2 ? "engagingly" : "seductively");
  18. 	} else
  19. 	    switch (mattk->aatyp) {
  20. 		case AT_BITE:
  21. 			pline("%s bites!", Monnam(mtmp));
  22. 			break;
  23. 		case AT_KICK:
  24. 			pline("%s kicks%c", Monnam(mtmp),
  25. 				    thick_skinned(youmonst.data) ? '.' : '!');
  26. 			break;
  27. 		case AT_STNG:
  28. 			pline("%s stings!", Monnam(mtmp));
  29. 			break;
  30. 		case AT_BUTT:
  31. 			pline("%s butts!", Monnam(mtmp));
  32. 			break;
  33. 		case AT_TUCH:
  34. 			pline("%s touches you!", Monnam(mtmp));
  35. 			break;
  36. 		case AT_TENT:
  37. 			pline("%s tentacles suck you!",
  38. 				        s_suffix(Monnam(mtmp)));
  39. 			break;
  40. 		case AT_EXPL:
  41. 		case AT_BOOM:
  42. 			pline("%s explodes!", Monnam(mtmp));
  43. 			break;
  44. 		default:
  45. 			pline("%s hits!", Monnam(mtmp));
  46. 	    }
  47. }

missmu[edit]

  1. STATIC_OVL void
  2. missmu(mtmp, nearmiss, mattk)		/* monster missed you */
  3. register struct monst *mtmp;
  4. register boolean nearmiss;
  5. register struct attack *mattk;
  6. {
  7. 	if (!canspotmon(mtmp))
  8. 	    map_invisible(mtmp->mx, mtmp->my);
  9.  
  10. 	if(could_seduce(mtmp, &youmonst, mattk) && !mtmp->mcan)
  11. 	    pline("%s pretends to be friendly.", Monnam(mtmp));
  12. 	else {
  13. 	    if (!flags.verbose || !nearmiss)
  14. 		pline("%s misses.", Monnam(mtmp));
  15. 	    else
  16. 		pline("%s just misses!", Monnam(mtmp));
  17. 	}
  18. 	stop_occupation();
  19. }

mswings[edit]

  1. STATIC_OVL void
  2. mswings(mtmp, otemp)		/* monster swings obj */
  3. register struct monst *mtmp;
  4. register struct obj *otemp;
  5. {
  6. 	if (!flags.verbose || Blind || !mon_visible(mtmp))
  7. 		return;
  8. 	pline("%s %s %s %s.", Monnam(mtmp),
  9. 	      (objects[otemp->otyp].oc_dir & PIERCE) ? "thrusts" : "swings",
  10. 	      mhis(mtmp), singular(otemp, xname));
  11. }

mpoisons_subj[edit]

  1. /* return how a poison attack was delivered */
  2. const char *
  3. mpoisons_subj(mtmp, mattk)
  4. struct monst *mtmp;
  5. struct attack *mattk;
  6. {
  7. 	if (mattk->aatyp == AT_WEAP) {
  8. 	    struct obj *mwep = (mtmp == &youmonst) ? uwep : MON_WEP(mtmp);
  9. 	    /* "Foo's attack was poisoned." is pretty lame, but at least
  10. 	       it's better than "sting" when not a stinging attack... */
  11. 	    return (!mwep || !mwep->opoisoned) ? "attack" : "weapon";
  12. 	} else {
  13. 	    return (mattk->aatyp == AT_TUCH) ? "contact" :
  14. 		   (mattk->aatyp == AT_GAZE) ? "gaze" :
  15. 		   (mattk->aatyp == AT_BITE) ? "bite" : "sting";
  16. 	}
  17. }

u_slow_down[edit]

  1. /* called when your intrinsic speed is taken away */
  2. void
  3. u_slow_down()
  4. {
  5. 	HFast = 0L;
  6. 	if (!Fast)
  7. 	    You("slow down.");
  8. 	else	/* speed boots */
  9. 	    Your("quickness feels less natural.");
  10. 	exercise(A_DEX, FALSE);
  11. }
  12.  
  13. #endif /* OVL1 */

wildmiss[edit]

  1. #ifdef OVLB
  2.  
  3. STATIC_OVL void
  4. wildmiss(mtmp, mattk)		/* monster attacked your displaced image */
  5. 	register struct monst *mtmp;
  6. 	register struct attack *mattk;
  7. {
  8. 	int compat;
  9.  
  10. 	/* no map_invisible() -- no way to tell where _this_ is coming from */
  11.  
  12. 	if (!flags.verbose) return;
  13. 	if (!cansee(mtmp->mx, mtmp->my)) return;
  14. 		/* maybe it's attacking an image around the corner? */
  15.  
  16. 	compat = (mattk->adtyp == AD_SEDU || mattk->adtyp == AD_SSEX) &&
  17. 		 could_seduce(mtmp, &youmonst, (struct attack *)0);
  18.  
  19. 	if (!mtmp->mcansee || (Invis && !perceives(mtmp->data))) {
  20. 	    const char *swings =
  21. 		mattk->aatyp == AT_BITE ? "snaps" :
  22. 		mattk->aatyp == AT_KICK ? "kicks" :
  23. 		(mattk->aatyp == AT_STNG ||
  24. 		 mattk->aatyp == AT_BUTT ||
  25. 		 nolimbs(mtmp->data)) ? "lunges" : "swings";
  26.  
  27. 	    if (compat)
  28. 		pline("%s tries to touch you and misses!", Monnam(mtmp));
  29. 	    else
  30. 		switch(rn2(3)) {
  31. 		case 0: pline("%s %s wildly and misses!", Monnam(mtmp),
  32. 			      swings);
  33. 		    break;
  34. 		case 1: pline("%s attacks a spot beside you.", Monnam(mtmp));
  35. 		    break;
  36. 		case 2: pline("%s strikes at %s!", Monnam(mtmp),
  37. 				levl[mtmp->mux][mtmp->muy].typ == WATER
  38. 				    ? "empty water" : "thin air");
  39. 		    break;
  40. 		default:pline("%s %s wildly!", Monnam(mtmp), swings);
  41. 		    break;
  42. 		}
  43.  
  44. 	} else if (Displaced) {
  45. 	    if (compat)
  46. 		pline("%s smiles %s at your %sdisplaced image...",
  47. 			Monnam(mtmp),
  48. 			compat == 2 ? "engagingly" : "seductively",
  49. 			Invis ? "invisible " : "");
  50. 	    else
  51. 		pline("%s strikes at your %sdisplaced image and misses you!",
  52. 			/* Note: if you're both invisible and displaced,
  53. 			 * only monsters which see invisible will attack your
  54. 			 * displaced image, since the displaced image is also
  55. 			 * invisible.
  56. 			 */
  57. 			Monnam(mtmp),
  58. 			Invis ? "invisible " : "");
  59.  
  60. 	} else if (Underwater) {
  61. 	    /* monsters may miss especially on water level where
  62. 	       bubbles shake the player here and there */
  63. 	    if (compat)
  64. 		pline("%s reaches towards your distorted image.",Monnam(mtmp));
  65. 	    else
  66. 		pline("%s is fooled by water reflections and misses!",Monnam(mtmp));
  67.  
  68. 	} else impossible("%s attacks you without knowing your location?",
  69. 		Monnam(mtmp));
  70. }

expels[edit]

  1. void
  2. expels(mtmp, mdat, message)
  3. register struct monst *mtmp;
  4. register struct permonst *mdat; /* if mtmp is polymorphed, mdat != mtmp->data */
  5. boolean message;
  6. {
  7. 	if (message) {
  8. 		if (is_animal(mdat))
  9. 			You("get regurgitated!");
  10. 		else {
  11. 			char blast[40];
  12. 			register int i;
  13.  
  14. 			blast[0] = '\0';
  15. 			for(i = 0; i < NATTK; i++)
  16. 				if(mdat->mattk[i].aatyp == AT_ENGL)
  17. 					break;
  18. 			if (mdat->mattk[i].aatyp != AT_ENGL)
  19. 			      impossible("Swallower has no engulfing attack?");
  20. 			else {
  21. 				if (is_whirly(mdat)) {
  22. 					switch (mdat->mattk[i].adtyp) {
  23. 						case AD_ELEC:
  24. 							Strcpy(blast,
  25. 						      " in a shower of sparks");
  26. 							break;
  27. 						case AD_COLD:
  28. 							Strcpy(blast,
  29. 							" in a blast of frost");
  30. 							break;
  31. 					}
  32. 				} else
  33. 					Strcpy(blast, " with a squelch");
  34. 				You("get expelled from %s%s!",
  35. 				    mon_nam(mtmp), blast);
  36. 			}
  37. 		}
  38. 	}
  39. 	unstuck(mtmp);	/* ball&chain returned in unstuck() */
  40. 	mnexto(mtmp);
  41. 	newsym(u.ux,u.uy);
  42. 	spoteffects(TRUE);
  43. 	/* to cover for a case where mtmp is not in a next square */
  44. 	if(um_dist(mtmp->mx,mtmp->my,1))
  45. 		pline("Brrooaa...  You land hard at some distance.");
  46. }
  47.  
  48. #endif /* OVLB */

getmattk[edit]

  1. #ifdef OVL0
  2.  
  3. /* select a monster's next attack, possibly substituting for its usual one */
  4. struct attack *
  5. getmattk(mptr, indx, prev_result, alt_attk_buf)
  6. struct permonst *mptr;
  7. int indx, prev_result[];
  8. struct attack *alt_attk_buf;
  9. {
  10. struct attack *attk = &mptr->mattk[indx];
  11.  
  12. /* prevent a monster with two consecutive disease or hunger attacks
  13. from hitting with both of them on the same turn; if the first has
  14. already hit, switch to a stun attack for the second */
  15. if (indx > 0 && prev_result[indx - 1] > 0 &&
  16. 	    (attk->adtyp == AD_DISE ||
  17. 		attk->adtyp == AD_PEST ||
  18. 		attk->adtyp == AD_FAMN) &&
  19. 	    attk->adtyp == mptr->mattk[indx - 1].adtyp) {
  20. 	*alt_attk_buf = *attk;
  21. 	attk = alt_attk_buf;
  22. 	attk->adtyp = AD_STUN;
  23. }
  24. return attk;
  25. }

mattacku[edit]

  1. /*
  2. * mattacku: monster attacks you
  3. *	returns 1 if monster dies (e.g. "yellow light"), 0 otherwise
  4. *	Note: if you're displaced or invisible the monster might attack the
  5. *		wrong position...
  6. *	Assumption: it's attacking you or an empty square; if there's another
  7. *		monster which it attacks by mistake, the caller had better
  8. *		take care of it...
  9. */
  10. int
  11. mattacku(mtmp)
  12. 	register struct monst *mtmp;
  13. {
  14. 	struct	attack	*mattk, alt_attk;
  15. 	int	i, j, tmp, sum[NATTK];
  16. 	struct	permonst *mdat = mtmp->data;
  17. 	boolean ranged = (distu(mtmp->mx, mtmp->my) > 3);
  18. 		/* Is it near you?  Affects your actions */
  19. 	boolean range2 = !monnear(mtmp, mtmp->mux, mtmp->muy);
  20. 		/* Does it think it's near you?  Affects its actions */
  21. 	boolean foundyou = (mtmp->mux==u.ux && mtmp->muy==u.uy);
  22. 		/* Is it attacking you or your image? */
  23. 	boolean youseeit = canseemon(mtmp);
  24. 		/* Might be attacking your image around the corner, or
  25. 		 * invisible, or you might be blind....
  26. 		 */
  27.  
  28. 	if(!ranged) nomul(0);
  29. 	if(mtmp->mhp <= 0 || (Underwater && !is_swimmer(mtmp->data)))
  30. 	    return(0);
  31.  
  32. 	/* If swallowed, can only be affected by u.ustuck */
  33. 	if(u.uswallow) {
  34. 	    if(mtmp != u.ustuck)
  35. 		return(0);
  36. 	    u.ustuck->mux = u.ux;
  37. 	    u.ustuck->muy = u.uy;
  38. 	    range2 = 0;
  39. 	    foundyou = 1;
  40. 	    if(u.uinvulnerable) return (0); /* stomachs can't hurt you! */
  41. 	}
  42.  
  43. #ifdef STEED
  44. 	else if (u.usteed) {
  45. 		if (mtmp == u.usteed)
  46. 			/* Your steed won't attack you */
  47. 			return (0);
  48. 		/* Orcs like to steal and eat horses and the like */
  49. 		if (!rn2(is_orc(mtmp->data) ? 2 : 4) &&
  50. 				distu(mtmp->mx, mtmp->my) <= 2) {
  51. 			/* Attack your steed instead */
  52. 			i = mattackm(mtmp, u.usteed);
  53. 			if ((i & MM_AGR_DIED))
  54. 				return (1);
  55. 			if (i & MM_DEF_DIED || u.umoved)
  56. 				return (0);
  57. 			/* Let your steed retaliate */
  58. 			return (!!(mattackm(u.usteed, mtmp) & MM_DEF_DIED));
  59. 		}
  60. 	}
  61. #endif
  62.  
  63. 	if (u.uundetected && !range2 && foundyou && !u.uswallow) {
  64. 		u.uundetected = 0;
  65. 		if (is_hider(youmonst.data)) {
  66. 		    coord cc; /* maybe we need a unexto() function? */
  67. 		    struct obj *obj;
  68.  
  69. 		    You("fall from the %s!", ceiling(u.ux,u.uy));
  70. 		    if (enexto(&cc, u.ux, u.uy, youmonst.data)) {
  71. 			remove_monster(mtmp->mx, mtmp->my);
  72. 			newsym(mtmp->mx,mtmp->my);
  73. 			place_monster(mtmp, u.ux, u.uy);
  74. 			if(mtmp->wormno) worm_move(mtmp);
  75. 			teleds(cc.x, cc.y, TRUE);
  76. 			set_apparxy(mtmp);
  77. 			newsym(u.ux,u.uy);
  78. 		    } else {
  79. 			pline("%s is killed by a falling %s (you)!",
  80. 					Monnam(mtmp), youmonst.data->mname);
  81. 			killed(mtmp);
  82. 			newsym(u.ux,u.uy);
  83. 			if (mtmp->mhp > 0) return 0;
  84. 			else return 1;
  85. 		    }
  86. 		    if (youmonst.data->mlet != S_PIERCER)
  87. 			return(0);	/* trappers don't attack */
  88.  
  89. 		    obj = which_armor(mtmp, WORN_HELMET);
  90. 		    if (obj && is_metallic(obj)) {
  91. 			Your("blow glances off %s helmet.",
  92. 			               s_suffix(mon_nam(mtmp)));
  93. 		    } else {
  94. 			if (3 + find_mac(mtmp) <= rnd(20)) {
  95. 			    pline("%s is hit by a falling piercer (you)!",
  96. 								Monnam(mtmp));
  97. 			    if ((mtmp->mhp -= d(3,6)) < 1)
  98. 				killed(mtmp);
  99. 			} else
  100. 			  pline("%s is almost hit by a falling piercer (you)!",
  101. 								Monnam(mtmp));
  102. 		    }
  103. 		} else {
  104. 		    if (!youseeit)
  105. 			pline("It tries to move where you are hiding.");
  106. 		    else {
  107. 			/* Ugly kludge for eggs.  The message is phrased so as
  108. 			 * to be directed at the monster, not the player,
  109. 			 * which makes "laid by you" wrong.  For the
  110. 			 * parallelism to work, we can't rephrase it, so we
  111. 			 * zap the "laid by you" momentarily instead.
  112. 			 */
  113. 			struct obj *obj = level.objects[u.ux][u.uy];
  114.  
  115. 			if (obj ||
  116. 			      (youmonst.data->mlet == S_EEL && is_pool(u.ux, u.uy))) {
  117. 			    int save_spe = 0; /* suppress warning */
  118. 			    if (obj) {
  119. 				save_spe = obj->spe;
  120. 				if (obj->otyp == EGG) obj->spe = 0;
  121. 			    }
  122. 			    if (youmonst.data->mlet == S_EEL)
  123. 		pline("Wait, %s!  There's a hidden %s named %s there!",
  124. 				m_monnam(mtmp), youmonst.data->mname, plname);
  125. 			    else
  126. 	     pline("Wait, %s!  There's a %s named %s hiding under %s!",
  127. 				m_monnam(mtmp), youmonst.data->mname, plname,
  128. 				doname(level.objects[u.ux][u.uy]));
  129. 			    if (obj) obj->spe = save_spe;
  130. 			} else
  131. 			    impossible("hiding under nothing?");
  132. 		    }
  133. 		    newsym(u.ux,u.uy);
  134. 		}
  135. 		return(0);
  136. 	}
  137. 	if (youmonst.data->mlet == S_MIMIC && youmonst.m_ap_type &&
  138. 		    !range2 && foundyou && !u.uswallow) {
  139. 		if (!youseeit) pline("It gets stuck on you.");
  140. 		else pline("Wait, %s!  That's a %s named %s!",
  141. 			   m_monnam(mtmp), youmonst.data->mname, plname);
  142. 		u.ustuck = mtmp;
  143. 		youmonst.m_ap_type = M_AP_NOTHING;
  144. 		youmonst.mappearance = 0;
  145. 		newsym(u.ux,u.uy);
  146. 		return(0);
  147. 	}
  148.  
  149. 	/* player might be mimicking an object */
  150. 	if (youmonst.m_ap_type == M_AP_OBJECT && !range2 && foundyou && !u.uswallow) {
  151. 	    if (!youseeit)
  152. 		 pline("%s %s!", Something,
  153. 			(likes_gold(mtmp->data) && youmonst.mappearance == GOLD_PIECE) ?
  154. 			"tries to pick you up" : "disturbs you");
  155. 	    else pline("Wait, %s!  That %s is really %s named %s!",
  156. 			m_monnam(mtmp),
  157. 			mimic_obj_name(&youmonst),
  158. 			an(mons[u.umonnum].mname),
  159. 			plname);
  160. 	    if (multi < 0) {	/* this should always be the case */
  161. 		char buf[BUFSZ];
  162. 		Sprintf(buf, "You appear to be %s again.",
  163. 			Upolyd ? (const char *) an(youmonst.data->mname) :
  164. 			    (const char *) "yourself");
  165. 		unmul(buf);	/* immediately stop mimicking */
  166. 	    }
  167. 	    return 0;
  168. 	}
  169.  
  170. /*	Work out the armor class differential	*/
  171. 	tmp = AC_VALUE(u.uac) + 10;		/* tmp ~= 0 - 20 */
  172. 	tmp += mtmp->m_lev;
  173. 	if(multi < 0) tmp += 4;
  174. 	if((Invis && !perceives(mdat)) || !mtmp->mcansee)
  175. 		tmp -= 2;
  176. 	if(mtmp->mtrapped) tmp -= 2;
  177. 	if(tmp <= 0) tmp = 1;
  178.  
  179. 	/* make eels visible the moment they hit/miss us */
  180. 	if(mdat->mlet == S_EEL && mtmp->minvis && cansee(mtmp->mx,mtmp->my)) {
  181. 		mtmp->minvis = 0;
  182. 		newsym(mtmp->mx,mtmp->my);
  183. 	}
  184.  
  185. /*	Special demon handling code */
  186. 	if(!mtmp->cham && is_demon(mdat) && !range2
  187. 	   && mtmp->data != &mons[PM_BALROG]
  188. 	   && mtmp->data != &mons[PM_SUCCUBUS]
  189. 	   && mtmp->data != &mons[PM_INCUBUS])
  190. 	    if(!mtmp->mcan && !rn2(13))	msummon(mtmp);
  191.  
  192. /*	Special lycanthrope handling code */
  193. 	if(!mtmp->cham && is_were(mdat) && !range2) {
  194.  
  195. 	    if(is_human(mdat)) {
  196. 		if(!rn2(5 - (night() * 2)) && !mtmp->mcan) new_were(mtmp);
  197. 	    } else if(!rn2(30) && !mtmp->mcan) new_were(mtmp);
  198. 	    mdat = mtmp->data;
  199.  
  200. 	    if(!rn2(10) && !mtmp->mcan) {
  201. 	    	int numseen, numhelp;
  202. 		char buf[BUFSZ], genericwere[BUFSZ];
  203.  
  204. 		Strcpy(genericwere, "creature");
  205. 		numhelp = were_summon(mdat, FALSE, &numseen, genericwere);
  206. 		if (youseeit) {
  207. 			pline("%s summons help!", Monnam(mtmp));
  208. 			if (numhelp > 0) {
  209. 			    if (numseen == 0)
  210. 				You_feel("hemmed in.");
  211. 			} else pline("But none comes.");
  212. 		} else {
  213. 			const char *from_nowhere;
  214.  
  215. 			if (flags.soundok) {
  216. 				pline("%s %s!", Something,
  217. 					makeplural(growl_sound(mtmp)));
  218. 				from_nowhere = "";
  219. 			} else from_nowhere = " from nowhere";
  220. 			if (numhelp > 0) {
  221. 			    if (numseen < 1) You_feel("hemmed in.");
  222. 			    else {
  223. 				if (numseen == 1)
  224. 			    		Sprintf(buf, "%s appears",
  225. 							an(genericwere));
  226. 			    	else
  227. 			    		Sprintf(buf, "%s appear",
  228. 							makeplural(genericwere));
  229. 				pline("%s%s!", upstart(buf), from_nowhere);
  230. 			    }
  231. 			} /* else no help came; but you didn't know it tried */
  232. 		}
  233. 	    }
  234. 	}
  235.  
  236. 	if(u.uinvulnerable) {
  237. 	    /* monsters won't attack you */
  238. 	    if(mtmp == u.ustuck)
  239. 		pline("%s loosens its grip slightly.", Monnam(mtmp));
  240. 	    else if(!range2) {
  241. 		if (youseeit || sensemon(mtmp))
  242. 		    pline("%s starts to attack you, but pulls back.",
  243. 			  Monnam(mtmp));
  244. 		else
  245. 		    You_feel("%s move nearby.", something);
  246. 	    }
  247. 	    return (0);
  248. 	}
  249.  
  250. 	/* Unlike defensive stuff, don't let them use item _and_ attack. */
  251. 	if(find_offensive(mtmp)) {
  252. 		int foo = use_offensive(mtmp);
  253.  
  254. 		if (foo != 0) return(foo==1);
  255. 	}
  256.  
  257. 	for(i = 0; i < NATTK; i++) {
  258.  
  259. 	    sum[i] = 0;
  260. 	    mattk = getmattk(mdat, i, sum, &alt_attk);
  261. 	    if (u.uswallow && (mattk->aatyp != AT_ENGL))
  262. 		continue;
  263. 	    switch(mattk->aatyp) {
  264. 		case AT_CLAW:	/* "hand to hand" attacks */
  265. 		case AT_KICK:
  266. 		case AT_BITE:
  267. 		case AT_STNG:
  268. 		case AT_TUCH:
  269. 		case AT_BUTT:
  270. 		case AT_TENT:
  271. 			if(!range2 && (!MON_WEP(mtmp) || mtmp->mconf || Conflict ||
  272. 					!touch_petrifies(youmonst.data))) {
  273. 			    if (foundyou) {
  274. 				if(tmp > (j = rnd(20+i))) {
  275. 				    if (mattk->aatyp != AT_KICK ||
  276. 					    !thick_skinned(youmonst.data))
  277. 					sum[i] = hitmu(mtmp, mattk);
  278. 				} else
  279. 				    missmu(mtmp, (tmp == j), mattk);
  280. 			    } else
  281. 				wildmiss(mtmp, mattk);
  282. 			}
  283. 			break;
  284.  
  285. 		case AT_HUGS:	/* automatic if prev two attacks succeed */
  286. 			/* Note: if displaced, prev attacks never succeeded */
  287. 			if((!range2 && i>=2 && sum[i-1] && sum[i-2])
  288. 							|| mtmp == u.ustuck)
  289. 				sum[i]= hitmu(mtmp, mattk);
  290. 			break;
  291.  
  292. 		case AT_GAZE:	/* can affect you either ranged or not */
  293. 			/* Medusa gaze already operated through m_respond in
  294. 			 * dochug(); don't gaze more than once per round.
  295. 			 */
  296. 			if (mdat != &mons[PM_MEDUSA])
  297. 				sum[i] = gazemu(mtmp, mattk);
  298. 			break;
  299.  
  300. 		case AT_EXPL:	/* automatic hit if next to, and aimed at you */
  301. 			if(!range2) sum[i] = explmu(mtmp, mattk, foundyou);
  302. 			break;
  303.  
  304. 		case AT_ENGL:
  305. 			if (!range2) {
  306. 			    if(foundyou) {
  307. 				if(u.uswallow || tmp > (j = rnd(20+i))) {
  308. 				    /* Force swallowing monster to be
  309. 				     * displayed even when player is
  310. 				     * moving away */
  311. 				    flush_screen(1);
  312. 				    sum[i] = gulpmu(mtmp, mattk);
  313. 				} else {
  314. 				    missmu(mtmp, (tmp == j), mattk);
  315. 				}
  316. 			    } else if (is_animal(mtmp->data)) {
  317. 				pline("%s gulps some air!", Monnam(mtmp));
  318. 			    } else {
  319. 				if (youseeit)
  320. 				    pline("%s lunges forward and recoils!",
  321. 					  Monnam(mtmp));
  322. 				else
  323. 				    You_hear("a %s nearby.",
  324. 					     is_whirly(mtmp->data) ?
  325. 						"rushing noise" : "splat");
  326. 			   }
  327. 			}
  328. 			break;
  329. 		case AT_BREA:
  330. 			if(range2) sum[i] = breamu(mtmp, mattk);
  331. 			/* Note: breamu takes care of displacement */
  332. 			break;
  333. 		case AT_SPIT:
  334. 			if(range2) sum[i] = spitmu(mtmp, mattk);
  335. 			/* Note: spitmu takes care of displacement */
  336. 			break;
  337. 		case AT_WEAP:
  338. 			if(range2) {
  339. #ifdef REINCARNATION
  340. 				if (!Is_rogue_level(&u.uz))
  341. #endif
  342. 					thrwmu(mtmp);
  343. 			} else {
  344. 			    int hittmp = 0;
  345.  
  346. 			    /* Rare but not impossible.  Normally the monster
  347. 			     * wields when 2 spaces away, but it can be
  348. 			     * teleported or whatever....
  349. 			     */
  350. 			    if (mtmp->weapon_check == NEED_WEAPON ||
  351. 							!MON_WEP(mtmp)) {
  352. 				mtmp->weapon_check = NEED_HTH_WEAPON;
  353. 				/* mon_wield_item resets weapon_check as
  354. 				 * appropriate */
  355. 				if (mon_wield_item(mtmp) != 0) break;
  356. 			    }
  357. 			    if (foundyou) {
  358. 				otmp = MON_WEP(mtmp);
  359. 				if(otmp) {
  360. 				    hittmp = hitval(otmp, &youmonst);
  361. 				    tmp += hittmp;
  362. 				    mswings(mtmp, otmp);
  363. 				}
  364. 				if(tmp > (j = dieroll = rnd(20+i)))
  365. 				    sum[i] = hitmu(mtmp, mattk);
  366. 				else
  367. 				    missmu(mtmp, (tmp == j), mattk);
  368. 				/* KMH -- Don't accumulate to-hit bonuses */
  369. 				if (otmp)
  370. 					tmp -= hittmp;
  371. 			    } else
  372. 				wildmiss(mtmp, mattk);
  373. 			}
  374. 			break;
  375. 		case AT_MAGC:
  376. 			if (range2)
  377. 			    sum[i] = buzzmu(mtmp, mattk);
  378. 			else {
  379. 			    if (foundyou)
  380. 				sum[i] = castmu(mtmp, mattk, TRUE, TRUE);
  381. 			    else
  382. 				sum[i] = castmu(mtmp, mattk, TRUE, FALSE);
  383. 			}
  384. 			break;
  385.  
  386. 		default:		/* no attack */
  387. 			break;
  388. 	    }
  389. 	    if(flags.botl) bot();
  390. 	/* give player a chance of waking up before dying -kaa */
  391. 	    if(sum[i] == 1) {	    /* successful attack */
  392. 		if (u.usleep && u.usleep < monstermoves && !rn2(10)) {
  393. 		    multi = -1;
  394. 		    nomovemsg = "The combat suddenly awakens you.";
  395. 		}
  396. 	    }
  397. 	    if(sum[i] == 2) return 1;		/* attacker dead */
  398. 	    if(sum[i] == 3) break;  /* attacker teleported, no more attacks */
  399. 	    /* sum[i] == 0: unsuccessful attack */
  400. 	}
  401. 	return(0);
  402. }
  403.  
  404. #endif /* OVL0 */

hurtarmor[edit]

  1. #ifdef OVLB
  2.  
  3. /*
  4. * helper function for some compilers that have trouble with hitmu
  5. */
  6.  
  7. STATIC_OVL void
  8. hurtarmor(attk)
  9. int attk;
  10. {
  11. 	int	hurt;
  12.  
  13. 	switch(attk) {
  14. 	    /* 0 is burning, which we should never be called with */
  15. 	    case AD_RUST: hurt = 1; break;
  16. 	    case AD_CORR: hurt = 3; break;
  17. 	    default: hurt = 2; break;
  18. 	}
  19.  
  20. 	/* What the following code does: it keeps looping until it
  21. 	 * finds a target for the rust monster.
  22. 	 * Head, feet, etc... not covered by metal, or covered by
  23. 	 * rusty metal, are not targets.  However, your body always
  24. 	 * is, no matter what covers it.
  25. 	 */
  26. 	while (1) {
  27. 	    switch(rn2(5)) {
  28. 	    case 0:
  29. 		if (!uarmh || !rust_dmg(uarmh, xname(uarmh), hurt, FALSE, &youmonst))
  30. 			continue;
  31. 		break;
  32. 	    case 1:
  33. 		if (uarmc) {
  34. 		    (void)rust_dmg(uarmc, xname(uarmc), hurt, TRUE, &youmonst);
  35. 		    break;
  36. 		}
  37. 		/* Note the difference between break and continue;
  38. 		 * break means it was hit and didn't rust; continue
  39. 		 * means it wasn't a target and though it didn't rust
  40. 		 * something else did.
  41. 		 */
  42. 		if (uarm)
  43. 		    (void)rust_dmg(uarm, xname(uarm), hurt, TRUE, &youmonst);
  44. #ifdef TOURIST
  45. 		else if (uarmu)
  46. 		    (void)rust_dmg(uarmu, xname(uarmu), hurt, TRUE, &youmonst);
  47. #endif
  48. 		break;
  49. 	    case 2:
  50. 		if (!uarms || !rust_dmg(uarms, xname(uarms), hurt, FALSE, &youmonst))
  51. 		    continue;
  52. 		break;
  53. 	    case 3:
  54. 		if (!uarmg || !rust_dmg(uarmg, xname(uarmg), hurt, FALSE, &youmonst))
  55. 		    continue;
  56. 		break;
  57. 	    case 4:
  58. 		if (!uarmf || !rust_dmg(uarmf, xname(uarmf), hurt, FALSE, &youmonst))
  59. 		    continue;
  60. 		break;
  61. 	    }
  62. 	    break; /* Out of while loop */
  63. 	}
  64. }
  65.  
  66. #endif /* OVLB */

diseasemu[edit]

  1. #ifdef OVL1
  2.  
  3. STATIC_OVL boolean
  4. diseasemu(mdat)
  5. struct permonst *mdat;
  6. {
  7. 	if (Sick_resistance) {
  8. 		You_feel("a slight illness.");
  9. 		return FALSE;
  10. 	} else {
  11. 		make_sick(Sick ? Sick/3L + 1L : (long)rn1(ACURR(A_CON), 20),
  12. 			mdat->mname, TRUE, SICK_NONVOMITABLE);
  13. 		return TRUE;
  14. 	}
  15. }

u_slip_free[edit]

  1. /* check whether slippery clothing protects from hug or wrap attack */
  2. STATIC_OVL boolean
  3. u_slip_free(mtmp, mattk)
  4. struct monst *mtmp;
  5. struct attack *mattk;
  6. {
  7. 	struct obj *obj = (uarmc ? uarmc : uarm);
  8.  
  9. #ifdef TOURIST
  10. 	if (!obj) obj = uarmu;
  11. #endif
  12. 	if (mattk->adtyp == AD_DRIN) obj = uarmh;
  13.  
  14. 	/* if your cloak/armor is greased, monster slips off; this
  15. 	   protection might fail (33% chance) when the armor is cursed */
  16. 	if (obj && (obj->greased || obj->otyp == OILSKIN_CLOAK) &&
  17. 		(!obj->cursed || rn2(3))) {
  18. 	    pline("%s %s your %s %s!",
  19. 		  Monnam(mtmp),
  20. 		  (mattk->adtyp == AD_WRAP) ?
  21. 			"slips off of" : "grabs you, but cannot hold onto",
  22. 		  obj->greased ? "greased" : "slippery",
  23. 		  /* avoid "slippery slippery cloak"
  24. 		     for undiscovered oilskin cloak */
  25. 		  (obj->greased || objects[obj->otyp].oc_name_known) ?
  26. 			xname(obj) : cloak_simple_name(obj));
  27.  
  28. 	    if (obj->greased && !rn2(2)) {
  29. 		pline_The("grease wears off.");
  30. 		obj->greased = 0;
  31. 		update_inventory();
  32. 	    }
  33. 	    return TRUE;
  34. 	}
  35. 	return FALSE;
  36. }

magic_negation[edit]

  1. /* armor that sufficiently covers the body might be able to block magic */
  2. int
  3. magic_negation(mon)
  4. struct monst *mon;
  5. {
  6. 	struct obj *armor;
  7. 	int armpro = 0;
  8.  
  9. 	armor = (mon == &youmonst) ? uarm : which_armor(mon, W_ARM);
  10. 	if (armor && armpro < objects[armor->otyp].a_can)
  11. 	    armpro = objects[armor->otyp].a_can;
  12. 	armor = (mon == &youmonst) ? uarmc : which_armor(mon, W_ARMC);
  13. 	if (armor && armpro < objects[armor->otyp].a_can)
  14. 	    armpro = objects[armor->otyp].a_can;
  15. 	armor = (mon == &youmonst) ? uarmh : which_armor(mon, W_ARMH);
  16. 	if (armor && armpro < objects[armor->otyp].a_can)
  17. 	    armpro = objects[armor->otyp].a_can;
  18.  
  19. 	/* armor types for shirt, gloves, shoes, and shield don't currently
  20. 	   provide any magic cancellation but we might as well be complete */
  21. #ifdef TOURIST
  22. 	armor = (mon == &youmonst) ? uarmu : which_armor(mon, W_ARMU);
  23. 	if (armor && armpro < objects[armor->otyp].a_can)
  24. 	    armpro = objects[armor->otyp].a_can;
  25. #endif
  26. 	armor = (mon == &youmonst) ? uarmg : which_armor(mon, W_ARMG);
  27. 	if (armor && armpro < objects[armor->otyp].a_can)
  28. 	    armpro = objects[armor->otyp].a_can;
  29. 	armor = (mon == &youmonst) ? uarmf : which_armor(mon, W_ARMF);
  30. 	if (armor && armpro < objects[armor->otyp].a_can)
  31. 	    armpro = objects[armor->otyp].a_can;
  32. 	armor = (mon == &youmonst) ? uarms : which_armor(mon, W_ARMS);
  33. 	if (armor && armpro < objects[armor->otyp].a_can)
  34. 	    armpro = objects[armor->otyp].a_can;
  35.  
  36. #ifdef STEED
  37. 	/* this one is really a stretch... */
  38. 	armor = (mon == &youmonst) ? 0 : which_armor(mon, W_SADDLE);
  39. 	if (armor && armpro < objects[armor->otyp].a_can)
  40. 	    armpro = objects[armor->otyp].a_can;
  41. #endif
  42.  
  43. 	return armpro;
  44. }

hitmu[edit]

  1. /*
  2. * hitmu: monster hits you
  3. *	  returns 2 if monster dies (e.g. "yellow light"), 1 otherwise
  4. *	  3 if the monster lives but teleported/paralyzed, so it can't keep
  5. *	       attacking you
  6. */
  7. STATIC_OVL int
  8. hitmu(mtmp, mattk)
  9. 	register struct monst *mtmp;
  10. 	register struct attack  *mattk;
  11. {
  12. 	register struct permonst *mdat = mtmp->data;
  13. 	register int uncancelled, ptmp;
  14. 	int dmg, armpro, permdmg;
  15. 	char	 buf[BUFSZ];
  16. 	struct permonst *olduasmon = youmonst.data;
  17. 	int res;
  18.  
  19. 	if (!canspotmon(mtmp))
  20. 	    map_invisible(mtmp->mx, mtmp->my);
  21.  
  22. /*	If the monster is undetected & hits you, you should know where
  23. *	the attack came from.
  24. */
  25. 	if(mtmp->mundetected && (hides_under(mdat) || mdat->mlet == S_EEL)) {
  26. 	    mtmp->mundetected = 0;
  27. 	    if (!(Blind ? Blind_telepat : Unblind_telepat)) {
  28. 		struct obj *obj;
  29. 		const char *what;
  30.  
  31. 		if ((obj = level.objects[mtmp->mx][mtmp->my]) != 0) {
  32. 		    if (Blind && !obj->dknown)
  33. 			what = something;
  34. 		    else if (is_pool(mtmp->mx, mtmp->my) && !Underwater)
  35. 			what = "the water";
  36. 		    else
  37. 			what = doname(obj);
  38.  
  39. 		    pline("%s was hidden under %s!", Amonnam(mtmp), what);
  40. 		}
  41. 		newsym(mtmp->mx, mtmp->my);
  42. 	    }
  43. 	}
  44.  
  45. /*	First determine the base damage done */
  46. 	dmg = d((int)mattk->damn, (int)mattk->damd);
  47. 	if(is_undead(mdat) && midnight())
  48. 		dmg += d((int)mattk->damn, (int)mattk->damd); /* extra damage */
  49.  
  50. /*	Next a cancellation factor	*/
  51. /*	Use uncancelled when the cancellation factor takes into account certain
  52. *	armor's special magic protection.  Otherwise just use !mtmp->mcan.
  53. */
  54. 	armpro = magic_negation(&youmonst);
  55. 	uncancelled = !mtmp->mcan && ((rn2(3) >= armpro) || !rn2(50));
  56.  
  57. 	permdmg = 0;
  58. /*	Now, adjust damages via resistances or specific attacks */
  59. 	switch(mattk->adtyp) {
  60. 	    case AD_PHYS:
  61. 		if (mattk->aatyp == AT_HUGS && !sticks(youmonst.data)) {
  62. 		    if(!u.ustuck && rn2(2)) {
  63. 			if (u_slip_free(mtmp, mattk)) {
  64. 			    dmg = 0;
  65. 			} else {
  66. 			    u.ustuck = mtmp;
  67. 			    pline("%s grabs you!", Monnam(mtmp));
  68. 			}
  69. 		    } else if(u.ustuck == mtmp) {
  70. 			exercise(A_STR, FALSE);
  71. 			You("are being %s.",
  72. 			      (mtmp->data == &mons[PM_ROPE_GOLEM])
  73. 			      ? "choked" : "crushed");
  74. 		    }
  75. 		} else {			  /* hand to hand weapon */
  76. 		    if(mattk->aatyp == AT_WEAP && otmp) {
  77. 			if (otmp->otyp == CORPSE
  78. 				&& touch_petrifies(&mons[otmp->corpsenm])) {
  79. 			    dmg = 1;
  80. 			    pline("%s hits you with the %s corpse.",
  81. 				Monnam(mtmp), mons[otmp->corpsenm].mname);
  82. 			    if (!Stoned)
  83. 				goto do_stone;
  84. 			}
  85. 			dmg += dmgval(otmp, &youmonst);
  86. 			if (dmg <= 0) dmg = 1;
  87. 			if (!(otmp->oartifact &&
  88. 				artifact_hit(mtmp, &youmonst, otmp, &dmg,dieroll)))
  89. 			     hitmsg(mtmp, mattk);
  90. 			if (!dmg) break;
  91. 			if (u.mh > 1 && u.mh > ((u.uac>0) ? dmg : dmg+u.uac) &&
  92. 				   objects[otmp->otyp].oc_material == IRON &&
  93. 					(u.umonnum==PM_BLACK_PUDDING
  94. 					|| u.umonnum==PM_BROWN_PUDDING)) {
  95. 			    /* This redundancy necessary because you have to
  96. 			     * take the damage _before_ being cloned.
  97. 			     */
  98. 			    if (u.uac < 0) dmg += u.uac;
  99. 			    if (dmg < 1) dmg = 1;
  100. 			    if (dmg > 1) exercise(A_STR, FALSE);
  101. 			    u.mh -= dmg;
  102. 			    flags.botl = 1;
  103. 			    dmg = 0;
  104. 			    if(cloneu())
  105. 			    You("divide as %s hits you!",mon_nam(mtmp));
  106. 			}
  107. 			urustm(mtmp, otmp);
  108. 		    } else if (mattk->aatyp != AT_TUCH || dmg != 0 ||
  109. 				mtmp != u.ustuck)
  110. 			hitmsg(mtmp, mattk);
  111. 		}
  112. 		break;
  113. 	    case AD_DISE:
  114. 		hitmsg(mtmp, mattk);
  115. 		if (!diseasemu(mdat)) dmg = 0;
  116. 		break;
  117. 	    case AD_FIRE:
  118. 		hitmsg(mtmp, mattk);
  119. 		if (uncancelled) {
  120. 		    pline("You're %s!", on_fire(youmonst.data, mattk));
  121. 		    if (youmonst.data == &mons[PM_STRAW_GOLEM] ||
  122. 		        youmonst.data == &mons[PM_PAPER_GOLEM]) {
  123. 			    You("roast!");
  124. 			    /* KMH -- this is okay with unchanging */
  125. 			    rehumanize();
  126. 			    break;
  127. 		    } else if (Fire_resistance) {
  128. 			pline_The("fire doesn't feel hot!");
  129. 			dmg = 0;
  130. 		    }
  131. 		    if((int) mtmp->m_lev > rn2(20))
  132. 			destroy_item(SCROLL_CLASS, AD_FIRE);
  133. 		    if((int) mtmp->m_lev > rn2(20))
  134. 			destroy_item(POTION_CLASS, AD_FIRE);
  135. 		    if((int) mtmp->m_lev > rn2(25))
  136. 			destroy_item(SPBOOK_CLASS, AD_FIRE);
  137. 		    burn_away_slime();
  138. 		} else dmg = 0;
  139. 		break;
  140. 	    case AD_COLD:
  141. 		hitmsg(mtmp, mattk);
  142. 		if (uncancelled) {
  143. 		    pline("You're covered in frost!");
  144. 		    if (Cold_resistance) {
  145. 			pline_The("frost doesn't seem cold!");
  146. 			dmg = 0;
  147. 		    }
  148. 		    if((int) mtmp->m_lev > rn2(20))
  149. 			destroy_item(POTION_CLASS, AD_COLD);
  150. 		} else dmg = 0;
  151. 		break;
  152. 	    case AD_ELEC:
  153. 		hitmsg(mtmp, mattk);
  154. 		if (uncancelled) {
  155. 		    You("get zapped!");
  156. 		    if (Shock_resistance) {
  157. 			pline_The("zap doesn't shock you!");
  158. 			dmg = 0;
  159. 		    }
  160. 		    if((int) mtmp->m_lev > rn2(20))
  161. 			destroy_item(WAND_CLASS, AD_ELEC);
  162. 		    if((int) mtmp->m_lev > rn2(20))
  163. 			destroy_item(RING_CLASS, AD_ELEC);
  164. 		} else dmg = 0;
  165. 		break;
  166. 	    case AD_SLEE:
  167. 		hitmsg(mtmp, mattk);
  168. 		if (uncancelled && multi >= 0 && !rn2(5)) {
  169. 		    if (Sleep_resistance) break;
  170. 		    fall_asleep(-rnd(10), TRUE);
  171. 		    if (Blind) You("are put to sleep!");
  172. 		    else You("are put to sleep by %s!", mon_nam(mtmp));
  173. 		}
  174. 		break;
  175. 	    case AD_BLND:
  176. 		if (can_blnd(mtmp, &youmonst, mattk->aatyp, (struct obj*)0)) {
  177. 		    if (!Blind) pline("%s blinds you!", Monnam(mtmp));
  178. 		    make_blinded(Blinded+(long)dmg,FALSE);
  179. 		    if (!Blind) Your(vision_clears);
  180. 		}
  181. 		dmg = 0;
  182. 		break;
  183. 	    case AD_DRST:
  184. 		ptmp = A_STR;
  185. 		goto dopois;
  186. 	    case AD_DRDX:
  187. 		ptmp = A_DEX;
  188. 		goto dopois;
  189. 	    case AD_DRCO:
  190. 		ptmp = A_CON;
  191. dopois:
  192. 		hitmsg(mtmp, mattk);
  193. 		if (uncancelled && !rn2(8)) {
  194. 		    Sprintf(buf, "%s %s",
  195. 			    s_suffix(Monnam(mtmp)), mpoisons_subj(mtmp, mattk));
  196. 		    poisoned(buf, ptmp, mdat->mname, 30);
  197. 		}
  198. 		break;
  199. 	    case AD_DRIN:
  200. 		hitmsg(mtmp, mattk);
  201. 		if (defends(AD_DRIN, uwep) || !has_head(youmonst.data)) {
  202. 		    You("don't seem harmed.");
  203. 		    /* Not clear what to do for green slimes */
  204. 		    break;
  205. 		}
  206. 		if (u_slip_free(mtmp,mattk)) break;
  207.  
  208. 		if (uarmh && rn2(8)) {
  209. 		    /* not body_part(HEAD) */
  210. 		    Your("helmet blocks the attack to your head.");
  211. 		    break;
  212. 		}
  213. 		if (Half_physical_damage) dmg = (dmg+1) / 2;
  214. 		mdamageu(mtmp, dmg);
  215.  
  216. 		if (!uarmh || uarmh->otyp != DUNCE_CAP) {
  217. 		    Your("brain is eaten!");
  218. 		    /* No such thing as mindless players... */
  219. 		    if (ABASE(A_INT) <= ATTRMIN(A_INT)) {
  220. 			int lifesaved = 0;
  221. 			struct obj *wore_amulet = uamul;
  222.  
  223. 			while(1) {
  224. 			    /* avoid looping on "die(y/n)?" */
  225. 			    if (lifesaved && (discover || wizard)) {
  226. 				if (wore_amulet && !uamul) {
  227. 				    /* used up AMULET_OF_LIFE_SAVING; still
  228. 				       subject to dying from brainlessness */
  229. 				    wore_amulet = 0;
  230. 				} else {
  231. 				    /* explicitly chose not to die;
  232. 				       arbitrarily boost intelligence */
  233. 				    ABASE(A_INT) = ATTRMIN(A_INT) + 2;
  234. 				    You_feel("like a scarecrow.");
  235. 				    break;
  236. 				}
  237. 			    }
  238.  
  239. 			    if (lifesaved)
  240. 				pline("Unfortunately your brain is still gone.");
  241. 			    else
  242. 				Your("last thought fades away.");
  243. 			    killer = "brainlessness";
  244. 			    killer_format = KILLED_BY;
  245. 			    done(DIED);
  246. 			    lifesaved++;
  247. 			}
  248. 		    }
  249. 		}
  250. 		/* adjattrib gives dunce cap message when appropriate */
  251. 		(void) adjattrib(A_INT, -rnd(2), FALSE);
  252. 		forget_levels(25);	/* lose memory of 25% of levels */
  253. 		forget_objects(25);	/* lose memory of 25% of objects */
  254. 		exercise(A_WIS, FALSE);
  255. 		break;
  256. 	    case AD_PLYS:
  257. 		hitmsg(mtmp, mattk);
  258. 		if (uncancelled && multi >= 0 && !rn2(3)) {
  259. 		    if (Free_action) {
  260. 			You("momentarily stiffen.");            
  261. 		    } else {
  262. 			if (Blind) You("are frozen!");
  263. 			else You("are frozen by %s!", mon_nam(mtmp));
  264. 			nomovemsg = 0;	/* default: "you can move again" */
  265. 			nomul(-rnd(10));
  266. 			exercise(A_DEX, FALSE);
  267. 		    }
  268. 		}
  269. 		break;
  270. 	    case AD_DRLI:
  271. 		hitmsg(mtmp, mattk);
  272. 		if (uncancelled && !rn2(3) && !Drain_resistance) {
  273. 		    losexp("life drainage");
  274. 		}
  275. 		break;
  276. 	    case AD_LEGS:
  277. 		{ register long side = rn2(2) ? RIGHT_SIDE : LEFT_SIDE;
  278. 		  const char *sidestr = (side == RIGHT_SIDE) ? "right" : "left";
  279.  
  280. 		/* This case is too obvious to ignore, but Nethack is not in
  281. 		 * general very good at considering height--most short monsters
  282. 		 * still _can_ attack you when you're flying or mounted.
  283. 		 * [FIXME: why can't a flying attacker overcome this?]
  284. 		 */
  285. 		  if (
  286. #ifdef STEED
  287. 			u.usteed ||
  288. #endif
  289. 				    Levitation || Flying) {
  290. 		    pline("%s tries to reach your %s %s!", Monnam(mtmp),
  291. 			  sidestr, body_part(LEG));
  292. 		    dmg = 0;
  293. 		  } else if (mtmp->mcan) {
  294. 		    pline("%s nuzzles against your %s %s!", Monnam(mtmp),
  295. 			  sidestr, body_part(LEG));
  296. 		    dmg = 0;
  297. 		  } else {
  298. 		    if (uarmf) {
  299. 			if (rn2(2) && (uarmf->otyp == LOW_BOOTS ||
  300. 					     uarmf->otyp == IRON_SHOES))
  301. 			    pline("%s pricks the exposed part of your %s %s!",
  302. 				Monnam(mtmp), sidestr, body_part(LEG));
  303. 			else if (!rn2(5))
  304. 			    pline("%s pricks through your %s boot!",
  305. 				Monnam(mtmp), sidestr);
  306. 			else {
  307. 			    pline("%s scratches your %s boot!", Monnam(mtmp),
  308. 				sidestr);
  309. 			    dmg = 0;
  310. 			    break;
  311. 			}
  312. 		    } else pline("%s pricks your %s %s!", Monnam(mtmp),
  313. 			  sidestr, body_part(LEG));
  314. 		    set_wounded_legs(side, rnd(60-ACURR(A_DEX)));
  315. 		    exercise(A_STR, FALSE);
  316. 		    exercise(A_DEX, FALSE);
  317. 		  }
  318. 		  break;
  319. 		}
  320. 	    case AD_STON:	/* cockatrice */
  321. 		hitmsg(mtmp, mattk);
  322. 		if(!rn2(3)) {
  323. 		    if (mtmp->mcan) {
  324. 			if (flags.soundok)
  325. 			    You_hear("a cough from %s!", mon_nam(mtmp));
  326. 		    } else {
  327. 			if (flags.soundok)
  328. 			    You_hear("%s hissing!", s_suffix(mon_nam(mtmp)));
  329. 			if(!rn2(10) ||
  330. 			    (flags.moonphase == NEW_MOON && !have_lizard())) {
  331. do_stone:
  332. 			    if (!Stoned && !Stone_resistance
  333. 				    && !(poly_when_stoned(youmonst.data) &&
  334. 					polymon(PM_STONE_GOLEM))) {
  335. 				Stoned = 5;
  336. 				delayed_killer = mtmp->data->mname;
  337. 				if (mtmp->data->geno & G_UNIQ) {
  338. 				    if (!type_is_pname(mtmp->data)) {
  339. 					static char kbuf[BUFSZ];
  340.  
  341. 					/* "the" buffer may be reallocated */
  342. 					Strcpy(kbuf, the(delayed_killer));
  343. 					delayed_killer = kbuf;
  344. 				    }
  345. 				    killer_format = KILLED_BY;
  346. 				} else killer_format = KILLED_BY_AN;
  347. 				return(1);
  348. 				/* You("turn to stone..."); */
  349. 				/* done_in_by(mtmp); */
  350. 			    }
  351. 			}
  352. 		    }
  353. 		}
  354. 		break;
  355. 	    case AD_STCK:
  356. 		hitmsg(mtmp, mattk);
  357. 		if (uncancelled && !u.ustuck && !sticks(youmonst.data))
  358. 			u.ustuck = mtmp;
  359. 		break;
  360. 	    case AD_WRAP:
  361. 		if ((!mtmp->mcan || u.ustuck == mtmp) && !sticks(youmonst.data)) {
  362. 		    if (!u.ustuck && !rn2(10)) {
  363. 			if (u_slip_free(mtmp, mattk)) {
  364. 			    dmg = 0;
  365. 			} else {
  366. 			    pline("%s swings itself around you!",
  367. 				  Monnam(mtmp));
  368. 			    u.ustuck = mtmp;
  369. 			}
  370. 		    } else if(u.ustuck == mtmp) {
  371. 			if (is_pool(mtmp->mx,mtmp->my) && !Swimming
  372. 			    && !Amphibious) {
  373. 			    boolean moat =
  374. 				(levl[mtmp->mx][mtmp->my].typ != POOL) &&
  375. 				(levl[mtmp->mx][mtmp->my].typ != WATER) &&
  376. 				!Is_medusa_level(&u.uz) &&
  377. 				!Is_waterlevel(&u.uz);
  378.  
  379. 			    pline("%s drowns you...", Monnam(mtmp));
  380. 			    killer_format = KILLED_BY_AN;
  381. 			    Sprintf(buf, "%s by %s",
  382. 				    moat ? "moat" : "pool of water",
  383. 				    an(mtmp->data->mname));
  384. 			    killer = buf;
  385. 			    done(DROWNING);
  386. 			} else if(mattk->aatyp == AT_HUGS)
  387. 			    You("are being crushed.");
  388. 		    } else {
  389. 			dmg = 0;
  390. 			if(flags.verbose)
  391. 			    pline("%s brushes against your %s.", Monnam(mtmp),
  392. 				   body_part(LEG));
  393. 		    }
  394. 		} else dmg = 0;
  395. 		break;
  396. 	    case AD_WERE:
  397. 		hitmsg(mtmp, mattk);
  398. 		if (uncancelled && !rn2(4) && u.ulycn == NON_PM &&
  399. 			!Protection_from_shape_changers &&
  400. 			!defends(AD_WERE,uwep)) {
  401. 		    You_feel("feverish.");
  402. 		    exercise(A_CON, FALSE);
  403. 		    u.ulycn = monsndx(mdat);
  404. 		}
  405. 		break;
  406. 	    case AD_SGLD:
  407. 		hitmsg(mtmp, mattk);
  408. 		if (youmonst.data->mlet == mdat->mlet) break;
  409. 		if(!mtmp->mcan) stealgold(mtmp);
  410. 		break;
  411.  
  412. 	    case AD_SITM:	/* for now these are the same */
  413. 	    case AD_SEDU:
  414. 		if (is_animal(mtmp->data)) {
  415. 			hitmsg(mtmp, mattk);
  416. 			if (mtmp->mcan) break;
  417. 			/* Continue below */
  418. 		} else if (dmgtype(youmonst.data, AD_SEDU)
  419. #ifdef SEDUCE
  420. 			|| dmgtype(youmonst.data, AD_SSEX)
  421. #endif
  422. 						) {
  423. 			pline("%s %s.", Monnam(mtmp), mtmp->minvent ?
  424. 		    "brags about the goods some dungeon explorer provided" :
  425. 		    "makes some remarks about how difficult theft is lately");
  426. 			if (!tele_restrict(mtmp)) (void) rloc(mtmp, FALSE);
  427. 			return 3;
  428. 		} else if (mtmp->mcan) {
  429. 		    if (!Blind) {
  430. 			pline("%s tries to %s you, but you seem %s.",
  431. 			    Adjmonnam(mtmp, "plain"),
  432. 			    flags.female ? "charm" : "seduce",
  433. 			    flags.female ? "unaffected" : "uninterested");
  434. 		    }
  435. 		    if(rn2(3)) {
  436. 			if (!tele_restrict(mtmp)) (void) rloc(mtmp, FALSE);
  437. 			return 3;
  438. 		    }
  439. 		    break;
  440. 		}
  441. 		buf[0] = '\0';
  442. 		switch (steal(mtmp, buf)) {
  443. 		  case -1:
  444. 			return 2;
  445. 		  case 0:
  446. 			break;
  447. 		  default:
  448. 			if (!is_animal(mtmp->data) && !tele_restrict(mtmp))
  449. 			    (void) rloc(mtmp, FALSE);
  450. 			if (is_animal(mtmp->data) && *buf) {
  451. 			    if (canseemon(mtmp))
  452. 				pline("%s tries to %s away with %s.",
  453. 				      Monnam(mtmp),
  454. 				      locomotion(mtmp->data, "run"),
  455. 				      buf);
  456. 			}
  457. 			monflee(mtmp, 0, FALSE, FALSE);
  458. 			return 3;
  459. 		}
  460. 		break;
  461. #ifdef SEDUCE
  462. 	    case AD_SSEX:
  463. 		if(could_seduce(mtmp, &youmonst, mattk) == 1
  464. 			&& !mtmp->mcan)
  465. 		    if (doseduce(mtmp))
  466. 			return 3;
  467. 		break;
  468. #endif
  469. 	    case AD_SAMU:
  470. 		hitmsg(mtmp, mattk);
  471. 		/* when the Wiz hits, 1/20 steals the amulet */
  472. 		if (u.uhave.amulet ||
  473. 		     u.uhave.bell || u.uhave.book || u.uhave.menorah
  474. 		     || u.uhave.questart) /* carrying the Quest Artifact */
  475. 		    if (!rn2(20)) stealamulet(mtmp);
  476. 		break;
  477.  
  478. 	    case AD_TLPT:
  479. 		hitmsg(mtmp, mattk);
  480. 		if (uncancelled) {
  481. 		    if(flags.verbose)
  482. 			Your("position suddenly seems very uncertain!");
  483. 		    tele();
  484. 		}
  485. 		break;
  486. 	    case AD_RUST:
  487. 		hitmsg(mtmp, mattk);
  488. 		if (mtmp->mcan) break;
  489. 		if (u.umonnum == PM_IRON_GOLEM) {
  490. 			You("rust!");
  491. 			/* KMH -- this is okay with unchanging */
  492. 			rehumanize();
  493. 			break;
  494. 		}
  495. 		hurtarmor(AD_RUST);
  496. 		break;
  497. 	    case AD_CORR:
  498. 		hitmsg(mtmp, mattk);
  499. 		if (mtmp->mcan) break;
  500. 		hurtarmor(AD_CORR);
  501. 		break;
  502. 	    case AD_DCAY:
  503. 		hitmsg(mtmp, mattk);
  504. 		if (mtmp->mcan) break;
  505. 		if (u.umonnum == PM_WOOD_GOLEM ||
  506. 		    u.umonnum == PM_LEATHER_GOLEM) {
  507. 			You("rot!");
  508. 			/* KMH -- this is okay with unchanging */
  509. 			rehumanize();
  510. 			break;
  511. 		}
  512. 		hurtarmor(AD_DCAY);
  513. 		break;
  514. 	    case AD_HEAL:
  515. 		/* a cancelled nurse is just an ordinary monster */
  516. 		if (mtmp->mcan) {
  517. 		    hitmsg(mtmp, mattk);
  518. 		    break;
  519. 		}
  520. 		if(!uwep
  521. #ifdef TOURIST
  522. 		   && !uarmu
  523. #endif
  524. 		   && !uarm && !uarmh && !uarms && !uarmg && !uarmc && !uarmf) {
  525. 		    boolean goaway = FALSE;
  526. 		    pline("%s hits!  (I hope you don't mind.)", Monnam(mtmp));
  527. 		    if (Upolyd) {
  528. 			u.mh += rnd(7);
  529. 			if (!rn2(7)) {
  530. 			    /* no upper limit necessary; effect is temporary */
  531. 			    u.mhmax++;
  532. 			    if (!rn2(13)) goaway = TRUE;
  533. 			}
  534. 			if (u.mh > u.mhmax) u.mh = u.mhmax;
  535. 		    } else {
  536. 			u.uhp += rnd(7);
  537. 			if (!rn2(7)) {
  538. 			    /* hard upper limit via nurse care: 25 * ulevel */
  539. 			    if (u.uhpmax < 5 * u.ulevel + d(2 * u.ulevel, 10))
  540. 				u.uhpmax++;
  541. 			    if (!rn2(13)) goaway = TRUE;
  542. 			}
  543. 			if (u.uhp > u.uhpmax) u.uhp = u.uhpmax;
  544. 		    }
  545. 		    if (!rn2(3)) exercise(A_STR, TRUE);
  546. 		    if (!rn2(3)) exercise(A_CON, TRUE);
  547. 		    if (Sick) make_sick(0L, (char *) 0, FALSE, SICK_ALL);
  548. 		    flags.botl = 1;
  549. 		    if (goaway) {
  550. 			mongone(mtmp);
  551. 			return 2;
  552. 		    } else if (!rn2(33)) {
  553. 			if (!tele_restrict(mtmp)) (void) rloc(mtmp, FALSE);
  554. 			monflee(mtmp, d(3, 6), TRUE, FALSE);
  555. 			return 3;
  556. 		    }
  557. 		    dmg = 0;
  558. 		} else {
  559. 		    if (Role_if(PM_HEALER)) {
  560. 			if (flags.soundok && !(moves % 5))
  561. 		      verbalize("Doc, I can't help you unless you cooperate.");
  562. 			dmg = 0;
  563. 		    } else hitmsg(mtmp, mattk);
  564. 		}
  565. 		break;
  566. 	    case AD_CURS:
  567. 		hitmsg(mtmp, mattk);
  568. 		if(!night() && mdat == &mons[PM_GREMLIN]) break;
  569. 		if(!mtmp->mcan && !rn2(10)) {
  570. 		    if (flags.soundok) {
  571. 			if (Blind) You_hear("laughter.");
  572. 			else       pline("%s chuckles.", Monnam(mtmp));
  573. 		    }
  574. 		    if (u.umonnum == PM_CLAY_GOLEM) {
  575. 			pline("Some writing vanishes from your head!");
  576. 			/* KMH -- this is okay with unchanging */
  577. 			rehumanize();
  578. 			break;
  579. 		    }
  580. 		    attrcurse();
  581. 		}
  582. 		break;
  583. 	    case AD_STUN:
  584. 		hitmsg(mtmp, mattk);
  585. 		if(!mtmp->mcan && !rn2(4)) {
  586. 		    make_stunned(HStun + dmg, TRUE);
  587. 		    dmg /= 2;
  588. 		}
  589. 		break;
  590. 	    case AD_ACID:
  591. 		hitmsg(mtmp, mattk);
  592. 		if (!mtmp->mcan && !rn2(3))
  593. 		    if (Acid_resistance) {
  594. 			pline("You're covered in acid, but it seems harmless.");
  595. 			dmg = 0;
  596. 		    } else {
  597. 			pline("You're covered in acid!	It burns!");
  598. 			exercise(A_STR, FALSE);
  599. 		    }
  600. 		else		dmg = 0;
  601. 		break;
  602. 	    case AD_SLOW:
  603. 		hitmsg(mtmp, mattk);
  604. 		if (uncancelled && HFast &&
  605. 					!defends(AD_SLOW, uwep) && !rn2(4))
  606. 		    u_slow_down();
  607. 		break;
  608. 	    case AD_DREN:
  609. 		hitmsg(mtmp, mattk);
  610. 		if (uncancelled && !rn2(4))
  611. 		    drain_en(dmg);
  612. 		dmg = 0;
  613. 		break;
  614. 	    case AD_CONF:
  615. 		hitmsg(mtmp, mattk);
  616. 		if(!mtmp->mcan && !rn2(4) && !mtmp->mspec_used) {
  617. 		    mtmp->mspec_used = mtmp->mspec_used + (dmg + rn2(6));
  618. 		    if(Confusion)
  619. 			 You("are getting even more confused.");
  620. 		    else You("are getting confused.");
  621. 		    make_confused(HConfusion + dmg, FALSE);
  622. 		}
  623. 		dmg = 0;
  624. 		break;
  625. 	    case AD_DETH:
  626. 		pline("%s reaches out with its deadly touch.", Monnam(mtmp));
  627. 		if (is_undead(youmonst.data)) {
  628. 		    /* Still does normal damage */
  629. 		    pline("Was that the touch of death?");
  630. 		    break;
  631. 		}
  632. 		switch (rn2(20)) {
  633. 		case 19: case 18: case 17:
  634. 		    if (!Antimagic) {
  635. 			killer_format = KILLED_BY_AN;
  636. 			killer = "touch of death";
  637. 			done(DIED);
  638. 			dmg = 0;
  639. 			break;
  640. 		    } /* else FALLTHRU */
  641. 		default: /* case 16: ... case 5: */
  642. 		    You_feel("your life force draining away...");
  643. 		    permdmg = 1;	/* actual damage done below */
  644. 		    break;
  645. 		case 4: case 3: case 2: case 1: case 0:
  646. 		    if (Antimagic) shieldeff(u.ux, u.uy);
  647. 		    pline("Lucky for you, it didn't work!");
  648. 		    dmg = 0;
  649. 		    break;
  650. 		}
  651. 		break;
  652. 	    case AD_PEST:
  653. 		pline("%s reaches out, and you feel fever and chills.",
  654. 			Monnam(mtmp));
  655. 		(void) diseasemu(mdat); /* plus the normal damage */
  656. 		break;
  657. 	    case AD_FAMN:
  658. 		pline("%s reaches out, and your body shrivels.",
  659. 			Monnam(mtmp));
  660. 		exercise(A_CON, FALSE);
  661. 		if (!is_fainted()) morehungry(rn1(40,40));
  662. 		/* plus the normal damage */
  663. 		break;
  664. 	    case AD_SLIM:    
  665. 		hitmsg(mtmp, mattk);
  666. 		if (!uncancelled) break;
  667. 		if (flaming(youmonst.data)) {
  668. 		    pline_The("slime burns away!");
  669. 		    dmg = 0;
  670. 		} else if (Unchanging ||
  671. 				youmonst.data == &mons[PM_GREEN_SLIME]) {
  672. 		    You("are unaffected.");
  673. 		    dmg = 0;
  674. 		} else if (!Slimed) {
  675. 		    You("don't feel very well.");
  676. 		    Slimed = 10L;
  677. 		    flags.botl = 1;
  678. 		    killer_format = KILLED_BY_AN;
  679. 		    delayed_killer = mtmp->data->mname;
  680. 		} else
  681. 		    pline("Yuck!");
  682. 		break;
  683. 	    case AD_ENCH:	/* KMH -- remove enchantment (disenchanter) */
  684. 		hitmsg(mtmp, mattk);
  685. 		/* uncancelled is sufficient enough; please
  686. 		   don't make this attack less frequent */
  687. 		if (uncancelled) {
  688. 		    struct obj *obj = some_armor(&youmonst);
  689.  
  690. 		    if (drain_item(obj)) {
  691. 			Your("%s less effective.", aobjnam(obj, "seem"));
  692. 		    }
  693. 		}
  694. 		break;
  695. 	    default:	dmg = 0;
  696. 			break;
  697. 	}
  698. 	if(u.uhp < 1) done_in_by(mtmp);
  699.  
  700. /*	Negative armor class reduces damage done instead of fully protecting
  701. *	against hits.
  702. */
  703. 	if (dmg && u.uac < 0) {
  704. 		dmg -= rnd(-u.uac);
  705. 		if (dmg < 1) dmg = 1;
  706. 	}
  707.  
  708. 	if(dmg) {
  709. 	    if (Half_physical_damage
  710. 					/* Mitre of Holiness */
  711. 		|| (Role_if(PM_PRIEST) && uarmh && is_quest_artifact(uarmh) &&
  712. 		    (is_undead(mtmp->data) || is_demon(mtmp->data))))
  713. 		dmg = (dmg+1) / 2;
  714.  
  715. 	    if (permdmg) {	/* Death's life force drain */
  716. 		int lowerlimit, *hpmax_p;
  717. 		/*
  718. 		 * Apply some of the damage to permanent hit points:
  719. 		 *	polymorphed	    100% against poly'd hpmax
  720. 		 *	hpmax > 25*lvl	    100% against normal hpmax
  721. 		 *	hpmax > 10*lvl	50..100%
  722. 		 *	hpmax >  5*lvl	25..75%
  723. 		 *	otherwise	 0..50%
  724. 		 * Never reduces hpmax below 1 hit point per level.
  725. 		 */
  726. 		permdmg = rn2(dmg / 2 + 1);
  727. 		if (Upolyd || u.uhpmax > 25 * u.ulevel) permdmg = dmg;
  728. 		else if (u.uhpmax > 10 * u.ulevel) permdmg += dmg / 2;
  729. 		else if (u.uhpmax > 5 * u.ulevel) permdmg += dmg / 4;
  730.  
  731. 		if (Upolyd) {
  732. 		    hpmax_p = &u.mhmax;
  733. 		    /* [can't use youmonst.m_lev] */
  734. 		    lowerlimit = min((int)youmonst.data->mlevel, u.ulevel);
  735. 		} else {
  736. 		    hpmax_p = &u.uhpmax;
  737. 		    lowerlimit = u.ulevel;
  738. 		}
  739. 		if (*hpmax_p - permdmg > lowerlimit)
  740. 		    *hpmax_p -= permdmg;
  741. 		else if (*hpmax_p > lowerlimit)
  742. 		    *hpmax_p = lowerlimit;
  743. 		else	/* unlikely... */
  744. 		    ;	/* already at or below minimum threshold; do nothing */
  745. 		flags.botl = 1;
  746. 	    }
  747.  
  748. 	    mdamageu(mtmp, dmg);
  749. 	}
  750.  
  751. 	if (dmg)
  752. 	    res = passiveum(olduasmon, mtmp, mattk);
  753. 	else
  754. 	    res = 1;
  755. 	stop_occupation();
  756. 	return res;
  757. }
  758.  
  759. #endif /* OVL1 */

gulpmu[edit]

  1. #ifdef OVLB
  2.  
  3. STATIC_OVL int
  4. gulpmu(mtmp, mattk)	/* monster swallows you, or damage if u.uswallow */
  5. 	register struct monst *mtmp;
  6. 	register struct attack  *mattk;
  7. {
  8. 	struct trap *t = t_at(u.ux, u.uy);
  9. 	int	tmp = d((int)mattk->damn, (int)mattk->damd);
  10. 	int	tim_tmp;
  11. 	register struct obj *otmp2;
  12. 	int	i;
  13.  
  14. 	if (!u.uswallow) {	/* swallows you */
  15. 		if (youmonst.data->msize >= MZ_HUGE) return(0);
  16. 		if ((t && ((t->ttyp == PIT) || (t->ttyp == SPIKED_PIT))) &&
  17. 		    sobj_at(BOULDER, u.ux, u.uy))
  18. 			return(0);
  19.  
  20. 		if (Punished) unplacebc();	/* ball&chain go away */
  21. 		remove_monster(mtmp->mx, mtmp->my);
  22. 		mtmp->mtrapped = 0;		/* no longer on old trap */
  23. 		place_monster(mtmp, u.ux, u.uy);
  24. 		u.ustuck = mtmp;
  25. 		newsym(mtmp->mx,mtmp->my);
  26. #ifdef STEED
  27. 		if (is_animal(mtmp->data) && u.usteed) {
  28. 			char buf[BUFSZ];
  29. 			/* Too many quirks presently if hero and steed
  30. 			 * are swallowed. Pretend purple worms don't
  31. 			 * like horses for now :-)
  32. 			 */
  33. 			Strcpy(buf, mon_nam(u.usteed));
  34. 			pline ("%s lunges forward and plucks you off %s!",
  35. 				Monnam(mtmp), buf);
  36. 			dismount_steed(DISMOUNT_ENGULFED);
  37. 		} else
  38. #endif
  39. 		pline("%s engulfs you!", Monnam(mtmp));
  40. 		stop_occupation();
  41. 		reset_occupations();	/* behave as if you had moved */
  42.  
  43. 		if (u.utrap) {
  44. 			You("are released from the %s!",
  45. 				u.utraptype==TT_WEB ? "web" : "trap");
  46. 			u.utrap = 0;
  47. 		}
  48.  
  49. 		i = number_leashed();
  50. 		if (i > 0) {
  51. 		    const char *s = (i > 1) ? "leashes" : "leash";
  52. 		    pline_The("%s %s loose.", s, vtense(s, "snap"));
  53. 		    unleash_all();
  54. 		}
  55.  
  56. 		if (touch_petrifies(youmonst.data) && !resists_ston(mtmp)) {
  57. 			minstapetrify(mtmp, TRUE);
  58. 			if (mtmp->mhp > 0) return 0;
  59. 			else return 2;
  60. 		}
  61.  
  62. 		display_nhwindow(WIN_MESSAGE, FALSE);
  63. 		vision_recalc(2);	/* hero can't see anything */
  64. 		u.uswallow = 1;
  65. 		/* u.uswldtim always set > 1 */
  66. 		tim_tmp = 25 - (int)mtmp->m_lev;
  67. 		if (tim_tmp > 0) tim_tmp = rnd(tim_tmp) / 2;
  68. 		else if (tim_tmp < 0) tim_tmp = -(rnd(-tim_tmp) / 2);
  69. 		tim_tmp += -u.uac + 10;
  70. 		u.uswldtim = (unsigned)((tim_tmp < 2) ? 2 : tim_tmp);
  71. 		swallowed(1);
  72. 		for (otmp2 = invent; otmp2; otmp2 = otmp2->nobj)
  73. 		    (void) snuff_lit(otmp2);
  74. 	}
  75.  
  76. 	if (mtmp != u.ustuck) return(0);
  77. 	if (u.uswldtim > 0) u.uswldtim -= 1;
  78.  
  79. 	switch(mattk->adtyp) {
  80.  
  81. 		case AD_DGST:
  82. 		    if (Slow_digestion) {
  83. 			/* Messages are handled below */
  84. 			u.uswldtim = 0;
  85. 			tmp = 0;
  86. 		    } else if (u.uswldtim == 0) {
  87. 			pline("%s totally digests you!", Monnam(mtmp));
  88. 			tmp = u.uhp;
  89. 			if (Half_physical_damage) tmp *= 2; /* sorry */
  90. 		    } else {
  91. 			pline("%s%s digests you!", Monnam(mtmp),
  92. 			      (u.uswldtim == 2) ? " thoroughly" :
  93. 			      (u.uswldtim == 1) ? " utterly" : "");
  94. 			exercise(A_STR, FALSE);
  95. 		    }
  96. 		    break;
  97. 		case AD_PHYS:
  98. 		    if (mtmp->data == &mons[PM_FOG_CLOUD]) {
  99. 			You("are laden with moisture and %s",
  100. 			    flaming(youmonst.data) ? "are smoldering out!" :
  101. 			    Breathless ? "find it mildly uncomfortable." :
  102. 			    amphibious(youmonst.data) ? "feel comforted." :
  103. 			    "can barely breathe!");
  104. 			/* NB: Amphibious includes Breathless */
  105. 			if (Amphibious && !flaming(youmonst.data)) tmp = 0;
  106. 		    } else {
  107. 			You("are pummeled with debris!");
  108. 			exercise(A_STR, FALSE);
  109. 		    }
  110. 		    break;
  111. 		case AD_ACID:
  112. 		    if (Acid_resistance) {
  113. 			You("are covered with a seemingly harmless goo.");
  114. 			tmp = 0;
  115. 		    } else {
  116. 		      if (Hallucination) pline("Ouch!  You've been slimed!");
  117. 		      else You("are covered in slime!  It burns!");
  118. 		      exercise(A_STR, FALSE);
  119. 		    }
  120. 		    break;
  121. 		case AD_BLND:
  122. 		    if (can_blnd(mtmp, &youmonst, mattk->aatyp, (struct obj*)0)) {
  123. 			if(!Blind) {
  124. 			    You_cant("see in here!");
  125. 			    make_blinded((long)tmp,FALSE);
  126. 			    if (!Blind) Your(vision_clears);
  127. 			} else
  128. 			    /* keep him blind until disgorged */
  129. 			    make_blinded(Blinded+1,FALSE);
  130. 		    }
  131. 		    tmp = 0;
  132. 		    break;
  133. 		case AD_ELEC:
  134. 		    if(!mtmp->mcan && rn2(2)) {
  135. 			pline_The("air around you crackles with electricity.");
  136. 			if (Shock_resistance) {
  137. 				shieldeff(u.ux, u.uy);
  138. 				You("seem unhurt.");
  139. 				ugolemeffects(AD_ELEC,tmp);
  140. 				tmp = 0;
  141. 			}
  142. 		    } else tmp = 0;
  143. 		    break;
  144. 		case AD_COLD:
  145. 		    if(!mtmp->mcan && rn2(2)) {
  146. 			if (Cold_resistance) {
  147. 				shieldeff(u.ux, u.uy);
  148. 				You_feel("mildly chilly.");
  149. 				ugolemeffects(AD_COLD,tmp);
  150. 				tmp = 0;
  151. 			} else You("are freezing to death!");
  152. 		    } else tmp = 0;
  153. 		    break;
  154. 		case AD_FIRE:
  155. 		    if(!mtmp->mcan && rn2(2)) {
  156. 			if (Fire_resistance) {
  157. 				shieldeff(u.ux, u.uy);
  158. 				You_feel("mildly hot.");
  159. 				ugolemeffects(AD_FIRE,tmp);
  160. 				tmp = 0;
  161. 			} else You("are burning to a crisp!");
  162. 			burn_away_slime();
  163. 		    } else tmp = 0;
  164. 		    break;
  165. 		case AD_DISE:
  166. 		    if (!diseasemu(mtmp->data)) tmp = 0;
  167. 		    break;
  168. 		default:
  169. 		    tmp = 0;
  170. 		    break;
  171. 	}
  172.  
  173. 	if (Half_physical_damage) tmp = (tmp+1) / 2;
  174.  
  175. 	mdamageu(mtmp, tmp);
  176. 	if (tmp) stop_occupation();
  177.  
  178. 	if (touch_petrifies(youmonst.data) && !resists_ston(mtmp)) {
  179. 	    pline("%s very hurriedly %s you!", Monnam(mtmp),
  180. 		  is_animal(mtmp->data)? "regurgitates" : "expels");
  181. 	    expels(mtmp, mtmp->data, FALSE);
  182. 	} else if (!u.uswldtim || youmonst.data->msize >= MZ_HUGE) {
  183. 	    You("get %s!", is_animal(mtmp->data)? "regurgitated" : "expelled");
  184. 	    if (flags.verbose && (is_animal(mtmp->data) ||
  185. 		    (dmgtype(mtmp->data, AD_DGST) && Slow_digestion)))
  186. 		pline("Obviously %s doesn't like your taste.", mon_nam(mtmp));
  187. 	    expels(mtmp, mtmp->data, FALSE);
  188. 	}
  189. 	return(1);
  190. }

explmu[edit]

  1. STATIC_OVL int
  2. explmu(mtmp, mattk, ufound)	/* monster explodes in your face */
  3. register struct monst *mtmp;
  4. register struct attack  *mattk;
  5. boolean ufound;
  6. {
  7. if (mtmp->mcan) return(0);
  8.  
  9. if (!ufound)
  10. 	pline("%s explodes at a spot in %s!",
  11. 	    canseemon(mtmp) ? Monnam(mtmp) : "It",
  12. 	    levl[mtmp->mux][mtmp->muy].typ == WATER
  13. 		? "empty water" : "thin air");
  14. else {
  15. 	register int tmp = d((int)mattk->damn, (int)mattk->damd);
  16. 	register boolean not_affected = defends((int)mattk->adtyp, uwep);
  17.  
  18. 	hitmsg(mtmp, mattk);
  19.  
  20. 	switch (mattk->adtyp) {
  21. 	    case AD_COLD:
  22. 		not_affected |= Cold_resistance;
  23. 		goto common;
  24. 	    case AD_FIRE:
  25. 		not_affected |= Fire_resistance;
  26. 		goto common;
  27. 	    case AD_ELEC:
  28. 		not_affected |= Shock_resistance;
  29. common:
  30.  
  31. 		if (!not_affected) {
  32. 		    if (ACURR(A_DEX) > rnd(20)) {
  33. 			You("duck some of the blast.");
  34. 			tmp = (tmp+1) / 2;
  35. 		    } else {
  36. 		        if (flags.verbose) You("get blasted!");
  37. 		    }
  38. 		    if (mattk->adtyp == AD_FIRE) burn_away_slime();
  39. 		    if (Half_physical_damage) tmp = (tmp+1) / 2;
  40. 		    mdamageu(mtmp, tmp);
  41. 		}
  42. 		break;
  43.  
  44. 	    case AD_BLND:
  45. 		not_affected = resists_blnd(&youmonst);
  46. 		if (!not_affected) {
  47. 		    /* sometimes you're affected even if it's invisible */
  48. 		    if (mon_visible(mtmp) || (rnd(tmp /= 2) > u.ulevel)) {
  49. 			You("are blinded by a blast of light!");
  50. 			make_blinded((long)tmp, FALSE);
  51. 			if (!Blind) Your(vision_clears);
  52. 		    } else if (flags.verbose)
  53. 			You("get the impression it was not terribly bright.");
  54. 		}
  55. 		break;
  56.  
  57. 	    case AD_HALU:
  58. 		not_affected |= Blind ||
  59. 			(u.umonnum == PM_BLACK_LIGHT ||
  60. 			 u.umonnum == PM_VIOLET_FUNGUS ||
  61. 			 dmgtype(youmonst.data, AD_STUN));
  62. 		if (!not_affected) {
  63. 		    boolean chg;
  64. 		    if (!Hallucination)
  65. 			You("are caught in a blast of kaleidoscopic light!");
  66. 		    chg = make_hallucinated(HHallucination + (long)tmp,FALSE,0L);
  67. 		    You("%s.", chg ? "are freaked out" : "seem unaffected");
  68. 		}
  69. 		break;
  70.  
  71. 	    default:
  72. 		break;
  73. 	}
  74. 	if (not_affected) {
  75. 	    You("seem unaffected by it.");
  76. 	    ugolemeffects((int)mattk->adtyp, tmp);
  77. 	}
  78. }
  79. mondead(mtmp);
  80. wake_nearto(mtmp->mx, mtmp->my, 7*7);
  81. if (mtmp->mhp > 0) return(0);
  82. return(2);	/* it dies */
  83. }

gazemu[edit]

  1. int
  2. gazemu(mtmp, mattk)	/* monster gazes at you */
  3. 	register struct monst *mtmp;
  4. 	register struct attack  *mattk;
  5. {
  6. 	switch(mattk->adtyp) {
  7. 	    case AD_STON:
  8. 		if (mtmp->mcan || !mtmp->mcansee) {
  9. 		    if (!canseemon(mtmp)) break;	/* silently */
  10. 		    pline("%s %s.", Monnam(mtmp),
  11. 			  (mtmp->data == &mons[PM_MEDUSA] && mtmp->mcan) ?
  12. 				"doesn't look all that ugly" :
  13. 				"gazes ineffectually");
  14. 		    break;
  15. 		}
  16. 		if (Reflecting && couldsee(mtmp->mx, mtmp->my) &&
  17. 			mtmp->data == &mons[PM_MEDUSA]) {
  18. 		    /* hero has line of sight to Medusa and she's not blind */
  19. 		    boolean useeit = canseemon(mtmp);
  20.  
  21. 		    if (useeit)
  22. 			(void) ureflects("%s gaze is reflected by your %s.",
  23. 					 s_suffix(Monnam(mtmp)));
  24. 		    if (mon_reflects(mtmp, !useeit ? (char *)0 :
  25. 				     "The gaze is reflected away by %s %s!"))
  26. 			break;
  27. 		    if (!m_canseeu(mtmp)) { /* probably you're invisible */
  28. 			if (useeit)
  29. 			    pline(
  30. 		      "%s doesn't seem to notice that %s gaze was reflected.",
  31. 				  Monnam(mtmp), mhis(mtmp));
  32. 			break;
  33. 		    }
  34. 		    if (useeit)
  35. 			pline("%s is turned to stone!", Monnam(mtmp));
  36. 		    stoned = TRUE;
  37. 		    killed(mtmp);
  38.  
  39. 		    if (mtmp->mhp > 0) break;
  40. 		    return 2;
  41. 		}
  42. 		if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my) &&
  43. 		    !Stone_resistance) {
  44. 		    You("meet %s gaze.", s_suffix(mon_nam(mtmp)));
  45. 		    stop_occupation();
  46. 		    if(poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM))
  47. 			break;
  48. 		    You("turn to stone...");
  49. 		    killer_format = KILLED_BY;
  50. 		    killer = mtmp->data->mname;
  51. 		    done(STONING);
  52. 		}
  53. 		break;
  54. 	    case AD_CONF:
  55. 		if(!mtmp->mcan && canseemon(mtmp) &&
  56. 		   couldsee(mtmp->mx, mtmp->my) &&
  57. 		   mtmp->mcansee && !mtmp->mspec_used && rn2(5)) {
  58. 		    int conf = d(3,4);
  59.  
  60. 		    mtmp->mspec_used = mtmp->mspec_used + (conf + rn2(6));
  61. 		    if(!Confusion)
  62. 			pline("%s gaze confuses you!",
  63. 			                  s_suffix(Monnam(mtmp)));
  64. 		    else
  65. 			You("are getting more and more confused.");
  66. 		    make_confused(HConfusion + conf, FALSE);
  67. 		    stop_occupation();
  68. 		}
  69. 		break;
  70. 	    case AD_STUN:
  71. 		if(!mtmp->mcan && canseemon(mtmp) &&
  72. 		   couldsee(mtmp->mx, mtmp->my) &&
  73. 		   mtmp->mcansee && !mtmp->mspec_used && rn2(5)) {
  74. 		    int stun = d(2,6);
  75.  
  76. 		    mtmp->mspec_used = mtmp->mspec_used + (stun + rn2(6));
  77. 		    pline("%s stares piercingly at you!", Monnam(mtmp));
  78. 		    make_stunned(HStun + stun, TRUE);
  79. 		    stop_occupation();
  80. 		}
  81. 		break;
  82. 	    case AD_BLND:
  83. 		if (!mtmp->mcan && canseemon(mtmp) && !resists_blnd(&youmonst)
  84. 			&& distu(mtmp->mx,mtmp->my) <= BOLT_LIM*BOLT_LIM) {
  85. 		    int blnd = d((int)mattk->damn, (int)mattk->damd);
  86.  
  87. 		    You("are blinded by %s radiance!",
  88. 			              s_suffix(mon_nam(mtmp)));
  89. 		    make_blinded((long)blnd,FALSE);
  90. 		    stop_occupation();
  91. 		    /* not blind at this point implies you're wearing
  92. 		       the Eyes of the Overworld; make them block this
  93. 		       particular stun attack too */
  94. 		    if (!Blind) Your(vision_clears);
  95. 		    else make_stunned((long)d(1,3),TRUE);
  96. 		}
  97. 		break;
  98. 	    case AD_FIRE:
  99. 		if (!mtmp->mcan && canseemon(mtmp) &&
  100. 			couldsee(mtmp->mx, mtmp->my) &&
  101. 			mtmp->mcansee && !mtmp->mspec_used && rn2(5)) {
  102. 		    int dmg = d(2,6);
  103.  
  104. 		    pline("%s attacks you with a fiery gaze!", Monnam(mtmp));
  105. 		    stop_occupation();
  106. 		    if (Fire_resistance) {
  107. 			pline_The("fire doesn't feel hot!");
  108. 			dmg = 0;
  109. 		    }
  110. 		    burn_away_slime();
  111. 		    if ((int) mtmp->m_lev > rn2(20))
  112. 			destroy_item(SCROLL_CLASS, AD_FIRE);
  113. 		    if ((int) mtmp->m_lev > rn2(20))
  114. 			destroy_item(POTION_CLASS, AD_FIRE);
  115. 		    if ((int) mtmp->m_lev > rn2(25))
  116. 			destroy_item(SPBOOK_CLASS, AD_FIRE);
  117. 		    if (dmg) mdamageu(mtmp, dmg);
  118. 		}
  119. 		break;
  120. #ifdef PM_BEHOLDER /* work in progress */
  121. 	    case AD_SLEE:
  122. 		if(!mtmp->mcan && canseemon(mtmp) &&
  123. 		   couldsee(mtmp->mx, mtmp->my) && mtmp->mcansee &&
  124. 		   multi >= 0 && !rn2(5) && !Sleep_resistance) {
  125.  
  126. 		    fall_asleep(-rnd(10), TRUE);
  127. 		    pline("%s gaze makes you very sleepy...",
  128. 			  s_suffix(Monnam(mtmp)));
  129. 		}
  130. 		break;
  131. 	    case AD_SLOW:
  132. 		if(!mtmp->mcan && canseemon(mtmp) && mtmp->mcansee &&
  133. 		   (HFast & (INTRINSIC|TIMEOUT)) &&
  134. 		   !defends(AD_SLOW, uwep) && !rn2(4))
  135.  
  136. 		    u_slow_down();
  137. 		    stop_occupation();
  138. 		break;
  139. #endif
  140. 	    default: impossible("Gaze attack %d?", mattk->adtyp);
  141. 		break;
  142. 	}
  143. 	return(0);
  144. }
  145.  
  146. #endif /* OVLB */

mdamageu[edit]

  1. #ifdef OVL1
  2.  
  3. void
  4. mdamageu(mtmp, n)	/* mtmp hits you for n points damage */
  5. register struct monst *mtmp;
  6. register int n;
  7. {
  8. 	flags.botl = 1;
  9. 	if (Upolyd) {
  10. 		u.mh -= n;
  11. 		if (u.mh < 1) rehumanize();
  12. 	} else {
  13. 		u.uhp -= n;
  14. 		if(u.uhp < 1) done_in_by(mtmp);
  15. 	}
  16. }
  17.  
  18. #endif /* OVL1 */

urustm[edit]

  1. #ifdef OVLB
  2.  
  3. STATIC_OVL void
  4. urustm(mon, obj)
  5. register struct monst *mon;
  6. register struct obj *obj;
  7. {
  8. 	boolean vis;
  9. 	boolean is_acid;
  10.  
  11. 	if (!mon || !obj) return; /* just in case */
  12. 	if (dmgtype(youmonst.data, AD_CORR))
  13. 	    is_acid = TRUE;
  14. 	else if (dmgtype(youmonst.data, AD_RUST))
  15. 	    is_acid = FALSE;
  16. 	else
  17. 	    return;
  18.  
  19. 	vis = cansee(mon->mx, mon->my);
  20.  
  21. 	if ((is_acid ? is_corrodeable(obj) : is_rustprone(obj)) &&
  22. 	    (is_acid ? obj->oeroded2 : obj->oeroded) < MAX_ERODE) {
  23. 		if (obj->greased || obj->oerodeproof || (obj->blessed && rn2(3))) {
  24. 		    if (vis)
  25. 			pline("Somehow, %s weapon is not affected.",
  26. 						s_suffix(mon_nam(mon)));
  27. 		    if (obj->greased && !rn2(2)) obj->greased = 0;
  28. 		} else {
  29. 		    if (vis)
  30. 			pline("%s %s%s!",
  31. 			        s_suffix(Monnam(mon)),
  32. 				aobjnam(obj, (is_acid ? "corrode" : "rust")),
  33. 			        (is_acid ? obj->oeroded2 : obj->oeroded)
  34. 				    ? " further" : "");
  35. 		    if (is_acid) obj->oeroded2++;
  36. 		    else obj->oeroded++;
  37. 		}
  38. 	}
  39. }
  40.  
  41. #endif /* OVLB */

could_seduce[edit]

  1. #ifdef OVL1
  2.  
  3. int
  4. could_seduce(magr,mdef,mattk)
  5. struct monst *magr, *mdef;
  6. struct attack *mattk;
  7. /* returns 0 if seduction impossible,
  8. *	   1 if fine,
  9. *	   2 if wrong gender for nymph */
  10. {
  11. 	register struct permonst *pagr;
  12. 	boolean agrinvis, defperc;
  13. 	xchar genagr, gendef;
  14.  
  15. 	if (is_animal(magr->data)) return (0);
  16. 	if(magr == &youmonst) {
  17. 		pagr = youmonst.data;
  18. 		agrinvis = (Invis != 0);
  19. 		genagr = poly_gender();
  20. 	} else {
  21. 		pagr = magr->data;
  22. 		agrinvis = magr->minvis;
  23. 		genagr = gender(magr);
  24. 	}
  25. 	if(mdef == &youmonst) {
  26. 		defperc = (See_invisible != 0);
  27. 		gendef = poly_gender();
  28. 	} else {
  29. 		defperc = perceives(mdef->data);
  30. 		gendef = gender(mdef);
  31. 	}
  32.  
  33. 	if(agrinvis && !defperc
  34. #ifdef SEDUCE
  35. 		&& mattk && mattk->adtyp != AD_SSEX
  36. #endif
  37. 		)
  38. 		return 0;
  39.  
  40. 	if(pagr->mlet != S_NYMPH
  41. 		&& ((pagr != &mons[PM_INCUBUS] && pagr != &mons[PM_SUCCUBUS])
  42. #ifdef SEDUCE
  43. 		    || (mattk && mattk->adtyp != AD_SSEX)
  44. #endif
  45. 		   ))
  46. 		return 0;
  47.  
  48. 	if(genagr == 1 - gendef)
  49. 		return 1;
  50. 	else
  51. 		return (pagr->mlet == S_NYMPH) ? 2 : 0;
  52. }
  53.  
  54. #endif /* OVL1 */

doseduce[edit]

  1. #ifdef OVLB
  2.  
  3. #ifdef SEDUCE
  4. /* Returns 1 if monster teleported */
  5. int
  6. doseduce(mon)
  7. register struct monst *mon;
  8. {
  9. 	register struct obj *ring, *nring;
  10. 	boolean fem = (mon->data == &mons[PM_SUCCUBUS]); /* otherwise incubus */
  11. 	char qbuf[QBUFSZ];
  12.  
  13. 	if (mon->mcan || mon->mspec_used) {
  14. 		pline("%s acts as though %s has got a %sheadache.",
  15. 		      Monnam(mon), mhe(mon),
  16. 		      mon->mcan ? "severe " : "");
  17. 		return 0;
  18. 	}
  19.  
  20. 	if (unconscious()) {
  21. 		pline("%s seems dismayed at your lack of response.",
  22. 		      Monnam(mon));
  23. 		return 0;
  24. 	}
  25.  
  26. 	if (Blind) pline("It caresses you...");
  27. 	else You_feel("very attracted to %s.", mon_nam(mon));
  28.  
  29. 	for(ring = invent; ring; ring = nring) {
  30. 	    nring = ring->nobj;
  31. 	    if (ring->otyp != RIN_ADORNMENT) continue;
  32. 	    if (fem) {
  33. 		if (rn2(20) < ACURR(A_CHA)) {
  34. 		    Sprintf(qbuf, "\"That %s looks pretty.  May I have it?\"",
  35. 			safe_qbuf("",sizeof("\"That  looks pretty.  May I have it?\""),
  36. 			xname(ring), simple_typename(ring->otyp), "ring"));
  37. 		    makeknown(RIN_ADORNMENT);
  38. 		    if (yn(qbuf) == 'n') continue;
  39. 		} else pline("%s decides she'd like your %s, and takes it.",
  40. 			Blind ? "She" : Monnam(mon), xname(ring));
  41. 		makeknown(RIN_ADORNMENT);
  42. 		if (ring==uleft || ring==uright) Ring_gone(ring);
  43. 		if (ring==uwep) setuwep((struct obj *)0);
  44. 		if (ring==uswapwep) setuswapwep((struct obj *)0);
  45. 		if (ring==uquiver) setuqwep((struct obj *)0);
  46. 		freeinv(ring);
  47. 		(void) mpickobj(mon,ring);
  48. 	    } else {
  49. 		char buf[BUFSZ];
  50.  
  51. 		if (uleft && uright && uleft->otyp == RIN_ADORNMENT
  52. 				&& uright->otyp==RIN_ADORNMENT)
  53. 			break;
  54. 		if (ring==uleft || ring==uright) continue;
  55. 		if (rn2(20) < ACURR(A_CHA)) {
  56. 		    Sprintf(qbuf,"\"That %s looks pretty.  Would you wear it for me?\"",
  57. 			safe_qbuf("",
  58. 			    sizeof("\"That  looks pretty.  Would you wear it for me?\""),
  59. 			    xname(ring), simple_typename(ring->otyp), "ring"));
  60. 		    makeknown(RIN_ADORNMENT);
  61. 		    if (yn(qbuf) == 'n') continue;
  62. 		} else {
  63. 		    pline("%s decides you'd look prettier wearing your %s,",
  64. 			Blind ? "He" : Monnam(mon), xname(ring));
  65. 		    pline("and puts it on your finger.");
  66. 		}
  67. 		makeknown(RIN_ADORNMENT);
  68. 		if (!uright) {
  69. 		    pline("%s puts %s on your right %s.",
  70. 			Blind ? "He" : Monnam(mon), the(xname(ring)), body_part(HAND));
  71. 		    setworn(ring, RIGHT_RING);
  72. 		} else if (!uleft) {
  73. 		    pline("%s puts %s on your left %s.",
  74. 			Blind ? "He" : Monnam(mon), the(xname(ring)), body_part(HAND));
  75. 		    setworn(ring, LEFT_RING);
  76. 		} else if (uright && uright->otyp != RIN_ADORNMENT) {
  77. 		    Strcpy(buf, xname(uright));
  78. 		    pline("%s replaces your %s with your %s.",
  79. 			Blind ? "He" : Monnam(mon), buf, xname(ring));
  80. 		    Ring_gone(uright);
  81. 		    setworn(ring, RIGHT_RING);
  82. 		} else if (uleft && uleft->otyp != RIN_ADORNMENT) {
  83. 		    Strcpy(buf, xname(uleft));
  84. 		    pline("%s replaces your %s with your %s.",
  85. 			Blind ? "He" : Monnam(mon), buf, xname(ring));
  86. 		    Ring_gone(uleft);
  87. 		    setworn(ring, LEFT_RING);
  88. 		} else impossible("ring replacement");
  89. 		Ring_on(ring);
  90. 		prinv((char *)0, ring, 0L);
  91. 	    }
  92. 	}
  93.  
  94. 	if (!uarmc && !uarmf && !uarmg && !uarms && !uarmh
  95. #ifdef TOURIST
  96. 								&& !uarmu
  97. #endif
  98. 									)
  99. 		pline("%s murmurs sweet nothings into your ear.",
  100. 			Blind ? (fem ? "She" : "He") : Monnam(mon));
  101. 	else
  102. 		pline("%s murmurs in your ear, while helping you undress.",
  103. 			Blind ? (fem ? "She" : "He") : Monnam(mon));
  104. 	mayberem(uarmc, cloak_simple_name(uarmc));
  105. 	if(!uarmc)
  106. 		mayberem(uarm, "suit");
  107. 	mayberem(uarmf, "boots");
  108. 	if(!uwep || !welded(uwep))
  109. 		mayberem(uarmg, "gloves");
  110. 	mayberem(uarms, "shield");
  111. 	mayberem(uarmh, "helmet");
  112. #ifdef TOURIST
  113. 	if(!uarmc && !uarm)
  114. 		mayberem(uarmu, "shirt");
  115. #endif
  116.  
  117. 	if (uarm || uarmc) {
  118. 		verbalize("You're such a %s; I wish...",
  119. 				flags.female ? "sweet lady" : "nice guy");
  120. 		if (!tele_restrict(mon)) (void) rloc(mon, FALSE);
  121. 		return 1;
  122. 	}
  123. 	if (u.ualign.type == A_CHAOTIC)
  124. 		adjalign(1);
  125.  
  126. 	/* by this point you have discovered mon's identity, blind or not... */
  127. 	pline("Time stands still while you and %s lie in each other's arms...",
  128. 		noit_mon_nam(mon));
  129. 	if (rn2(35) > ACURR(A_CHA) + ACURR(A_INT)) {
  130. 		/* Don't bother with mspec_used here... it didn't get tired! */
  131. 		pline("%s seems to have enjoyed it more than you...",
  132. 			noit_Monnam(mon));
  133. 		switch (rn2(5)) {
  134. 			case 0: You_feel("drained of energy.");
  135. 				u.uen = 0;
  136. 				u.uenmax -= rnd(Half_physical_damage ? 5 : 10);
  137. 			        exercise(A_CON, FALSE);
  138. 				if (u.uenmax < 0) u.uenmax = 0;
  139. 				break;
  140. 			case 1: You("are down in the dumps.");
  141. 				(void) adjattrib(A_CON, -1, TRUE);
  142. 			        exercise(A_CON, FALSE);
  143. 				flags.botl = 1;
  144. 				break;
  145. 			case 2: Your("senses are dulled.");
  146. 				(void) adjattrib(A_WIS, -1, TRUE);
  147. 			        exercise(A_WIS, FALSE);
  148. 				flags.botl = 1;
  149. 				break;
  150. 			case 3:
  151. 				if (!resists_drli(&youmonst)) {
  152. 				    You_feel("out of shape.");
  153. 				    losexp("overexertion");
  154. 				} else {
  155. 				    You("have a curious feeling...");
  156. 				}
  157. 				break;
  158. 			case 4: {
  159. 				int tmp;
  160. 				You_feel("exhausted.");
  161. 			        exercise(A_STR, FALSE);
  162. 				tmp = rn1(10, 6);
  163. 				if(Half_physical_damage) tmp = (tmp+1) / 2;
  164. 				losehp(tmp, "exhaustion", KILLED_BY);
  165. 				break;
  166. 			}
  167. 		}
  168. 	} else {
  169. 		mon->mspec_used = rnd(100); /* monster is worn out */
  170. 		You("seem to have enjoyed it more than %s...",
  171. 		    noit_mon_nam(mon));
  172. 		switch (rn2(5)) {
  173. 		case 0: You_feel("raised to your full potential.");
  174. 			exercise(A_CON, TRUE);
  175. 			u.uen = (u.uenmax += rnd(5));
  176. 			break;
  177. 		case 1: You_feel("good enough to do it again.");
  178. 			(void) adjattrib(A_CON, 1, TRUE);
  179. 			exercise(A_CON, TRUE);
  180. 			flags.botl = 1;
  181. 			break;
  182. 		case 2: You("will always remember %s...", noit_mon_nam(mon));
  183. 			(void) adjattrib(A_WIS, 1, TRUE);
  184. 			exercise(A_WIS, TRUE);
  185. 			flags.botl = 1;
  186. 			break;
  187. 		case 3: pline("That was a very educational experience.");
  188. 			pluslvl(FALSE);
  189. 			exercise(A_WIS, TRUE);
  190. 			break;
  191. 		case 4: You_feel("restored to health!");
  192. 			u.uhp = u.uhpmax;
  193. 			if (Upolyd) u.mh = u.mhmax;
  194. 			exercise(A_STR, TRUE);
  195. 			flags.botl = 1;
  196. 			break;
  197. 		}
  198. 	}
  199.  
  200. 	if (mon->mtame) /* don't charge */ ;
  201. 	else if (rn2(20) < ACURR(A_CHA)) {
  202. 		pline("%s demands that you pay %s, but you refuse...",
  203. 			noit_Monnam(mon),
  204. 			Blind ? (fem ? "her" : "him") : mhim(mon));
  205. 	} else if (u.umonnum == PM_LEPRECHAUN)
  206. 		pline("%s tries to take your money, but fails...",
  207. 				noit_Monnam(mon));
  208. 	else {
  209. #ifndef GOLDOBJ
  210. 		long cost;
  211.  
  212. 		if (u.ugold > (long)LARGEST_INT - 10L)
  213. 			cost = (long) rnd(LARGEST_INT) + 500L;
  214. 		else
  215. 			cost = (long) rnd((int)u.ugold + 10) + 500L;
  216. 		if (mon->mpeaceful) {
  217. 			cost /= 5L;
  218. 			if (!cost) cost = 1L;
  219. 		}
  220. 		if (cost > u.ugold) cost = u.ugold;
  221. 		if (!cost) verbalize("It's on the house!");
  222. 		else {
  223. 		    pline("%s takes %ld %s for services rendered!",
  224. 			    noit_Monnam(mon), cost, currency(cost));
  225. 		    u.ugold -= cost;
  226. 		    mon->mgold += cost;
  227. 		    flags.botl = 1;
  228. 		}
  229. #else
  230. 		long cost;
  231. long umoney = money_cnt(invent);
  232.  
  233. 		if (umoney > (long)LARGEST_INT - 10L)
  234. 			cost = (long) rnd(LARGEST_INT) + 500L;
  235. 		else
  236. 			cost = (long) rnd((int)umoney + 10) + 500L;
  237. 		if (mon->mpeaceful) {
  238. 			cost /= 5L;
  239. 			if (!cost) cost = 1L;
  240. 		}
  241. 		if (cost > umoney) cost = umoney;
  242. 		if (!cost) verbalize("It's on the house!");
  243. 		else { 
  244. 		    pline("%s takes %ld %s for services rendered!",
  245. 			    noit_Monnam(mon), cost, currency(cost));
  246. money2mon(mon, cost);
  247. 		    flags.botl = 1;
  248. 		}
  249. #endif
  250. 	}
  251. 	if (!rn2(25)) mon->mcan = 1; /* monster is worn out */
  252. 	if (!tele_restrict(mon)) (void) rloc(mon, FALSE);
  253. 	return 1;
  254. }

mayberem[edit]

  1. STATIC_OVL void
  2. mayberem(obj, str)
  3. register struct obj *obj;
  4. const char *str;
  5. {
  6. 	char qbuf[QBUFSZ];
  7.  
  8. 	if (!obj || !obj->owornmask) return;
  9.  
  10. 	if (rn2(20) < ACURR(A_CHA)) {
  11. 		Sprintf(qbuf,"\"Shall I remove your %s, %s?\"",
  12. 			str,
  13. 			(!rn2(2) ? "lover" : !rn2(2) ? "dear" : "sweetheart"));
  14. 		if (yn(qbuf) == 'n') return;
  15. 	} else {
  16. 		char hairbuf[BUFSZ];
  17.  
  18. 		Sprintf(hairbuf, "let me run my fingers through your %s",
  19. 			body_part(HAIR));
  20. 		verbalize("Take off your %s; %s.", str,
  21. 			(obj == uarm)  ? "let's get a little closer" :
  22. 			(obj == uarmc || obj == uarms) ? "it's in the way" :
  23. 			(obj == uarmf) ? "let me rub your feet" :
  24. 			(obj == uarmg) ? "they're too clumsy" :
  25. #ifdef TOURIST
  26. 			(obj == uarmu) ? "let me massage you" :
  27. #endif
  28. 			/* obj == uarmh */
  29. 			hairbuf);
  30. 	}
  31. 	remove_worn_item(obj, TRUE);
  32. }
  33. #endif  /* SEDUCE */
  34.  
  35. #endif /* OVLB */

passiveum[edit]

  1. #ifdef OVL1
  2.  
  3. STATIC_OVL int
  4. passiveum(olduasmon,mtmp,mattk)
  5. struct permonst *olduasmon;
  6. register struct monst *mtmp;
  7. register struct attack *mattk;
  8. {
  9. 	int i, tmp;
  10.  
  11. 	for (i = 0; ; i++) {
  12. 	    if (i >= NATTK) return 1;
  13. 	    if (olduasmon->mattk[i].aatyp == AT_NONE ||
  14. 	    		olduasmon->mattk[i].aatyp == AT_BOOM) break;
  15. 	}
  16. 	if (olduasmon->mattk[i].damn)
  17. 	    tmp = d((int)olduasmon->mattk[i].damn,
  18. 				    (int)olduasmon->mattk[i].damd);
  19. 	else if(olduasmon->mattk[i].damd)
  20. 	    tmp = d((int)olduasmon->mlevel+1, (int)olduasmon->mattk[i].damd);
  21. 	else
  22. 	    tmp = 0;
  23.  
  24. 	/* These affect the enemy even if you were "killed" (rehumanized) */
  25. 	switch(olduasmon->mattk[i].adtyp) {
  26. 	    case AD_ACID:
  27. 		if (!rn2(2)) {
  28. 		    pline("%s is splashed by your acid!", Monnam(mtmp));
  29. 		    if (resists_acid(mtmp)) {
  30. 			pline("%s is not affected.", Monnam(mtmp));
  31. 			tmp = 0;
  32. 		    }
  33. 		} else tmp = 0;
  34. 		if (!rn2(30)) erode_armor(mtmp, TRUE);
  35. 		if (!rn2(6)) erode_obj(MON_WEP(mtmp), TRUE, TRUE);
  36. 		goto assess_dmg;
  37. 	    case AD_STON: /* cockatrice */
  38. 	    {
  39. 		long protector = attk_protection((int)mattk->aatyp),
  40. 		     wornitems = mtmp->misc_worn_check;
  41.  
  42. 		/* wielded weapon gives same protection as gloves here */
  43. 		if (MON_WEP(mtmp) != 0) wornitems |= W_ARMG;
  44.  
  45. 		if (!resists_ston(mtmp) && (protector == 0L ||
  46. 			(protector != ~0L &&
  47. 			    (wornitems & protector) != protector))) {
  48. 		    if (poly_when_stoned(mtmp->data)) {
  49. 			mon_to_stone(mtmp);
  50. 			return (1);
  51. 		    }
  52. 		    pline("%s turns to stone!", Monnam(mtmp));
  53. 		    stoned = 1;
  54. 		    xkilled(mtmp, 0);
  55. 		    if (mtmp->mhp > 0) return 1;
  56. 		    return 2;
  57. 		}
  58. 		return 1;
  59. 	    }
  60. 	    case AD_ENCH:	/* KMH -- remove enchantment (disenchanter) */
  61. 	    	if (otmp) {
  62. 	    	    (void) drain_item(otmp);
  63. 	    	    /* No message */
  64. 	    	}
  65. 	    	return (1);
  66. 	    default:
  67. 		break;
  68. 	}
  69. 	if (!Upolyd) return 1;
  70.  
  71. 	/* These affect the enemy only if you are still a monster */
  72. 	if (rn2(3)) switch(youmonst.data->mattk[i].adtyp) {
  73. 	    case AD_PHYS:
  74. 	    	if (youmonst.data->mattk[i].aatyp == AT_BOOM) {
  75. 	    	    You("explode!");
  76. 	    	    /* KMH, balance patch -- this is okay with unchanging */
  77. 	    	    rehumanize();
  78. 	    	    goto assess_dmg;
  79. 	    	}
  80. 	    	break;
  81. 	    case AD_PLYS: /* Floating eye */
  82. 		if (tmp > 127) tmp = 127;
  83. 		if (u.umonnum == PM_FLOATING_EYE) {
  84. 		    if (!rn2(4)) tmp = 127;
  85. 		    if (mtmp->mcansee && haseyes(mtmp->data) && rn2(3) &&
  86. 				(perceives(mtmp->data) || !Invis)) {
  87. 			if (Blind)
  88. 			    pline("As a blind %s, you cannot defend yourself.",
  89. 							youmonst.data->mname);
  90. 		        else {
  91. 			    if (mon_reflects(mtmp,
  92. 					    "Your gaze is reflected by %s %s."))
  93. 				return 1;
  94. 			    pline("%s is frozen by your gaze!", Monnam(mtmp));
  95. 			    mtmp->mcanmove = 0;
  96. 			    mtmp->mfrozen = tmp;
  97. 			    return 3;
  98. 			}
  99. 		    }
  100. 		} else { /* gelatinous cube */
  101. 		    pline("%s is frozen by you.", Monnam(mtmp));
  102. 		    mtmp->mcanmove = 0;
  103. 		    mtmp->mfrozen = tmp;
  104. 		    return 3;
  105. 		}
  106. 		return 1;
  107. 	    case AD_COLD: /* Brown mold or blue jelly */
  108. 		if (resists_cold(mtmp)) {
  109. 		    shieldeff(mtmp->mx, mtmp->my);
  110. 		    pline("%s is mildly chilly.", Monnam(mtmp));
  111. 		    golemeffects(mtmp, AD_COLD, tmp);
  112. 		    tmp = 0;
  113. 		    break;
  114. 		}
  115. 		pline("%s is suddenly very cold!", Monnam(mtmp));
  116. 		u.mh += tmp / 2;
  117. 		if (u.mhmax < u.mh) u.mhmax = u.mh;
  118. 		if (u.mhmax > ((youmonst.data->mlevel+1) * 8))
  119. 		    (void)split_mon(&youmonst, mtmp);
  120. 		break;
  121. 	    case AD_STUN: /* Yellow mold */
  122. 		if (!mtmp->mstun) {
  123. 		    mtmp->mstun = 1;
  124. 		    pline("%s %s.", Monnam(mtmp),
  125. 			  makeplural(stagger(mtmp->data, "stagger")));
  126. 		}
  127. 		tmp = 0;
  128. 		break;
  129. 	    case AD_FIRE: /* Red mold */
  130. 		if (resists_fire(mtmp)) {
  131. 		    shieldeff(mtmp->mx, mtmp->my);
  132. 		    pline("%s is mildly warm.", Monnam(mtmp));
  133. 		    golemeffects(mtmp, AD_FIRE, tmp);
  134. 		    tmp = 0;
  135. 		    break;
  136. 		}
  137. 		pline("%s is suddenly very hot!", Monnam(mtmp));
  138. 		break;
  139. 	    case AD_ELEC:
  140. 		if (resists_elec(mtmp)) {
  141. 		    shieldeff(mtmp->mx, mtmp->my);
  142. 		    pline("%s is slightly tingled.", Monnam(mtmp));
  143. 		    golemeffects(mtmp, AD_ELEC, tmp);
  144. 		    tmp = 0;
  145. 		    break;
  146. 		}
  147. 		pline("%s is jolted with your electricity!", Monnam(mtmp));
  148. 		break;
  149. 	    default: tmp = 0;
  150. 		break;
  151. 	}
  152. 	else tmp = 0;
  153.  
  154. assess_dmg:
  155. 	if((mtmp->mhp -= tmp) <= 0) {
  156. 		pline("%s dies!", Monnam(mtmp));
  157. 		xkilled(mtmp,0);
  158. 		if (mtmp->mhp > 0) return 1;
  159. 		return 2;
  160. 	}
  161. 	return 1;
  162. }
  163.  
  164. #endif /* OVL1 */

cloneu[edit]

  1. #ifdef OVLB
  2.  
  3. #include "edog.h"
  4. struct monst *
  5. cloneu()
  6. {
  7. 	register struct monst *mon;
  8. 	int mndx = monsndx(youmonst.data);
  9.  
  10. 	if (u.mh <= 1) return(struct monst *)0;
  11. 	if (mvitals[mndx].mvflags & G_EXTINCT) return(struct monst *)0;
  12. 	mon = makemon(youmonst.data, u.ux, u.uy, NO_MINVENT|MM_EDOG);
  13. 	mon = christen_monst(mon, plname);
  14. 	initedog(mon);
  15. 	mon->m_lev = youmonst.data->mlevel;
  16. 	mon->mhpmax = u.mhmax;
  17. 	mon->mhp = u.mh / 2;
  18. 	u.mh -= mon->mhp;
  19. 	flags.botl = 1;
  20. 	return(mon);
  21. }
  22.  
  23. #endif /* OVLB */
  24.  
  25. /*mhitu.c*/