Home | History | Annotate | Line # | Download | only in hack
      1  1.12  dholland /*	$NetBSD: hack.fight.c,v 1.12 2009/08/12 07:28:40 dholland 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.12  dholland __RCSID("$NetBSD: hack.fight.c,v 1.12 2009/08/12 07:28:40 dholland 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.12  dholland static void monstone(struct monst *);
     76  1.12  dholland 
     77   1.1       cgd /* hitmm returns 0 (miss), 1 (hit), or 2 (kill) */
     78   1.4  christos int
     79   1.9  dholland hitmm(struct monst *magr, struct monst *mdef)
     80   1.4  christos {
     81   1.5       jsm 	const struct permonst *pa = magr->data, *pd = mdef->data;
     82   1.8  dholland 	int             didhit;
     83   1.4  christos 	schar           tmp;
     84   1.4  christos 	boolean         vis;
     85   1.8  dholland 
     86   1.4  christos 	if (strchr("Eauy", pa->mlet))
     87   1.4  christos 		return (0);
     88   1.4  christos 	if (magr->mfroz)
     89   1.4  christos 		return (0);	/* riv05!a3 */
     90   1.1       cgd 	tmp = pd->ac + pa->mlevel;
     91   1.4  christos 	if (mdef->mconf || mdef->mfroz || mdef->msleep) {
     92   1.1       cgd 		tmp += 4;
     93   1.4  christos 		if (mdef->msleep)
     94   1.4  christos 			mdef->msleep = 0;
     95   1.1       cgd 	}
     96   1.8  dholland 	didhit = (tmp > rnd(20));
     97   1.8  dholland 	if (didhit)
     98   1.4  christos 		mdef->msleep = 0;
     99   1.4  christos 	vis = (cansee(magr->mx, magr->my) && cansee(mdef->mx, mdef->my));
    100   1.4  christos 	if (vis) {
    101   1.4  christos 		char            buf[BUFSZ];
    102   1.4  christos 		if (mdef->mimic)
    103   1.4  christos 			seemimic(mdef);
    104   1.4  christos 		if (magr->mimic)
    105   1.4  christos 			seemimic(magr);
    106  1.10  dholland 		(void) snprintf(buf, sizeof(buf), "%s %s", Monnam(magr),
    107   1.8  dholland 			       didhit ? "hits" : "misses");
    108   1.1       cgd 		pline("%s %s.", buf, monnam(mdef));
    109   1.1       cgd 	} else {
    110   1.4  christos 		boolean         far = (dist(magr->mx, magr->my) > 15);
    111   1.4  christos 		if (far != far_noise || moves - noisetime > 10) {
    112   1.1       cgd 			far_noise = far;
    113   1.1       cgd 			noisetime = moves;
    114   1.1       cgd 			pline("You hear some noises%s.",
    115   1.4  christos 			      far ? " in the distance" : "");
    116   1.1       cgd 		}
    117   1.1       cgd 	}
    118   1.8  dholland 	if (didhit) {
    119   1.4  christos 		if (magr->data->mlet == 'c' && !magr->cham) {
    120   1.1       cgd 			magr->mhpmax += 3;
    121   1.4  christos 			if (vis)
    122   1.4  christos 				pline("%s is turned to stone!", Monnam(mdef));
    123   1.4  christos 			else if (mdef->mtame)
    124   1.4  christos 				pline("You have a peculiarly sad feeling for a moment, then it passes.");
    125   1.1       cgd 			monstone(mdef);
    126   1.8  dholland 			didhit = 2;
    127   1.4  christos 		} else if ((mdef->mhp -= d(pa->damn, pa->damd)) < 1) {
    128   1.4  christos 			magr->mhpmax += 1 + rn2(pd->mlevel + 1);
    129   1.4  christos 			if (magr->mtame && magr->mhpmax > 8 * pa->mlevel) {
    130   1.4  christos 				if (pa == &li_dog)
    131   1.4  christos 					magr->data = pa = &dog;
    132   1.4  christos 				else if (pa == &dog)
    133   1.4  christos 					magr->data = pa = &la_dog;
    134   1.1       cgd 			}
    135   1.4  christos 			if (vis)
    136   1.4  christos 				pline("%s is killed!", Monnam(mdef));
    137   1.4  christos 			else if (mdef->mtame)
    138   1.4  christos 				pline("You have a sad feeling for a moment, then it passes.");
    139   1.1       cgd 			mondied(mdef);
    140   1.8  dholland 			didhit = 2;
    141   1.1       cgd 		}
    142   1.1       cgd 	}
    143   1.8  dholland 	return (didhit);
    144   1.1       cgd }
    145   1.1       cgd 
    146   1.1       cgd /* drop (perhaps) a cadaver and remove monster */
    147   1.4  christos void
    148   1.9  dholland mondied(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.12  dholland static void
    164   1.9  dholland monstone(struct monst *mdef)
    165   1.4  christos {
    166   1.4  christos 	if (strchr(mlarge, mdef->data->mlet))
    167   1.1       cgd 		mksobj_at(ENORMOUS_ROCK, mdef->mx, mdef->my);
    168   1.1       cgd 	else
    169   1.1       cgd 		mksobj_at(ROCK, mdef->mx, mdef->my);
    170   1.4  christos 	if (cansee(mdef->mx, mdef->my)) {
    171   1.1       cgd 		unpmon(mdef);
    172   1.4  christos 		atl(mdef->mx, mdef->my, fobj->olet);
    173   1.1       cgd 	}
    174   1.1       cgd 	mondead(mdef);
    175   1.1       cgd }
    176   1.1       cgd 
    177   1.4  christos 
    178   1.4  christos int
    179   1.9  dholland fightm(struct monst *mtmp)
    180   1.4  christos {
    181   1.4  christos 	struct monst   *mon;
    182   1.4  christos 	for (mon = fmon; mon; mon = mon->nmon)
    183   1.4  christos 		if (mon != mtmp) {
    184   1.4  christos 			if (DIST(mon->mx, mon->my, mtmp->mx, mtmp->my) < 3)
    185   1.4  christos 				if (rn2(4))
    186   1.4  christos 					return (hitmm(mtmp, mon));
    187   1.4  christos 		}
    188   1.4  christos 	return (-1);
    189   1.1       cgd }
    190   1.1       cgd 
    191   1.1       cgd /* u is hit by sth, but not a monster */
    192   1.4  christos int
    193   1.9  dholland thitu(int tlev, int dam, const char *name)
    194   1.1       cgd {
    195   1.4  christos 	char            buf[BUFSZ];
    196  1.10  dholland 
    197  1.10  dholland 	setan(name, buf, sizeof(buf));
    198   1.4  christos 	if (u.uac + tlev <= rnd(20)) {
    199   1.4  christos 		if (Blind)
    200   1.4  christos 			pline("It misses.");
    201   1.4  christos 		else
    202   1.4  christos 			pline("You are almost hit by %s!", buf);
    203   1.4  christos 		return (0);
    204   1.1       cgd 	} else {
    205   1.4  christos 		if (Blind)
    206   1.4  christos 			pline("You are hit!");
    207   1.4  christos 		else
    208   1.4  christos 			pline("You are hit by %s!", buf);
    209   1.4  christos 		losehp(dam, name);
    210   1.4  christos 		return (1);
    211   1.1       cgd 	}
    212   1.1       cgd }
    213   1.1       cgd 
    214  1.11  dholland const char mlarge[] = "bCDdegIlmnoPSsTUwY',&";
    215   1.1       cgd 
    216   1.9  dholland /* return TRUE if mon still alive */
    217   1.1       cgd boolean
    218   1.9  dholland hmon(struct monst *mon, struct obj *obj, int thrown)
    219   1.1       cgd {
    220   1.4  christos 	int tmp;
    221   1.4  christos 	boolean         hittxt = FALSE;
    222   1.1       cgd 
    223   1.4  christos 	if (!obj) {
    224   1.1       cgd 		tmp = rnd(2);	/* attack with bare hands */
    225   1.4  christos 		if (mon->data->mlet == 'c' && !uarmg) {
    226   1.1       cgd 			pline("You hit the cockatrice with your bare hands.");
    227   1.1       cgd 			pline("You turn to stone ...");
    228   1.1       cgd 			done_in_by(mon);
    229   1.1       cgd 		}
    230   1.4  christos 	} else if (obj->olet == WEAPON_SYM || obj->otyp == PICK_AXE) {
    231   1.4  christos 		if (obj == uwep && (obj->otyp > SPEAR || obj->otyp < BOOMERANG))
    232   1.4  christos 			tmp = rnd(2);
    233   1.4  christos 		else {
    234   1.4  christos 			if (strchr(mlarge, mon->data->mlet)) {
    235   1.4  christos 				tmp = rnd(objects[obj->otyp].wldam);
    236   1.4  christos 				if (obj->otyp == TWO_HANDED_SWORD)
    237   1.4  christos 					tmp += d(2, 6);
    238   1.4  christos 				else if (obj->otyp == FLAIL)
    239   1.4  christos 					tmp += rnd(4);
    240   1.4  christos 			} else {
    241   1.4  christos 				tmp = rnd(objects[obj->otyp].wsdam);
    242   1.4  christos 			}
    243   1.4  christos 			tmp += obj->spe;
    244   1.4  christos 			if (!thrown && obj == uwep && obj->otyp == BOOMERANG
    245   1.4  christos 			    && !rn2(3)) {
    246   1.4  christos 				pline("As you hit %s, the boomerang breaks into splinters.",
    247   1.4  christos 				      monnam(mon));
    248   1.4  christos 				freeinv(obj);
    249   1.4  christos 				setworn((struct obj *) 0, obj->owornmask);
    250   1.4  christos 				obfree(obj, (struct obj *) 0);
    251   1.7   jnemeth 				obj = NULL;
    252   1.4  christos 				tmp++;
    253   1.4  christos 			}
    254   1.1       cgd 		}
    255   1.7   jnemeth 		if (mon->data->mlet == 'O' && obj != NULL &&
    256   1.7   jnemeth 		    obj->otyp == TWO_HANDED_SWORD &&
    257   1.4  christos 		    !strcmp(ONAME(obj), "Orcrist"))
    258   1.4  christos 			tmp += rnd(10);
    259   1.4  christos 	} else
    260   1.4  christos 		switch (obj->otyp) {
    261   1.1       cgd 		case HEAVY_IRON_BALL:
    262   1.4  christos 			tmp = rnd(25);
    263   1.4  christos 			break;
    264   1.1       cgd 		case EXPENSIVE_CAMERA:
    265   1.4  christos 			pline("You succeed in destroying your camera. Congratulations!");
    266   1.1       cgd 			freeinv(obj);
    267   1.4  christos 			if (obj->owornmask)
    268   1.1       cgd 				setworn((struct obj *) 0, obj->owornmask);
    269   1.1       cgd 			obfree(obj, (struct obj *) 0);
    270   1.4  christos 			return (TRUE);
    271   1.1       cgd 		case DEAD_COCKATRICE:
    272   1.1       cgd 			pline("You hit %s with the cockatrice corpse.",
    273   1.4  christos 			      monnam(mon));
    274   1.4  christos 			if (mon->data->mlet == 'c') {
    275   1.1       cgd 				tmp = 1;
    276   1.1       cgd 				hittxt = TRUE;
    277   1.1       cgd 				break;
    278   1.1       cgd 			}
    279   1.1       cgd 			pline("%s is turned to stone!", Monnam(mon));
    280   1.1       cgd 			killed(mon);
    281   1.4  christos 			return (FALSE);
    282   1.4  christos 		case CLOVE_OF_GARLIC:	/* no effect against demons */
    283   1.4  christos 			if (strchr(UNDEAD, mon->data->mlet))
    284   1.1       cgd 				mon->mflee = 1;
    285   1.1       cgd 			tmp = 1;
    286   1.1       cgd 			break;
    287   1.1       cgd 		default:
    288   1.1       cgd 			/* non-weapons can damage because of their weight */
    289   1.1       cgd 			/* (but not too much) */
    290   1.4  christos 			tmp = obj->owt / 10;
    291   1.4  christos 			if (tmp < 1)
    292   1.4  christos 				tmp = 1;
    293   1.4  christos 			else
    294   1.4  christos 				tmp = rnd(tmp);
    295   1.4  christos 			if (tmp > 6)
    296   1.4  christos 				tmp = 6;
    297   1.1       cgd 		}
    298   1.1       cgd 
    299   1.1       cgd 	/****** NOTE: perhaps obj is undefined!! (if !thrown && BOOMERANG) */
    300   1.1       cgd 
    301   1.1       cgd 	tmp += u.udaminc + dbon();
    302   1.4  christos 	if (u.uswallow) {
    303   1.4  christos 		if ((tmp -= u.uswldtim) <= 0) {
    304   1.1       cgd 			pline("Your arms are no longer able to hit.");
    305   1.4  christos 			return (TRUE);
    306   1.1       cgd 		}
    307   1.1       cgd 	}
    308   1.4  christos 	if (tmp < 1)
    309   1.4  christos 		tmp = 1;
    310   1.1       cgd 	mon->mhp -= tmp;
    311   1.4  christos 	if (mon->mhp < 1) {
    312   1.1       cgd 		killed(mon);
    313   1.4  christos 		return (FALSE);
    314   1.1       cgd 	}
    315   1.4  christos 	if (mon->mtame && (!mon->mflee || mon->mfleetim)) {
    316   1.4  christos 		mon->mflee = 1;	/* Rick Richardson */
    317   1.4  christos 		mon->mfleetim += 10 * rnd(tmp);
    318   1.1       cgd 	}
    319   1.4  christos 	if (!hittxt) {
    320   1.7   jnemeth 		if (thrown) {
    321   1.1       cgd 			/* this assumes that we cannot throw plural things */
    322   1.7   jnemeth 			if (obj == NULL)
    323   1.7   jnemeth 				panic("thrown non-object");
    324   1.4  christos 			hit(xname(obj) /* or: objects[obj->otyp].oc_name */ ,
    325   1.4  christos 			    mon, exclam(tmp));
    326   1.7   jnemeth 		} else if (Blind)
    327   1.1       cgd 			pline("You hit it.");
    328   1.1       cgd 		else
    329   1.1       cgd 			pline("You hit %s%s", monnam(mon), exclam(tmp));
    330   1.1       cgd 	}
    331   1.4  christos 	if (u.umconf && !thrown) {
    332   1.4  christos 		if (!Blind) {
    333   1.1       cgd 			pline("Your hands stop glowing blue.");
    334   1.4  christos 			if (!mon->mfroz && !mon->msleep)
    335   1.4  christos 				pline("%s appears confused.", Monnam(mon));
    336   1.1       cgd 		}
    337   1.1       cgd 		mon->mconf = 1;
    338   1.1       cgd 		u.umconf = 0;
    339   1.1       cgd 	}
    340   1.4  christos 	return (TRUE);		/* mon still alive */
    341   1.1       cgd }
    342   1.1       cgd 
    343   1.1       cgd /* try to attack; return FALSE if monster evaded */
    344   1.1       cgd /* u.dx and u.dy must be set */
    345   1.4  christos int
    346   1.9  dholland attack(struct monst *mtmp)
    347   1.1       cgd {
    348   1.4  christos 	schar           tmp;
    349   1.4  christos 	boolean         malive = TRUE;
    350   1.5       jsm 	const struct permonst *mdat;
    351   1.1       cgd 	mdat = mtmp->data;
    352   1.1       cgd 
    353   1.4  christos 	u_wipe_engr(3);		/* andrew@orca: prevent unlimited pick-axe
    354   1.4  christos 				 * attacks */
    355   1.1       cgd 
    356   1.4  christos 	if (mdat->mlet == 'L' && !mtmp->mfroz && !mtmp->msleep &&
    357   1.4  christos 	    !mtmp->mconf && mtmp->mcansee && !rn2(7) &&
    358   1.4  christos 	    (m_move(mtmp, 0) == 2 /* he died */ ||	/* he moved: */
    359   1.4  christos 	     mtmp->mx != u.ux + u.dx || mtmp->my != u.uy + u.dy))
    360   1.4  christos 		return (FALSE);
    361   1.4  christos 
    362   1.4  christos 	if (mtmp->mimic) {
    363   1.4  christos 		if (!u.ustuck && !mtmp->mflee)
    364   1.4  christos 			u.ustuck = mtmp;
    365   1.4  christos 		switch (levl[u.ux + u.dx][u.uy + u.dy].scrsym) {
    366   1.1       cgd 		case '+':
    367   1.1       cgd 			pline("The door actually was a Mimic.");
    368   1.1       cgd 			break;
    369   1.1       cgd 		case '$':
    370   1.1       cgd 			pline("The chest was a Mimic!");
    371   1.1       cgd 			break;
    372   1.1       cgd 		default:
    373   1.1       cgd 			pline("Wait! That's a Mimic!");
    374   1.1       cgd 		}
    375   1.1       cgd 		wakeup(mtmp);	/* clears mtmp->mimic */
    376   1.4  christos 		return (TRUE);
    377   1.1       cgd 	}
    378   1.1       cgd 	wakeup(mtmp);
    379   1.1       cgd 
    380   1.4  christos 	if (mtmp->mhide && mtmp->mundetected) {
    381   1.4  christos 		struct obj     *obj;
    382   1.1       cgd 
    383   1.1       cgd 		mtmp->mundetected = 0;
    384   1.4  christos 		if ((obj = o_at(mtmp->mx, mtmp->my)) && !Blind)
    385   1.1       cgd 			pline("Wait! There's a %s hiding under %s!",
    386   1.4  christos 			      mdat->mname, doname(obj));
    387   1.4  christos 		return (TRUE);
    388   1.1       cgd 	}
    389   1.1       cgd 	tmp = u.uluck + u.ulevel + mdat->ac + abon();
    390   1.4  christos 	if (uwep) {
    391   1.4  christos 		if (uwep->olet == WEAPON_SYM || uwep->otyp == PICK_AXE)
    392   1.1       cgd 			tmp += uwep->spe;
    393   1.4  christos 		if (uwep->otyp == TWO_HANDED_SWORD)
    394   1.4  christos 			tmp -= 1;
    395   1.4  christos 		else if (uwep->otyp == DAGGER)
    396   1.4  christos 			tmp += 2;
    397   1.4  christos 		else if (uwep->otyp == CRYSKNIFE)
    398   1.4  christos 			tmp += 3;
    399   1.4  christos 		else if (uwep->otyp == SPEAR &&
    400   1.4  christos 			 strchr("XDne", mdat->mlet))
    401   1.4  christos 			tmp += 2;
    402   1.1       cgd 	}
    403   1.4  christos 	if (mtmp->msleep) {
    404   1.1       cgd 		mtmp->msleep = 0;
    405   1.1       cgd 		tmp += 2;
    406   1.1       cgd 	}
    407   1.4  christos 	if (mtmp->mfroz) {
    408   1.1       cgd 		tmp += 4;
    409   1.4  christos 		if (!rn2(10))
    410   1.4  christos 			mtmp->mfroz = 0;
    411   1.1       cgd 	}
    412   1.4  christos 	if (mtmp->mflee)
    413   1.4  christos 		tmp += 2;
    414   1.4  christos 	if (u.utrap)
    415   1.4  christos 		tmp -= 3;
    416   1.1       cgd 
    417   1.1       cgd 	/* with a lot of luggage, your agility diminishes */
    418   1.4  christos 	tmp -= (inv_weight() + 40) / 20;
    419   1.1       cgd 
    420   1.4  christos 	if (tmp <= rnd(20) && !u.uswallow) {
    421   1.4  christos 		if (Blind)
    422   1.4  christos 			pline("You miss it.");
    423   1.4  christos 		else
    424   1.4  christos 			pline("You miss %s.", monnam(mtmp));
    425   1.1       cgd 	} else {
    426   1.1       cgd 		/* we hit the monster; be careful: it might die! */
    427   1.1       cgd 
    428   1.4  christos 		if ((malive = hmon(mtmp, uwep, 0)) == TRUE) {
    429   1.4  christos 			/* monster still alive */
    430   1.4  christos 			if (!rn2(25) && mtmp->mhp < mtmp->mhpmax / 2) {
    431   1.1       cgd 				mtmp->mflee = 1;
    432   1.4  christos 				if (!rn2(3))
    433   1.4  christos 					mtmp->mfleetim = rnd(100);
    434   1.4  christos 				if (u.ustuck == mtmp && !u.uswallow)
    435   1.1       cgd 					u.ustuck = 0;
    436   1.1       cgd 			}
    437   1.1       cgd #ifndef NOWORM
    438   1.4  christos 			if (mtmp->wormno)
    439   1.4  christos 				cutworm(mtmp, u.ux + u.dx, u.uy + u.dy,
    440   1.1       cgd 					uwep ? uwep->otyp : 0);
    441   1.4  christos #endif	/* NOWORM */
    442   1.1       cgd 		}
    443   1.4  christos 		if (mdat->mlet == 'a') {
    444   1.4  christos 			if (rn2(2)) {
    445   1.1       cgd 				pline("You are splashed by the blob's acid!");
    446   1.1       cgd 				losehp_m(rnd(6), mtmp);
    447   1.4  christos 				if (!rn2(30))
    448   1.4  christos 					corrode_armor();
    449   1.1       cgd 			}
    450   1.4  christos 			if (!rn2(6))
    451   1.4  christos 				corrode_weapon();
    452   1.1       cgd 		}
    453   1.1       cgd 	}
    454   1.4  christos 	if (malive && mdat->mlet == 'E' && canseemon(mtmp)
    455   1.4  christos 	    && !mtmp->mcan && rn2(3)) {
    456   1.4  christos 		if (mtmp->mcansee) {
    457   1.4  christos 			pline("You are frozen by the floating eye's gaze!");
    458   1.4  christos 			nomul((u.ulevel > 6 || rn2(4)) ? rn1(20, -21) : -200);
    459   1.4  christos 		} else {
    460   1.4  christos 			pline("The blinded floating eye cannot defend itself.");
    461   1.4  christos 			if (!rn2(500))
    462   1.4  christos 				if ((int) u.uluck > LUCKMIN)
    463   1.4  christos 					u.uluck--;
    464   1.4  christos 		}
    465   1.1       cgd 	}
    466   1.4  christos 	return (TRUE);
    467   1.1       cgd }
    468