Home | History | Annotate | Line # | Download | only in hack
hack.fight.c revision 1.8.14.1
      1  1.8.14.1       snj /*	$NetBSD: hack.fight.c,v 1.8.14.1 2009/06/29 23:22:24 snj Exp $	*/
      2       1.4  christos 
      3       1.2   mycroft /*
      4       1.6       jsm  * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
      5       1.6       jsm  * Amsterdam
      6       1.6       jsm  * All rights reserved.
      7       1.6       jsm  *
      8       1.6       jsm  * Redistribution and use in source and binary forms, with or without
      9       1.6       jsm  * modification, are permitted provided that the following conditions are
     10       1.6       jsm  * met:
     11       1.6       jsm  *
     12       1.6       jsm  * - Redistributions of source code must retain the above copyright notice,
     13       1.6       jsm  * this list of conditions and the following disclaimer.
     14       1.6       jsm  *
     15       1.6       jsm  * - Redistributions in binary form must reproduce the above copyright
     16       1.6       jsm  * notice, this list of conditions and the following disclaimer in the
     17       1.6       jsm  * documentation and/or other materials provided with the distribution.
     18       1.6       jsm  *
     19       1.6       jsm  * - Neither the name of the Stichting Centrum voor Wiskunde en
     20       1.6       jsm  * Informatica, nor the names of its contributors may be used to endorse or
     21       1.6       jsm  * promote products derived from this software without specific prior
     22       1.6       jsm  * written permission.
     23       1.6       jsm  *
     24       1.6       jsm  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
     25       1.6       jsm  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     26       1.6       jsm  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
     27       1.6       jsm  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
     28       1.6       jsm  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     29       1.6       jsm  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     30       1.6       jsm  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     31       1.6       jsm  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
     32       1.6       jsm  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     33       1.6       jsm  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     34       1.6       jsm  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     35       1.6       jsm  */
     36       1.6       jsm 
     37       1.6       jsm /*
     38       1.6       jsm  * Copyright (c) 1982 Jay Fenlason <hack (at) gnu.org>
     39       1.6       jsm  * All rights reserved.
     40       1.6       jsm  *
     41       1.6       jsm  * Redistribution and use in source and binary forms, with or without
     42       1.6       jsm  * modification, are permitted provided that the following conditions
     43       1.6       jsm  * are met:
     44       1.6       jsm  * 1. Redistributions of source code must retain the above copyright
     45       1.6       jsm  *    notice, this list of conditions and the following disclaimer.
     46       1.6       jsm  * 2. Redistributions in binary form must reproduce the above copyright
     47       1.6       jsm  *    notice, this list of conditions and the following disclaimer in the
     48       1.6       jsm  *    documentation and/or other materials provided with the distribution.
     49       1.6       jsm  * 3. The name of the author may not be used to endorse or promote products
     50       1.6       jsm  *    derived from this software without specific prior written permission.
     51       1.6       jsm  *
     52       1.6       jsm  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
     53       1.6       jsm  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
     54       1.6       jsm  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
     55       1.6       jsm  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     56       1.6       jsm  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     57       1.6       jsm  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     58       1.6       jsm  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     59       1.6       jsm  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     60       1.6       jsm  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     61       1.6       jsm  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     62       1.2   mycroft  */
     63       1.2   mycroft 
     64       1.4  christos #include <sys/cdefs.h>
     65       1.2   mycroft #ifndef lint
     66  1.8.14.1       snj __RCSID("$NetBSD: hack.fight.c,v 1.8.14.1 2009/06/29 23:22:24 snj Exp $");
     67       1.4  christos #endif				/* not lint */
     68       1.1       cgd 
     69       1.4  christos #include "hack.h"
     70       1.4  christos #include "extern.h"
     71       1.1       cgd 
     72       1.4  christos static boolean  far_noise;
     73       1.4  christos static long     noisetime;
     74       1.1       cgd 
     75       1.1       cgd /* hitmm returns 0 (miss), 1 (hit), or 2 (kill) */
     76       1.4  christos int
     77       1.4  christos hitmm(magr, mdef)
     78       1.4  christos 	struct monst   *magr, *mdef;
     79       1.4  christos {
     80       1.5       jsm 	const struct permonst *pa = magr->data, *pd = mdef->data;
     81       1.8  dholland 	int             didhit;
     82       1.4  christos 	schar           tmp;
     83       1.4  christos 	boolean         vis;
     84       1.8  dholland 
     85       1.4  christos 	if (strchr("Eauy", pa->mlet))
     86       1.4  christos 		return (0);
     87       1.4  christos 	if (magr->mfroz)
     88       1.4  christos 		return (0);	/* riv05!a3 */
     89       1.1       cgd 	tmp = pd->ac + pa->mlevel;
     90       1.4  christos 	if (mdef->mconf || mdef->mfroz || mdef->msleep) {
     91       1.1       cgd 		tmp += 4;
     92       1.4  christos 		if (mdef->msleep)
     93       1.4  christos 			mdef->msleep = 0;
     94       1.1       cgd 	}
     95       1.8  dholland 	didhit = (tmp > rnd(20));
     96       1.8  dholland 	if (didhit)
     97       1.4  christos 		mdef->msleep = 0;
     98       1.4  christos 	vis = (cansee(magr->mx, magr->my) && cansee(mdef->mx, mdef->my));
     99       1.4  christos 	if (vis) {
    100       1.4  christos 		char            buf[BUFSZ];
    101       1.4  christos 		if (mdef->mimic)
    102       1.4  christos 			seemimic(mdef);
    103       1.4  christos 		if (magr->mimic)
    104       1.4  christos 			seemimic(magr);
    105  1.8.14.1       snj 		(void) snprintf(buf, sizeof(buf), "%s %s", Monnam(magr),
    106       1.8  dholland 			       didhit ? "hits" : "misses");
    107       1.1       cgd 		pline("%s %s.", buf, monnam(mdef));
    108       1.1       cgd 	} else {
    109       1.4  christos 		boolean         far = (dist(magr->mx, magr->my) > 15);
    110       1.4  christos 		if (far != far_noise || moves - noisetime > 10) {
    111       1.1       cgd 			far_noise = far;
    112       1.1       cgd 			noisetime = moves;
    113       1.1       cgd 			pline("You hear some noises%s.",
    114       1.4  christos 			      far ? " in the distance" : "");
    115       1.1       cgd 		}
    116       1.1       cgd 	}
    117       1.8  dholland 	if (didhit) {
    118       1.4  christos 		if (magr->data->mlet == 'c' && !magr->cham) {
    119       1.1       cgd 			magr->mhpmax += 3;
    120       1.4  christos 			if (vis)
    121       1.4  christos 				pline("%s is turned to stone!", Monnam(mdef));
    122       1.4  christos 			else if (mdef->mtame)
    123       1.4  christos 				pline("You have a peculiarly sad feeling for a moment, then it passes.");
    124       1.1       cgd 			monstone(mdef);
    125       1.8  dholland 			didhit = 2;
    126       1.4  christos 		} else if ((mdef->mhp -= d(pa->damn, pa->damd)) < 1) {
    127       1.4  christos 			magr->mhpmax += 1 + rn2(pd->mlevel + 1);
    128       1.4  christos 			if (magr->mtame && magr->mhpmax > 8 * pa->mlevel) {
    129       1.4  christos 				if (pa == &li_dog)
    130       1.4  christos 					magr->data = pa = &dog;
    131       1.4  christos 				else if (pa == &dog)
    132       1.4  christos 					magr->data = pa = &la_dog;
    133       1.1       cgd 			}
    134       1.4  christos 			if (vis)
    135       1.4  christos 				pline("%s is killed!", Monnam(mdef));
    136       1.4  christos 			else if (mdef->mtame)
    137       1.4  christos 				pline("You have a sad feeling for a moment, then it passes.");
    138       1.1       cgd 			mondied(mdef);
    139       1.8  dholland 			didhit = 2;
    140       1.1       cgd 		}
    141       1.1       cgd 	}
    142       1.8  dholland 	return (didhit);
    143       1.1       cgd }
    144       1.1       cgd 
    145       1.1       cgd /* drop (perhaps) a cadaver and remove monster */
    146       1.4  christos void
    147       1.4  christos mondied(mdef)
    148       1.4  christos 	struct monst   *mdef;
    149       1.4  christos {
    150       1.5       jsm 	const struct permonst *pd = mdef->data;
    151       1.4  christos 	if (letter(pd->mlet) && rn2(3)) {
    152       1.4  christos 		(void) mkobj_at(pd->mlet, mdef->mx, mdef->my);
    153       1.4  christos 		if (cansee(mdef->mx, mdef->my)) {
    154       1.4  christos 			unpmon(mdef);
    155       1.4  christos 			atl(mdef->mx, mdef->my, fobj->olet);
    156       1.1       cgd 		}
    157       1.4  christos 		stackobj(fobj);
    158       1.4  christos 	}
    159       1.4  christos 	mondead(mdef);
    160       1.1       cgd }
    161       1.1       cgd 
    162       1.1       cgd /* drop a rock and remove monster */
    163       1.4  christos void
    164       1.4  christos monstone(mdef)
    165       1.4  christos 	struct monst   *mdef;
    166       1.4  christos {
    167       1.4  christos 	if (strchr(mlarge, mdef->data->mlet))
    168       1.1       cgd 		mksobj_at(ENORMOUS_ROCK, mdef->mx, mdef->my);
    169       1.1       cgd 	else
    170       1.1       cgd 		mksobj_at(ROCK, mdef->mx, mdef->my);
    171       1.4  christos 	if (cansee(mdef->mx, mdef->my)) {
    172       1.1       cgd 		unpmon(mdef);
    173       1.4  christos 		atl(mdef->mx, mdef->my, fobj->olet);
    174       1.1       cgd 	}
    175       1.1       cgd 	mondead(mdef);
    176       1.1       cgd }
    177       1.1       cgd 
    178       1.4  christos 
    179       1.4  christos int
    180       1.4  christos fightm(mtmp)
    181       1.4  christos 	struct monst   *mtmp;
    182       1.4  christos {
    183       1.4  christos 	struct monst   *mon;
    184       1.4  christos 	for (mon = fmon; mon; mon = mon->nmon)
    185       1.4  christos 		if (mon != mtmp) {
    186       1.4  christos 			if (DIST(mon->mx, mon->my, mtmp->mx, mtmp->my) < 3)
    187       1.4  christos 				if (rn2(4))
    188       1.4  christos 					return (hitmm(mtmp, mon));
    189       1.4  christos 		}
    190       1.4  christos 	return (-1);
    191       1.1       cgd }
    192       1.1       cgd 
    193       1.1       cgd /* u is hit by sth, but not a monster */
    194       1.4  christos int
    195       1.4  christos thitu(tlev, dam, name)
    196       1.4  christos 	int tlev, dam;
    197       1.5       jsm 	const char           *name;
    198       1.1       cgd {
    199       1.4  christos 	char            buf[BUFSZ];
    200  1.8.14.1       snj 
    201  1.8.14.1       snj 	setan(name, buf, sizeof(buf));
    202       1.4  christos 	if (u.uac + tlev <= rnd(20)) {
    203       1.4  christos 		if (Blind)
    204       1.4  christos 			pline("It misses.");
    205       1.4  christos 		else
    206       1.4  christos 			pline("You are almost hit by %s!", buf);
    207       1.4  christos 		return (0);
    208       1.1       cgd 	} else {
    209       1.4  christos 		if (Blind)
    210       1.4  christos 			pline("You are hit!");
    211       1.4  christos 		else
    212       1.4  christos 			pline("You are hit by %s!", buf);
    213       1.4  christos 		losehp(dam, name);
    214       1.4  christos 		return (1);
    215       1.1       cgd 	}
    216       1.1       cgd }
    217       1.1       cgd 
    218       1.4  christos char            mlarge[] = "bCDdegIlmnoPSsTUwY',&";
    219       1.1       cgd 
    220       1.1       cgd boolean
    221       1.4  christos hmon(mon, obj, thrown)		/* return TRUE if mon still alive */
    222       1.4  christos 	struct monst   *mon;
    223       1.4  christos 	struct obj     *obj;
    224       1.4  christos 	int thrown;
    225       1.1       cgd {
    226       1.4  christos 	int tmp;
    227       1.4  christos 	boolean         hittxt = FALSE;
    228       1.1       cgd 
    229       1.4  christos 	if (!obj) {
    230       1.1       cgd 		tmp = rnd(2);	/* attack with bare hands */
    231       1.4  christos 		if (mon->data->mlet == 'c' && !uarmg) {
    232       1.1       cgd 			pline("You hit the cockatrice with your bare hands.");
    233       1.1       cgd 			pline("You turn to stone ...");
    234       1.1       cgd 			done_in_by(mon);
    235       1.1       cgd 		}
    236       1.4  christos 	} else if (obj->olet == WEAPON_SYM || obj->otyp == PICK_AXE) {
    237       1.4  christos 		if (obj == uwep && (obj->otyp > SPEAR || obj->otyp < BOOMERANG))
    238       1.4  christos 			tmp = rnd(2);
    239       1.4  christos 		else {
    240       1.4  christos 			if (strchr(mlarge, mon->data->mlet)) {
    241       1.4  christos 				tmp = rnd(objects[obj->otyp].wldam);
    242       1.4  christos 				if (obj->otyp == TWO_HANDED_SWORD)
    243       1.4  christos 					tmp += d(2, 6);
    244       1.4  christos 				else if (obj->otyp == FLAIL)
    245       1.4  christos 					tmp += rnd(4);
    246       1.4  christos 			} else {
    247       1.4  christos 				tmp = rnd(objects[obj->otyp].wsdam);
    248       1.4  christos 			}
    249       1.4  christos 			tmp += obj->spe;
    250       1.4  christos 			if (!thrown && obj == uwep && obj->otyp == BOOMERANG
    251       1.4  christos 			    && !rn2(3)) {
    252       1.4  christos 				pline("As you hit %s, the boomerang breaks into splinters.",
    253       1.4  christos 				      monnam(mon));
    254       1.4  christos 				freeinv(obj);
    255       1.4  christos 				setworn((struct obj *) 0, obj->owornmask);
    256       1.4  christos 				obfree(obj, (struct obj *) 0);
    257       1.7   jnemeth 				obj = NULL;
    258       1.4  christos 				tmp++;
    259       1.4  christos 			}
    260       1.1       cgd 		}
    261       1.7   jnemeth 		if (mon->data->mlet == 'O' && obj != NULL &&
    262       1.7   jnemeth 		    obj->otyp == TWO_HANDED_SWORD &&
    263       1.4  christos 		    !strcmp(ONAME(obj), "Orcrist"))
    264       1.4  christos 			tmp += rnd(10);
    265       1.4  christos 	} else
    266       1.4  christos 		switch (obj->otyp) {
    267       1.1       cgd 		case HEAVY_IRON_BALL:
    268       1.4  christos 			tmp = rnd(25);
    269       1.4  christos 			break;
    270       1.1       cgd 		case EXPENSIVE_CAMERA:
    271       1.4  christos 			pline("You succeed in destroying your camera. Congratulations!");
    272       1.1       cgd 			freeinv(obj);
    273       1.4  christos 			if (obj->owornmask)
    274       1.1       cgd 				setworn((struct obj *) 0, obj->owornmask);
    275       1.1       cgd 			obfree(obj, (struct obj *) 0);
    276       1.4  christos 			return (TRUE);
    277       1.1       cgd 		case DEAD_COCKATRICE:
    278       1.1       cgd 			pline("You hit %s with the cockatrice corpse.",
    279       1.4  christos 			      monnam(mon));
    280       1.4  christos 			if (mon->data->mlet == 'c') {
    281       1.1       cgd 				tmp = 1;
    282       1.1       cgd 				hittxt = TRUE;
    283       1.1       cgd 				break;
    284       1.1       cgd 			}
    285       1.1       cgd 			pline("%s is turned to stone!", Monnam(mon));
    286       1.1       cgd 			killed(mon);
    287       1.4  christos 			return (FALSE);
    288       1.4  christos 		case CLOVE_OF_GARLIC:	/* no effect against demons */
    289       1.4  christos 			if (strchr(UNDEAD, mon->data->mlet))
    290       1.1       cgd 				mon->mflee = 1;
    291       1.1       cgd 			tmp = 1;
    292       1.1       cgd 			break;
    293       1.1       cgd 		default:
    294       1.1       cgd 			/* non-weapons can damage because of their weight */
    295       1.1       cgd 			/* (but not too much) */
    296       1.4  christos 			tmp = obj->owt / 10;
    297       1.4  christos 			if (tmp < 1)
    298       1.4  christos 				tmp = 1;
    299       1.4  christos 			else
    300       1.4  christos 				tmp = rnd(tmp);
    301       1.4  christos 			if (tmp > 6)
    302       1.4  christos 				tmp = 6;
    303       1.1       cgd 		}
    304       1.1       cgd 
    305       1.1       cgd 	/****** NOTE: perhaps obj is undefined!! (if !thrown && BOOMERANG) */
    306       1.1       cgd 
    307       1.1       cgd 	tmp += u.udaminc + dbon();
    308       1.4  christos 	if (u.uswallow) {
    309       1.4  christos 		if ((tmp -= u.uswldtim) <= 0) {
    310       1.1       cgd 			pline("Your arms are no longer able to hit.");
    311       1.4  christos 			return (TRUE);
    312       1.1       cgd 		}
    313       1.1       cgd 	}
    314       1.4  christos 	if (tmp < 1)
    315       1.4  christos 		tmp = 1;
    316       1.1       cgd 	mon->mhp -= tmp;
    317       1.4  christos 	if (mon->mhp < 1) {
    318       1.1       cgd 		killed(mon);
    319       1.4  christos 		return (FALSE);
    320       1.1       cgd 	}
    321       1.4  christos 	if (mon->mtame && (!mon->mflee || mon->mfleetim)) {
    322       1.4  christos 		mon->mflee = 1;	/* Rick Richardson */
    323       1.4  christos 		mon->mfleetim += 10 * rnd(tmp);
    324       1.1       cgd 	}
    325       1.4  christos 	if (!hittxt) {
    326       1.7   jnemeth 		if (thrown) {
    327       1.1       cgd 			/* this assumes that we cannot throw plural things */
    328       1.7   jnemeth 			if (obj == NULL)
    329       1.7   jnemeth 				panic("thrown non-object");
    330       1.4  christos 			hit(xname(obj) /* or: objects[obj->otyp].oc_name */ ,
    331       1.4  christos 			    mon, exclam(tmp));
    332       1.7   jnemeth 		} else if (Blind)
    333       1.1       cgd 			pline("You hit it.");
    334       1.1       cgd 		else
    335       1.1       cgd 			pline("You hit %s%s", monnam(mon), exclam(tmp));
    336       1.1       cgd 	}
    337       1.4  christos 	if (u.umconf && !thrown) {
    338       1.4  christos 		if (!Blind) {
    339       1.1       cgd 			pline("Your hands stop glowing blue.");
    340       1.4  christos 			if (!mon->mfroz && !mon->msleep)
    341       1.4  christos 				pline("%s appears confused.", Monnam(mon));
    342       1.1       cgd 		}
    343       1.1       cgd 		mon->mconf = 1;
    344       1.1       cgd 		u.umconf = 0;
    345       1.1       cgd 	}
    346       1.4  christos 	return (TRUE);		/* mon still alive */
    347       1.1       cgd }
    348       1.1       cgd 
    349       1.1       cgd /* try to attack; return FALSE if monster evaded */
    350       1.1       cgd /* u.dx and u.dy must be set */
    351       1.4  christos int
    352       1.1       cgd attack(mtmp)
    353       1.4  christos 	struct monst   *mtmp;
    354       1.1       cgd {
    355       1.4  christos 	schar           tmp;
    356       1.4  christos 	boolean         malive = TRUE;
    357       1.5       jsm 	const struct permonst *mdat;
    358       1.1       cgd 	mdat = mtmp->data;
    359       1.1       cgd 
    360       1.4  christos 	u_wipe_engr(3);		/* andrew@orca: prevent unlimited pick-axe
    361       1.4  christos 				 * attacks */
    362       1.1       cgd 
    363       1.4  christos 	if (mdat->mlet == 'L' && !mtmp->mfroz && !mtmp->msleep &&
    364       1.4  christos 	    !mtmp->mconf && mtmp->mcansee && !rn2(7) &&
    365       1.4  christos 	    (m_move(mtmp, 0) == 2 /* he died */ ||	/* he moved: */
    366       1.4  christos 	     mtmp->mx != u.ux + u.dx || mtmp->my != u.uy + u.dy))
    367       1.4  christos 		return (FALSE);
    368       1.4  christos 
    369       1.4  christos 	if (mtmp->mimic) {
    370       1.4  christos 		if (!u.ustuck && !mtmp->mflee)
    371       1.4  christos 			u.ustuck = mtmp;
    372       1.4  christos 		switch (levl[u.ux + u.dx][u.uy + u.dy].scrsym) {
    373       1.1       cgd 		case '+':
    374       1.1       cgd 			pline("The door actually was a Mimic.");
    375       1.1       cgd 			break;
    376       1.1       cgd 		case '$':
    377       1.1       cgd 			pline("The chest was a Mimic!");
    378       1.1       cgd 			break;
    379       1.1       cgd 		default:
    380       1.1       cgd 			pline("Wait! That's a Mimic!");
    381       1.1       cgd 		}
    382       1.1       cgd 		wakeup(mtmp);	/* clears mtmp->mimic */
    383       1.4  christos 		return (TRUE);
    384       1.1       cgd 	}
    385       1.1       cgd 	wakeup(mtmp);
    386       1.1       cgd 
    387       1.4  christos 	if (mtmp->mhide && mtmp->mundetected) {
    388       1.4  christos 		struct obj     *obj;
    389       1.1       cgd 
    390       1.1       cgd 		mtmp->mundetected = 0;
    391       1.4  christos 		if ((obj = o_at(mtmp->mx, mtmp->my)) && !Blind)
    392       1.1       cgd 			pline("Wait! There's a %s hiding under %s!",
    393       1.4  christos 			      mdat->mname, doname(obj));
    394       1.4  christos 		return (TRUE);
    395       1.1       cgd 	}
    396       1.1       cgd 	tmp = u.uluck + u.ulevel + mdat->ac + abon();
    397       1.4  christos 	if (uwep) {
    398       1.4  christos 		if (uwep->olet == WEAPON_SYM || uwep->otyp == PICK_AXE)
    399       1.1       cgd 			tmp += uwep->spe;
    400       1.4  christos 		if (uwep->otyp == TWO_HANDED_SWORD)
    401       1.4  christos 			tmp -= 1;
    402       1.4  christos 		else if (uwep->otyp == DAGGER)
    403       1.4  christos 			tmp += 2;
    404       1.4  christos 		else if (uwep->otyp == CRYSKNIFE)
    405       1.4  christos 			tmp += 3;
    406       1.4  christos 		else if (uwep->otyp == SPEAR &&
    407       1.4  christos 			 strchr("XDne", mdat->mlet))
    408       1.4  christos 			tmp += 2;
    409       1.1       cgd 	}
    410       1.4  christos 	if (mtmp->msleep) {
    411       1.1       cgd 		mtmp->msleep = 0;
    412       1.1       cgd 		tmp += 2;
    413       1.1       cgd 	}
    414       1.4  christos 	if (mtmp->mfroz) {
    415       1.1       cgd 		tmp += 4;
    416       1.4  christos 		if (!rn2(10))
    417       1.4  christos 			mtmp->mfroz = 0;
    418       1.1       cgd 	}
    419       1.4  christos 	if (mtmp->mflee)
    420       1.4  christos 		tmp += 2;
    421       1.4  christos 	if (u.utrap)
    422       1.4  christos 		tmp -= 3;
    423       1.1       cgd 
    424       1.1       cgd 	/* with a lot of luggage, your agility diminishes */
    425       1.4  christos 	tmp -= (inv_weight() + 40) / 20;
    426       1.1       cgd 
    427       1.4  christos 	if (tmp <= rnd(20) && !u.uswallow) {
    428       1.4  christos 		if (Blind)
    429       1.4  christos 			pline("You miss it.");
    430       1.4  christos 		else
    431       1.4  christos 			pline("You miss %s.", monnam(mtmp));
    432       1.1       cgd 	} else {
    433       1.1       cgd 		/* we hit the monster; be careful: it might die! */
    434       1.1       cgd 
    435       1.4  christos 		if ((malive = hmon(mtmp, uwep, 0)) == TRUE) {
    436       1.4  christos 			/* monster still alive */
    437       1.4  christos 			if (!rn2(25) && mtmp->mhp < mtmp->mhpmax / 2) {
    438       1.1       cgd 				mtmp->mflee = 1;
    439       1.4  christos 				if (!rn2(3))
    440       1.4  christos 					mtmp->mfleetim = rnd(100);
    441       1.4  christos 				if (u.ustuck == mtmp && !u.uswallow)
    442       1.1       cgd 					u.ustuck = 0;
    443       1.1       cgd 			}
    444       1.1       cgd #ifndef NOWORM
    445       1.4  christos 			if (mtmp->wormno)
    446       1.4  christos 				cutworm(mtmp, u.ux + u.dx, u.uy + u.dy,
    447       1.1       cgd 					uwep ? uwep->otyp : 0);
    448       1.4  christos #endif	/* NOWORM */
    449       1.1       cgd 		}
    450       1.4  christos 		if (mdat->mlet == 'a') {
    451       1.4  christos 			if (rn2(2)) {
    452       1.1       cgd 				pline("You are splashed by the blob's acid!");
    453       1.1       cgd 				losehp_m(rnd(6), mtmp);
    454       1.4  christos 				if (!rn2(30))
    455       1.4  christos 					corrode_armor();
    456       1.1       cgd 			}
    457       1.4  christos 			if (!rn2(6))
    458       1.4  christos 				corrode_weapon();
    459       1.1       cgd 		}
    460       1.1       cgd 	}
    461       1.4  christos 	if (malive && mdat->mlet == 'E' && canseemon(mtmp)
    462       1.4  christos 	    && !mtmp->mcan && rn2(3)) {
    463       1.4  christos 		if (mtmp->mcansee) {
    464       1.4  christos 			pline("You are frozen by the floating eye's gaze!");
    465       1.4  christos 			nomul((u.ulevel > 6 || rn2(4)) ? rn1(20, -21) : -200);
    466       1.4  christos 		} else {
    467       1.4  christos 			pline("The blinded floating eye cannot defend itself.");
    468       1.4  christos 			if (!rn2(500))
    469       1.4  christos 				if ((int) u.uluck > LUCKMIN)
    470       1.4  christos 					u.uluck--;
    471       1.4  christos 		}
    472       1.1       cgd 	}
    473       1.4  christos 	return (TRUE);
    474       1.1       cgd }
    475