Source:NetHack 2.3e/fight.c

From NetHackWiki
Jump to navigation Jump to search

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

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

Screenshots and source code from Hack are used under the CWI license.

1.    /*	SCCS Id: @(#)fight.c	2.3	87/12/12
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    
4.    #include	<stdio.h>
5.    #include	"hack.h"
6.    
7.    extern struct permonst li_dog, dog, la_dog;
8.    extern char *exclam(), *hcolor(), *xname();
9.    extern struct obj *mkobj_at();
10.   #ifdef KAA
11.   extern boolean stoned;
12.   extern boolean unweapon;
13.   extern char *nomovemsg, *defmonnam();
14.   extern struct monst *mkmon_at();
15.   #endif
16.   #ifdef RPH
17.   extern struct obj *mk_named_obj_at();
18.   #endif
19.   
20.   static boolean far_noise;
21.   static long noisetime;
22.   
23.   #ifdef STOOGES
24.   char random_joke[][30] = {"Why I ought a ...",
25.   			"You'll get what's comming!",
26.   			"I'll murder you!",
27.   			"I get no respect!",
28.   			"Right in the kisser!",
29.   			"Wait a minute!",
30.   			"Take it easy!",
31.   			"Alright already!",
32.   			"That's more like it!",
33.   			"Well excuse me!",
34.   			"Take that!",
35.   			"I'll fix you!",
36.   			"I'm sorry!",
37.   			"Your mama!",
38.   			"Shut up!",
39.   			"Listen you!",
40.   			"Pardon me!",
41.   			"Not that!",
42.   			"Quiet!",
43.   			"Relax!",
44.   			"Certainly!",
45.   			"Ouch!",
46.   			"What happened?",
47.   			"What was that for?",
48.   			"What's the matter with you?",
49.   			"Oh Yea?",
50.   			"Wise guy eh?",
51.   			"How about a knuckle sandwich?",
52.   			"You coward!",
53.   			"You rat you!",
54.   			"You chuckelhead!",
55.   			"You bonehead!",
56.   			"You numbskull!",
57.   			"Nyak Nyak Nyak ...",
58.   			"Woop Woop Woop Woop ..."};
59.   #define RAND_JOKE	35
60.   #endif
61.   
62.   /* hitmm returns 0 (miss), 1 (hit), or 2 (kill) */
63.   hitmm(magr,mdef) register struct monst *magr,*mdef; {
64.   register struct permonst *pa = magr->data, *pd = mdef->data;
65.   int hit;
66.   schar tmp;
67.   boolean vis;
68.   	if(!magr || !mdef) return(0);		/* mike@genat */
69.   	if(index("Eauy", pa->mlet)) return(0);
70.   	if(magr->mfroz) return(0);		/* riv05!a3 */
71.   	tmp = pd->ac + pa->mlevel;
72.   	if(mdef->mconf || mdef->mfroz || mdef->msleep){
73.   		tmp += 4;
74.   		if(mdef->msleep) mdef->msleep = 0;
75.   	}
76.   	hit = (tmp > rnd(20));
77.   	if(hit) mdef->msleep = 0;
78.   	vis = (cansee(magr->mx,magr->my) && cansee(mdef->mx,mdef->my));
79.   	if(vis){
80.   		char buf[BUFSZ];
81.   		if(mdef->mimic) seemimic(mdef);
82.   		if(magr->mimic) seemimic(magr);
83.   		(void) sprintf(buf,"%s %s", Monnam(magr),
84.   			hit ? "hits" : "misses");
85.   		pline("%s %s.", buf, monnam(mdef));
86.   	} else {
87.   		boolean farq = (dist(magr->mx, magr->my) > 15);
88.   		if(farq != far_noise || moves-noisetime > 10) {
89.   			far_noise = farq;
90.   			noisetime = moves;
91.   			pline("You hear some noises%s.",
92.   				farq ? " in the distance" : "");
93.   		}
94.   	}
95.   #ifdef STOOGES
96.   	if (hit && magr->isstooge) {
97.   		if (!rn2(6) && !index("afgvyF",mdef->data->mlet)) {
98.   			if(vis)
99.   				pline("%s is poked in the eye!", Monnam(mdef));
100.  			mdef->mcansee = 0;
101.  			mdef->mblinded += rnd(10);
102.  			if (mdef->mblinded <= 0) mdef->mblinded = 127;
103.  		} else if (vis && mdef->isstooge)
104.  			switch (rn2(100)) {
105.  			case 0 : pline("%s is shoved!", Monnam(mdef)); 
106.  				break;
107.  			case 1 : pline("%s is kicked!", Monnam(mdef));
108.  				break;
109.  			case 2 : pline("%s is slapped!", Monnam(mdef));
110.  				break;
111.  			case 3 : pline("%s is slugged!", Monnam(mdef));
112.  				break;
113.  			case 4 : pline("%s is punched!", Monnam(mdef));
114.  				break;
115.  			case 5 : pline("%s is pinched!", Monnam(mdef));
116.  				break;
117.  			case 6 : pline("But %s dodges!", monnam(mdef));
118.  				break;
119.  			case 7 : pline("But %s ducks!", monnam(mdef));
120.  				break;
121.  			case 8 : pline("%s gets a black eye!", Monnam(mdef));
122.  				break;
123.  			case 9 : pline("%s gets a bloody nose!", Monnam(mdef));
124.  				break;
125.  			case 10: pline("%s gets a broken tooth!", Monnam(mdef));
126.  				break;
127.  			}
128.  		if (!rn2(2))
129.  			stoogejoke();
130.  	}
131.  	if (magr->isstooge && mdef->isstooge)
132.  		return(hit);	/* stooges don't damage each other */
133.  #endif
134.  	if(hit){
135.  		if(magr->data->mlet == 'c' && !magr->cham) {
136.  			magr->mhpmax += 3;
137.  			if(vis) pline("%s is turned to stone!", Monnam(mdef));
138.  			else if(mdef->mtame)
139.       pline("You have a peculiarly sad feeling for a moment, then it passes.");
140.  			monstone(mdef);
141.  			hit = 2;
142.  		} else
143.  		if((mdef->mhp -= d(pa->damn,pa->damd)) < 1) {
144.  			magr->mhpmax += 1 + rn2(pd->mlevel+1);
145.  			if(magr->mtame && magr->mhpmax > 8*pa->mlevel){
146.  				if(pa == &li_dog) magr->data = pa = &dog;
147.  				else if(pa == &dog) magr->data = pa = &la_dog;
148.  			}
149.  			if(vis) pline("%s is killed!", Monnam(mdef));
150.  			else if(mdef->mtame)
151.  		pline("You have a sad feeling for a moment, then it passes.");
152.  			mondied(mdef);
153.  			hit = 2;
154.  		}
155.  		/* fixes a bug where max monster hp could overflow. */
156.  		if(magr->mhpmax <= 0) magr->mhpmax = 127;
157.  	}
158.  #ifdef KAA
159.  	if(hit == 1 && magr->data->mlet == 'Q') {
160.  		rloc(mdef);
161.  		if(vis && !cansee(mdef->mx,mdef->my))
162.  			pline("%s suddenly disappears!",Monnam(mdef));
163.  	}
164.  #endif
165.  	return(hit);
166.  }
167.  
168.  /* drop (perhaps) a cadaver and remove monster */
169.  mondied(mdef) register struct monst *mdef; {
170.  register struct permonst *pd = mdef->data;
171.  #ifdef KOPS
172.  	if(pd->mlet != 'K')
173.  #endif
174.  	{
175.  #if defined(ROCKMOLE) && defined(KJSMODS)
176.  	    /* if a giant rat is killed by a monster, do not make a 
177.  	     * corpse (like Keystone Kops above). */
178.  	    if(!(pd->mlet == 'r' && dlevel < 4))
179.  #endif
180.  	    if(!(pd->mlet == '&' && mdef->isdjinni))  /* no djinni corpse */
181.  	    if(!(pd->mlet == 'G' && mdef->isgremlin)) /* no gremlin corpse */
182.  		if(letter(pd->mlet) && rn2(3)) {
183.  		    if (pd->mlet == '1') panic("mondied: making obj '1'");
184.  #ifndef RPH
185.  		    (void) mkobj_at(pd->mlet,mdef->mx,mdef->my);
186.  #else
187.  		    (void) mk_named_obj_at(pd->mlet,mdef->mx,mdef->my,
188.  					   NAME(mdef), mdef->mnamelth);
189.  #endif
190.  		    if(cansee(mdef->mx,mdef->my)){
191.  			unpmon(mdef);
192.  			atl(mdef->mx,mdef->my,fobj->olet);
193.  		    }
194.  		    stackobj(fobj);
195.  		}
196.  		mondead(mdef);
197.  	}
198.  }
199.  
200.  /* drop a rock and remove monster */
201.  monstone(mdef)
202.  	register struct monst *mdef;
203.  {
204.  	extern char mlarge[];
205.  	if(index(mlarge, mdef->data->mlet))
206.  		mksobj_at(ENORMOUS_ROCK, mdef->mx, mdef->my);
207.  	else
208.  		mksobj_at(ROCK, mdef->mx, mdef->my);
209.  	if(cansee(mdef->mx, mdef->my)){
210.  		unpmon(mdef);
211.  		atl(mdef->mx,mdef->my,fobj->olet);
212.  	}
213.  	mondead(mdef);
214.  }
215.  		
216.  
217.  fightm(mtmp)
218.  	register struct monst *mtmp;
219.  {
220.  register struct monst *mon;
221.  
222.  	for(mon = fmon; mon; mon = mon->nmon)
223.  	    if(mon != mtmp) {
224.  		if(DIST(mon->mx,mon->my,mtmp->mx,mtmp->my) < 3)
225.  		    if(rn2(4))  return(hitmm(mtmp,mon));
226.  	    }
227.  	return(-1);
228.  }
229.  
230.  /* u is hit by sth, but not a monster */
231.  thitu(tlev,dam,name)
232.  	register tlev,dam;
233.  	register char *name;
234.  {
235.  	char buf[BUFSZ];
236.  
237.  	setan(name,buf);
238.  	if(u.uac + tlev <= rnd(20)) {
239.  		if(Blind) pline("It misses.");
240.  		else pline("You are almost hit by %s!", buf);
241.  		return(0);
242.  	} else {
243.  		if(Blind) pline("You are hit!");
244.  		else pline("You are hit by %s!", buf);
245.  		losehp(dam,name);
246.  		return(1);
247.  	}
248.  }
249.  
250.  #ifdef KAA
251.  char mlarge[] = "bCDdegIlmnoPSsTUwY',&9";
252.  #else
253.  char mlarge[] = "bCDdegIlmnoPSsTUwY',&";
254.  #endif
255.  
256.  boolean
257.  hmon(mon,obj,thrown)	/* return TRUE if mon still alive */
258.  register struct monst *mon;
259.  register struct obj *obj;
260.  register thrown;
261.  {
262.  	register tmp;
263.  	boolean hittxt = FALSE;
264.  
265.  #ifdef KAA
266.  	stoned = FALSE;		/* this refers to the thing hit, not you */
267.  #endif
268.  	if(!obj){
269.  #ifdef KAA
270.  /* Note that c, y, and F can never wield weapons anyway */
271.  	  if (u.usym == 'c' && mon->data->mlet != 'c') {
272.  	       pline("You turn %s to stone!", monnam(mon));
273.  	       stoned = TRUE;
274.  	       xkilled(mon,0);
275.  	       return(FALSE);
276.  	  } else if (u.usym == 'y' && mon->data->mlet != 'y') {
277.  	       pline("%s is blinded by your flash of light!",Monnam(mon));
278.  	       if (!mon->mblinded) {
279.  		    mon->mblinded += rn2(25);
280.  		    mon->mcansee = 0;
281.  	       }
282.  	       rehumanize();
283.  	       return(TRUE);
284.  	  } else if (u.usym == 'F') {
285.  	       pline("You explode!");
286.  	       if (!index("gFY",mon->data->mlet)) {
287.  		    pline("%s gets blasted!", Monnam(mon));
288.  		    mon->mhp -= d(6,6);
289.  		    rehumanize();
290.  		    if (mon->mhp <= 0) {
291.  			 killed(mon);
292.  			 return(FALSE);
293.  		    } else return(TRUE);
294.  	       } else {
295.  		    pline("The blast doesn't seem to affect %s.", monnam(mon));
296.  		    rehumanize();
297.  		    return(TRUE);
298.  	       }
299.  	  } else if (index("P,'", u.usym) && u.uhunger < 1500
300.  		  && !u.uswallow && mon->data->mlet != 'c') {
301.  	       static char msgbuf[BUFSZ];
302.  	       pline("You swallow %s whole!", monnam(mon));
303.  	       u.uhunger += 20*mon->mhpmax;
304.  	       newuhs(FALSE);
305.  	       xkilled(mon,2);
306.  	       if (tmp = mon->mhpmax/5) {
307.  		    nomul(-tmp);
308.  		    (void)sprintf(msgbuf, "You finished digesting %s.",
309.  			 monnam(mon));
310.  		    nomovemsg = msgbuf;
311.  	       }
312.  	       return(FALSE);
313.  	  } else if (u.usym != '@') {
314.  	       if (u.usym == '&' && !rn2(5)) {
315.  		    struct monst *dtmp;
316.  		    pline("Some hell-p has arrived!");
317.  		    if((dtmp = mkmon_at('&',u.ux,u.uy)))
318.  			(void)tamedog(dtmp,(struct obj *)0);
319.  	       }
320.  	       tmp = d(mons[u.umonnum].damn, mons[u.umonnum].damd);
321.  	  } else
322.  #endif
323.  		tmp = rnd(2);	/* attack with bare hands */
324.  #ifdef KAA
325.  		if (mon->data->mlet == 'c' && !uarmg && u.usym != 'c'){
326.  #else
327.  		if(mon->data->mlet == 'c' && !uarmg){
328.  #endif
329.  			pline("You hit the cockatrice with your bare hands.");
330.  			pline("You turn to stone ...");
331.  			done_in_by(mon);
332.  		}
333.  	} else if(obj->olet == WEAPON_SYM || obj->otyp == PICK_AXE) {
334.  	    if(obj == uwep && (obj->otyp > SPEAR || obj->otyp < BOOMERANG))
335.  		tmp = rnd(2);
336.  	    else {
337.  		if(index(mlarge, mon->data->mlet)) {
338.  		    tmp = rnd(objects[obj->otyp].wldam);
339.  		    switch (obj->otyp) {
340.  			case SLING_BULLET:
341.  			case CROSSBOW_BOLT:
342.  			case MORNING_STAR:
343.  			case PARTISAN:
344.  			case BROAD_SWORD:	tmp += 1; break;
345.  
346.  			case FLAIL:
347.  			case RANSEUR:
348.  			case VOULGE:		tmp += rnd(4); break;
349.  
350.  			case HALBERD:
351.  			case SPETUM:		tmp += rnd(6); break;
352.  
353.  			case BARDICHE:
354.  			case TRIDENT:		tmp += d(2,4); break;
355.  
356.  			case TWO_HANDED_SWORD: 
357.  			case KATANA: 		tmp += d(2,6); break;
358.  		    }
359.  		} else {
360.  		    tmp = rnd(objects[obj->otyp].wsdam);
361.  		    switch (obj->otyp) {
362.  			case SLING_BULLET:
363.  			case CROSSBOW_BOLT:
364.  			case MACE:
365.  			case FLAIL:
366.  			case SPETUM:
367.  			case TRIDENT:		tmp += 1; break;
368.  
369.  			case BARDICHE:
370.  			case BILL_GUISARME:
371.  			case GUISARME:
372.  			case LUCERN_HAMMER:
373.  			case MORNING_STAR:
374.  			case RANSEUR:
375.  			case BROAD_SWORD:
376.  			case VOULGE:		tmp += rnd(4); break;
377.  		    }
378.  		}
379.  		tmp += obj->spe;
380.  #ifdef KAA
381.  		if(obj->olet == WEAPON_SYM && obj->dknown && index("VWZ &",
382.  				mon->data->mlet)) tmp += rn2(4);
383.  #endif
384.  		if(!thrown && obj == uwep && obj->otyp == BOOMERANG
385.  		 && !rn2(3)){
386.  		  pline("As you hit %s, the boomerang breaks into splinters.",
387.  				monnam(mon));
388.  			freeinv(obj);
389.  			setworn((struct obj *) 0, obj->owornmask);
390.  			obfree(obj, (struct obj *) 0);
391.  			tmp++;
392.  		}
393.  	    }
394.  #ifdef BVH
395.  	    if(!strcmp(ONAME(obj), "Excalibur")) tmp += rnd(10);
396.  	    else
397.  #endif
398.  		if(obj->otyp == KATANA
399.  		   && !strcmp(ONAME(obj), "Snickersnee")) tmp += rnd(5);
400.  
401.  	    else if(mon->data->mlet == 'O' && obj->otyp == TWO_HANDED_SWORD
402.  		    && !strcmp(ONAME(obj), "Orcrist"))	tmp += rnd(10);
403.  
404.  	    else if((obj->otyp == SHORT_SWORD || obj->otyp == DAGGER)
405.  		   && !strcmp(ONAME(obj), "Sting")) tmp += rnd(5);
406.  
407.  	} else	switch(obj->otyp) {
408.  		case HEAVY_IRON_BALL:
409.  			tmp = rnd(25); break;
410.  		case ENORMOUS_ROCK:
411.  			tmp = rnd(20); break;
412.  #ifdef RPH
413.  		case MIRROR:
414.  			pline("You break your mirror.  That's bad luck!");
415.  		        change_luck(-2);
416.  			freeinv(obj);
417.  			if(obj->owornmask)
418.  				setworn((struct obj *) 0, obj->owornmask);
419.  			obfree(obj, (struct obj *) 0);
420.  			return(TRUE);
421.  #endif
422.  		case EXPENSIVE_CAMERA:
423.  	pline("You succeed in destroying your camera. Congratulations!");
424.  			freeinv(obj);
425.  			if(obj->owornmask)
426.  				setworn((struct obj *) 0, obj->owornmask);
427.  			obfree(obj, (struct obj *) 0);
428.  			return(TRUE);
429.  		case DEAD_COCKATRICE:	/* fixed by polder@cs.vu.nl */
430.  			pline("You hit %s with the cockatrice corpse.",
431.  				monnam(mon));
432.  			if(mon->data->mlet == 'c') {
433.  				tmp = 1;
434.  				hittxt = TRUE;
435.  				break;
436.  			}
437.  			pline ("%s is turned to stone!", Monnam(mon));
438.  #ifdef KAA
439.  			stoned = TRUE;
440.  			xkilled(mon,0);
441.  #else
442.  			killed(mon);
443.  #endif
444.  			return(FALSE);
445.  		case CLOVE_OF_GARLIC:		/* no effect against demons */
446.  			if(index(UNDEAD, mon->data->mlet))
447.  				mon->mflee = 1;
448.  			tmp = 1;
449.  			break;
450.  		default:
451.  			/* non-weapons can damage because of their weight */
452.  			/* (but not too much) */
453.  			tmp = obj->owt/10;
454.  			if(tmp < 1) tmp = 1;
455.  			else tmp = rnd(tmp);
456.  			if(tmp > 6) tmp = 6;
457.  		}
458.  
459.  	/****** NOTE: perhaps obj is undefined!! (if !thrown && BOOMERANG) */
460.  
461.  	tmp += u.udaminc + dbon();
462.  	if(u.uswallow) {
463.  		if((tmp -= u.uswldtim) <= 0) {
464.  			pline("Your arms are no longer able to hit.");
465.  			return(TRUE);
466.  		}
467.  	}
468.  	if(tmp < 1) tmp = 1;
469.  	mon->mhp -= tmp;
470.  	if(mon->mhp < 1) {
471.  		killed(mon);
472.  		return(FALSE);
473.  	}
474.  	if(mon->mtame && (!mon->mflee || mon->mfleetim)) {
475.  		mon->mflee = 1;			/* Rick Richardson */
476.  		mon->mfleetim += 10*rnd(tmp);
477.  	}
478.  
479.  	if(!hittxt) {
480.  		if(thrown)
481.  			/* this assumes that we cannot throw plural things */
482.  			hit( xname(obj)  /* or: objects[obj->otyp].oc_name */,
483.  				mon, exclam(tmp) );
484.  		else if(Blind)
485.  			pline("You hit it.");
486.  		else
487.  			pline("You hit %s%s", monnam(mon), exclam(tmp));
488.  	}
489.  
490.  	if(u.umconf && !thrown) {
491.  		if(!Blind) {
492.  			pline("Your hands stop glowing %s.",
493.  			Hallucination ? hcolor() : "blue");
494.  		}
495.  		if (!resist(mon, '+', 0, NOTELL)) mon->mconf = 1;
496.  		if(!mon->mfroz && !mon->msleep && !Blind && mon->mconf)
497.  			pline("%s appears confused.",Monnam(mon));
498.  		u.umconf = 0;
499.  	}
500.  	if(!thrown && rn2(2) && index("VW",u.usym) &&
501.  	   !index("VW",mon->data->mlet)){
502.  		int tmp=d(2,6);
503.  		pline("%s suddenly seems weaker!",Monnam(mon));
504.  		mon->mhpmax -= tmp;
505.  		if ((mon->mhp -= tmp) <= 0) {
506.  			pline("%s dies!",Monnam(mon));
507.  			xkilled(mon,0);
508.  			return(FALSE);
509.  		}
510.  	}
511.  	return(TRUE);	/* mon still alive */
512.  }
513.  
514.  /* try to attack; return FALSE if monster evaded */
515.  /* u.dx and u.dy must be set */
516.  attack(mtmp)
517.  register struct monst *mtmp;
518.  {
519.  	schar tmp;
520.  	boolean malive = TRUE;
521.  	register struct permonst *mdat;
522.  	mdat = mtmp->data;
523.  
524.  #ifdef KAA
525.  	if(unweapon) {
526.  		unweapon=FALSE;
527.  		if(uwep)
528.  			pline("You begin bashing monsters with your %s.",
529.  				aobjnam(uwep,(char *)0));
530.  	}
531.  #endif
532.  	u_wipe_engr(3);   /* andrew@orca: prevent unlimited pick-axe attacks */
533.  
534.  	if(mdat->mlet == 'L' && !mtmp->mfroz && !mtmp->msleep &&
535.  	   !mtmp->mconf && mtmp->mcansee && !rn2(7) &&
536.  	   (m_move(mtmp, 0) == 2 /* he died */ || /* he moved: */
537.  		mtmp->mx != u.ux+u.dx || mtmp->my != u.uy+u.dy))
538.  		return(FALSE);
539.  #ifdef SAFE_ATTACK
540.  	/* This section of code provides protection against accidentally
541.  	 * hitting peaceful (like '@') and tame (like 'd') monsters.
542.  	 * There is protection only if you're not blind, confused or
543.  	 * invisible.
544.  	 */
545.  	/*  changes by wwp 5/16/85 */
546.  	if (!Blind && !Confusion && !Hallucination
547.  	    && mdat->mlet == 'd' && mtmp->mtame) {
548.  		char *dname;		/* added by Janet Walz (walz@mimsy) */
549.  		mtmp->mflee = 1;
550.  		mtmp->mfleetim = rnd(6);
551.  		if(*(dname = NAME(mtmp)))
552.  		    pline("You stop to avoid hitting %s.",dname);
553.  		else
554.  		    pline("You stop to avoid hitting your dog.");
555.  		return(TRUE);
556.  	}
557.  	if (flags.confirm && (mtmp->mpeaceful || mtmp->mtame) && ! Confusion
558.  	    && !Hallucination && !Invisible)
559.  
560.  		if (Blind ? Telepat : (!mtmp->minvis || See_invisible)) {
561.  			pline("Really attack %s?", monnam(mtmp));
562.  			(void) fflush(stdout);
563.  			if (readchar() != 'y') {
564.  				flags.move = 0;
565.  				return(TRUE);
566.  			}
567.  		}
568.  #endif /* SAFE_ATTACK /**/
569.  
570.  	if(mtmp->mimic){
571.  		if(!u.ustuck && !mtmp->mflee) u.ustuck = mtmp;
572.  		if (levl[u.ux+u.dx][u.uy+u.dy].scrsym == DOOR_SYM)
573.  		{
574.  		    if (okdoor(u.ux+u.dx, u.uy+u.dy))
575.  			pline("The door actually was %s.", defmonnam(mtmp));
576.  		    else
577.  			pline("That spellbook was %s.", defmonnam(mtmp));
578.  		}
579.  		else if (levl[u.ux+u.dx][u.uy+u.dy].scrsym == GOLD_SYM)
580.  			pline("The chest was %s!", defmonnam(mtmp));
581.  		else
582.  			pline("Wait! That's %s!",defmonnam(mtmp));
583.  		wakeup(mtmp);	/* clears mtmp->mimic */
584.  		return(TRUE);
585.  	}
586.  
587.  	wakeup(mtmp);
588.  
589.  	if(mtmp->mhide && mtmp->mundetected){
590.  		register struct obj *obj;
591.  
592.  		mtmp->mundetected = 0;
593.  		if((obj = o_at(mtmp->mx,mtmp->my)) && !Blind)
594.  			pline("Wait! There's %s hiding under %s!",
595.  				defmonnam(mtmp), doname(obj));
596.  		return(TRUE);
597.  	}
598.  #ifdef KAA
599.  	tmp = u.uluck + (u.mtimedone ? mons[u.umonnum].mlevel : u.ulevel) +
600.  			mdat->ac + abon();
601.  	if (u.usym=='y' || u.usym=='F') tmp=100;
602.  	if (index("uEa",u.usym)) return(TRUE);
603.  #else
604.  	tmp = u.uluck + u.ulevel + mdat->ac + abon();
605.  #endif
606.  	if(uwep) {
607.  #ifdef KAA	/* Blessed weapons used against undead or demons */
608.  		if(uwep->olet == WEAPON_SYM && uwep->dknown && index("VWZ &",
609.  			mtmp->data->mlet)) tmp += 2;
610.  #endif
611.  		if(uwep->olet == WEAPON_SYM || uwep->otyp == PICK_AXE)
612.  			tmp += uwep->spe;
613.  #ifdef  BVH
614.  		if(!strcmp(ONAME(uwep),"Excalibur")) tmp += 5;
615.  #endif
616.  		if(uwep->otyp == TWO_HANDED_SWORD) tmp -= 1;
617.  		else if(uwep->otyp == KATANA) tmp += 1;
618.  		else if(uwep->otyp == DAGGER ||
619.  			uwep->otyp == SHURIKEN) tmp += 2;
620.  		else if(uwep->otyp == CRYSKNIFE) tmp += 3;
621.  		else if(uwep->otyp == SPEAR &&
622.  			index("XDne", mdat->mlet)) tmp += 2;
623.  	}
624.  	if(mtmp->msleep) {
625.  		mtmp->msleep = 0;
626.  		tmp += 2;
627.  	}
628.  	if(mtmp->mfroz) {
629.  		tmp += 4;
630.  		if(!rn2(10)) mtmp->mfroz = 0;
631.  	}
632.  	if(mtmp->mflee) tmp += 2;
633.  	if(u.utrap) tmp -= 3;
634.  
635.  	/* with a lot of luggage, your agility diminishes */
636.  	tmp -= (inv_weight() + 40)/20;
637.  
638.  	if(tmp <= rnd(20) && !u.uswallow){
639.  		if(Blind) pline("You miss it.");
640.  		else pline("You miss %s.",monnam(mtmp));
641.  	} else {
642.  		/* we hit the monster; be careful: it might die! */
643.  
644.  		if((malive = hmon(mtmp,uwep,0)) == TRUE) {
645.  		/* monster still alive */
646.  			if(!rn2(25) && mtmp->mhp < mtmp->mhpmax/2) {
647.  				mtmp->mflee = 1;
648.  				if(!rn2(3)) mtmp->mfleetim = rnd(100);
649.  				if(u.ustuck == mtmp && !u.uswallow)
650.  					u.ustuck = 0;
651.  			}
652.  #ifndef NOWORM
653.  			if(mtmp->wormno)
654.  				cutworm(mtmp, u.ux+u.dx, u.uy+u.dy,
655.  					uwep ? uwep->otyp : 0);
656.  #endif
657.  		}
658.  		if(mdat->mlet == 'a') {
659.  			if(rn2(2)) {
660.  				if (Blind) pline("You are splashed!");
661.  				else	   pline("You are splashed by %s's acid!",monnam(mtmp));
662.  				if (u.usym != 'a') {
663.  					losehp_m(rnd(6), mtmp);
664.  					if(!rn2(30)) corrode_armor();
665.  				}
666.  			}
667.  			if(!rn2(6)) corrode_weapon();
668.  		}
669.  	}
670.  #ifdef KAA
671.  	if (malive) if (u.usym=='N' && mtmp->minvent) {
672.  		struct obj *otmp, *addinv();
673.  		otmp = mtmp->minvent;
674.  		mtmp->minvent = otmp->nobj;
675.  		otmp = addinv(otmp);
676.  		pline("You steal:");
677.  		prinv(otmp);
678.  	} else if (u.usym=='L' && mtmp->mgold) {
679.  		u.ugold += mtmp->mgold;
680.  		mtmp->mgold = 0;
681.  		pline("Your purse feels heavier.");
682.  	} else if (u.usym=='Q') rloc(mtmp);
683.  #endif
684.  	if(malive && mdat->mlet == 'E' && canseemon(mtmp)
685.  	   && !mtmp->mcan && rn2(3)) {
686.  	    if(mtmp->mcansee) {
687.  	      pline("You are frozen by %s's gaze!",monnam(mtmp));
688.  	      nomul((u.ulevel > 6 || rn2(4)) ? rn1(20,-21) : -200);
689.  	    } else {
690.  	      pline("%s cannot defend itself.", Amonnam(mtmp,"blinded"));
691.  	      if(!rn2(500)) change_luck(-1);
692.  	    }
693.  	}
694.  	return(TRUE);
695.  }
696.  
697.  #ifdef STOOGES
698.  stoogejoke() {		/* have the stooges say something funny */
699.  	pline("'%s'", random_joke[rn2(RAND_JOKE)]);
700.  }
701.  #endif