xref: /netbsd-src/games/hack/hack.mhitu.c (revision 1fa8a9a633c6f43b2e4cc46b520a81da0c53b6da)
1*1fa8a9a6Sdholland /*	$NetBSD: hack.mhitu.c,v 1.7 2009/06/07 18:30:39 dholland Exp $	*/
23ea4a95cSchristos 
302ded532Smycroft /*
41c7f94e5Sjsm  * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
51c7f94e5Sjsm  * Amsterdam
61c7f94e5Sjsm  * All rights reserved.
71c7f94e5Sjsm  *
81c7f94e5Sjsm  * Redistribution and use in source and binary forms, with or without
91c7f94e5Sjsm  * modification, are permitted provided that the following conditions are
101c7f94e5Sjsm  * met:
111c7f94e5Sjsm  *
121c7f94e5Sjsm  * - Redistributions of source code must retain the above copyright notice,
131c7f94e5Sjsm  * this list of conditions and the following disclaimer.
141c7f94e5Sjsm  *
151c7f94e5Sjsm  * - Redistributions in binary form must reproduce the above copyright
161c7f94e5Sjsm  * notice, this list of conditions and the following disclaimer in the
171c7f94e5Sjsm  * documentation and/or other materials provided with the distribution.
181c7f94e5Sjsm  *
191c7f94e5Sjsm  * - Neither the name of the Stichting Centrum voor Wiskunde en
201c7f94e5Sjsm  * Informatica, nor the names of its contributors may be used to endorse or
211c7f94e5Sjsm  * promote products derived from this software without specific prior
221c7f94e5Sjsm  * written permission.
231c7f94e5Sjsm  *
241c7f94e5Sjsm  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
251c7f94e5Sjsm  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
261c7f94e5Sjsm  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
271c7f94e5Sjsm  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
281c7f94e5Sjsm  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
291c7f94e5Sjsm  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
301c7f94e5Sjsm  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
311c7f94e5Sjsm  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
321c7f94e5Sjsm  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
331c7f94e5Sjsm  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
341c7f94e5Sjsm  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
351c7f94e5Sjsm  */
361c7f94e5Sjsm 
371c7f94e5Sjsm /*
381c7f94e5Sjsm  * Copyright (c) 1982 Jay Fenlason <hack@gnu.org>
391c7f94e5Sjsm  * All rights reserved.
401c7f94e5Sjsm  *
411c7f94e5Sjsm  * Redistribution and use in source and binary forms, with or without
421c7f94e5Sjsm  * modification, are permitted provided that the following conditions
431c7f94e5Sjsm  * are met:
441c7f94e5Sjsm  * 1. Redistributions of source code must retain the above copyright
451c7f94e5Sjsm  *    notice, this list of conditions and the following disclaimer.
461c7f94e5Sjsm  * 2. Redistributions in binary form must reproduce the above copyright
471c7f94e5Sjsm  *    notice, this list of conditions and the following disclaimer in the
481c7f94e5Sjsm  *    documentation and/or other materials provided with the distribution.
491c7f94e5Sjsm  * 3. The name of the author may not be used to endorse or promote products
501c7f94e5Sjsm  *    derived from this software without specific prior written permission.
511c7f94e5Sjsm  *
521c7f94e5Sjsm  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
531c7f94e5Sjsm  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
541c7f94e5Sjsm  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
551c7f94e5Sjsm  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
561c7f94e5Sjsm  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
571c7f94e5Sjsm  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
581c7f94e5Sjsm  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
591c7f94e5Sjsm  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
601c7f94e5Sjsm  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
611c7f94e5Sjsm  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6202ded532Smycroft  */
6302ded532Smycroft 
643ea4a95cSchristos #include <sys/cdefs.h>
6502ded532Smycroft #ifndef lint
66*1fa8a9a6Sdholland __RCSID("$NetBSD: hack.mhitu.c,v 1.7 2009/06/07 18:30:39 dholland Exp $");
6702ded532Smycroft #endif				/* not lint */
6861f28255Scgd 
6961f28255Scgd #include "hack.h"
703ea4a95cSchristos #include "extern.h"
7161f28255Scgd 
7261f28255Scgd /*
7361f28255Scgd  * mhitu: monster hits you
7461f28255Scgd  *	  returns 1 if monster dies (e.g. 'y', 'F'), 0 otherwise
7561f28255Scgd  */
763ea4a95cSchristos int
mhitu(struct monst * mtmp)77*1fa8a9a6Sdholland mhitu(struct monst *mtmp)
7861f28255Scgd {
79ab8b6343Sjsm 	const struct permonst *mdat = mtmp->data;
803ea4a95cSchristos 	int             tmp, ctmp;
8161f28255Scgd 
8261f28255Scgd 	nomul(0);
8361f28255Scgd 
8461f28255Scgd 	/* If swallowed, can only be affected by hissers and by u.ustuck */
8561f28255Scgd 	if (u.uswallow) {
8661f28255Scgd 		if (mtmp != u.ustuck) {
8761f28255Scgd 			if (mdat->mlet == 'c' && !rn2(13)) {
8861f28255Scgd 				pline("Outside, you hear %s's hissing!",
8961f28255Scgd 				      monnam(mtmp));
9061f28255Scgd 				pline("%s gets turned to stone!",
9161f28255Scgd 				      Monnam(u.ustuck));
9261f28255Scgd 				pline("And the same fate befalls you.");
9361f28255Scgd 				done_in_by(mtmp);
9461f28255Scgd 				/* "notreached": not return(1); */
9561f28255Scgd 			}
9661f28255Scgd 			return (0);
9761f28255Scgd 		}
9861f28255Scgd 		switch (mdat->mlet) {	/* now mtmp == u.ustuck */
9961f28255Scgd 		case ',':
10061f28255Scgd 			youswld(mtmp, (u.uac > 0) ? u.uac + 4 : 4,
10161f28255Scgd 				5, "The trapper");
10261f28255Scgd 			break;
10361f28255Scgd 		case '\'':
10461f28255Scgd 			youswld(mtmp, rnd(6), 7, "The lurker above");
10561f28255Scgd 			break;
10661f28255Scgd 		case 'P':
10761f28255Scgd 			youswld(mtmp, d(2, 4), 12, "The purple worm");
10861f28255Scgd 			break;
10961f28255Scgd 		default:
11061f28255Scgd 			/* This is not impossible! */
11161f28255Scgd 			pline("The mysterious monster totally digests you.");
11261f28255Scgd 			u.uhp = 0;
11361f28255Scgd 		}
1143ea4a95cSchristos 		if (u.uhp < 1)
1153ea4a95cSchristos 			done_in_by(mtmp);
11661f28255Scgd 		return (0);
11761f28255Scgd 	}
11861f28255Scgd 	if (mdat->mlet == 'c' && Stoned)
11961f28255Scgd 		return (0);
12061f28255Scgd 
12161f28255Scgd 	/* make eels visible the moment they hit/miss us */
12261f28255Scgd 	if (mdat->mlet == ';' && mtmp->minvis && cansee(mtmp->mx, mtmp->my)) {
12361f28255Scgd 		mtmp->minvis = 0;
12461f28255Scgd 		pmon(mtmp);
12561f28255Scgd 	}
1263ea4a95cSchristos 	if (!strchr("1&DuxynNF", mdat->mlet))
12761f28255Scgd 		tmp = hitu(mtmp, d(mdat->damn, mdat->damd));
12861f28255Scgd 	else
12961f28255Scgd 		tmp = 0;
1303ea4a95cSchristos 	if (strchr(UNDEAD, mdat->mlet) && midnight())
13161f28255Scgd 		tmp += hitu(mtmp, d(mdat->damn, mdat->damd));
13261f28255Scgd 
13361f28255Scgd 	ctmp = tmp && !mtmp->mcan &&
13461f28255Scgd 		(!uarm || objects[uarm->otyp].a_can < rnd(3) || !rn2(50));
13561f28255Scgd 	switch (mdat->mlet) {
13661f28255Scgd 	case '1':
1373ea4a95cSchristos 		if (wiz_hit(mtmp))
1383ea4a95cSchristos 			return (1);	/* he disappeared */
13961f28255Scgd 		break;
14061f28255Scgd 	case '&':
14161f28255Scgd 		if (!mtmp->cham && !mtmp->mcan && !rn2(13)) {
14261f28255Scgd 			(void) makemon(PM_DEMON, u.ux, u.uy);
14361f28255Scgd 		} else {
14461f28255Scgd 			(void) hitu(mtmp, d(2, 6));
14561f28255Scgd 			(void) hitu(mtmp, d(2, 6));
14661f28255Scgd 			(void) hitu(mtmp, rnd(3));
14761f28255Scgd 			(void) hitu(mtmp, rnd(3));
14861f28255Scgd 			(void) hitu(mtmp, rn1(4, 2));
14961f28255Scgd 		}
15061f28255Scgd 		break;
15161f28255Scgd 	case ',':
1523ea4a95cSchristos 		if (tmp)
1533ea4a95cSchristos 			justswld(mtmp, "The trapper");
15461f28255Scgd 		break;
15561f28255Scgd 	case '\'':
1563ea4a95cSchristos 		if (tmp)
1573ea4a95cSchristos 			justswld(mtmp, "The lurker above");
15861f28255Scgd 		break;
15961f28255Scgd 	case ';':
16061f28255Scgd 		if (ctmp) {
16161f28255Scgd 			if (!u.ustuck && !rn2(10)) {
16261f28255Scgd 				pline("%s swings itself around you!",
16361f28255Scgd 				      Monnam(mtmp));
16461f28255Scgd 				u.ustuck = mtmp;
16561f28255Scgd 			} else if (u.ustuck == mtmp &&
16661f28255Scgd 				   levl[mtmp->mx][mtmp->my].typ == POOL) {
16761f28255Scgd 				pline("%s drowns you ...", Monnam(mtmp));
16861f28255Scgd 				done("drowned");
16961f28255Scgd 			}
17061f28255Scgd 		}
17161f28255Scgd 		break;
17261f28255Scgd 	case 'A':
17361f28255Scgd 		if (ctmp && rn2(2)) {
17461f28255Scgd 			if (Poison_resistance)
17561f28255Scgd 				pline("The sting doesn't seem to affect you.");
17661f28255Scgd 			else {
17761f28255Scgd 				pline("You feel weaker!");
17861f28255Scgd 				losestr(1);
17961f28255Scgd 			}
18061f28255Scgd 		}
18161f28255Scgd 		break;
18261f28255Scgd 	case 'C':
18361f28255Scgd 		(void) hitu(mtmp, rnd(6));
18461f28255Scgd 		break;
18561f28255Scgd 	case 'c':
18661f28255Scgd 		if (!rn2(5)) {
18761f28255Scgd 			pline("You hear %s's hissing!", monnam(mtmp));
18861f28255Scgd 			if (ctmp || !rn2(20) || (flags.moonphase == NEW_MOON
18961f28255Scgd 					       && !carrying(DEAD_LIZARD))) {
19061f28255Scgd 				Stoned = 5;
19161f28255Scgd 				/* pline("You get turned to stone!"); */
19261f28255Scgd 				/* done_in_by(mtmp); */
19361f28255Scgd 			}
19461f28255Scgd 		}
19561f28255Scgd 		break;
19661f28255Scgd 	case 'D':
19761f28255Scgd 		if (rn2(6) || mtmp->mcan) {
19861f28255Scgd 			(void) hitu(mtmp, d(3, 10));
19961f28255Scgd 			(void) hitu(mtmp, rnd(8));
20061f28255Scgd 			(void) hitu(mtmp, rnd(8));
20161f28255Scgd 			break;
20261f28255Scgd 		}
20361f28255Scgd 		kludge("%s breathes fire!", "The dragon");
20461f28255Scgd 		buzz(-1, mtmp->mx, mtmp->my, u.ux - mtmp->mx, u.uy - mtmp->my);
20561f28255Scgd 		break;
20661f28255Scgd 	case 'd':
20761f28255Scgd 		(void) hitu(mtmp, d(2, (flags.moonphase == FULL_MOON) ? 3 : 4));
20861f28255Scgd 		break;
20961f28255Scgd 	case 'e':
21061f28255Scgd 		(void) hitu(mtmp, d(3, 6));
21161f28255Scgd 		break;
21261f28255Scgd 	case 'F':
2133ea4a95cSchristos 		if (mtmp->mcan)
2143ea4a95cSchristos 			break;
21561f28255Scgd 		kludge("%s explodes!", "The freezing sphere");
2163ea4a95cSchristos 		if (Cold_resistance)
2173ea4a95cSchristos 			pline("You don't seem affected by it.");
21861f28255Scgd 		else {
21961f28255Scgd 			xchar           dn;
22061f28255Scgd 			if (17 - (u.ulevel / 2) > rnd(20)) {
22161f28255Scgd 				pline("You get blasted!");
22261f28255Scgd 				dn = 6;
22361f28255Scgd 			} else {
22461f28255Scgd 				pline("You duck the blast...");
22561f28255Scgd 				dn = 3;
22661f28255Scgd 			}
22761f28255Scgd 			losehp_m(d(dn, 6), mtmp);
22861f28255Scgd 		}
22961f28255Scgd 		mondead(mtmp);
23061f28255Scgd 		return (1);
23161f28255Scgd 	case 'g':
23261f28255Scgd 		if (ctmp && multi >= 0 && !rn2(3)) {
23361f28255Scgd 			kludge("You are frozen by %ss juices", "the cube'");
23461f28255Scgd 			nomul(-rnd(10));
23561f28255Scgd 		}
23661f28255Scgd 		break;
23761f28255Scgd 	case 'h':
23861f28255Scgd 		if (ctmp && multi >= 0 && !rn2(5)) {
23961f28255Scgd 			nomul(-rnd(10));
24061f28255Scgd 			kludge("You are put to sleep by %ss bite!",
24161f28255Scgd 			       "the homunculus'");
24261f28255Scgd 		}
24361f28255Scgd 		break;
24461f28255Scgd 	case 'j':
24561f28255Scgd 		tmp = hitu(mtmp, rnd(3));
24661f28255Scgd 		tmp &= hitu(mtmp, rnd(3));
24761f28255Scgd 		if (tmp) {
24861f28255Scgd 			(void) hitu(mtmp, rnd(4));
24961f28255Scgd 			(void) hitu(mtmp, rnd(4));
25061f28255Scgd 		}
25161f28255Scgd 		break;
25261f28255Scgd 	case 'k':
25361f28255Scgd 		if ((hitu(mtmp, rnd(4)) || !rn2(3)) && ctmp) {
25461f28255Scgd 			poisoned("bee's sting", mdat->mname);
25561f28255Scgd 		}
25661f28255Scgd 		break;
25761f28255Scgd 	case 'L':
2583ea4a95cSchristos 		if (tmp)
2593ea4a95cSchristos 			stealgold(mtmp);
26061f28255Scgd 		break;
26161f28255Scgd 	case 'N':
26261f28255Scgd 		if (mtmp->mcan && !Blind) {
26361f28255Scgd 			pline("%s tries to seduce you, but you seem not interested.",
26461f28255Scgd 			      Amonnam(mtmp, "plain"));
2653ea4a95cSchristos 			if (rn2(3))
2663ea4a95cSchristos 				rloc(mtmp);
26761f28255Scgd 		} else if (steal(mtmp)) {
26861f28255Scgd 			rloc(mtmp);
26961f28255Scgd 			mtmp->mflee = 1;
27061f28255Scgd 		}
27161f28255Scgd 		break;
27261f28255Scgd 	case 'n':
27361f28255Scgd 		if (!uwep && !uarm && !uarmh && !uarms && !uarmg) {
27461f28255Scgd 			pline("%s hits! (I hope you don't mind)",
27561f28255Scgd 			      Monnam(mtmp));
27661f28255Scgd 			u.uhp += rnd(7);
2773ea4a95cSchristos 			if (!rn2(7))
2783ea4a95cSchristos 				u.uhpmax++;
2793ea4a95cSchristos 			if (u.uhp > u.uhpmax)
2803ea4a95cSchristos 				u.uhp = u.uhpmax;
28161f28255Scgd 			flags.botl = 1;
2823ea4a95cSchristos 			if (!rn2(50))
2833ea4a95cSchristos 				rloc(mtmp);
28461f28255Scgd 		} else {
28561f28255Scgd 			(void) hitu(mtmp, d(2, 6));
28661f28255Scgd 			(void) hitu(mtmp, d(2, 6));
28761f28255Scgd 		}
28861f28255Scgd 		break;
28961f28255Scgd 	case 'o':
29061f28255Scgd 		tmp = hitu(mtmp, rnd(6));
29161f28255Scgd 		if (hitu(mtmp, rnd(6)) && tmp &&	/* hits with both paws */
29261f28255Scgd 		    !u.ustuck && rn2(2)) {
29361f28255Scgd 			u.ustuck = mtmp;
29461f28255Scgd 			kludge("%s has grabbed you!", "The owlbear");
29561f28255Scgd 			u.uhp -= d(2, 8);
29661f28255Scgd 		} else if (u.ustuck == mtmp) {
29761f28255Scgd 			u.uhp -= d(2, 8);
29861f28255Scgd 			pline("You are being crushed.");
29961f28255Scgd 		}
30061f28255Scgd 		break;
30161f28255Scgd 	case 'P':
30261f28255Scgd 		if (ctmp && !rn2(4))
30361f28255Scgd 			justswld(mtmp, "The purple worm");
30461f28255Scgd 		else
30561f28255Scgd 			(void) hitu(mtmp, d(2, 4));
30661f28255Scgd 		break;
30761f28255Scgd 	case 'Q':
30861f28255Scgd 		(void) hitu(mtmp, rnd(2));
30961f28255Scgd 		(void) hitu(mtmp, rnd(2));
31061f28255Scgd 		break;
31161f28255Scgd 	case 'R':
31261f28255Scgd 		if (tmp && uarmh && !uarmh->rustfree &&
31361f28255Scgd 		    (int) uarmh->spe >= -1) {
31461f28255Scgd 			pline("Your helmet rusts!");
31561f28255Scgd 			uarmh->spe--;
3163ea4a95cSchristos 		} else if (ctmp && uarm && !uarm->rustfree &&	/* Mike Newton */
31761f28255Scgd 			   uarm->otyp < STUDDED_LEATHER_ARMOR &&
31861f28255Scgd 			   (int) uarm->spe >= -1) {
31961f28255Scgd 			pline("Your armor rusts!");
32061f28255Scgd 			uarm->spe--;
32161f28255Scgd 		}
32261f28255Scgd 		break;
32361f28255Scgd 	case 'S':
32461f28255Scgd 		if (ctmp && !rn2(8)) {
32561f28255Scgd 			poisoned("snake's bite", mdat->mname);
32661f28255Scgd 		}
32761f28255Scgd 		break;
32861f28255Scgd 	case 's':
32961f28255Scgd 		if (tmp && !rn2(8)) {
33061f28255Scgd 			poisoned("scorpion's sting", mdat->mname);
33161f28255Scgd 		}
33261f28255Scgd 		(void) hitu(mtmp, rnd(8));
33361f28255Scgd 		(void) hitu(mtmp, rnd(8));
33461f28255Scgd 		break;
33561f28255Scgd 	case 'T':
33661f28255Scgd 		(void) hitu(mtmp, rnd(6));
33761f28255Scgd 		(void) hitu(mtmp, rnd(6));
33861f28255Scgd 		break;
33961f28255Scgd 	case 't':
3403ea4a95cSchristos 		if (!rn2(5))
3413ea4a95cSchristos 			rloc(mtmp);
34261f28255Scgd 		break;
34361f28255Scgd 	case 'u':
34461f28255Scgd 		mtmp->mflee = 1;
34561f28255Scgd 		break;
34661f28255Scgd 	case 'U':
34761f28255Scgd 		(void) hitu(mtmp, d(3, 4));
34861f28255Scgd 		(void) hitu(mtmp, d(3, 4));
34961f28255Scgd 		break;
35061f28255Scgd 	case 'v':
3513ea4a95cSchristos 		if (ctmp && !u.ustuck)
3523ea4a95cSchristos 			u.ustuck = mtmp;
35361f28255Scgd 		break;
35461f28255Scgd 	case 'V':
3553ea4a95cSchristos 		if (tmp)
3563ea4a95cSchristos 			u.uhp -= 4;
3573ea4a95cSchristos 		if (ctmp)
3583ea4a95cSchristos 			losexp();
35961f28255Scgd 		break;
36061f28255Scgd 	case 'W':
3613ea4a95cSchristos 		if (ctmp)
3623ea4a95cSchristos 			losexp();
36361f28255Scgd 		break;
36461f28255Scgd #ifndef NOWORM
36561f28255Scgd 	case 'w':
3663ea4a95cSchristos 		if (tmp)
3673ea4a95cSchristos 			wormhit(mtmp);
3683ea4a95cSchristos #endif	/* NOWORM */
36961f28255Scgd 		break;
37061f28255Scgd 	case 'X':
37161f28255Scgd 		(void) hitu(mtmp, rnd(5));
37261f28255Scgd 		(void) hitu(mtmp, rnd(5));
37361f28255Scgd 		(void) hitu(mtmp, rnd(5));
37461f28255Scgd 		break;
37561f28255Scgd 	case 'x':
3763ea4a95cSchristos 		{
3773ea4a95cSchristos 			long            side = rn2(2) ? RIGHT_SIDE : LEFT_SIDE;
37861f28255Scgd 			pline("%s pricks in your %s leg!",
37961f28255Scgd 			      Monnam(mtmp), (side == RIGHT_SIDE) ? "right" : "left");
38061f28255Scgd 			set_wounded_legs(side, rnd(50));
38161f28255Scgd 			losehp_m(2, mtmp);
38261f28255Scgd 			break;
38361f28255Scgd 		}
38461f28255Scgd 	case 'y':
3853ea4a95cSchristos 		if (mtmp->mcan)
3863ea4a95cSchristos 			break;
38761f28255Scgd 		mondead(mtmp);
38861f28255Scgd 		if (!Blind) {
38961f28255Scgd 			pline("You are blinded by a blast of light!");
39061f28255Scgd 			Blind = d(4, 12);
39161f28255Scgd 			seeoff(0);
39261f28255Scgd 		}
39361f28255Scgd 		return (1);
39461f28255Scgd 	case 'Y':
39561f28255Scgd 		(void) hitu(mtmp, rnd(6));
39661f28255Scgd 		break;
39761f28255Scgd 	}
3983ea4a95cSchristos 	if (u.uhp < 1)
3993ea4a95cSchristos 		done_in_by(mtmp);
40061f28255Scgd 	return (0);
40161f28255Scgd }
40261f28255Scgd 
4033ea4a95cSchristos int
hitu(struct monst * mtmp,int dam)404*1fa8a9a6Sdholland hitu(struct monst *mtmp, int dam)
40561f28255Scgd {
4063ea4a95cSchristos 	int tmp, res;
40761f28255Scgd 
40861f28255Scgd 	nomul(0);
4093ea4a95cSchristos 	if (u.uswallow)
4103ea4a95cSchristos 		return (0);
41161f28255Scgd 
41261f28255Scgd 	if (mtmp->mhide && mtmp->mundetected) {
41361f28255Scgd 		mtmp->mundetected = 0;
41461f28255Scgd 		if (!Blind) {
4153ea4a95cSchristos 			struct obj     *obj;
4163ea4a95cSchristos 			if ((obj = o_at(mtmp->mx, mtmp->my)) != NULL)
41761f28255Scgd 				pline("%s was hidden under %s!",
41861f28255Scgd 				      Xmonnam(mtmp), doname(obj));
41961f28255Scgd 		}
42061f28255Scgd 	}
42161f28255Scgd 	tmp = u.uac;
42261f28255Scgd 	/* give people with Ac = -10 at least some vulnerability */
42361f28255Scgd 	if (tmp < 0) {
42461f28255Scgd 		dam += tmp;	/* decrease damage */
4253ea4a95cSchristos 		if (dam <= 0)
4263ea4a95cSchristos 			dam = 1;
42761f28255Scgd 		tmp = -rn2(-tmp);
42861f28255Scgd 	}
42961f28255Scgd 	tmp += mtmp->data->mlevel;
4303ea4a95cSchristos 	if (multi < 0)
4313ea4a95cSchristos 		tmp += 4;
4323ea4a95cSchristos 	if ((Invis && mtmp->data->mlet != 'I') || !mtmp->mcansee)
4333ea4a95cSchristos 		tmp -= 2;
4343ea4a95cSchristos 	if (mtmp->mtrapped)
4353ea4a95cSchristos 		tmp -= 2;
43661f28255Scgd 	if (tmp <= rnd(20)) {
4373ea4a95cSchristos 		if (Blind)
4383ea4a95cSchristos 			pline("It misses.");
4393ea4a95cSchristos 		else
4403ea4a95cSchristos 			pline("%s misses.", Monnam(mtmp));
44161f28255Scgd 		res = 0;
44261f28255Scgd 	} else {
4433ea4a95cSchristos 		if (Blind)
4443ea4a95cSchristos 			pline("It hits!");
4453ea4a95cSchristos 		else
4463ea4a95cSchristos 			pline("%s hits!", Monnam(mtmp));
44761f28255Scgd 		losehp_m(dam, mtmp);
44861f28255Scgd 		res = 1;
44961f28255Scgd 	}
45061f28255Scgd 	stop_occupation();
45161f28255Scgd 	return (res);
45261f28255Scgd }
453