1 /* NetHack 3.6 mhitm.c $NHDT-Date: 1583606861 2020/03/07 18:47:41 $ $NHDT-Branch: NetHack-3.6-Mar2020 $:$NHDT-Revision: 1.119 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Robert Patrick Rankin, 2011. */
4 /* NetHack may be freely redistributed. See license for details. */
6 /* JNetHack Copyright */
7 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000 */
8 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2019 */
9 /* JNetHack may be freely redistributed. See license for details. */
14 extern boolean notonhead;
16 static NEARDATA boolean vis, far_noise;
17 static NEARDATA long noisetime;
18 static NEARDATA struct obj *otmp;
20 static const char brief_feeling[] =
22 "have a %s feeling for a moment, then it passes.";
24 "%s
\8bC
\8e\9d\82É
\82¨
\82»
\82í
\82ê
\82½
\82ª
\81C
\82·
\82®
\82É
\89ß
\82¬
\82³
\82Á
\82½
\81D";
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.
52 register struct monst *magr;
53 register struct attack *mattk;
55 boolean farq = (distu(magr->mx, magr->my) > 15);
57 if (!Deaf && (farq != far_noise || moves - noisetime > 10)) {
62 (mattk->aatyp == AT_EXPL) ? "an explosion" : "some noises",
63 farq ? " in the distance" : "");
65 You_hear("%s%s
\82ð
\95·
\82¢
\82½
\81D",
66 farq ? "
\89\93\82
\82Å" : "",
67 (mattk->aatyp == AT_EXPL) ? "
\94\9a\94
\89¹" : "
\89½
\82©
\82ª
\90í
\82¤
\89¹"
75 missmm(magr, mdef, mattk)
76 register struct monst *magr, *mdef;
81 boolean showit = FALSE;
83 /* unhiding or unmimicking happens even if hero can't see it
84 because the formerly concealed monster is now in action */
85 if (M_AP_TYPE(mdef)) {
88 } else if (mdef->mundetected) {
89 mdef->mundetected = 0;
92 if (M_AP_TYPE(magr)) {
95 } else if (magr->mundetected) {
96 magr->mundetected = 0;
101 if (!canspotmon(magr))
102 map_invisible(magr->mx, magr->my);
104 newsym(magr->mx, magr->my);
105 if (!canspotmon(mdef))
106 map_invisible(mdef->mx, mdef->my);
108 newsym(mdef->mx, mdef->my);
111 fmt = (could_seduce(magr, mdef, mattk) && !magr->mcan)
112 ? "%s pretends to be friendly to"
114 #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Ó*/
115 fmt = (could_seduce(magr,mdef,mattk) && !magr->mcan)
116 ? "%s
\82Í%%s
\82É
\97F
\8dD
\93I
\82È
\82Ó
\82è
\82ð
\82µ
\82½
\81D"
117 : "%s
\82Ì%%s
\82Ö
\82Ì
\8dU
\8c\82\82Í
\8aO
\82ê
\82½
\81D";
119 Sprintf(buf, fmt, Monnam(magr));
121 pline("%s %s.", buf, mon_nam_too(mdef, magr));
123 pline(buf, mon_nam_too(mdef, magr));
130 * fightm() -- fight some other monster
133 * 0 - Monster did nothing.
134 * 1 - If the monster made an attack. The monster might have died.
136 * There is an exception to the above. If mtmp has the hero swallowed,
137 * then we report that the monster did nothing so it will continue to
140 /* have monsters fight each other */
143 register struct monst *mtmp;
145 register struct monst *mon, *nmon;
146 int result, has_u_swallowed;
150 /* perhaps the monster will resist Conflict */
151 if (resist(mtmp, RING_CLASS, 0, 0))
154 if (u.ustuck == mtmp) {
155 /* perhaps we're holding it... */
159 has_u_swallowed = (u.uswallow && (mtmp == u.ustuck));
161 for (mon = fmon; mon; mon = nmon) {
165 /* Be careful to ignore monsters that are already dead, since we
166 * might be calling this before we've cleaned them up. This can
167 * happen if the monster attacked a cockatrice bare-handedly, for
170 if (mon != mtmp && !DEADMONSTER(mon)) {
171 if (monnear(mtmp, mon->mx, mon->my)) {
172 if (!u.uswallow && (mtmp == u.ustuck)) {
175 pline("%s releases you!", Monnam(mtmp));
177 pline("%s
\82Í
\82 \82È
\82½
\82ð
\89ð
\95ú
\82µ
\82½
\81I", Monnam(mtmp));
183 /* mtmp can be killed */
187 result = mattackm(mtmp, mon);
189 if (result & MM_AGR_DIED)
190 return 1; /* mtmp died */
192 * If mtmp has the hero swallowed, lie and say there
193 * was no attack (this allows mtmp to digest the hero).
198 /* Allow attacked monsters a chance to hit back. Primarily
199 * to allow monsters that resist conflict to respond.
201 if ((result & MM_HIT) && !(result & MM_DEF_DIED) && rn2(4)
202 && mon->movement >= NORMAL_SPEED) {
203 mon->movement -= NORMAL_SPEED;
205 (void) mattackm(mon, mtmp); /* return attack */
208 return (result & MM_HIT) ? 1 : 0;
216 * mdisplacem() -- attacker moves defender out of the way;
217 * returns same results as mattackm().
220 mdisplacem(magr, mdef, quietly)
221 register struct monst *magr, *mdef;
224 struct permonst *pa, *pd;
227 /* sanity checks; could matter if we unexpectedly get a long worm */
228 if (!magr || !mdef || magr == mdef)
230 pa = magr->data, pd = mdef->data;
231 tx = mdef->mx, ty = mdef->my; /* destination */
232 fx = magr->mx, fy = magr->my; /* current location */
233 if (m_at(fx, fy) != magr || m_at(tx, ty) != mdef)
236 /* The 1 in 7 failure below matches the chance in attack()
237 * for pet displacement.
242 /* Grid bugs cannot displace at an angle. */
243 if (pa == &mons[PM_GRID_BUG] && magr->mx != mdef->mx
244 && magr->my != mdef->my)
247 /* undetected monster becomes un-hidden if it is displaced */
248 if (mdef->mundetected)
249 mdef->mundetected = 0;
250 if (M_AP_TYPE(mdef) && M_AP_TYPE(mdef) != M_AP_MONSTER)
252 /* wake up the displaced defender */
254 mdef->mstrategy &= ~STRAT_WAITMASK;
255 finish_meating(mdef);
258 * Set up the visibility of action.
259 * You can observe monster displacement if you can see both of
260 * the monsters involved.
262 vis = (canspotmon(magr) && canspotmon(mdef));
264 if (touch_petrifies(pd) && !resists_ston(magr)) {
265 if (which_armor(magr, W_ARMG) != 0) {
266 if (poly_when_stoned(pa)) {
268 return MM_HIT; /* no damage during the polymorph */
270 if (!quietly && canspotmon(magr))
272 pline("%s turns to stone!", Monnam(magr));
274 pline("%s
\82Í
\90Î
\82É
\82È
\82Á
\82½
\81I", Monnam(magr));
276 if (!DEADMONSTER(magr))
277 return MM_HIT; /* lifesaved */
278 else if (magr->mtame && !vis)
280 You(brief_feeling, "peculiarly sad");
282 You(brief_feeling, "
\82à
\82Ì
\94ß
\82µ
\82¢");
287 remove_monster(fx, fy); /* pick up from orig position */
288 remove_monster(tx, ty);
289 place_monster(magr, tx, ty); /* put down at target spot */
290 place_monster(mdef, fx, fy);
293 pline("%s moves %s out of %s way!", Monnam(magr), mon_nam(mdef),
294 is_rider(pa) ? "the" : mhis(magr));
296 pline("%s
\82Í%s
\82ð
\89\9f\82µ
\82Ì
\82¯
\82½
\81I", Monnam(magr), mon_nam(mdef));
298 newsym(fx, fy); /* see it */
299 newsym(tx, ty); /* all happen */
300 flush_screen(0); /* make sure it shows up */
306 * mattackm() -- a monster attacks another monster.
308 * --------- aggressor died
309 * / ------- defender died
310 * / / ----- defender was hit
319 * Each successive attack has a lower probability of hitting. Some rely on
320 * success of previous attacks. ** this doen't seem to be implemented -dl **
322 * In the case of exploding monsters, the monster dies as well.
326 register struct monst *magr, *mdef;
328 int i, /* loop counter */
329 tmp, /* amour class difference */
330 strike = 0, /* hit this attack */
331 attk, /* attack attempted this time */
332 struck = 0, /* hit at least once */
333 res[NATTK]; /* results of all attacks */
334 struct attack *mattk, alt_attk;
335 struct permonst *pa, *pd;
338 return MM_MISS; /* mike@genat */
339 if (!magr->mcanmove || magr->msleeping)
344 /* Grid bugs cannot attack at an angle. */
345 if (pa == &mons[PM_GRID_BUG] && magr->mx != mdef->mx
346 && magr->my != mdef->my)
349 /* Calculate the armour class differential. */
350 tmp = find_mac(mdef) + magr->m_lev;
351 if (mdef->mconf || !mdef->mcanmove || mdef->msleeping) {
356 /* undetect monsters become un-hidden if they are attacked */
357 if (mdef->mundetected) {
358 mdef->mundetected = 0;
359 newsym(mdef->mx, mdef->my);
360 if (canseemon(mdef) && !sensemon(mdef)) {
363 boolean justone = (mdef->data->geno & G_UNIQ) != 0L;
366 montype = noname_monnam(mdef, justone ? ARTICLE_THE
369 montype = makeplural(montype);
370 You("dream of %s.", montype);
372 You("%s
\82Ì
\96²
\82ð
\8c©
\82½
\81D", a_monnam(mdef));
376 pline("Suddenly, you notice %s.", a_monnam(mdef));
378 pline("
\93Ë
\91R
\81C
\82 \82È
\82½
\82Í%s
\82É
\8bC
\82ª
\82Â
\82¢
\82½
\81D", a_monnam(mdef));
382 /* Elves hate orcs. */
383 if (is_elf(pa) && is_orc(pd))
386 /* Set up the visibility of action */
387 vis = (cansee(magr->mx, magr->my) && cansee(mdef->mx, mdef->my)
388 && (canspotmon(magr) || canspotmon(mdef)));
390 /* Set flag indicating monster has moved this turn. Necessary since a
391 * monster might get an attack out of sequence (i.e. before its move) in
392 * some cases, in which case this still counts as its move for the round
393 * and it shouldn't move again.
395 magr->mlstmv = monstermoves;
397 /* Now perform all attacks for the monster. */
398 for (i = 0; i < NATTK; i++) {
400 mattk = getmattk(magr, mdef, i, res, &alt_attk);
401 otmp = (struct obj *) 0;
403 switch (mattk->aatyp) {
404 case AT_WEAP: /* "hand to hand" attacks */
405 if (distmin(magr->mx, magr->my, mdef->mx, mdef->my) > 1) {
406 /* D: Do a ranged attack here! */
407 strike = thrwmm(magr, mdef);
408 if (DEADMONSTER(mdef))
409 res[i] = MM_DEF_DIED;
410 if (DEADMONSTER(magr))
411 res[i] |= MM_AGR_DIED;
414 if (magr->weapon_check == NEED_WEAPON || !MON_WEP(magr)) {
415 magr->weapon_check = NEED_HTH_WEAPON;
416 if (mon_wield_item(magr) != 0)
419 possibly_unwield(magr, FALSE);
420 otmp = MON_WEP(magr);
424 mswingsm(magr, mdef, otmp);
425 tmp += hitval(otmp, mdef);
435 /* Nymph that teleported away on first attack? */
436 if (distmin(magr->mx, magr->my, mdef->mx, mdef->my) > 1)
437 /* Continue because the monster may have a ranged attack. */
439 /* Monsters won't attack cockatrices physically if they
440 * have a weapon instead. This instinct doesn't work for
441 * players, or under conflict or confusion.
443 if (!magr->mconf && !Conflict && otmp && mattk->aatyp != AT_WEAP
444 && touch_petrifies(mdef->data)) {
448 dieroll = rnd(20 + i);
449 strike = (tmp > dieroll);
450 /* KMH -- don't accumulate to-hit bonuses */
452 tmp -= hitval(otmp, mdef);
454 res[i] = hitmm(magr, mdef, mattk);
455 if ((mdef->data == &mons[PM_BLACK_PUDDING]
456 || mdef->data == &mons[PM_BROWN_PUDDING])
457 && (otmp && (objects[otmp->otyp].oc_material == IRON
458 || objects[otmp->otyp].oc_material == METAL))
459 && mdef->mhp > 1 && !mdef->mcan) {
460 struct monst *mclone;
462 if ((mclone = clone_mon(mdef, 0, 0)) != 0) {
463 if (vis && canspotmon(mdef)) {
466 Strcpy(buf, Monnam(mdef));
468 pline("%s divides as %s hits it!", buf,
471 pline("%s
\82Ì
\8dU
\8c\82\82Å%s
\82ª
\95ª
\97ô
\82µ
\82½
\81I",
479 missmm(magr, mdef, mattk);
482 case AT_HUGS: /* automatic if prev two attacks succeed */
483 strike = (i >= 2 && res[i - 1] == MM_HIT && res[i - 2] == MM_HIT);
485 res[i] = hitmm(magr, mdef, mattk);
491 res[i] = gazemm(magr, mdef, mattk);
495 /* D: Prevent explosions from a distance */
496 if (distmin(magr->mx,magr->my,mdef->mx,mdef->my) > 1)
499 res[i] = explmm(magr, mdef, mattk);
500 if (res[i] == MM_MISS) { /* cancelled--no attack */
504 strike = 1; /* automatic hit */
508 if (mdef->data == &mons[PM_SHADE]) { /* no silver teeth... */
510 pline("%s attempt to engulf %s is futile.",
511 s_suffix(Monnam(magr)), mon_nam(mdef));
515 if (u.usteed && mdef == u.usteed) {
519 /* D: Prevent engulf from a distance */
520 if (distmin(magr->mx, magr->my, mdef->mx, mdef->my) > 1)
522 /* Engulfing attacks are directed at the hero if possible. -dlc */
523 if (u.uswallow && magr == u.ustuck)
525 else if ((strike = (tmp > rnd(20 + i))) != 0)
526 res[i] = gulpmm(magr, mdef, mattk);
528 missmm(magr, mdef, mattk);
532 if (!monnear(magr, mdef->mx, mdef->my)) {
533 strike = breamm(magr, mattk, mdef);
535 /* We don't really know if we hit or not; pretend we did. */
538 if (DEADMONSTER(mdef))
539 res[i] = MM_DEF_DIED;
540 if (DEADMONSTER(magr))
541 res[i] |= MM_AGR_DIED;
548 if (!monnear(magr, mdef->mx, mdef->my)) {
549 strike = spitmm(magr, mattk, mdef);
551 /* We don't really know if we hit or not; pretend we did. */
554 if (DEADMONSTER(mdef))
555 res[i] = MM_DEF_DIED;
556 if (DEADMONSTER(magr))
557 res[i] |= MM_AGR_DIED;
561 default: /* no attack */
567 if (attk && !(res[i] & MM_AGR_DIED)
568 && distmin(magr->mx, magr->my, mdef->mx, mdef->my) <= 1)
569 res[i] = passivemm(magr, mdef, strike, res[i] & MM_DEF_DIED);
571 if (res[i] & MM_DEF_DIED)
573 if (res[i] & MM_AGR_DIED)
575 /* return if aggressor can no longer attack */
576 if (!magr->mcanmove || magr->msleeping)
579 struck = 1; /* at least one hit */
582 return (struck ? MM_HIT : MM_MISS);
585 /* Returns the result of mdamagem(). */
587 hitmm(magr, mdef, mattk)
588 register struct monst *magr, *mdef;
589 struct attack *mattk;
591 boolean weaponhit = ((mattk->aatyp == AT_WEAP
592 || (mattk->aatyp == AT_CLAW && otmp))),
593 silverhit = (weaponhit && otmp
594 && objects[otmp->otyp].oc_material == SILVER),
597 /* unhiding or unmimicking happens even if hero can't see it
598 because the formerly concealed monster is now in action */
599 if (M_AP_TYPE(mdef)) {
602 } else if (mdef->mundetected) {
603 mdef->mundetected = 0;
606 if (M_AP_TYPE(magr)) {
609 } else if (magr->mundetected) {
610 magr->mundetected = 0;
618 if (!canspotmon(magr))
619 map_invisible(magr->mx, magr->my);
621 newsym(magr->mx, magr->my);
622 if (!canspotmon(mdef))
623 map_invisible(mdef->mx, mdef->my);
625 newsym(mdef->mx, mdef->my);
627 if ((compat = could_seduce(magr, mdef, mattk)) && !magr->mcan) {
629 Sprintf(buf, "%s %s", Monnam(magr),
630 mdef->mcansee ? "smiles at" : "talks to");
631 pline("%s %s %s.", buf, mon_nam(mdef),
632 compat == 2 ? "engagingly" : "seductively");
634 Sprintf(buf, "%s
\82Í%%s
\82É%%s%s
\81D", Monnam(magr),
635 mdef->mcansee ? "
\94÷
\8fÎ
\82Ý
\82©
\82¯
\82½" : "
\98b
\82µ
\82©
\82¯
\82½");
636 pline(buf, mon_nam(mdef),
637 compat == 2 ? "
\96£
\97Í
\93I
\82É" : "
\97U
\98f
\93I
\82É");
639 } else if (shade_miss(magr, mdef, otmp, FALSE, TRUE)) {
640 return MM_MISS; /* bypass mdamagem() */
642 char magr_name[BUFSZ];
644 Strcpy(magr_name, Monnam(magr));
645 switch (mattk->aatyp) {
648 Sprintf(buf, "%s bites", magr_name);
650 Sprintf(buf,"%s
\82Í%%s
\82É
\8a\9a\82Ý
\82Â
\82¢
\82½
\81D", magr_name);
654 Sprintf(buf, "%s stings", magr_name);
656 Sprintf(buf,"%s
\82Í%%s
\82ð
\93Ë
\82«
\82³
\82µ
\82½
\81D", magr_name);
660 Sprintf(buf, "%s butts", magr_name);
662 Sprintf(buf,"%s
\82Í%%s
\82É
\93ª
\93Ë
\82«
\82ð
\82
\82ç
\82í
\82µ
\82½
\81D", magr_name);
666 Sprintf(buf, "%s touches", magr_name);
668 Sprintf(buf,"%s
\82Í%%s
\82É
\90G
\82ê
\82½
\81D", magr_name);
672 Sprintf(buf, "%s tentacles suck", s_suffix(magr_name));
674 Sprintf(buf, "%s
\82Ì
\90G
\8eè
\82ª%%s
\82Ì
\91Ì
\89t
\82ð
\8bz
\82¢
\82Æ
\82Á
\82½
\81D", magr_name);
677 if (magr != u.ustuck) {
679 Sprintf(buf, "%s squeezes", magr_name);
681 Sprintf(buf,"%s
\82Í%%s
\82ð
\8di
\82ß
\82½
\81D", magr_name);
687 Sprintf(buf, "%s hits", magr_name);
689 Sprintf(buf,"%s
\82Ì%%s
\82Ö
\82Ì
\8dU
\8c\82\82Í
\96½
\92\86\82µ
\82½
\81D", magr_name);
692 pline("%s %s.", buf, mon_nam_too(mdef, magr));
694 pline(buf, mon_nam_too(mdef, magr));
697 if (mon_hates_silver(mdef) && silverhit) {
698 char *mdef_name = mon_nam_too(mdef, magr);
700 /* note: mon_nam_too returns a modifiable buffer; so
701 does s_suffix, but it returns a single static buffer
702 and we might be calling it twice for this message */
703 Strcpy(magr_name, s_suffix(magr_name));
704 if (!noncorporeal(mdef->data) && !amorphous(mdef->data)) {
706 mdef_name = s_suffix(mdef_name);
708 (void) strsubst(mdef_name, "himself", "his own");
709 (void) strsubst(mdef_name, "herself", "her own");
710 (void) strsubst(mdef_name, "itself", "its own");
712 Strcat(mdef_name, " flesh");
715 pline("%s %s sears %s!", magr_name, /*s_suffix(magr_name), */
716 simpleonames(otmp), mdef_name);
722 return mdamagem(magr, mdef, mattk);
725 /* Returns the same values as mdamagem(). */
727 gazemm(magr, mdef, mattk)
728 register struct monst *magr, *mdef;
729 struct attack *mattk;
734 if (mdef->data->mlet == S_MIMIC
735 && M_AP_TYPE(mdef) != M_AP_NOTHING)
738 Sprintf(buf, "%s gazes at", Monnam(magr));
739 pline("%s %s...", buf,
740 canspotmon(mdef) ? mon_nam(mdef) : "something");
742 Sprintf(buf, "%s
\82Í%%s
\82ð
\82É
\82ç
\82Ý
\82Â
\82¯
\82½
\81D
\81D
\81D", Monnam(magr));
743 pline(buf, canspotmon(mdef) ? mon_nam(mdef) : "
\89½
\82©");
747 if (magr->mcan || !magr->mcansee || !mdef->mcansee
748 || (magr->minvis && !perceives(mdef->data)) || mdef->msleeping) {
749 if (vis && canspotmon(mdef))
751 pline("but nothing happens.");
753 pline("
\82µ
\82©
\82µ
\89½
\82à
\82¨
\82±
\82ç
\82È
\82©
\82Á
\82½
\81D");
756 /* call mon_reflects 2x, first test, then, if visible, print message */
757 if (magr->data == &mons[PM_MEDUSA] && mon_reflects(mdef, (char *) 0)) {
760 (void) mon_reflects(mdef, "The gaze is reflected away by %s %s.");
762 (void) mon_reflects(mdef, "
\82É
\82ç
\82Ý
\82Í%s
\82Ì%s
\82Å
\94½
\8eË
\82µ
\82½
\81D");
764 if (mon_reflects(magr, (char *) 0)) {
767 (void) mon_reflects(magr,
768 "The gaze is reflected away by %s %s.");
770 (void) mon_reflects(magr,
771 "
\82É
\82ç
\82Ý
\82Í%s
\82Ì%s
\82Å
\94½
\8eË
\82µ
\82½
\81D");
775 if (mdef->minvis && !perceives(magr->data)) {
776 if (canseemon(magr)) {
779 "%s doesn't seem to notice that %s gaze was reflected.",
780 Monnam(magr), mhis(magr));
782 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",
790 pline("%s is turned to stone!", Monnam(magr));
792 pline("%s
\82Í
\90Î
\82É
\82È
\82Á
\82½
\81I", Monnam(magr));
794 if (!DEADMONSTER(magr))
800 return mdamagem(magr, mdef, mattk);
803 /* return True if magr is allowed to swallow mdef, False otherwise */
805 engulf_target(magr, mdef)
806 struct monst *magr, *mdef;
811 /* can't swallow something that's too big */
812 if (mdef->data->msize >= MZ_HUGE)
815 /* (hypothetical) engulfers who can pass through walls aren't
816 limited by rock|trees|bars */
817 if ((magr == &youmonst) ? Passes_walls : passes_walls(magr->data))
820 /* don't swallow something in a spot where attacker wouldn't
821 otherwise be able to move onto; we don't want to engulf
822 a wall-phaser and end up with a non-phaser inside a wall */
823 dx = mdef->mx, dy = mdef->my;
824 if (mdef == &youmonst)
825 dx = u.ux, dy = u.uy;
827 if (IS_ROCK(lev->typ) || closed_door(dx, dy) || IS_TREE(lev->typ)
828 /* not passes_bars(); engulfer isn't squeezing through */
829 || (lev->typ == IRONBARS && !is_whirly(magr->data)))
835 /* Returns the same values as mattackm(). */
837 gulpmm(magr, mdef, mattk)
838 register struct monst *magr, *mdef;
839 register struct attack *mattk;
841 xchar ax, ay, dx, dy;
846 if (!engulf_target(magr, mdef))
850 /* [this two-part formatting dates back to when only one x_monnam
851 result could be included in an expression because the next one
852 would overwrite first's result -- that's no longer the case] */
854 Sprintf(buf, "%s swallows", Monnam(magr));
855 pline("%s %s.", buf, mon_nam(mdef));
857 Sprintf(buf, "%s
\82Í%%s
\82ð
\82®
\82Á
\82Æ
\88ù
\82Ý
\82±
\82ñ
\82¾
\81D", Monnam(magr));
858 pline(buf, mon_nam(mdef));
861 for (obj = mdef->minvent; obj; obj = obj->nobj)
862 (void) snuff_lit(obj);
864 if (is_vampshifter(mdef)
865 && newcham(mdef, &mons[mdef->cham], FALSE, FALSE)) {
867 /* 'it' -- previous form is no longer available and
868 using that would be excessively verbose */
870 pline("%s expels %s.", Monnam(magr),
871 canspotmon(mdef) ? "it" : something);
873 pline("%s
\82Í%s
\82ð
\93f
\82«
\8fo
\82µ
\82½
\81D", Monnam(magr),
874 canspotmon(mdef) ? "
\89½
\82©" : something);
876 if (canspotmon(mdef))
878 pline("It turns into %s.", a_monnam(mdef));
880 pline("
\82»
\82ê
\82Í%s
\82É
\82È
\82Á
\82½
\81D", a_monnam(mdef));
882 return MM_HIT; /* bypass mdamagem() */
886 * All of this manipulation is needed to keep the display correct.
887 * There is a flush at the next pline().
894 * Leave the defender in the monster chain at it's current position,
895 * but don't leave it on the screen. Move the aggressor to the
896 * defender's position.
898 remove_monster(dx, dy);
899 remove_monster(ax, ay);
900 place_monster(magr, dx, dy);
901 newsym(ax, ay); /* erase old position */
902 newsym(dx, dy); /* update new position */
904 status = mdamagem(magr, mdef, mattk);
906 if ((status & (MM_AGR_DIED | MM_DEF_DIED))
907 == (MM_AGR_DIED | MM_DEF_DIED)) {
908 ; /* both died -- do nothing */
909 } else if (status & MM_DEF_DIED) { /* defender died */
911 * Note: remove_monster() was called in relmon(), wiping out
912 * magr from level.monsters[mdef->mx][mdef->my]. We need to
913 * put it back and display it. -kd
915 place_monster(magr, dx, dy);
917 /* aggressor moves to <dx,dy> and might encounter trouble there */
918 if (minliquid(magr) || (t_at(dx, dy) && mintrap(magr) == 2))
919 status |= MM_AGR_DIED;
920 } else if (status & MM_AGR_DIED) { /* aggressor died */
921 place_monster(mdef, dx, dy);
923 } else { /* both alive, put them back */
926 pline("%s is regurgitated!", Monnam(mdef));
928 pline("%s
\82Í
\93f
\82«
\96ß
\82³
\82ê
\82½
\81I", Monnam(mdef));
930 remove_monster(dx,dy);
931 place_monster(magr, ax, ay);
932 place_monster(mdef, dx, dy);
941 explmm(magr, mdef, mattk)
942 struct monst *magr, *mdef;
943 struct attack *mattk;
950 if (cansee(magr->mx, magr->my))
952 pline("%s explodes!", Monnam(magr));
954 pline("%s
\82Í
\94\9a\94
\82µ
\82½
\81I", Monnam(magr));
958 result = mdamagem(magr, mdef, mattk);
960 /* Kill off aggressor if it didn't die. */
961 if (!(result & MM_AGR_DIED)) {
962 boolean was_leashed = (magr->mleashed != 0);
965 if (!DEADMONSTER(magr))
966 return result; /* life saved */
967 result |= MM_AGR_DIED;
969 /* mondead() -> m_detach() -> m_unleash() always suppresses
970 the m_unleash() slack message, so deliver it here instead */
972 Your("leash falls slack.");
974 if (magr->mtame) /* give this one even if it was visible */
976 You(brief_feeling, "melancholy");
978 You(brief_feeling, "
\97J
\82¤
\82Â
\82È");
984 * See comment at top of mattackm(), for return values.
987 mdamagem(magr, mdef, mattk)
988 register struct monst *magr, *mdef;
989 register struct attack *mattk;
993 struct permonst *pa = magr->data, *pd = mdef->data;
995 tmp = d((int) mattk->damn, (int) mattk->damd),
999 if ((touch_petrifies(pd) /* or flesh_petrifies() */
1000 || (mattk->adtyp == AD_DGST && pd == &mons[PM_MEDUSA]))
1001 && !resists_ston(magr)) {
1002 long protector = attk_protection((int) mattk->aatyp),
1003 wornitems = magr->misc_worn_check;
1005 /* wielded weapon gives same protection as gloves here */
1007 wornitems |= W_ARMG;
1010 || (protector != ~0L && (wornitems & protector) != protector)) {
1011 if (poly_when_stoned(pa)) {
1013 return MM_HIT; /* no damage during the polymorph */
1015 if (vis && canspotmon(magr))
1017 pline("%s turns to stone!", Monnam(magr));
1019 pline("%s
\82Í
\90Î
\82É
\82È
\82Á
\82½
\81I", Monnam(magr));
1021 if (!DEADMONSTER(magr))
1022 return MM_HIT; /* lifesaved */
1023 else if (magr->mtame && !vis)
1025 You(brief_feeling, "peculiarly sad");
1027 You(brief_feeling, "
\82à
\82Ì
\94ß
\82µ
\82¢");
1032 /* cancellation factor is the same as when attacking the hero */
1033 armpro = magic_negation(mdef);
1034 cancelled = magr->mcan || !(rn2(10) >= 3 * armpro);
1036 switch (mattk->adtyp) {
1038 /* eating a Rider or its corpse is fatal */
1040 if (vis && canseemon(magr))
1042 pline("%s %s!", Monnam(magr),
1043 (pd == &mons[PM_FAMINE])
1044 ? "belches feebly, shrivels up and dies"
1045 : (pd == &mons[PM_PESTILENCE])
1046 ? "coughs spasmodically and collapses"
1047 : "vomits violently and drops dead");
1049 pline("%s%s
\81I", Monnam(magr),
1050 (pd == &mons[PM_FAMINE])
1051 ? "
\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½"
1052 : (pd == &mons[PM_PESTILENCE])
1053 ? "áz
\9d¹
\82µ
\82½
\82æ
\82¤
\82É
\82¹
\82«
\82±
\82Ý
\93|
\82ê
\82½"
1054 : "
\8c\83\82µ
\82
\9aq
\93f
\82µ
\8e\80\82ñ
\82¾");
1057 if (!DEADMONSTER(magr))
1058 return 0; /* lifesaved */
1059 else if (magr->mtame && !vis)
1061 You(brief_feeling, "queasy");
1063 You(brief_feeling, "
\95s
\88À
\82È");
1066 if (flags.verbose && !Deaf)
1068 verbalize("Burrrrp!");
1070 verbalize("
\82°
\82Á
\82Õ
\81I");
1072 /* Use up amulet of life saving */
1073 if (!!(obj = mlifesaver(mdef)))
1076 /* Is a corpse for nutrition possible? It may kill magr */
1077 if (!corpse_chance(mdef, magr, TRUE) || DEADMONSTER(magr))
1080 /* Pets get nutrition from swallowing monster whole.
1081 * No nutrition from G_NOCORPSE monster, eg, undead.
1082 * DGST monsters don't die from undead corpses
1085 if (magr->mtame && !magr->isminion
1086 && !(mvitals[num].mvflags & G_NOCORPSE)) {
1087 struct obj *virtualcorpse = mksobj(CORPSE, FALSE, FALSE);
1090 set_corpsenm(virtualcorpse, num);
1091 nutrit = dog_nutrition(magr, virtualcorpse);
1092 dealloc_obj(virtualcorpse);
1094 /* only 50% nutrition, 25% of normal eating time */
1095 if (magr->meating > 1)
1096 magr->meating = (magr->meating + 3) / 4;
1099 EDOG(magr)->hungrytime += nutrit;
1105 if (canseemon(mdef))
1107 pline("%s %s for a moment.", Monnam(mdef),
1108 makeplural(stagger(pd, "stagger")));
1110 pline("%s
\82Í
\82·
\82±
\82µ%s
\81D", Monnam(mdef),
1111 jpast(stagger(pd, "
\82æ
\82ë
\82ß
\82")));
1125 obj = (mattk->aatyp == AT_WEAP || mattk->aatyp == AT_CLAW) ? otmp : 0;
1126 if (shade_miss(magr, mdef, obj, FALSE, TRUE)) {
1128 } else if (mattk->aatyp == AT_KICK && thick_skinned(pd)) {
1130 } else if (mattk->aatyp == AT_WEAP
1131 || (mattk->aatyp == AT_CLAW && otmp)) {
1135 if (otmp->otyp == CORPSE
1136 && touch_petrifies(&mons[otmp->corpsenm]))
1139 tmp += dmgval(otmp, mdef);
1140 if ((marmg = which_armor(magr, W_ARMG)) != 0
1141 && marmg->otyp == GAUNTLETS_OF_POWER)
1142 tmp += rn1(4, 3); /* 3..6 */
1143 if (tmp < 1) /* is this necessary? mhitu.c has it... */
1145 if (otmp->oartifact) {
1146 (void) artifact_hit(magr, mdef, otmp, &tmp, dieroll);
1147 if (DEADMONSTER(mdef))
1149 | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1154 } else if (pa == &mons[PM_PURPLE_WORM] && pd == &mons[PM_SHRIEKER]) {
1155 /* hack to enhance mm_aggression(); we don't want purple
1156 worm's bite attack to kill a shrieker because then it
1157 won't swallow the corpse; but if the target survives,
1158 the subsequent engulf attack should accomplish that */
1159 if (tmp >= mdef->mhp && mdef->mhp > 1)
1160 tmp = mdef->mhp - 1;
1168 if (vis && canseemon(mdef))
1170 pline("%s is %s!", Monnam(mdef), on_fire(pd, mattk));
1172 pline("%s
\82Í%s
\81I", Monnam(mdef), on_fire(pd, mattk));
1173 if (completelyburns(pd)) { /* paper golem or straw golem */
1174 if (vis && canseemon(mdef))
1176 pline("%s burns completely!", Monnam(mdef));
1178 pline("%s
\82Í
\8aD
\82É
\82È
\82Á
\82½
\81I", Monnam(mdef));
1179 mondead(mdef); /* was mondied() but that dropped paper scrolls */
1180 if (!DEADMONSTER(mdef))
1182 else if (mdef->mtame && !vis)
1184 pline("May %s roast in peace.", mon_nam(mdef));
1186 pline("%s
\82æ
\81C
\88À
\82ç
\82©
\82É
\94R
\82¦
\82ñ
\8e\96\82ð
\81D", mon_nam(mdef));
1187 return (MM_DEF_DIED | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1189 tmp += destroy_mitem(mdef, SCROLL_CLASS, AD_FIRE);
1190 tmp += destroy_mitem(mdef, SPBOOK_CLASS, AD_FIRE);
1191 if (resists_fire(mdef)) {
1192 if (vis && canseemon(mdef))
1194 pline_The("fire doesn't seem to burn %s!", mon_nam(mdef));
1196 pline("%s
\82Í
\89\8a\82Å
\94R
\82¦
\82È
\82¢
\82æ
\82¤
\82¾
\81I", mon_nam(mdef));
1197 shieldeff(mdef->mx, mdef->my);
1198 golemeffects(mdef, AD_FIRE, tmp);
1201 /* only potions damage resistant players in destroy_item */
1202 tmp += destroy_mitem(mdef, POTION_CLASS, AD_FIRE);
1209 if (vis && canseemon(mdef))
1211 pline("%s is covered in frost!", Monnam(mdef));
1213 pline("%s
\82Í
\95X
\82Å
\95¢
\82í
\82ê
\82½
\81I", Monnam(mdef));
1214 if (resists_cold(mdef)) {
1215 if (vis && canseemon(mdef))
1217 pline_The("frost doesn't seem to chill %s!", mon_nam(mdef));
1219 pline("
\95X
\82Í%s
\82ð
\93\80\82ç
\82¹
\82é
\82±
\82Æ
\82ª
\82Å
\82«
\82È
\82¢
\82æ
\82¤
\82¾
\81I", mon_nam(mdef));
1220 shieldeff(mdef->mx, mdef->my);
1221 golemeffects(mdef, AD_COLD, tmp);
1224 tmp += destroy_mitem(mdef, POTION_CLASS, AD_COLD);
1231 if (vis && canseemon(mdef))
1233 pline("%s gets zapped!", Monnam(mdef));
1235 pline("%s
\82Í
\8fÕ
\8c\82\82ð
\82
\82ç
\82Á
\82½
\81I", Monnam(mdef));
1236 tmp += destroy_mitem(mdef, WAND_CLASS, AD_ELEC);
1237 if (resists_elec(mdef)) {
1238 if (vis && canseemon(mdef))
1240 pline_The("zap doesn't shock %s!", mon_nam(mdef));
1242 pline("
\8fÕ
\8c\82\82Í%s
\82É
\89e
\8b¿
\82ð
\97^
\82¦
\82È
\82¢
\81I", mon_nam(mdef));
1243 shieldeff(mdef->mx, mdef->my);
1244 golemeffects(mdef, AD_ELEC, tmp);
1247 /* only rings damage resistant players in destroy_item */
1248 tmp += destroy_mitem(mdef, RING_CLASS, AD_ELEC);
1255 if (resists_acid(mdef)) {
1256 if (vis && canseemon(mdef))
1258 pline("%s is covered in %s, but it seems harmless.",
1259 Monnam(mdef), hliquid("acid"));
1261 pline("%s
\82Í%s
\82É
\82Â
\82Â
\82Ü
\82ê
\82½
\81D
\82µ
\82©
\82µ
\82È
\82ñ
\82Æ
\82à
\82È
\82¢
\82æ
\82¤
\82¾
\81D",
1262 Monnam(mdef), hliquid("
\8e_"));
1265 } else if (vis && canseemon(mdef)) {
1267 pline("%s is covered in %s!", Monnam(mdef), hliquid("acid"));
1269 pline("%s
\82Í%s
\82É
\82Â
\82Â
\82Ü
\82ê
\82½
\81I", Monnam(mdef), hliquid("
\8e_"));
1271 pline("It burns %s!", mon_nam(mdef));
1273 pline("%s
\82Í
\8fÄ
\82©
\82ê
\82½
\81I", mon_nam(mdef));
1276 erode_armor(mdef, ERODE_CORRODE);
1278 acid_damage(MON_WEP(mdef));
1283 if (pd == &mons[PM_IRON_GOLEM]) {
1284 if (vis && canseemon(mdef))
1286 pline("%s falls to pieces!", Monnam(mdef));
1288 pline("%s
\82Í
\83o
\83\89\83o
\83\89\82É
\82È
\82Á
\82½
\81I", Monnam(mdef));
1290 if (!DEADMONSTER(mdef))
1292 else if (mdef->mtame && !vis)
1294 pline("May %s rust in peace.", mon_nam(mdef));
1296 pline("%s
\82æ
\81C
\88À
\82ç
\82©
\82É
\8eK
\82Ñ
\82ñ
\8e\96\82ð
\81D", mon_nam(mdef));
1297 return (MM_DEF_DIED | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1299 erode_armor(mdef, ERODE_RUST);
1300 mdef->mstrategy &= ~STRAT_WAITFORU;
1306 erode_armor(mdef, ERODE_CORRODE);
1307 mdef->mstrategy &= ~STRAT_WAITFORU;
1313 if (pd == &mons[PM_WOOD_GOLEM] || pd == &mons[PM_LEATHER_GOLEM]) {
1314 if (vis && canseemon(mdef))
1316 pline("%s falls to pieces!", Monnam(mdef));
1318 pline("%s
\82Í
\83o
\83\89\83o
\83\89\82É
\82È
\82Á
\82½
\81I", Monnam(mdef));
1320 if (!DEADMONSTER(mdef))
1322 else if (mdef->mtame && !vis)
1324 pline("May %s rot in peace.", mon_nam(mdef));
1326 pline("%s
\82æ
\81C
\88À
\82ç
\82©
\82É
\95\85\82ç
\82ñ
\8e\96\82ð
\81D", mon_nam(mdef));
1327 return (MM_DEF_DIED | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1329 erode_armor(mdef, ERODE_CORRODE);
1330 mdef->mstrategy &= ~STRAT_WAITFORU;
1337 /* may die from the acid if it eats a stone-curing corpse */
1338 if (munstone(mdef, FALSE))
1340 if (poly_when_stoned(pd)) {
1345 if (!resists_ston(mdef)) {
1346 if (vis && canseemon(mdef))
1348 pline("%s turns to stone!", Monnam(mdef));
1350 pline("%s
\82Í
\90Î
\82É
\82È
\82Á
\82½
\81I", Monnam(mdef));
1353 if (!DEADMONSTER(mdef))
1355 else if (mdef->mtame && !vis)
1357 You(brief_feeling, "peculiarly sad");
1359 You(brief_feeling, "
\82à
\82Ì
\94ß
\82µ
\82¢");
1360 return (MM_DEF_DIED | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1362 tmp = (mattk->adtyp == AD_STON ? 0 : 1);
1365 if (!cancelled && tmp < mdef->mhp && !tele_restrict(mdef)) {
1366 char mdef_Monnam[BUFSZ];
1367 boolean wasseen = canspotmon(mdef);
1369 /* save the name before monster teleports, otherwise
1370 we'll get "it" in the suddenly disappears message */
1372 Strcpy(mdef_Monnam, Monnam(mdef));
1373 mdef->mstrategy &= ~STRAT_WAITFORU;
1374 (void) rloc(mdef, TRUE);
1375 if (vis && wasseen && !canspotmon(mdef) && mdef != u.usteed)
1377 pline("%s suddenly disappears!", mdef_Monnam);
1379 pline("%s
\82Í
\93Ë
\91R
\8fÁ
\82¦
\82½
\81I", mdef_Monnam);
1380 if (tmp >= mdef->mhp) { /* see hitmu(mhitu.c) */
1383 tmp = mdef->mhp - 1;
1388 if (!cancelled && !mdef->msleeping
1389 && sleep_monst(mdef, rnd(10), -1)) {
1390 if (vis && canspotmon(mdef)) {
1391 Strcpy(buf, Monnam(mdef));
1393 pline("%s is put to sleep by %s.", buf, mon_nam(magr));
1395 pline("%s
\82Í%s
\82É
\82æ
\82Á
\82Ä
\96°
\82ç
\82³
\82ê
\82½
\81D", buf, mon_nam(magr));
1397 mdef->mstrategy &= ~STRAT_WAITFORU;
1402 if (!cancelled && mdef->mcanmove) {
1403 if (vis && canspotmon(mdef)) {
1404 Strcpy(buf, Monnam(mdef));
1406 pline("%s is frozen by %s.", buf, mon_nam(magr));
1408 pline("%s
\82Í%s
\82É
\82æ
\82Á
\82Ä
\93®
\82¯
\82È
\82
\82È
\82Á
\82½
\81D", buf, mon_nam(magr));
1410 paralyze_monst(mdef, rnd(10));
1414 if (!cancelled && mdef->mspeed != MSLOW) {
1415 unsigned int oldspeed = mdef->mspeed;
1417 mon_adjust_speed(mdef, -1, (struct obj *) 0);
1418 mdef->mstrategy &= ~STRAT_WAITFORU;
1419 if (mdef->mspeed != oldspeed && vis && canspotmon(mdef))
1421 pline("%s slows down.", Monnam(mdef));
1423 pline("%s
\82Í
\93®
\8dì
\82ª
\82Ì
\82ë
\82
\82È
\82Á
\82½
\81D", Monnam(mdef));
1427 /* Since confusing another monster doesn't have a real time
1428 * limit, setting spec_used would not really be right (though
1429 * we still should check for it).
1431 if (!magr->mcan && !mdef->mconf && !magr->mspec_used) {
1432 if (vis && canseemon(mdef))
1434 pline("%s looks confused.", Monnam(mdef));
1436 pline("%s
\82Í
\8d¬
\97\90\82µ
\82Ä
\82¢
\82é
\82æ
\82¤
\82É
\8c©
\82¦
\82é
\81D", Monnam(mdef));
1438 mdef->mstrategy &= ~STRAT_WAITFORU;
1442 if (can_blnd(magr, mdef, mattk->aatyp, (struct obj *) 0)) {
1443 register unsigned rnd_tmp;
1445 if (vis && mdef->mcansee && canspotmon(mdef))
1447 pline("%s is blinded.", Monnam(mdef));
1449 pline("%s
\82Í
\96Ú
\82ª
\8c©
\82¦
\82È
\82
\82È
\82Á
\82½
\81D", Monnam(mdef));
1450 rnd_tmp = d((int) mattk->damn, (int) mattk->damd);
1451 if ((rnd_tmp += mdef->mblinded) > 127)
1453 mdef->mblinded = rnd_tmp;
1455 mdef->mstrategy &= ~STRAT_WAITFORU;
1460 if (!magr->mcan && haseyes(pd) && mdef->mcansee) {
1461 if (vis && canseemon(mdef))
1463 pline("%s looks %sconfused.", Monnam(mdef),
1464 mdef->mconf ? "more " : "");
1466 pline("%s
\82Í%s
\8d¬
\97\90\82µ
\82Ä
\82¢
\82é
\82æ
\82¤
\82É
\8c©
\82¦
\82é
\81D", Monnam(mdef),
1467 mdef->mconf ? "
\82Ü
\82·
\82Ü
\82·" : "");
1470 mdef->mstrategy &= ~STRAT_WAITFORU;
1475 if (!night() && (pa == &mons[PM_GREMLIN]))
1477 if (!magr->mcan && !rn2(10)) {
1478 mdef->mcan = 1; /* cancelled regardless of lifesave */
1479 mdef->mstrategy &= ~STRAT_WAITFORU;
1480 if (is_were(pd) && pd->mlet != S_HUMAN)
1482 if (pd == &mons[PM_CLAY_GOLEM]) {
1483 if (vis && canseemon(mdef)) {
1485 pline("Some writing vanishes from %s head!",
1486 s_suffix(mon_nam(mdef)));
1488 pline("
\82¢
\82
\82Â
\82©
\82Ì
\95¶
\8e\9a\82ª%s
\82Ì
\93ª
\82©
\82ç
\8fÁ
\82¦
\82½
\81I",
1492 pline("%s is destroyed!", Monnam(mdef));
1494 pline("%s
\82Í
\94j
\89ó
\82³
\82ê
\82½
\81I", Monnam(mdef));
1497 if (!DEADMONSTER(mdef))
1499 else if (mdef->mtame && !vis)
1501 You(brief_feeling, "strangely sad");
1503 You(brief_feeling, "
\96
\82É
\94ß
\82µ
\82¢");
1505 | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1510 You_hear("laughter.");
1512 You_hear("
\8fÎ
\82¢
\90º
\82ð
\95·
\82¢
\82½
\81D");
1513 else if (canseemon(magr))
1515 pline("%s chuckles.", Monnam(magr));
1517 pline("%s
\82Í
\82
\82·
\82
\82·
\8fÎ
\82Á
\82½
\81D", Monnam(magr));
1525 /* technically incorrect; no check for stealing gold from
1526 * between mdef's feet...
1529 struct obj *gold = findgold(mdef->minvent);
1533 obj_extract_self(gold);
1534 add_to_minv(magr, gold);
1536 mdef->mstrategy &= ~STRAT_WAITFORU;
1537 if (vis && canseemon(mdef)) {
1538 Strcpy(buf, Monnam(magr));
1540 pline("%s steals some gold from %s.", buf, mon_nam(mdef));
1542 pline("%s
\82Í%s
\82©
\82ç
\8bà
\82ð
\93\90\82ñ
\82¾
\81D", buf, mon_nam(mdef));
1544 if (!tele_restrict(magr)) {
1545 boolean couldspot = canspotmon(magr);
1546 (void) rloc(magr, TRUE);
1547 if (vis && couldspot && !canspotmon(magr))
1549 pline("%s suddenly disappears!", buf);
1551 pline("%s
\82Í
\93Ë
\91R
\8fÁ
\82¦
\82½
\81I", buf);
1555 if (!cancelled && !rn2(3) && !resists_drli(mdef)) {
1557 if (vis && canspotmon(mdef))
1559 pline("%s suddenly seems weaker!", Monnam(mdef));
1561 pline("%s
\82Í
\93Ë
\91R
\8eã
\82
\82È
\82Á
\82½
\82æ
\82¤
\82É
\8c©
\82¦
\82½
\81I", Monnam(mdef));
1562 mdef->mhpmax -= tmp;
1563 if (mdef->m_lev == 0)
1567 /* Automatic kill if drained past level 0 */
1571 case AD_SITM: /* for now these are the same */
1575 /* find an object to steal, non-cursed if magr is tame */
1576 for (obj = mdef->minvent; obj; obj = obj->nobj)
1577 if (!magr->mtame || !obj->cursed)
1581 char onambuf[BUFSZ], mdefnambuf[BUFSZ];
1583 /* make a special x_monnam() call that never omits
1584 the saddle, and save it for later messages */
1586 x_monnam(mdef, ARTICLE_THE, (char *) 0, 0, FALSE));
1589 if (u.usteed == mdef && otmp == which_armor(mdef, W_SADDLE))
1590 /* "You can no longer ride <steed>." */
1591 dismount_steed(DISMOUNT_POLY);
1592 obj_extract_self(otmp);
1593 if (otmp->owornmask) {
1594 mdef->misc_worn_check &= ~otmp->owornmask;
1595 if (otmp->owornmask & W_WEP)
1597 otmp->owornmask = 0L;
1598 update_mon_intrinsics(mdef, otmp, FALSE, FALSE);
1599 /* give monster a chance to wear other equipment on its next
1600 move instead of waiting until it picks something up */
1601 mdef->misc_worn_check |= I_SPECIAL;
1603 /* add_to_minv() might free otmp [if it merges] */
1605 Strcpy(onambuf, doname(otmp));
1606 (void) add_to_minv(magr, otmp);
1607 if (vis && canseemon(mdef)) {
1608 Strcpy(buf, Monnam(magr));
1610 pline("%s steals %s from %s!", buf, onambuf, mdefnambuf);
1612 pline("%s
\82Í%s
\82©
\82ç%s
\82ð
\93\90\82ñ
\82¾
\81I", buf, mdefnambuf, onambuf);
1614 possibly_unwield(mdef, FALSE);
1615 mdef->mstrategy &= ~STRAT_WAITFORU;
1616 mselftouch(mdef, (const char *) 0, FALSE);
1617 if (DEADMONSTER(mdef))
1619 | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1620 if (pa->mlet == S_NYMPH && !tele_restrict(magr)) {
1621 boolean couldspot = canspotmon(magr);
1623 (void) rloc(magr, TRUE);
1624 if (vis && couldspot && !canspotmon(magr))
1626 pline("%s suddenly disappears!", buf);
1628 pline("%s
\82Í
\93Ë
\91R
\8fÁ
\82¦
\82½
\81I", buf);
1634 if (!cancelled && !rn2(4))
1635 xdrainenergym(mdef, (boolean) (vis && canspotmon(mdef)
1636 && mattk->aatyp != AT_ENGL));
1642 if (!cancelled && !rn2(8)) {
1643 if (vis && canspotmon(magr))
1645 pline("%s %s was poisoned!", s_suffix(Monnam(magr)),
1646 mpoisons_subj(magr, mattk));
1648 pline("%s
\82Ì%s
\82Í
\93Å
\82³
\82ê
\82Ä
\82¢
\82é
\81I", Monnam(magr),
1649 mpoisons_subj(magr, mattk));
1651 if (resists_poison(mdef)) {
1652 if (vis && canspotmon(mdef) && canspotmon(magr))
1654 pline_The("poison doesn't seem to affect %s.",
1656 pline("%s
\82Í
\93Å
\82Ì
\89e
\8b¿
\82ð
\8eó
\82¯
\82È
\82¢
\81D",
1662 if (vis && canspotmon(mdef))
1664 pline_The("poison was deadly...");
1666 pline("
\93Å
\82Í
\92v
\8e\80\97Ê
\82¾
\82Á
\82½
\81D
\81D
\81D");
1673 if (notonhead || !has_head(pd)) {
1674 if (vis && canspotmon(mdef))
1676 pline("%s doesn't seem harmed.", Monnam(mdef));
1678 pline("%s
\82Í
\8f\9d\82Â
\82¢
\82½
\82æ
\82¤
\82É
\82Í
\8c©
\82¦
\82È
\82¢
\81D", Monnam(mdef));
1679 /* Not clear what to do for green slimes */
1683 if ((mdef->misc_worn_check & W_ARMH) && rn2(8)) {
1684 if (vis && canspotmon(magr) && canseemon(mdef)) {
1685 Strcpy(buf, s_suffix(Monnam(mdef)));
1687 pline("%s helmet blocks %s attack to %s head.", buf,
1688 s_suffix(mon_nam(magr)), mhis(mdef));
1690 pline("%s
\82Ì
\8a\95\82Í%s
\82Ì
\93ª
\82Ö
\82Ì
\8dU
\8c\82\82ð
\96h
\82¢
\82¾
\81D", buf,
1696 res = eat_brains(magr, mdef, vis, &tmp);
1700 break; /* physical damage only */
1701 if (!rn2(4) && !slimeproof(pd)) {
1702 if (!munslime(mdef, FALSE) && !DEADMONSTER(mdef)) {
1703 if (newcham(mdef, &mons[PM_GREEN_SLIME], FALSE,
1704 (boolean) (vis && canseemon(mdef))))
1706 mdef->mstrategy &= ~STRAT_WAITFORU;
1709 /* munslime attempt could have been fatal,
1710 potentially to multiple monsters (SCR_FIRE) */
1711 if (DEADMONSTER(magr))
1713 if (DEADMONSTER(mdef))
1722 case AD_WRAP: /* monsters cannot grab one another, it's too hard */
1727 /* there's no msomearmor() function, so just do damage */
1728 /* if (cancelled) break; */
1737 if ((mdef->mhp -= tmp) < 1) {
1738 if (m_at(mdef->mx, mdef->my) == magr) { /* see gulpmm() */
1739 remove_monster(mdef->mx, mdef->my);
1740 mdef->mhp = 1; /* otherwise place_monster will complain */
1741 place_monster(mdef, mdef->mx, mdef->my);
1744 monkilled(mdef, "", (int) mattk->adtyp);
1745 if (!DEADMONSTER(mdef))
1746 return res; /* mdef lifesaved */
1747 else if (res == MM_AGR_DIED)
1748 return (MM_DEF_DIED | MM_AGR_DIED);
1750 if (mattk->adtyp == AD_DGST) {
1751 /* various checks similar to dog_eat and meatobj.
1752 * after monkilled() to provide better message ordering */
1753 if (mdef->cham >= LOW_PM) {
1754 (void) newcham(magr, (struct permonst *) 0, FALSE, TRUE);
1755 } else if (pd == &mons[PM_GREEN_SLIME] && !slimeproof(pa)) {
1756 (void) newcham(magr, &mons[PM_GREEN_SLIME], FALSE, TRUE);
1757 } else if (pd == &mons[PM_WRAITH]) {
1758 (void) grow_up(magr, (struct monst *) 0);
1759 /* don't grow up twice */
1760 return (MM_DEF_DIED | (!DEADMONSTER(magr) ? 0 : MM_AGR_DIED));
1761 } else if (pd == &mons[PM_NURSE]) {
1762 magr->mhp = magr->mhpmax;
1765 /* caveat: above digestion handling doesn't keep `pa' up to date */
1767 return (MM_DEF_DIED | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
1769 return (res == MM_AGR_DIED) ? MM_AGR_DIED : MM_HIT;
1773 paralyze_monst(mon, amt)
1782 mon->meating = 0; /* terminate any meal-in-progress */
1783 mon->mstrategy &= ~STRAT_WAITFORU;
1786 /* `mon' is hit by a sleep attack; return 1 if it's affected, 0 otherwise */
1788 sleep_monst(mon, amt, how)
1792 if (resists_sleep(mon)
1793 || (how >= 0 && resist(mon, (char) how, 0, NOTELL))) {
1794 shieldeff(mon->mx, mon->my);
1795 } else if (mon->mcanmove) {
1796 finish_meating(mon); /* terminate any meal-in-progress */
1797 amt += (int) mon->mfrozen;
1798 if (amt > 0) { /* sleep for N turns */
1800 mon->mfrozen = min(amt, 127);
1801 } else { /* sleep until awakened */
1809 /* sleeping grabber releases, engulfer doesn't; don't use for paralysis! */
1814 if ((mon->msleeping || !mon->mcanmove) && mon == u.ustuck
1815 && !sticks(youmonst.data) && !u.uswallow) {
1817 pline("%s grip relaxes.", s_suffix(Monnam(mon)));
1819 pline("%s
\82Ì
\88¬
\82é
\97Í
\82ª
\8eã
\82
\82È
\82Á
\82½
\81D", Monnam(mon));
1829 int dmgtyp = -1, chance = 1;
1832 return; /* just in case */
1833 /* AD_ACID and AD_ENCH are handled in passivemm() and passiveum() */
1834 if (dmgtype(mdef->data, AD_CORR)) {
1835 dmgtyp = ERODE_CORRODE;
1836 } else if (dmgtype(mdef->data, AD_RUST)) {
1837 dmgtyp = ERODE_RUST;
1838 } else if (dmgtype(mdef->data, AD_FIRE)
1839 /* steam vortex: fire resist applies, fire damage doesn't */
1840 && mdef->data != &mons[PM_STEAM_VORTEX]) {
1841 dmgtyp = ERODE_BURN;
1845 if (dmgtyp >= 0 && !rn2(chance))
1846 (void) erode_obj(obj, (char *) 0, dmgtyp, EF_GREASE | EF_VERBOSE);
1850 mswingsm(magr, mdef, otemp)
1851 struct monst *magr, *mdef;
1854 if (flags.verbose && !Blind && mon_visible(magr)) {
1856 pline("%s %s %s%s %s at %s.", Monnam(magr),
1857 (objects[otemp->otyp].oc_dir & PIERCE) ? "thrusts" : "swings",
1858 (otemp->quan > 1L) ? "one of " : "", mhis(magr), xname(otemp),
1861 pline((objects[otemp->otyp].oc_dir & PIERCE) ?
1862 "%s
\82Í%s
\82Å%s
\82ð
\93Ë
\82¢
\82½
\81D" :
1863 "%s
\82Í%s
\82ð
\90U
\82è
\82Ü
\82í
\82µ%s
\82ð
\8dU
\8c\82\82µ
\82½
\81D", Monnam(magr),
1864 xname(otemp), mon_nam(mdef));
1870 * Passive responses by defenders. Does not replicate responses already
1871 * handled above. Returns same values as mattackm.
1874 passivemm(magr, mdef, mhit, mdead)
1875 register struct monst *magr, *mdef;
1879 register struct permonst *mddat = mdef->data;
1880 register struct permonst *madat = magr->data;
1886 return (mdead | mhit); /* no passive attacks */
1887 if (mddat->mattk[i].aatyp == AT_NONE)
1890 if (mddat->mattk[i].damn)
1891 tmp = d((int) mddat->mattk[i].damn, (int) mddat->mattk[i].damd);
1892 else if (mddat->mattk[i].damd)
1893 tmp = d((int) mddat->mlevel + 1, (int) mddat->mattk[i].damd);
1897 /* These affect the enemy even if defender killed */
1898 switch (mddat->mattk[i].adtyp) {
1900 if (mhit && !rn2(2)) {
1901 Strcpy(buf, Monnam(magr));
1902 if (canseemon(magr))
1904 pline("%s is splashed by %s %s!", buf,
1905 s_suffix(mon_nam(mdef)), hliquid("acid"));
1907 pline("%s
\82Í%s
\82Ì%s
\82ð
\97\81\82Ñ
\82½
\81I", buf,
1908 mon_nam(mdef), hliquid("
\8e_"));
1910 if (resists_acid(magr)) {
1911 if (canseemon(magr))
1913 pline("%s is not affected.", Monnam(magr));
1915 pline("%s
\82Í
\89e
\8b¿
\82ð
\8eó
\82¯
\82È
\82¢
\81D", Monnam(magr));
1921 erode_armor(magr, ERODE_CORRODE);
1923 acid_damage(MON_WEP(magr));
1925 case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
1926 if (mhit && !mdef->mcan && otmp) {
1927 (void) drain_item(otmp, FALSE);
1934 if (mdead || mdef->mcan)
1935 return (mdead | mhit);
1937 /* These affect the enemy only if defender is still alive */
1939 switch (mddat->mattk[i].adtyp) {
1940 case AD_PLYS: /* Floating eye */
1943 if (mddat == &mons[PM_FLOATING_EYE]) {
1946 if (magr->mcansee && haseyes(madat) && mdef->mcansee
1947 && (perceives(madat) || !mdef->minvis)) {
1948 /* construct format string; guard against '%' in Monnam */
1950 Strcpy(buf, s_suffix(Monnam(mdef)));
1952 Strcpy(buf, Monnam(mdef));
1954 (void) strNsubst(buf, "%", "%%", 0);
1956 Strcat(buf, " gaze is reflected by %s %s.");
1958 Strcat(buf, "
\82Ì
\82É
\82ç
\82Ý
\82Í%s
\82É
\82æ
\82Á
\82Ä%s
\81D");
1959 if (mon_reflects(magr,
1960 canseemon(magr) ? buf : (char *) 0))
1961 return (mdead | mhit);
1962 Strcpy(buf, Monnam(magr));
1963 if (canseemon(magr))
1965 pline("%s is frozen by %s gaze!", buf,
1966 s_suffix(mon_nam(mdef)));
1968 pline("%s
\82Í%s
\82Ì
\82É
\82ç
\82Ý
\82Å
\93®
\82¯
\82È
\82
\82È
\82Á
\82½
\81I", buf,
1971 paralyze_monst(magr, tmp);
1972 return (mdead | mhit);
1974 } else { /* gelatinous cube */
1975 Strcpy(buf, Monnam(magr));
1976 if (canseemon(magr))
1978 pline("%s is frozen by %s.", buf, mon_nam(mdef));
1980 pline("%s
\82Í%s
\82É
\82æ
\82Á
\82Ä
\93®
\82¯
\82È
\82
\82È
\82Á
\82½
\81D", buf, mon_nam(mdef));
1981 paralyze_monst(magr, tmp);
1982 return (mdead | mhit);
1986 if (resists_cold(magr)) {
1987 if (canseemon(magr)) {
1989 pline("%s is mildly chilly.", Monnam(magr));
1991 pline("%s
\82Í
\97â
\82¦
\82½
\81D", Monnam(magr));
1992 golemeffects(magr, AD_COLD, tmp);
1997 if (canseemon(magr))
1999 pline("%s is suddenly very cold!", Monnam(magr));
2001 pline("%s
\82Í
\93Ë
\91R
\93\80\82è
\82Ã
\82¯
\82É
\82È
\82Á
\82½
\81I", Monnam(magr));
2002 mdef->mhp += tmp / 2;
2003 if (mdef->mhpmax < mdef->mhp)
2004 mdef->mhpmax = mdef->mhp;
2005 if (mdef->mhpmax > ((int) (mdef->m_lev + 1) * 8))
2006 (void) split_mon(mdef, magr);
2011 if (canseemon(magr))
2013 pline("%s %s...", Monnam(magr),
2014 makeplural(stagger(magr->data, "stagger")));
2016 pline("%s
\82Í%s
\81D
\81D
\81D", Monnam(magr),
2017 jpast(stagger(magr->data, "
\82æ
\82ë
\82ß
\82")));
2023 if (resists_fire(magr)) {
2024 if (canseemon(magr)) {
2026 pline("%s is mildly warmed.", Monnam(magr));
2028 pline("%s
\82Í
\92g
\82©
\82
\82È
\82Á
\82½
\81D", Monnam(magr));
2029 golemeffects(magr, AD_FIRE, tmp);
2034 if (canseemon(magr))
2036 pline("%s is suddenly very hot!", Monnam(magr));
2038 pline("%s
\82Í
\93Ë
\91R
\82Æ
\82Ä
\82à
\94M
\82
\82È
\82Á
\82½
\81I", Monnam(magr));
2041 if (resists_elec(magr)) {
2042 if (canseemon(magr)) {
2044 pline("%s is mildly tingled.", Monnam(magr));
2046 pline("%s
\82Í
\83s
\83\8a\83s
\83\8a\82µ
\82Ä
\82¢
\82é
\81D", Monnam(magr));
2047 golemeffects(magr, AD_ELEC, tmp);
2052 if (canseemon(magr))
2054 pline("%s is jolted with electricity!", Monnam(magr));
2056 pline("%s
\82Í
\93d
\8bC
\83V
\83\87\83b
\83N
\82ð
\82¤
\82¯
\82½
\81I", Monnam(magr));
2066 if ((magr->mhp -= tmp) <= 0) {
2067 monkilled(magr, "", (int) mddat->mattk[i].adtyp);
2068 return (mdead | mhit | MM_AGR_DIED);
2070 return (mdead | mhit);
2073 /* hero or monster has successfully hit target mon with drain energy attack */
2075 xdrainenergym(mon, givemsg)
2079 if (mon->mspec_used < 20 /* limit draining */
2080 && (attacktype(mon->data, AT_MAGC)
2081 || attacktype(mon->data, AT_BREA))) {
2082 mon->mspec_used += d(2, 2);
2085 pline("%s seems lethargic.", Monnam(mon));
2087 pline("%s
\82Í
\96³
\8bC
\97Í
\82É
\82È
\82Á
\82½
\82æ
\82¤
\82¾
\81D", Monnam(mon));
2091 /* "aggressive defense"; what type of armor prevents specified attack
2092 from touching its target? */
2094 attk_protection(aatyp)
2107 w_mask = ~0L; /* special case; no defense needed */
2112 w_mask = W_ARMG; /* caller needs to check for weapon */
2121 w_mask = (W_ARMC | W_ARMG); /* attacker needs both to be protected */
2128 w_mask = 0L; /* no defense available */