1 /* NetHack 3.6 mhitm.c $NHDT-Date: 1446854229 2015/11/06 23:57:09 $ $NHDT-Branch: master $:$NHDT-Revision: 1.83 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
5 /* JNetHack Copyright */
6 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000 */
7 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016 */
8 /* JNetHack may be freely redistributed. See license for details. */
13 extern boolean notonhead;
15 static NEARDATA boolean vis, far_noise;
16 static NEARDATA long noisetime;
17 static NEARDATA struct obj *otmp;
19 static const char brief_feeling[] =
21 "have a %s feeling for a moment, then it passes.";
23 "%s
\8bC
\8e\9d\82É
\82¨
\82»
\82í
\82ê
\82½
\82ª
\81C
\82·
\82®
\82É
\89ß
\82¬
\82³
\82Á
\82½
\81D";
25 STATIC_DCL char *FDECL(mon_nam_too, (char *, struct monst *, struct monst *));
26 STATIC_DCL int FDECL(hitmm, (struct monst *, struct monst *,
28 STATIC_DCL int FDECL(gazemm, (struct monst *, struct monst *,
30 STATIC_DCL int FDECL(gulpmm, (struct monst *, struct monst *,
32 STATIC_DCL int FDECL(explmm, (struct monst *, struct monst *,
34 STATIC_DCL int FDECL(mdamagem, (struct monst *, struct monst *,
36 STATIC_DCL void FDECL(mswingsm, (struct monst *, struct monst *,
38 STATIC_DCL void FDECL(noises, (struct monst *, struct attack *));
39 STATIC_DCL void FDECL(missmm, (struct monst *, struct monst *,
41 STATIC_DCL int FDECL(passivemm, (struct monst *, struct monst *,
44 /* Needed for the special case of monsters wielding vorpal blades (rare).
45 * If we use this a lot it should probably be a parameter to mdamagem()
46 * instead of a global variable.
50 /* returns mon_nam(mon) relative to other_mon; normal name unless they're
51 the same, in which case the reference is to {him|her|it} self */
53 mon_nam_too(outbuf, mon, other_mon)
55 struct monst *mon, *other_mon;
57 Strcpy(outbuf, mon_nam(mon));
60 switch (pronoun_gender(mon)) {
62 Strcpy(outbuf, "himself");
65 Strcpy(outbuf, "herself");
68 Strcpy(outbuf, "itself");
72 Strcpy(outbuf, "
\8e©
\95ª
\8e©
\90g");
79 register struct monst *magr;
80 register struct attack *mattk;
82 boolean farq = (distu(magr->mx, magr->my) > 15);
84 if (!Deaf && (farq != far_noise || moves - noisetime > 10)) {
89 (mattk->aatyp == AT_EXPL) ? "an explosion" : "some noises",
90 farq ? " in the distance" : "");
92 You_hear("%s%s
\82ð
\95·
\82¢
\82½
\81D",
93 farq ? "
\89\93\82
\82Å" : "",
94 (mattk->aatyp == AT_EXPL) ? "
\94\9a\94
\89¹" : "
\89½
\82©
\82ª
\90í
\82¤
\89¹"
102 missmm(magr, mdef, mattk)
103 register struct monst *magr, *mdef;
104 struct attack *mattk;
107 char buf[BUFSZ], mdef_name[BUFSZ];
110 if (!canspotmon(magr))
111 map_invisible(magr->mx, magr->my);
112 if (!canspotmon(mdef))
113 map_invisible(mdef->mx, mdef->my);
119 fmt = (could_seduce(magr, mdef, mattk) && !magr->mcan)
120 ? "%s pretends to be friendly to"
122 #else /*JP:
\89p
\8cê
\82Æ
\95Ï
\90\94\93W
\8aJ
\82Ì
\83^
\83C
\83~
\83\93\83O
\82ª
\88Ù
\82È
\82é
\82Ì
\82Å
\92\8d\88Ó*/
123 fmt = (could_seduce(magr,mdef,mattk) && !magr->mcan)
124 ? "%s
\82Í%%s
\82É
\97F
\8dD
\93I
\82È
\82Ó
\82è
\82ð
\82µ
\82½
\81D"
125 : "%s
\82Ì%%s
\82Ö
\82Ì
\8dU
\8c\82\82Í
\8aO
\82ê
\82½
\81D";
127 Sprintf(buf, fmt, Monnam(magr));
129 pline("%s %s.", buf, mon_nam_too(mdef_name, mdef, magr));
131 pline(buf, mon_nam_too(mdef_name, mdef, magr));
138 * fightm() -- fight some other monster
141 * 0 - Monster did nothing.
142 * 1 - If the monster made an attack. The monster might have died.
144 * There is an exception to the above. If mtmp has the hero swallowed,
145 * then we report that the monster did nothing so it will continue to
148 /* have monsters fight each other */
151 register struct monst *mtmp;
153 register struct monst *mon, *nmon;
154 int result, has_u_swallowed;
158 /* perhaps the monster will resist Conflict */
159 if (resist(mtmp, RING_CLASS, 0, 0))
162 if (u.ustuck == mtmp) {
163 /* perhaps we're holding it... */
167 has_u_swallowed = (u.uswallow && (mtmp == u.ustuck));
169 for (mon = fmon; mon; mon = nmon) {
173 /* Be careful to ignore monsters that are already dead, since we
174 * might be calling this before we've cleaned them up. This can
175 * happen if the monster attacked a cockatrice bare-handedly, for
178 if (mon != mtmp && !DEADMONSTER(mon)) {
179 if (monnear(mtmp, mon->mx, mon->my)) {
180 if (!u.uswallow && (mtmp == u.ustuck)) {
183 pline("%s releases you!", Monnam(mtmp));
185 pline("%s
\82Í
\82 \82È
\82½
\82ð
\89ð
\95ú
\82µ
\82½
\81I", Monnam(mtmp));
191 /* mtmp can be killed */
195 result = mattackm(mtmp, mon);
197 if (result & MM_AGR_DIED)
198 return 1; /* mtmp died */
200 * If mtmp has the hero swallowed, lie and say there
201 * was no attack (this allows mtmp to digest the hero).
206 /* Allow attacked monsters a chance to hit back. Primarily
207 * to allow monsters that resist conflict to respond.
209 if ((result & MM_HIT) && !(result & MM_DEF_DIED) && rn2(4)
210 && mon->movement >= NORMAL_SPEED) {
211 mon->movement -= NORMAL_SPEED;
213 (void) mattackm(mon, mtmp); /* return attack */
216 return (result & MM_HIT) ? 1 : 0;
224 * mdisplacem() -- attacker moves defender out of the way;
225 * returns same results as mattackm().
228 mdisplacem(magr, mdef, quietly)
229 register struct monst *magr, *mdef;
232 struct permonst *pa, *pd;
235 /* sanity checks; could matter if we unexpectedly get a long worm */
236 if (!magr || !mdef || magr == mdef)
238 pa = magr->data, pd = mdef->data;
239 tx = mdef->mx, ty = mdef->my; /* destination */
240 fx = magr->mx, fy = magr->my; /* current location */
241 if (m_at(fx, fy) != magr || m_at(tx, ty) != mdef)
244 /* The 1 in 7 failure below matches the chance in attack()
245 * for pet displacement.
250 /* Grid bugs cannot displace at an angle. */
251 if (pa == &mons[PM_GRID_BUG] && magr->mx != mdef->mx
252 && magr->my != mdef->my)
255 /* undetected monster becomes un-hidden if it is displaced */
256 if (mdef->mundetected)
257 mdef->mundetected = 0;
258 if (mdef->m_ap_type && mdef->m_ap_type != M_AP_MONSTER)
260 /* wake up the displaced defender */
262 mdef->mstrategy &= ~STRAT_WAITMASK;
263 finish_meating(mdef);
266 * Set up the visibility of action.
267 * You can observe monster displacement if you can see both of
268 * the monsters involved.
270 vis = (canspotmon(magr) && canspotmon(mdef));
272 if (touch_petrifies(pd) && !resists_ston(magr)) {
273 if (which_armor(magr, W_ARMG) != 0) {
274 if (poly_when_stoned(pa)) {
276 return MM_HIT; /* no damage during the polymorph */
278 if (!quietly && canspotmon(magr))
280 pline("%s turns to stone!", Monnam(magr));
282 pline("%s
\82Í
\90Î
\82É
\82È
\82Á
\82½
\81I", Monnam(magr));
285 return MM_HIT; /* lifesaved */
286 else if (magr->mtame && !vis)
288 You(brief_feeling, "peculiarly sad");
290 You(brief_feeling, "
\82à
\82Ì
\94ß
\82µ
\82¢");
295 remove_monster(fx, fy); /* pick up from orig position */
296 remove_monster(tx, ty);
297 place_monster(magr, tx, ty); /* put down at target spot */
298 place_monster(mdef, fx, fy);
301 pline("%s moves %s out of %s way!", Monnam(magr), mon_nam(mdef),
302 is_rider(pa) ? "the" : mhis(magr));
304 pline("%s
\82Í%s
\82ð
\89\9f\82µ
\82Ì
\82¯
\82½
\81I", Monnam(magr), mon_nam(mdef));
306 newsym(fx, fy); /* see it */
307 newsym(tx, ty); /* all happen */
308 flush_screen(0); /* make sure it shows up */
314 * mattackm() -- a monster attacks another monster.
316 * --------- aggressor died
317 * / ------- defender died
318 * / / ----- defender was hit
327 * Each successive attack has a lower probability of hitting. Some rely on
328 * success of previous attacks. ** this doen't seem to be implemented -dl **
330 * In the case of exploding monsters, the monster dies as well.
334 register struct monst *magr, *mdef;
336 int i, /* loop counter */
337 tmp, /* amour class difference */
338 strike, /* hit this attack */
339 attk, /* attack attempted this time */
340 struck = 0, /* hit at least once */
341 res[NATTK]; /* results of all attacks */
342 struct attack *mattk, alt_attk;
343 struct permonst *pa, *pd;
346 return MM_MISS; /* mike@genat */
347 if (!magr->mcanmove || magr->msleeping)
352 /* Grid bugs cannot attack at an angle. */
353 if (pa == &mons[PM_GRID_BUG] && magr->mx != mdef->mx
354 && magr->my != mdef->my)
357 /* Calculate the armour class differential. */
358 tmp = find_mac(mdef) + magr->m_lev;
359 if (mdef->mconf || !mdef->mcanmove || mdef->msleeping) {
364 /* undetect monsters become un-hidden if they are attacked */
365 if (mdef->mundetected) {
366 mdef->mundetected = 0;
367 newsym(mdef->mx, mdef->my);
368 if (canseemon(mdef) && !sensemon(mdef)) {
371 You("dream of %s.", (mdef->data->geno & G_UNIQ)
373 : makeplural(m_monnam(mdef)));
375 You("%s
\82Ì
\96²
\82ð
\8c©
\82½
\81D", a_monnam(mdef));
379 pline("Suddenly, you notice %s.", a_monnam(mdef));
381 pline("
\93Ë
\91R
\81C
\82 \82È
\82½
\82Í%s
\82É
\8bC
\82ª
\82Â
\82¢
\82½
\81D", a_monnam(mdef));
385 /* Elves hate orcs. */
386 if (is_elf(pa) && is_orc(pd))
389 /* Set up the visibility of action */
390 vis = (cansee(magr->mx, magr->my) && cansee(mdef->mx, mdef->my)
391 && (canspotmon(magr) || canspotmon(mdef)));
393 /* Set flag indicating monster has moved this turn. Necessary since a
394 * monster might get an attack out of sequence (i.e. before its move) in
395 * some cases, in which case this still counts as its move for the round
396 * and it shouldn't move again.
398 magr->mlstmv = monstermoves;
400 /* Now perform all attacks for the monster. */
401 for (i = 0; i < NATTK; i++) {
403 mattk = getmattk(pa, i, res, &alt_attk);
404 otmp = (struct obj *) 0;
406 switch (mattk->aatyp) {
407 case AT_WEAP: /* "hand to hand" attacks */
408 if (magr->weapon_check == NEED_WEAPON || !MON_WEP(magr)) {
409 magr->weapon_check = NEED_HTH_WEAPON;
410 if (mon_wield_item(magr) != 0)
413 possibly_unwield(magr, FALSE);
414 otmp = MON_WEP(magr);
418 mswingsm(magr, mdef, otmp);
419 tmp += hitval(otmp, mdef);
429 /* Nymph that teleported away on first attack? */
430 if (distmin(magr->mx, magr->my, mdef->mx, mdef->my) > 1)
432 /* Monsters won't attack cockatrices physically if they
433 * have a weapon instead. This instinct doesn't work for
434 * players, or under conflict or confusion.
436 if (!magr->mconf && !Conflict && otmp && mattk->aatyp != AT_WEAP
437 && touch_petrifies(mdef->data)) {
441 dieroll = rnd(20 + i);
442 strike = (tmp > dieroll);
443 /* KMH -- don't accumulate to-hit bonuses */
445 tmp -= hitval(otmp, mdef);
447 res[i] = hitmm(magr, mdef, mattk);
448 if ((mdef->data == &mons[PM_BLACK_PUDDING]
449 || mdef->data == &mons[PM_BROWN_PUDDING]) && otmp
450 && objects[otmp->otyp].oc_material == IRON
453 if (clone_mon(mdef, 0, 0)) {
457 Strcpy(buf, Monnam(mdef));
459 pline("%s divides as %s hits it!", buf,
462 pline("%s
\82Ì
\8dU
\8c\82\82Å%s
\82ª
\95ª
\97ô
\82µ
\82½
\81I",
469 missmm(magr, mdef, mattk);
472 case AT_HUGS: /* automatic if prev two attacks succeed */
473 strike = (i >= 2 && res[i - 1] == MM_HIT && res[i - 2] == MM_HIT);
475 res[i] = hitmm(magr, mdef, mattk);
481 res[i] = gazemm(magr, mdef, mattk);
485 res[i] = explmm(magr, mdef, mattk);
486 if (res[i] == MM_MISS) { /* cancelled--no attack */
490 strike = 1; /* automatic hit */
494 if (u.usteed && (mdef == u.usteed)) {
498 /* Engulfing attacks are directed at the hero if
501 if (u.uswallow && magr == u.ustuck)
504 if ((strike = (tmp > rnd(20 + i))))
505 res[i] = gulpmm(magr, mdef, mattk);
507 missmm(magr, mdef, mattk);
511 default: /* no attack */
517 if (attk && !(res[i] & MM_AGR_DIED))
518 res[i] = passivemm(magr, mdef, strike, res[i] & MM_DEF_DIED);
520 if (res[i] & MM_DEF_DIED)
523 if (res[i] & MM_AGR_DIED)
525 /* return if aggressor can no longer attack */
526 if (!magr->mcanmove || magr->msleeping)
529 struck = 1; /* at least one hit */
532 return (struck ? MM_HIT : MM_MISS);
535 /* Returns the result of mdamagem(). */
537 hitmm(magr, mdef, mattk)
538 register struct monst *magr, *mdef;
539 struct attack *mattk;
543 char buf[BUFSZ], mdef_name[BUFSZ];
545 if (!canspotmon(magr))
546 map_invisible(magr->mx, magr->my);
547 if (!canspotmon(mdef))
548 map_invisible(mdef->mx, mdef->my);
553 if ((compat = could_seduce(magr, mdef, mattk)) && !magr->mcan) {
555 Sprintf(buf, "%s %s", Monnam(magr),
556 mdef->mcansee ? "smiles at" : "talks to");
557 pline("%s %s %s.", buf, mon_nam(mdef),
558 compat == 2 ? "engagingly" : "seductively");
560 Sprintf(buf, "%s
\82Í%%s
\82É%%s%s
\81D", Monnam(magr),
561 mdef->mcansee ? "
\94÷
\8fÎ
\82Ý
\82©
\82¯
\82½" : "
\98b
\82µ
\82©
\82¯
\82½");
562 pline(buf, mon_nam(mdef),
563 compat == 2 ? "
\96£
\97Í
\93I
\82É" : "
\97U
\98f
\93I
\82É");
566 char magr_name[BUFSZ];
568 Strcpy(magr_name, Monnam(magr));
569 switch (mattk->aatyp) {
572 Sprintf(buf, "%s bites", magr_name);
574 Sprintf(buf,"%s
\82Í%%s
\82É
\8a\9a\82Ý
\82Â
\82¢
\82½
\81D", magr_name);
578 Sprintf(buf, "%s stings", magr_name);
580 Sprintf(buf,"%s
\82Í%%s
\82ð
\93Ë
\82«
\82³
\82µ
\82½
\81D", magr_name);
584 Sprintf(buf, "%s butts", magr_name);
586 Sprintf(buf,"%s
\82Í%%s
\82É
\93ª
\93Ë
\82«
\82ð
\82
\82ç
\82í
\82µ
\82½
\81D", magr_name);
590 Sprintf(buf, "%s touches", magr_name);
592 Sprintf(buf,"%s
\82Í%%s
\82É
\90G
\82ê
\82½
\81D", magr_name);
596 Sprintf(buf, "%s tentacles suck", s_suffix(magr_name));
598 Sprintf(buf, "%s
\82Ì
\90G
\8eè
\82ª%%s
\82Ì
\91Ì
\89t
\82ð
\8bz
\82¢
\82Æ
\82Á
\82½
\81D", s_suffix(magr_name));
601 if (magr != u.ustuck) {
603 Sprintf(buf, "%s squeezes", magr_name);
605 Sprintf(buf,"%s
\82Í%%s
\82ð
\8di
\82ß
\82½
\81D", magr_name);
610 Sprintf(buf, "%s hits", magr_name);
612 Sprintf(buf,"%s
\82Ì%%s
\82Ö
\82Ì
\8dU
\8c\82\82Í
\96½
\92\86\82µ
\82½
\81D", magr_name);
615 pline("%s %s.", buf, mon_nam_too(mdef_name, mdef, magr));
617 pline(buf, mon_nam_too(mdef_name, mdef, magr));
623 return mdamagem(magr, mdef, mattk);
626 /* Returns the same values as mdamagem(). */
628 gazemm(magr, mdef, mattk)
629 register struct monst *magr, *mdef;
630 struct attack *mattk;
636 Sprintf(buf, "%s gazes at", Monnam(magr));
637 pline("%s %s...", buf, mon_nam(mdef));
639 Sprintf(buf, "%s
\82Í%%s
\82ð
\82É
\82ç
\82Ý
\82Â
\82¯
\82½
\81D
\81D
\81D", Monnam(magr));
640 pline(buf, mon_nam(mdef));
644 if (magr->mcan || !magr->mcansee
645 || (magr->minvis && !perceives(mdef->data)) || !mdef->mcansee
646 || mdef->msleeping) {
649 pline("but nothing happens.");
651 pline("
\82µ
\82©
\82µ
\89½
\82à
\82¨
\82±
\82ç
\82È
\82©
\82Á
\82½
\81D");
654 /* call mon_reflects 2x, first test, then, if visible, print message */
655 if (magr->data == &mons[PM_MEDUSA] && mon_reflects(mdef, (char *) 0)) {
658 (void) mon_reflects(mdef, "The gaze is reflected away by %s %s.");
660 (void) mon_reflects(mdef, "
\82É
\82ç
\82Ý
\82Í%s
\82Ì%s
\82Å
\94½
\8eË
\82µ
\82½
\81D");
662 if (mon_reflects(magr, (char *) 0)) {
666 magr, "The gaze is reflected away by %s %s.");
668 magr, "
\82É
\82ç
\82Ý
\82Í%s
\82Ì%s
\82Å
\94½
\8eË
\82µ
\82½
\81D");
671 if (mdef->minvis && !perceives(magr->data)) {
672 if (canseemon(magr)) {
675 "%s doesn't seem to notice that %s gaze was reflected.",
676 Monnam(magr), mhis(magr));
678 pline("
\82É
\82ç
\82Ý
\82ª
\94½
\8eË
\82µ
\82Ä
\82¢
\82é
\82±
\82Æ
\82É%s
\82Í
\8bC
\95t
\82¢
\82Ä
\82¢
\82È
\82¢
\82æ
\82¤
\82¾
\81D",
686 pline("%s is turned to stone!", Monnam(magr));
688 pline("%s
\82Í
\90Î
\82É
\82È
\82Á
\82½
\81I", Monnam(magr));
696 return mdamagem(magr, mdef, mattk);
699 /* return True if magr is allowed to swallow mdef, False otherwise */
701 engulf_target(magr, mdef)
702 struct monst *magr, *mdef;
707 /* can't swallow something that's too big */
708 if (mdef->data->msize >= MZ_HUGE)
711 /* (hypothetical) engulfers who can pass through walls aren't
712 limited by rock|trees|bars */
713 if ((magr == &youmonst) ? Passes_walls : passes_walls(magr->data))
716 /* don't swallow something in a spot where attacker wouldn't
717 otherwise be able to move onto; we don't want to engulf
718 a wall-phaser and end up with a non-phaser inside a wall */
719 dx = mdef->mx, dy = mdef->my;
720 if (mdef == &youmonst)
721 dx = u.ux, dy = u.uy;
723 if (IS_ROCK(lev->typ) || closed_door(dx, dy) || IS_TREE(lev->typ)
724 /* not passes_bars(); engulfer isn't squeezing through */
725 || (lev->typ == IRONBARS && !is_whirly(magr->data)))
731 /* Returns the same values as mattackm(). */
733 gulpmm(magr, mdef, mattk)
734 register struct monst *magr, *mdef;
735 register struct attack *mattk;
737 xchar ax, ay, dx, dy;
742 if (!engulf_target(magr, mdef))
747 Sprintf(buf, "%s swallows", Monnam(magr));
748 pline("%s %s.", buf, mon_nam(mdef));
750 Sprintf(buf, "%s
\82Í%%s
\82ð
\82®
\82Á
\82Æ
\88ù
\82Ý
\82±
\82ñ
\82¾
\81D", Monnam(magr));
751 pline(buf, mon_nam(mdef));
754 for (obj = mdef->minvent; obj; obj = obj->nobj)
755 (void) snuff_lit(obj);
758 * All of this manipulation is needed to keep the display correct.
759 * There is a flush at the next pline().
766 * Leave the defender in the monster chain at it's current position,
767 * but don't leave it on the screen. Move the aggressor to the
768 * defender's position.
770 remove_monster(ax, ay);
771 place_monster(magr, dx, dy);
772 newsym(ax, ay); /* erase old position */
773 newsym(dx, dy); /* update new position */
775 status = mdamagem(magr, mdef, mattk);
777 if ((status & (MM_AGR_DIED | MM_DEF_DIED))
778 == (MM_AGR_DIED | MM_DEF_DIED)) {
779 ; /* both died -- do nothing */
780 } else if (status & MM_DEF_DIED) { /* defender died */
782 * Note: remove_monster() was called in relmon(), wiping out
783 * magr from level.monsters[mdef->mx][mdef->my]. We need to
784 * put it back and display it. -kd
786 place_monster(magr, dx, dy);
788 /* aggressor moves to <dx,dy> and might encounter trouble there */
789 if (minliquid(magr) || (t_at(dx, dy) && mintrap(magr) == 2))
790 status |= MM_AGR_DIED;
791 } else if (status & MM_AGR_DIED) { /* aggressor died */
792 place_monster(mdef, dx, dy);
794 } else { /* both alive, put them back */
797 pline("%s is regurgitated!", Monnam(mdef));
799 pline("%s
\82Í
\93f
\82«
\96ß
\82³
\82ê
\82½
\81I", Monnam(mdef));
801 place_monster(magr, ax, ay);
802 place_monster(mdef, dx, dy);
811 explmm(magr, mdef, mattk)
812 struct monst *magr, *mdef;
813 struct attack *mattk;
820 if (cansee(magr->mx, magr->my))
822 pline("%s explodes!", Monnam(magr));
824 pline("%s
\82Í
\94\9a\94
\82µ
\82½
\81I", Monnam(magr));
828 result = mdamagem(magr, mdef, mattk);
830 /* Kill off aggressor if it didn't die. */
831 if (!(result & MM_AGR_DIED)) {
834 return result; /* life saved */
835 result |= MM_AGR_DIED;
837 if (magr->mtame) /* give this one even if it was visible */
839 You(brief_feeling, "melancholy");
841 You(brief_feeling, "
\97J
\82¤
\82Â
\82È");
847 * See comment at top of mattackm(), for return values.
850 mdamagem(magr, mdef, mattk)
851 register struct monst *magr, *mdef;
852 register struct attack *mattk;
856 struct permonst *pa = magr->data, *pd = mdef->data;
857 int armpro, num, tmp = d((int) mattk->damn, (int) mattk->damd),
861 if ((touch_petrifies(pd) /* or flesh_petrifies() */
862 || (mattk->adtyp == AD_DGST && pd == &mons[PM_MEDUSA]))
863 && !resists_ston(magr)) {
864 long protector = attk_protection((int) mattk->aatyp),
865 wornitems = magr->misc_worn_check;
867 /* wielded weapon gives same protection as gloves here */
872 || (protector != ~0L && (wornitems & protector) != protector)) {
873 if (poly_when_stoned(pa)) {
875 return MM_HIT; /* no damage during the polymorph */
879 pline("%s turns to stone!", Monnam(magr));
881 pline("%s
\82Í
\90Î
\82É
\82È
\82Á
\82½
\81I", Monnam(magr));
884 return MM_HIT; /* lifesaved */
885 else if (magr->mtame && !vis)
887 You(brief_feeling, "peculiarly sad");
889 You(brief_feeling, "
\82à
\82Ì
\94ß
\82µ
\82¢");
894 /* cancellation factor is the same as when attacking the hero */
895 armpro = magic_negation(mdef);
896 cancelled = magr->mcan || !(rn2(10) >= 3 * armpro);
898 switch (mattk->adtyp) {
900 /* eating a Rider or its corpse is fatal */
904 pline("%s %s!", Monnam(magr),
905 (pd == &mons[PM_FAMINE])
906 ? "belches feebly, shrivels up and dies"
907 : (pd == &mons[PM_PESTILENCE])
908 ? "coughs spasmodically and collapses"
909 : "vomits violently and drops dead");
911 pline("%s%s
\81I", Monnam(magr),
912 (pd == &mons[PM_FAMINE])
913 ? "
\8eã
\81X
\82µ
\82
\93f
\82«
\82à
\82Ç
\82µ
\82½
\82©
\82Æ
\8ev
\82¤
\82Æ
\81C
\91Ì
\82ª
\82µ
\82Ú
\82Ý
\8e\80\82ñ
\82Å
\82µ
\82Ü
\82Á
\82½" :
914 pd == &mons[PM_PESTILENCE]
915 ? "áz
\9d¹
\82µ
\82½
\82æ
\82¤
\82É
\82¹
\82«
\82±
\82Ý
\93|
\82ê
\82½"
916 : "
\8c\83\82µ
\82
\9aq
\93f
\82µ
\8e\80\82ñ
\82¾");
920 return 0; /* lifesaved */
921 else if (magr->mtame && !vis)
923 You(brief_feeling, "queasy");
925 You(brief_feeling, "
\95s
\88À
\82È");
928 if (flags.verbose && !Deaf)
930 verbalize("Burrrrp!");
932 verbalize("
\82°
\82Á
\82Õ
\81I");
934 /* Use up amulet of life saving */
935 if (!!(obj = mlifesaver(mdef)))
938 /* Is a corpse for nutrition possible? It may kill magr */
939 if (!corpse_chance(mdef, magr, TRUE) || magr->mhp < 1)
942 /* Pets get nutrition from swallowing monster whole.
943 * No nutrition from G_NOCORPSE monster, eg, undead.
944 * DGST monsters don't die from undead corpses
947 if (magr->mtame && !magr->isminion
948 && !(mvitals[num].mvflags & G_NOCORPSE)) {
949 struct obj *virtualcorpse = mksobj(CORPSE, FALSE, FALSE);
952 set_corpsenm(virtualcorpse, num);
953 nutrit = dog_nutrition(magr, virtualcorpse);
954 dealloc_obj(virtualcorpse);
956 /* only 50% nutrition, 25% of normal eating time */
957 if (magr->meating > 1)
958 magr->meating = (magr->meating + 3) / 4;
961 EDOG(magr)->hungrytime += nutrit;
969 pline("%s %s for a moment.", Monnam(mdef),
970 makeplural(stagger(pd, "stagger")));
972 pline("%s
\82Í
\82·
\82±
\82µ
\82æ
\82ë
\82ß
\82¢
\82½
\81D", Monnam(mdef));
986 if (mattk->aatyp == AT_KICK && thick_skinned(pd)) {
988 } else if (mattk->aatyp == AT_WEAP) {
990 if (otmp->otyp == CORPSE
991 && touch_petrifies(&mons[otmp->corpsenm]))
993 tmp += dmgval(otmp, mdef);
994 if (otmp->oartifact) {
995 (void) artifact_hit(magr, mdef, otmp, &tmp, dieroll);
998 | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1003 } else if (pa == &mons[PM_PURPLE_WORM] && pd == &mons[PM_SHRIEKER]) {
1004 /* hack to enhance mm_aggression(); we don't want purple
1005 worm's bite attack to kill a shrieker because then it
1006 won't swallow the corpse; but if the target survives,
1007 the subsequent engulf attack should accomplish that */
1008 if (tmp >= mdef->mhp && mdef->mhp > 1)
1009 tmp = mdef->mhp - 1;
1019 pline("%s is %s!", Monnam(mdef), on_fire(pd, mattk));
1021 pline("%s
\82Í%s
\81I", Monnam(mdef), on_fire(pd, mattk));
1022 if (pd == &mons[PM_STRAW_GOLEM] || pd == &mons[PM_PAPER_GOLEM]) {
1025 pline("%s burns completely!", Monnam(mdef));
1027 pline("%s
\82Í
\8aD
\82É
\82È
\82Á
\82½
\81I", Monnam(mdef));
1031 else if (mdef->mtame && !vis)
1033 pline("May %s roast in peace.", mon_nam(mdef));
1035 pline("%s
\82æ
\81C
\88À
\82ç
\82©
\82É
\94R
\82¦
\82ñ
\8e\96\82ð
\81D", mon_nam(mdef));
1036 return (MM_DEF_DIED | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1038 tmp += destroy_mitem(mdef, SCROLL_CLASS, AD_FIRE);
1039 tmp += destroy_mitem(mdef, SPBOOK_CLASS, AD_FIRE);
1040 if (resists_fire(mdef)) {
1043 pline_The("fire doesn't seem to burn %s!", mon_nam(mdef));
1045 pline("%s
\82Í
\89\8a\82Å
\94R
\82¦
\82È
\82¢
\82æ
\82¤
\82¾
\81I", mon_nam(mdef));
1046 shieldeff(mdef->mx, mdef->my);
1047 golemeffects(mdef, AD_FIRE, tmp);
1050 /* only potions damage resistant players in destroy_item */
1051 tmp += destroy_mitem(mdef, POTION_CLASS, AD_FIRE);
1060 pline("%s is covered in frost!", Monnam(mdef));
1062 pline("%s
\82Í
\95X
\82Å
\95¢
\82í
\82ê
\82½
\81I", Monnam(mdef));
1063 if (resists_cold(mdef)) {
1066 pline_The("frost doesn't seem to chill %s!", mon_nam(mdef));
1068 pline("
\95X
\82Í%s
\82ð
\93\80\82ç
\82¹
\82é
\82±
\82Æ
\82ª
\82Å
\82«
\82È
\82¢
\82æ
\82¤
\82¾
\81I", mon_nam(mdef));
1069 shieldeff(mdef->mx, mdef->my);
1070 golemeffects(mdef, AD_COLD, tmp);
1073 tmp += destroy_mitem(mdef, POTION_CLASS, AD_COLD);
1082 pline("%s gets zapped!", Monnam(mdef));
1084 pline("%s
\82Í
\8fÕ
\8c\82\82ð
\82
\82ç
\82Á
\82½
\81I", Monnam(mdef));
1085 tmp += destroy_mitem(mdef, WAND_CLASS, AD_ELEC);
1086 if (resists_elec(mdef)) {
1089 pline_The("zap doesn't shock %s!", mon_nam(mdef));
1091 pline("
\8fÕ
\8c\82\82Í%s
\82É
\89e
\8b¿
\82ð
\97^
\82¦
\82È
\82¢
\81I", mon_nam(mdef));
1092 shieldeff(mdef->mx, mdef->my);
1093 golemeffects(mdef, AD_ELEC, tmp);
1096 /* only rings damage resistant players in destroy_item */
1097 tmp += destroy_mitem(mdef, RING_CLASS, AD_ELEC);
1104 if (resists_acid(mdef)) {
1107 pline("%s is covered in acid, but it seems harmless.",
1109 pline("%s
\82Í
\8e_
\82É
\82Â
\82Â
\82Ü
\82ê
\82½
\81D
\82µ
\82©
\82µ
\82È
\82ñ
\82Æ
\82à
\82È
\82¢
\82æ
\82¤
\82¾
\81D",
1114 pline("%s is covered in acid!", Monnam(mdef));
1116 pline("%s
\82Í
\8e_
\82É
\82Â
\82Â
\82Ü
\82ê
\82½
\81I", Monnam(mdef));
1118 pline("It burns %s!", mon_nam(mdef));
1120 pline("%s
\82Í
\8fÄ
\82©
\82ê
\82½
\81I", mon_nam(mdef));
1123 erode_armor(mdef, ERODE_CORRODE);
1125 acid_damage(MON_WEP(mdef));
1130 if (pd == &mons[PM_IRON_GOLEM]) {
1133 pline("%s falls to pieces!", Monnam(mdef));
1135 pline("%s
\82Í
\83o
\83\89\83o
\83\89\82É
\82È
\82Á
\82½
\81I", Monnam(mdef));
1139 else if (mdef->mtame && !vis)
1141 pline("May %s rust in peace.", mon_nam(mdef));
1143 pline("%s
\82æ
\81C
\88À
\82ç
\82©
\82É
\8eK
\82Ñ
\82ñ
\8e\96\82ð
\81D", mon_nam(mdef));
1144 return (MM_DEF_DIED | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1146 erode_armor(mdef, ERODE_RUST);
1147 mdef->mstrategy &= ~STRAT_WAITFORU;
1153 erode_armor(mdef, ERODE_CORRODE);
1154 mdef->mstrategy &= ~STRAT_WAITFORU;
1160 if (pd == &mons[PM_WOOD_GOLEM] || pd == &mons[PM_LEATHER_GOLEM]) {
1163 pline("%s falls to pieces!", Monnam(mdef));
1165 pline("%s
\82Í
\83o
\83\89\83o
\83\89\82É
\82È
\82Á
\82½
\81I", Monnam(mdef));
1169 else if (mdef->mtame && !vis)
1171 pline("May %s rot in peace.", mon_nam(mdef));
1173 pline("%s
\82æ
\81C
\88À
\82ç
\82©
\82É
\95\85\82ç
\82ñ
\8e\96\82ð
\81D", mon_nam(mdef));
1174 return (MM_DEF_DIED | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1176 erode_armor(mdef, ERODE_CORRODE);
1177 mdef->mstrategy &= ~STRAT_WAITFORU;
1184 /* may die from the acid if it eats a stone-curing corpse */
1185 if (munstone(mdef, FALSE))
1187 if (poly_when_stoned(pd)) {
1192 if (!resists_ston(mdef)) {
1195 pline("%s turns to stone!", Monnam(mdef));
1197 pline("%s
\82Í
\90Î
\82É
\82È
\82Á
\82½
\81I", Monnam(mdef));
1202 else if (mdef->mtame && !vis)
1204 You(brief_feeling, "peculiarly sad");
1206 You(brief_feeling, "
\82à
\82Ì
\94ß
\82µ
\82¢");
1207 return (MM_DEF_DIED | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1209 tmp = (mattk->adtyp == AD_STON ? 0 : 1);
1212 if (!cancelled && tmp < mdef->mhp && !tele_restrict(mdef)) {
1213 char mdef_Monnam[BUFSZ];
1214 /* save the name before monster teleports, otherwise
1215 we'll get "it" in the suddenly disappears message */
1217 Strcpy(mdef_Monnam, Monnam(mdef));
1218 mdef->mstrategy &= ~STRAT_WAITFORU;
1219 (void) rloc(mdef, TRUE);
1220 if (vis && !canspotmon(mdef) && mdef != u.usteed)
1222 pline("%s suddenly disappears!", mdef_Monnam);
1224 pline("%s
\82Í
\93Ë
\91R
\8fÁ
\82¦
\82½
\81I", mdef_Monnam);
1228 if (!cancelled && !mdef->msleeping
1229 && sleep_monst(mdef, rnd(10), -1)) {
1231 Strcpy(buf, Monnam(mdef));
1233 pline("%s is put to sleep by %s.", buf, mon_nam(magr));
1235 pline("%s
\82Í%s
\82É
\82æ
\82Á
\82Ä
\96°
\82ç
\82³
\82ê
\82½
\81D", buf, mon_nam(magr));
1237 mdef->mstrategy &= ~STRAT_WAITFORU;
1242 if (!cancelled && mdef->mcanmove) {
1244 Strcpy(buf, Monnam(mdef));
1246 pline("%s is frozen by %s.", buf, mon_nam(magr));
1248 pline("%s
\82Í%s
\82É
\82æ
\82Á
\82Ä
\93®
\82¯
\82È
\82
\82È
\82Á
\82½
\81D", buf, mon_nam(magr));
1250 paralyze_monst(mdef, rnd(10));
1254 if (!cancelled && mdef->mspeed != MSLOW) {
1255 unsigned int oldspeed = mdef->mspeed;
1257 mon_adjust_speed(mdef, -1, (struct obj *) 0);
1258 mdef->mstrategy &= ~STRAT_WAITFORU;
1259 if (mdef->mspeed != oldspeed && vis)
1261 pline("%s slows down.", Monnam(mdef));
1263 pline("%s
\82Í
\93®
\8dì
\82ª
\82Ì
\82ë
\82
\82È
\82Á
\82½
\81D", Monnam(mdef));
1267 /* Since confusing another monster doesn't have a real time
1268 * limit, setting spec_used would not really be right (though
1269 * we still should check for it).
1271 if (!magr->mcan && !mdef->mconf && !magr->mspec_used) {
1274 pline("%s looks confused.", Monnam(mdef));
1276 pline("%s
\82Í
\8d¬
\97\90\82µ
\82Ä
\82¢
\82é
\82æ
\82¤
\82É
\8c©
\82¦
\82é
\81D", Monnam(mdef));
1278 mdef->mstrategy &= ~STRAT_WAITFORU;
1282 if (can_blnd(magr, mdef, mattk->aatyp, (struct obj *) 0)) {
1283 register unsigned rnd_tmp;
1285 if (vis && mdef->mcansee)
1287 pline("%s is blinded.", Monnam(mdef));
1289 pline("%s
\82Í
\96Ú
\82ª
\8c©
\82¦
\82È
\82
\82È
\82Á
\82½
\81D", Monnam(mdef));
1290 rnd_tmp = d((int) mattk->damn, (int) mattk->damd);
1291 if ((rnd_tmp += mdef->mblinded) > 127)
1293 mdef->mblinded = rnd_tmp;
1295 mdef->mstrategy &= ~STRAT_WAITFORU;
1300 if (!magr->mcan && haseyes(pd) && mdef->mcansee) {
1303 pline("%s looks %sconfused.", Monnam(mdef),
1304 mdef->mconf ? "more " : "");
1306 pline("%s
\82Í%s
\8d¬
\97\90\82µ
\82Ä
\82¢
\82é
\82æ
\82¤
\82É
\8c©
\82¦
\82é
\81D", Monnam(mdef),
1307 mdef->mconf ? "
\82Ü
\82·
\82Ü
\82·" : "");
1310 mdef->mstrategy &= ~STRAT_WAITFORU;
1315 if (!night() && (pa == &mons[PM_GREMLIN]))
1317 if (!magr->mcan && !rn2(10)) {
1318 mdef->mcan = 1; /* cancelled regardless of lifesave */
1319 mdef->mstrategy &= ~STRAT_WAITFORU;
1320 if (is_were(pd) && pd->mlet != S_HUMAN)
1322 if (pd == &mons[PM_CLAY_GOLEM]) {
1325 pline("Some writing vanishes from %s head!",
1327 pline("
\82¢
\82
\82Â
\82©
\82Ì
\95¶
\8e\9a\82ª%s
\82Ì
\93ª
\82©
\82ç
\8fÁ
\82¦
\82½
\81I",
1328 s_suffix(mon_nam(mdef)));
1330 pline("%s is destroyed!", Monnam(mdef));
1332 pline("%s
\82Í
\94j
\89ó
\82³
\82ê
\82½
\81I", Monnam(mdef));
1337 else if (mdef->mtame && !vis)
1339 You(brief_feeling, "strangely sad");
1341 You(brief_feeling, "
\96
\82É
\94ß
\82µ
\82¢");
1343 | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1348 You_hear("laughter.");
1350 You_hear("
\8fÎ
\82¢
\90º
\82ð
\95·
\82¢
\82½
\81D");
1353 pline("%s chuckles.", Monnam(magr));
1355 pline("%s
\82Í
\82
\82·
\82
\82·
\8fÎ
\82Á
\82½
\81D", Monnam(magr));
1363 /* technically incorrect; no check for stealing gold from
1364 * between mdef's feet...
1367 struct obj *gold = findgold(mdef->minvent);
1370 obj_extract_self(gold);
1371 add_to_minv(magr, gold);
1373 mdef->mstrategy &= ~STRAT_WAITFORU;
1375 Strcpy(buf, Monnam(magr));
1377 pline("%s steals some gold from %s.", buf, mon_nam(mdef));
1379 pline("%s
\82Í%s
\82©
\82ç
\8bà
\82ð
\93\90\82ñ
\82¾
\81D", buf, mon_nam(mdef));
1381 if (!tele_restrict(magr)) {
1382 (void) rloc(magr, TRUE);
1383 if (vis && !canspotmon(magr))
1385 pline("%s suddenly disappears!", buf);
1387 pline("%s
\82Í
\93Ë
\91R
\8fÁ
\82¦
\82½
\81I", buf);
1391 if (!cancelled && !rn2(3) && !resists_drli(mdef)) {
1395 pline("%s suddenly seems weaker!", Monnam(mdef));
1397 pline("%s
\82Í
\93Ë
\91R
\8eã
\82
\82È
\82Á
\82½
\82æ
\82¤
\82É
\8c©
\82¦
\82½
\81I", Monnam(mdef));
1398 mdef->mhpmax -= tmp;
1399 if (mdef->m_lev == 0)
1403 /* Automatic kill if drained past level 0 */
1407 case AD_SITM: /* for now these are the same */
1411 /* find an object to steal, non-cursed if magr is tame */
1412 for (obj = mdef->minvent; obj; obj = obj->nobj)
1413 if (!magr->mtame || !obj->cursed)
1417 char onambuf[BUFSZ], mdefnambuf[BUFSZ];
1419 /* make a special x_monnam() call that never omits
1420 the saddle, and save it for later messages */
1422 x_monnam(mdef, ARTICLE_THE, (char *) 0, 0, FALSE));
1425 if (u.usteed == mdef && otmp == which_armor(mdef, W_SADDLE))
1426 /* "You can no longer ride <steed>." */
1427 dismount_steed(DISMOUNT_POLY);
1428 obj_extract_self(otmp);
1429 if (otmp->owornmask) {
1430 mdef->misc_worn_check &= ~otmp->owornmask;
1431 if (otmp->owornmask & W_WEP)
1433 otmp->owornmask = 0L;
1434 update_mon_intrinsics(mdef, otmp, FALSE, FALSE);
1436 /* add_to_minv() might free otmp [if it merges] */
1438 Strcpy(onambuf, doname(otmp));
1439 (void) add_to_minv(magr, otmp);
1441 Strcpy(buf, Monnam(magr));
1443 pline("%s steals %s from %s!", buf, onambuf, mdefnambuf);
1445 pline("%s
\82Í%s
\82©
\82ç%s
\82ð
\93\90\82ñ
\82¾
\81I", buf, mdefnambuf, onambuf);
1447 possibly_unwield(mdef, FALSE);
1448 mdef->mstrategy &= ~STRAT_WAITFORU;
1449 mselftouch(mdef, (const char *) 0, FALSE);
1452 | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1453 if (pa->mlet == S_NYMPH && !tele_restrict(magr)) {
1454 (void) rloc(magr, TRUE);
1455 if (vis && !canspotmon(magr))
1457 pline("%s suddenly disappears!", buf);
1459 pline("%s
\82Í
\93Ë
\91R
\8fÁ
\82¦
\82½
\81I", buf);
1465 if (!cancelled && !rn2(4))
1466 xdrainenergym(mdef, vis && mattk->aatyp != AT_ENGL);
1472 if (!cancelled && !rn2(8)) {
1475 pline("%s %s was poisoned!", s_suffix(Monnam(magr)),
1476 mpoisons_subj(magr, mattk));
1478 pline("%s
\82Ì%s
\82Í
\93Å
\82³
\82ê
\82Ä
\82¢
\82é
\81I", Monnam(magr),
1479 mpoisons_subj(magr, mattk));
1481 if (resists_poison(mdef)) {
1484 pline_The("poison doesn't seem to affect %s.",
1486 pline("%s
\82Í
\93Å
\82Ì
\89e
\8b¿
\82ð
\8eó
\82¯
\82È
\82¢
\81D",
1494 pline_The("poison was deadly...");
1496 pline("
\93Å
\82Í
\92v
\8e\80\97Ê
\82¾
\82Á
\82½
\81D
\81D
\81D");
1503 if (notonhead || !has_head(pd)) {
1506 pline("%s doesn't seem harmed.", Monnam(mdef));
1508 pline("%s
\82Í
\8f\9d\82Â
\82¢
\82½
\82æ
\82¤
\82É
\82Í
\8c©
\82¦
\82È
\82¢
\81D", Monnam(mdef));
1509 /* Not clear what to do for green slimes */
1513 if ((mdef->misc_worn_check & W_ARMH) && rn2(8)) {
1515 Strcpy(buf, s_suffix(Monnam(mdef)));
1517 pline("%s helmet blocks %s attack to %s head.", buf,
1518 s_suffix(mon_nam(magr)), mhis(mdef));
1520 pline("%s
\82Ì
\8a\95\82Í%s
\82Ì
\93ª
\82Ö
\82Ì
\8dU
\8c\82\82ð
\96h
\82¢
\82¾
\81D", buf,
1526 res = eat_brains(magr, mdef, vis, &tmp);
1530 break; /* physical damage only */
1531 if (!rn2(4) && !slimeproof(pd)) {
1532 if (!munslime(mdef, FALSE) && mdef->mhp > 0) {
1533 if (newcham(mdef, &mons[PM_GREEN_SLIME], FALSE, vis))
1535 mdef->mstrategy &= ~STRAT_WAITFORU;
1538 /* munslime attempt could have been fatal,
1539 potentially to multiple monsters (SCR_FIRE) */
1551 case AD_WRAP: /* monsters cannot grab one another, it's too hard */
1556 /* there's no msomearmor() function, so just do damage */
1557 /* if (cancelled) break; */
1566 if ((mdef->mhp -= tmp) < 1) {
1567 if (m_at(mdef->mx, mdef->my) == magr) { /* see gulpmm() */
1568 remove_monster(mdef->mx, mdef->my);
1569 mdef->mhp = 1; /* otherwise place_monster will complain */
1570 place_monster(mdef, mdef->mx, mdef->my);
1573 monkilled(mdef, "", (int) mattk->adtyp);
1575 return res; /* mdef lifesaved */
1576 else if (res == MM_AGR_DIED)
1577 return (MM_DEF_DIED | MM_AGR_DIED);
1579 if (mattk->adtyp == AD_DGST) {
1580 /* various checks similar to dog_eat and meatobj.
1581 * after monkilled() to provide better message ordering */
1582 if (mdef->cham >= LOW_PM) {
1583 (void) newcham(magr, (struct permonst *) 0, FALSE, TRUE);
1584 } else if (pd == &mons[PM_GREEN_SLIME] && !slimeproof(pa)) {
1585 (void) newcham(magr, &mons[PM_GREEN_SLIME], FALSE, TRUE);
1586 } else if (pd == &mons[PM_WRAITH]) {
1587 (void) grow_up(magr, (struct monst *) 0);
1588 /* don't grow up twice */
1589 return (MM_DEF_DIED | (magr->mhp > 0 ? 0 : MM_AGR_DIED));
1590 } else if (pd == &mons[PM_NURSE]) {
1591 magr->mhp = magr->mhpmax;
1594 /* caveat: above digestion handling doesn't keep `pa' up to date */
1596 return (MM_DEF_DIED | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1598 return (res == MM_AGR_DIED) ? MM_AGR_DIED : MM_HIT;
1602 paralyze_monst(mon, amt)
1611 mon->meating = 0; /* terminate any meal-in-progress */
1612 mon->mstrategy &= ~STRAT_WAITFORU;
1615 /* `mon' is hit by a sleep attack; return 1 if it's affected, 0 otherwise */
1617 sleep_monst(mon, amt, how)
1621 if (resists_sleep(mon)
1622 || (how >= 0 && resist(mon, (char) how, 0, NOTELL))) {
1623 shieldeff(mon->mx, mon->my);
1624 } else if (mon->mcanmove) {
1625 finish_meating(mon); /* terminate any meal-in-progress */
1626 amt += (int) mon->mfrozen;
1627 if (amt > 0) { /* sleep for N turns */
1629 mon->mfrozen = min(amt, 127);
1630 } else { /* sleep until awakened */
1638 /* sleeping grabber releases, engulfer doesn't; don't use for paralysis! */
1643 if ((mon->msleeping || !mon->mcanmove) && mon == u.ustuck
1644 && !sticks(youmonst.data) && !u.uswallow) {
1646 pline("%s grip relaxes.", s_suffix(Monnam(mon)));
1648 pline("%s
\82Ì
\88¬
\82é
\97Í
\82ª
\8eã
\82
\82È
\82Á
\82½
\81D", Monnam(mon));
1661 return; /* just in case */
1662 /* AD_ACID is handled in passivemm */
1663 if (dmgtype(mdef->data, AD_CORR))
1664 dmgtyp = ERODE_CORRODE;
1665 else if (dmgtype(mdef->data, AD_RUST))
1666 dmgtyp = ERODE_RUST;
1667 else if (dmgtype(mdef->data, AD_FIRE))
1668 dmgtyp = ERODE_BURN;
1671 (void) erode_obj(obj, NULL, dmgtyp, EF_GREASE | EF_VERBOSE);
1675 mswingsm(magr, mdef, otemp)
1676 struct monst *magr, *mdef;
1679 if (flags.verbose && !Blind && mon_visible(magr)) {
1681 pline("%s %s %s%s %s at %s.", Monnam(magr),
1682 (objects[otemp->otyp].oc_dir & PIERCE) ? "thrusts" : "swings",
1683 (otemp->quan > 1L) ? "one of " : "", mhis(magr), xname(otemp),
1686 pline((objects[otemp->otyp].oc_dir & PIERCE) ?
1687 "%s
\82Í%s
\82Å%s
\82ð
\93Ë
\82¢
\82½
\81D" :
1688 "%s
\82Í%s
\82ð
\90U
\82è
\82Ü
\82í
\82µ%s
\82ð
\8dU
\8c\82\82µ
\82½
\81D", Monnam(magr),
1689 xname(otemp), mon_nam(mdef));
1695 * Passive responses by defenders. Does not replicate responses already
1696 * handled above. Returns same values as mattackm.
1699 passivemm(magr, mdef, mhit, mdead)
1700 register struct monst *magr, *mdef;
1704 register struct permonst *mddat = mdef->data;
1705 register struct permonst *madat = magr->data;
1711 return (mdead | mhit); /* no passive attacks */
1712 if (mddat->mattk[i].aatyp == AT_NONE)
1715 if (mddat->mattk[i].damn)
1716 tmp = d((int) mddat->mattk[i].damn, (int) mddat->mattk[i].damd);
1717 else if (mddat->mattk[i].damd)
1718 tmp = d((int) mddat->mlevel + 1, (int) mddat->mattk[i].damd);
1722 /* These affect the enemy even if defender killed */
1723 switch (mddat->mattk[i].adtyp) {
1725 if (mhit && !rn2(2)) {
1726 Strcpy(buf, Monnam(magr));
1727 if (canseemon(magr))
1729 pline("%s is splashed by %s acid!", buf,
1730 s_suffix(mon_nam(mdef)));
1732 pline("%s
\82Í%s
\82Ì
\8e_
\82ð
\97\81\82Ñ
\82½
\81I", buf,
1735 if (resists_acid(magr)) {
1736 if (canseemon(magr))
1738 pline("%s is not affected.", Monnam(magr));
1740 pline("%s
\82Í
\89e
\8b¿
\82ð
\8eó
\82¯
\82È
\82¢
\81D", Monnam(magr));
1746 erode_armor(magr, ERODE_CORRODE);
1748 acid_damage(MON_WEP(magr));
1750 case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
1751 if (mhit && !mdef->mcan && otmp) {
1752 (void) drain_item(otmp);
1759 if (mdead || mdef->mcan)
1760 return (mdead | mhit);
1762 /* These affect the enemy only if defender is still alive */
1764 switch (mddat->mattk[i].adtyp) {
1765 case AD_PLYS: /* Floating eye */
1768 if (mddat == &mons[PM_FLOATING_EYE]) {
1771 if (magr->mcansee && haseyes(madat) && mdef->mcansee
1772 && (perceives(madat) || !mdef->minvis)) {
1774 Sprintf(buf, "%s gaze is reflected by %%s %%s.",
1776 Sprintf(buf, "%s
\82Ì
\82É
\82ç
\82Ý
\82Í%%s
\82É
\82æ
\82Á
\82Ä%%s
\81D",
1777 s_suffix(Monnam(mdef)));
1778 if (mon_reflects(magr,
1779 canseemon(magr) ? buf : (char *) 0))
1780 return (mdead | mhit);
1781 Strcpy(buf, Monnam(magr));
1782 if (canseemon(magr))
1784 pline("%s is frozen by %s gaze!", buf,
1785 s_suffix(mon_nam(mdef)));
1787 pline("%s
\82Í%s
\82Ì
\82É
\82ç
\82Ý
\82Å
\93®
\82¯
\82È
\82
\82È
\82Á
\82½
\81I", buf,
1790 paralyze_monst(magr, tmp);
1791 return (mdead | mhit);
1793 } else { /* gelatinous cube */
1794 Strcpy(buf, Monnam(magr));
1795 if (canseemon(magr))
1797 pline("%s is frozen by %s.", buf, mon_nam(mdef));
1799 pline("%s
\82Í%s
\82É
\82æ
\82Á
\82Ä
\93®
\82¯
\82È
\82
\82È
\82Á
\82½
\81D", buf, mon_nam(mdef));
1800 paralyze_monst(magr, tmp);
1801 return (mdead | mhit);
1805 if (resists_cold(magr)) {
1806 if (canseemon(magr)) {
1808 pline("%s is mildly chilly.", Monnam(magr));
1810 pline("%s
\82Í
\97â
\82¦
\82½
\81D", Monnam(magr));
1811 golemeffects(magr, AD_COLD, tmp);
1816 if (canseemon(magr))
1818 pline("%s is suddenly very cold!", Monnam(magr));
1820 pline("%s
\82Í
\93Ë
\91R
\93\80\82è
\82Ã
\82¯
\82É
\82È
\82Á
\82½
\81I", Monnam(magr));
1821 mdef->mhp += tmp / 2;
1822 if (mdef->mhpmax < mdef->mhp)
1823 mdef->mhpmax = mdef->mhp;
1824 if (mdef->mhpmax > ((int) (mdef->m_lev + 1) * 8))
1825 (void) split_mon(mdef, magr);
1830 if (canseemon(magr))
1832 pline("%s %s...", Monnam(magr),
1833 makeplural(stagger(magr->data, "stagger")));
1835 pline("%s
\82Í
\82
\82ç
\82
\82ç
\82µ
\82½
\81D
\81D
\81D", Monnam(magr));
1841 if (resists_fire(magr)) {
1842 if (canseemon(magr)) {
1844 pline("%s is mildly warmed.", Monnam(magr));
1846 pline("%s
\82Í
\92g
\82©
\82
\82È
\82Á
\82½
\81D", Monnam(magr));
1847 golemeffects(magr, AD_FIRE, tmp);
1852 if (canseemon(magr))
1854 pline("%s is suddenly very hot!", Monnam(magr));
1856 pline("%s
\82Í
\93Ë
\91R
\82Æ
\82Ä
\82à
\94M
\82
\82È
\82Á
\82½
\81I", Monnam(magr));
1859 if (resists_elec(magr)) {
1860 if (canseemon(magr)) {
1862 pline("%s is mildly tingled.", Monnam(magr));
1864 pline("%s
\82Í
\83s
\83\8a\83s
\83\8a\82µ
\82Ä
\82¢
\82é
\81D", Monnam(magr));
1865 golemeffects(magr, AD_ELEC, tmp);
1870 if (canseemon(magr))
1872 pline("%s is jolted with electricity!", Monnam(magr));
1874 pline("%s
\82Í
\93d
\8bC
\83V
\83\87\83b
\83N
\82ð
\82¤
\82¯
\82½
\81I", Monnam(magr));
1884 if ((magr->mhp -= tmp) <= 0) {
1885 monkilled(magr, "", (int) mddat->mattk[i].adtyp);
1886 return (mdead | mhit | MM_AGR_DIED);
1888 return (mdead | mhit);
1891 /* hero or monster has successfully hit target mon with drain energy attack */
1893 xdrainenergym(mon, givemsg)
1897 if (mon->mspec_used < 20 /* limit draining */
1898 && (attacktype(mon->data, AT_MAGC)
1899 || attacktype(mon->data, AT_BREA))) {
1900 mon->mspec_used += d(2, 2);
1903 pline("%s seems lethargic.", Monnam(mon));
1905 pline("%s
\82Í
\96³
\8bC
\97Í
\82É
\82È
\82Á
\82½
\82æ
\82¤
\82¾
\81D", Monnam(mon));
1909 /* "aggressive defense"; what type of armor prevents specified attack
1910 from touching its target? */
1912 attk_protection(aatyp)
1925 w_mask = ~0L; /* special case; no defense needed */
1930 w_mask = W_ARMG; /* caller needs to check for weapon */
1939 w_mask = (W_ARMC | W_ARMG); /* attacker needs both to be protected */
1946 w_mask = 0L; /* no defense available */