Source:NetHack 3.6.2/src/mthrowu.c

From NetHackWiki
Jump to navigation Jump to search

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

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.

1. /* NetHack 3.6	mthrowu.c	$NHDT-Date: 1542765360 2018/11/21 01:56:00 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.78 $ */
2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3. /*-Copyright (c) Pasi Kallinen, 2016. */
4. /* NetHack may be freely redistributed.  See license for details. */
5. 
6. #include "hack.h"
7. 
8. STATIC_DCL int FDECL(monmulti, (struct monst *, struct obj *, struct obj *));
9. STATIC_DCL void FDECL(monshoot, (struct monst *, struct obj *, struct obj *));
10. STATIC_DCL int FDECL(drop_throw, (struct obj *, BOOLEAN_P, int, int));
11. STATIC_DCL boolean FDECL(m_lined_up, (struct monst *, struct monst *));
12. 
13. #define URETREATING(x, y) \
14.     (distmin(u.ux, u.uy, x, y) > distmin(u.ux0, u.uy0, x, y))
15. 
16. #define POLE_LIM 5 /* How far monsters can use pole-weapons */
17. 
18. #define PET_MISSILE_RANGE2 36 /* Square of distance within which pets shoot */
19. 
20. /*
21.  * Keep consistent with breath weapons in zap.c, and AD_* in monattk.h.
22.  */
23. STATIC_OVL NEARDATA const char *breathwep[] = {
24.     "fragments", "fire", "frost", "sleep gas", "a disintegration blast",
25.     "lightning", "poison gas", "acid", "strange breath #8",
26.     "strange breath #9"
27. };
28. 
29. extern boolean notonhead; /* for long worms */
30. STATIC_VAR int mesg_given; /* for m_throw()/thitu() 'miss' message */
31. 
32. /* hero is hit by something other than a monster */
33. int
34. thitu(tlev, dam, objp, name)
35. int tlev, dam;
36. struct obj **objp;
37. const char *name; /* if null, then format `*objp' */
38. {
39.     struct obj *obj = objp ? *objp : 0;
40.     const char *onm, *knm;
41.     boolean is_acid;
42.     int kprefix = KILLED_BY_AN, dieroll;
43.     char onmbuf[BUFSZ], knmbuf[BUFSZ];
44. 
45.     if (!name) {
46.         if (!obj)
47.             panic("thitu: name & obj both null?");
48.         name = strcpy(onmbuf,
49.                       (obj->quan > 1L) ? doname(obj) : mshot_xname(obj));
50.         knm = strcpy(knmbuf, killer_xname(obj));
51.         kprefix = KILLED_BY; /* killer_name supplies "an" if warranted */
52.     } else {
53.         knm = name;
54.         /* [perhaps ought to check for plural here to] */
55.         if (!strncmpi(name, "the ", 4) || !strncmpi(name, "an ", 3)
56.             || !strncmpi(name, "a ", 2))
57.             kprefix = KILLED_BY;
58.     }
59.     onm = (obj && obj_is_pname(obj)) ? the(name)
60.           : (obj && obj->quan > 1L) ? name
61.             : an(name);
62.     is_acid = (obj && obj->otyp == ACID_VENOM);
63. 
64.     if (u.uac + tlev <= (dieroll = rnd(20))) {
65.         ++mesg_given;
66.         if (Blind || !flags.verbose) {
67.             pline("It misses.");
68.         } else if (u.uac + tlev <= dieroll - 2) {
69.             if (onm != onmbuf)
70.                 Strcpy(onmbuf, onm); /* [modifiable buffer for upstart()] */
71.             pline("%s %s you.", upstart(onmbuf), vtense(onmbuf, "miss"));
72.         } else
73.             You("are almost hit by %s.", onm);
74.         return 0;
75.     } else {
76.         if (Blind || !flags.verbose)
77.             You("are hit%s", exclam(dam));
78.         else
79.             You("are hit by %s%s", onm, exclam(dam));
80. 
81.         if (is_acid && Acid_resistance) {
82.             pline("It doesn't seem to hurt you.");
83.         } else if (obj && obj->oclass == POTION_CLASS) {
84.             /* an explosion which scatters objects might hit hero with one
85.                (potions deliberately thrown at hero are handled by m_throw) */
86.             potionhit(&youmonst, obj, POTHIT_OTHER_THROW);
87.             *objp = obj = 0; /* potionhit() uses up the potion */
88.         } else {
89.             if (obj && objects[obj->otyp].oc_material == SILVER
90.                 && Hate_silver) {
91.                 /* extra damage already applied by dmgval() */
92.                 pline_The("silver sears your flesh!");
93.                 exercise(A_CON, FALSE);
94.             }
95.             if (is_acid)
96.                 pline("It burns!");
97.             losehp(dam, knm, kprefix); /* acid damage */
98.             exercise(A_STR, FALSE);
99.         }
100.         return 1;
101.     }
102. }
103. 
104. /* Be sure this corresponds with what happens to player-thrown objects in
105.  * dothrow.c (for consistency). --KAA
106.  * Returns 0 if object still exists (not destroyed).
107.  */
108. STATIC_OVL int
109. drop_throw(obj, ohit, x, y)
110. register struct obj *obj;
111. boolean ohit;
112. int x, y;
113. {
114.     int retvalu = 1;
115.     int create;
116.     struct monst *mtmp;
117.     struct trap *t;
118. 
119.     if (obj->otyp == CREAM_PIE || obj->oclass == VENOM_CLASS
120.         || (ohit && obj->otyp == EGG))
121.         create = 0;
122.     else if (ohit && (is_multigen(obj) || obj->otyp == ROCK))
123.         create = !rn2(3);
124.     else
125.         create = 1;
126. 
127.     if (create && !((mtmp = m_at(x, y)) != 0 && mtmp->mtrapped
128.                     && (t = t_at(x, y)) != 0
129.                     && is_pit(t->ttyp))) {
130.         int objgone = 0;
131. 
132.         if (down_gate(x, y) != -1)
133.             objgone = ship_object(obj, x, y, FALSE);
134.         if (!objgone) {
135.             if (!flooreffects(obj, x, y, "fall")) {
136.                 place_object(obj, x, y);
137.                 if (!mtmp && x == u.ux && y == u.uy)
138.                     mtmp = &youmonst;
139.                 if (mtmp && ohit)
140.                     passive_obj(mtmp, obj, (struct attack *) 0);
141.                 stackobj(obj);
142.                 retvalu = 0;
143.             }
144.         }
145.     } else
146.         obfree(obj, (struct obj *) 0);
147.     return retvalu;
148. }
149. 
150. /* The monster that's being shot at when one monster shoots at another */
151. STATIC_OVL struct monst *target = 0;
152. /* The monster that's doing the shooting/throwing */
153. STATIC_OVL struct monst *archer = 0;
154. 
155. /* calculate multishot volley count for mtmp throwing otmp (if not ammo) or
156.    shooting otmp with mwep (if otmp is ammo and mwep appropriate launcher) */
157. STATIC_OVL int
158. monmulti(mtmp, otmp, mwep)
159. struct monst *mtmp;
160. struct obj *otmp, *mwep;
161. {
162.     int skill = (int) objects[otmp->otyp].oc_skill;
163.     int multishot = 1;
164. 
165.     if (otmp->quan > 1L /* no point checking if there's only 1 */
166.         /* ammo requires corresponding launcher be wielded */
167.         && (is_ammo(otmp)
168.                ? matching_launcher(otmp, mwep)
169.                /* otherwise any stackable (non-ammo) weapon */
170.                : otmp->oclass == WEAPON_CLASS)
171.         && !mtmp->mconf) {
172.         /* Assumes lords are skilled, princes are expert */
173.         if (is_prince(mtmp->data))
174.             multishot += 2;
175.         else if (is_lord(mtmp->data))
176.             multishot++;
177.         /* fake players treated as skilled (regardless of role limits) */
178.         else if (is_mplayer(mtmp->data))
179.             multishot++;
180. 
181.         /* this portion is different from hero multishot; from slash'em?
182.          */
183.         /* Elven Craftsmanship makes for light, quick bows */
184.         if (otmp->otyp == ELVEN_ARROW && !otmp->cursed)
185.             multishot++;
186.         if (ammo_and_launcher(otmp, uwep) && mwep->otyp == ELVEN_BOW
187.             && !mwep->cursed)
188.             multishot++;
189.         /* 1/3 of launcher enchantment */
190.         if (ammo_and_launcher(otmp, mwep) && mwep->spe > 1)
191.             multishot += (long) rounddiv(mwep->spe, 3);
192.         /* Some randomness */
193.         multishot = (long) rnd((int) multishot);
194. 
195.         /* class bonus */
196.         switch (monsndx(mtmp->data)) {
197.         case PM_CAVEMAN: /* give bonus for low-tech gear */
198.             if (skill == -P_SLING || skill == P_SPEAR)
199.                 multishot++;
200.             break;
201.         case PM_MONK: /* allow higher volley count */
202.             if (skill == -P_SHURIKEN)
203.                 multishot++;
204.             break;
205.         case PM_RANGER:
206.             if (skill != P_DAGGER)
207.                 multishot++;
208.             break;
209.         case PM_ROGUE:
210.             if (skill == P_DAGGER)
211.                 multishot++;
212.             break;
213.         case PM_NINJA:
214.             if (skill == -P_SHURIKEN || skill == -P_DART)
215.                 multishot++;
216.             /*FALLTHRU*/
217.         case PM_SAMURAI:
218.             if (otmp->otyp == YA && mwep->otyp == YUMI)
219.                 multishot++;
220.             break;
221.         default:
222.             break;
223.         }
224.         /* racial bonus */
225.         if ((is_elf(mtmp->data) && otmp->otyp == ELVEN_ARROW
226.             && mwep->otyp == ELVEN_BOW)
227.             || (is_orc(mtmp->data) && otmp->otyp == ORCISH_ARROW
228.                 && mwep->otyp == ORCISH_BOW)
229.             || (is_gnome(mtmp->data) && otmp->otyp == CROSSBOW_BOLT
230.                 && mwep->otyp == CROSSBOW))
231.             multishot++;
232.     }
233. 
234.     if (otmp->quan < multishot)
235.         multishot = (int) otmp->quan;
236.     if (multishot < 1)
237.         multishot = 1;
238.     return multishot;
239. }
240. 
241. /* mtmp throws otmp, or shoots otmp with mwep, at hero or at monster mtarg */
242. STATIC_OVL void
243. monshoot(mtmp, otmp, mwep)
244. struct monst *mtmp;
245. struct obj *otmp, *mwep;
246. {
247.     struct monst *mtarg = target;
248.     int dm = distmin(mtmp->mx, mtmp->my,
249.                      mtarg ? mtarg->mx : mtmp->mux,
250.                      mtarg ? mtarg->my : mtmp->muy),
251.         multishot = monmulti(mtmp, otmp, mwep);
252.         /*
253.          * Caller must have called linedup() to set up tbx, tby.
254.          */
255. 
256.     if (canseemon(mtmp)) {
257.         const char *onm;
258.         char onmbuf[BUFSZ], trgbuf[BUFSZ];
259. 
260.         if (multishot > 1) {
261.             /* "N arrows"; multishot > 1 implies otmp->quan > 1, so
262.                xname()'s result will already be pluralized */
263.             Sprintf(onmbuf, "%d %s", multishot, xname(otmp));
264.             onm = onmbuf;
265.         } else {
266.             /* "an arrow" */
267.             onm = singular(otmp, xname);
268.             onm = obj_is_pname(otmp) ? the(onm) : an(onm);
269.         }
270.         m_shot.s = ammo_and_launcher(otmp, mwep) ? TRUE : FALSE;
271.         Strcpy(trgbuf, mtarg ? mon_nam(mtarg) : "");
272.         if (!strcmp(trgbuf, "it"))
273.             Strcpy(trgbuf, humanoid(mtmp->data) ? "someone" : something);
274.         pline("%s %s %s%s%s!", Monnam(mtmp),
275.               m_shot.s ? "shoots" : "throws", onm,
276.               mtarg ? " at " : "", trgbuf);
277.         m_shot.o = otmp->otyp;
278.     } else {
279.         m_shot.o = STRANGE_OBJECT; /* don't give multishot feedback */
280.     }
281.     m_shot.n = multishot;
282.     for (m_shot.i = 1; m_shot.i <= m_shot.n; m_shot.i++) {
283.         m_throw(mtmp, mtmp->mx, mtmp->my, sgn(tbx), sgn(tby), dm, otmp);
284.         /* conceptually all N missiles are in flight at once, but
285.            if mtmp gets killed (shot kills adjacent gas spore and
286.            triggers explosion, perhaps), inventory will be dropped
287.            and otmp might go away via merging into another stack */
288.         if (DEADMONSTER(mtmp) && m_shot.i < m_shot.n)
289.             /* cancel pending shots (perhaps ought to give a message here
290.                since we gave one above about throwing/shooting N missiles) */
291.             break; /* endmultishot(FALSE); */
292.     }
293.     /* reset 'm_shot' */
294.     m_shot.n = m_shot.i = 0;
295.     m_shot.o = STRANGE_OBJECT;
296.     m_shot.s = FALSE;
297. }
298. 
299. /* an object launched by someone/thing other than player attacks a monster;
300.    return 1 if the object has stopped moving (hit or its range used up) */
301. int
302. ohitmon(mtmp, otmp, range, verbose)
303. struct monst *mtmp; /* accidental target, located at <bhitpos.x,.y> */
304. struct obj *otmp;   /* missile; might be destroyed by drop_throw */
305. int range;          /* how much farther will object travel if it misses;
306.                        use -1 to signify to keep going even after hit,
307.                        unless it's gone (used for rolling_boulder_traps) */
308. boolean verbose;    /* give message(s) even when you can't see what happened */
309. {
310.     int damage, tmp;
311.     boolean vis, ismimic;
312.     int objgone = 1;
313.     struct obj *mon_launcher = archer ? MON_WEP(archer) : NULL;
314. 
315.     notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my);
316.     ismimic = M_AP_TYPE(mtmp) && M_AP_TYPE(mtmp) != M_AP_MONSTER;
317.     vis = cansee(bhitpos.x, bhitpos.y);
318. 
319.     tmp = 5 + find_mac(mtmp) + omon_adj(mtmp, otmp, FALSE);
320.     /* High level monsters will be more likely to hit */
321.     /* This check applies only if this monster is the target
322.      * the archer was aiming at. */
323.     if (archer && target == mtmp) {
324.         if (archer->m_lev > 5)
325.             tmp += archer->m_lev - 5;
326.         if (mon_launcher && mon_launcher->oartifact)
327.             tmp += spec_abon(mon_launcher, mtmp);
328.     }
329.     if (tmp < rnd(20)) {
330.         if (!ismimic) {
331.             if (vis)
332.                 miss(distant_name(otmp, mshot_xname), mtmp);
333.             else if (verbose && !target)
334.                 pline("It is missed.");
335.         }
336.         if (!range) { /* Last position; object drops */
337.             (void) drop_throw(otmp, 0, mtmp->mx, mtmp->my);
338.             return 1;
339.         }
340.     } else if (otmp->oclass == POTION_CLASS) {
341.         if (ismimic)
342.             seemimic(mtmp);
343.         mtmp->msleeping = 0;
344.         if (vis)
345.             otmp->dknown = 1;
346.         /* probably thrown by a monster rather than 'other', but the
347.            distinction only matters when hitting the hero */
348.         potionhit(mtmp, otmp, POTHIT_OTHER_THROW);
349.         return 1;
350.     } else {
351.         damage = dmgval(otmp, mtmp);
352.         if (otmp->otyp == ACID_VENOM && resists_acid(mtmp))
353.             damage = 0;
354.         if (ismimic)
355.             seemimic(mtmp);
356.         mtmp->msleeping = 0;
357.         if (vis) {
358.             if (otmp->otyp == EGG)
359.                 pline("Splat!  %s is hit with %s egg!", Monnam(mtmp),
360.                       otmp->known ? an(mons[otmp->corpsenm].mname) : "an");
361.             else
362.                 hit(distant_name(otmp, mshot_xname), mtmp, exclam(damage));
363.         } else if (verbose && !target)
364.             pline("%s%s is hit%s", (otmp->otyp == EGG) ? "Splat!  " : "",
365.                   Monnam(mtmp), exclam(damage));
366. 
367.         if (otmp->opoisoned && is_poisonable(otmp)) {
368.             if (resists_poison(mtmp)) {
369.                 if (vis)
370.                     pline_The("poison doesn't seem to affect %s.",
371.                               mon_nam(mtmp));
372.             } else {
373.                 if (rn2(30)) {
374.                     damage += rnd(6);
375.                 } else {
376.                     if (vis)
377.                         pline_The("poison was deadly...");
378.                     damage = mtmp->mhp;
379.                 }
380.             }
381.         }
382.         if (objects[otmp->otyp].oc_material == SILVER
383.             && mon_hates_silver(mtmp)) {
384.             if (vis)
385.                 pline_The("silver sears %s flesh!", s_suffix(mon_nam(mtmp)));
386.             else if (verbose && !target)
387.                 pline("Its flesh is seared!");
388.         }
389.         if (otmp->otyp == ACID_VENOM && cansee(mtmp->mx, mtmp->my)) {
390.             if (resists_acid(mtmp)) {
391.                 if (vis || (verbose && !target))
392.                     pline("%s is unaffected.", Monnam(mtmp));
393.             } else {
394.                 if (vis)
395.                     pline_The("%s burns %s!", hliquid("acid"), mon_nam(mtmp));
396.                 else if (verbose && !target)
397.                     pline("It is burned!");
398.             }
399.         }
400.         if (otmp->otyp == EGG && touch_petrifies(&mons[otmp->corpsenm])) {
401.             if (!munstone(mtmp, TRUE))
402.                 minstapetrify(mtmp, TRUE);
403.             if (resists_ston(mtmp))
404.                 damage = 0;
405.         }
406. 
407.         if (!DEADMONSTER(mtmp)) { /* might already be dead (if petrified) */
408.             mtmp->mhp -= damage;
409.             if (DEADMONSTER(mtmp)) {
410.                 if (vis || (verbose && !target))
411.                     pline("%s is %s!", Monnam(mtmp),
412.                           (nonliving(mtmp->data) || is_vampshifter(mtmp)
413.                            || !canspotmon(mtmp)) ? "destroyed" : "killed");
414.                 /* don't blame hero for unknown rolling boulder trap */
415.                 if (!context.mon_moving && (otmp->otyp != BOULDER
416.                                             || range >= 0 || otmp->otrapped))
417.                     xkilled(mtmp, XKILL_NOMSG);
418.                 else
419.                     mondied(mtmp);
420.             }
421.         }
422. 
423.         /* blinding venom and cream pie do 0 damage, but verify
424.            that the target is still alive anyway */
425.         if (!DEADMONSTER(mtmp)
426.             && can_blnd((struct monst *) 0, mtmp,
427.                         (uchar) ((otmp->otyp == BLINDING_VENOM) ? AT_SPIT
428.                                                                 : AT_WEAP),
429.                         otmp)) {
430.             if (vis && mtmp->mcansee)
431.                 pline("%s is blinded by %s.", Monnam(mtmp), the(xname(otmp)));
432.             mtmp->mcansee = 0;
433.             tmp = (int) mtmp->mblinded + rnd(25) + 20;
434.             if (tmp > 127)
435.                 tmp = 127;
436.             mtmp->mblinded = tmp;
437.         }
438. 
439.         objgone = drop_throw(otmp, 1, bhitpos.x, bhitpos.y);
440.         if (!objgone && range == -1) { /* special case */
441.             obj_extract_self(otmp);    /* free it for motion again */
442.             return 0;
443.         }
444.         return 1;
445.     }
446.     return 0;
447. }
448. 
449. #define MT_FLIGHTCHECK(pre)                                             \
450.     (/* missile hits edge of screen */                                  \
451.      !isok(bhitpos.x + dx, bhitpos.y + dy)                              \
452.      /* missile hits the wall */                                        \
453.      || IS_ROCK(levl[bhitpos.x + dx][bhitpos.y + dy].typ)               \
454.      /* missile hit closed door */                                      \
455.      || closed_door(bhitpos.x + dx, bhitpos.y + dy)                     \
456.      /* missile might hit iron bars */                                  \
457.      /* the random chance for small objects hitting bars is */          \
458.      /* skipped when reaching them at point blank range */              \
459.      || (levl[bhitpos.x + dx][bhitpos.y + dy].typ == IRONBARS           \
460.          && hits_bars(&singleobj,                                       \
461.                       bhitpos.x, bhitpos.y,                             \
462.                       bhitpos.x + dx, bhitpos.y + dy,                   \
463.                       ((pre) ? 0 : !rn2(5)), 0))                        \
464.      /* Thrown objects "sink" */                                        \
465.      || (!(pre) && IS_SINK(levl[bhitpos.x][bhitpos.y].typ)))
466. 
467. void
468. m_throw(mon, x, y, dx, dy, range, obj)
469. struct monst *mon;       /* launching monster */
470. int x, y, dx, dy, range; /* launch point, direction, and range */
471. struct obj *obj;         /* missile (or stack providing it) */
472. {
473.     struct monst *mtmp;
474.     struct obj *singleobj;
475.     char sym = obj->oclass;
476.     int hitu = 0, oldumort, blindinc = 0;
477. 
478.     bhitpos.x = x;
479.     bhitpos.y = y;
480.     notonhead = FALSE; /* reset potentially stale value */
481. 
482.     if (obj->quan == 1L) {
483.         /*
484.          * Remove object from minvent.  This cannot be done later on;
485.          * what if the player dies before then, leaving the monster
486.          * with 0 daggers?  (This caused the infamous 2^32-1 orcish
487.          * dagger bug).
488.          *
489.          * VENOM is not in minvent - it should already be OBJ_FREE.
490.          * The extract below does nothing.
491.          */
492. 
493.         /* not possibly_unwield, which checks the object's */
494.         /* location, not its existence */
495.         if (MON_WEP(mon) == obj)
496.             setmnotwielded(mon, obj);
497.         obj_extract_self(obj);
498.         singleobj = obj;
499.         obj = (struct obj *) 0;
500.     } else {
501.         singleobj = splitobj(obj, 1L);
502.         obj_extract_self(singleobj);
503.     }
504. 
505.     singleobj->owornmask = 0; /* threw one of multiple weapons in hand? */
506. 
507.     if ((singleobj->cursed || singleobj->greased) && (dx || dy) && !rn2(7)) {
508.         if (canseemon(mon) && flags.verbose) {
509.             if (is_ammo(singleobj))
510.                 pline("%s misfires!", Monnam(mon));
511.             else
512.                 pline("%s as %s throws it!", Tobjnam(singleobj, "slip"),
513.                       mon_nam(mon));
514.         }
515.         dx = rn2(3) - 1;
516.         dy = rn2(3) - 1;
517.         /* check validity of new direction */
518.         if (!dx && !dy) {
519.             (void) drop_throw(singleobj, 0, bhitpos.x, bhitpos.y);
520.             return;
521.         }
522.     }
523. 
524.     if (MT_FLIGHTCHECK(TRUE)) {
525.         (void) drop_throw(singleobj, 0, bhitpos.x, bhitpos.y);
526.         return;
527.     }
528.     mesg_given = 0; /* a 'missile misses' message has not yet been shown */
529. 
530.     /* Note: drop_throw may destroy singleobj.  Since obj must be destroyed
531.      * early to avoid the dagger bug, anyone who modifies this code should
532.      * be careful not to use either one after it's been freed.
533.      */
534.     if (sym)
535.         tmp_at(DISP_FLASH, obj_to_glyph(singleobj, rn2_on_display_rng));
536.     while (range-- > 0) { /* Actually the loop is always exited by break */
537.         bhitpos.x += dx;
538.         bhitpos.y += dy;
539.         if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != 0) {
540.             if (ohitmon(mtmp, singleobj, range, TRUE))
541.                 break;
542.         } else if (bhitpos.x == u.ux && bhitpos.y == u.uy) {
543.             if (multi)
544.                 nomul(0);
545. 
546.             if (singleobj->oclass == GEM_CLASS
547.                 && singleobj->otyp <= LAST_GEM + 9 /* 9 glass colors */
548.                 && is_unicorn(youmonst.data)) {
549.                 if (singleobj->otyp > LAST_GEM) {
550.                     You("catch the %s.", xname(singleobj));
551.                     You("are not interested in %s junk.",
552.                         s_suffix(mon_nam(mon)));
553.                     makeknown(singleobj->otyp);
554.                     dropy(singleobj);
555.                 } else {
556.                     You(
557.                      "accept %s gift in the spirit in which it was intended.",
558.                         s_suffix(mon_nam(mon)));
559.                     (void) hold_another_object(singleobj,
560.                                                "You catch, but drop, %s.",
561.                                                xname(singleobj),
562.                                                "You catch:");
563.                 }
564.                 break;
565.             }
566.             if (singleobj->oclass == POTION_CLASS) {
567.                 if (!Blind)
568.                     singleobj->dknown = 1;
569.                 potionhit(&youmonst, singleobj, POTHIT_MONST_THROW);
570.                 break;
571.             }
572.             oldumort = u.umortality;
573.             switch (singleobj->otyp) {
574.                 int dam, hitv;
575.             case EGG:
576.                 if (!touch_petrifies(&mons[singleobj->corpsenm])) {
577.                     impossible("monster throwing egg type %d",
578.                                singleobj->corpsenm);
579.                     hitu = 0;
580.                     break;
581.                 }
582.             /* fall through */
583.             case CREAM_PIE:
584.             case BLINDING_VENOM:
585.                 hitu = thitu(8, 0, &singleobj, (char *) 0);
586.                 break;
587.             default:
588.                 dam = dmgval(singleobj, &youmonst);
589.                 hitv = 3 - distmin(u.ux, u.uy, mon->mx, mon->my);
590.                 if (hitv < -4)
591.                     hitv = -4;
592.                 if (is_elf(mon->data)
593.                     && objects[singleobj->otyp].oc_skill == P_BOW) {
594.                     hitv++;
595.                     if (MON_WEP(mon) && MON_WEP(mon)->otyp == ELVEN_BOW)
596.                         hitv++;
597.                     if (singleobj->otyp == ELVEN_ARROW)
598.                         dam++;
599.                 }
600.                 if (bigmonst(youmonst.data))
601.                     hitv++;
602.                 hitv += 8 + singleobj->spe;
603.                 if (dam < 1)
604.                     dam = 1;
605.                 hitu = thitu(hitv, dam, &singleobj, (char *) 0);
606.             }
607.             if (hitu && singleobj->opoisoned && is_poisonable(singleobj)) {
608.                 char onmbuf[BUFSZ], knmbuf[BUFSZ];
609. 
610.                 Strcpy(onmbuf, xname(singleobj));
611.                 Strcpy(knmbuf, killer_xname(singleobj));
612.                 poisoned(onmbuf, A_STR, knmbuf,
613.                          /* if damage triggered life-saving,
614.                             poison is limited to attrib loss */
615.                          (u.umortality > oldumort) ? 0 : 10, TRUE);
616.             }
617.             if (hitu && can_blnd((struct monst *) 0, &youmonst,
618.                                  (uchar) ((singleobj->otyp == BLINDING_VENOM)
619.                                              ? AT_SPIT
620.                                              : AT_WEAP),
621.                                  singleobj)) {
622.                 blindinc = rnd(25);
623.                 if (singleobj->otyp == CREAM_PIE) {
624.                     if (!Blind)
625.                         pline("Yecch!  You've been creamed.");
626.                     else
627.                         pline("There's %s sticky all over your %s.",
628.                               something, body_part(FACE));
629.                 } else if (singleobj->otyp == BLINDING_VENOM) {
630.                     const char *eyes = body_part(EYE);
631. 
632.                     if (eyecount(youmonst.data) != 1)
633.                         eyes = makeplural(eyes);
634.                     /* venom in the eyes */
635.                     if (!Blind)
636.                         pline_The("venom blinds you.");
637.                     else
638.                         Your("%s %s.", eyes, vtense(eyes, "sting"));
639.                 }
640.             }
641.             if (hitu && singleobj->otyp == EGG) {
642.                 if (!Stoned && !Stone_resistance
643.                     && !(poly_when_stoned(youmonst.data)
644.                          && polymon(PM_STONE_GOLEM))) {
645.                     make_stoned(5L, (char *) 0, KILLED_BY, "");
646.                 }
647.             }
648.             stop_occupation();
649.             if (hitu) {
650.                 (void) drop_throw(singleobj, hitu, u.ux, u.uy);
651.                 break;
652.             }
653.         }
654.         if (!range /* reached end of path */
655.             || MT_FLIGHTCHECK(FALSE)) {
656.             if (singleobj) { /* hits_bars might have destroyed it */
657.                 if (m_shot.n > 1
658.                     && (!mesg_given || bhitpos.x != u.ux || bhitpos.y != u.uy)
659.                     && (cansee(bhitpos.x, bhitpos.y)
660.                         || (archer && canseemon(archer))))
661.                     pline("%s misses.", The(mshot_xname(singleobj)));
662.                 (void) drop_throw(singleobj, 0, bhitpos.x, bhitpos.y);
663.             }
664.             break;
665.         }
666.         tmp_at(bhitpos.x, bhitpos.y);
667.         delay_output();
668.     }
669.     tmp_at(bhitpos.x, bhitpos.y);
670.     delay_output();
671.     tmp_at(DISP_END, 0);
672.     mesg_given = 0; /* reset */
673. 
674.     if (blindinc) {
675.         u.ucreamed += blindinc;
676.         make_blinded(Blinded + (long) blindinc, FALSE);
677.         if (!Blind)
678.             Your1(vision_clears);
679.     }
680. }
681. 
682. #undef MT_FLIGHTCHECK
683. 
684. /* Monster throws item at another monster */
685. int
686. thrwmm(mtmp, mtarg)
687. struct monst *mtmp, *mtarg;
688. {
689.     struct obj *otmp, *mwep;
690.     register xchar x, y;
691.     boolean ispole;
692. 
693.     /* Polearms won't be applied by monsters against other monsters */
694.     if (mtmp->weapon_check == NEED_WEAPON || !MON_WEP(mtmp)) {
695.         mtmp->weapon_check = NEED_RANGED_WEAPON;
696.         /* mon_wield_item resets weapon_check as appropriate */
697.         if (mon_wield_item(mtmp) != 0)
698.             return 0;
699.     }
700. 
701.     /* Pick a weapon */
702.     otmp = select_rwep(mtmp);
703.     if (!otmp)
704.         return 0;
705.     ispole = is_pole(otmp);
706. 
707.     x = mtmp->mx;
708.     y = mtmp->my;
709. 
710.     mwep = MON_WEP(mtmp); /* wielded weapon */
711. 
712.     if (!ispole && m_lined_up(mtarg, mtmp)) {
713.         int chance = max(BOLT_LIM - distmin(x, y, mtarg->mx, mtarg->my), 1);
714. 
715.         if (!mtarg->mflee || !rn2(chance)) {
716.             if (ammo_and_launcher(otmp, mwep)
717.                 && dist2(mtmp->mx, mtmp->my, mtarg->mx, mtarg->my)
718.                    > PET_MISSILE_RANGE2)
719.                 return 0; /* Out of range */
720.             /* Set target monster */
721.             target = mtarg;
722.             archer = mtmp;
723.             monshoot(mtmp, otmp, mwep); /* multishot shooting or throwing */
724.             archer = target = (struct monst *) 0;
725.             nomul(0);
726.             return 1;
727.         }
728.     }
729.     return 0;
730. }
731. 
732. /* monster spits substance at monster */
733. int
734. spitmm(mtmp, mattk, mtarg)
735. struct monst *mtmp, *mtarg;
736. struct attack *mattk;
737. {
738.     struct obj *otmp;
739. 
740.     if (mtmp->mcan) {
741.         if (!Deaf)
742.             pline("A dry rattle comes from %s throat.",
743.                   s_suffix(mon_nam(mtmp)));
744.         return 0;
745.     }
746.     if (m_lined_up(mtarg, mtmp)) {
747.         switch (mattk->adtyp) {
748.         case AD_BLND:
749.         case AD_DRST:
750.             otmp = mksobj(BLINDING_VENOM, TRUE, FALSE);
751.             break;
752.         default:
753.             impossible("bad attack type in spitmu");
754.             /* fall through */
755.         case AD_ACID:
756.             otmp = mksobj(ACID_VENOM, TRUE, FALSE);
757.             break;
758.         }
759.         if (!rn2(BOLT_LIM-distmin(mtmp->mx,mtmp->my,mtarg->mx,mtarg->my))) {
760.             if (canseemon(mtmp))
761.                 pline("%s spits venom!", Monnam(mtmp));
762.             target = mtarg;
763.             m_throw(mtmp, mtmp->mx, mtmp->my, sgn(tbx), sgn(tby),
764.                     distmin(mtmp->mx,mtmp->my,mtarg->mx,mtarg->my), otmp);
765.             target = (struct monst *)0;
766.             nomul(0);
767. 
768.             /* If this is a pet, it'll get hungry. Minions and
769.              * spell beings won't hunger */
770.             if (mtmp->mtame && !mtmp->isminion) {
771.                 struct edog *dog = EDOG(mtmp);
772. 
773.                 /* Hunger effects will catch up next move */
774.                 if (dog->hungrytime > 1)
775.                     dog->hungrytime -= 5;
776.             }
777. 
778.             return 1;
779.         }
780.     }
781.     return 0;
782. }
783. 
784. /* monster breathes at monster (ranged) */
785. int
786. breamm(mtmp, mattk, mtarg)
787. struct monst *mtmp, *mtarg;
788. struct attack  *mattk;
789. {
790.     /* if new breath types are added, change AD_ACID to max type */
791.     int typ = (mattk->adtyp == AD_RBRE) ? rnd(AD_ACID) : mattk->adtyp ;
792. 
793.     if (m_lined_up(mtarg, mtmp)) {
794.         if (mtmp->mcan) {
795.             if (!Deaf) {
796.                 if (canseemon(mtmp))
797.                     pline("%s coughs.", Monnam(mtmp));
798.                 else
799.                     You_hear("a cough.");
800.             }
801.             return 0;
802.         }
803.         if (!mtmp->mspec_used && rn2(3)) {
804.             if ((typ >= AD_MAGM) && (typ <= AD_ACID)) {
805.                 if (canseemon(mtmp))
806.                     pline("%s breathes %s!", Monnam(mtmp), breathwep[typ - 1]);
807.                 dobuzz((int) (-20 - (typ - 1)), (int) mattk->damn,
808.                        mtmp->mx, mtmp->my, sgn(tbx), sgn(tby), FALSE);
809.                 nomul(0);
810.                 /* breath runs out sometimes. Also, give monster some
811.                  * cunning; don't breath if the target fell asleep.
812.                  */
813.                 mtmp->mspec_used = 6 + rn2(18);
814. 
815.                 /* If this is a pet, it'll get hungry. Minions and
816.                  * spell beings won't hunger */
817.                 if (mtmp->mtame && !mtmp->isminion) {
818.                     struct edog *dog = EDOG(mtmp);
819. 
820.                     /* Hunger effects will catch up next move */
821.                     if (dog->hungrytime >= 10)
822.                         dog->hungrytime -= 10;
823.                 }
824.             } else impossible("Breath weapon %d used", typ-1);
825.         } else
826.             return 0;
827.     }
828.     return 1;
829. }
830. 
831. 
832. 
833. /* remove an entire item from a monster's inventory; destroy that item */
834. void
835. m_useupall(mon, obj)
836. struct monst *mon;
837. struct obj *obj;
838. {
839.     obj_extract_self(obj);
840.     if (obj->owornmask) {
841.         if (obj == MON_WEP(mon))
842.             mwepgone(mon);
843.         mon->misc_worn_check &= ~obj->owornmask;
844.         update_mon_intrinsics(mon, obj, FALSE, FALSE);
845.         obj->owornmask = 0L;
846.     }
847.     obfree(obj, (struct obj *) 0);
848. }
849. 
850. /* remove one instance of an item from a monster's inventory */
851. void
852. m_useup(mon, obj)
853. struct monst *mon;
854. struct obj *obj;
855. {
856.     if (obj->quan > 1L) {
857.         obj->quan--;
858.         obj->owt = weight(obj);
859.     } else {
860.         m_useupall(mon, obj);
861.     }
862. }
863. 
864. /* monster attempts ranged weapon attack against player */
865. void
866. thrwmu(mtmp)
867. struct monst *mtmp;
868. {
869.     struct obj *otmp, *mwep;
870.     xchar x, y;
871.     const char *onm;
872. 
873.     /* Rearranged beginning so monsters can use polearms not in a line */
874.     if (mtmp->weapon_check == NEED_WEAPON || !MON_WEP(mtmp)) {
875.         mtmp->weapon_check = NEED_RANGED_WEAPON;
876.         /* mon_wield_item resets weapon_check as appropriate */
877.         if (mon_wield_item(mtmp) != 0)
878.             return;
879.     }
880. 
881.     /* Pick a weapon */
882.     otmp = select_rwep(mtmp);
883.     if (!otmp)
884.         return;
885. 
886.     if (is_pole(otmp)) {
887.         int dam, hitv;
888. 
889.         if (otmp != MON_WEP(mtmp))
890.             return; /* polearm must be wielded */
891.         if (dist2(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy) > POLE_LIM
892.             || !couldsee(mtmp->mx, mtmp->my))
893.             return; /* Out of range, or intervening wall */
894. 
895.         if (canseemon(mtmp)) {
896.             onm = xname(otmp);
897.             pline("%s thrusts %s.", Monnam(mtmp),
898.                   obj_is_pname(otmp) ? the(onm) : an(onm));
899.         }
900. 
901.         dam = dmgval(otmp, &youmonst);
902.         hitv = 3 - distmin(u.ux, u.uy, mtmp->mx, mtmp->my);
903.         if (hitv < -4)
904.             hitv = -4;
905.         if (bigmonst(youmonst.data))
906.             hitv++;
907.         hitv += 8 + otmp->spe;
908.         if (dam < 1)
909.             dam = 1;
910. 
911.         (void) thitu(hitv, dam, &otmp, (char *) 0);
912.         stop_occupation();
913.         return;
914.     }
915. 
916.     x = mtmp->mx;
917.     y = mtmp->my;
918.     /* If you are coming toward the monster, the monster
919.      * should try to soften you up with missiles.  If you are
920.      * going away, you are probably hurt or running.  Give
921.      * chase, but if you are getting too far away, throw.
922.      */
923.     if (!lined_up(mtmp)
924.         || (URETREATING(x, y)
925.             && rn2(BOLT_LIM - distmin(x, y, mtmp->mux, mtmp->muy))))
926.         return;
927. 
928.     mwep = MON_WEP(mtmp); /* wielded weapon */
929.     monshoot(mtmp, otmp, mwep); /* multishot shooting or throwing */
930.     nomul(0);
931. }
932. 
933. /* monster spits substance at you */
934. int
935. spitmu(mtmp, mattk)
936. struct monst *mtmp;
937. struct attack *mattk;
938. {
939.     struct obj *otmp;
940. 
941.     if (mtmp->mcan) {
942.         if (!Deaf)
943.             pline("A dry rattle comes from %s throat.",
944.                   s_suffix(mon_nam(mtmp)));
945.         return 0;
946.     }
947.     if (lined_up(mtmp)) {
948.         switch (mattk->adtyp) {
949.         case AD_BLND:
950.         case AD_DRST:
951.             otmp = mksobj(BLINDING_VENOM, TRUE, FALSE);
952.             break;
953.         default:
954.             impossible("bad attack type in spitmu");
955.         /* fall through */
956.         case AD_ACID:
957.             otmp = mksobj(ACID_VENOM, TRUE, FALSE);
958.             break;
959.         }
960.         if (!rn2(BOLT_LIM
961.                  - distmin(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy))) {
962.             if (canseemon(mtmp))
963.                 pline("%s spits venom!", Monnam(mtmp));
964.             m_throw(mtmp, mtmp->mx, mtmp->my, sgn(tbx), sgn(tby),
965.                     distmin(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy), otmp);
966.             nomul(0);
967.             return 0;
968.         } else {
969.             obj_extract_self(otmp);
970.             obfree(otmp, (struct obj *) 0);
971.         }
972.     }
973.     return 0;
974. }
975. 
976. /* monster breathes at you (ranged) */
977. int
978. breamu(mtmp, mattk)
979. struct monst *mtmp;
980. struct attack *mattk;
981. {
982.     /* if new breath types are added, change AD_ACID to max type */
983.     int typ = (mattk->adtyp == AD_RBRE) ? rnd(AD_ACID) : mattk->adtyp;
984. 
985.     if (lined_up(mtmp)) {
986.         if (mtmp->mcan) {
987.             if (!Deaf) {
988.                 if (canseemon(mtmp))
989.                     pline("%s coughs.", Monnam(mtmp));
990.                 else
991.                     You_hear("a cough.");
992.             }
993.             return 0;
994.         }
995.         if (!mtmp->mspec_used && rn2(3)) {
996.             if ((typ >= AD_MAGM) && (typ <= AD_ACID)) {
997.                 if (canseemon(mtmp))
998.                     pline("%s breathes %s!", Monnam(mtmp),
999.                           breathwep[typ - 1]);
1000.                 buzz((int) (-20 - (typ - 1)), (int) mattk->damn, mtmp->mx,
1001.                      mtmp->my, sgn(tbx), sgn(tby));
1002.                 nomul(0);
1003.                 /* breath runs out sometimes. Also, give monster some
1004.                  * cunning; don't breath if the player fell asleep.
1005.                  */
1006.                 if (!rn2(3))
1007.                     mtmp->mspec_used = 10 + rn2(20);
1008.                 if (typ == AD_SLEE && !Sleep_resistance)
1009.                     mtmp->mspec_used += rnd(20);
1010.             } else
1011.                 impossible("Breath weapon %d used", typ - 1);
1012.         }
1013.     }
1014.     return 1;
1015. }
1016. 
1017. boolean
1018. linedup(ax, ay, bx, by, boulderhandling)
1019. register xchar ax, ay, bx, by;
1020. int boulderhandling; /* 0=block, 1=ignore, 2=conditionally block */
1021. {
1022.     int dx, dy, boulderspots;
1023. 
1024.     /* These two values are set for use after successful return. */
1025.     tbx = ax - bx;
1026.     tby = ay - by;
1027. 
1028.     /* sometimes displacement makes a monster think that you're at its
1029.        own location; prevent it from throwing and zapping in that case */
1030.     if (!tbx && !tby)
1031.         return FALSE;
1032. 
1033.     if ((!tbx || !tby || abs(tbx) == abs(tby)) /* straight line or diagonal */
1034.         && distmin(tbx, tby, 0, 0) < BOLT_LIM) {
1035.         if ((ax == u.ux && ay == u.uy) ? (boolean) couldsee(bx, by)
1036.                                        : clear_path(ax, ay, bx, by))
1037.             return TRUE;
1038.         /* don't have line of sight, but might still be lined up
1039.            if that lack of sight is due solely to boulders */
1040.         if (boulderhandling == 0)
1041.             return FALSE;
1042.         dx = sgn(ax - bx), dy = sgn(ay - by);
1043.         boulderspots = 0;
1044.         do {
1045.             /* <bx,by> is guaranteed to eventually converge with <ax,ay> */
1046.             bx += dx, by += dy;
1047.             if (IS_ROCK(levl[bx][by].typ) || closed_door(bx, by))
1048.                 return FALSE;
1049.             if (sobj_at(BOULDER, bx, by))
1050.                 ++boulderspots;
1051.         } while (bx != ax || by != ay);
1052.         /* reached target position without encountering obstacle */
1053.         if (boulderhandling == 1 || rn2(2 + boulderspots) < 2)
1054.             return TRUE;
1055.     }
1056.     return FALSE;
1057. }
1058. 
1059. STATIC_OVL boolean
1060. m_lined_up(mtarg, mtmp)
1061. struct monst *mtarg, *mtmp;
1062. {
1063.     return (linedup(mtarg->mx, mtarg->my, mtmp->mx, mtmp->my, 0));
1064. }
1065. 
1066. 
1067. /* is mtmp in position to use ranged attack? */
1068. boolean
1069. lined_up(mtmp)
1070. register struct monst *mtmp;
1071. {
1072.     boolean ignore_boulders;
1073. 
1074.     /* hero concealment usually trumps monst awareness of being lined up */
1075.     if (Upolyd && rn2(25)
1076.         && (u.uundetected || (U_AP_TYPE != M_AP_NOTHING
1077.                               && U_AP_TYPE != M_AP_MONSTER)))
1078.         return FALSE;
1079. 
1080.     ignore_boulders = (throws_rocks(mtmp->data)
1081.                        || m_carrying(mtmp, WAN_STRIKING));
1082.     return linedup(mtmp->mux, mtmp->muy, mtmp->mx, mtmp->my,
1083.                    ignore_boulders ? 1 : 2);
1084. }
1085. 
1086. /* check if a monster is carrying a particular item */
1087. struct obj *
1088. m_carrying(mtmp, type)
1089. struct monst *mtmp;
1090. int type;
1091. {
1092.     register struct obj *otmp;
1093. 
1094.     for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
1095.         if (otmp->otyp == type)
1096.             return otmp;
1097.     return (struct obj *) 0;
1098. }
1099. 
1100. void
1101. hit_bars(objp, objx, objy, barsx, barsy, your_fault, from_invent)
1102. struct obj **objp;      /* *objp will be set to NULL if object breaks */
1103. int objx, objy, barsx, barsy;
1104. boolean your_fault, from_invent;
1105. {
1106.     struct obj *otmp = *objp;
1107.     int obj_type = otmp->otyp;
1108.     boolean unbreakable = (levl[barsx][barsy].wall_info & W_NONDIGGABLE) != 0;
1109. 
1110.     if (your_fault
1111.         ? hero_breaks(otmp, objx, objy, from_invent)
1112.         : breaks(otmp, objx, objy)) {
1113.         *objp = 0; /* object is now gone */
1114.         /* breakage makes its own noises */
1115.         if (obj_type == POT_ACID) {
1116.             if (cansee(barsx, barsy) && !unbreakable)
1117.                 pline_The("iron bars are dissolved!");
1118.             else
1119.                 You_hear(Hallucination ? "angry snakes!" : "a hissing noise.");
1120.             if (!unbreakable)
1121.                 dissolve_bars(barsx, barsy);
1122.         }
1123.     }
1124.     else if (obj_type == BOULDER || obj_type == HEAVY_IRON_BALL)
1125.         pline("Whang!");
1126.     else if (otmp->oclass == COIN_CLASS
1127.              || objects[obj_type].oc_material == GOLD
1128.              || objects[obj_type].oc_material == SILVER)
1129.         pline("Clink!");
1130.     else
1131.         pline("Clonk!");
1132. }
1133. 
1134. /* TRUE iff thrown/kicked/rolled object doesn't pass through iron bars */
1135. boolean
1136. hits_bars(obj_p, x, y, barsx, barsy, always_hit, whodidit)
1137. struct obj **obj_p; /* *obj_p will be set to NULL if object breaks */
1138. int x, y, barsx, barsy;
1139. int always_hit; /* caller can force a hit for items which would fit through */
1140. int whodidit;   /* 1==hero, 0=other, -1==just check whether it'll pass thru */
1141. {
1142.     struct obj *otmp = *obj_p;
1143.     int obj_type = otmp->otyp;
1144.     boolean hits = always_hit;
1145. 
1146.     if (!hits)
1147.         switch (otmp->oclass) {
1148.         case WEAPON_CLASS: {
1149.             int oskill = objects[obj_type].oc_skill;
1150. 
1151.             hits = (oskill != -P_BOW && oskill != -P_CROSSBOW
1152.                     && oskill != -P_DART && oskill != -P_SHURIKEN
1153.                     && oskill != P_SPEAR
1154.                     && oskill != P_KNIFE); /* but not dagger */
1155.             break;
1156.         }
1157.         case ARMOR_CLASS:
1158.             hits = (objects[obj_type].oc_armcat != ARM_GLOVES);
1159.             break;
1160.         case TOOL_CLASS:
1161.             hits = (obj_type != SKELETON_KEY && obj_type != LOCK_PICK
1162.                     && obj_type != CREDIT_CARD && obj_type != TALLOW_CANDLE
1163.                     && obj_type != WAX_CANDLE && obj_type != LENSES
1164.                     && obj_type != TIN_WHISTLE && obj_type != MAGIC_WHISTLE);
1165.             break;
1166.         case ROCK_CLASS: /* includes boulder */
1167.             if (obj_type != STATUE || mons[otmp->corpsenm].msize > MZ_TINY)
1168.                 hits = TRUE;
1169.             break;
1170.         case FOOD_CLASS:
1171.             if (obj_type == CORPSE && mons[otmp->corpsenm].msize > MZ_TINY)
1172.                 hits = TRUE;
1173.             else
1174.                 hits = (obj_type == MEAT_STICK
1175.                         || obj_type == HUGE_CHUNK_OF_MEAT);
1176.             break;
1177.         case SPBOOK_CLASS:
1178.         case WAND_CLASS:
1179.         case BALL_CLASS:
1180.         case CHAIN_CLASS:
1181.             hits = TRUE;
1182.             break;
1183.         default:
1184.             break;
1185.         }
1186. 
1187.     if (hits && whodidit != -1) {
1188.         hit_bars(obj_p, x,y, barsx,barsy, whodidit, FALSE);
1189.     }
1190. 
1191.     return hits;
1192. }
1193. 
1194. /*mthrowu.c*/