Wikia

Wikihack

Source:NetHack 3.3.0/mhitu.c

2,032pages on
this wiki
Talk0

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

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

The NetHack General Public License applies to screenshots, source code and other content from NetHack.
1.    /*	SCCS Id: @(#)mhitu.c	3.3	1999/10/20	*/
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    /* NetHack may be freely redistributed.  See license for details. */
4.    
5.    #include "hack.h"
6.    #include "artifact.h"
7.    
8.    STATIC_VAR NEARDATA struct obj *otmp;
9.    
10.   STATIC_DCL void FDECL(urustm, (struct monst *, struct obj *));
11.   # ifdef OVL1
12.   STATIC_DCL boolean FDECL(u_slip_free, (struct monst *,struct attack *));
13.   STATIC_DCL int FDECL(passiveum, (struct permonst *,struct monst *,struct attack *));
14.   # endif /* OVL1 */
15.   
16.   #ifdef OVLB
17.   # ifdef SEDUCE
18.   STATIC_DCL void FDECL(mayberem, (struct obj *, const char *));
19.   # endif
20.   #endif /* OVLB */
21.   
22.   STATIC_DCL boolean FDECL(diseasemu, (struct permonst *));
23.   STATIC_DCL int FDECL(hitmu, (struct monst *,struct attack *));
24.   STATIC_DCL int FDECL(gulpmu, (struct monst *,struct attack *));
25.   STATIC_DCL int FDECL(explmu, (struct monst *,struct attack *,BOOLEAN_P));
26.   STATIC_DCL void FDECL(missmu,(struct monst *,BOOLEAN_P,struct attack *));
27.   STATIC_DCL void FDECL(mswings,(struct monst *,struct obj *));
28.   STATIC_DCL void FDECL(wildmiss, (struct monst *,struct attack *));
29.   
30.   STATIC_DCL void FDECL(hurtarmor,(struct permonst *,int));
31.   STATIC_DCL void FDECL(hitmsg,(struct monst *,struct attack *));
32.   
33.   /* See comment in mhitm.c.  If we use this a lot it probably should be */
34.   /* changed to a parameter to mhitu. */
35.   static int dieroll;
36.   
37.   #ifdef OVL1
38.   
39.   
40.   STATIC_OVL void
41.   hitmsg(mtmp, mattk)
42.   register struct monst *mtmp;
43.   register struct attack *mattk;
44.   {
45.   	int compat;
46.   
47.   	/* Note: if opposite gender, "seductively" */
48.   	/* If same gender, "engagingly" for nymph, normal msg for others */
49.   	if((compat = could_seduce(mtmp, &youmonst, mattk))
50.   			&& !mtmp->mcan && !mtmp->mspec_used) {
51.   		pline("%s %s you %s.", Monnam(mtmp),
52.   			Blind ? "talks to" : "smiles at",
53.   			compat == 2 ? "engagingly" : "seductively");
54.   	} else
55.   	    switch (mattk->aatyp) {
56.   		case AT_BITE:
57.   			pline("%s bites!", Monnam(mtmp));
58.   			break;
59.   		case AT_KICK:
60.   			pline("%s kicks%c", Monnam(mtmp),
61.   				    thick_skinned(youmonst.data) ? '.' : '!');
62.   			break;
63.   		case AT_STNG:
64.   			pline("%s stings!", Monnam(mtmp));
65.   			break;
66.   		case AT_BUTT:
67.   			pline("%s butts!", Monnam(mtmp));
68.   			break;
69.   		case AT_TUCH:
70.   			pline("%s touches you!", Monnam(mtmp));
71.   			break;
72.   		case AT_TENT:
73.   			pline("%s tentacles suck you!",
74.   				        s_suffix(Monnam(mtmp)));
75.   			break;
76.   		case AT_EXPL:
77.   		case AT_BOOM:
78.   			pline("%s explodes!", Monnam(mtmp));
79.   			break;
80.   		default:
81.   			pline("%s hits!", Monnam(mtmp));
82.   	    }
83.   }
84.   
85.   STATIC_OVL void
86.   missmu(mtmp, nearmiss, mattk)		/* monster missed you */
87.   register struct monst *mtmp;
88.   register boolean nearmiss;
89.   register struct attack *mattk;
90.   {
91.   	if (!canspotmon(mtmp))
92.   	    map_invisible(mtmp->mx, mtmp->my);
93.   
94.   	if(could_seduce(mtmp, &youmonst, mattk) && !mtmp->mcan)
95.   	    pline("%s pretends to be friendly.", Monnam(mtmp));
96.   	else {
97.   	    if (!flags.verbose || !nearmiss)
98.   		pline("%s misses.", Monnam(mtmp));
99.   	    else
100.  		pline("%s just misses!", Monnam(mtmp));
101.  	}
102.  }
103.  
104.  STATIC_OVL void
105.  mswings(mtmp, otemp)		/* monster swings obj */
106.  register struct monst *mtmp;
107.  register struct obj *otemp;
108.  {
109.  	if (!flags.verbose || Blind || !mon_visible(mtmp))
110.  		return;
111.  	pline("%s %s %s %s.", Monnam(mtmp),
112.  	      (objects[otemp->otyp].oc_dir & PIERCE) ? "thrusts" : "swings",
113.  	      his[pronoun_gender(mtmp)], xname(otemp));
114.  }
115.  
116.  /* return how a poison attack was delivered */
117.  const char *
118.  mpoisons_subj(mtmp, mattk)
119.  struct monst *mtmp;
120.  struct attack *mattk;
121.  {
122.  	if (mattk->aatyp == AT_WEAP) {
123.  	    struct obj *mwep = (mtmp == &youmonst) ? uwep : MON_WEP(mtmp);
124.  	    /* "Foo's attack was poisoned." is pretty lame, but at least
125.  	       it's better than "sting" when not a stinging attack... */
126.  	    return (!mwep || !mwep->opoisoned) ? "attack" : "weapon";
127.  	} else {
128.  	    return (mattk->aatyp == AT_TUCH) ? "contact" :
129.  		   (mattk->aatyp == AT_GAZE) ? "gaze" :
130.  		   (mattk->aatyp == AT_BITE) ? "bite" : "sting";
131.  	}
132.  }
133.  
134.  /* called when your intrinsic speed is taken away */
135.  void
136.  u_slow_down()
137.  {
138.  	HFast = 0L;
139.  	if (!Fast)
140.  	    You("slow down.");
141.  	else	/* speed boots */
142.  	    Your("quickness feels less natural.");
143.  	exercise(A_DEX, FALSE);
144.  }
145.  
146.  #endif /* OVL1 */
147.  #ifdef OVLB
148.  
149.  STATIC_OVL void
150.  wildmiss(mtmp, mattk)		/* monster attacked your displaced image */
151.  	register struct monst *mtmp;
152.  	register struct attack *mattk;
153.  {
154.  	int compat;
155.  
156.  	/* no map_invisible() -- no way to tell where _this_ is coming from */
157.  
158.  	if (!flags.verbose) return;
159.  	if (!cansee(mtmp->mx, mtmp->my)) return;
160.  		/* maybe it's attacking an image around the corner? */
161.  
162.  	compat = (mattk->adtyp == AD_SEDU || mattk->adtyp == AD_SSEX) &&
163.  		 could_seduce(mtmp, &youmonst, (struct attack *)0);
164.  
165.  	if (!mtmp->mcansee || (Invis && !perceives(mtmp->data))) {
166.  	    const char *swings =
167.  		mattk->aatyp == AT_BITE ? "snaps" :
168.  		mattk->aatyp == AT_KICK ? "kicks" :
169.  		(mattk->aatyp == AT_STNG ||
170.  		 mattk->aatyp == AT_BUTT ||
171.  		 nolimbs(mtmp->data)) ? "lunges" : "swings";
172.  
173.  	    if (compat)
174.  		pline("%s tries to touch you and misses!", Monnam(mtmp));
175.  	    else
176.  		switch(rn2(3)) {
177.  		case 0: pline("%s %s wildly and misses!", Monnam(mtmp),
178.  			      swings);
179.  		    break;
180.  		case 1: pline("%s attacks a spot beside you.", Monnam(mtmp));
181.  		    break;
182.  		case 2: pline("%s strikes at %s!", Monnam(mtmp),
183.  				levl[mtmp->mux][mtmp->muy].typ == WATER
184.  				    ? "empty water" : "thin air");
185.  		    break;
186.  		default:pline("%s %s wildly!", Monnam(mtmp), swings);
187.  		    break;
188.  		}
189.  
190.  	} else if (Displaced) {
191.  	    if (compat)
192.  		pline("%s smiles %s at your %sdisplaced image...",
193.  			Monnam(mtmp),
194.  			compat == 2 ? "engagingly" : "seductively",
195.  			Invis ? "invisible " : "");
196.  	    else
197.  		pline("%s strikes at your %sdisplaced image and misses you!",
198.  			/* Note: if you're both invisible and displaced,
199.  			 * only monsters which see invisible will attack your
200.  			 * displaced image, since the displaced image is also
201.  			 * invisible.
202.  			 */
203.  			Monnam(mtmp),
204.  			Invis ? "invisible " : "");
205.  
206.  	} else if (Underwater) {
207.  	    /* monsters may miss especially on water level where
208.  	       bubbles shake the player here and there */
209.  	    if (compat)
210.  		pline("%s reaches towards your distorted image.",Monnam(mtmp));
211.  	    else
212.  		pline("%s is fooled by water reflections and misses!",Monnam(mtmp));
213.  
214.  	} else impossible("%s attacks you without knowing your location?",
215.  		Monnam(mtmp));
216.  }
217.  
218.  void
219.  expels(mtmp, mdat, message)
220.  register struct monst *mtmp;
221.  register struct permonst *mdat; /* if mtmp is polymorphed, mdat != mtmp->data */
222.  boolean message;
223.  {
224.  	if (message) {
225.  		if (is_animal(mdat))
226.  			You("get regurgitated!");
227.  		else {
228.  			char blast[40];
229.  			register int i;
230.  
231.  			blast[0] = '\0';
232.  			for(i = 0; i < NATTK; i++)
233.  				if(mdat->mattk[i].aatyp == AT_ENGL)
234.  					break;
235.  			if (mdat->mattk[i].aatyp != AT_ENGL)
236.  			      impossible("Swallower has no engulfing attack?");
237.  			else {
238.  				if (is_whirly(mdat)) {
239.  					switch (mdat->mattk[i].adtyp) {
240.  						case AD_ELEC:
241.  							Strcpy(blast,
242.  						      " in a shower of sparks");
243.  							break;
244.  						case AD_COLD:
245.  							Strcpy(blast,
246.  							" in a blast of frost");
247.  							break;
248.  					}
249.  				} else
250.  					Strcpy(blast, " with a squelch");
251.  				You("get expelled from %s%s!",
252.  				    mon_nam(mtmp), blast);
253.  			}
254.  		}
255.  	}
256.  	unstuck(mtmp);	/* ball&chain returned in unstuck() */
257.  	mnexto(mtmp);
258.  	newsym(u.ux,u.uy);
259.  	spoteffects();
260.  	/* to cover for a case where mtmp is not in a next square */
261.  	if(um_dist(mtmp->mx,mtmp->my,1))
262.  		pline("Brrooaa...  You land hard at some distance.");
263.  }
264.  
265.  #endif /* OVLB */
266.  #ifdef OVL0
267.  
268.  /*
269.   * mattacku: monster attacks you
270.   *	returns 1 if monster dies (e.g. "yellow light"), 0 otherwise
271.   *	Note: if you're displaced or invisible the monster might attack the
272.   *		wrong position...
273.   *	Assumption: it's attacking you or an empty square; if there's another
274.   *		monster which it attacks by mistake, the caller had better
275.   *		take care of it...
276.   */
277.  int
278.  mattacku(mtmp)
279.  	register struct monst *mtmp;
280.  {
281.  	struct	attack	*mattk;
282.  	int	i, j, tmp, sum[NATTK];
283.  	struct	permonst *mdat = mtmp->data;
284.  	boolean ranged = (distu(mtmp->mx, mtmp->my) > 3);
285.  		/* Is it near you?  Affects your actions */
286.  	boolean range2 = !monnear(mtmp, mtmp->mux, mtmp->muy);
287.  		/* Does it think it's near you?  Affects its actions */
288.  	boolean foundyou = (mtmp->mux==u.ux && mtmp->muy==u.uy);
289.  		/* Is it attacking you or your image? */
290.  	boolean youseeit = canseemon(mtmp);
291.  		/* Might be attacking your image around the corner, or
292.  		 * invisible, or you might be blind....
293.  		 */
294.  
295.  	if(!ranged) nomul(0);
296.  	if(mtmp->mhp <= 0 || (Underwater && !is_swimmer(mtmp->data)))
297.  	    return(0);
298.  
299.  	/* If swallowed, can only be affected by u.ustuck */
300.  	if(u.uswallow) {
301.  	    if(mtmp != u.ustuck)
302.  		return(0);
303.  	    u.ustuck->mux = u.ux;
304.  	    u.ustuck->muy = u.uy;
305.  	    range2 = 0;
306.  	    foundyou = 1;
307.  	    if(u.uinvulnerable) return (0); /* stomachs can't hurt you! */
308.  	}
309.  
310.  #ifdef STEED
311.  	else if (u.usteed) {
312.  		if (mtmp == u.usteed)
313.  			/* Your steed won't attack you */
314.  			return (0);
315.  		/* Orcs like to steal and eat horses and the like */
316.  		if (!rn2(is_orc(mtmp->data) ? 2 : 4) &&
317.  				distu(mtmp->mx, mtmp->my) <= 2) {
318.  			/* Attack your steed instead */
319.  			i = mattackm(mtmp, u.usteed);
320.  			if ((i & MM_AGR_DIED))
321.  				return (1);
322.  			if (i & MM_DEF_DIED)
323.  				return (0);
324.  			/* Let your steed retaliate */
325.  			return (!!(mattackm(u.usteed, mtmp) & MM_DEF_DIED));
326.  		}
327.  	}
328.  #endif
329.  
330.  	if (u.uundetected && !range2 && foundyou && !u.uswallow) {
331.  		u.uundetected = 0;
332.  		if (is_hider(youmonst.data)) {
333.  		    coord cc; /* maybe we need a unexto() function? */
334.  
335.  		    You("fall from the %s!", ceiling(u.ux,u.uy));
336.  		    if (enexto(&cc, u.ux, u.uy, youmonst.data)) {
337.  			remove_monster(mtmp->mx, mtmp->my);
338.  			newsym(mtmp->mx,mtmp->my);
339.  			place_monster(mtmp, u.ux, u.uy);
340.  			if(mtmp->wormno) worm_move(mtmp);
341.  			teleds(cc.x, cc.y);
342.  			set_apparxy(mtmp);
343.  			newsym(u.ux,u.uy);
344.  		    } else {
345.  			pline("%s is killed by a falling %s (you)!",
346.  						Monnam(mtmp), youmonst.data->mname);
347.  			killed(mtmp);
348.  			newsym(u.ux,u.uy);
349.  			if (mtmp->mhp > 0) return 0;
350.  			else return 1;
351.  		    }
352.  		    if (youmonst.data->mlet != S_PIERCER)
353.  			return(0);	/* trappers don't attack */
354.  
355.  		    if (which_armor(mtmp, WORN_HELMET)) {
356.  			Your("blow glances off %s helmet.",
357.  			               s_suffix(mon_nam(mtmp)));
358.  		    } else {
359.  			if (3 + find_mac(mtmp) <= rnd(20)) {
360.  			    pline("%s is hit by a falling piercer (you)!",
361.  								Monnam(mtmp));
362.  			    if ((mtmp->mhp -= d(3,6)) < 1)
363.  				killed(mtmp);
364.  			} else
365.  			  pline("%s is almost hit by a falling piercer (you)!",
366.  								Monnam(mtmp));
367.  		    }
368.  		} else {
369.  		    if (!youseeit)
370.  			pline("It tries to move where you are hiding.");
371.  		    else {
372.  			/* Ugly kludge for eggs.  The message is phrased so as
373.  			 * to be directed at the monster, not the player,
374.  			 * which makes "laid by you" wrong.  For the
375.  			 * parallelism to work, we can't rephrase it, so we
376.  			 * zap the "laid by you" momentarily instead.
377.  			 */
378.  			struct obj *obj = level.objects[u.ux][u.uy];
379.  
380.  			if (obj ||
381.  			      (youmonst.data->mlet == S_EEL && is_pool(u.ux, u.uy))) {
382.  			    int save_spe = 0; /* suppress warning */
383.  			    if (obj) {
384.  				save_spe = obj->spe;
385.  				if (obj->otyp == EGG) obj->spe = 0;
386.  			    }
387.  			    if (youmonst.data->mlet == S_EEL)
388.  		pline("Wait, %s!  There's a hidden %s named %s there!",
389.  				m_monnam(mtmp), youmonst.data->mname, plname);
390.  			    else
391.  	     pline("Wait, %s!  There's a %s named %s hiding under %s!",
392.  				m_monnam(mtmp), youmonst.data->mname, plname,
393.  				doname(level.objects[u.ux][u.uy]));
394.  			    if (obj) obj->spe = save_spe;
395.  			} else
396.  			    impossible("hiding under nothing?");
397.  		    }
398.  		    newsym(u.ux,u.uy);
399.  		}
400.  		return(0);
401.  	}
402.  	if (youmonst.data->mlet == S_MIMIC && youmonst.m_ap_type && !range2 && foundyou && !u.uswallow) {
403.  		if (!youseeit) pline("It gets stuck on you.");
404.  		else pline("Wait, %s!  That's a %s named %s!",
405.  			   m_monnam(mtmp), youmonst.data->mname, plname);
406.  		u.ustuck = mtmp;
407.  		youmonst.m_ap_type = M_AP_NOTHING;
408.  		youmonst.mappearance = 0;
409.  		newsym(u.ux,u.uy);
410.  		return(0);
411.  	}
412.  
413.  	/* player might be mimicking gold */
414.  	if (youmonst.m_ap_type == M_AP_OBJECT
415.  		&& youmonst.mappearance == GOLD_PIECE
416.  		&& !range2 && foundyou && !u.uswallow) {
417.  	    if (!youseeit)
418.  		 pline("%s %s!", Something, likes_gold(mtmp->data) ?
419.  			"tries to pick you up" : "disturbs you");
420.  	    else pline("Wait, %s!  That gold is really %s named %s!",
421.  			m_monnam(mtmp),
422.  			an(mons[u.umonnum].mname),
423.  			plname);
424.  	    if (multi < 0) {	/* this should always be the case */
425.  		char buf[BUFSIZ];
426.  		Sprintf(buf, "You appear to be %s again.",
427.  			Upolyd ? (const char *) an(youmonst.data->mname) :
428.  			    (const char *) "yourself");
429.  		unmul(buf);	/* immediately stop mimicking gold */
430.  	    }
431.  	    return 0;
432.  	}
433.  
434.  /*	Work out the armor class differential	*/
435.  	tmp = AC_VALUE(u.uac) + 10;		/* tmp ~= 0 - 20 */
436.  	tmp += mtmp->m_lev;
437.  	if(multi < 0) tmp += 4;
438.  	if((Invis && !perceives(mdat)) || !mtmp->mcansee)
439.  		tmp -= 2;
440.  	if(mtmp->mtrapped) tmp -= 2;
441.  	if(tmp <= 0) tmp = 1;
442.  
443.  	/* make eels visible the moment they hit/miss us */
444.  	if(mdat->mlet == S_EEL && mtmp->minvis && cansee(mtmp->mx,mtmp->my)) {
445.  		mtmp->minvis = 0;
446.  		newsym(mtmp->mx,mtmp->my);
447.  	}
448.  
449.  /*	Special demon handling code */
450.  	if(!mtmp->cham && is_demon(mdat) && !range2
451.  	   && mtmp->data != &mons[PM_BALROG]
452.  	   && mtmp->data != &mons[PM_SUCCUBUS]
453.  	   && mtmp->data != &mons[PM_INCUBUS])
454.  	    if(!mtmp->mcan && !rn2(13))	msummon(mdat);
455.  
456.  /*	Special lycanthrope handling code */
457.  	if(!mtmp->cham && is_were(mdat) && !range2) {
458.  
459.  	    if(is_human(mdat)) {
460.  		if(!rn2(5 - (night() * 2)) && !mtmp->mcan) new_were(mtmp);
461.  	    } else if(!rn2(30) && !mtmp->mcan) new_were(mtmp);
462.  	    mdat = mtmp->data;
463.  
464.  	    if(!rn2(10) && !mtmp->mcan) {
465.  		if(youseeit) {
466.  			pline("%s summons help!", Monnam(mtmp));
467.  		} else
468.  			You_feel("hemmed in.");
469.  		/* Technically wrong; we really should check if you can see the
470.  		 * help, but close enough...
471.  		 */
472.  		if (!were_summon(mdat,FALSE) && youseeit)
473.  		    pline("But none comes.");
474.  	    }
475.  	}
476.  
477.  	if(u.uinvulnerable) {
478.  	    /* monster's won't attack you */
479.  	    if(mtmp == u.ustuck)
480.  		pline("%s loosens its grip slightly.", Monnam(mtmp));
481.  	    else if(!range2) {
482.  		if(youseeit)
483.  		    pline("%s starts to attack you, but pulls back.",
484.  			  Monnam(mtmp));
485.  		else
486.  		    You_feel("%s move nearby.", something);
487.  	    }
488.  	    return (0);
489.  	}
490.  
491.  	/* Unlike defensive stuff, don't let them use item _and_ attack. */
492.  	if(find_offensive(mtmp)) {
493.  		int foo = use_offensive(mtmp);
494.  
495.  		if (foo != 0) return(foo==1);
496.  	}
497.  
498.  	for(i = 0; i < NATTK; i++) {
499.  
500.  	    sum[i] = 0;
501.  	    mattk = &(mdat->mattk[i]);
502.  	    if (u.uswallow && (mattk->aatyp != AT_ENGL))
503.  		continue;
504.  	    switch(mattk->aatyp) {
505.  		case AT_CLAW:	/* "hand to hand" attacks */
506.  		case AT_KICK:
507.  		case AT_BITE:
508.  		case AT_STNG:
509.  		case AT_TUCH:
510.  		case AT_BUTT:
511.  		case AT_TENT:
512.  			if(!range2 && (!MON_WEP(mtmp) || mtmp->mconf || Conflict ||
513.  					!touch_petrifies(youmonst.data))) {
514.  			    if (foundyou) {
515.  				if(tmp > (j = rnd(20+i))) {
516.  				    if (mattk->aatyp != AT_KICK ||
517.  					    !thick_skinned(youmonst.data))
518.  					sum[i] = hitmu(mtmp, mattk);
519.  				} else
520.  				    missmu(mtmp, (tmp == j), mattk);
521.  			    } else
522.  				wildmiss(mtmp, mattk);
523.  			}
524.  			break;
525.  
526.  		case AT_HUGS:	/* automatic if prev two attacks succeed */
527.  			/* Note: if displaced, prev attacks never succeeded */
528.  			if((!range2 && i>=2 && sum[i-1] && sum[i-2])
529.  							|| mtmp == u.ustuck)
530.  				sum[i]= hitmu(mtmp, mattk);
531.  			break;
532.  
533.  		case AT_GAZE:	/* can affect you either ranged or not */
534.  			/* Medusa gaze already operated through m_respond in
535.  			 * dochug(); don't gaze more than once per round.
536.  			 */
537.  			if (mdat != &mons[PM_MEDUSA])
538.  				sum[i] = gazemu(mtmp, mattk);
539.  			break;
540.  
541.  		case AT_EXPL:	/* automatic hit if next to, and aimed at you */
542.  			if(!range2) sum[i] = explmu(mtmp, mattk, foundyou);
543.  			break;
544.  
545.  		case AT_ENGL:
546.  			if (!range2) {
547.  			    if(foundyou) {
548.  				if(u.uswallow || tmp > (j = rnd(20+i))) {
549.  				    /* Force swallowing monster to be
550.  				     * displayed even when player is
551.  				     * moving away */
552.  				    flush_screen(1);
553.  				    sum[i] = gulpmu(mtmp, mattk);
554.  				} else {
555.  				    missmu(mtmp, (tmp == j), mattk);
556.  				}
557.  			   } else if (is_animal(mtmp->data))
558.  					pline("%s gulps some air!", youseeit ?
559.  					      Monnam(mtmp) : "It");
560.  				  else
561.  					if (youseeit)
562.  					 pline("%s lunges forward and recoils!",
563.  					       Monnam(mtmp));
564.  					else
565.  						You_hear("a %s nearby.",
566.  						    is_whirly(mtmp->data)?
567.  						    "rushing noise" :
568.  						    "splat");
569.  			}
570.  			break;
571.  		case AT_BREA:
572.  			if(range2) sum[i] = breamu(mtmp, mattk);
573.  			/* Note: breamu takes care of displacement */
574.  			break;
575.  		case AT_SPIT:
576.  			if(range2) sum[i] = spitmu(mtmp, mattk);
577.  			/* Note: spitmu takes care of displacement */
578.  			break;
579.  		case AT_WEAP:
580.  			if(range2) {
581.  #ifdef REINCARNATION
582.  				if (!Is_rogue_level(&u.uz))
583.  #endif
584.  					thrwmu(mtmp);
585.  			} else {
586.  			    int hittmp = 0;
587.  
588.  			    /* Rare but not impossible.  Normally the monster
589.  			     * wields when 2 spaces away, but it can be
590.  			     * teleported or whatever....
591.  			     */
592.  			    if (mtmp->weapon_check == NEED_WEAPON ||
593.  							!MON_WEP(mtmp)) {
594.  				mtmp->weapon_check = NEED_HTH_WEAPON;
595.  				/* mon_wield_item resets weapon_check as
596.  				 * appropriate */
597.  				if (mon_wield_item(mtmp) != 0) break;
598.  			    }
599.  			    if (foundyou) {
600.  				possibly_unwield(mtmp);
601.  				otmp = MON_WEP(mtmp);
602.  				if(otmp) {
603.  				    hittmp = hitval(otmp, &youmonst);
604.  				    tmp += hittmp;
605.  				    mswings(mtmp, otmp);
606.  				}
607.  				if(tmp > (j = dieroll = rnd(20+i)))
608.  				    sum[i] = hitmu(mtmp, mattk);
609.  				else
610.  				    missmu(mtmp, (tmp == j), mattk);
611.  				/* KMH -- Don't accumulate to-hit bonuses */
612.  				if (otmp)
613.  					tmp -= hittmp;
614.  			    } else
615.  				wildmiss(mtmp, mattk);
616.  			}
617.  			break;
618.  		case AT_MAGC:
619.  			if (range2)
620.  			    sum[i] = buzzmu(mtmp, mattk);
621.  			else
622.  			    if (foundyou)
623.  				sum[i] = castmu(mtmp, mattk);
624.  			    else
625.  				pline("%s casts a spell at %s!",
626.  					youseeit ? Monnam(mtmp) : "It",
627.  					levl[mtmp->mux][mtmp->muy].typ == WATER
628.  					    ? "empty water" : "thin air");
629.  				/* FIXME: castmu includes spells that are not
630.  				 * cast at the player and thus should be
631.  				 * possible whether the monster knows your
632.  				 * location or not.
633.  				 * --KAA
634.  				 */
635.  			break;
636.  
637.  		default:		/* no attack */
638.  			break;
639.  	    }
640.  	    if(flags.botl) bot();
641.  	/* give player a chance of waking up before dying -kaa */
642.  	    if(sum[i] == 1) {	    /* successful attack */
643.  		if (u.usleep && u.usleep < monstermoves && !rn2(10)) {
644.  		    multi = -1;
645.  		    nomovemsg = "The combat suddenly awakens you.";
646.  		}
647.  	    }
648.  	    if(sum[i] == 2) return 1;		/* attacker dead */
649.  	    if(sum[i] == 3) break;  /* attacker teleported, no more attacks */
650.  	    /* sum[i] == 0: unsuccessful attack */
651.  	}
652.  	return(0);
653.  }
654.  
655.  #endif /* OVL0 */
656.  #ifdef OVLB
657.  
658.  /*
659.   * helper function for some compilers that have trouble with hitmu
660.   */
661.  
662.  STATIC_OVL void
663.  hurtarmor(mdat, attk)
664.  struct permonst *mdat;
665.  int attk;
666.  {
667.  	boolean getbronze, rusting;
668.  	int	hurt;
669.  
670.  	rusting = (attk == AD_RUST);
671.  	if (rusting) {
672.  		hurt = 1;
673.  		getbronze = (mdat == &mons[PM_BLACK_PUDDING] &&
674.  			     uarm && is_corrodeable(uarm));
675.  	}
676.  	else {
677.  		hurt=2;
678.  		getbronze = FALSE;
679.  	}
680.  	/* What the following code does: it keeps looping until it
681.  	 * finds a target for the rust monster.
682.  	 * Head, feet, etc... not covered by metal, or covered by
683.  	 * rusty metal, are not targets.  However, your body always
684.  	 * is, no matter what covers it.
685.  	 */
686.  	while (1) {
687.  	    switch(rn2(5)) {
688.  	    case 0:
689.  		if (!rust_dmg(uarmh, rusting ? "helmet" : "leather helmet",
690.  					 hurt, FALSE, &youmonst))
691.  			continue;
692.  		break;
693.  	    case 1:
694.  		if (uarmc) {
695.  		    if (!rusting)
696.  			(void)rust_dmg(uarmc, "cloak", hurt, TRUE, &youmonst);
697.  		    break;
698.  		}
699.  		/* Note the difference between break and continue;
700.  		 * break means it was hit and didn't rust; continue
701.  		 * means it wasn't a target and though it didn't rust
702.  		 * something else did.
703.  		 */
704.  		if (getbronze)
705.  		    (void)rust_dmg(uarm, "bronze armor", 3, TRUE, &youmonst);
706.  		else if (uarm)
707.  		    (void)rust_dmg(uarm, xname(uarm), hurt, TRUE, &youmonst);
708.  #ifdef TOURIST
709.  		else if (uarmu)
710.  		    (void)rust_dmg(uarmu, "shirt", hurt, TRUE, &youmonst);
711.  #endif
712.  		break;
713.  	    case 2:
714.  		if (!rust_dmg(uarms, rusting ? "shield" : "wooden shield",
715.  					 hurt, FALSE, &youmonst))
716.  			continue;
717.  		break;
718.  	    case 3:
719.  		if (!rust_dmg(uarmg, rusting ? "metal gauntlets" : "gloves",
720.  					 hurt, FALSE, &youmonst))
721.  			continue;
722.  		break;
723.  	    case 4:
724.  		if (!rust_dmg(uarmf, rusting ? "metal boots" : "boots",
725.  					 hurt, FALSE, &youmonst))
726.  			continue;
727.  		break;
728.  	    }
729.  	    break; /* Out of while loop */
730.  	}
731.  }
732.  
733.  #endif /* OVLB */
734.  #ifdef OVL1
735.  
736.  STATIC_OVL boolean
737.  diseasemu(mdat)
738.  struct permonst *mdat;
739.  {
740.  	if (Sick_resistance) {
741.  		You_feel("a slight illness.");
742.  		return FALSE;
743.  	} else {
744.  		make_sick(Sick ? Sick/3L + 1L : (long)rn1(ACURR(A_CON), 20),
745.  			mdat->mname, TRUE, SICK_NONVOMITABLE);
746.  		return TRUE;
747.  	}
748.  }
749.  
750.  /* check whether slippery clothing protects from hug or wrap attack */
751.  STATIC_OVL boolean
752.  u_slip_free(mtmp, mattk)
753.  struct monst *mtmp;
754.  struct attack *mattk;
755.  {
756.  	struct obj *obj = (uarmc ? uarmc : uarm);
757.  
758.  #ifdef TOURIST
759.  	if (!obj) obj = uarmu;
760.  #endif
761.  	if (mattk->adtyp == AD_DRIN) obj = uarmh;
762.  
763.  	/* if your cloak/armor is greased, monster slips off; this
764.  	   protection might fail (33% chance) when the armor is cursed */
765.  	if (obj && (obj->greased || obj->otyp == OILSKIN_CLOAK) &&
766.  		(!obj->cursed || rn2(3))) {
767.  	    pline("%s %s your %s %s!",
768.  		  Monnam(mtmp),
769.  		  (mattk->adtyp == AD_WRAP) ?
770.  			"slips off of" : "grabs you, but cannot hold onto",
771.  		  obj->greased ? "greased" : "slippery",
772.  		  /* avoid "slippery slippery cloak"
773.  		     for undiscovered oilskin cloak */
774.  		  (obj->greased || objects[obj->otyp].oc_name_known) ?
775.  			xname(obj) : "cloak");
776.  
777.  	    if (obj->greased && !rn2(2)) {
778.  		pline_The("grease wears off.");
779.  		obj->greased = 0;
780.  	    }
781.  	    return TRUE;
782.  	}
783.  	return FALSE;
784.  }
785.  
786.  /*
787.   * hitmu: monster hits you
788.   *	  returns 2 if monster dies (e.g. "yellow light"), 1 otherwise
789.   *	  3 if the monster lives but teleported/paralyzed, so it can't keep
790.   *	       attacking you
791.   */
792.  STATIC_OVL int
793.  hitmu(mtmp, mattk)
794.  	register struct monst *mtmp;
795.  	register struct attack  *mattk;
796.  {
797.  	register struct permonst *mdat = mtmp->data;
798.  	register int uncancelled, ptmp;
799.  	int dmg, armpro;
800.  	char	 buf[BUFSZ];
801.  	struct permonst *olduasmon = youmonst.data;
802.  	int res;
803.  
804.  	if (!canspotmon(mtmp))
805.  	    map_invisible(mtmp->mx, mtmp->my);
806.  
807.  /*	If the monster is undetected & hits you, you should know where
808.   *	the attack came from.
809.   */
810.  	if(mtmp->mundetected && (hides_under(mdat) || mdat->mlet == S_EEL)) {
811.  	    mtmp->mundetected = 0;
812.  	    if (!(Blind ? Blind_telepat : Unblind_telepat)) {
813.  		struct obj *obj;
814.  		const char *what;
815.  
816.  		if ((obj = level.objects[mtmp->mx][mtmp->my]) != 0) {
817.  		    if (Blind && !obj->dknown)
818.  			what = something;
819.  		    else if (is_pool(mtmp->mx, mtmp->my) && !Underwater)
820.  			what = "the water";
821.  		    else
822.  			what = doname(obj);
823.  
824.  		    pline("%s was hidden under %s!", Amonnam(mtmp), what);
825.  		}
826.  		newsym(mtmp->mx, mtmp->my);
827.  	    }
828.  	}
829.  
830.  /*	First determine the base damage done */
831.  	dmg = d((int)mattk->damn, (int)mattk->damd);
832.  	if(is_undead(mdat) && midnight())
833.  		dmg += d((int)mattk->damn, (int)mattk->damd); /* extra damage */
834.  
835.  /*	Next a cancellation factor	*/
836.  /*	Use uncancelled when the cancellation factor takes into account certain
837.   *	armor's special magic protection.  Otherwise just use !mtmp->mcan.
838.   */
839.  	armpro = 0;
840.  	if (uarm && armpro < objects[uarm->otyp].a_can)
841.  		armpro = objects[uarm->otyp].a_can;
842.  	if (uarmc && armpro < objects[uarmc->otyp].a_can)
843.  		armpro = objects[uarmc->otyp].a_can;
844.  	if (uarmh && armpro < objects[uarmh->otyp].a_can)
845.  		armpro = objects[uarmh->otyp].a_can;
846.  	uncancelled = !mtmp->mcan && ((rn2(3) >= armpro) || !rn2(50));
847.  
848.  /*	Now, adjust damages via resistances or specific attacks */
849.  	switch(mattk->adtyp) {
850.  	    case AD_PHYS:
851.  		if (mattk->aatyp == AT_HUGS && !sticks(youmonst.data)) {
852.  		    if(!u.ustuck && rn2(2)) {
853.  			if (u_slip_free(mtmp, mattk)) {
854.  			    dmg = 0;
855.  			} else {
856.  			    u.ustuck = mtmp;
857.  			    pline("%s grabs you!", Monnam(mtmp));
858.  			}
859.  		    } else if(u.ustuck == mtmp) {
860.  			exercise(A_STR, FALSE);
861.  			You("are being %s.",
862.  			      (mtmp->data == &mons[PM_ROPE_GOLEM])
863.  			      ? "choked" : "crushed");
864.  		    }
865.  		} else {			  /* hand to hand weapon */
866.  		    if(mattk->aatyp == AT_WEAP && otmp) {
867.  			if (otmp->otyp == CORPSE
868.  				&& touch_petrifies(&mons[otmp->corpsenm])) {
869.  			    dmg = 1;
870.  			    pline("%s hits you with the %s corpse.",
871.  				Monnam(mtmp), mons[otmp->corpsenm].mname);
872.  			    if (!Stoned)
873.  				goto do_stone;
874.  			}
875.  			dmg += dmgval(otmp, &youmonst);
876.  			if (dmg <= 0) dmg = 1;
877.  			if (!(otmp->oartifact &&
878.  				artifact_hit(mtmp, &youmonst, otmp, &dmg,dieroll)))
879.  			     hitmsg(mtmp, mattk);
880.  			if (!dmg) break;
881.  			if (u.mh > 1 && u.mh > ((u.uac>0) ? dmg : dmg+u.uac) &&
882.  					(u.umonnum==PM_BLACK_PUDDING
883.  					|| u.umonnum==PM_BROWN_PUDDING)) {
884.  			    /* This redundancy necessary because you have to
885.  			     * take the damage _before_ being cloned.
886.  			     */
887.  			    if (u.uac < 0) dmg += u.uac;
888.  			    if (dmg < 1) dmg = 1;
889.  			    if (dmg > 1) exercise(A_STR, FALSE);
890.  			    u.mh -= dmg;
891.  			    flags.botl = 1;
892.  			    dmg = 0;
893.  			    if(cloneu())
894.  			    You("divide as %s hits you!",mon_nam(mtmp));
895.  			}
896.  			urustm(mtmp, otmp);
897.  		    } else if (mattk->aatyp != AT_TUCH || dmg != 0 ||
898.  				mtmp != u.ustuck)
899.  			hitmsg(mtmp, mattk);
900.  		}
901.  		break;
902.  	    case AD_DISE:
903.  		hitmsg(mtmp, mattk);
904.  		if (!diseasemu(mdat)) dmg = 0;
905.  		break;
906.  	    case AD_FIRE:
907.  		hitmsg(mtmp, mattk);
908.  		if (uncancelled) {
909.  		    pline("You're %s!",
910.  			  mattk->aatyp == AT_HUGS ? "being roasted" :
911.  			  "on fire");
912.  		    if (youmonst.data == &mons[PM_STRAW_GOLEM] ||
913.  		        youmonst.data == &mons[PM_PAPER_GOLEM]) {
914.  			    You("roast!");
915.  			    /* KMH -- this is okay with unchanging */
916.  			    rehumanize();
917.  			    break;
918.  		    } else if (Fire_resistance) {
919.  			pline_The("fire doesn't feel hot!");
920.  			dmg = 0;
921.  		    }
922.  		    if((int) mtmp->m_lev > rn2(20))
923.  			destroy_item(SCROLL_CLASS, AD_FIRE);
924.  		    if((int) mtmp->m_lev > rn2(20))
925.  			destroy_item(POTION_CLASS, AD_FIRE);
926.  		    if((int) mtmp->m_lev > rn2(25))
927.  			destroy_item(SPBOOK_CLASS, AD_FIRE);
928.  		    burn_away_slime();
929.  		} else dmg = 0;
930.  		break;
931.  	    case AD_COLD:
932.  		hitmsg(mtmp, mattk);
933.  		if (uncancelled) {
934.  		    pline("You're covered in frost!");
935.  		    if (Cold_resistance) {
936.  			pline_The("frost doesn't seem cold!");
937.  			dmg = 0;
938.  		    }
939.  		    if((int) mtmp->m_lev > rn2(20))
940.  			destroy_item(POTION_CLASS, AD_COLD);
941.  		} else dmg = 0;
942.  		break;
943.  	    case AD_ELEC:
944.  		hitmsg(mtmp, mattk);
945.  		if (uncancelled) {
946.  		    You("get zapped!");
947.  		    if (Shock_resistance) {
948.  			pline_The("zap doesn't shock you!");
949.  			dmg = 0;
950.  		    }
951.  		    if((int) mtmp->m_lev > rn2(20))
952.  			destroy_item(WAND_CLASS, AD_ELEC);
953.  		    if((int) mtmp->m_lev > rn2(20))
954.  			destroy_item(RING_CLASS, AD_ELEC);
955.  		} else dmg = 0;
956.  		break;
957.  	    case AD_SLEE:
958.  		hitmsg(mtmp, mattk);
959.  		if (uncancelled && multi >= 0 && !rn2(5)) {
960.  		    if (Sleep_resistance) break;
961.  		    fall_asleep(-rnd(10), TRUE);
962.  		    if (Blind) You("are put to sleep!");
963.  		    else You("are put to sleep by %s!", mon_nam(mtmp));
964.  		}
965.  		break;
966.  	    case AD_BLND:
967.  		if (!resists_blnd(&youmonst) && !Blind) {
968.  		    pline("%s blinds you!", Monnam(mtmp));
969.  		    make_blinded((long)dmg,FALSE);
970.  		}
971.  		dmg = 0;
972.  		break;
973.  	    case AD_DRST:
974.  		ptmp = A_STR;
975.  		goto dopois;
976.  	    case AD_DRDX:
977.  		ptmp = A_DEX;
978.  		goto dopois;
979.  	    case AD_DRCO:
980.  		ptmp = A_CON;
981.  dopois:
982.  		hitmsg(mtmp, mattk);
983.  		if (uncancelled && !rn2(8)) {
984.  			Sprintf(buf, "%s %s",
985.  				!canspotmon(mtmp) ? "Its" :
986.  				Hallucination ? s_suffix(rndmonnam()) :
987.  				                s_suffix(mdat->mname),
988.  				mpoisons_subj(mtmp, mattk));
989.  			poisoned(buf, ptmp, mdat->mname, 30);
990.  		}
991.  		break;
992.  	    case AD_DRIN:
993.  		hitmsg(mtmp, mattk);
994.  		if (defends(AD_DRIN, uwep) || !has_head(youmonst.data)) {
995.  		    You("don't seem harmed.");
996.  		    break;
997.  		}
998.  		if (u_slip_free(mtmp,mattk)) break;
999.  
1000. 		if (uarmh && rn2(8)) {
1001. 		    Your("helmet blocks the attack to your head.");
1002. 		    break;
1003. 		}
1004. 		if (Half_physical_damage) dmg = (dmg+1) / 2;
1005. 		losehp(dmg, mon_nam(mtmp), KILLED_BY_AN);
1006. 
1007. 		if (!uarmh || uarmh->otyp != DUNCE_CAP) {
1008. 		    Your("brain is eaten!");
1009. 		    /* No such thing as mindless players... */
1010. 		    if (ABASE(A_INT) <= ATTRMIN(A_INT)) {
1011. 			int lifesaved = 0;
1012. 			struct obj *wore_amulet = uamul;
1013. 
1014. 			while(1) {
1015. 			    /* avoid looping on "die(y/n)?" */
1016. 			    if (lifesaved && (discover || wizard)) {
1017. 				if (wore_amulet && !uamul) {
1018. 				    /* used up AMULET_OF_LIFE_SAVING; still
1019. 				       subject to dying from brainlessness */
1020. 				    wore_amulet = 0;
1021. 				} else {
1022. 				    /* explicitly chose not to die;
1023. 				       arbitrarily boost intelligence */
1024. 				    ABASE(A_INT) = ATTRMIN(A_INT) + 2;
1025. 				    You_feel("like a scarecrow.");
1026. 				    break;
1027. 				}
1028. 			    }
1029. 
1030. 			    if (lifesaved)
1031. 				pline("Unfortunately your brain is still gone.");
1032. 			    else
1033. 				Your("last thought fades away.");
1034. 			    killer = "brainlessness";
1035. 			    killer_format = KILLED_BY;
1036. 			    done(DIED);
1037. 			    lifesaved++;
1038. 			}
1039. 		    }
1040. 		}
1041. 		/* adjattrib gives dunce cap message when appropriate */
1042. 		(void) adjattrib(A_INT, -rnd(2), FALSE);
1043. 		forget_levels(25);	/* lose memory of 25% of levels */
1044. 		forget_objects(25);	/* lose memory of 25% of objects */
1045. 		exercise(A_WIS, FALSE);
1046. 		break;
1047. 	    case AD_PLYS:
1048. 		hitmsg(mtmp, mattk);
1049. 		if (uncancelled && multi >= 0 && !rn2(3)) {
1050. 	    	if (Free_action) You("momentarily stiffen.");            
1051. 	    	else {
1052. 	    	    if (Blind) You("are frozen!");
1053. 	    	    else You("are frozen by %s!", mon_nam(mtmp));
1054. 	    	    nomovemsg = 0;	/* default: "you can move again" */
1055. 	    	    nomul(-rnd(10));
1056. 	    	    exercise(A_DEX, FALSE);
1057. 	    	}
1058. 		}
1059. 		break;
1060. 	    case AD_DRLI:
1061. 		hitmsg(mtmp, mattk);
1062. 		if (uncancelled && !rn2(3) && !Drain_resistance)
1063. 		    losexp();
1064. 		break;
1065. 	    case AD_LEGS:
1066. 		{ register long side = rn2(2) ? RIGHT_SIDE : LEFT_SIDE;
1067. 		  const char *sidestr = (side == RIGHT_SIDE) ? "right" : "left";
1068. 
1069. 		/* This case is too obvious to ignore, but Nethack is not in
1070. 		 * general very good at considering height--most short monsters
1071. 		 * still _can_ attack you when you're flying or mounted.
1072. 		 */
1073. 		  if (
1074. #ifdef STEED
1075. 			u.usteed ||
1076. #endif
1077. 				    Levitation || Flying) {
1078. 		    pline("%s tries to reach your %s %s!", Monnam(mtmp),
1079. 			  sidestr, body_part(LEG));
1080. 		  } else if (mtmp->mcan) {
1081. 		    pline("%s nuzzles against your %s %s!", Monnam(mtmp),
1082. 			  sidestr, body_part(LEG));
1083. 		  } else {
1084. 		    if (uarmf) {
1085. 			if (rn2(2) && (uarmf->otyp == LOW_BOOTS ||
1086. 					     uarmf->otyp == IRON_SHOES))
1087. 			    pline("%s pricks the exposed part of your %s %s!",
1088. 				Monnam(mtmp), sidestr, body_part(LEG));
1089. 			else if (!rn2(5))
1090. 			    pline("%s pricks through your %s boot!",
1091. 				Monnam(mtmp), sidestr);
1092. 			else {
1093. 			    pline("%s scratches your %s boot!", Monnam(mtmp),
1094. 				sidestr);
1095. 			    break;
1096. 			}
1097. 		    } else pline("%s pricks your %s %s!", Monnam(mtmp),
1098. 			  sidestr, body_part(LEG));
1099. 		    set_wounded_legs(side, rnd(60-ACURR(A_DEX)));
1100. 		    exercise(A_STR, FALSE);
1101. 		    exercise(A_DEX, FALSE);
1102. 		  }
1103. 		  break;
1104. 		}
1105. 	    case AD_STON:	/* cockatrice */
1106. 		hitmsg(mtmp, mattk);
1107. 		if(!rn2(3) && !Stoned) {
1108. 		    if (mtmp->mcan) {
1109. 			if (flags.soundok)
1110. 			    You_hear("a cough from %s!", mon_nam(mtmp));
1111. 		    } else {
1112. 			if (flags.soundok)
1113. 			    You_hear("%s hissing!", s_suffix(mon_nam(mtmp)));
1114. 			if(!rn2(10) ||
1115. 			    (flags.moonphase == NEW_MOON && !have_lizard())) {
1116. do_stone:
1117. 			    if (!Stone_resistance
1118. 				    && !(poly_when_stoned(youmonst.data) &&
1119. 					polymon(PM_STONE_GOLEM))) {
1120. 				Stoned = 5;
1121. 				return(1);
1122. 				/* You("turn to stone..."); */
1123. 				/* done_in_by(mtmp); */
1124. 			    }
1125. 			}
1126. 		    }
1127. 		}
1128. 		break;
1129. 	    case AD_STCK:
1130. 		hitmsg(mtmp, mattk);
1131. 		if (uncancelled && !u.ustuck && !sticks(youmonst.data))
1132. 			u.ustuck = mtmp;
1133. 		break;
1134. 	    case AD_WRAP:
1135. 		if ((!mtmp->mcan || u.ustuck == mtmp) && !sticks(youmonst.data)) {
1136. 		    if (!u.ustuck && !rn2(10)) {
1137. 			if (u_slip_free(mtmp, mattk)) {
1138. 			    dmg = 0;
1139. 			} else {
1140. 			    pline("%s swings itself around you!",
1141. 				  Monnam(mtmp));
1142. 			    u.ustuck = mtmp;
1143. 			}
1144. 		    } else if(u.ustuck == mtmp) {
1145. 			if (is_pool(mtmp->mx,mtmp->my) && !Swimming
1146. 			    && !Amphibious) {
1147. 			    boolean moat = (levl[u.ux][u.uy].typ != POOL) &&
1148. 				(levl[u.ux][u.uy].typ != WATER) &&
1149. 				!Is_medusa_level(&u.uz) &&
1150. 				!Is_waterlevel(&u.uz);
1151. 
1152. 			    pline("%s drowns you...", Monnam(mtmp));
1153. 			    killer_format = KILLED_BY_AN;
1154. 			    Sprintf(buf, "%s by %s",
1155. 				    moat ? "moat" : "pool of water",
1156. 				    a_monnam(mtmp));
1157. 			    killer = buf;
1158. 			    done(DROWNING);
1159. 			} else if(mattk->aatyp == AT_HUGS)
1160. 			    You("are being crushed.");
1161. 		    } else {
1162. 			dmg = 0;
1163. 			if(flags.verbose)
1164. 			    pline("%s brushes against your %s.", Monnam(mtmp),
1165. 				   body_part(LEG));
1166. 		    }
1167. 		} else dmg = 0;
1168. 		break;
1169. 	    case AD_WERE:
1170. 		hitmsg(mtmp, mattk);
1171. 		if (uncancelled && !rn2(4) && u.ulycn == NON_PM &&
1172. 			!Protection_from_shape_changers &&
1173. 			!defends(AD_WERE,uwep)) {
1174. 		    You_feel("feverish.");
1175. 		    exercise(A_CON, FALSE);
1176. 		    u.ulycn = monsndx(mdat);
1177. 		}
1178. 		break;
1179. 	    case AD_SGLD:
1180. 		hitmsg(mtmp, mattk);
1181. 		if (youmonst.data->mlet == mdat->mlet) break;
1182. 		if(!mtmp->mcan) stealgold(mtmp);
1183. 		break;
1184. 
1185. 	    case AD_SITM:	/* for now these are the same */
1186. 	    case AD_SEDU:
1187. 		if (is_animal(mtmp->data)) {
1188. 			hitmsg(mtmp, mattk);
1189. 			if (mtmp->mcan) break;
1190. 			/* Continue below */
1191. 		} else if (dmgtype(youmonst.data, AD_SEDU)
1192. #ifdef SEDUCE
1193. 			|| dmgtype(youmonst.data, AD_SSEX)
1194. #endif
1195. 						) {
1196. 			pline("%s %s.", Monnam(mtmp), mtmp->minvent ?
1197. 		    "brags about the goods some dungeon explorer provided" :
1198. 		    "makes some remarks about how difficult theft is lately");
1199. 			if (!tele_restrict(mtmp)) rloc(mtmp);
1200. 			return 3;
1201. 		} else if (mtmp->mcan) {
1202. 		    if (!Blind) {
1203. 			pline("%s tries to %s you, but you seem %s.",
1204. 			    Adjmonnam(mtmp, "plain"),
1205. 			    flags.female ? "charm" : "seduce",
1206. 			    flags.female ? "unaffected" : "uninterested");
1207. 		    }
1208. 		    if(rn2(3)) {
1209. 			if (!tele_restrict(mtmp)) rloc(mtmp);
1210. 			return 3;
1211. 		    }
1212. 		    break;
1213. 		}
1214. 		switch (steal(mtmp)) {
1215. 		  case -1:
1216. 			return 2;
1217. 		  case 0:
1218. 			break;
1219. 		  default:
1220. 			if (!is_animal(mtmp->data) && !tele_restrict(mtmp))
1221. 			    rloc(mtmp);
1222. 			mtmp->mflee = 1;
1223. 			return 3;
1224. 		}
1225. 		break;
1226. #ifdef SEDUCE
1227. 	    case AD_SSEX:
1228. 		if(could_seduce(mtmp, &youmonst, mattk) == 1
1229. 			&& !mtmp->mcan)
1230. 		    if (doseduce(mtmp))
1231. 			return 3;
1232. 		break;
1233. #endif
1234. 	    case AD_SAMU:
1235. 		hitmsg(mtmp, mattk);
1236. 		/* when the Wiz hits, 1/20 steals the amulet */
1237. 		if (u.uhave.amulet ||
1238. 		     u.uhave.bell || u.uhave.book || u.uhave.menorah
1239. 		     || u.uhave.questart) /* carrying the Quest Artifact */
1240. 		    if (!rn2(20)) stealamulet(mtmp);
1241. 		break;
1242. 
1243. 	    case AD_TLPT:
1244. 		hitmsg(mtmp, mattk);
1245. 		if (uncancelled) {
1246. 		    if(flags.verbose)
1247. 			Your("position suddenly seems very uncertain!");
1248. 		    tele();
1249. 		}
1250. 		break;
1251. 	    case AD_RUST:
1252. 		hitmsg(mtmp, mattk);
1253. 		if (mtmp->mcan) break;
1254. 		if (u.umonnum == PM_IRON_GOLEM) {
1255. 			You("rust!");
1256. 			/* KMH -- this is okay with unchanging */
1257. 			rehumanize();
1258. 			break;
1259. 		}
1260. 		hurtarmor(mdat, AD_RUST);
1261. 		break;
1262. 	    case AD_DCAY:
1263. 		hitmsg(mtmp, mattk);
1264. 		if (mtmp->mcan) break;
1265. 		if (u.umonnum == PM_WOOD_GOLEM ||
1266. 		    u.umonnum == PM_LEATHER_GOLEM) {
1267. 			You("rot!");
1268. 			/* KMH -- this is okay with unchanging */
1269. 			rehumanize();
1270. 			break;
1271. 		}
1272. 		hurtarmor(mdat, AD_DCAY);
1273. 		break;
1274. 	    case AD_HEAL:
1275. 		if(!uwep
1276. #ifdef TOURIST
1277. 		   && !uarmu
1278. #endif
1279. 		   && !uarm && !uarmh && !uarms && !uarmg && !uarmc && !uarmf) {
1280. 		    boolean goaway = FALSE;
1281. 		    pline("%s hits!  (I hope you don't mind.)", Monnam(mtmp));
1282. 		    if (Upolyd) {
1283. 			u.mh += rnd(7);
1284. 			if (!rn2(7)) {
1285. 			    /* no upper limit necessary; effect is temporary */
1286. 			    u.mhmax++;
1287. 			    if (!rn2(13)) goaway = TRUE;
1288. 			}
1289. 			if (u.mh > u.mhmax) u.mh = u.mhmax;
1290. 		    } else {
1291. 			u.uhp += rnd(7);
1292. 			if (!rn2(7)) {
1293. 			    /* hard upper limit via nurse care: 25 * ulevel */
1294. 			    if (u.uhpmax < 5 * u.ulevel + d(2 * u.ulevel, 10))
1295. 				u.uhpmax++;
1296. 			    if (!rn2(13)) goaway = TRUE;
1297. 			}
1298. 			if (u.uhp > u.uhpmax) u.uhp = u.uhpmax;
1299. 		    }
1300. 		    if (!rn2(3)) exercise(A_STR, TRUE);
1301. 		    if (!rn2(3)) exercise(A_CON, TRUE);
1302. 		    if (Sick) make_sick(0L, (char *) 0, FALSE, SICK_ALL);
1303. 		    flags.botl = 1;
1304. 		    if (goaway) {
1305. 			mongone(mtmp);
1306. 			return 2;
1307. 		    } else if (!rn2(33)) {
1308. 			if (!tele_restrict(mtmp)) rloc(mtmp);
1309. 			if (!mtmp->mflee) {
1310. 			    mtmp->mflee = 1;
1311. 			    mtmp->mfleetim = d(3,6);
1312. 			}
1313. 			return 3;
1314. 		    }
1315. 		    dmg = 0;
1316. 		} else {
1317. 		    if (Role_if(PM_HEALER)) {
1318. 			if (flags.soundok && !(moves % 5))
1319. 		      verbalize("Doc, I can't help you unless you cooperate.");
1320. 			dmg = 0;
1321. 		    } else hitmsg(mtmp, mattk);
1322. 		}
1323. 		break;
1324. 	    case AD_CURS:
1325. 		hitmsg(mtmp, mattk);
1326. 		if(!night() && mdat == &mons[PM_GREMLIN]) break;
1327. 		if(!mtmp->mcan && !rn2(10)) {
1328. 		    if (flags.soundok)
1329. 			if (Blind) You_hear("laughter.");
1330. 			else       pline("%s chuckles.", Monnam(mtmp));
1331. 		    if (u.umonnum == PM_CLAY_GOLEM) {
1332. 			pline("Some writing vanishes from your head!");
1333. 			/* KMH -- this is okay with unchanging */
1334. 			rehumanize();
1335. 			break;
1336. 		    }
1337. 		    attrcurse();
1338. 		}
1339. 		break;
1340. 	    case AD_STUN:
1341. 		hitmsg(mtmp, mattk);
1342. 		if(!mtmp->mcan && !rn2(4)) {
1343. 		    make_stunned(HStun + dmg, TRUE);
1344. 		    dmg /= 2;
1345. 		}
1346. 		break;
1347. 	    case AD_ACID:
1348. 		hitmsg(mtmp, mattk);
1349. 		if (!mtmp->mcan && !rn2(3))
1350. 		    if (Acid_resistance) {
1351. 			pline("You're covered in acid, but it seems harmless.");
1352. 			dmg = 0;
1353. 		    } else {
1354. 			pline("You're covered in acid!	It burns!");
1355. 			exercise(A_STR, FALSE);
1356. 		    }
1357. 		else		dmg = 0;
1358. 		break;
1359. 	    case AD_SLOW:
1360. 		hitmsg(mtmp, mattk);
1361. 		if (uncancelled && HFast &&
1362. 					!defends(AD_SLOW, uwep) && !rn2(4))
1363. 		    u_slow_down();
1364. 		break;
1365. 	    case AD_DREN:
1366. 		hitmsg(mtmp, mattk);
1367. 		if (uncancelled && !rn2(4))
1368. 		    drain_en(dmg);
1369. 		dmg = 0;
1370. 		break;
1371. 	    case AD_CONF:
1372. 		hitmsg(mtmp, mattk);
1373. 		if(!mtmp->mcan && !rn2(4) && !mtmp->mspec_used) {
1374. 		    mtmp->mspec_used = mtmp->mspec_used + (dmg + rn2(6));
1375. 		    if(Confusion)
1376. 			 You("are getting even more confused.");
1377. 		    else You("are getting confused.");
1378. 		    make_confused(HConfusion + dmg, FALSE);
1379. 		}
1380. 		/* fall through to next case */
1381. 	    case AD_DETH:
1382. 		pline("%s reaches out with its deadly touch.", Monnam(mtmp));
1383. 		if (is_undead(youmonst.data)) {
1384. 		    /* Still does normal damage */
1385. 		    pline("Was that the touch of death?");
1386. 		    break;
1387. 		}
1388. 		if(!Antimagic && rn2(20) > 16)  {
1389. 		    killer_format = KILLED_BY_AN;
1390. 		    killer = "touch of death";
1391. 		    done(DIED);
1392. 		} else {
1393. 		    if(!rn2(5)) {
1394. 			if(Antimagic) shieldeff(u.ux, u.uy);
1395. 			pline("Lucky for you, it didn't work!");
1396. 			dmg = 0;
1397. 		    } else You_feel("your life force draining away...");
1398. 		}
1399. 		break;
1400. 	    case AD_PEST:
1401. 		pline("%s reaches out, and you feel fever and chills.",
1402. 			Monnam(mtmp));
1403. 		(void) diseasemu(mdat); /* plus the normal damage */
1404. 		break;
1405. 	    case AD_FAMN:
1406. 		pline("%s reaches out, and your body shrivels.",
1407. 			Monnam(mtmp));
1408. 		exercise(A_CON, FALSE);
1409. 		if (!is_fainted()) morehungry(rn1(40,40));
1410. 		/* plus the normal damage */
1411. 		break;
1412. 	    case AD_SLIM:    
1413. 	    	hitmsg(mtmp, mattk);
1414. 	    	if (!uncancelled) break;
1415. 	    	if (youmonst.data == &mons[PM_FIRE_VORTEX] ||
1416. 	    			youmonst.data == &mons[PM_FIRE_ELEMENTAL]) {
1417. 	    	    pline_The("slime burns away!");
1418. 	    	    dmg = 0;
1419. 	    	} else if (Unchanging ||
1420. 	    			youmonst.data == &mons[PM_GREEN_SLIME]) {
1421. 	    	    You("are unaffected.");
1422. 	    	    dmg = 0;
1423. 	    	} else if (!Slimed) {
1424. 	    	    You("don't feel very well.");
1425. 	    	    Slimed = 10L;
1426. 	    	} else
1427. 	    	    pline("Yuck!");
1428. 	    	break;
1429. 	    case AD_ENCH:	/* KMH -- remove enchantment (disenchanter) */
1430. 	    	hitmsg(mtmp, mattk);
1431. 	    	/* uncancelled is sufficient enough; please
1432. 	    	   don't make this attack less frequent */
1433. 	    	if (uncancelled) {
1434. 	    		struct obj *obj = some_armor(&youmonst);
1435. 
1436. 	    		if (drain_item(obj)) {
1437. 	    			Your("%s less effective.", aobjnam(obj, "seem"));
1438. 	    		}
1439. 	    	}
1440. 	    	break;
1441. 	    default:	dmg = 0;
1442. 			break;
1443. 	}
1444. 	if(u.uhp < 1) done_in_by(mtmp);
1445. 
1446. /*	Negative armor class reduces damage done instead of fully protecting
1447.  *	against hits.
1448.  */
1449. 	if (dmg && u.uac < 0) {
1450. 		dmg -= rnd(-u.uac);
1451. 		if (dmg < 1) dmg = 1;
1452. 	}
1453. 
1454. 	if(dmg) {
1455. 	    if (Half_physical_damage
1456. 					/* Mitre of Holiness */
1457. 		|| (Role_if(PM_PRIEST) && uarmh && is_quest_artifact(uarmh) &&
1458. 		    (is_undead(mtmp->data) || is_demon(mtmp->data))))
1459. 		dmg = (dmg+1) / 2;
1460. 	    mdamageu(mtmp, dmg);
1461. 	}
1462. 
1463. 	if (dmg) {
1464. 	    res = passiveum(olduasmon, mtmp, mattk);
1465. 	    stop_occupation();
1466. 	    return res;
1467. 	} else
1468. 	    return 1;
1469. }
1470. 
1471. #endif /* OVL1 */
1472. #ifdef OVLB
1473. 
1474. STATIC_OVL int
1475. gulpmu(mtmp, mattk)	/* monster swallows you, or damage if u.uswallow */
1476. 	register struct monst *mtmp;
1477. 	register struct attack  *mattk;
1478. {
1479. 	struct trap *t = t_at(u.ux, u.uy);
1480. 	int	tmp = d((int)mattk->damn, (int)mattk->damd);
1481. 	int	tim_tmp;
1482. 	register struct obj *otmp2;
1483. 	int	i;
1484. 
1485. 	if (!u.uswallow) {	/* swallows you */
1486. 		if (youmonst.data->msize >= MZ_HUGE) return(0);
1487. 		if ((t && ((t->ttyp == PIT) || (t->ttyp == SPIKED_PIT))) &&
1488. 		    sobj_at(BOULDER, u.ux, u.uy))
1489. 			return(0);
1490. 
1491. 		if (Punished) unplacebc();	/* ball&chain go away */
1492. 		remove_monster(mtmp->mx, mtmp->my);
1493. 		place_monster(mtmp, u.ux, u.uy);
1494. 		u.ustuck = mtmp;
1495. 		newsym(mtmp->mx,mtmp->my);
1496. #ifdef STEED
1497. 		if (is_animal(mtmp->data) && u.usteed) {
1498. 			char buf[BUFSZ];
1499. 			/* Too many quirks presently if hero and steed
1500. 			 * are swallowed. Pretend purple worms don't
1501. 			 * like horses for now :-)
1502. 			 */
1503. 			Strcpy(buf, mon_nam(u.usteed));
1504. 			pline ("%s lunges forward and plucks you off %s!",
1505. 				Monnam(mtmp), buf);
1506. 			dismount_steed(DISMOUNT_ENGULFED);
1507. 		} else
1508. #endif
1509. 		pline("%s engulfs you!", Monnam(mtmp));
1510. 		stop_occupation();
1511. 		reset_occupations();	/* behave as if you had moved */
1512. 
1513. 		if (u.utrap) {
1514. 			You("are released from the %s!",
1515. 				u.utraptype==TT_WEB ? "web" : "trap");
1516. 			u.utrap = 0;
1517. 		}
1518. 
1519. 		i = number_leashed();
1520. 		if (i > 0) {
1521. 			pline_The("leash%s snap%s loose.",
1522. 					(i > 1) ? "es" : "",
1523. 					(i > 1) ? "" : "s");
1524. 			unleash_all();
1525. 		}
1526. 
1527. 		if (touch_petrifies(youmonst.data) && !resists_ston(mtmp)) {
1528. 			minstapetrify(mtmp, TRUE);
1529. 			if (mtmp->mhp > 0) return 0;
1530. 			else return 2;
1531. 		}
1532. 
1533. 		display_nhwindow(WIN_MESSAGE, FALSE);
1534. 		vision_recalc(2);	/* hero can't see anything */
1535. 		u.uswallow = 1;
1536. 		/* assume that u.uswldtim always set >= 0 */
1537. 		u.uswldtim = (tim_tmp =
1538. 			(-u.uac + 10 + rnd(25 - (int)mtmp->m_lev)) >> 1) > 0 ?
1539. 			    tim_tmp : 0;
1540. 		swallowed(1);
1541. 		for(otmp2 = invent; otmp2; otmp2 = otmp2->nobj) {
1542. 			(void) snuff_lit(otmp2);
1543. 		}
1544. 	}
1545. 
1546. 	if (mtmp != u.ustuck) return(0);
1547. 
1548. 	switch(mattk->adtyp) {
1549. 
1550. 		case AD_DGST:
1551. 		    if (Slow_digestion) {
1552. 		    	/* Messages are handled below */
1553. 		    	u.uswldtim = 0;
1554. 		    	tmp = 0;
1555. 		    } else
1556. 		    if(u.uswldtim <= 1) {	/* a3 *//*no cf unsigned <=0*/
1557. 			pline("%s totally digests you!", Monnam(mtmp));
1558. 			tmp = u.uhp;
1559. 			if (Half_physical_damage) tmp *= 2; /* sorry */
1560. 		    } else {
1561. 			pline("%s digests you!", Monnam(mtmp));
1562. 		        exercise(A_STR, FALSE);
1563. 		    }
1564. 		    break;
1565. 		case AD_PHYS:
1566. 		    You("are pummeled with debris!");
1567. 		    exercise(A_STR, FALSE);
1568. 		    break;
1569. 		case AD_ACID:
1570. 		    if (Acid_resistance) {
1571. 			You("are covered with a seemingly harmless goo.");
1572. 			tmp = 0;
1573. 		    } else {
1574. 		      if (Hallucination) pline("Ouch!  You've been slimed!");
1575. 		      else You("are covered in slime!  It burns!");
1576. 		      exercise(A_STR, FALSE);
1577. 		    }
1578. 		    break;
1579. 		case AD_BLND:
1580. 		    if (!resists_blnd(&youmonst)) {
1581. 			if(!Blind) {
1582. 			    You_cant("see in here!");
1583. 			    make_blinded((long)tmp,FALSE);
1584. 			} else
1585. 			    /* keep him blind until disgorged */
1586. 			    make_blinded(Blinded+1,FALSE);
1587. 		    }
1588. 		    tmp = 0;
1589. 		    break;
1590. 		case AD_ELEC:
1591. 		    if(!mtmp->mcan && rn2(2)) {
1592. 			pline_The("air around you crackles with electricity.");
1593. 			if (Shock_resistance) {
1594. 				shieldeff(u.ux, u.uy);
1595. 				You("seem unhurt.");
1596. 				ugolemeffects(AD_ELEC,tmp);
1597. 				tmp = 0;
1598. 			}
1599. 		    } else tmp = 0;
1600. 		    break;
1601. 		case AD_COLD:
1602. 		    if(!mtmp->mcan && rn2(2)) {
1603. 			if (Cold_resistance) {
1604. 				shieldeff(u.ux, u.uy);
1605. 				You_feel("mildly chilly.");
1606. 				ugolemeffects(AD_COLD,tmp);
1607. 				tmp = 0;
1608. 			} else You("are freezing to death!");
1609. 		    } else tmp = 0;
1610. 		    break;
1611. 		case AD_FIRE:
1612. 		    if(!mtmp->mcan && rn2(2)) {
1613. 			if (Fire_resistance) {
1614. 				shieldeff(u.ux, u.uy);
1615. 				You_feel("mildly hot.");
1616. 				ugolemeffects(AD_FIRE,tmp);
1617. 				tmp = 0;
1618. 			} else You("are burning to a crisp!");
1619. 			burn_away_slime();
1620. 		    } else tmp = 0;
1621. 		    break;
1622. 		case AD_DISE:
1623. 		    if (!diseasemu(mtmp->data)) tmp = 0;
1624. 		    break;
1625. 		default:
1626. 		    tmp = 0;
1627. 		    break;
1628. 	}
1629. 
1630. 	if (Half_physical_damage) tmp = (tmp+1) / 2;
1631. 
1632. 	mdamageu(mtmp, tmp);
1633. 	if (tmp) stop_occupation();
1634. 	if (u.uswldtim) --u.uswldtim;
1635. 
1636. 	if (touch_petrifies(youmonst.data) && !resists_ston(mtmp)) {
1637. 		pline("%s very hurriedly %s you!", Monnam(mtmp),
1638. 		       is_animal(mtmp->data)? "regurgitates" : "expels");
1639. 		expels(mtmp, mtmp->data, FALSE);
1640. 	} else if (!u.uswldtim || youmonst.data->msize >= MZ_HUGE) {
1641. 	    You("get %s!", is_animal(mtmp->data)? "regurgitated" : "expelled");
1642. 	    if (flags.verbose && (is_animal(mtmp->data) || Slow_digestion))
1643. 		    pline("Obviously %s doesn't like your taste.",
1644. 			   mon_nam(mtmp));
1645. 	    expels(mtmp, mtmp->data, FALSE);
1646. 	}
1647. 	return(1);
1648. }
1649. 
1650. STATIC_OVL int
1651. explmu(mtmp, mattk, ufound)	/* monster explodes in your face */
1652. register struct monst *mtmp;
1653. register struct attack  *mattk;
1654. boolean ufound;
1655. {
1656.     if (mtmp->mcan) return(0);
1657. 
1658.     if (!ufound)
1659. 	pline("%s explodes at a spot in %s!",
1660. 	    canseemon(mtmp) ? Monnam(mtmp) : "It",
1661. 	    levl[mtmp->mux][mtmp->muy].typ == WATER
1662. 		? "empty water" : "thin air");
1663.     else {
1664. 	register int tmp = d((int)mattk->damn, (int)mattk->damd);
1665. 	register boolean not_affected = defends((int)mattk->adtyp, uwep);
1666. 
1667. 	hitmsg(mtmp, mattk);
1668. 
1669. 	switch (mattk->adtyp) {
1670. 	    case AD_COLD:
1671. 		not_affected |= Cold_resistance;
1672. 		goto common;
1673. 	    case AD_FIRE:
1674. 		not_affected |= Fire_resistance;
1675. 		goto common;
1676. 	    case AD_ELEC:
1677. 		not_affected |= Shock_resistance;
1678. common:
1679. 
1680. 		if (!not_affected) {
1681. 		    if (ACURR(A_DEX) > rnd(20)) {
1682. 			You("duck some of the blast.");
1683. 			tmp = (tmp+1) / 2;
1684. 		    } else {
1685. 		        if (flags.verbose) You("get blasted!");
1686. 		    }
1687. 		    if (mattk->adtyp == AD_FIRE) burn_away_slime();
1688. 		    if (Half_physical_damage) tmp = (tmp+1) / 2;
1689. 		    mdamageu(mtmp, tmp);
1690. 		}
1691. 		break;
1692. 
1693. 	    case AD_BLND:
1694. 		not_affected = resists_blnd(&youmonst);
1695. 		if (!not_affected) {
1696. 		    /* sometimes you're affected even if it's invisible */
1697. 		    if (mon_visible(mtmp) || (rnd(tmp /= 2) > u.ulevel)) {
1698. 			You("are blinded by a blast of light!");
1699. 			make_blinded((long)tmp, FALSE);
1700. 		    } else
1701. 			if (flags.verbose)
1702. 			You("get the impression it was not terribly bright.");
1703. 		}
1704. 		break;
1705. 
1706. 	    case AD_HALU:
1707. 		not_affected |= Blind ||
1708. 			(u.umonnum == PM_BLACK_LIGHT ||
1709. 			 u.umonnum == PM_VIOLET_FUNGUS ||
1710. 			 dmgtype(youmonst.data, AD_STUN));
1711. 		if (!not_affected) {
1712. 		    if (!Hallucination)
1713. 			You("are freaked by a blast of kaleidoscopic light!");
1714. 		    make_hallucinated(HHallucination + (long)tmp,FALSE,0L);
1715. 		}
1716. 		break;
1717. 
1718. 	    default:
1719. 		break;
1720. 	}
1721. 	if (not_affected) {
1722. 	    You("seem unaffected by it.");
1723. 	    ugolemeffects((int)mattk->adtyp, tmp);
1724. 	}
1725.     }
1726.     mondead(mtmp);
1727.     if (mtmp->mhp > 0) return(0);
1728.     return(2);	/* it dies */
1729. }
1730. 
1731. int
1732. gazemu(mtmp, mattk)	/* monster gazes at you */
1733. 	register struct monst *mtmp;
1734. 	register struct attack  *mattk;
1735. {
1736. 	switch(mattk->adtyp) {
1737. 	    case AD_STON:
1738. 		if (mtmp->mcan) {
1739. 		    if (mtmp->data == &mons[PM_MEDUSA] && canseemon(mtmp))
1740. 			pline("%s doesn't look all that ugly.", Monnam(mtmp));
1741. 		    break;
1742. 		}
1743. 		if(Reflecting && m_canseeu(mtmp) &&
1744. 		   !mtmp->mcan && mtmp->data == &mons[PM_MEDUSA]) {
1745. 		    if(!Blind) {
1746. 		    	(void) ureflects("%s gaze is reflected by your %s.",
1747. 		    			s_suffix(Monnam(mtmp)));
1748. 		    	if (mon_reflects(mtmp,
1749. 		    			"The gaze is reflected away by %s %s!"))
1750. 		    	    break;
1751. 			pline("%s is turned to stone!", Monnam(mtmp));
1752. 		    }
1753. 		    stoned = TRUE;
1754. 		    killed(mtmp);
1755. 
1756. 		    if (mtmp->mhp > 0) break;
1757. 		    return 2;
1758. 		}
1759. 		if (canseemon(mtmp) && !Stone_resistance) {
1760. 			You("look upon %s.", mon_nam(mtmp));
1761. 			if(poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM))
1762. 			    break;
1763. 			You("turn to stone...");
1764. 			killer_format = KILLED_BY;
1765. 			killer = mons[PM_MEDUSA].mname;
1766. 			done(STONING);
1767. 		}
1768. 		break;
1769. 	    case AD_CONF:
1770. 		if(!mtmp->mcan && canseemon(mtmp) && mtmp->mcansee &&
1771. 					!mtmp->mspec_used && rn2(5)) {
1772. 		    int conf = d(3,4);
1773. 
1774. 		    mtmp->mspec_used = mtmp->mspec_used + (conf + rn2(6));
1775. 		    if(!Confusion)
1776. 			pline("%s gaze confuses you!",
1777. 			                  s_suffix(Monnam(mtmp)));
1778. 		    else
1779. 			You("are getting more and more confused.");
1780. 		    make_confused(HConfusion + conf, FALSE);
1781. 		}
1782. 		break;
1783. 	    case AD_STUN:
1784. 		if(!mtmp->mcan && canseemon(mtmp) && mtmp->mcansee &&
1785. 					!mtmp->mspec_used && rn2(5)) {
1786. 		    int stun = d(2,6);
1787. 
1788. 		    mtmp->mspec_used = mtmp->mspec_used + (stun + rn2(6));
1789. 		    make_stunned(HStun + stun, TRUE);
1790. 		    pline("%s stares piercingly at you!", Monnam(mtmp));
1791. 		}
1792. 		break;
1793. 	    case AD_BLND:
1794. 		if (!mtmp->mcan && canseemon(mtmp) && !resists_blnd(&youmonst)
1795. 			&& distu(mtmp->mx,mtmp->my) <= BOLT_LIM*BOLT_LIM) {
1796. 		    int blnd = d((int)mattk->damn, (int)mattk->damd);
1797. 		    make_blinded((long)blnd,FALSE);
1798. 		    make_stunned((long)d(1,3),TRUE);
1799. 		    You("are blinded by %s radiance!",
1800. 			              s_suffix(mon_nam(mtmp)));
1801. 		}
1802. 		break;
1803. 	    case AD_FIRE:
1804. 	    	if(!mtmp->mcan && canseemon(mtmp) && mtmp->mcansee &&
1805. 	    			!mtmp->mspec_used && rn2(5)) {
1806. 	    	    int dmg = d(2,6);
1807. 	    	    pline("%s attacks you with a fiery gaze!",
1808. 	    	    		Monnam(mtmp));
1809. 	    	    if (Fire_resistance) {
1810. 	    	    	pline("The fire doesn't feel hot!");
1811. 	    	    	dmg = 0;
1812. 	    	    }
1813. 	    	    burn_away_slime();
1814. 	    	    if((int) mtmp->m_lev > rn2(20))
1815. 	    	    	destroy_item(SCROLL_CLASS, AD_FIRE);
1816. 	    	    if((int) mtmp->m_lev > rn2(20))
1817. 	    	    	destroy_item(POTION_CLASS, AD_FIRE);
1818. 	    	    if((int) mtmp->m_lev > rn2(25))
1819. 	    	    	destroy_item(SPBOOK_CLASS, AD_FIRE);
1820. 	    	    if (dmg) mdamageu(mtmp, dmg);
1821. 	    	}
1822.         break;
1823. #ifdef PM_BEHOLDER /* work in progress */
1824. 	    case AD_SLEE:
1825. 		if(multi >= 0 && !rn2(5) && !Sleep_resistance) {
1826. 		    fall_asleep(-rnd(10), TRUE);
1827. 		    pline("%s gaze makes you very sleepy...",
1828. 			  s_suffix(Monnam(mtmp)));
1829. 		}
1830. 		break;
1831. 	    case AD_SLOW:
1832. 		if((Fast & (INTRINSIC|TIMEOUT)) &&
1833. 					!defends(AD_SLOW, uwep) && !rn2(4))
1834. 		    u_slow_down();
1835. 		break;
1836. #endif
1837. 	    default: impossible("Gaze attack %d?", mattk->adtyp);
1838. 		break;
1839. 	}
1840. 	return(0);
1841. }
1842. 
1843. #endif /* OVLB */
1844. #ifdef OVL1
1845. 
1846. void
1847. mdamageu(mtmp, n)	/* mtmp hits you for n points damage */
1848. register struct monst *mtmp;
1849. register int n;
1850. {
1851. 	flags.botl = 1;
1852. 	if (Upolyd) {
1853. 		u.mh -= n;
1854. 		if (u.mh < 1) rehumanize();
1855. 	} else {
1856. 		u.uhp -= n;
1857. 		if(u.uhp < 1) done_in_by(mtmp);
1858. 	}
1859. }
1860. 
1861. #endif /* OVL1 */
1862. #ifdef OVLB
1863. 
1864. STATIC_OVL void
1865. urustm(mon, obj)
1866. register struct monst *mon;
1867. register struct obj *obj;
1868. {
1869. 	boolean vis;
1870. 
1871. 	if (!mon || !obj) return; /* just in case */
1872. 	vis = cansee(mon->mx, mon->my);
1873. 	if (u.umonnum == PM_RUST_MONSTER &&
1874. 	    is_rustprone(obj) && obj->oeroded < MAX_ERODE) {
1875. 		if (obj->greased || obj->oerodeproof || (obj->blessed && rn2(3))) {
1876. 		    if (vis)
1877. 			pline("Somehow, %s weapon is not affected.",
1878. 						s_suffix(mon_nam(mon)));
1879. 		    if (obj->greased && !rn2(2)) obj->greased = 0;
1880. 		} else {
1881. 		    if (vis)
1882. 			pline("%s %s%s!",
1883. 			        s_suffix(Monnam(mon)), aobjnam(obj, "rust"),
1884. 			        obj->oeroded ? " further" : "");
1885. 		    obj->oeroded++;
1886. 		}
1887. 	}
1888. }
1889. 
1890. #endif /* OVLB */
1891. #ifdef OVL1
1892. 
1893. int
1894. could_seduce(magr,mdef,mattk)
1895. struct monst *magr, *mdef;
1896. struct attack *mattk;
1897. /* returns 0 if seduction impossible,
1898.  *	   1 if fine,
1899.  *	   2 if wrong gender for nymph */
1900. {
1901. 	register struct permonst *pagr;
1902. 	boolean agrinvis, defperc;
1903. 	xchar genagr, gendef;
1904. 
1905. 	if (is_animal(magr->data)) return (0);
1906. 	if(magr == &youmonst) {
1907. 		pagr = youmonst.data;
1908. 		agrinvis = (Invis != 0);
1909. 		genagr = poly_gender();
1910. 	} else {
1911. 		pagr = magr->data;
1912. 		agrinvis = magr->minvis;
1913. 		genagr = gender(magr);
1914. 	}
1915. 	if(mdef == &youmonst) {
1916. 		defperc = (See_invisible != 0);
1917. 		gendef = poly_gender();
1918. 	} else {
1919. 		defperc = perceives(mdef->data);
1920. 		gendef = gender(mdef);
1921. 	}
1922. 
1923. 	if(agrinvis && !defperc
1924. #ifdef SEDUCE
1925. 		&& mattk && mattk->adtyp != AD_SSEX
1926. #endif
1927. 		)
1928. 		return 0;
1929. 
1930. 	if(pagr->mlet != S_NYMPH
1931. 		&& ((pagr != &mons[PM_INCUBUS] && pagr != &mons[PM_SUCCUBUS])
1932. #ifdef SEDUCE
1933. 		    || (mattk && mattk->adtyp != AD_SSEX)
1934. #endif
1935. 		   ))
1936. 		return 0;
1937. 	
1938. 	if(genagr == 1 - gendef)
1939. 		return 1;
1940. 	else
1941. 		return (pagr->mlet == S_NYMPH) ? 2 : 0;
1942. }
1943. 
1944. #endif /* OVL1 */
1945. #ifdef OVLB
1946. 
1947. #ifdef SEDUCE
1948. /* Returns 1 if monster teleported */
1949. int
1950. doseduce(mon)
1951. register struct monst *mon;
1952. {
1953. 	register struct obj *ring, *nring;
1954. 	boolean fem = (mon->data == &mons[PM_SUCCUBUS]); /* otherwise incubus */
1955. 	char qbuf[QBUFSZ];
1956. 
1957. 	if (mon->mcan || mon->mspec_used) {
1958. 		pline("%s acts as though %s has got a %sheadache.",
1959. 		      Monnam(mon), he[pronoun_gender(mon)],
1960. 		      mon->mcan ? "severe " : "");
1961. 		return 0;
1962. 	}
1963. 
1964. 	if (unconscious()) {
1965. 		pline("%s seems dismayed at your lack of response.",
1966. 		      Monnam(mon));
1967. 		return 0;
1968. 	}
1969. 
1970. 	if (Blind) pline("It caresses you...");
1971. 	else You_feel("very attracted to %s.", mon_nam(mon));
1972. 
1973. 	for(ring = invent; ring; ring = nring) {
1974. 	    nring = ring->nobj;
1975. 	    if (ring->otyp != RIN_ADORNMENT) continue;
1976. 	    if (fem) {
1977. 		if (rn2(20) < ACURR(A_CHA)) {
1978. 		    Sprintf(qbuf, "\"That %s looks pretty.  May I have it?\"",
1979. 			xname(ring));
1980. 		    makeknown(RIN_ADORNMENT);
1981. 		    if (yn(qbuf) == 'n') continue;
1982. 		} else pline("%s decides she'd like your %s, and takes it.",
1983. 			Blind ? "She" : Monnam(mon), xname(ring));
1984. 		makeknown(RIN_ADORNMENT);
1985. 		if (ring==uleft || ring==uright) Ring_gone(ring);
1986. 		if (ring==uwep) setuwep((struct obj *)0);
1987. 		if (ring==uswapwep) setuswapwep((struct obj *)0);
1988. 		if (ring==uquiver) setuqwep((struct obj *)0);
1989. 		freeinv(ring);
1990. 		mpickobj(mon,ring);
1991. 	    } else {
1992. 		char buf[BUFSZ];
1993. 
1994. 		if (uleft && uright && uleft->otyp == RIN_ADORNMENT
1995. 				&& uright->otyp==RIN_ADORNMENT)
1996. 			break;
1997. 		if (ring==uleft || ring==uright) continue;
1998. 		if (rn2(20) < ACURR(A_CHA)) {
1999. 		    Sprintf(qbuf,"\"That %s looks pretty.  Would you wear it for me?\"",
2000. 			xname(ring));
2001. 		    makeknown(RIN_ADORNMENT);
2002. 		    if (yn(qbuf) == 'n') continue;
2003. 		} else {
2004. 		    pline("%s decides you'd look prettier wearing your %s,",
2005. 			Blind ? "He" : Monnam(mon), xname(ring));
2006. 		    pline("and puts it on your finger.");
2007. 		}
2008. 		makeknown(RIN_ADORNMENT);
2009. 		if (!uright) {
2010. 		    pline("%s puts %s on your right hand.",
2011. 			Blind ? "He" : Monnam(mon), the(xname(ring)));
2012. 		    setworn(ring, RIGHT_RING);
2013. 		} else if (!uleft) {
2014. 		    pline("%s puts %s on your left hand.",
2015. 			Blind ? "He" : Monnam(mon), the(xname(ring)));
2016. 		    setworn(ring, LEFT_RING);
2017. 		} else if (uright && uright->otyp != RIN_ADORNMENT) {
2018. 		    Strcpy(buf, xname(uright));
2019. 		    pline("%s replaces your %s with your %s.",
2020. 			Blind ? "He" : Monnam(mon), buf, xname(ring));
2021. 		    Ring_gone(uright);
2022. 		    setworn(ring, RIGHT_RING);
2023. 		} else if (uleft && uleft->otyp != RIN_ADORNMENT) {
2024. 		    Strcpy(buf, xname(uleft));
2025. 		    pline("%s replaces your %s with your %s.",
2026. 			Blind ? "He" : Monnam(mon), buf, xname(ring));
2027. 		    Ring_gone(uleft);
2028. 		    setworn(ring, LEFT_RING);
2029. 		} else impossible("ring replacement");
2030. 		Ring_on(ring);
2031. 		prinv((char *)0, ring, 0L);
2032. 	    }
2033. 	}
2034. 
2035. 	if (!uarmc && !uarmf && !uarmg && !uarms && !uarmh
2036. #ifdef TOURIST
2037. 								&& !uarmu
2038. #endif
2039. 									)
2040. 		pline("%s murmurs sweet nothings into your ear.",
2041. 			Blind ? (fem ? "She" : "He") : Monnam(mon));
2042. 	else
2043. 		pline("%s murmurs in your ear, while helping you undress.",
2044. 			Blind ? (fem ? "She" : "He") : Monnam(mon));
2045. 	mayberem(uarmc, "cloak");
2046. 	if(!uarmc)
2047. 		mayberem(uarm, "suit");
2048. 	mayberem(uarmf, "boots");
2049. 	if(!uwep || !welded(uwep))
2050. 		mayberem(uarmg, "gloves");
2051. 	mayberem(uarms, "shield");
2052. 	mayberem(uarmh, "helmet");
2053. #ifdef TOURIST
2054. 	if(!uarmc && !uarm)
2055. 		mayberem(uarmu, "shirt");
2056. #endif
2057. 
2058. 	if (uarm || uarmc) {
2059. 		verbalize("You're such a %s; I wish...",
2060. 				flags.female ? "sweet lady" : "nice guy");
2061. 		if (!tele_restrict(mon)) rloc(mon);
2062. 		return 1;
2063. 	}
2064. 	if (u.ualign.type == A_CHAOTIC)
2065. 		adjalign(1);
2066. 
2067. 	/* by this point you have discovered mon's identity, blind or not... */
2068. 	pline("Time stands still while you and %s lie in each other's arms...",
2069. 		mon_nam(mon));
2070. 	if (rn2(35) > ACURR(A_CHA) + ACURR(A_INT)) {
2071. 		/* Don't bother with mspec_used here... it didn't get tired! */
2072. 		pline("%s seems to have enjoyed it more than you...",
2073. 			Monnam(mon));
2074. 		switch (rn2(5)) {
2075. 			case 0: You_feel("drained of energy.");
2076. 				u.uen = 0;
2077. 				u.uenmax -= rnd(Half_physical_damage ? 5 : 10);
2078. 			        exercise(A_CON, FALSE);
2079. 				if (u.uenmax < 0) u.uenmax = 0;
2080. 				break;
2081. 			case 1: You("are down in the dumps.");
2082. 				(void) adjattrib(A_CON, -1, TRUE);
2083. 			        exercise(A_CON, FALSE);
2084. 				flags.botl = 1;
2085. 				break;
2086. 			case 2: Your("senses are dulled.");
2087. 				(void) adjattrib(A_WIS, -1, TRUE);
2088. 			        exercise(A_WIS, FALSE);
2089. 				flags.botl = 1;
2090. 				break;
2091. 			case 3:
2092. 				if (!resists_drli(&youmonst)) {
2093. 				    You_feel("out of shape.");
2094. 				    losexp();
2095. 				    if(u.uhp <= 0) {
2096. 					killer_format = KILLED_BY;
2097. 					killer = "overexertion";
2098. 					done(DIED);
2099. 				    }
2100. 				} else {
2101. 				    You("have a curious feeling...");
2102. 				}
2103. 				break;
2104. 			case 4: {
2105. 				int tmp;
2106. 				You_feel("exhausted.");
2107. 			        exercise(A_STR, FALSE);
2108. 				tmp = rn1(10, 6);
2109. 				if(Half_physical_damage) tmp = (tmp+1) / 2;
2110. 				losehp(tmp, "exhaustion", KILLED_BY);
2111. 				break;
2112. 			}
2113. 		}
2114. 	} else {
2115. 		mon->mspec_used = rnd(100); /* monster is worn out */
2116. 		You("seem to have enjoyed it more than %s...", mon_nam(mon));
2117. 		switch (rn2(5)) {
2118. 			case 0: You_feel("raised to your full potential.");
2119. 				exercise(A_CON, TRUE);
2120. 				u.uen = (u.uenmax += rnd(5));
2121. 				break;
2122. 			case 1: You_feel("good enough to do it again.");
2123. 				(void) adjattrib(A_CON, 1, TRUE);
2124. 				exercise(A_CON, TRUE);
2125. 				flags.botl = 1;
2126. 				break;
2127. 			case 2: You("will always remember %s...", mon_nam(mon));
2128. 				(void) adjattrib(A_WIS, 1, TRUE);
2129. 				exercise(A_WIS, TRUE);
2130. 				flags.botl = 1;
2131. 				break;
2132. 			case 3: pline("That was a very educational experience.");
2133. 				pluslvl(FALSE);
2134. 				exercise(A_WIS, TRUE);
2135. 				break;
2136. 			case 4: You_feel("restored to health!");
2137. 				u.uhp = u.uhpmax;
2138. 				if (Upolyd) u.mh = u.mhmax;
2139. 				exercise(A_STR, TRUE);
2140. 				flags.botl = 1;
2141. 				break;
2142. 		}
2143. 	}
2144. 
2145. 	if (mon->mtame) /* don't charge */ ;
2146. 	else if (rn2(20) < ACURR(A_CHA)) {
2147. 		pline("%s demands that you pay %s, but you refuse...",
2148. 			Monnam(mon), him[fem]);
2149. 	} else if (u.umonnum == PM_LEPRECHAUN)
2150. 		pline("%s tries to take your money, but fails...",
2151. 				Monnam(mon));
2152. 	else {
2153. 		long cost;
2154. 
2155. 		if (u.ugold > (long)LARGEST_INT - 10L)
2156. 			cost = (long) rnd(LARGEST_INT) + 500L;
2157. 		else
2158. 			cost = (long) rnd((int)u.ugold + 10) + 500L;
2159. 		if (mon->mpeaceful) {
2160. 			cost /= 5L;
2161. 			if (!cost) cost = 1L;
2162. 		}
2163. 		if (cost > u.ugold) cost = u.ugold;
2164. 		if (!cost) verbalize("It's on the house!");
2165. 		else {
2166. 		    pline("%s takes %ld zorkmid%s for services rendered!",
2167. 			    Monnam(mon), cost, plur(cost));
2168. 		    u.ugold -= cost;
2169. 		    mon->mgold += cost;
2170. 		    flags.botl = 1;
2171. 		}
2172. 	}
2173. 	if (!rn2(25)) mon->mcan = 1; /* monster is worn out */
2174. 	if (!tele_restrict(mon)) rloc(mon);
2175. 	return 1;
2176. }
2177. 
2178. STATIC_OVL void
2179. mayberem(obj, str)
2180. register struct obj *obj;
2181. const char *str;
2182. {
2183. 	char qbuf[QBUFSZ];
2184. 
2185. 	if (!obj || !obj->owornmask) return;
2186. 
2187. 	if (rn2(20) < ACURR(A_CHA)) {
2188. 		Sprintf(qbuf,"\"Shall I remove your %s, %s?\"",
2189. 			str,
2190. 			(!rn2(2) ? "lover" : !rn2(2) ? "dear" : "sweetheart"));
2191. 		if (yn(qbuf) == 'n') return;
2192. 	} else {
2193. 		char hairbuf[BUFSZ];
2194. 
2195. 		Sprintf(hairbuf, "let me run my fingers through your %s",
2196. 			body_part(HAIR));
2197. 		verbalize("Take off your %s; %s.", str,
2198. 			(obj == uarm)  ? "let's get a little closer" :
2199. 			(obj == uarmc || obj == uarms) ? "it's in the way" :
2200. 			(obj == uarmf) ? "let me rub your feet" :
2201. 			(obj == uarmg) ? "they're too clumsy" :
2202. #ifdef TOURIST
2203. 			(obj == uarmu) ? "let me massage you" :
2204. #endif
2205. 			/* obj == uarmh */
2206. 			hairbuf);
2207. 	}
2208. 	remove_worn_item(obj);
2209. }
2210. #endif  /* SEDUCE */
2211. 
2212. #endif /* OVLB */
2213. 
2214. #ifdef OVL1
2215. 
2216. STATIC_OVL int
2217. passiveum(olduasmon,mtmp,mattk)
2218. struct permonst *olduasmon;
2219. register struct monst *mtmp;
2220. register struct attack *mattk;
2221. {
2222. 	int i, tmp;
2223. 
2224. 	for (i = 0; ; i++) {
2225. 	    if (i >= NATTK) return 1;
2226. 	    if (olduasmon->mattk[i].aatyp == AT_NONE ||
2227. 	    		olduasmon->mattk[i].aatyp == AT_BOOM) break;
2228. 	}
2229. 	if (olduasmon->mattk[i].damn)
2230. 	    tmp = d((int)olduasmon->mattk[i].damn,
2231. 				    (int)olduasmon->mattk[i].damd);
2232. 	else if(olduasmon->mattk[i].damd)
2233. 	    tmp = d((int)olduasmon->mlevel+1, (int)olduasmon->mattk[i].damd);
2234. 	else
2235. 	    tmp = 0;
2236. 
2237. 	/* These affect the enemy even if you were "killed" (rehumanized) */
2238. 	switch(olduasmon->mattk[i].adtyp) {
2239. 	    case AD_ACID:
2240. 		if (!rn2(2)) {
2241. 		    pline("%s is splashed by your acid!", Monnam(mtmp));
2242. 		    if (resists_acid(mtmp)) {
2243. 			pline("%s is not affected.", Monnam(mtmp));
2244. 			tmp = 0;
2245. 		    }
2246. 		} else tmp = 0;
2247. 		if(!rn2(30)) erode_armor(mtmp, TRUE);
2248. 		if(!rn2(6)) erode_weapon(mtmp, TRUE);
2249. 		goto assess_dmg;
2250. 	    case AD_STON: /* cockatrice */
2251. 		if (!resists_ston(mtmp) &&
2252. 		    (mattk->aatyp != AT_WEAP || !MON_WEP(mtmp)) &&
2253. 		    mattk->aatyp != AT_GAZE && mattk->aatyp != AT_EXPL &&
2254. 		    mattk->aatyp != AT_MAGC &&
2255. 		    !(mtmp->misc_worn_check & W_ARMG)) {
2256. 		    if(poly_when_stoned(mtmp->data)) {
2257. 			mon_to_stone(mtmp);
2258. 			return (1);
2259. 		    }
2260. 		    pline("%s turns to stone!", Monnam(mtmp));
2261. 		    stoned = 1;
2262. 		    xkilled(mtmp, 0);
2263. 		    if (mtmp->mhp > 0) return 1;
2264. 		    return 2;
2265. 		}
2266. 		return 1;
2267. 	    case AD_ENCH:	/* KMH -- remove enchantment (disenchanter) */
2268. 	    	if (otmp) {
2269. 	    	    (void) drain_item(otmp);
2270. 	    	    /* No message */
2271. 	    	}
2272. 	    	return (1);
2273. 	    default:
2274. 		break;
2275. 	}
2276. 	if (!Upolyd) return 1;
2277. 
2278. 	/* These affect the enemy only if you are still a monster */
2279. 	if (rn2(3)) switch(youmonst.data->mattk[i].adtyp) {
2280. 	    case AD_PHYS:
2281. 	    	if (youmonst.data->mattk[i].aatyp == AT_BOOM) {
2282. 	    	    pline("You explode!");
2283. 	    	    /* KMH, balance patch -- this is okay with unchanging */
2284. 	    	    rehumanize();
2285. 	    	    goto assess_dmg;
2286. 	    	}
2287. 	    	break;
2288. 	    case AD_PLYS: /* Floating eye */
2289. 		if (tmp > 127) tmp = 127;
2290. 		if (u.umonnum == PM_FLOATING_EYE) {
2291. 		    if (!rn2(4)) tmp = 127;
2292. 		    if (mtmp->mcansee && haseyes(mtmp->data) && rn2(3) &&
2293. 				(perceives(mtmp->data) || !Invis)) {
2294. 			if (Blind)
2295. 			    pline("As a blind %s, you cannot defend yourself.",
2296. 							youmonst.data->mname);
2297. 		        else {
2298. 			    if (mon_reflects(mtmp,
2299. 					    "Your gaze is reflected by %s %s."))
2300. 				return 1;
2301. 			    pline("%s is frozen by your gaze!", Monnam(mtmp));
2302. 			    mtmp->mcanmove = 0;
2303. 			    mtmp->mfrozen = tmp;
2304. 			    return 3;
2305. 			}
2306. 		    }
2307. 		} else { /* gelatinous cube */
2308. 		    pline("%s is frozen by you.", Monnam(mtmp));
2309. 		    mtmp->mcanmove = 0;
2310. 		    mtmp->mfrozen = tmp;
2311. 		    return 3;
2312. 		}
2313. 		return 1;
2314. 	    case AD_COLD: /* Brown mold or blue jelly */
2315. 		if (resists_cold(mtmp)) {
2316. 		    shieldeff(mtmp->mx, mtmp->my);
2317. 		    pline("%s is mildly chilly.", Monnam(mtmp));
2318. 		    golemeffects(mtmp, AD_COLD, tmp);
2319. 		    tmp = 0;
2320. 		    break;
2321. 		}
2322. 		pline("%s is suddenly very cold!", Monnam(mtmp));
2323. 		u.mh += tmp / 2;
2324. 		if (u.mhmax < u.mh) u.mhmax = u.mh;
2325. 		if (u.mhmax > ((youmonst.data->mlevel+1) * 8))
2326. 		    (void)split_mon(&youmonst, mtmp);
2327. 		break;
2328. 	    case AD_STUN: /* Yellow mold */
2329. 		if (!mtmp->mstun) {
2330. 		    mtmp->mstun = 1;
2331. 		    pline("%s staggers.", Monnam(mtmp));
2332. 		}
2333. 		tmp = 0;
2334. 		break;
2335. 	    case AD_FIRE: /* Red mold */
2336. 		if (resists_fire(mtmp)) {
2337. 		    shieldeff(mtmp->mx, mtmp->my);
2338. 		    pline("%s is mildly warm.", Monnam(mtmp));
2339. 		    golemeffects(mtmp, AD_FIRE, tmp);
2340. 		    tmp = 0;
2341. 		    break;
2342. 		}
2343. 		pline("%s is suddenly very hot!", Monnam(mtmp));
2344. 		break;
2345. 	    case AD_ELEC:
2346. 		if (resists_elec(mtmp)) {
2347. 		    shieldeff(mtmp->mx, mtmp->my);
2348. 		    pline("%s is slightly tingled.", Monnam(mtmp));
2349. 		    golemeffects(mtmp, AD_ELEC, tmp);
2350. 		    tmp = 0;
2351. 		    break;
2352. 		}
2353. 		pline("%s is jolted with your electricity!", Monnam(mtmp));
2354. 		break;
2355. 	    default: tmp = 0;
2356. 		break;
2357. 	}
2358. 	else tmp = 0;
2359. 
2360.     assess_dmg:
2361. 	if((mtmp->mhp -= tmp) <= 0) {
2362. 		pline("%s dies!", Monnam(mtmp));
2363. 		xkilled(mtmp,0);
2364. 		if (mtmp->mhp > 0) return 1;
2365. 		return 2;
2366. 	}
2367. 	return 1;
2368. }
2369. 
2370. #endif /* OVL1 */
2371. #ifdef OVLB
2372. 
2373. #include "edog.h"
2374. struct monst *
2375. cloneu()
2376. {
2377. 	register struct monst *mon;
2378. 	int mndx = monsndx(youmonst.data);
2379. 
2380. 	if (u.mh <= 1) return(struct monst *)0;
2381. 	if (mvitals[mndx].mvflags & G_EXTINCT) return(struct monst *)0;
2382. 	mon = makemon(youmonst.data, u.ux, u.uy, NO_MINVENT|MM_EDOG);
2383. 	mon = christen_monst(mon, plname);
2384. 	initedog(mon);
2385. 	mon->m_lev = youmonst.data->mlevel;
2386. 	mon->mhpmax = u.mhmax;
2387. 	mon->mhp = u.mh / 2;
2388. 	u.mh -= mon->mhp;
2389. 	flags.botl = 1;
2390. 	return(mon);
2391. }
2392. 
2393. #endif /* OVLB */
2394. 
2395. /*mhitu.c*/

Around Wikia's network

Random Wiki