# Source:NetHack 3.6.1/src/uhitm.c
Below is the full text to uhitm.c from the source code of NetHack 3.6.1. To link to a particular line, write [[Source:NetHack 3.6.1/src/uhitm.c#line123]], for example.

Contents

1 Top of file
2 erode_armor
3 attack_checks
4 check_caitiff
5 find_roll_to_hit
6 attack
7 known_hitum
8 hitum_cleave
9 hitum
10 hmon
11 hmon_hitmon
12 shade_aware
13 m_slips_free
14 joust
15 demonpet
16 theft_petrifies
17 steal_it
18 damageum
19 explum
20 start_engulf
21 end_engulf
22 gulpum
23 missum
24 hmonas
25 passive
26 passive_obj
27 stumble_onto_mimic
28 nohandglow
29 flash_hits_mon
30 light_hits_gremlin

Top of file
&nbsp;/* NetHack 3.6	uhitm.c	$NHDT-Date: 1521684760 2018/03/22 02:12:40 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.176 $ */
&nbsp;/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
&nbsp;/*-Copyright (c) Robert Patrick Rankin, 2012. */
&nbsp;/* NetHack may be freely redistributed.  See license for details. */

The NetHack General Public License applies to screenshots, source code and other content from NetHack.
This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

&nbsp;
&nbsp;#include "hack.h"
&nbsp;
&nbsp;STATIC_DCL boolean FDECL(known_hitum, (struct monst *, struct obj *, int *,
&nbsp;                                       int, int, struct attack *, int));
&nbsp;STATIC_DCL boolean FDECL(theft_petrifies, (struct obj *));
&nbsp;STATIC_DCL void FDECL(steal_it, (struct monst *, struct attack *));
&nbsp;STATIC_DCL boolean FDECL(hitum_cleave, (struct monst *, struct attack *));
&nbsp;STATIC_DCL boolean FDECL(hitum, (struct monst *, struct attack *));
&nbsp;STATIC_DCL boolean FDECL(hmon_hitmon, (struct monst *, struct obj *, int,
&nbsp;                                       int));
&nbsp;STATIC_DCL int FDECL(joust, (struct monst *, struct obj *));
&nbsp;STATIC_DCL void NDECL(demonpet);
&nbsp;STATIC_DCL boolean FDECL(m_slips_free, (struct monst *, struct attack *));
&nbsp;STATIC_DCL int FDECL(explum, (struct monst *, struct attack *));
&nbsp;STATIC_DCL void FDECL(start_engulf, (struct monst *));
&nbsp;STATIC_DCL void NDECL(end_engulf);
&nbsp;STATIC_DCL int FDECL(gulpum, (struct monst *, struct attack *));
&nbsp;STATIC_DCL boolean FDECL(hmonas, (struct monst *));
&nbsp;STATIC_DCL void FDECL(nohandglow, (struct monst *));
&nbsp;STATIC_DCL boolean FDECL(shade_aware, (struct obj *));
&nbsp;
&nbsp;extern boolean notonhead; /* for long worms */
&nbsp;
&nbsp;/* Used to flag attacks caused by Stormbringer's maliciousness. */
&nbsp;static boolean override_confirmation = FALSE;
&nbsp;
&nbsp;#define PROJECTILE(obj) ((obj) &amp;&amp; is_ammo(obj))
&nbsp;
erode_armor
&nbsp;void
&nbsp;erode_armor(mdef, hurt)
&nbsp;struct monst *mdef;
&nbsp;int hurt;
&nbsp;{
&nbsp;    struct obj *target;
&nbsp;
&nbsp;    /* What the following code does: it keeps looping until it
&nbsp;     * finds a target for the rust monster.
&nbsp;     * Head, feet, etc... not covered by metal, or covered by
&nbsp;     * rusty metal, are not targets.  However, your body always
&nbsp;     * is, no matter what covers it.
&nbsp;     */
&nbsp;    while (1) {
&nbsp;        switch (rn2(5)) {
&nbsp;        case 0:
&nbsp;            target = which_armor(mdef, W_ARMH);
&nbsp;            if (!target
&nbsp;                || erode_obj(target, xname(target), hurt, EF_GREASE)
&nbsp;                       == ER_NOTHING)
&nbsp;                continue;
&nbsp;            break;
&nbsp;        case 1:
&nbsp;            target = which_armor(mdef, W_ARMC);
&nbsp;            if (target) {
&nbsp;                (void) erode_obj(target, xname(target), hurt,
&nbsp;                                 EF_GREASE | EF_VERBOSE);
&nbsp;                break;
&nbsp;            }
&nbsp;            if ((target = which_armor(mdef, W_ARM)) != (struct obj *) 0) {
&nbsp;                (void) erode_obj(target, xname(target), hurt,
&nbsp;                                 EF_GREASE | EF_VERBOSE);
&nbsp;            } else if ((target = which_armor(mdef, W_ARMU))
&nbsp;                       != (struct obj *) 0) {
&nbsp;                (void) erode_obj(target, xname(target), hurt,
&nbsp;                                 EF_GREASE | EF_VERBOSE);
&nbsp;            }
&nbsp;            break;
&nbsp;        case 2:
&nbsp;            target = which_armor(mdef, W_ARMS);
&nbsp;            if (!target
&nbsp;                || erode_obj(target, xname(target), hurt, EF_GREASE)
&nbsp;                       == ER_NOTHING)
&nbsp;                continue;
&nbsp;            break;
&nbsp;        case 3:
&nbsp;            target = which_armor(mdef, W_ARMG);
&nbsp;            if (!target
&nbsp;                || erode_obj(target, xname(target), hurt, EF_GREASE)
&nbsp;                       == ER_NOTHING)
&nbsp;                continue;
&nbsp;            break;
&nbsp;        case 4:
&nbsp;            target = which_armor(mdef, W_ARMF);
&nbsp;            if (!target
&nbsp;                || erode_obj(target, xname(target), hurt, EF_GREASE)
&nbsp;                       == ER_NOTHING)
&nbsp;                continue;
&nbsp;            break;
&nbsp;        }
&nbsp;        break; /* Out of while loop */
&nbsp;    }
&nbsp;}
&nbsp;
attack_checks
&nbsp;/* FALSE means it's OK to attack */
&nbsp;boolean
&nbsp;attack_checks(mtmp, wep)
&nbsp;register struct monst *mtmp;
&nbsp;struct obj *wep; /* uwep for attack(), null for kick_monster() */
&nbsp;{
&nbsp;    char qbuf[QBUFSZ];
&nbsp;
&nbsp;    /* if you're close enough to attack, alert any waiting monster */
&nbsp;    mtmp-&gt;mstrategy &amp;= ~STRAT_WAITMASK;
&nbsp;
&nbsp;    if (u.uswallow &amp;&amp; mtmp == u.ustuck)
&nbsp;        return FALSE;
&nbsp;
&nbsp;    if (context.forcefight) {
&nbsp;        /* Do this in the caller, after we checked that the monster
&nbsp;         * didn't die from the blow.  Reason: putting the 'I' there
&nbsp;         * causes the hero to forget the square's contents since
&nbsp;         * both 'I' and remembered contents are stored in .glyph.
&nbsp;         * If the monster dies immediately from the blow, the 'I' will
&nbsp;         * not stay there, so the player will have suddenly forgotten
&nbsp;         * the square's contents for no apparent reason.
&nbsp;        if (!canspotmon(mtmp)
&nbsp;            &amp;&amp; !glyph_is_invisible(levl[bhitpos.x][bhitpos.y].glyph))
&nbsp;            map_invisible(bhitpos.x, bhitpos.y);
&nbsp;         */
&nbsp;        return FALSE;
&nbsp;    }
&nbsp;
&nbsp;    /* Put up an invisible monster marker, but with exceptions for
&nbsp;     * monsters that hide and monsters you've been warned about.
&nbsp;     * The former already prints a warning message and
&nbsp;     * prevents you from hitting the monster just via the hidden monster
&nbsp;     * code below; if we also did that here, similar behavior would be
&nbsp;     * happening two turns in a row.  The latter shows a glyph on
&nbsp;     * the screen, so you know something is there.
&nbsp;     */
&nbsp;    if (!canspotmon(mtmp) &amp;&amp; !glyph_is_warning(glyph_at(bhitpos.x, bhitpos.y))
&nbsp;        &amp;&amp; !glyph_is_invisible(levl[bhitpos.x][bhitpos.y].glyph)
&nbsp;        &amp;&amp; !(!Blind &amp;&amp; mtmp-&gt;mundetected &amp;&amp; hides_under(mtmp-&gt;data))) {
&nbsp;        pline("Wait!  There's %s there you can't see!", something);
&nbsp;        map_invisible(bhitpos.x, bhitpos.y);
&nbsp;        /* if it was an invisible mimic, treat it as if we stumbled
&nbsp;         * onto a visible mimic
&nbsp;         */
&nbsp;        if (mtmp-&gt;m_ap_type &amp;&amp; !Protection_from_shape_changers
&nbsp;            /* applied pole-arm attack is too far to get stuck */
&nbsp;            &amp;&amp; distu(mtmp-&gt;mx, mtmp-&gt;my) &lt;= 2) {
&nbsp;            if (!u.ustuck &amp;&amp; !mtmp-&gt;mflee &amp;&amp; dmgtype(mtmp-&gt;data, AD_STCK))
&nbsp;                u.ustuck = mtmp;
&nbsp;        }
&nbsp;        wakeup(mtmp, TRUE); /* always necessary; also un-mimics mimics */
&nbsp;        return TRUE;
&nbsp;    }
&nbsp;
&nbsp;    if (mtmp-&gt;m_ap_type &amp;&amp; !Protection_from_shape_changers &amp;&amp; !sensemon(mtmp)
&nbsp;        &amp;&amp; !glyph_is_warning(glyph_at(bhitpos.x, bhitpos.y))) {
&nbsp;        /* If a hidden mimic was in a square where a player remembers
&nbsp;         * some (probably different) unseen monster, the player is in
&nbsp;         * luck--he attacks it even though it's hidden.
&nbsp;         */
&nbsp;        if (glyph_is_invisible(levl[mtmp-&gt;mx][mtmp-&gt;my].glyph)) {
&nbsp;            seemimic(mtmp);
&nbsp;            return FALSE;
&nbsp;        }
&nbsp;        stumble_onto_mimic(mtmp);
&nbsp;        return TRUE;
&nbsp;    }
&nbsp;
&nbsp;    if (mtmp-&gt;mundetected &amp;&amp; !canseemon(mtmp)
&nbsp;        &amp;&amp; !glyph_is_warning(glyph_at(bhitpos.x, bhitpos.y))
&nbsp;        &amp;&amp; (hides_under(mtmp-&gt;data) || mtmp-&gt;data-&gt;mlet == S_EEL)) {
&nbsp;        mtmp-&gt;mundetected = mtmp-&gt;msleeping = 0;
&nbsp;        newsym(mtmp-&gt;mx, mtmp-&gt;my);
&nbsp;        if (glyph_is_invisible(levl[mtmp-&gt;mx][mtmp-&gt;my].glyph)) {
&nbsp;            seemimic(mtmp);
&nbsp;            return FALSE;
&nbsp;        }
&nbsp;        if (!((Blind ? Blind_telepat : Unblind_telepat) || Detect_monsters)) {
&nbsp;            struct obj *obj;
&nbsp;
&nbsp;            if (Blind || (is_pool(mtmp-&gt;mx, mtmp-&gt;my) &amp;&amp; !Underwater))
&nbsp;                pline("Wait!  There's a hidden monster there!");
&nbsp;            else if ((obj = level.objects[mtmp-&gt;mx][mtmp-&gt;my]) != 0)
&nbsp;                pline("Wait!  There's %s hiding under %s!",
&nbsp;                      an(l_monnam(mtmp)), doname(obj));
&nbsp;            return TRUE;
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    /*
&nbsp;     * make sure to wake up a monster from the above cases if the
&nbsp;     * hero can sense that the monster is there.
&nbsp;     */
&nbsp;    if ((mtmp-&gt;mundetected || mtmp-&gt;m_ap_type) &amp;&amp; sensemon(mtmp)) {
&nbsp;        mtmp-&gt;mundetected = 0;
&nbsp;        wakeup(mtmp, TRUE);
&nbsp;    }
&nbsp;
&nbsp;    if (flags.confirm &amp;&amp; mtmp-&gt;mpeaceful &amp;&amp; !Confusion &amp;&amp; !Hallucination
&nbsp;        &amp;&amp; !Stunned) {
&nbsp;        /* Intelligent chaotic weapons (Stormbringer) want blood */
&nbsp;        if (wep &amp;&amp; wep-&gt;oartifact == ART_STORMBRINGER) {
&nbsp;            override_confirmation = TRUE;
&nbsp;            return FALSE;
&nbsp;        }
&nbsp;        if (canspotmon(mtmp)) {
&nbsp;            Sprintf(qbuf, "Really attack %s?", mon_nam(mtmp));
&nbsp;            if (!paranoid_query(ParanoidHit, qbuf)) {
&nbsp;                context.move = 0;
&nbsp;                return TRUE;
&nbsp;            }
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    return FALSE;
&nbsp;}
&nbsp;
check_caitiff
&nbsp;/*
&nbsp; * It is unchivalrous for a knight to attack the defenseless or from behind.
&nbsp; */
&nbsp;void
&nbsp;check_caitiff(mtmp)
&nbsp;struct monst *mtmp;
&nbsp;{
&nbsp;    if (u.ualign.record &lt;= -10)
&nbsp;        return;
&nbsp;
&nbsp;    if (Role_if(PM_KNIGHT) &amp;&amp; u.ualign.type == A_LAWFUL
&nbsp;        &amp;&amp; (!mtmp-&gt;mcanmove || mtmp-&gt;msleeping
&nbsp;            || (mtmp-&gt;mflee &amp;&amp; !mtmp-&gt;mavenge))) {
&nbsp;        You("caitiff!");
&nbsp;        adjalign(-1);
&nbsp;    } else if (Role_if(PM_SAMURAI) &amp;&amp; mtmp-&gt;mpeaceful) {
&nbsp;        /* attacking peaceful creatures is bad for the samurai's giri */
&nbsp;        You("dishonorably attack the innocent!");
&nbsp;        adjalign(-1);
&nbsp;    }
&nbsp;}
&nbsp;
find_roll_to_hit
&nbsp;int
&nbsp;find_roll_to_hit(mtmp, aatyp, weapon, attk_count, role_roll_penalty)
&nbsp;register struct monst *mtmp;
&nbsp;uchar aatyp;        /* usually AT_WEAP or AT_KICK */
&nbsp;struct obj *weapon; /* uwep or uswapwep or NULL */
&nbsp;int *attk_count, *role_roll_penalty;
&nbsp;{
&nbsp;    int tmp, tmp2;
&nbsp;
&nbsp;    *role_roll_penalty = 0; /* default is `none' */
&nbsp;
&nbsp;    tmp = 1 + Luck + abon() + find_mac(mtmp) + u.uhitinc
&nbsp;          + maybe_polyd(youmonst.data-&gt;mlevel, u.ulevel);
&nbsp;
&nbsp;    /* some actions should occur only once during multiple attacks */
&nbsp;    if (!(*attk_count)++) {
&nbsp;        /* knight's chivalry or samurai's giri */
&nbsp;        check_caitiff(mtmp);
&nbsp;    }
&nbsp;
&nbsp;    /* adjust vs. (and possibly modify) monster state */
&nbsp;    if (mtmp-&gt;mstun)
&nbsp;        tmp += 2;
&nbsp;    if (mtmp-&gt;mflee)
&nbsp;        tmp += 2;
&nbsp;
&nbsp;    if (mtmp-&gt;msleeping) {
&nbsp;        mtmp-&gt;msleeping = 0;
&nbsp;        tmp += 2;
&nbsp;    }
&nbsp;    if (!mtmp-&gt;mcanmove) {
&nbsp;        tmp += 4;
&nbsp;        if (!rn2(10)) {
&nbsp;            mtmp-&gt;mcanmove = 1;
&nbsp;            mtmp-&gt;mfrozen = 0;
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    /* role/race adjustments */
&nbsp;    if (Role_if(PM_MONK) &amp;&amp; !Upolyd) {
&nbsp;        if (uarm)
&nbsp;            tmp -= (*role_roll_penalty = urole.spelarmr);
&nbsp;        else if (!uwep &amp;&amp; !uarms)
&nbsp;            tmp += (u.ulevel / 3) + 2;
&nbsp;    }
&nbsp;    if (is_orc(mtmp-&gt;data)
&nbsp;        &amp;&amp; maybe_polyd(is_elf(youmonst.data), Race_if(PM_ELF)))
&nbsp;        tmp++;
&nbsp;
&nbsp;    /* encumbrance: with a lot of luggage, your agility diminishes */
&nbsp;    if ((tmp2 = near_capacity()) != 0)
&nbsp;        tmp -= (tmp2 * 2) - 1;
&nbsp;    if (u.utrap)
&nbsp;        tmp -= 3;
&nbsp;
&nbsp;    /*
&nbsp;     * hitval applies if making a weapon attack while wielding a weapon;
&nbsp;     * weapon_hit_bonus applies if doing a weapon attack even bare-handed
&nbsp;     * or if kicking as martial artist
&nbsp;     */
&nbsp;    if (aatyp == AT_WEAP || aatyp == AT_CLAW) {
&nbsp;        if (weapon)
&nbsp;            tmp += hitval(weapon, mtmp);
&nbsp;        tmp += weapon_hit_bonus(weapon);
&nbsp;    } else if (aatyp == AT_KICK &amp;&amp; martial_bonus()) {
&nbsp;        tmp += weapon_hit_bonus((struct obj *) 0);
&nbsp;    }
&nbsp;
&nbsp;    return tmp;
&nbsp;}
&nbsp;
attack
&nbsp;/* try to attack; return False if monster evaded;
&nbsp;   u.dx and u.dy must be set */
&nbsp;boolean
&nbsp;attack(mtmp)
&nbsp;register struct monst *mtmp;
&nbsp;{
&nbsp;    register struct permonst *mdat = mtmp-&gt;data;
&nbsp;
&nbsp;    /* This section of code provides protection against accidentally
&nbsp;     * hitting peaceful (like '@') and tame (like 'd') monsters.
&nbsp;     * Protection is provided as long as player is not: blind, confused,
&nbsp;     * hallucinating or stunned.
&nbsp;     * changes by wwp 5/16/85
&nbsp;     * More changes 12/90, -dkh-. if its tame and safepet, (and protected
&nbsp;     * 07/92) then we assume that you're not trying to attack. Instead,
&nbsp;     * you'll usually just swap places if this is a movement command
&nbsp;     */
&nbsp;    /* Intelligent chaotic weapons (Stormbringer) want blood */
&nbsp;    if (is_safepet(mtmp) &amp;&amp; !context.forcefight) {
&nbsp;        if (!uwep || uwep-&gt;oartifact != ART_STORMBRINGER) {
&nbsp;            /* there are some additional considerations: this won't work
&nbsp;             * if in a shop or Punished or you miss a random roll or
&nbsp;             * if you can walk thru walls and your pet cannot (KAA) or
&nbsp;             * if your pet is a long worm (unless someone does better).
&nbsp;             * there's also a chance of displacing a "frozen" monster.
&nbsp;             * sleeping monsters might magically walk in their sleep.
&nbsp;             */
&nbsp;            boolean foo = (Punished || !rn2(7) || is_longworm(mtmp-&gt;data)),
&nbsp;                    inshop = FALSE;
&nbsp;            char *p;
&nbsp;
&nbsp;            for (p = in_rooms(mtmp-&gt;mx, mtmp-&gt;my, SHOPBASE); *p; p++)
&nbsp;                if (tended_shop(&amp;rooms[*p - ROOMOFFSET])) {
&nbsp;                    inshop = TRUE;
&nbsp;                    break;
&nbsp;                }
&nbsp;
&nbsp;            if (inshop || foo || (IS_ROCK(levl[u.ux][u.uy].typ)
&nbsp;                                  &amp;&amp; !passes_walls(mtmp-&gt;data))) {
&nbsp;                char buf[BUFSZ];
&nbsp;
&nbsp;                monflee(mtmp, rnd(6), FALSE, FALSE);
&nbsp;                Strcpy(buf, y_monnam(mtmp));
&nbsp;                buf[0] = highc(buf[0]);
&nbsp;                You("stop.  %s is in the way!", buf);
&nbsp;                context.travel = context.travel1 = context.mv = context.run = 0;
&nbsp;                return TRUE;
&nbsp;            } else if ((mtmp-&gt;mfrozen || (!mtmp-&gt;mcanmove)
&nbsp;                        || (mtmp-&gt;data-&gt;mmove == 0)) &amp;&amp; rn2(6)) {
&nbsp;                pline("%s doesn't seem to move!", Monnam(mtmp));
&nbsp;                context.travel = context.travel1 = context.mv = context.run = 0;
&nbsp;                return TRUE;
&nbsp;            } else
&nbsp;                return FALSE;
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    /* possibly set in attack_checks;
&nbsp;       examined in known_hitum, called via hitum or hmonas below */
&nbsp;    override_confirmation = FALSE;
&nbsp;    /* attack_checks() used to use 

<u.ux+u.dx,u.uy+u.dy> directly, now
&nbsp;       it uses bhitpos instead; it might map an invisible monster there */
&nbsp;    bhitpos.x = u.ux + u.dx;
&nbsp;    bhitpos.y = u.uy + u.dy;
&nbsp;    if (attack_checks(mtmp, uwep))
&nbsp;        return TRUE;
&nbsp;
&nbsp;    if (Upolyd &amp;&amp; noattacks(youmonst.data)) {
&nbsp;        /* certain "pacifist" monsters don't attack */
&nbsp;        You("have no way to attack monsters physically.");
&nbsp;        mtmp-&gt;mstrategy &amp;= ~STRAT_WAITMASK;
&nbsp;        goto atk_done;
&nbsp;    }
&nbsp;
&nbsp;    if (check_capacity("You cannot fight while so heavily loaded.")
&nbsp;        /* consume extra nutrition during combat; maybe pass out */
&nbsp;        || overexertion())
&nbsp;        goto atk_done;
&nbsp;
&nbsp;    if (u.twoweap &amp;&amp; !can_twoweapon())
&nbsp;        untwoweapon();
&nbsp;
&nbsp;    if (unweapon) {
&nbsp;        unweapon = FALSE;
&nbsp;        if (flags.verbose) {
&nbsp;            if (uwep)
&nbsp;                You("begin bashing monsters with %s.", yname(uwep));
&nbsp;            else if (!cantwield(youmonst.data))
&nbsp;                You("begin %s monsters with your %s %s.",
&nbsp;                    ing_suffix(Role_if(PM_MONK) ? "strike" : "bash"),
&nbsp;                    uarmg ? "gloved" : "bare", /* Del Lamb */
&nbsp;                    makeplural(body_part(HAND)));
&nbsp;        }
&nbsp;    }
&nbsp;    exercise(A_STR, TRUE); /* you're exercising muscles */
&nbsp;    /* andrew@orca: prevent unlimited pick-axe attacks */
&nbsp;    u_wipe_engr(3);
&nbsp;
&nbsp;    /* Is the "it died" check actually correct? */
&nbsp;    if (mdat-&gt;mlet == S_LEPRECHAUN &amp;&amp; !mtmp-&gt;mfrozen &amp;&amp; !mtmp-&gt;msleeping
&nbsp;        &amp;&amp; !mtmp-&gt;mconf &amp;&amp; mtmp-&gt;mcansee &amp;&amp; !rn2(7)
&nbsp;        &amp;&amp; (m_move(mtmp, 0) == 2 /* it died */
&nbsp;            || mtmp-&gt;mx != u.ux + u.dx
&nbsp;            || mtmp-&gt;my != u.uy + u.dy)) /* it moved */
&nbsp;        return FALSE;
&nbsp;
&nbsp;    if (Upolyd)
&nbsp;        (void) hmonas(mtmp);
&nbsp;    else
&nbsp;        (void) hitum(mtmp, youmonst.data-&gt;mattk);
&nbsp;    mtmp-&gt;mstrategy &amp;= ~STRAT_WAITMASK;
&nbsp;
&nbsp;atk_done:
&nbsp;    /* see comment in attack_checks() */
&nbsp;    /* we only need to check for this if we did an attack_checks()
&nbsp;     * and it returned 0 (it's okay to attack), and the monster didn't
&nbsp;     * evade.
&nbsp;     */
&nbsp;    if (context.forcefight &amp;&amp; mtmp-&gt;mhp &gt; 0 &amp;&amp; !canspotmon(mtmp)
&nbsp;        &amp;&amp; !glyph_is_invisible(levl[u.ux + u.dx][u.uy + u.dy].glyph)
&nbsp;        &amp;&amp; !(u.uswallow &amp;&amp; mtmp == u.ustuck))
&nbsp;        map_invisible(u.ux + u.dx, u.uy + u.dy);
&nbsp;
&nbsp;    return TRUE;
&nbsp;}
&nbsp;
known_hitum
&nbsp;/* really hit target monster; returns TRUE if it still lives */
&nbsp;STATIC_OVL boolean
&nbsp;known_hitum(mon, weapon, mhit, rollneeded, armorpenalty, uattk, dieroll)
&nbsp;register struct monst *mon;
&nbsp;struct obj *weapon;
&nbsp;int *mhit;
&nbsp;int rollneeded, armorpenalty; /* for monks */
&nbsp;struct attack *uattk;
&nbsp;int dieroll;
&nbsp;{
&nbsp;    register boolean malive = TRUE;
&nbsp;
&nbsp;    if (override_confirmation) {
&nbsp;        /* this may need to be generalized if weapons other than
&nbsp;           Stormbringer acquire similar anti-social behavior... */
&nbsp;        if (flags.verbose)
&nbsp;            Your("bloodthirsty blade attacks!");
&nbsp;    }
&nbsp;
&nbsp;    if (!*mhit) {
&nbsp;        missum(mon, uattk, (rollneeded + armorpenalty &gt; dieroll));
&nbsp;    } else {
&nbsp;        int oldhp = mon-&gt;mhp, x = u.ux + u.dx, y = u.uy + u.dy;
&nbsp;        long oldweaphit = u.uconduct.weaphit;
&nbsp;
&nbsp;        /* KMH, conduct */
&nbsp;        if (weapon &amp;&amp; (weapon-&gt;oclass == WEAPON_CLASS || is_weptool(weapon)))
&nbsp;            u.uconduct.weaphit++;
&nbsp;
&nbsp;        /* we hit the monster; be careful: it might die or
&nbsp;           be knocked into a different location */
&nbsp;        notonhead = (mon-&gt;mx != x || mon-&gt;my != y);
&nbsp;        malive = hmon(mon, weapon, HMON_MELEE, dieroll);
&nbsp;        if (malive) {
&nbsp;            /* monster still alive */
&nbsp;            if (!rn2(25) &amp;&amp; mon-&gt;mhp &lt; mon-&gt;mhpmax / 2
&nbsp;                &amp;&amp; !(u.uswallow &amp;&amp; mon == u.ustuck)) {
&nbsp;                /* maybe should regurgitate if swallowed? */
&nbsp;                monflee(mon, !rn2(3) ? rnd(100) : 0, FALSE, TRUE);
&nbsp;
&nbsp;                if (u.ustuck == mon &amp;&amp; !u.uswallow &amp;&amp; !sticks(youmonst.data))
&nbsp;                    u.ustuck = 0;
&nbsp;            }
&nbsp;            /* Vorpal Blade hit converted to miss */
&nbsp;            /* could be headless monster or worm tail */
&nbsp;            if (mon-&gt;mhp == oldhp) {
&nbsp;                *mhit = 0;
&nbsp;                /* a miss does not break conduct */
&nbsp;                u.uconduct.weaphit = oldweaphit;
&nbsp;            }
&nbsp;            if (mon-&gt;wormno &amp;&amp; *mhit)
&nbsp;                cutworm(mon, x, y, weapon);
&nbsp;        }
&nbsp;    }
&nbsp;    return malive;
&nbsp;}
&nbsp;
hitum_cleave
&nbsp;/* hit the monster next to you and the monsters to the left and right of it;
&nbsp;   return False if the primary target is killed, True otherwise */
&nbsp;STATIC_OVL boolean
&nbsp;hitum_cleave(target, uattk)
&nbsp;struct monst *target; /* non-Null; forcefight at nothing doesn't cleave... */
&nbsp;struct attack *uattk; /* ... but we don't enforce that here; Null works ok */
&nbsp;{
&nbsp;    /* swings will be delivered in alternate directions; with consecutive
&nbsp;       attacks it will simulate normal swing and backswing; when swings
&nbsp;       are non-consecutive, hero will sometimes start a series of attacks
&nbsp;       with a backswing--that doesn't impact actual play, just spoils the
&nbsp;       simulation attempt a bit */
&nbsp;    static boolean clockwise = FALSE;
&nbsp;    unsigned i;
&nbsp;    int count, umort, x = u.ux, y = u.uy;
&nbsp;
&nbsp;    /* find the direction toward primary target */
&nbsp;    for (i = 0; i &lt; 8; ++i)
&nbsp;        if (xdir[i] == u.dx &amp;&amp; ydir[i] == u.dy)
&nbsp;            break;
&nbsp;    if (i == 8) {
&nbsp;        impossible("hitum_cleave: unknown target direction [%d,%d,%d]?",
&nbsp;                   u.dx, u.dy, u.dz);
&nbsp;        return TRUE; /* target hasn't been killed */
&nbsp;    }
&nbsp;    /* adjust direction by two so that loop's increment (for clockwise)
&nbsp;       or decrement (for counter-clockwise) will point at the spot next
&nbsp;       to primary target */
&nbsp;    i = (i + (clockwise ? 6 : 2)) % 8;
&nbsp;    umort = u.umortality; /* used to detect life-saving */
&nbsp;
&nbsp;    /*
&nbsp;     * Three attacks:  adjacent to primary, primary, adjacent on other
&nbsp;     * side.  Primary target must be present or we wouldn't have gotten
&nbsp;     * here (forcefight at thin air won't 'cleave').  However, the
&nbsp;     * first attack might kill it (gas spore explosion, weak long worm
&nbsp;     * occupying both spots) so we don't assume that it's still present
&nbsp;     * on the second attack.
&nbsp;     */
&nbsp;    for (count = 3; count &gt; 0; --count) {
&nbsp;        struct monst *mtmp;
&nbsp;        int tx, ty, tmp, dieroll, mhit, attknum, armorpenalty;
&nbsp;
&nbsp;        /* ++i, wrap 8 to i=0 /or/ --i, wrap -1 to i=7 */
&nbsp;        i = (i + (clockwise ? 1 : 7)) % 8;
&nbsp;
&nbsp;        tx = x + xdir[i], ty = y + ydir[i]; /* current target location */
&nbsp;        if (!isok(tx, ty))
&nbsp;            continue;
&nbsp;        mtmp = m_at(tx, ty);
&nbsp;        if (!mtmp) {
&nbsp;            if (glyph_is_invisible(levl[tx][ty].glyph))
&nbsp;                (void) unmap_invisible(tx, ty);
&nbsp;            continue;
&nbsp;        }
&nbsp;
&nbsp;        tmp = find_roll_to_hit(mtmp, uattk-&gt;aatyp, uwep,
&nbsp;                               &amp;attknum, &amp;armorpenalty);
&nbsp;        dieroll = rnd(20);
&nbsp;        mhit = (tmp &gt; dieroll);
&nbsp;        (void) known_hitum(mtmp, uwep, &amp;mhit, tmp, armorpenalty,
&nbsp;                           uattk, dieroll);
&nbsp;        (void) passive(mtmp, uwep, mhit, !DEADMONSTER(mtmp), AT_WEAP, !uwep);
&nbsp;
&nbsp;        /* stop attacking if weapon is gone or hero got killed and
&nbsp;           life-saved after passive counter-attack */
&nbsp;        if (!uwep || u.umortality &gt; umort)
&nbsp;            break;
&nbsp;    }
&nbsp;    /* set up for next time */
&nbsp;    clockwise = !clockwise; /* alternate */
&nbsp;
&nbsp;    /* return False if primary target died, True otherwise; note: if 'target'
&nbsp;       was nonNull upon entry then it's still nonNull even if *target died */
&nbsp;    return (target &amp;&amp; DEADMONSTER(target)) ? FALSE : TRUE;
&nbsp;}
&nbsp;
hitum
&nbsp;/* hit target monster; returns TRUE if it still lives */
&nbsp;STATIC_OVL boolean
&nbsp;hitum(mon, uattk)
&nbsp;struct monst *mon;
&nbsp;struct attack *uattk;
&nbsp;{
&nbsp;    boolean malive, wep_was_destroyed = FALSE;
&nbsp;    struct obj *wepbefore = uwep;
&nbsp;    int armorpenalty, attknum = 0, x = u.ux + u.dx, y = u.uy + u.dy,
&nbsp;                      tmp = find_roll_to_hit(mon, uattk-&gt;aatyp, uwep,
&nbsp;                                             &amp;attknum, &amp;armorpenalty);
&nbsp;    int dieroll = rnd(20);
&nbsp;    int mhit = (tmp &gt; dieroll || u.uswallow);
&nbsp;
&nbsp;    /* Cleaver attacks three spots, 'mon' and one on either side of 'mon';
&nbsp;       it can't be part of dual-wielding but we guard against that anyway;
&nbsp;       cleave return value reflects status of primary target ('mon') */
&nbsp;    if (uwep &amp;&amp; uwep-&gt;oartifact == ART_CLEAVER &amp;&amp; !u.twoweap
&nbsp;        &amp;&amp; !u.uswallow &amp;&amp; !u.ustuck &amp;&amp; !NODIAG(u.umonnum))
&nbsp;        return hitum_cleave(mon, uattk);
&nbsp;
&nbsp;    if (tmp &gt; dieroll)
&nbsp;        exercise(A_DEX, TRUE);
&nbsp;    malive = known_hitum(mon, uwep, &amp;mhit, tmp, armorpenalty, uattk, dieroll);
&nbsp;    if (wepbefore &amp;&amp; !uwep)
&nbsp;        wep_was_destroyed = TRUE;
&nbsp;    (void) passive(mon, uwep, mhit, malive, AT_WEAP, wep_was_destroyed);
&nbsp;
&nbsp;    /* second attack for two-weapon combat; won't occur if Stormbringer
&nbsp;       overrode confirmation (assumes Stormbringer is primary weapon)
&nbsp;       or if the monster was killed or knocked to different location */
&nbsp;    if (u.twoweap &amp;&amp; !override_confirmation &amp;&amp; malive &amp;&amp; m_at(x, y) == mon) {
&nbsp;        tmp = find_roll_to_hit(mon, uattk-&gt;aatyp, uswapwep, &amp;attknum,
&nbsp;                               &amp;armorpenalty);
&nbsp;        dieroll = rnd(20);
&nbsp;        mhit = (tmp &gt; dieroll || u.uswallow);
&nbsp;        malive = known_hitum(mon, uswapwep, &amp;mhit, tmp, armorpenalty, uattk,
&nbsp;                             dieroll);
&nbsp;        /* second passive counter-attack only occurs if second attack hits */
&nbsp;        if (mhit)
&nbsp;            (void) passive(mon, uswapwep, mhit, malive, AT_WEAP, !uswapwep);
&nbsp;    }
&nbsp;    return malive;
&nbsp;}
&nbsp;
hmon
&nbsp;/* general "damage monster" routine; return True if mon still alive */
&nbsp;boolean
&nbsp;hmon(mon, obj, thrown, dieroll)
&nbsp;struct monst *mon;
&nbsp;struct obj *obj;
&nbsp;int thrown; /* HMON_xxx (0 =&gt; hand-to-hand, other =&gt; ranged) */
&nbsp;int dieroll;
&nbsp;{
&nbsp;    boolean result, anger_guards;
&nbsp;
&nbsp;    anger_guards = (mon-&gt;mpeaceful
&nbsp;                    &amp;&amp; (mon-&gt;ispriest || mon-&gt;isshk || is_watch(mon-&gt;data)));
&nbsp;    result = hmon_hitmon(mon, obj, thrown, dieroll);
&nbsp;    if (mon-&gt;ispriest &amp;&amp; !rn2(2))
&nbsp;        ghod_hitsu(mon);
&nbsp;    if (anger_guards)
&nbsp;        (void) angry_guards(!!Deaf);
&nbsp;    return result;
&nbsp;}
&nbsp;
hmon_hitmon
&nbsp;/* guts of hmon() */
&nbsp;STATIC_OVL boolean
&nbsp;hmon_hitmon(mon, obj, thrown, dieroll)
&nbsp;struct monst *mon;
&nbsp;struct obj *obj;
&nbsp;int thrown; /* HMON_xxx (0 =&gt; hand-to-hand, other =&gt; ranged) */
&nbsp;int dieroll;
&nbsp;{
&nbsp;    int tmp;
&nbsp;    struct permonst *mdat = mon-&gt;data;
&nbsp;    int barehand_silver_rings = 0;
&nbsp;    /* The basic reason we need all these booleans is that we don't want
&nbsp;     * a "hit" message when a monster dies, so we have to know how much
&nbsp;     * damage it did _before_ outputting a hit message, but any messages
&nbsp;     * associated with the damage don't come out until _after_ outputting
&nbsp;     * a hit message.
&nbsp;     */
&nbsp;    boolean hittxt = FALSE, destroyed = FALSE, already_killed = FALSE;
&nbsp;    boolean get_dmg_bonus = TRUE;
&nbsp;    boolean ispoisoned = FALSE, needpoismsg = FALSE, poiskilled = FALSE,
&nbsp;            unpoisonmsg = FALSE;
&nbsp;    boolean silvermsg = FALSE, silverobj = FALSE;
&nbsp;    boolean valid_weapon_attack = FALSE;
&nbsp;    boolean unarmed = !uwep &amp;&amp; !uarm &amp;&amp; !uarms;
&nbsp;    boolean hand_to_hand = (thrown == HMON_MELEE
&nbsp;                            /* not grapnels; applied implies uwep */
&nbsp;                            || (thrown == HMON_APPLIED &amp;&amp; is_pole(uwep)));
&nbsp;    int jousting = 0;
&nbsp;    int wtype;
&nbsp;    struct obj *monwep;
&nbsp;    char unconventional[BUFSZ]; /* substituted for word "attack" in msg */
&nbsp;    char saved_oname[BUFSZ];
&nbsp;
&nbsp;    unconventional[0] = '\0';
&nbsp;    saved_oname[0] = '\0';
&nbsp;
&nbsp;    wakeup(mon, TRUE);
&nbsp;    if (!obj) { /* attack with bare hands */
&nbsp;        if (mdat == &amp;mons[PM_SHADE])
&nbsp;            tmp = 0;
&nbsp;        else if (martial_bonus())
&nbsp;            tmp = rnd(4); /* bonus for martial arts */
&nbsp;        else
&nbsp;            tmp = rnd(2);
&nbsp;        valid_weapon_attack = (tmp &gt; 1);
&nbsp;        /* blessed gloves give bonuses when fighting 'bare-handed' */
&nbsp;        if (uarmg &amp;&amp; uarmg-&gt;blessed
&nbsp;            &amp;&amp; (is_undead(mdat) || is_demon(mdat) || is_vampshifter(mon)))
&nbsp;            tmp += rnd(4);
&nbsp;        /* So do silver rings.  Note: rings are worn under gloves, so you
&nbsp;         * don't get both bonuses.
&nbsp;         */
&nbsp;        if (!uarmg) {
&nbsp;            if (uleft &amp;&amp; objects[uleft-&gt;otyp].oc_material == SILVER)
&nbsp;                barehand_silver_rings++;
&nbsp;            if (uright &amp;&amp; objects[uright-&gt;otyp].oc_material == SILVER)
&nbsp;                barehand_silver_rings++;
&nbsp;            if (barehand_silver_rings &amp;&amp; mon_hates_silver(mon)) {
&nbsp;                tmp += rnd(20);
&nbsp;                silvermsg = TRUE;
&nbsp;            }
&nbsp;        }
&nbsp;    } else {
&nbsp;        Strcpy(saved_oname, cxname(obj));
&nbsp;        if (obj-&gt;oclass == WEAPON_CLASS || is_weptool(obj)
&nbsp;            || obj-&gt;oclass == GEM_CLASS) {
&nbsp;            /* is it not a melee weapon? */
&nbsp;            if (/* if you strike with a bow... */
&nbsp;                is_launcher(obj)
&nbsp;                /* or strike with a missile in your hand... */
&nbsp;                || (!thrown &amp;&amp; (is_missile(obj) || is_ammo(obj)))
&nbsp;                /* or use a pole at short range and not mounted... */
&nbsp;                || (!thrown &amp;&amp; !u.usteed &amp;&amp; is_pole(obj))
&nbsp;                /* or throw a missile without the proper bow... */
&nbsp;                || (is_ammo(obj) &amp;&amp; (thrown != HMON_THROWN
&nbsp;                                     || !ammo_and_launcher(obj, uwep)))) {
&nbsp;                /* then do only 1-2 points of damage */
&nbsp;                if (mdat == &amp;mons[PM_SHADE] &amp;&amp; !shade_glare(obj))
&nbsp;                    tmp = 0;
&nbsp;                else
&nbsp;                    tmp = rnd(2);
&nbsp;                if (objects[obj-&gt;otyp].oc_material == SILVER
&nbsp;                    &amp;&amp; mon_hates_silver(mon)) {
&nbsp;                    silvermsg = TRUE;
&nbsp;                    silverobj = TRUE;
&nbsp;                    /* if it will already inflict dmg, make it worse */
&nbsp;                    tmp += rnd((tmp) ? 20 : 10);
&nbsp;                }
&nbsp;                if (!thrown &amp;&amp; obj == uwep &amp;&amp; obj-&gt;otyp == BOOMERANG
&nbsp;                    &amp;&amp; rnl(4) == 4 - 1) {
&nbsp;                    boolean more_than_1 = (obj-&gt;quan &gt; 1L);
&nbsp;
&nbsp;                    pline("As you hit %s, %s%s breaks into splinters.",
&nbsp;                          mon_nam(mon), more_than_1 ? "one of " : "",
&nbsp;                          yname(obj));
&nbsp;                    if (!more_than_1)
&nbsp;                        uwepgone(); /* set unweapon */
&nbsp;                    useup(obj);
&nbsp;                    if (!more_than_1)
&nbsp;                        obj = (struct obj *) 0;
&nbsp;                    hittxt = TRUE;
&nbsp;                    if (mdat != &amp;mons[PM_SHADE])
&nbsp;                        tmp++;
&nbsp;                }
&nbsp;            } else {
&nbsp;                tmp = dmgval(obj, mon);
&nbsp;                /* a minimal hit doesn't exercise proficiency */
&nbsp;                valid_weapon_attack = (tmp &gt; 1);
&nbsp;                if (!valid_weapon_attack || mon == u.ustuck || u.twoweap
&nbsp;                    /* Cleaver can hit up to three targets at once so don't
&nbsp;                       let it also hit from behind or shatter foes' weapons */
&nbsp;                    || (hand_to_hand &amp;&amp; obj-&gt;oartifact == ART_CLEAVER)) {
&nbsp;                    ; /* no special bonuses */
&nbsp;                } else if (mon-&gt;mflee &amp;&amp; Role_if(PM_ROGUE) &amp;&amp; !Upolyd
&nbsp;                           /* multi-shot throwing is too powerful here */
&nbsp;                           &amp;&amp; hand_to_hand) {
&nbsp;                    You("strike %s from behind!", mon_nam(mon));
&nbsp;                    tmp += rnd(u.ulevel);
&nbsp;                    hittxt = TRUE;
&nbsp;                } else if (dieroll == 2 &amp;&amp; obj == uwep
&nbsp;                           &amp;&amp; obj-&gt;oclass == WEAPON_CLASS
&nbsp;                           &amp;&amp; (bimanual(obj)
&nbsp;                               || (Role_if(PM_SAMURAI) &amp;&amp; obj-&gt;otyp == KATANA
&nbsp;                                   &amp;&amp; !uarms))
&nbsp;                           &amp;&amp; ((wtype = uwep_skill_type()) != P_NONE
&nbsp;                               &amp;&amp; P_SKILL(wtype) &gt;= P_SKILLED)
&nbsp;                           &amp;&amp; ((monwep = MON_WEP(mon)) != 0
&nbsp;                               &amp;&amp; !is_flimsy(monwep)
&nbsp;                               &amp;&amp; !obj_resists(monwep,
&nbsp;                                       50 + 15 * (greatest_erosion(obj)
&nbsp;                                                  - greatest_erosion(monwep)),
&nbsp;                                               100))) {
&nbsp;                    /*
&nbsp;                     * 2.5% chance of shattering defender's weapon when
&nbsp;                     * using a two-handed weapon; less if uwep is rusted.
&nbsp;                     * [dieroll == 2 is most successful non-beheading or
&nbsp;                     * -bisecting hit, in case of special artifact damage;
&nbsp;                     * the percentage chance is (1/20)*(50/100).]
&nbsp;                     * If attacker's weapon is rustier than defender's,
&nbsp;                     * the obj_resists chance is increased so the shatter
&nbsp;                     * chance is decreased; if less rusty, then vice versa.
&nbsp;                     */
&nbsp;                    setmnotwielded(mon, monwep);
&nbsp;                    mon-&gt;weapon_check = NEED_WEAPON;
&nbsp;                    pline("%s from the force of your blow!",
&nbsp;                          Yobjnam2(monwep, "shatter"));
&nbsp;                    m_useupall(mon, monwep);
&nbsp;                    /* If someone just shattered MY weapon, I'd flee! */
&nbsp;                    if (rn2(4)) {
&nbsp;                        monflee(mon, d(2, 3), TRUE, TRUE);
&nbsp;                    }
&nbsp;                    hittxt = TRUE;
&nbsp;                }
&nbsp;
&nbsp;                if (obj-&gt;oartifact
&nbsp;                    &amp;&amp; artifact_hit(&amp;youmonst, mon, obj, &amp;tmp, dieroll)) {
&nbsp;                    if (mon-&gt;mhp &lt;= 0) /* artifact killed monster */
&nbsp;                        return FALSE;
&nbsp;                    if (tmp == 0)
&nbsp;                        return TRUE;
&nbsp;                    hittxt = TRUE;
&nbsp;                }
&nbsp;                if (objects[obj-&gt;otyp].oc_material == SILVER
&nbsp;                    &amp;&amp; mon_hates_silver(mon)) {
&nbsp;                    silvermsg = TRUE;
&nbsp;                    silverobj = TRUE;
&nbsp;                }
&nbsp;                if (u.usteed &amp;&amp; !thrown &amp;&amp; tmp &gt; 0
&nbsp;                    &amp;&amp; weapon_type(obj) == P_LANCE &amp;&amp; mon != u.ustuck) {
&nbsp;                    jousting = joust(mon, obj);
&nbsp;                    /* exercise skill even for minimal damage hits */
&nbsp;                    if (jousting)
&nbsp;                        valid_weapon_attack = TRUE;
&nbsp;                }
&nbsp;                if (thrown == HMON_THROWN
&nbsp;                    &amp;&amp; (is_ammo(obj) || is_missile(obj))) {
&nbsp;                    if (ammo_and_launcher(obj, uwep)) {
&nbsp;                        /* Elves and Samurai do extra damage using
&nbsp;                         * their bows&amp;arrows they're highly trained.
&nbsp;                         */
&nbsp;                        if (Role_if(PM_SAMURAI) &amp;&amp; obj-&gt;otyp == YA
&nbsp;                            &amp;&amp; uwep-&gt;otyp == YUMI)
&nbsp;                            tmp++;
&nbsp;                        else if (Race_if(PM_ELF) &amp;&amp; obj-&gt;otyp == ELVEN_ARROW
&nbsp;                                 &amp;&amp; uwep-&gt;otyp == ELVEN_BOW)
&nbsp;                            tmp++;
&nbsp;                    }
&nbsp;                    if (obj-&gt;opoisoned &amp;&amp; is_poisonable(obj))
&nbsp;                        ispoisoned = TRUE;
&nbsp;                }
&nbsp;            }
&nbsp;        } else if (obj-&gt;oclass == POTION_CLASS) {
&nbsp;            if (obj-&gt;quan &gt; 1L)
&nbsp;                obj = splitobj(obj, 1L);
&nbsp;            else
&nbsp;                setuwep((struct obj *) 0);
&nbsp;            freeinv(obj);
&nbsp;            potionhit(mon, obj,
&nbsp;                      hand_to_hand ? POTHIT_HERO_BASH : POTHIT_HERO_THROW);
&nbsp;            if (mon-&gt;mhp &lt;= 0)
&nbsp;                return FALSE; /* killed */
&nbsp;            hittxt = TRUE;
&nbsp;            /* in case potion effect causes transformation */
&nbsp;            mdat = mon-&gt;data;
&nbsp;            tmp = (mdat == &amp;mons[PM_SHADE]) ? 0 : 1;
&nbsp;        } else {
&nbsp;            if (mdat == &amp;mons[PM_SHADE] &amp;&amp; !shade_aware(obj)) {
&nbsp;                tmp = 0;
&nbsp;                Strcpy(unconventional, cxname(obj));
&nbsp;            } else {
&nbsp;                switch (obj-&gt;otyp) {
&nbsp;                case BOULDER:         /* 1d20 */
&nbsp;                case HEAVY_IRON_BALL: /* 1d25 */
&nbsp;                case IRON_CHAIN:      /* 1d4+1 */
&nbsp;                    tmp = dmgval(obj, mon);
&nbsp;                    break;
&nbsp;                case MIRROR:
&nbsp;                    if (breaktest(obj)) {
&nbsp;                        You("break %s.  That's bad luck!", ysimple_name(obj));
&nbsp;                        change_luck(-2);
&nbsp;                        useup(obj);
&nbsp;                        obj = (struct obj *) 0;
&nbsp;                        unarmed = FALSE; /* avoid obj==0 confusion */
&nbsp;                        get_dmg_bonus = FALSE;
&nbsp;                        hittxt = TRUE;
&nbsp;                    }
&nbsp;                    tmp = 1;
&nbsp;                    break;
&nbsp;                case EXPENSIVE_CAMERA:
&nbsp;                    You("succeed in destroying %s.  Congratulations!",
&nbsp;                        ysimple_name(obj));
&nbsp;                    release_camera_demon(obj, u.ux, u.uy);
&nbsp;                    useup(obj);
&nbsp;                    return TRUE;
&nbsp;                case CORPSE: /* fixed by polder@cs.vu.nl */
&nbsp;                    if (touch_petrifies(&amp;mons[obj-&gt;corpsenm])) {
&nbsp;                        tmp = 1;
&nbsp;                        hittxt = TRUE;
&nbsp;                        You("hit %s with %s.", mon_nam(mon),
&nbsp;                            corpse_xname(obj, (const char *) 0,
&nbsp;                                         obj-&gt;dknown ? CXN_PFX_THE
&nbsp;                                                     : CXN_ARTICLE));
&nbsp;                        obj-&gt;dknown = 1;
&nbsp;                        if (!munstone(mon, TRUE))
&nbsp;                            minstapetrify(mon, TRUE);
&nbsp;                        if (resists_ston(mon))
&nbsp;                            break;
&nbsp;                        /* note: hp may be &lt;= 0 even if munstoned==TRUE */
&nbsp;                        return (boolean) (mon-&gt;mhp &gt; 0);
&nbsp;#if 0
&nbsp;                    } else if (touch_petrifies(mdat)) {
&nbsp;                        ; /* maybe turn the corpse into a statue? */
&nbsp;#endif
&nbsp;                    }
&nbsp;                    tmp = (obj-&gt;corpsenm &gt;= LOW_PM ? mons[obj-&gt;corpsenm].msize
&nbsp;                                                   : 0) + 1;
&nbsp;                    break;
&nbsp;
&nbsp;#define useup_eggs(o)                    \
&nbsp;    {                                    \
&nbsp;        if (thrown)                      \
&nbsp;            obfree(o, (struct obj *) 0); \
&nbsp;        else                             \
&nbsp;            useupall(o);                 \
&nbsp;        o = (struct obj *) 0;            \
&nbsp;    } /* now gone */
&nbsp;                case EGG: {
&nbsp;                    long cnt = obj-&gt;quan;
&nbsp;
&nbsp;                    tmp = 1; /* nominal physical damage */
&nbsp;                    get_dmg_bonus = FALSE;
&nbsp;                    hittxt = TRUE; /* message always given */
&nbsp;                    /* egg is always either used up or transformed, so next
&nbsp;                       hand-to-hand attack should yield a "bashing" mesg */
&nbsp;                    if (obj == uwep)
&nbsp;                        unweapon = TRUE;
&nbsp;                    if (obj-&gt;spe &amp;&amp; obj-&gt;corpsenm &gt;= LOW_PM) {
&nbsp;                        if (obj-&gt;quan &lt; 5L)
&nbsp;                            change_luck((schar) - (obj-&gt;quan));
&nbsp;                        else
&nbsp;                            change_luck(-5);
&nbsp;                    }
&nbsp;
&nbsp;                    if (touch_petrifies(&amp;mons[obj-&gt;corpsenm])) {
&nbsp;                        /*learn_egg_type(obj-&gt;corpsenm);*/
&nbsp;                        pline("Splat! You hit %s with %s %s egg%s!",
&nbsp;                              mon_nam(mon),
&nbsp;                              obj-&gt;known ? "the" : cnt &gt; 1L ? "some" : "a",
&nbsp;                              obj-&gt;known ? mons[obj-&gt;corpsenm].mname
&nbsp;                                         : "petrifying",
&nbsp;                              plur(cnt));
&nbsp;                        obj-&gt;known = 1; /* (not much point...) */
&nbsp;                        useup_eggs(obj);
&nbsp;                        if (!munstone(mon, TRUE))
&nbsp;                            minstapetrify(mon, TRUE);
&nbsp;                        if (resists_ston(mon))
&nbsp;                            break;
&nbsp;                        return (boolean) (mon-&gt;mhp &gt; 0);
&nbsp;                    } else { /* ordinary egg(s) */
&nbsp;                        const char *eggp =
&nbsp;                            (obj-&gt;corpsenm != NON_PM &amp;&amp; obj-&gt;known)
&nbsp;                                ? the(mons[obj-&gt;corpsenm].mname)
&nbsp;                                : (cnt &gt; 1L) ? "some" : "an";
&nbsp;                        You("hit %s with %s egg%s.", mon_nam(mon), eggp,
&nbsp;                            plur(cnt));
&nbsp;                        if (touch_petrifies(mdat) &amp;&amp; !stale_egg(obj)) {
&nbsp;                            pline_The("egg%s %s alive any more...", plur(cnt),
&nbsp;                                      (cnt == 1L) ? "isn't" : "aren't");
&nbsp;                            if (obj-&gt;timed)
&nbsp;                                obj_stop_timers(obj);
&nbsp;                            obj-&gt;otyp = ROCK;
&nbsp;                            obj-&gt;oclass = GEM_CLASS;
&nbsp;                            obj-&gt;oartifact = 0;
&nbsp;                            obj-&gt;spe = 0;
&nbsp;                            obj-&gt;known = obj-&gt;dknown = obj-&gt;bknown = 0;
&nbsp;                            obj-&gt;owt = weight(obj);
&nbsp;                            if (thrown)
&nbsp;                                place_object(obj, mon-&gt;mx, mon-&gt;my);
&nbsp;                        } else {
&nbsp;                            pline("Splat!");
&nbsp;                            useup_eggs(obj);
&nbsp;                            exercise(A_WIS, FALSE);
&nbsp;                        }
&nbsp;                    }
&nbsp;                    break;
&nbsp;#undef useup_eggs
&nbsp;                }
&nbsp;                case CLOVE_OF_GARLIC: /* no effect against demons */
&nbsp;                    if (is_undead(mdat) || is_vampshifter(mon)) {
&nbsp;                        monflee(mon, d(2, 4), FALSE, TRUE);
&nbsp;                    }
&nbsp;                    tmp = 1;
&nbsp;                    break;
&nbsp;                case CREAM_PIE:
&nbsp;                case BLINDING_VENOM:
&nbsp;                    mon-&gt;msleeping = 0;
&nbsp;                    if (can_blnd(&amp;youmonst, mon,
&nbsp;                                 (uchar) (obj-&gt;otyp == BLINDING_VENOM
&nbsp;                                             ? AT_SPIT
&nbsp;                                             : AT_WEAP),
&nbsp;                                 obj)) {
&nbsp;                        if (Blind) {
&nbsp;                            pline(obj-&gt;otyp == CREAM_PIE ? "Splat!"
&nbsp;                                                         : "Splash!");
&nbsp;                        } else if (obj-&gt;otyp == BLINDING_VENOM) {
&nbsp;                            pline_The("venom blinds %s%s!", mon_nam(mon),
&nbsp;                                      mon-&gt;mcansee ? "" : " further");
&nbsp;                        } else {
&nbsp;                            char *whom = mon_nam(mon);
&nbsp;                            char *what = The(xname(obj));
&nbsp;
&nbsp;                            if (!thrown &amp;&amp; obj-&gt;quan &gt; 1L)
&nbsp;                                what = An(singular(obj, xname));
&nbsp;                            /* note: s_suffix returns a modifiable buffer */
&nbsp;                            if (haseyes(mdat)
&nbsp;                                &amp;&amp; mdat != &amp;mons[PM_FLOATING_EYE])
&nbsp;                                whom = strcat(strcat(s_suffix(whom), " "),
&nbsp;                                              mbodypart(mon, FACE));
&nbsp;                            pline("%s %s over %s!", what,
&nbsp;                                  vtense(what, "splash"), whom);
&nbsp;                        }
&nbsp;                        setmangry(mon, TRUE);
&nbsp;                        mon-&gt;mcansee = 0;
&nbsp;                        tmp = rn1(25, 21);
&nbsp;                        if (((int) mon-&gt;mblinded + tmp) &gt; 127)
&nbsp;                            mon-&gt;mblinded = 127;
&nbsp;                        else
&nbsp;                            mon-&gt;mblinded += tmp;
&nbsp;                    } else {
&nbsp;                        pline(obj-&gt;otyp == CREAM_PIE ? "Splat!" : "Splash!");
&nbsp;                        setmangry(mon, TRUE);
&nbsp;                    }
&nbsp;                    if (thrown)
&nbsp;                        obfree(obj, (struct obj *) 0);
&nbsp;                    else
&nbsp;                        useup(obj);
&nbsp;                    hittxt = TRUE;
&nbsp;                    get_dmg_bonus = FALSE;
&nbsp;                    tmp = 0;
&nbsp;                    break;
&nbsp;                case ACID_VENOM: /* thrown (or spit) */
&nbsp;                    if (resists_acid(mon)) {
&nbsp;                        Your("venom hits %s harmlessly.", mon_nam(mon));
&nbsp;                        tmp = 0;
&nbsp;                    } else {
&nbsp;                        Your("venom burns %s!", mon_nam(mon));
&nbsp;                        tmp = dmgval(obj, mon);
&nbsp;                    }
&nbsp;                    if (thrown)
&nbsp;                        obfree(obj, (struct obj *) 0);
&nbsp;                    else
&nbsp;                        useup(obj);
&nbsp;                    hittxt = TRUE;
&nbsp;                    get_dmg_bonus = FALSE;
&nbsp;                    break;
&nbsp;                default:
&nbsp;                    /* non-weapons can damage because of their weight */
&nbsp;                    /* (but not too much) */
&nbsp;                    tmp = obj-&gt;owt / 100;
&nbsp;                    if (is_wet_towel(obj)) {
&nbsp;                        /* wielded wet towel should probably use whip skill
&nbsp;                           (but not by setting objects[TOWEL].oc_skill==P_WHIP
&nbsp;                           because that would turn towel into a weptool) */
&nbsp;                        tmp += obj-&gt;spe;
&nbsp;                        if (rn2(obj-&gt;spe + 1)) /* usually lose some wetness */
&nbsp;                            dry_a_towel(obj, -1, TRUE);
&nbsp;                    }
&nbsp;                    if (tmp &lt; 1)
&nbsp;                        tmp = 1;
&nbsp;                    else
&nbsp;                        tmp = rnd(tmp);
&nbsp;                    if (tmp &gt; 6)
&nbsp;                        tmp = 6;
&nbsp;                    /*
&nbsp;                     * Things like silver wands can arrive here so
&nbsp;                     * so we need another silver check.
&nbsp;                     */
&nbsp;                    if (objects[obj-&gt;otyp].oc_material == SILVER
&nbsp;                        &amp;&amp; mon_hates_silver(mon)) {
&nbsp;                        tmp += rnd(20);
&nbsp;                        silvermsg = TRUE;
&nbsp;                        silverobj = TRUE;
&nbsp;                    }
&nbsp;                }
&nbsp;            }
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    /****** NOTE: perhaps obj is undefined!! (if !thrown &amp;&amp; BOOMERANG)
&nbsp;     *      *OR* if attacking bare-handed!! */
&nbsp;
&nbsp;    if (get_dmg_bonus &amp;&amp; tmp &gt; 0) {
&nbsp;        tmp += u.udaminc;
&nbsp;        /* If you throw using a propellor, you don't get a strength
&nbsp;         * bonus but you do get an increase-damage bonus.
&nbsp;         */
&nbsp;        if (thrown != HMON_THROWN || !obj || !uwep
&nbsp;            || !ammo_and_launcher(obj, uwep))
&nbsp;            tmp += dbon();
&nbsp;    }
&nbsp;
&nbsp;    if (valid_weapon_attack) {
&nbsp;        struct obj *wep;
&nbsp;
&nbsp;        /* to be valid a projectile must have had the correct projector */
&nbsp;        wep = PROJECTILE(obj) ? uwep : obj;
&nbsp;        tmp += weapon_dam_bonus(wep);
&nbsp;        /* [this assumes that `!thrown' implies wielded...] */
&nbsp;        wtype = thrown ? weapon_type(wep) : uwep_skill_type();
&nbsp;        use_skill(wtype, 1);
&nbsp;    }
&nbsp;
&nbsp;    if (ispoisoned) {
&nbsp;        int nopoison = (10 - (obj-&gt;owt / 10));
&nbsp;
&nbsp;        if (nopoison &lt; 2)
&nbsp;            nopoison = 2;
&nbsp;        if (Role_if(PM_SAMURAI)) {
&nbsp;            You("dishonorably use a poisoned weapon!");
&nbsp;            adjalign(-sgn(u.ualign.type));
&nbsp;        } else if (u.ualign.type == A_LAWFUL &amp;&amp; u.ualign.record &gt; -10) {
&nbsp;            You_feel("like an evil coward for using a poisoned weapon.");
&nbsp;            adjalign(-1);
&nbsp;        }
&nbsp;        if (obj &amp;&amp; !rn2(nopoison)) {
&nbsp;            /* remove poison now in case obj ends up in a bones file */
&nbsp;            obj-&gt;opoisoned = FALSE;
&nbsp;            /* defer "obj is no longer poisoned" until after hit message */
&nbsp;            unpoisonmsg = TRUE;
&nbsp;        }
&nbsp;        if (resists_poison(mon))
&nbsp;            needpoismsg = TRUE;
&nbsp;        else if (rn2(10))
&nbsp;            tmp += rnd(6);
&nbsp;        else
&nbsp;            poiskilled = TRUE;
&nbsp;    }
&nbsp;    if (tmp &lt; 1) {
&nbsp;        /* make sure that negative damage adjustment can't result
&nbsp;           in inadvertently boosting the victim's hit points */
&nbsp;        tmp = 0;
&nbsp;        if (mdat == &amp;mons[PM_SHADE]) {
&nbsp;            if (!hittxt) {
&nbsp;                const char *what = *unconventional ? unconventional : "attack";
&nbsp;
&nbsp;                Your("%s %s harmlessly through %s.", what,
&nbsp;                     vtense(what, "pass"), mon_nam(mon));
&nbsp;                hittxt = TRUE;
&nbsp;            }
&nbsp;        } else {
&nbsp;            if (get_dmg_bonus)
&nbsp;                tmp = 1;
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    if (jousting) {
&nbsp;        tmp += d(2, (obj == uwep) ? 10 : 2); /* [was in dmgval()] */
&nbsp;        You("joust %s%s", mon_nam(mon), canseemon(mon) ? exclam(tmp) : ".");
&nbsp;        if (jousting &lt; 0) {
&nbsp;            pline("%s shatters on impact!", Yname2(obj));
&nbsp;            /* (must be either primary or secondary weapon to get here) */
&nbsp;            u.twoweap = FALSE; /* untwoweapon() is too verbose here */
&nbsp;            if (obj == uwep)
&nbsp;                uwepgone(); /* set unweapon */
&nbsp;            /* minor side-effect: broken lance won't split puddings */
&nbsp;            useup(obj);
&nbsp;            obj = 0;
&nbsp;        }
&nbsp;        /* avoid migrating a dead monster */
&nbsp;        if (mon-&gt;mhp &gt; tmp) {
&nbsp;            mhurtle(mon, u.dx, u.dy, 1);
&nbsp;            mdat = mon-&gt;data; /* in case of a polymorph trap */
&nbsp;            if (DEADMONSTER(mon))
&nbsp;                already_killed = TRUE;
&nbsp;        }
&nbsp;        hittxt = TRUE;
&nbsp;    } else if (unarmed &amp;&amp; tmp &gt; 1 &amp;&amp; !thrown &amp;&amp; !obj &amp;&amp; !Upolyd) {
&nbsp;        /* VERY small chance of stunning opponent if unarmed. */
&nbsp;        if (rnd(100) &lt; P_SKILL(P_BARE_HANDED_COMBAT) &amp;&amp; !bigmonst(mdat)
&nbsp;            &amp;&amp; !thick_skinned(mdat)) {
&nbsp;            if (canspotmon(mon))
&nbsp;                pline("%s %s from your powerful strike!", Monnam(mon),
&nbsp;                      makeplural(stagger(mon-&gt;data, "stagger")));
&nbsp;            /* avoid migrating a dead monster */
&nbsp;            if (mon-&gt;mhp &gt; tmp) {
&nbsp;                mhurtle(mon, u.dx, u.dy, 1);
&nbsp;                mdat = mon-&gt;data; /* in case of a polymorph trap */
&nbsp;                if (DEADMONSTER(mon))
&nbsp;                    already_killed = TRUE;
&nbsp;            }
&nbsp;            hittxt = TRUE;
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    if (!already_killed)
&nbsp;        mon-&gt;mhp -= tmp;
&nbsp;    /* adjustments might have made tmp become less than what
&nbsp;       a level draining artifact has already done to max HP */
&nbsp;    if (mon-&gt;mhp &gt; mon-&gt;mhpmax)
&nbsp;        mon-&gt;mhp = mon-&gt;mhpmax;
&nbsp;    if (mon-&gt;mhp &lt; 1)
&nbsp;        destroyed = TRUE;
&nbsp;    if (mon-&gt;mtame &amp;&amp; tmp &gt; 0) {
&nbsp;        /* do this even if the pet is being killed (affects revival) */
&nbsp;        abuse_dog(mon); /* reduces tameness */
&nbsp;        /* flee if still alive and still tame; if already suffering from
&nbsp;           untimed fleeing, no effect, otherwise increases timed fleeing */
&nbsp;        if (mon-&gt;mtame &amp;&amp; !destroyed)
&nbsp;            monflee(mon, 10 * rnd(tmp), FALSE, FALSE);
&nbsp;    }
&nbsp;    if ((mdat == &amp;mons[PM_BLACK_PUDDING] || mdat == &amp;mons[PM_BROWN_PUDDING])
&nbsp;        /* pudding is alive and healthy enough to split */
&nbsp;        &amp;&amp; mon-&gt;mhp &gt; 1 &amp;&amp; !mon-&gt;mcan
&nbsp;        /* iron weapon using melee or polearm hit [3.6.1: metal weapon too;
&nbsp;           also allow either or both weapons to cause split when twoweap] */
&nbsp;        &amp;&amp; obj &amp;&amp; (obj == uwep || (u.twoweap &amp;&amp; obj == uswapwep))
&nbsp;        &amp;&amp; ((objects[obj-&gt;otyp].oc_material == IRON
&nbsp;             /* allow scalpel and tsurugi to split puddings */
&nbsp;             || objects[obj-&gt;otyp].oc_material == METAL)
&nbsp;            /* but not bashing with darts, arrows or ya */
&nbsp;            &amp;&amp; !(is_ammo(obj) || is_missile(obj)))
&nbsp;        &amp;&amp; hand_to_hand) {
&nbsp;        if (clone_mon(mon, 0, 0)) {
&nbsp;            char withwhat[BUFSZ];
&nbsp;
&nbsp;            withwhat[0] = '\0';
&nbsp;            if (u.twoweap &amp;&amp; flags.verbose)
&nbsp;                Sprintf(withwhat, " with %s", yname(obj));
&nbsp;            pline("%s divides as you hit it%s!", Monnam(mon), withwhat);
&nbsp;            hittxt = TRUE;
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    if (!hittxt /*( thrown =&gt; obj exists )*/
&nbsp;        &amp;&amp; (!destroyed
&nbsp;            || (thrown &amp;&amp; m_shot.n &gt; 1 &amp;&amp; m_shot.o == obj-&gt;otyp))) {
&nbsp;        if (thrown)
&nbsp;            hit(mshot_xname(obj), mon, exclam(tmp));
&nbsp;        else if (!flags.verbose)
&nbsp;            You("hit it.");
&nbsp;        else
&nbsp;            You("%s %s%s", Role_if(PM_BARBARIAN) ? "smite" : "hit",
&nbsp;                mon_nam(mon), canseemon(mon) ? exclam(tmp) : ".");
&nbsp;    }
&nbsp;
&nbsp;    if (silvermsg) {
&nbsp;        const char *fmt;
&nbsp;        char *whom = mon_nam(mon);
&nbsp;        char silverobjbuf[BUFSZ];
&nbsp;
&nbsp;        if (canspotmon(mon)) {
&nbsp;            if (barehand_silver_rings == 1)
&nbsp;                fmt = "Your silver ring sears %s!";
&nbsp;            else if (barehand_silver_rings == 2)
&nbsp;                fmt = "Your silver rings sear %s!";
&nbsp;            else if (silverobj &amp;&amp; saved_oname[0]) {
&nbsp;                /* guard constructed format string against '%' in
&nbsp;                   saved_oname[] from xname(via cxname()) */
&nbsp;                Sprintf(silverobjbuf, "Your %s%s %s",
&nbsp;                        strstri(saved_oname, "silver") ? "" : "silver ",
&nbsp;                        saved_oname, vtense(saved_oname, "sear"));
&nbsp;                (void) strNsubst(silverobjbuf, "%", "%%", 0);
&nbsp;                Strcat(silverobjbuf, " %s!");
&nbsp;                fmt = silverobjbuf;
&nbsp;            } else
&nbsp;                fmt = "The silver sears %s!";
&nbsp;        } else {
&nbsp;            *whom = highc(*whom); /* "it" -&gt; "It" */
&nbsp;            fmt = "%s is seared!";
&nbsp;        }
&nbsp;        /* note: s_suffix returns a modifiable buffer */
&nbsp;        if (!noncorporeal(mdat) &amp;&amp; !amorphous(mdat))
&nbsp;            whom = strcat(s_suffix(whom), " flesh");
&nbsp;        pline(fmt, whom);
&nbsp;    }
&nbsp;    /* if a "no longer poisoned" message is coming, it will be last;
&nbsp;       obj-&gt;opoisoned was cleared above and any message referring to
&nbsp;       "poisoned <obj>" has now been given; we want just "<obj>" for
&nbsp;       last message, so reformat while obj is still accessible */
&nbsp;    if (unpoisonmsg)
&nbsp;        Strcpy(saved_oname, cxname(obj));
&nbsp;
&nbsp;    /* [note: thrown obj might go away during killed/xkilled call] */
&nbsp;
&nbsp;    if (needpoismsg)
&nbsp;        pline_The("poison doesn't seem to affect %s.", mon_nam(mon));
&nbsp;    if (poiskilled) {
&nbsp;        pline_The("poison was deadly...");
&nbsp;        if (!already_killed)
&nbsp;            xkilled(mon, XKILL_NOMSG);
&nbsp;        destroyed = TRUE; /* return FALSE; */
&nbsp;    } else if (destroyed) {
&nbsp;        if (!already_killed)
&nbsp;            killed(mon); /* takes care of most messages */
&nbsp;    } else if (u.umconf &amp;&amp; hand_to_hand) {
&nbsp;        nohandglow(mon);
&nbsp;        if (!mon-&gt;mconf &amp;&amp; !resist(mon, SPBOOK_CLASS, 0, NOTELL)) {
&nbsp;            mon-&gt;mconf = 1;
&nbsp;            if (!mon-&gt;mstun &amp;&amp; mon-&gt;mcanmove &amp;&amp; !mon-&gt;msleeping
&nbsp;                &amp;&amp; canseemon(mon))
&nbsp;                pline("%s appears confused.", Monnam(mon));
&nbsp;        }
&nbsp;    }
&nbsp;    if (unpoisonmsg)
&nbsp;        Your("%s %s no longer poisoned.", saved_oname,
&nbsp;             vtense(saved_oname, "are"));
&nbsp;
&nbsp;    return destroyed ? FALSE : TRUE;
&nbsp;}
&nbsp;
shade_aware
&nbsp;STATIC_OVL boolean
&nbsp;shade_aware(obj)
&nbsp;struct obj *obj;
&nbsp;{
&nbsp;    if (!obj)
&nbsp;        return FALSE;
&nbsp;    /*
&nbsp;     * The things in this list either
&nbsp;     * 1) affect shades.
&nbsp;     *  OR
&nbsp;     * 2) are dealt with properly by other routines
&nbsp;     *    when it comes to shades.
&nbsp;     */
&nbsp;    if (obj-&gt;otyp == BOULDER
&nbsp;        || obj-&gt;otyp == HEAVY_IRON_BALL
&nbsp;        || obj-&gt;otyp == IRON_CHAIN      /* dmgval handles those first three */
&nbsp;        || obj-&gt;otyp == MIRROR          /* silver in the reflective surface */
&nbsp;        || obj-&gt;otyp == CLOVE_OF_GARLIC /* causes shades to flee */
&nbsp;        || objects[obj-&gt;otyp].oc_material == SILVER)
&nbsp;        return TRUE;
&nbsp;    return FALSE;
&nbsp;}
&nbsp;
m_slips_free
&nbsp;/* check whether slippery clothing protects from hug or wrap attack */
&nbsp;/* [currently assumes that you are the attacker] */
&nbsp;STATIC_OVL boolean
&nbsp;m_slips_free(mdef, mattk)
&nbsp;struct monst *mdef;
&nbsp;struct attack *mattk;
&nbsp;{
&nbsp;    struct obj *obj;
&nbsp;
&nbsp;    if (mattk-&gt;adtyp == AD_DRIN) {
&nbsp;        /* intelligence drain attacks the head */
&nbsp;        obj = which_armor(mdef, W_ARMH);
&nbsp;    } else {
&nbsp;        /* grabbing attacks the body */
&nbsp;        obj = which_armor(mdef, W_ARMC); /* cloak */
&nbsp;        if (!obj)
&nbsp;            obj = which_armor(mdef, W_ARM); /* suit */
&nbsp;        if (!obj)
&nbsp;            obj = which_armor(mdef, W_ARMU); /* shirt */
&nbsp;    }
&nbsp;
&nbsp;    /* if monster's cloak/armor is greased, your grab slips off; this
&nbsp;       protection might fail (33% chance) when the armor is cursed */
&nbsp;    if (obj &amp;&amp; (obj-&gt;greased || obj-&gt;otyp == OILSKIN_CLOAK)
&nbsp;        &amp;&amp; (!obj-&gt;cursed || rn2(3))) {
&nbsp;        You("%s %s %s %s!",
&nbsp;            mattk-&gt;adtyp == AD_WRAP ? "slip off of"
&nbsp;                                    : "grab, but cannot hold onto",
&nbsp;            s_suffix(mon_nam(mdef)), obj-&gt;greased ? "greased" : "slippery",
&nbsp;            /* avoid "slippery slippery cloak"
&nbsp;               for undiscovered oilskin cloak */
&nbsp;            (obj-&gt;greased || objects[obj-&gt;otyp].oc_name_known)
&nbsp;                ? xname(obj)
&nbsp;                : cloak_simple_name(obj));
&nbsp;
&nbsp;        if (obj-&gt;greased &amp;&amp; !rn2(2)) {
&nbsp;            pline_The("grease wears off.");
&nbsp;            obj-&gt;greased = 0;
&nbsp;        }
&nbsp;        return TRUE;
&nbsp;    }
&nbsp;    return FALSE;
&nbsp;}
&nbsp;
joust
&nbsp;/* used when hitting a monster with a lance while mounted;
&nbsp;   1: joust hit; 0: ordinary hit; -1: joust but break lance */
&nbsp;STATIC_OVL int
&nbsp;joust(mon, obj)
&nbsp;struct monst *mon; /* target */
&nbsp;struct obj *obj;   /* weapon */
&nbsp;{
&nbsp;    int skill_rating, joust_dieroll;
&nbsp;
&nbsp;    if (Fumbling || Stunned)
&nbsp;        return 0;
&nbsp;    /* sanity check; lance must be wielded in order to joust */
&nbsp;    if (obj != uwep &amp;&amp; (obj != uswapwep || !u.twoweap))
&nbsp;        return 0;
&nbsp;
&nbsp;    /* if using two weapons, use worse of lance and two-weapon skills */
&nbsp;    skill_rating = P_SKILL(weapon_type(obj)); /* lance skill */
&nbsp;    if (u.twoweap &amp;&amp; P_SKILL(P_TWO_WEAPON_COMBAT) &lt; skill_rating)
&nbsp;        skill_rating = P_SKILL(P_TWO_WEAPON_COMBAT);
&nbsp;    if (skill_rating == P_ISRESTRICTED)
&nbsp;        skill_rating = P_UNSKILLED; /* 0=&gt;1 */
&nbsp;
&nbsp;    /* odds to joust are expert:80%, skilled:60%, basic:40%, unskilled:20% */
&nbsp;    if ((joust_dieroll = rn2(5)) &lt; skill_rating) {
&nbsp;        if (joust_dieroll == 0 &amp;&amp; rnl(50) == (50 - 1) &amp;&amp; !unsolid(mon-&gt;data)
&nbsp;            &amp;&amp; !obj_resists(obj, 0, 100))
&nbsp;            return -1; /* hit that breaks lance */
&nbsp;        return 1;      /* successful joust */
&nbsp;    }
&nbsp;    return 0; /* no joust bonus; revert to ordinary attack */
&nbsp;}
&nbsp;
demonpet
&nbsp;/*
&nbsp; * Send in a demon pet for the hero.  Exercise wisdom.
&nbsp; *
&nbsp; * This function used to be inline to damageum(), but the Metrowerks compiler
&nbsp; * (DR4 and DR4.5) screws up with an internal error 5 "Expression Too
&nbsp; * Complex."
&nbsp; * Pulling it out makes it work.
&nbsp; */
&nbsp;STATIC_OVL void
&nbsp;demonpet()
&nbsp;{
&nbsp;    int i;
&nbsp;    struct permonst *pm;
&nbsp;    struct monst *dtmp;
&nbsp;
&nbsp;    pline("Some hell-p has arrived!");
&nbsp;    i = !rn2(6) ? ndemon(u.ualign.type) : NON_PM;
&nbsp;    pm = i != NON_PM ? &amp;mons[i] : youmonst.data;
&nbsp;    if ((dtmp = makemon(pm, u.ux, u.uy, NO_MM_FLAGS)) != 0)
&nbsp;        (void) tamedog(dtmp, (struct obj *) 0);
&nbsp;    exercise(A_WIS, TRUE);
&nbsp;}
&nbsp;
theft_petrifies
&nbsp;STATIC_OVL boolean
&nbsp;theft_petrifies(otmp)
&nbsp;struct obj *otmp;
&nbsp;{
&nbsp;    if (uarmg || otmp-&gt;otyp != CORPSE
&nbsp;        || !touch_petrifies(&amp;mons[otmp-&gt;corpsenm]) || Stone_resistance)
&nbsp;        return FALSE;
&nbsp;
&nbsp;#if 0   /* no poly_when_stoned() critter has theft capability */
&nbsp;    if (poly_when_stoned(youmonst.data) &amp;&amp; polymon(PM_STONE_GOLEM)) {
&nbsp;        display_nhwindow(WIN_MESSAGE, FALSE);   /* --More-- */
&nbsp;        return TRUE;
&nbsp;    }
&nbsp;#endif
&nbsp;
&nbsp;    /* stealing this corpse is fatal... */
&nbsp;    instapetrify(corpse_xname(otmp, "stolen", CXN_ARTICLE));
&nbsp;    /* apparently wasn't fatal after all... */
&nbsp;    return TRUE;
&nbsp;}
&nbsp;
steal_it
&nbsp;/*
&nbsp; * Player uses theft attack against monster.
&nbsp; *
&nbsp; * If the target is wearing body armor, take all of its possessions;
&nbsp; * otherwise, take one object.  [Is this really the behavior we want?]
&nbsp; */
&nbsp;STATIC_OVL void
&nbsp;steal_it(mdef, mattk)
&nbsp;struct monst *mdef;
&nbsp;struct attack *mattk;
&nbsp;{
&nbsp;    struct obj *otmp, *stealoid, **minvent_ptr;
&nbsp;    long unwornmask;
&nbsp;
&nbsp;    if (!mdef-&gt;minvent)
&nbsp;        return; /* nothing to take */
&nbsp;
&nbsp;    /* look for worn body armor */
&nbsp;    stealoid = (struct obj *) 0;
&nbsp;    if (could_seduce(&amp;youmonst, mdef, mattk)) {
&nbsp;        /* find armor, and move it to end of inventory in the process */
&nbsp;        minvent_ptr = &amp;mdef-&gt;minvent;
&nbsp;        while ((otmp = *minvent_ptr) != 0)
&nbsp;            if (otmp-&gt;owornmask &amp; W_ARM) {
&nbsp;                if (stealoid)
&nbsp;                    panic("steal_it: multiple worn suits");
&nbsp;                *minvent_ptr = otmp-&gt;nobj; /* take armor out of minvent */
&nbsp;                stealoid = otmp;
&nbsp;                stealoid-&gt;nobj = (struct obj *) 0;
&nbsp;            } else {
&nbsp;                minvent_ptr = &amp;otmp-&gt;nobj;
&nbsp;            }
&nbsp;        *minvent_ptr = stealoid; /* put armor back into minvent */
&nbsp;    }
&nbsp;
&nbsp;    if (stealoid) { /* we will be taking everything */
&nbsp;        if (gender(mdef) == (int) u.mfemale &amp;&amp; youmonst.data-&gt;mlet == S_NYMPH)
&nbsp;            You("charm %s.  She gladly hands over her possessions.",
&nbsp;                mon_nam(mdef));
&nbsp;        else
&nbsp;            You("seduce %s and %s starts to take off %s clothes.",
&nbsp;                mon_nam(mdef), mhe(mdef), mhis(mdef));
&nbsp;    }
&nbsp;
&nbsp;    while ((otmp = mdef-&gt;minvent) != 0) {
&nbsp;        if (!Upolyd)
&nbsp;            break; /* no longer have ability to steal */
&nbsp;        /* take the object away from the monster */
&nbsp;        obj_extract_self(otmp);
&nbsp;        if ((unwornmask = otmp-&gt;owornmask) != 0L) {
&nbsp;            mdef-&gt;misc_worn_check &amp;= ~unwornmask;
&nbsp;            if (otmp-&gt;owornmask &amp; W_WEP)
&nbsp;                setmnotwielded(mdef, otmp);
&nbsp;            otmp-&gt;owornmask = 0L;
&nbsp;            update_mon_intrinsics(mdef, otmp, FALSE, FALSE);
&nbsp;
&nbsp;            if (otmp == stealoid) /* special message for final item */
&nbsp;                pline("%s finishes taking off %s suit.", Monnam(mdef),
&nbsp;                      mhis(mdef));
&nbsp;        }
&nbsp;        /* give the object to the character */
&nbsp;        otmp = hold_another_object(otmp, "You snatched but dropped %s.",
&nbsp;                                   doname(otmp), "You steal: ");
&nbsp;        if (otmp-&gt;where != OBJ_INVENT)
&nbsp;            continue;
&nbsp;        if (theft_petrifies(otmp))
&nbsp;            break; /* stop thieving even though hero survived */
&nbsp;        /* more take-away handling, after theft message */
&nbsp;        if (unwornmask &amp; W_WEP) { /* stole wielded weapon */
&nbsp;            possibly_unwield(mdef, FALSE);
&nbsp;        } else if (unwornmask &amp; W_ARMG) { /* stole worn gloves */
&nbsp;            mselftouch(mdef, (const char *) 0, TRUE);
&nbsp;            if (mdef-&gt;mhp &lt;= 0) /* it's now a statue */
&nbsp;                return;         /* can't continue stealing */
&nbsp;        }
&nbsp;
&nbsp;        if (!stealoid)
&nbsp;            break; /* only taking one item */
&nbsp;    }
&nbsp;}
&nbsp;
damageum
&nbsp;int
&nbsp;damageum(mdef, mattk)
&nbsp;register struct monst *mdef;
&nbsp;register struct attack *mattk;
&nbsp;{
&nbsp;    register struct permonst *pd = mdef-&gt;data;
&nbsp;    int armpro, tmp = d((int) mattk-&gt;damn, (int) mattk-&gt;damd);
&nbsp;    boolean negated;
&nbsp;
&nbsp;    armpro = magic_negation(mdef);
&nbsp;    /* since hero can't be cancelled, only defender's armor applies */
&nbsp;    negated = !(rn2(10) &gt;= 3 * armpro);
&nbsp;
&nbsp;    if (is_demon(youmonst.data) &amp;&amp; !rn2(13) &amp;&amp; !uwep
&nbsp;        &amp;&amp; u.umonnum != PM_SUCCUBUS &amp;&amp; u.umonnum != PM_INCUBUS
&nbsp;        &amp;&amp; u.umonnum != PM_BALROG) {
&nbsp;        demonpet();
&nbsp;        return 0;
&nbsp;    }
&nbsp;    switch (mattk-&gt;adtyp) {
&nbsp;    case AD_STUN:
&nbsp;        if (!Blind)
&nbsp;            pline("%s %s for a moment.", Monnam(mdef),
&nbsp;                  makeplural(stagger(pd, "stagger")));
&nbsp;        mdef-&gt;mstun = 1;
&nbsp;        goto physical;
&nbsp;    case AD_LEGS:
&nbsp;#if 0
&nbsp;        if (u.ucancelled) {
&nbsp;            tmp = 0;
&nbsp;            break;
&nbsp;        }
&nbsp;#endif
&nbsp;        goto physical;
&nbsp;    case AD_WERE: /* no special effect on monsters */
&nbsp;    case AD_HEAL: /* likewise */
&nbsp;    case AD_PHYS:
&nbsp;    physical:
&nbsp;        if (mattk-&gt;aatyp == AT_WEAP) {
&nbsp;            if (uwep)
&nbsp;                tmp = 0;
&nbsp;        } else if (mattk-&gt;aatyp == AT_KICK) {
&nbsp;            if (thick_skinned(pd))
&nbsp;                tmp = 0;
&nbsp;            if (pd == &amp;mons[PM_SHADE]) {
&nbsp;                if (!(uarmf &amp;&amp; uarmf-&gt;blessed)) {
&nbsp;                    impossible("bad shade attack function flow?");
&nbsp;                    tmp = 0;
&nbsp;                } else
&nbsp;                    tmp = rnd(4); /* bless damage */
&nbsp;            }
&nbsp;            /* add ring(s) of increase damage */
&nbsp;            if (u.udaminc &gt; 0) {
&nbsp;                /* applies even if damage was 0 */
&nbsp;                tmp += u.udaminc;
&nbsp;            } else if (tmp &gt; 0) {
&nbsp;                /* ring(s) might be negative; avoid converting
&nbsp;                   0 to non-0 or positive to non-positive */
&nbsp;                tmp += u.udaminc;
&nbsp;                if (tmp &lt; 1)
&nbsp;                    tmp = 1;
&nbsp;            }
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_FIRE:
&nbsp;        if (negated) {
&nbsp;            tmp = 0;
&nbsp;            break;
&nbsp;        }
&nbsp;        if (!Blind)
&nbsp;            pline("%s is %s!", Monnam(mdef), on_fire(pd, mattk));
&nbsp;        if (completelyburns(pd)) { /* paper golem or straw golem */
&nbsp;            if (!Blind)
&nbsp;                pline("%s burns completely!", Monnam(mdef));
&nbsp;            else
&nbsp;                You("smell burning%s.",
&nbsp;                    (pd == &amp;mons[PM_PAPER_GOLEM]) ? " paper"
&nbsp;                      : (pd == &amp;mons[PM_STRAW_GOLEM]) ? " straw" : "");
&nbsp;            xkilled(mdef, XKILL_NOMSG | XKILL_NOCORPSE);
&nbsp;            tmp = 0;
&nbsp;            break;
&nbsp;            /* Don't return yet; keep hp&lt;1 and tmp=0 for pet msg */
&nbsp;        }
&nbsp;        tmp += destroy_mitem(mdef, SCROLL_CLASS, AD_FIRE);
&nbsp;        tmp += destroy_mitem(mdef, SPBOOK_CLASS, AD_FIRE);
&nbsp;        if (resists_fire(mdef)) {
&nbsp;            if (!Blind)
&nbsp;                pline_The("fire doesn't heat %s!", mon_nam(mdef));
&nbsp;            golemeffects(mdef, AD_FIRE, tmp);
&nbsp;            shieldeff(mdef-&gt;mx, mdef-&gt;my);
&nbsp;            tmp = 0;
&nbsp;        }
&nbsp;        /* only potions damage resistant players in destroy_item */
&nbsp;        tmp += destroy_mitem(mdef, POTION_CLASS, AD_FIRE);
&nbsp;        break;
&nbsp;    case AD_COLD:
&nbsp;        if (negated) {
&nbsp;            tmp = 0;
&nbsp;            break;
&nbsp;        }
&nbsp;        if (!Blind)
&nbsp;            pline("%s is covered in frost!", Monnam(mdef));
&nbsp;        if (resists_cold(mdef)) {
&nbsp;            shieldeff(mdef-&gt;mx, mdef-&gt;my);
&nbsp;            if (!Blind)
&nbsp;                pline_The("frost doesn't chill %s!", mon_nam(mdef));
&nbsp;            golemeffects(mdef, AD_COLD, tmp);
&nbsp;            tmp = 0;
&nbsp;        }
&nbsp;        tmp += destroy_mitem(mdef, POTION_CLASS, AD_COLD);
&nbsp;        break;
&nbsp;    case AD_ELEC:
&nbsp;        if (negated) {
&nbsp;            tmp = 0;
&nbsp;            break;
&nbsp;        }
&nbsp;        if (!Blind)
&nbsp;            pline("%s is zapped!", Monnam(mdef));
&nbsp;        tmp += destroy_mitem(mdef, WAND_CLASS, AD_ELEC);
&nbsp;        if (resists_elec(mdef)) {
&nbsp;            if (!Blind)
&nbsp;                pline_The("zap doesn't shock %s!", mon_nam(mdef));
&nbsp;            golemeffects(mdef, AD_ELEC, tmp);
&nbsp;            shieldeff(mdef-&gt;mx, mdef-&gt;my);
&nbsp;            tmp = 0;
&nbsp;        }
&nbsp;        /* only rings damage resistant players in destroy_item */
&nbsp;        tmp += destroy_mitem(mdef, RING_CLASS, AD_ELEC);
&nbsp;        break;
&nbsp;    case AD_ACID:
&nbsp;        if (resists_acid(mdef))
&nbsp;            tmp = 0;
&nbsp;        break;
&nbsp;    case AD_STON:
&nbsp;        if (!munstone(mdef, TRUE))
&nbsp;            minstapetrify(mdef, TRUE);
&nbsp;        tmp = 0;
&nbsp;        break;
&nbsp;    case AD_SSEX:
&nbsp;    case AD_SEDU:
&nbsp;    case AD_SITM:
&nbsp;        steal_it(mdef, mattk);
&nbsp;        tmp = 0;
&nbsp;        break;
&nbsp;    case AD_SGLD:
&nbsp;        /* This you as a leprechaun, so steal
&nbsp;           real gold only, no lesser coins */
&nbsp;        {
&nbsp;            struct obj *mongold = findgold(mdef-&gt;minvent);
&nbsp;            if (mongold) {
&nbsp;                obj_extract_self(mongold);
&nbsp;                if (merge_choice(invent, mongold) || inv_cnt(FALSE) &lt; 52) {
&nbsp;                    addinv(mongold);
&nbsp;                    Your("purse feels heavier.");
&nbsp;                } else {
&nbsp;                    You("grab %s's gold, but find no room in your knapsack.",
&nbsp;                        mon_nam(mdef));
&nbsp;                    dropy(mongold);
&nbsp;                }
&nbsp;            }
&nbsp;        }
&nbsp;        exercise(A_DEX, TRUE);
&nbsp;        tmp = 0;
&nbsp;        break;
&nbsp;    case AD_TLPT:
&nbsp;        if (tmp &lt;= 0)
&nbsp;            tmp = 1;
&nbsp;        if (!negated &amp;&amp; tmp &lt; mdef-&gt;mhp) {
&nbsp;            char nambuf[BUFSZ];
&nbsp;            boolean u_saw_mon =
&nbsp;                canseemon(mdef) || (u.uswallow &amp;&amp; u.ustuck == mdef);
&nbsp;            /* record the name before losing sight of monster */
&nbsp;            Strcpy(nambuf, Monnam(mdef));
&nbsp;            if (u_teleport_mon(mdef, FALSE) &amp;&amp; u_saw_mon
&nbsp;                &amp;&amp; !(canseemon(mdef) || (u.uswallow &amp;&amp; u.ustuck == mdef)))
&nbsp;                pline("%s suddenly disappears!", nambuf);
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_BLND:
&nbsp;        if (can_blnd(&amp;youmonst, mdef, mattk-&gt;aatyp, (struct obj *) 0)) {
&nbsp;            if (!Blind &amp;&amp; mdef-&gt;mcansee)
&nbsp;                pline("%s is blinded.", Monnam(mdef));
&nbsp;            mdef-&gt;mcansee = 0;
&nbsp;            tmp += mdef-&gt;mblinded;
&nbsp;            if (tmp &gt; 127)
&nbsp;                tmp = 127;
&nbsp;            mdef-&gt;mblinded = tmp;
&nbsp;        }
&nbsp;        tmp = 0;
&nbsp;        break;
&nbsp;    case AD_CURS:
&nbsp;        if (night() &amp;&amp; !rn2(10) &amp;&amp; !mdef-&gt;mcan) {
&nbsp;            if (pd == &amp;mons[PM_CLAY_GOLEM]) {
&nbsp;                if (!Blind)
&nbsp;                    pline("Some writing vanishes from %s head!",
&nbsp;                          s_suffix(mon_nam(mdef)));
&nbsp;                xkilled(mdef, XKILL_NOMSG);
&nbsp;                /* Don't return yet; keep hp&lt;1 and tmp=0 for pet msg */
&nbsp;            } else {
&nbsp;                mdef-&gt;mcan = 1;
&nbsp;                You("chuckle.");
&nbsp;            }
&nbsp;        }
&nbsp;        tmp = 0;
&nbsp;        break;
&nbsp;    case AD_DRLI:
&nbsp;        if (!negated &amp;&amp; !rn2(3) &amp;&amp; !resists_drli(mdef)) {
&nbsp;            int xtmp = d(2, 6);
&nbsp;
&nbsp;            pline("%s suddenly seems weaker!", Monnam(mdef));
&nbsp;            mdef-&gt;mhpmax -= xtmp;
&nbsp;            mdef-&gt;mhp -= xtmp;
&nbsp;            /* !m_lev: level 0 monster is killed regardless of hit points
&nbsp;               rather than drop to level -1 */
&nbsp;            if (mdef-&gt;mhp &lt;= 0 || !mdef-&gt;m_lev) {
&nbsp;                pline("%s dies!", Monnam(mdef));
&nbsp;                xkilled(mdef, XKILL_NOMSG);
&nbsp;            } else
&nbsp;                mdef-&gt;m_lev--;
&nbsp;            tmp = 0;
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_RUST:
&nbsp;        if (pd == &amp;mons[PM_IRON_GOLEM]) {
&nbsp;            pline("%s falls to pieces!", Monnam(mdef));
&nbsp;            xkilled(mdef, XKILL_NOMSG);
&nbsp;        }
&nbsp;        erode_armor(mdef, ERODE_RUST);
&nbsp;        tmp = 0;
&nbsp;        break;
&nbsp;    case AD_CORR:
&nbsp;        erode_armor(mdef, ERODE_CORRODE);
&nbsp;        tmp = 0;
&nbsp;        break;
&nbsp;    case AD_DCAY:
&nbsp;        if (pd == &amp;mons[PM_WOOD_GOLEM] || pd == &amp;mons[PM_LEATHER_GOLEM]) {
&nbsp;            pline("%s falls to pieces!", Monnam(mdef));
&nbsp;            xkilled(mdef, XKILL_NOMSG);
&nbsp;        }
&nbsp;        erode_armor(mdef, ERODE_ROT);
&nbsp;        tmp = 0;
&nbsp;        break;
&nbsp;    case AD_DREN:
&nbsp;        if (!negated &amp;&amp; !rn2(4))
&nbsp;            xdrainenergym(mdef, TRUE);
&nbsp;        tmp = 0;
&nbsp;        break;
&nbsp;    case AD_DRST:
&nbsp;    case AD_DRDX:
&nbsp;    case AD_DRCO:
&nbsp;        if (!negated &amp;&amp; !rn2(8)) {
&nbsp;            Your("%s was poisoned!", mpoisons_subj(&amp;youmonst, mattk));
&nbsp;            if (resists_poison(mdef))
&nbsp;                pline_The("poison doesn't seem to affect %s.", mon_nam(mdef));
&nbsp;            else {
&nbsp;                if (!rn2(10)) {
&nbsp;                    Your("poison was deadly...");
&nbsp;                    tmp = mdef-&gt;mhp;
&nbsp;                } else
&nbsp;                    tmp += rn1(10, 6);
&nbsp;            }
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_DRIN: {
&nbsp;        struct obj *helmet;
&nbsp;
&nbsp;        if (notonhead || !has_head(pd)) {
&nbsp;            pline("%s doesn't seem harmed.", Monnam(mdef));
&nbsp;            tmp = 0;
&nbsp;            if (!Unchanging &amp;&amp; pd == &amp;mons[PM_GREEN_SLIME]) {
&nbsp;                if (!Slimed) {
&nbsp;                    You("suck in some slime and don't feel very well.");
&nbsp;                    make_slimed(10L, (char *) 0);
&nbsp;                }
&nbsp;            }
&nbsp;            break;
&nbsp;        }
&nbsp;        if (m_slips_free(mdef, mattk))
&nbsp;            break;
&nbsp;
&nbsp;        if ((helmet = which_armor(mdef, W_ARMH)) != 0 &amp;&amp; rn2(8)) {
&nbsp;            pline("%s %s blocks your attack to %s head.",
&nbsp;                  s_suffix(Monnam(mdef)), helm_simple_name(helmet),
&nbsp;                  mhis(mdef));
&nbsp;            break;
&nbsp;        }
&nbsp;
&nbsp;        (void) eat_brains(&amp;youmonst, mdef, TRUE, &amp;tmp);
&nbsp;        break;
&nbsp;    }
&nbsp;    case AD_STCK:
&nbsp;        if (!negated &amp;&amp; !sticks(pd))
&nbsp;            u.ustuck = mdef; /* it's now stuck to you */
&nbsp;        break;
&nbsp;    case AD_WRAP:
&nbsp;        if (!sticks(pd)) {
&nbsp;            if (!u.ustuck &amp;&amp; !rn2(10)) {
&nbsp;                if (m_slips_free(mdef, mattk)) {
&nbsp;                    tmp = 0;
&nbsp;                } else {
&nbsp;                    You("swing yourself around %s!", mon_nam(mdef));
&nbsp;                    u.ustuck = mdef;
&nbsp;                }
&nbsp;            } else if (u.ustuck == mdef) {
&nbsp;                /* Monsters don't wear amulets of magical breathing */
&nbsp;                if (is_pool(u.ux, u.uy) &amp;&amp; !is_swimmer(pd)
&nbsp;                    &amp;&amp; !amphibious(pd)) {
&nbsp;                    You("drown %s...", mon_nam(mdef));
&nbsp;                    tmp = mdef-&gt;mhp;
&nbsp;                } else if (mattk-&gt;aatyp == AT_HUGS)
&nbsp;                    pline("%s is being crushed.", Monnam(mdef));
&nbsp;            } else {
&nbsp;                tmp = 0;
&nbsp;                if (flags.verbose)
&nbsp;                    You("brush against %s %s.", s_suffix(mon_nam(mdef)),
&nbsp;                        mbodypart(mdef, LEG));
&nbsp;            }
&nbsp;        } else
&nbsp;            tmp = 0;
&nbsp;        break;
&nbsp;    case AD_PLYS:
&nbsp;        if (!negated &amp;&amp; mdef-&gt;mcanmove &amp;&amp; !rn2(3) &amp;&amp; tmp &lt; mdef-&gt;mhp) {
&nbsp;            if (!Blind)
&nbsp;                pline("%s is frozen by you!", Monnam(mdef));
&nbsp;            paralyze_monst(mdef, rnd(10));
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_SLEE:
&nbsp;        if (!negated &amp;&amp; !mdef-&gt;msleeping &amp;&amp; sleep_monst(mdef, rnd(10), -1)) {
&nbsp;            if (!Blind)
&nbsp;                pline("%s is put to sleep by you!", Monnam(mdef));
&nbsp;            slept_monst(mdef);
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_SLIM:
&nbsp;        if (negated)
&nbsp;            break; /* physical damage only */
&nbsp;        if (!rn2(4) &amp;&amp; !slimeproof(pd)) {
&nbsp;            if (!munslime(mdef, TRUE) &amp;&amp; mdef-&gt;mhp &gt; 0) {
&nbsp;                /* this assumes newcham() won't fail; since hero has
&nbsp;                   a slime attack, green slimes haven't been geno'd */
&nbsp;                You("turn %s into slime.", mon_nam(mdef));
&nbsp;                if (newcham(mdef, &amp;mons[PM_GREEN_SLIME], FALSE, FALSE))
&nbsp;                    pd = mdef-&gt;data;
&nbsp;            }
&nbsp;            /* munslime attempt could have been fatal */
&nbsp;            if (mdef-&gt;mhp &lt; 1)
&nbsp;                return 2; /* skip death message */
&nbsp;            tmp = 0;
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
&nbsp;        /* there's no msomearmor() function, so just do damage */
&nbsp;        /* if (negated) break; */
&nbsp;        break;
&nbsp;    case AD_SLOW:
&nbsp;        if (!negated &amp;&amp; mdef-&gt;mspeed != MSLOW) {
&nbsp;            unsigned int oldspeed = mdef-&gt;mspeed;
&nbsp;
&nbsp;            mon_adjust_speed(mdef, -1, (struct obj *) 0);
&nbsp;            if (mdef-&gt;mspeed != oldspeed &amp;&amp; canseemon(mdef))
&nbsp;                pline("%s slows down.", Monnam(mdef));
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_CONF:
&nbsp;        if (!mdef-&gt;mconf) {
&nbsp;            if (canseemon(mdef))
&nbsp;                pline("%s looks confused.", Monnam(mdef));
&nbsp;            mdef-&gt;mconf = 1;
&nbsp;        }
&nbsp;        break;
&nbsp;    default:
&nbsp;        tmp = 0;
&nbsp;        break;
&nbsp;    }
&nbsp;
&nbsp;    mdef-&gt;mstrategy &amp;= ~STRAT_WAITFORU; /* in case player is very fast */
&nbsp;    mdef-&gt;mhp -= tmp;
&nbsp;    if (mdef-&gt;mhp &lt; 1) {
&nbsp;        if (mdef-&gt;mtame &amp;&amp; !cansee(mdef-&gt;mx, mdef-&gt;my)) {
&nbsp;            You_feel("embarrassed for a moment.");
&nbsp;            if (tmp)
&nbsp;                xkilled(mdef, XKILL_NOMSG); /* !tmp but hp&lt;1: already killed */
&nbsp;        } else if (!flags.verbose) {
&nbsp;            You("destroy it!");
&nbsp;            if (tmp)
&nbsp;                xkilled(mdef, XKILL_NOMSG);
&nbsp;        } else if (tmp)
&nbsp;            killed(mdef);
&nbsp;        return 2;
&nbsp;    }
&nbsp;    return 1;
&nbsp;}
&nbsp;
explum
&nbsp;STATIC_OVL int
&nbsp;explum(mdef, mattk)
&nbsp;register struct monst *mdef;
&nbsp;register struct attack *mattk;
&nbsp;{
&nbsp;    register int tmp = d((int) mattk-&gt;damn, (int) mattk-&gt;damd);
&nbsp;
&nbsp;    You("explode!");
&nbsp;    switch (mattk-&gt;adtyp) {
&nbsp;        boolean resistance; /* only for cold/fire/elec */
&nbsp;
&nbsp;    case AD_BLND:
&nbsp;        if (!resists_blnd(mdef)) {
&nbsp;            pline("%s is blinded by your flash of light!", Monnam(mdef));
&nbsp;            mdef-&gt;mblinded = min((int) mdef-&gt;mblinded + tmp, 127);
&nbsp;            mdef-&gt;mcansee = 0;
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_HALU:
&nbsp;        if (haseyes(mdef-&gt;data) &amp;&amp; mdef-&gt;mcansee) {
&nbsp;            pline("%s is affected by your flash of light!", Monnam(mdef));
&nbsp;            mdef-&gt;mconf = 1;
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_COLD:
&nbsp;        resistance = resists_cold(mdef);
&nbsp;        goto common;
&nbsp;    case AD_FIRE:
&nbsp;        resistance = resists_fire(mdef);
&nbsp;        goto common;
&nbsp;    case AD_ELEC:
&nbsp;        resistance = resists_elec(mdef);
&nbsp;    common:
&nbsp;        if (!resistance) {
&nbsp;            pline("%s gets blasted!", Monnam(mdef));
&nbsp;            mdef-&gt;mhp -= tmp;
&nbsp;            if (mdef-&gt;mhp &lt;= 0) {
&nbsp;                killed(mdef);
&nbsp;                return 2;
&nbsp;            }
&nbsp;        } else {
&nbsp;            shieldeff(mdef-&gt;mx, mdef-&gt;my);
&nbsp;            if (is_golem(mdef-&gt;data))
&nbsp;                golemeffects(mdef, (int) mattk-&gt;adtyp, tmp);
&nbsp;            else
&nbsp;                pline_The("blast doesn't seem to affect %s.", mon_nam(mdef));
&nbsp;        }
&nbsp;        break;
&nbsp;    default:
&nbsp;        break;
&nbsp;    }
&nbsp;    return 1;
&nbsp;}
&nbsp;
start_engulf
&nbsp;STATIC_OVL void
&nbsp;start_engulf(mdef)
&nbsp;struct monst *mdef;
&nbsp;{
&nbsp;    if (!Invisible) {
&nbsp;        map_location(u.ux, u.uy, TRUE);
&nbsp;        tmp_at(DISP_ALWAYS, mon_to_glyph(&amp;youmonst));
&nbsp;        tmp_at(mdef-&gt;mx, mdef-&gt;my);
&nbsp;    }
&nbsp;    You("engulf %s!", mon_nam(mdef));
&nbsp;    delay_output();
&nbsp;    delay_output();
&nbsp;}
&nbsp;
end_engulf
&nbsp;STATIC_OVL void
&nbsp;end_engulf()
&nbsp;{
&nbsp;    if (!Invisible) {
&nbsp;        tmp_at(DISP_END, 0);
&nbsp;        newsym(u.ux, u.uy);
&nbsp;    }
&nbsp;}
&nbsp;
gulpum
&nbsp;STATIC_OVL int
&nbsp;gulpum(mdef, mattk)
&nbsp;register struct monst *mdef;
&nbsp;register struct attack *mattk;
&nbsp;{
&nbsp;#ifdef LINT /* static char msgbuf[BUFSZ]; */
&nbsp;    char msgbuf[BUFSZ];
&nbsp;#else
&nbsp;    static char msgbuf[BUFSZ]; /* for nomovemsg */
&nbsp;#endif
&nbsp;    register int tmp;
&nbsp;    register int dam = d((int) mattk-&gt;damn, (int) mattk-&gt;damd);
&nbsp;    boolean fatal_gulp;
&nbsp;    struct obj *otmp;
&nbsp;    struct permonst *pd = mdef-&gt;data;
&nbsp;
&nbsp;    /* Not totally the same as for real monsters.  Specifically, these
&nbsp;     * don't take multiple moves.  (It's just too hard, for too little
&nbsp;     * result, to program monsters which attack from inside you, which
&nbsp;     * would be necessary if done accurately.)  Instead, we arbitrarily
&nbsp;     * kill the monster immediately for AD_DGST and we regurgitate them
&nbsp;     * after exactly 1 round of attack otherwise.  -KAA
&nbsp;     */
&nbsp;
&nbsp;    if (!engulf_target(&amp;youmonst, mdef))
&nbsp;        return 0;
&nbsp;
&nbsp;    if (u.uhunger &lt; 1500 &amp;&amp; !u.uswallow) {
&nbsp;        for (otmp = mdef-&gt;minvent; otmp; otmp = otmp-&gt;nobj)
&nbsp;            (void) snuff_lit(otmp);
&nbsp;
&nbsp;        /* force vampire in bat, cloud, or wolf form to revert back to
&nbsp;           vampire form now instead of dealing with that when it dies */
&nbsp;        if (is_vampshifter(mdef)
&nbsp;            &amp;&amp; newcham(mdef, &amp;mons[mdef-&gt;cham], FALSE, FALSE)) {
&nbsp;            You("engulf it, then expel it.");
&nbsp;            if (canspotmon(mdef))
&nbsp;                pline("It turns into %s.", a_monnam(mdef));
&nbsp;            else
&nbsp;                map_invisible(mdef-&gt;mx, mdef-&gt;my);
&nbsp;            return 1;
&nbsp;        }
&nbsp;
&nbsp;        /* engulfing a cockatrice or digesting a Rider or Medusa */
&nbsp;        fatal_gulp = (touch_petrifies(pd) &amp;&amp; !Stone_resistance)
&nbsp;                     || (mattk-&gt;adtyp == AD_DGST
&nbsp;                         &amp;&amp; (is_rider(pd) || (pd == &amp;mons[PM_MEDUSA]
&nbsp;                                              &amp;&amp; !Stone_resistance)));
&nbsp;
&nbsp;        if ((mattk-&gt;adtyp == AD_DGST &amp;&amp; !Slow_digestion) || fatal_gulp)
&nbsp;            eating_conducts(pd);
&nbsp;
&nbsp;        if (fatal_gulp &amp;&amp; !is_rider(pd)) { /* petrification */
&nbsp;            char kbuf[BUFSZ];
&nbsp;            const char *mname = pd-&gt;mname;
&nbsp;
&nbsp;            if (!type_is_pname(pd))
&nbsp;                mname = an(mname);
&nbsp;            You("englut %s.", mon_nam(mdef));
&nbsp;            Sprintf(kbuf, "swallowing %s whole", mname);
&nbsp;            instapetrify(kbuf);
&nbsp;        } else {
&nbsp;            start_engulf(mdef);
&nbsp;            switch (mattk-&gt;adtyp) {
&nbsp;            case AD_DGST:
&nbsp;                /* eating a Rider or its corpse is fatal */
&nbsp;                if (is_rider(pd)) {
&nbsp;                    pline("Unfortunately, digesting any of it is fatal.");
&nbsp;                    end_engulf();
&nbsp;                    Sprintf(killer.name, "unwisely tried to eat %s",
&nbsp;                            pd-&gt;mname);
&nbsp;                    killer.format = NO_KILLER_PREFIX;
&nbsp;                    done(DIED);
&nbsp;                    return 0; /* lifesaved */
&nbsp;                }
&nbsp;
&nbsp;                if (Slow_digestion) {
&nbsp;                    dam = 0;
&nbsp;                    break;
&nbsp;                }
&nbsp;
&nbsp;                /* Use up amulet of life saving */
&nbsp;                if (!!(otmp = mlifesaver(mdef)))
&nbsp;                    m_useup(mdef, otmp);
&nbsp;
&nbsp;                newuhs(FALSE);
&nbsp;                /* start_engulf() issues "you engulf <mdef>" above; this
&nbsp;                   used to specify XKILL_NOMSG but we need "you kill <mdef>"
&nbsp;                   in case we're also going to get "welcome to level N+1";
&nbsp;                   "you totally digest <mdef>" will be coming soon (after
&nbsp;                   several turns) but the level-gain message seems out of
&nbsp;                   order if the kill message is left implicit */
&nbsp;                xkilled(mdef, XKILL_GIVEMSG | XKILL_NOCORPSE);
&nbsp;                if (mdef-&gt;mhp &gt; 0) { /* monster lifesaved */
&nbsp;                    You("hurriedly regurgitate the sizzling in your %s.",
&nbsp;                        body_part(STOMACH));
&nbsp;                } else {
&nbsp;                    tmp = 1 + (pd-&gt;cwt &gt;&gt; 8);
&nbsp;                    if (corpse_chance(mdef, &amp;youmonst, TRUE)
&nbsp;                        &amp;&amp; !(mvitals[monsndx(pd)].mvflags &amp; G_NOCORPSE)) {
&nbsp;                        /* nutrition only if there can be a corpse */
&nbsp;                        u.uhunger += (pd-&gt;cnutrit + 1) / 2;
&nbsp;                    } else
&nbsp;                        tmp = 0;
&nbsp;                    Sprintf(msgbuf, "You totally digest %s.", mon_nam(mdef));
&nbsp;                    if (tmp != 0) {
&nbsp;                        /* setting afternmv = end_engulf is tempting,
&nbsp;                         * but will cause problems if the player is
&nbsp;                         * attacked (which uses his real location) or
&nbsp;                         * if his See_invisible wears off
&nbsp;                         */
&nbsp;                        You("digest %s.", mon_nam(mdef));
&nbsp;                        if (Slow_digestion)
&nbsp;                            tmp *= 2;
&nbsp;                        nomul(-tmp);
&nbsp;                        multi_reason = "digesting something";
&nbsp;                        nomovemsg = msgbuf;
&nbsp;                    } else
&nbsp;                        pline1(msgbuf);
&nbsp;                    if (pd == &amp;mons[PM_GREEN_SLIME]) {
&nbsp;                        Sprintf(msgbuf, "%s isn't sitting well with you.",
&nbsp;                                The(pd-&gt;mname));
&nbsp;                        if (!Unchanging) {
&nbsp;                            make_slimed(5L, (char *) 0);
&nbsp;                        }
&nbsp;                    } else
&nbsp;                        exercise(A_CON, TRUE);
&nbsp;                }
&nbsp;                end_engulf();
&nbsp;                return 2;
&nbsp;            case AD_PHYS:
&nbsp;                if (youmonst.data == &amp;mons[PM_FOG_CLOUD]) {
&nbsp;                    pline("%s is laden with your moisture.", Monnam(mdef));
&nbsp;                    if (amphibious(pd) &amp;&amp; !flaming(pd)) {
&nbsp;                        dam = 0;
&nbsp;                        pline("%s seems unharmed.", Monnam(mdef));
&nbsp;                    }
&nbsp;                } else
&nbsp;                    pline("%s is pummeled with your debris!", Monnam(mdef));
&nbsp;                break;
&nbsp;            case AD_ACID:
&nbsp;                pline("%s is covered with your goo!", Monnam(mdef));
&nbsp;                if (resists_acid(mdef)) {
&nbsp;                    pline("It seems harmless to %s.", mon_nam(mdef));
&nbsp;                    dam = 0;
&nbsp;                }
&nbsp;                break;
&nbsp;            case AD_BLND:
&nbsp;                if (can_blnd(&amp;youmonst, mdef, mattk-&gt;aatyp,
&nbsp;                             (struct obj *) 0)) {
&nbsp;                    if (mdef-&gt;mcansee)
&nbsp;                        pline("%s can't see in there!", Monnam(mdef));
&nbsp;                    mdef-&gt;mcansee = 0;
&nbsp;                    dam += mdef-&gt;mblinded;
&nbsp;                    if (dam &gt; 127)
&nbsp;                        dam = 127;
&nbsp;                    mdef-&gt;mblinded = dam;
&nbsp;                }
&nbsp;                dam = 0;
&nbsp;                break;
&nbsp;            case AD_ELEC:
&nbsp;                if (rn2(2)) {
&nbsp;                    pline_The("air around %s crackles with electricity.",
&nbsp;                              mon_nam(mdef));
&nbsp;                    if (resists_elec(mdef)) {
&nbsp;                        pline("%s seems unhurt.", Monnam(mdef));
&nbsp;                        dam = 0;
&nbsp;                    }
&nbsp;                    golemeffects(mdef, (int) mattk-&gt;adtyp, dam);
&nbsp;                } else
&nbsp;                    dam = 0;
&nbsp;                break;
&nbsp;            case AD_COLD:
&nbsp;                if (rn2(2)) {
&nbsp;                    if (resists_cold(mdef)) {
&nbsp;                        pline("%s seems mildly chilly.", Monnam(mdef));
&nbsp;                        dam = 0;
&nbsp;                    } else
&nbsp;                        pline("%s is freezing to death!", Monnam(mdef));
&nbsp;                    golemeffects(mdef, (int) mattk-&gt;adtyp, dam);
&nbsp;                } else
&nbsp;                    dam = 0;
&nbsp;                break;
&nbsp;            case AD_FIRE:
&nbsp;                if (rn2(2)) {
&nbsp;                    if (resists_fire(mdef)) {
&nbsp;                        pline("%s seems mildly hot.", Monnam(mdef));
&nbsp;                        dam = 0;
&nbsp;                    } else
&nbsp;                        pline("%s is burning to a crisp!", Monnam(mdef));
&nbsp;                    golemeffects(mdef, (int) mattk-&gt;adtyp, dam);
&nbsp;                } else
&nbsp;                    dam = 0;
&nbsp;                break;
&nbsp;            case AD_DREN:
&nbsp;                if (!rn2(4))
&nbsp;                    xdrainenergym(mdef, TRUE);
&nbsp;                dam = 0;
&nbsp;                break;
&nbsp;            }
&nbsp;            end_engulf();
&nbsp;            mdef-&gt;mhp -= dam;
&nbsp;            if (mdef-&gt;mhp &lt;= 0) {
&nbsp;                killed(mdef);
&nbsp;                if (mdef-&gt;mhp &lt;= 0) /* not lifesaved */
&nbsp;                    return 2;
&nbsp;            }
&nbsp;            You("%s %s!", is_animal(youmonst.data) ? "regurgitate" : "expel",
&nbsp;                mon_nam(mdef));
&nbsp;            if (Slow_digestion || is_animal(youmonst.data)) {
&nbsp;                pline("Obviously, you didn't like %s taste.",
&nbsp;                      s_suffix(mon_nam(mdef)));
&nbsp;            }
&nbsp;        }
&nbsp;    }
&nbsp;    return 0;
&nbsp;}
&nbsp;
missum
&nbsp;void
&nbsp;missum(mdef, mattk, wouldhavehit)
&nbsp;register struct monst *mdef;
&nbsp;register struct attack *mattk;
&nbsp;boolean wouldhavehit;
&nbsp;{
&nbsp;    if (wouldhavehit) /* monk is missing due to penalty for wearing suit */
&nbsp;        Your("armor is rather cumbersome...");
&nbsp;
&nbsp;    if (could_seduce(&amp;youmonst, mdef, mattk))
&nbsp;        You("pretend to be friendly to %s.", mon_nam(mdef));
&nbsp;    else if (canspotmon(mdef) &amp;&amp; flags.verbose)
&nbsp;        You("miss %s.", mon_nam(mdef));
&nbsp;    else
&nbsp;        You("miss it.");
&nbsp;    if (!mdef-&gt;msleeping &amp;&amp; mdef-&gt;mcanmove)
&nbsp;        wakeup(mdef, TRUE);
&nbsp;}
&nbsp;
hmonas
&nbsp;/* attack monster as a monster. */
&nbsp;STATIC_OVL boolean
&nbsp;hmonas(mon)
&nbsp;register struct monst *mon;
&nbsp;{
&nbsp;    struct attack *mattk, alt_attk;
&nbsp;    struct obj *weapon, **originalweapon;
&nbsp;    boolean altwep = FALSE, weapon_used = FALSE;
&nbsp;    int i, tmp, armorpenalty, sum[NATTK], nsum = 0, dhit = 0, attknum = 0;
&nbsp;    int dieroll;
&nbsp;
&nbsp;    for (i = 0; i &lt; NATTK; i++) {
&nbsp;        sum[i] = 0;
&nbsp;        mattk = getmattk(&amp;youmonst, mon, i, sum, &amp;alt_attk);
&nbsp;        weapon = 0;
&nbsp;        switch (mattk-&gt;aatyp) {
&nbsp;        case AT_WEAP:
&nbsp;        use_weapon:
&nbsp;            /* Certain monsters don't use weapons when encountered as enemies,
&nbsp;             * but players who polymorph into them have hands or claws and
&nbsp;             * thus should be able to use weapons.  This shouldn't prohibit
&nbsp;             * the use of most special abilities, either.
&nbsp;             * If monster has multiple claw attacks, only one can use weapon.
&nbsp;             */
&nbsp;            weapon_used = TRUE;
&nbsp;            /* Potential problem: if the monster gets multiple weapon attacks,
&nbsp;             * we currently allow the player to get each of these as a weapon
&nbsp;             * attack.  Is this really desirable?
&nbsp;             */
&nbsp;            /* approximate two-weapon mode; known_hitum() -&gt; hmon() -&gt; &amp;c
&nbsp;               might destroy the weapon argument, but it might also already
&nbsp;               be Null, and we want to track that for passive() */
&nbsp;            originalweapon = (altwep &amp;&amp; uswapwep) ? &amp;uswapwep : &amp;uwep
&nbsp;            if (uswapwep /* set up 'altwep' flag for next iteration */
&nbsp;                /* only switch to uswapwep if it's a weapon */
&nbsp;                &amp;&amp; (uswapwep-&gt;oclass == WEAPON_CLASS || is_weptool(uswapwep))
&nbsp;                /* only switch if uswapwep is not bow, arrows, or darts */
&nbsp;                &amp;&amp; !(is_launcher(uswapwep) || is_ammo(uswapwep)
&nbsp;                     || is_missile(uswapwep))) /* dart, shuriken, boomerang */
&nbsp;                altwep = !altwep; /* toggle for next attack */
&nbsp;            weapon = *originalweapon;
&nbsp;            if (!weapon) /* no need to go beyond no-gloves to rings; not ...*/
&nbsp;                originalweapon = &amp;uarmg /*... subject to erosion damage */
&nbsp;
&nbsp;            tmp = find_roll_to_hit(mon, AT_WEAP, weapon, &amp;attknum,
&nbsp;                                   &amp;armorpenalty);
&nbsp;            dieroll = rnd(20);
&nbsp;            dhit = (tmp &gt; dieroll || u.uswallow);
&nbsp;            /* Enemy dead, before any special abilities used */
&nbsp;            if (!known_hitum(mon, weapon, &amp;dhit, tmp,
&nbsp;                             armorpenalty, mattk, dieroll)) {
&nbsp;                sum[i] = 2;
&nbsp;                break;
&nbsp;            } else
&nbsp;                sum[i] = dhit;
&nbsp;            /* originalweapon points to an equipment slot which might
&nbsp;               now be empty if the weapon was destroyed during the hit;
&nbsp;               passive(,weapon,...) won't call passive_obj() in that case */
&nbsp;            weapon = *originalweapon; /* might receive passive erosion */
&nbsp;            /* might be a worm that gets cut in half */
&nbsp;            if (m_at(u.ux + u.dx, u.uy + u.dy) != mon)
&nbsp;                return (boolean) (nsum != 0);
&nbsp;            /* Do not print "You hit" message, since known_hitum
&nbsp;             * already did it.
&nbsp;             */
&nbsp;            if (dhit &amp;&amp; mattk-&gt;adtyp != AD_SPEL &amp;&amp; mattk-&gt;adtyp != AD_PHYS)
&nbsp;                sum[i] = damageum(mon, mattk);
&nbsp;            break;
&nbsp;        case AT_CLAW:
&nbsp;            if (uwep &amp;&amp; !cantwield(youmonst.data) &amp;&amp; !weapon_used)
&nbsp;                goto use_weapon;
&nbsp;            /*FALLTHRU*/
&nbsp;        case AT_TUCH:
&nbsp;            if (uwep &amp;&amp; youmonst.data-&gt;mlet == S_LICH &amp;&amp; !weapon_used)
&nbsp;                goto use_weapon;
&nbsp;            /*FALLTHRU*/
&nbsp;        case AT_KICK:
&nbsp;        case AT_BITE:
&nbsp;        case AT_STNG:
&nbsp;        case AT_BUTT:
&nbsp;        case AT_TENT:
&nbsp;            tmp = find_roll_to_hit(mon, mattk-&gt;aatyp, (struct obj *) 0,
&nbsp;                                   &amp;attknum, &amp;armorpenalty);
&nbsp;            dieroll = rnd(20);
&nbsp;            dhit = (tmp &gt; dieroll || u.uswallow);
&nbsp;            if (dhit) {
&nbsp;                int compat;
&nbsp;
&nbsp;                if (!u.uswallow
&nbsp;                    &amp;&amp; (compat = could_seduce(&amp;youmonst, mon, mattk))) {
&nbsp;                    You("%s %s %s.",
&nbsp;                        mon-&gt;mcansee &amp;&amp; haseyes(mon-&gt;data) ? "smile at"
&nbsp;                                                           : "talk to",
&nbsp;                        mon_nam(mon),
&nbsp;                        compat == 2 ? "engagingly" : "seductively");
&nbsp;                    /* doesn't anger it; no wakeup() */
&nbsp;                    sum[i] = damageum(mon, mattk);
&nbsp;                    break;
&nbsp;                }
&nbsp;                wakeup(mon, TRUE);
&nbsp;                /* maybe this check should be in damageum()? */
&nbsp;                if (mon-&gt;data == &amp;mons[PM_SHADE]
&nbsp;                    &amp;&amp; !(mattk-&gt;aatyp == AT_KICK &amp;&amp; uarmf
&nbsp;                         &amp;&amp; uarmf-&gt;blessed)) {
&nbsp;                    Your("attack passes harmlessly through %s.",
&nbsp;                         mon_nam(mon));
&nbsp;                    break;
&nbsp;                }
&nbsp;                if (mattk-&gt;aatyp == AT_KICK)
&nbsp;                    You("kick %s.", mon_nam(mon));
&nbsp;                else if (mattk-&gt;aatyp == AT_BITE)
&nbsp;                    You("bite %s.", mon_nam(mon));
&nbsp;                else if (mattk-&gt;aatyp == AT_STNG)
&nbsp;                    You("sting %s.", mon_nam(mon));
&nbsp;                else if (mattk-&gt;aatyp == AT_BUTT)
&nbsp;                    You("butt %s.", mon_nam(mon));
&nbsp;                else if (mattk-&gt;aatyp == AT_TUCH)
&nbsp;                    You("touch %s.", mon_nam(mon));
&nbsp;                else if (mattk-&gt;aatyp == AT_TENT)
&nbsp;                    Your("tentacles suck %s.", mon_nam(mon));
&nbsp;                else
&nbsp;                    You("hit %s.", mon_nam(mon));
&nbsp;                sum[i] = damageum(mon, mattk);
&nbsp;            } else {
&nbsp;                missum(mon, mattk, (tmp + armorpenalty &gt; dieroll));
&nbsp;            }
&nbsp;            break;
&nbsp;
&nbsp;        case AT_HUGS:
&nbsp;            /* automatic if prev two attacks succeed, or if
&nbsp;             * already grabbed in a previous attack
&nbsp;             */
&nbsp;            dhit = 1;
&nbsp;            wakeup(mon, TRUE);
&nbsp;            if (mon-&gt;data == &amp;mons[PM_SHADE])
&nbsp;                Your("hug passes harmlessly through %s.", mon_nam(mon));
&nbsp;            else if (!sticks(mon-&gt;data) &amp;&amp; !u.uswallow) {
&nbsp;                if (mon == u.ustuck) {
&nbsp;                    pline("%s is being %s.", Monnam(mon),
&nbsp;                          u.umonnum == PM_ROPE_GOLEM ? "choked" : "crushed");
&nbsp;                    sum[i] = damageum(mon, mattk);
&nbsp;                } else if (i &gt;= 2 &amp;&amp; sum[i - 1] &amp;&amp; sum[i - 2]) {
&nbsp;                    You("grab %s!", mon_nam(mon));
&nbsp;                    u.ustuck = mon;
&nbsp;                    sum[i] = damageum(mon, mattk);
&nbsp;                }
&nbsp;            }
&nbsp;            break;
&nbsp;
&nbsp;        case AT_EXPL: /* automatic hit if next to */
&nbsp;            dhit = -1;
&nbsp;            wakeup(mon, TRUE);
&nbsp;            sum[i] = explum(mon, mattk);
&nbsp;            break;
&nbsp;
&nbsp;        case AT_ENGL:
&nbsp;            tmp = find_roll_to_hit(mon, mattk-&gt;aatyp, (struct obj *) 0,
&nbsp;                                   &amp;attknum, &amp;armorpenalty);
&nbsp;            if ((dhit = (tmp &gt; rnd(20 + i)))) {
&nbsp;                wakeup(mon, TRUE);
&nbsp;                if (mon-&gt;data == &amp;mons[PM_SHADE])
&nbsp;                    Your("attempt to surround %s is harmless.", mon_nam(mon));
&nbsp;                else {
&nbsp;                    sum[i] = gulpum(mon, mattk);
&nbsp;                    if (sum[i] == 2 &amp;&amp; (mon-&gt;data-&gt;mlet == S_ZOMBIE
&nbsp;                                        || mon-&gt;data-&gt;mlet == S_MUMMY)
&nbsp;                        &amp;&amp; rn2(5) &amp;&amp; !Sick_resistance) {
&nbsp;                        You_feel("%ssick.", (Sick) ? "very " : "");
&nbsp;                        mdamageu(mon, rnd(8));
&nbsp;                    }
&nbsp;                }
&nbsp;            } else {
&nbsp;                missum(mon, mattk, FALSE);
&nbsp;            }
&nbsp;            break;
&nbsp;
&nbsp;        case AT_MAGC:
&nbsp;            /* No check for uwep; if wielding nothing we want to
&nbsp;             * do the normal 1-2 points bare hand damage...
&nbsp;             */
&nbsp;            if ((youmonst.data-&gt;mlet == S_KOBOLD
&nbsp;                 || youmonst.data-&gt;mlet == S_ORC
&nbsp;                 || youmonst.data-&gt;mlet == S_GNOME) &amp;&amp; !weapon_used)
&nbsp;                goto use_weapon;
&nbsp;            /*FALLTHRU*/
&nbsp;
&nbsp;        case AT_NONE:
&nbsp;        case AT_BOOM:
&nbsp;            continue;
&nbsp;        /* Not break--avoid passive attacks from enemy */
&nbsp;
&nbsp;        case AT_BREA:
&nbsp;        case AT_SPIT:
&nbsp;        case AT_GAZE: /* all done using #monster command */
&nbsp;            dhit = 0;
&nbsp;            break;
&nbsp;
&nbsp;        default: /* Strange... */
&nbsp;            impossible("strange attack of yours (%d)", mattk-&gt;aatyp);
&nbsp;        }
&nbsp;        if (dhit == -1) {
&nbsp;            u.mh = -1; /* dead in the current form */
&nbsp;            rehumanize();
&nbsp;        }
&nbsp;        if (sum[i] == 2) {
&nbsp;            /* defender dead */
&nbsp;            return (boolean) passive(mon, weapon, 1, 0, mattk-&gt;aatyp, FALSE);
&nbsp;        } else {
&nbsp;            (void) passive(mon, weapon, sum[i], 1, mattk-&gt;aatyp, FALSE);
&nbsp;            nsum |= sum[i];
&nbsp;        }
&nbsp;        if (!Upolyd)
&nbsp;            break; /* No extra attacks if no longer a monster */
&nbsp;        if (multi &lt; 0)
&nbsp;            break; /* If paralyzed while attacking, i.e. floating eye */
&nbsp;    }
&nbsp;    return (boolean) (nsum != 0);
&nbsp;}
&nbsp;
passive
&nbsp;/*      Special (passive) attacks on you by monsters done here.
&nbsp; */
&nbsp;int
&nbsp;passive(mon, weapon, mhit, malive, aatyp, wep_was_destroyed)
&nbsp;struct monst *mon;
&nbsp;struct obj *weapon; /* uwep or uswapwep or uarmg or uarmf or Null */
&nbsp;boolean mhit;
&nbsp;int malive;
&nbsp;uchar aatyp;
&nbsp;boolean wep_was_destroyed;
&nbsp;{
&nbsp;    register struct permonst *ptr = mon-&gt;data;
&nbsp;    register int i, tmp;
&nbsp;
&nbsp;    for (i = 0;; i++) {
&nbsp;        if (i &gt;= NATTK)
&nbsp;            return (malive | mhit); /* no passive attacks */
&nbsp;        if (ptr-&gt;mattk[i].aatyp == AT_NONE)
&nbsp;            break; /* try this one */
&nbsp;    }
&nbsp;    /* Note: tmp not always used */
&nbsp;    if (ptr-&gt;mattk[i].damn)
&nbsp;        tmp = d((int) ptr-&gt;mattk[i].damn, (int) ptr-&gt;mattk[i].damd);
&nbsp;    else if (ptr-&gt;mattk[i].damd)
&nbsp;        tmp = d((int) mon-&gt;m_lev + 1, (int) ptr-&gt;mattk[i].damd);
&nbsp;    else
&nbsp;        tmp = 0;
&nbsp;
&nbsp;    /*  These affect you even if they just died.
&nbsp;     */
&nbsp;    switch (ptr-&gt;mattk[i].adtyp) {
&nbsp;    case AD_FIRE:
&nbsp;        if (mhit &amp;&amp; !mon-&gt;mcan &amp;&amp; weapon) {
&nbsp;            if (aatyp == AT_KICK) {
&nbsp;                if (uarmf &amp;&amp; !rn2(6))
&nbsp;                    (void) erode_obj(uarmf, xname(uarmf), ERODE_BURN,
&nbsp;                                     EF_GREASE | EF_VERBOSE);
&nbsp;            } else if (aatyp == AT_WEAP || aatyp == AT_CLAW
&nbsp;                       || aatyp == AT_MAGC || aatyp == AT_TUCH)
&nbsp;                passive_obj(mon, weapon, &amp;(ptr-&gt;mattk[i]));
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_ACID:
&nbsp;        if (mhit &amp;&amp; rn2(2)) {
&nbsp;            if (Blind || !flags.verbose)
&nbsp;                You("are splashed!");
&nbsp;            else
&nbsp;                You("are splashed by %s %s!", s_suffix(mon_nam(mon)),
&nbsp;                    hliquid("acid"));
&nbsp;
&nbsp;            if (!Acid_resistance)
&nbsp;                mdamageu(mon, tmp);
&nbsp;            if (!rn2(30))
&nbsp;                erode_armor(&amp;youmonst, ERODE_CORRODE);
&nbsp;        }
&nbsp;        if (mhit &amp;&amp; weapon) {
&nbsp;            if (aatyp == AT_KICK) {
&nbsp;                if (uarmf &amp;&amp; !rn2(6))
&nbsp;                    (void) erode_obj(uarmf, xname(uarmf), ERODE_CORRODE,
&nbsp;                                     EF_GREASE | EF_VERBOSE);
&nbsp;            } else if (aatyp == AT_WEAP || aatyp == AT_CLAW
&nbsp;                       || aatyp == AT_MAGC || aatyp == AT_TUCH)
&nbsp;                passive_obj(mon, weapon, &amp;(ptr-&gt;mattk[i]));
&nbsp;        }
&nbsp;        exercise(A_STR, FALSE);
&nbsp;        break;
&nbsp;    case AD_STON:
&nbsp;        if (mhit) { /* successful attack */
&nbsp;            long protector = attk_protection((int) aatyp);
&nbsp;
&nbsp;            /* hero using monsters' AT_MAGC attack is hitting hand to
&nbsp;               hand rather than casting a spell */
&nbsp;            if (aatyp == AT_MAGC)
&nbsp;                protector = W_ARMG;
&nbsp;
&nbsp;            if (protector == 0L /* no protection */
&nbsp;                || (protector == W_ARMG &amp;&amp; !uarmg
&nbsp;                    &amp;&amp; !uwep &amp;&amp; !wep_was_destroyed)
&nbsp;                || (protector == W_ARMF &amp;&amp; !uarmf)
&nbsp;                || (protector == W_ARMH &amp;&amp; !uarmh)
&nbsp;                || (protector == (W_ARMC | W_ARMG) &amp;&amp; (!uarmc || !uarmg))) {
&nbsp;                if (!Stone_resistance
&nbsp;                    &amp;&amp; !(poly_when_stoned(youmonst.data)
&nbsp;                         &amp;&amp; polymon(PM_STONE_GOLEM))) {
&nbsp;                    done_in_by(mon, STONING); /* "You turn to stone..." */
&nbsp;                    return 2;
&nbsp;                }
&nbsp;            }
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_RUST:
&nbsp;        if (mhit &amp;&amp; !mon-&gt;mcan &amp;&amp; weapon) {
&nbsp;            if (aatyp == AT_KICK) {
&nbsp;                if (uarmf)
&nbsp;                    (void) erode_obj(uarmf, xname(uarmf), ERODE_RUST,
&nbsp;                                     EF_GREASE | EF_VERBOSE);
&nbsp;            } else if (aatyp == AT_WEAP || aatyp == AT_CLAW
&nbsp;                       || aatyp == AT_MAGC || aatyp == AT_TUCH)
&nbsp;                passive_obj(mon, weapon, &amp;(ptr-&gt;mattk[i]));
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_CORR:
&nbsp;        if (mhit &amp;&amp; !mon-&gt;mcan &amp;&amp; weapon) {
&nbsp;            if (aatyp == AT_KICK) {
&nbsp;                if (uarmf)
&nbsp;                    (void) erode_obj(uarmf, xname(uarmf), ERODE_CORRODE,
&nbsp;                                     EF_GREASE | EF_VERBOSE);
&nbsp;            } else if (aatyp == AT_WEAP || aatyp == AT_CLAW
&nbsp;                       || aatyp == AT_MAGC || aatyp == AT_TUCH)
&nbsp;                passive_obj(mon, weapon, &amp;(ptr-&gt;mattk[i]));
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_MAGM:
&nbsp;        /* wrath of gods for attacking Oracle */
&nbsp;        if (Antimagic) {
&nbsp;            shieldeff(u.ux, u.uy);
&nbsp;            pline("A hail of magic missiles narrowly misses you!");
&nbsp;        } else {
&nbsp;            You("are hit by magic missiles appearing from thin air!");
&nbsp;            mdamageu(mon, tmp);
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
&nbsp;        if (mhit) {
&nbsp;            if (aatyp == AT_KICK) {
&nbsp;                if (!weapon)
&nbsp;                    break;
&nbsp;            } else if (aatyp == AT_BITE || aatyp == AT_BUTT
&nbsp;                       || (aatyp &gt;= AT_STNG &amp;&amp; aatyp &lt; AT_WEAP)) {
&nbsp;                break; /* no object involved */
&nbsp;            }
&nbsp;            passive_obj(mon, weapon, &amp;(ptr-&gt;mattk[i]));
&nbsp;        }
&nbsp;        break;
&nbsp;    default:
&nbsp;        break;
&nbsp;    }
&nbsp;
&nbsp;    /*  These only affect you if they still live.
&nbsp;     */
&nbsp;    if (malive &amp;&amp; !mon-&gt;mcan &amp;&amp; rn2(3)) {
&nbsp;        switch (ptr-&gt;mattk[i].adtyp) {
&nbsp;        case AD_PLYS:
&nbsp;            if (ptr == &amp;mons[PM_FLOATING_EYE]) {
&nbsp;                if (!canseemon(mon)) {
&nbsp;                    break;
&nbsp;                }
&nbsp;                if (mon-&gt;mcansee) {
&nbsp;                    if (ureflects("%s gaze is reflected by your %s.",
&nbsp;                                  s_suffix(Monnam(mon)))) {
&nbsp;                        ;
&nbsp;                    } else if (Free_action) {
&nbsp;                        You("momentarily stiffen under %s gaze!",
&nbsp;                            s_suffix(mon_nam(mon)));
&nbsp;                    } else if (Hallucination &amp;&amp; rn2(4)) {
&nbsp;                        pline("%s looks %s%s.", Monnam(mon),
&nbsp;                              !rn2(2) ? "" : "rather ",
&nbsp;                              !rn2(2) ? "numb" : "stupified");
&nbsp;                    } else {
&nbsp;                        You("are frozen by %s gaze!", s_suffix(mon_nam(mon)));
&nbsp;                        nomul((ACURR(A_WIS) &gt; 12 || rn2(4)) ? -tmp : -127);
&nbsp;                        multi_reason = "frozen by a monster's gaze";
&nbsp;                        nomovemsg = 0;
&nbsp;                    }
&nbsp;                } else {
&nbsp;                    pline("%s cannot defend itself.",
&nbsp;                          Adjmonnam(mon, "blind"));
&nbsp;                    if (!rn2(500))
&nbsp;                        change_luck(-1);
&nbsp;                }
&nbsp;            } else if (Free_action) {
&nbsp;                You("momentarily stiffen.");
&nbsp;            } else { /* gelatinous cube */
&nbsp;                You("are frozen by %s!", mon_nam(mon));
&nbsp;                nomovemsg = You_can_move_again;
&nbsp;                nomul(-tmp);
&nbsp;                multi_reason = "frozen by a monster";
&nbsp;                exercise(A_DEX, FALSE);
&nbsp;            }
&nbsp;            break;
&nbsp;        case AD_COLD: /* brown mold or blue jelly */
&nbsp;            if (monnear(mon, u.ux, u.uy)) {
&nbsp;                if (Cold_resistance) {
&nbsp;                    shieldeff(u.ux, u.uy);
&nbsp;                    You_feel("a mild chill.");
&nbsp;                    ugolemeffects(AD_COLD, tmp);
&nbsp;                    break;
&nbsp;                }
&nbsp;                You("are suddenly very cold!");
&nbsp;                mdamageu(mon, tmp);
&nbsp;                /* monster gets stronger with your heat! */
&nbsp;                mon-&gt;mhp += tmp / 2;
&nbsp;                if (mon-&gt;mhpmax &lt; mon-&gt;mhp)
&nbsp;                    mon-&gt;mhpmax = mon-&gt;mhp;
&nbsp;                /* at a certain point, the monster will reproduce! */
&nbsp;                if (mon-&gt;mhpmax &gt; ((int) (mon-&gt;m_lev + 1) * 8))
&nbsp;                    (void) split_mon(mon, &amp;youmonst);
&nbsp;            }
&nbsp;            break;
&nbsp;        case AD_STUN: /* specifically yellow mold */
&nbsp;            if (!Stunned)
&nbsp;                make_stunned((long) tmp, TRUE);
&nbsp;            break;
&nbsp;        case AD_FIRE:
&nbsp;            if (monnear(mon, u.ux, u.uy)) {
&nbsp;                if (Fire_resistance) {
&nbsp;                    shieldeff(u.ux, u.uy);
&nbsp;                    You_feel("mildly warm.");
&nbsp;                    ugolemeffects(AD_FIRE, tmp);
&nbsp;                    break;
&nbsp;                }
&nbsp;                You("are suddenly very hot!");
&nbsp;                mdamageu(mon, tmp); /* fire damage */
&nbsp;            }
&nbsp;            break;
&nbsp;        case AD_ELEC:
&nbsp;            if (Shock_resistance) {
&nbsp;                shieldeff(u.ux, u.uy);
&nbsp;                You_feel("a mild tingle.");
&nbsp;                ugolemeffects(AD_ELEC, tmp);
&nbsp;                break;
&nbsp;            }
&nbsp;            You("are jolted with electricity!");
&nbsp;            mdamageu(mon, tmp);
&nbsp;            break;
&nbsp;        default:
&nbsp;            break;
&nbsp;        }
&nbsp;    }
&nbsp;    return (malive | mhit);
&nbsp;}
&nbsp;
passive_obj
&nbsp;/*
&nbsp; * Special (passive) attacks on an attacking object by monsters done here.
&nbsp; * Assumes the attack was successful.
&nbsp; */
&nbsp;void
&nbsp;passive_obj(mon, obj, mattk)
&nbsp;struct monst *mon;
&nbsp;struct obj *obj;          /* null means pick uwep, uswapwep or uarmg */
&nbsp;struct attack *mattk;     /* null means we find one internally */
&nbsp;{
&nbsp;    struct permonst *ptr = mon-&gt;data;
&nbsp;    int i;
&nbsp;
&nbsp;    /* [this first bit is obsolete; we're not called with Null anymore] */
&nbsp;    /* if caller hasn't specified an object, use uwep, uswapwep or uarmg */
&nbsp;    if (!obj) {
&nbsp;        obj = (u.twoweap &amp;&amp; uswapwep &amp;&amp; !rn2(2)) ? uswapwep : uwep;
&nbsp;        if (!obj &amp;&amp; mattk-&gt;adtyp == AD_ENCH)
&nbsp;            obj = uarmg; /* no weapon? then must be gloves */
&nbsp;        if (!obj)
&nbsp;            return; /* no object to affect */
&nbsp;    }
&nbsp;
&nbsp;    /* if caller hasn't specified an attack, find one */
&nbsp;    if (!mattk) {
&nbsp;        for (i = 0;; i++) {
&nbsp;            if (i &gt;= NATTK)
&nbsp;                return; /* no passive attacks */
&nbsp;            if (ptr-&gt;mattk[i].aatyp == AT_NONE)
&nbsp;                break; /* try this one */
&nbsp;        }
&nbsp;        mattk = &amp;(ptr-&gt;mattk[i]);
&nbsp;    }
&nbsp;
&nbsp;    switch (mattk-&gt;adtyp) {
&nbsp;    case AD_FIRE:
&nbsp;        if (!rn2(6) &amp;&amp; !mon-&gt;mcan
&nbsp;            /* steam vortex: fire resist applies, fire damage doesn't */
&nbsp;            &amp;&amp; mon-&gt;data != &amp;mons[PM_STEAM_VORTEX]) {
&nbsp;            (void) erode_obj(obj, NULL, ERODE_BURN, EF_NONE);
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_ACID:
&nbsp;        if (!rn2(6)) {
&nbsp;            (void) erode_obj(obj, NULL, ERODE_CORRODE, EF_GREASE);
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_RUST:
&nbsp;        if (!mon-&gt;mcan) {
&nbsp;            (void) erode_obj(obj, (char *) 0, ERODE_RUST, EF_GREASE);
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_CORR:
&nbsp;        if (!mon-&gt;mcan) {
&nbsp;            (void) erode_obj(obj, (char *) 0, ERODE_CORRODE, EF_GREASE);
&nbsp;        }
&nbsp;        break;
&nbsp;    case AD_ENCH:
&nbsp;        if (!mon-&gt;mcan) {
&nbsp;            if (drain_item(obj, TRUE) &amp;&amp; carried(obj)
&nbsp;                &amp;&amp; (obj-&gt;known || obj-&gt;oclass == ARMOR_CLASS)) {
&nbsp;                pline("%s less effective.", Yobjnam2(obj, "seem"));
&nbsp;            }
&nbsp;            break;
&nbsp;        }
&nbsp;    default:
&nbsp;        break;
&nbsp;    }
&nbsp;
&nbsp;    if (carried(obj))
&nbsp;        update_inventory();
&nbsp;}
&nbsp;
stumble_onto_mimic
&nbsp;/* Note: caller must ascertain mtmp is mimicking... */
&nbsp;void
&nbsp;stumble_onto_mimic(mtmp)
&nbsp;struct monst *mtmp;
&nbsp;{
&nbsp;    const char *fmt = "Wait!  That's %s!", *generic = "a monster", *what = 0;
&nbsp;
&nbsp;    if (!u.ustuck &amp;&amp; !mtmp-&gt;mflee &amp;&amp; dmgtype(mtmp-&gt;data, AD_STCK))
&nbsp;        u.ustuck = mtmp;
&nbsp;
&nbsp;    if (Blind) {
&nbsp;        if (!Blind_telepat)
&nbsp;            what = generic; /* with default fmt */
&nbsp;        else if (mtmp-&gt;m_ap_type == M_AP_MONSTER)
&nbsp;            what = a_monnam(mtmp); /* differs from what was sensed */
&nbsp;    } else {
&nbsp;        int glyph = levl[u.ux + u.dx][u.uy + u.dy].glyph;
&nbsp;
&nbsp;        if (glyph_is_cmap(glyph) &amp;&amp; (glyph_to_cmap(glyph) == S_hcdoor
&nbsp;                                     || glyph_to_cmap(glyph) == S_vcdoor))
&nbsp;            fmt = "The door actually was %s!";
&nbsp;        else if (glyph_is_object(glyph) &amp;&amp; glyph_to_obj(glyph) == GOLD_PIECE)
&nbsp;            fmt = "That gold was %s!";
&nbsp;
&nbsp;        /* cloned Wiz starts out mimicking some other monster and
&nbsp;           might make himself invisible before being revealed */
&nbsp;        if (mtmp-&gt;minvis &amp;&amp; !See_invisible)
&nbsp;            what = generic;
&nbsp;        else
&nbsp;            what = a_monnam(mtmp);
&nbsp;    }
&nbsp;    if (what)
&nbsp;        pline(fmt, what);
&nbsp;
&nbsp;    wakeup(mtmp, FALSE); /* clears mimicking */
&nbsp;    /* if hero is blind, wakeup() won't display the monster even though
&nbsp;       it's no longer concealed */
&nbsp;    if (!canspotmon(mtmp)
&nbsp;        &amp;&amp; !glyph_is_invisible(levl[mtmp-&gt;mx][mtmp-&gt;my].glyph))
&nbsp;        map_invisible(mtmp-&gt;mx, mtmp-&gt;my);
&nbsp;}
&nbsp;
nohandglow
&nbsp;STATIC_OVL void
&nbsp;nohandglow(mon)
&nbsp;struct monst *mon;
&nbsp;{
&nbsp;    char *hands = makeplural(body_part(HAND));
&nbsp;
&nbsp;    if (!u.umconf || mon-&gt;mconf)
&nbsp;        return;
&nbsp;    if (u.umconf == 1) {
&nbsp;        if (Blind)
&nbsp;            Your("%s stop tingling.", hands);
&nbsp;        else
&nbsp;            Your("%s stop glowing %s.", hands, hcolor(NH_RED));
&nbsp;    } else {
&nbsp;        if (Blind)
&nbsp;            pline_The("tingling in your %s lessens.", hands);
&nbsp;        else
&nbsp;            Your("%s no longer glow so brightly %s.", hands, hcolor(NH_RED));
&nbsp;    }
&nbsp;    u.umconf--;
&nbsp;}
&nbsp;
flash_hits_mon
&nbsp;int
&nbsp;flash_hits_mon(mtmp, otmp)
&nbsp;struct monst *mtmp;
&nbsp;struct obj *otmp; /* source of flash */
&nbsp;{
&nbsp;    int tmp, amt, res = 0, useeit = canseemon(mtmp);
&nbsp;
&nbsp;    if (mtmp-&gt;msleeping) {
&nbsp;        mtmp-&gt;msleeping = 0;
&nbsp;        if (useeit) {
&nbsp;            pline_The("flash awakens %s.", mon_nam(mtmp));
&nbsp;            res = 1;
&nbsp;        }
&nbsp;    } else if (mtmp-&gt;data-&gt;mlet != S_LIGHT) {
&nbsp;        if (!resists_blnd(mtmp)) {
&nbsp;            tmp = dist2(otmp-&gt;ox, otmp-&gt;oy, mtmp-&gt;mx, mtmp-&gt;my);
&nbsp;            if (useeit) {
&nbsp;                pline("%s is blinded by the flash!", Monnam(mtmp));
&nbsp;                res = 1;
&nbsp;            }
&nbsp;            if (mtmp-&gt;data == &amp;mons[PM_GREMLIN]) {
&nbsp;                /* Rule #1: Keep them out of the light. */
&nbsp;                amt = otmp-&gt;otyp == WAN_LIGHT ? d(1 + otmp-&gt;spe, 4)
&nbsp;                                              : rn2(min(mtmp-&gt;mhp, 4));
&nbsp;                light_hits_gremlin(mtmp, amt);
&nbsp;            }
&nbsp;            if (mtmp-&gt;mhp &gt; 0) {
&nbsp;                if (!context.mon_moving)
&nbsp;                    setmangry(mtmp, TRUE);
&nbsp;                if (tmp &lt; 9 &amp;&amp; !mtmp-&gt;isshk &amp;&amp; rn2(4))
&nbsp;                    monflee(mtmp, rn2(4) ? rnd(100) : 0, FALSE, TRUE);
&nbsp;                mtmp-&gt;mcansee = 0;
&nbsp;                mtmp-&gt;mblinded = (tmp &lt; 3) ? 0 : rnd(1 + 50 / tmp);
&nbsp;            }
&nbsp;        }
&nbsp;    }
&nbsp;    return res;
&nbsp;}
&nbsp;
light_hits_gremlin
&nbsp;void
&nbsp;light_hits_gremlin(mon, dmg)
&nbsp;struct monst *mon;
&nbsp;int dmg;
&nbsp;{
&nbsp;    pline("%s %s!", Monnam(mon),
&nbsp;          (dmg &gt; mon-&gt;mhp / 2) ? "wails in agony" : "cries out in pain");
&nbsp;    mon-&gt;mhp -= dmg;
&nbsp;    wake_nearto(mon-&gt;mx, mon-&gt;my, 30);
&nbsp;    if (mon-&gt;mhp &lt;= 0) {
&nbsp;        if (context.mon_moving)
&nbsp;            monkilled(mon, (char *) 0, AD_BLND);
&nbsp;        else
&nbsp;            killed(mon);
&nbsp;    } else if (cansee(mon-&gt;mx, mon-&gt;my) &amp;&amp; !canspotmon(mon)) {
&nbsp;        map_invisible(mon-&gt;mx, mon-&gt;my);
&nbsp;    }
&nbsp;}
&nbsp;
&nbsp;/*uhitm.c*/

</mdef></mdef></mdef></obj></obj></u.ux+u.dx,u.uy+u.dy>