1 /* NetHack 3.6 mhitm.c $NHDT-Date: 1470819842 2016/08/10 09:04:02 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.92 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
8 extern boolean notonhead
;
10 static NEARDATA boolean vis
, far_noise
;
11 static NEARDATA
long noisetime
;
12 static NEARDATA
struct obj
*otmp
;
14 static const char brief_feeling
[] =
15 "have a %s feeling for a moment, then it passes.";
17 STATIC_DCL
char *FDECL(mon_nam_too
, (char *, struct monst
*, struct monst
*));
18 STATIC_DCL
int FDECL(hitmm
, (struct monst
*, struct monst
*,
20 STATIC_DCL
int FDECL(gazemm
, (struct monst
*, struct monst
*,
22 STATIC_DCL
int FDECL(gulpmm
, (struct monst
*, struct monst
*,
24 STATIC_DCL
int FDECL(explmm
, (struct monst
*, struct monst
*,
26 STATIC_DCL
int FDECL(mdamagem
, (struct monst
*, struct monst
*,
28 STATIC_DCL
void FDECL(mswingsm
, (struct monst
*, struct monst
*,
30 STATIC_DCL
void FDECL(noises
, (struct monst
*, struct attack
*));
31 STATIC_DCL
void FDECL(missmm
, (struct monst
*, struct monst
*,
33 STATIC_DCL
int FDECL(passivemm
, (struct monst
*, struct monst
*,
36 /* Needed for the special case of monsters wielding vorpal blades (rare).
37 * If we use this a lot it should probably be a parameter to mdamagem()
38 * instead of a global variable.
42 /* returns mon_nam(mon) relative to other_mon; normal name unless they're
43 the same, in which case the reference is to {him|her|it} self */
45 mon_nam_too(outbuf
, mon
, other_mon
)
47 struct monst
*mon
, *other_mon
;
49 Strcpy(outbuf
, mon_nam(mon
));
51 switch (pronoun_gender(mon
)) {
53 Strcpy(outbuf
, "himself");
56 Strcpy(outbuf
, "herself");
59 Strcpy(outbuf
, "itself");
67 register struct monst
*magr
;
68 register struct attack
*mattk
;
70 boolean farq
= (distu(magr
->mx
, magr
->my
) > 15);
72 if (!Deaf
&& (farq
!= far_noise
|| moves
- noisetime
> 10)) {
76 (mattk
->aatyp
== AT_EXPL
) ? "an explosion" : "some noises",
77 farq
? " in the distance" : "");
83 missmm(magr
, mdef
, mattk
)
84 register struct monst
*magr
, *mdef
;
88 char buf
[BUFSZ
], mdef_name
[BUFSZ
];
91 if (!canspotmon(magr
))
92 map_invisible(magr
->mx
, magr
->my
);
93 if (!canspotmon(mdef
))
94 map_invisible(mdef
->mx
, mdef
->my
);
99 fmt
= (could_seduce(magr
, mdef
, mattk
) && !magr
->mcan
)
100 ? "%s pretends to be friendly to"
102 Sprintf(buf
, fmt
, Monnam(magr
));
103 pline("%s %s.", buf
, mon_nam_too(mdef_name
, mdef
, magr
));
109 * fightm() -- fight some other monster
112 * 0 - Monster did nothing.
113 * 1 - If the monster made an attack. The monster might have died.
115 * There is an exception to the above. If mtmp has the hero swallowed,
116 * then we report that the monster did nothing so it will continue to
119 /* have monsters fight each other */
122 register struct monst
*mtmp
;
124 register struct monst
*mon
, *nmon
;
125 int result
, has_u_swallowed
;
129 /* perhaps the monster will resist Conflict */
130 if (resist(mtmp
, RING_CLASS
, 0, 0))
133 if (u
.ustuck
== mtmp
) {
134 /* perhaps we're holding it... */
138 has_u_swallowed
= (u
.uswallow
&& (mtmp
== u
.ustuck
));
140 for (mon
= fmon
; mon
; mon
= nmon
) {
144 /* Be careful to ignore monsters that are already dead, since we
145 * might be calling this before we've cleaned them up. This can
146 * happen if the monster attacked a cockatrice bare-handedly, for
149 if (mon
!= mtmp
&& !DEADMONSTER(mon
)) {
150 if (monnear(mtmp
, mon
->mx
, mon
->my
)) {
151 if (!u
.uswallow
&& (mtmp
== u
.ustuck
)) {
153 pline("%s releases you!", Monnam(mtmp
));
159 /* mtmp can be killed */
163 result
= mattackm(mtmp
, mon
);
165 if (result
& MM_AGR_DIED
)
166 return 1; /* mtmp died */
168 * If mtmp has the hero swallowed, lie and say there
169 * was no attack (this allows mtmp to digest the hero).
174 /* Allow attacked monsters a chance to hit back. Primarily
175 * to allow monsters that resist conflict to respond.
177 if ((result
& MM_HIT
) && !(result
& MM_DEF_DIED
) && rn2(4)
178 && mon
->movement
>= NORMAL_SPEED
) {
179 mon
->movement
-= NORMAL_SPEED
;
181 (void) mattackm(mon
, mtmp
); /* return attack */
184 return (result
& MM_HIT
) ? 1 : 0;
192 * mdisplacem() -- attacker moves defender out of the way;
193 * returns same results as mattackm().
196 mdisplacem(magr
, mdef
, quietly
)
197 register struct monst
*magr
, *mdef
;
200 struct permonst
*pa
, *pd
;
203 /* sanity checks; could matter if we unexpectedly get a long worm */
204 if (!magr
|| !mdef
|| magr
== mdef
)
206 pa
= magr
->data
, pd
= mdef
->data
;
207 tx
= mdef
->mx
, ty
= mdef
->my
; /* destination */
208 fx
= magr
->mx
, fy
= magr
->my
; /* current location */
209 if (m_at(fx
, fy
) != magr
|| m_at(tx
, ty
) != mdef
)
212 /* The 1 in 7 failure below matches the chance in attack()
213 * for pet displacement.
218 /* Grid bugs cannot displace at an angle. */
219 if (pa
== &mons
[PM_GRID_BUG
] && magr
->mx
!= mdef
->mx
220 && magr
->my
!= mdef
->my
)
223 /* undetected monster becomes un-hidden if it is displaced */
224 if (mdef
->mundetected
)
225 mdef
->mundetected
= 0;
226 if (mdef
->m_ap_type
&& mdef
->m_ap_type
!= M_AP_MONSTER
)
228 /* wake up the displaced defender */
230 mdef
->mstrategy
&= ~STRAT_WAITMASK
;
231 finish_meating(mdef
);
234 * Set up the visibility of action.
235 * You can observe monster displacement if you can see both of
236 * the monsters involved.
238 vis
= (canspotmon(magr
) && canspotmon(mdef
));
240 if (touch_petrifies(pd
) && !resists_ston(magr
)) {
241 if (which_armor(magr
, W_ARMG
) != 0) {
242 if (poly_when_stoned(pa
)) {
244 return MM_HIT
; /* no damage during the polymorph */
246 if (!quietly
&& canspotmon(magr
))
247 pline("%s turns to stone!", Monnam(magr
));
250 return MM_HIT
; /* lifesaved */
251 else if (magr
->mtame
&& !vis
)
252 You(brief_feeling
, "peculiarly sad");
257 remove_monster(fx
, fy
); /* pick up from orig position */
258 remove_monster(tx
, ty
);
259 place_monster(magr
, tx
, ty
); /* put down at target spot */
260 place_monster(mdef
, fx
, fy
);
262 pline("%s moves %s out of %s way!", Monnam(magr
), mon_nam(mdef
),
263 is_rider(pa
) ? "the" : mhis(magr
));
264 newsym(fx
, fy
); /* see it */
265 newsym(tx
, ty
); /* all happen */
266 flush_screen(0); /* make sure it shows up */
272 * mattackm() -- a monster attacks another monster.
274 * --------- aggressor died
275 * / ------- defender died
276 * / / ----- defender was hit
285 * Each successive attack has a lower probability of hitting. Some rely on
286 * success of previous attacks. ** this doen't seem to be implemented -dl **
288 * In the case of exploding monsters, the monster dies as well.
292 register struct monst
*magr
, *mdef
;
294 int i
, /* loop counter */
295 tmp
, /* amour class difference */
296 strike
= 0, /* hit this attack */
297 attk
, /* attack attempted this time */
298 struck
= 0, /* hit at least once */
299 res
[NATTK
]; /* results of all attacks */
300 struct attack
*mattk
, alt_attk
;
301 struct permonst
*pa
, *pd
;
304 return MM_MISS
; /* mike@genat */
305 if (!magr
->mcanmove
|| magr
->msleeping
)
310 /* Grid bugs cannot attack at an angle. */
311 if (pa
== &mons
[PM_GRID_BUG
] && magr
->mx
!= mdef
->mx
312 && magr
->my
!= mdef
->my
)
315 /* Calculate the armour class differential. */
316 tmp
= find_mac(mdef
) + magr
->m_lev
;
317 if (mdef
->mconf
|| !mdef
->mcanmove
|| mdef
->msleeping
) {
322 /* undetect monsters become un-hidden if they are attacked */
323 if (mdef
->mundetected
) {
324 mdef
->mundetected
= 0;
325 newsym(mdef
->mx
, mdef
->my
);
326 if (canseemon(mdef
) && !sensemon(mdef
)) {
328 You("dream of %s.", (mdef
->data
->geno
& G_UNIQ
)
330 : makeplural(m_monnam(mdef
)));
332 pline("Suddenly, you notice %s.", a_monnam(mdef
));
336 /* Elves hate orcs. */
337 if (is_elf(pa
) && is_orc(pd
))
340 /* Set up the visibility of action */
341 vis
= (cansee(magr
->mx
, magr
->my
) && cansee(mdef
->mx
, mdef
->my
)
342 && (canspotmon(magr
) || canspotmon(mdef
)));
344 /* Set flag indicating monster has moved this turn. Necessary since a
345 * monster might get an attack out of sequence (i.e. before its move) in
346 * some cases, in which case this still counts as its move for the round
347 * and it shouldn't move again.
349 magr
->mlstmv
= monstermoves
;
351 /* Now perform all attacks for the monster. */
352 for (i
= 0; i
< NATTK
; i
++) {
354 mattk
= getmattk(magr
, mdef
, i
, res
, &alt_attk
);
355 otmp
= (struct obj
*) 0;
357 switch (mattk
->aatyp
) {
358 case AT_WEAP
: /* "hand to hand" attacks */
359 if (distmin(magr
->mx
, magr
->my
, mdef
->mx
, mdef
->my
) > 1) {
360 /* D: Do a ranged attack here! */
361 strike
= thrwmm(magr
, mdef
);
362 if (DEADMONSTER(mdef
))
363 res
[i
] = MM_DEF_DIED
;
364 if (DEADMONSTER(magr
))
365 res
[i
] |= MM_AGR_DIED
;
368 if (magr
->weapon_check
== NEED_WEAPON
|| !MON_WEP(magr
)) {
369 magr
->weapon_check
= NEED_HTH_WEAPON
;
370 if (mon_wield_item(magr
) != 0)
373 possibly_unwield(magr
, FALSE
);
374 otmp
= MON_WEP(magr
);
378 mswingsm(magr
, mdef
, otmp
);
379 tmp
+= hitval(otmp
, mdef
);
389 /* Nymph that teleported away on first attack? */
390 if (distmin(magr
->mx
, magr
->my
, mdef
->mx
, mdef
->my
) > 1)
391 /* Continue because the monster may have a ranged attack. */
393 /* Monsters won't attack cockatrices physically if they
394 * have a weapon instead. This instinct doesn't work for
395 * players, or under conflict or confusion.
397 if (!magr
->mconf
&& !Conflict
&& otmp
&& mattk
->aatyp
!= AT_WEAP
398 && touch_petrifies(mdef
->data
)) {
402 dieroll
= rnd(20 + i
);
403 strike
= (tmp
> dieroll
);
404 /* KMH -- don't accumulate to-hit bonuses */
406 tmp
-= hitval(otmp
, mdef
);
408 res
[i
] = hitmm(magr
, mdef
, mattk
);
409 if ((mdef
->data
== &mons
[PM_BLACK_PUDDING
]
410 || mdef
->data
== &mons
[PM_BROWN_PUDDING
]) && otmp
411 && objects
[otmp
->otyp
].oc_material
== IRON
414 if (clone_mon(mdef
, 0, 0)) {
415 if (vis
&& canspotmon(mdef
)) {
418 Strcpy(buf
, Monnam(mdef
));
419 pline("%s divides as %s hits it!", buf
,
425 missmm(magr
, mdef
, mattk
);
428 case AT_HUGS
: /* automatic if prev two attacks succeed */
429 strike
= (i
>= 2 && res
[i
- 1] == MM_HIT
&& res
[i
- 2] == MM_HIT
);
431 res
[i
] = hitmm(magr
, mdef
, mattk
);
437 res
[i
] = gazemm(magr
, mdef
, mattk
);
441 /* D: Prevent explosions from a distance */
442 if (distmin(magr
->mx
,magr
->my
,mdef
->mx
,mdef
->my
) > 1)
445 res
[i
] = explmm(magr
, mdef
, mattk
);
446 if (res
[i
] == MM_MISS
) { /* cancelled--no attack */
450 strike
= 1; /* automatic hit */
454 if (u
.usteed
&& mdef
== u
.usteed
) {
458 /* D: Prevent engulf from a distance */
459 if (distmin(magr
->mx
, magr
->my
, mdef
->mx
, mdef
->my
) > 1)
461 /* Engulfing attacks are directed at the hero if possible. -dlc */
462 if (u
.uswallow
&& magr
== u
.ustuck
)
464 else if ((strike
= (tmp
> rnd(20 + i
))) != 0)
465 res
[i
] = gulpmm(magr
, mdef
, mattk
);
467 missmm(magr
, mdef
, mattk
);
471 if (!monnear(magr
, mdef
->mx
, mdef
->my
)) {
472 strike
= breamm(magr
, mattk
, mdef
);
474 /* We don't really know if we hit or not; pretend we did. */
477 if (DEADMONSTER(mdef
))
478 res
[i
] = MM_DEF_DIED
;
479 if (DEADMONSTER(magr
))
480 res
[i
] |= MM_AGR_DIED
;
487 if (!monnear(magr
, mdef
->mx
, mdef
->my
)) {
488 strike
= spitmm(magr
, mattk
, mdef
);
490 /* We don't really know if we hit or not; pretend we did. */
493 if (DEADMONSTER(mdef
))
494 res
[i
] = MM_DEF_DIED
;
495 if (DEADMONSTER(magr
))
496 res
[i
] |= MM_AGR_DIED
;
500 default: /* no attack */
506 if (attk
&& !(res
[i
] & MM_AGR_DIED
)
507 && distmin(magr
->mx
, magr
->my
, mdef
->mx
, mdef
->my
) <= 1)
508 res
[i
] = passivemm(magr
, mdef
, strike
, res
[i
] & MM_DEF_DIED
);
510 if (res
[i
] & MM_DEF_DIED
)
512 if (res
[i
] & MM_AGR_DIED
)
514 /* return if aggressor can no longer attack */
515 if (!magr
->mcanmove
|| magr
->msleeping
)
518 struck
= 1; /* at least one hit */
521 return (struck
? MM_HIT
: MM_MISS
);
524 /* Returns the result of mdamagem(). */
526 hitmm(magr
, mdef
, mattk
)
527 register struct monst
*magr
, *mdef
;
528 struct attack
*mattk
;
532 char buf
[BUFSZ
], mdef_name
[BUFSZ
];
534 if (!canspotmon(magr
))
535 map_invisible(magr
->mx
, magr
->my
);
536 if (!canspotmon(mdef
))
537 map_invisible(mdef
->mx
, mdef
->my
);
542 if ((compat
= could_seduce(magr
, mdef
, mattk
)) && !magr
->mcan
) {
543 Sprintf(buf
, "%s %s", Monnam(magr
),
544 mdef
->mcansee
? "smiles at" : "talks to");
545 pline("%s %s %s.", buf
, mon_nam(mdef
),
546 compat
== 2 ? "engagingly" : "seductively");
548 char magr_name
[BUFSZ
];
550 Strcpy(magr_name
, Monnam(magr
));
551 switch (mattk
->aatyp
) {
553 Sprintf(buf
, "%s bites", magr_name
);
556 Sprintf(buf
, "%s stings", magr_name
);
559 Sprintf(buf
, "%s butts", magr_name
);
562 Sprintf(buf
, "%s touches", magr_name
);
565 Sprintf(buf
, "%s tentacles suck", s_suffix(magr_name
));
568 if (magr
!= u
.ustuck
) {
569 Sprintf(buf
, "%s squeezes", magr_name
);
573 Sprintf(buf
, "%s hits", magr_name
);
575 pline("%s %s.", buf
, mon_nam_too(mdef_name
, mdef
, magr
));
580 return mdamagem(magr
, mdef
, mattk
);
583 /* Returns the same values as mdamagem(). */
585 gazemm(magr
, mdef
, mattk
)
586 register struct monst
*magr
, *mdef
;
587 struct attack
*mattk
;
592 if (mdef
->data
->mlet
== S_MIMIC
593 && mdef
->m_ap_type
!= M_AP_NOTHING
)
595 Sprintf(buf
, "%s gazes at", Monnam(magr
));
596 pline("%s %s...", buf
,
597 canspotmon(mdef
) ? mon_nam(mdef
) : "something");
600 if (magr
->mcan
|| !magr
->mcansee
|| !mdef
->mcansee
601 || (magr
->minvis
&& !perceives(mdef
->data
)) || mdef
->msleeping
) {
602 if (vis
&& canspotmon(mdef
))
603 pline("but nothing happens.");
606 /* call mon_reflects 2x, first test, then, if visible, print message */
607 if (magr
->data
== &mons
[PM_MEDUSA
] && mon_reflects(mdef
, (char *) 0)) {
609 (void) mon_reflects(mdef
, "The gaze is reflected away by %s %s.");
611 if (mon_reflects(magr
, (char *) 0)) {
613 (void) mon_reflects(magr
,
614 "The gaze is reflected away by %s %s.");
617 if (mdef
->minvis
&& !perceives(magr
->data
)) {
618 if (canseemon(magr
)) {
620 "%s doesn't seem to notice that %s gaze was reflected.",
621 Monnam(magr
), mhis(magr
));
626 pline("%s is turned to stone!", Monnam(magr
));
634 return mdamagem(magr
, mdef
, mattk
);
637 /* return True if magr is allowed to swallow mdef, False otherwise */
639 engulf_target(magr
, mdef
)
640 struct monst
*magr
, *mdef
;
645 /* can't swallow something that's too big */
646 if (mdef
->data
->msize
>= MZ_HUGE
)
649 /* (hypothetical) engulfers who can pass through walls aren't
650 limited by rock|trees|bars */
651 if ((magr
== &youmonst
) ? Passes_walls
: passes_walls(magr
->data
))
654 /* don't swallow something in a spot where attacker wouldn't
655 otherwise be able to move onto; we don't want to engulf
656 a wall-phaser and end up with a non-phaser inside a wall */
657 dx
= mdef
->mx
, dy
= mdef
->my
;
658 if (mdef
== &youmonst
)
659 dx
= u
.ux
, dy
= u
.uy
;
661 if (IS_ROCK(lev
->typ
) || closed_door(dx
, dy
) || IS_TREE(lev
->typ
)
662 /* not passes_bars(); engulfer isn't squeezing through */
663 || (lev
->typ
== IRONBARS
&& !is_whirly(magr
->data
)))
669 /* Returns the same values as mattackm(). */
671 gulpmm(magr
, mdef
, mattk
)
672 register struct monst
*magr
, *mdef
;
673 register struct attack
*mattk
;
675 xchar ax
, ay
, dx
, dy
;
680 if (!engulf_target(magr
, mdef
))
684 /* [this two-part formatting dates back to when only one x_monnam
685 result could be included in an expression because the next one
686 would overwrite first's result -- that's no longer the case] */
687 Sprintf(buf
, "%s swallows", Monnam(magr
));
688 pline("%s %s.", buf
, mon_nam(mdef
));
690 for (obj
= mdef
->minvent
; obj
; obj
= obj
->nobj
)
691 (void) snuff_lit(obj
);
693 if (is_vampshifter(mdef
)
694 && newcham(mdef
, &mons
[mdef
->cham
], FALSE
, FALSE
)) {
696 /* 'it' -- previous form is no longer available and
697 using that would be excessively verbose */
698 pline("%s expels %s.", Monnam(magr
),
699 canspotmon(mdef
) ? "it" : something
);
700 if (canspotmon(mdef
))
701 pline("It turns into %s.", a_monnam(mdef
));
703 return MM_HIT
; /* bypass mdamagem() */
707 * All of this manipulation is needed to keep the display correct.
708 * There is a flush at the next pline().
715 * Leave the defender in the monster chain at it's current position,
716 * but don't leave it on the screen. Move the aggressor to the
717 * defender's position.
719 remove_monster(ax
, ay
);
720 place_monster(magr
, dx
, dy
);
721 newsym(ax
, ay
); /* erase old position */
722 newsym(dx
, dy
); /* update new position */
724 status
= mdamagem(magr
, mdef
, mattk
);
726 if ((status
& (MM_AGR_DIED
| MM_DEF_DIED
))
727 == (MM_AGR_DIED
| MM_DEF_DIED
)) {
728 ; /* both died -- do nothing */
729 } else if (status
& MM_DEF_DIED
) { /* defender died */
731 * Note: remove_monster() was called in relmon(), wiping out
732 * magr from level.monsters[mdef->mx][mdef->my]. We need to
733 * put it back and display it. -kd
735 place_monster(magr
, dx
, dy
);
737 /* aggressor moves to <dx,dy> and might encounter trouble there */
738 if (minliquid(magr
) || (t_at(dx
, dy
) && mintrap(magr
) == 2))
739 status
|= MM_AGR_DIED
;
740 } else if (status
& MM_AGR_DIED
) { /* aggressor died */
741 place_monster(mdef
, dx
, dy
);
743 } else { /* both alive, put them back */
745 pline("%s is regurgitated!", Monnam(mdef
));
747 place_monster(magr
, ax
, ay
);
748 place_monster(mdef
, dx
, dy
);
757 explmm(magr
, mdef
, mattk
)
758 struct monst
*magr
, *mdef
;
759 struct attack
*mattk
;
766 if (cansee(magr
->mx
, magr
->my
))
767 pline("%s explodes!", Monnam(magr
));
771 result
= mdamagem(magr
, mdef
, mattk
);
773 /* Kill off aggressor if it didn't die. */
774 if (!(result
& MM_AGR_DIED
)) {
777 return result
; /* life saved */
778 result
|= MM_AGR_DIED
;
780 if (magr
->mtame
) /* give this one even if it was visible */
781 You(brief_feeling
, "melancholy");
787 * See comment at top of mattackm(), for return values.
790 mdamagem(magr
, mdef
, mattk
)
791 register struct monst
*magr
, *mdef
;
792 register struct attack
*mattk
;
796 struct permonst
*pa
= magr
->data
, *pd
= mdef
->data
;
797 int armpro
, num
, tmp
= d((int) mattk
->damn
, (int) mattk
->damd
),
801 if ((touch_petrifies(pd
) /* or flesh_petrifies() */
802 || (mattk
->adtyp
== AD_DGST
&& pd
== &mons
[PM_MEDUSA
]))
803 && !resists_ston(magr
)) {
804 long protector
= attk_protection((int) mattk
->aatyp
),
805 wornitems
= magr
->misc_worn_check
;
807 /* wielded weapon gives same protection as gloves here */
812 || (protector
!= ~0L && (wornitems
& protector
) != protector
)) {
813 if (poly_when_stoned(pa
)) {
815 return MM_HIT
; /* no damage during the polymorph */
817 if (vis
&& canspotmon(magr
))
818 pline("%s turns to stone!", Monnam(magr
));
821 return MM_HIT
; /* lifesaved */
822 else if (magr
->mtame
&& !vis
)
823 You(brief_feeling
, "peculiarly sad");
828 /* cancellation factor is the same as when attacking the hero */
829 armpro
= magic_negation(mdef
);
830 cancelled
= magr
->mcan
|| !(rn2(10) >= 3 * armpro
);
832 switch (mattk
->adtyp
) {
834 /* eating a Rider or its corpse is fatal */
836 if (vis
&& canseemon(magr
))
837 pline("%s %s!", Monnam(magr
),
838 (pd
== &mons
[PM_FAMINE
])
839 ? "belches feebly, shrivels up and dies"
840 : (pd
== &mons
[PM_PESTILENCE
])
841 ? "coughs spasmodically and collapses"
842 : "vomits violently and drops dead");
845 return 0; /* lifesaved */
846 else if (magr
->mtame
&& !vis
)
847 You(brief_feeling
, "queasy");
850 if (flags
.verbose
&& !Deaf
)
851 verbalize("Burrrrp!");
853 /* Use up amulet of life saving */
854 if (!!(obj
= mlifesaver(mdef
)))
857 /* Is a corpse for nutrition possible? It may kill magr */
858 if (!corpse_chance(mdef
, magr
, TRUE
) || magr
->mhp
< 1)
861 /* Pets get nutrition from swallowing monster whole.
862 * No nutrition from G_NOCORPSE monster, eg, undead.
863 * DGST monsters don't die from undead corpses
866 if (magr
->mtame
&& !magr
->isminion
867 && !(mvitals
[num
].mvflags
& G_NOCORPSE
)) {
868 struct obj
*virtualcorpse
= mksobj(CORPSE
, FALSE
, FALSE
);
871 set_corpsenm(virtualcorpse
, num
);
872 nutrit
= dog_nutrition(magr
, virtualcorpse
);
873 dealloc_obj(virtualcorpse
);
875 /* only 50% nutrition, 25% of normal eating time */
876 if (magr
->meating
> 1)
877 magr
->meating
= (magr
->meating
+ 3) / 4;
880 EDOG(magr
)->hungrytime
+= nutrit
;
887 pline("%s %s for a moment.", Monnam(mdef
),
888 makeplural(stagger(pd
, "stagger")));
901 if (mattk
->aatyp
== AT_KICK
&& thick_skinned(pd
)) {
903 } else if (mattk
->aatyp
== AT_WEAP
) {
905 if (otmp
->otyp
== CORPSE
906 && touch_petrifies(&mons
[otmp
->corpsenm
]))
908 tmp
+= dmgval(otmp
, mdef
);
909 if (otmp
->oartifact
) {
910 (void) artifact_hit(magr
, mdef
, otmp
, &tmp
, dieroll
);
913 | (grow_up(magr
, mdef
) ? 0 : MM_AGR_DIED
));
918 } else if (pa
== &mons
[PM_PURPLE_WORM
] && pd
== &mons
[PM_SHRIEKER
]) {
919 /* hack to enhance mm_aggression(); we don't want purple
920 worm's bite attack to kill a shrieker because then it
921 won't swallow the corpse; but if the target survives,
922 the subsequent engulf attack should accomplish that */
923 if (tmp
>= mdef
->mhp
&& mdef
->mhp
> 1)
932 if (vis
&& canseemon(mdef
))
933 pline("%s is %s!", Monnam(mdef
), on_fire(pd
, mattk
));
934 if (pd
== &mons
[PM_STRAW_GOLEM
] || pd
== &mons
[PM_PAPER_GOLEM
]) {
935 if (vis
&& canseemon(mdef
))
936 pline("%s burns completely!", Monnam(mdef
));
940 else if (mdef
->mtame
&& !vis
)
941 pline("May %s roast in peace.", mon_nam(mdef
));
942 return (MM_DEF_DIED
| (grow_up(magr
, mdef
) ? 0 : MM_AGR_DIED
));
944 tmp
+= destroy_mitem(mdef
, SCROLL_CLASS
, AD_FIRE
);
945 tmp
+= destroy_mitem(mdef
, SPBOOK_CLASS
, AD_FIRE
);
946 if (resists_fire(mdef
)) {
947 if (vis
&& canseemon(mdef
))
948 pline_The("fire doesn't seem to burn %s!", mon_nam(mdef
));
949 shieldeff(mdef
->mx
, mdef
->my
);
950 golemeffects(mdef
, AD_FIRE
, tmp
);
953 /* only potions damage resistant players in destroy_item */
954 tmp
+= destroy_mitem(mdef
, POTION_CLASS
, AD_FIRE
);
961 if (vis
&& canseemon(mdef
))
962 pline("%s is covered in frost!", Monnam(mdef
));
963 if (resists_cold(mdef
)) {
964 if (vis
&& canseemon(mdef
))
965 pline_The("frost doesn't seem to chill %s!", mon_nam(mdef
));
966 shieldeff(mdef
->mx
, mdef
->my
);
967 golemeffects(mdef
, AD_COLD
, tmp
);
970 tmp
+= destroy_mitem(mdef
, POTION_CLASS
, AD_COLD
);
977 if (vis
&& canseemon(mdef
))
978 pline("%s gets zapped!", Monnam(mdef
));
979 tmp
+= destroy_mitem(mdef
, WAND_CLASS
, AD_ELEC
);
980 if (resists_elec(mdef
)) {
981 if (vis
&& canseemon(mdef
))
982 pline_The("zap doesn't shock %s!", mon_nam(mdef
));
983 shieldeff(mdef
->mx
, mdef
->my
);
984 golemeffects(mdef
, AD_ELEC
, tmp
);
987 /* only rings damage resistant players in destroy_item */
988 tmp
+= destroy_mitem(mdef
, RING_CLASS
, AD_ELEC
);
995 if (resists_acid(mdef
)) {
996 if (vis
&& canseemon(mdef
))
997 pline("%s is covered in %s, but it seems harmless.",
998 Monnam(mdef
), hliquid("acid"));
1000 } else if (vis
&& canseemon(mdef
)) {
1001 pline("%s is covered in %s!", Monnam(mdef
), hliquid("acid"));
1002 pline("It burns %s!", mon_nam(mdef
));
1005 erode_armor(mdef
, ERODE_CORRODE
);
1007 acid_damage(MON_WEP(mdef
));
1012 if (pd
== &mons
[PM_IRON_GOLEM
]) {
1013 if (vis
&& canseemon(mdef
))
1014 pline("%s falls to pieces!", Monnam(mdef
));
1018 else if (mdef
->mtame
&& !vis
)
1019 pline("May %s rust in peace.", mon_nam(mdef
));
1020 return (MM_DEF_DIED
| (grow_up(magr
, mdef
) ? 0 : MM_AGR_DIED
));
1022 erode_armor(mdef
, ERODE_RUST
);
1023 mdef
->mstrategy
&= ~STRAT_WAITFORU
;
1029 erode_armor(mdef
, ERODE_CORRODE
);
1030 mdef
->mstrategy
&= ~STRAT_WAITFORU
;
1036 if (pd
== &mons
[PM_WOOD_GOLEM
] || pd
== &mons
[PM_LEATHER_GOLEM
]) {
1037 if (vis
&& canseemon(mdef
))
1038 pline("%s falls to pieces!", Monnam(mdef
));
1042 else if (mdef
->mtame
&& !vis
)
1043 pline("May %s rot in peace.", mon_nam(mdef
));
1044 return (MM_DEF_DIED
| (grow_up(magr
, mdef
) ? 0 : MM_AGR_DIED
));
1046 erode_armor(mdef
, ERODE_CORRODE
);
1047 mdef
->mstrategy
&= ~STRAT_WAITFORU
;
1054 /* may die from the acid if it eats a stone-curing corpse */
1055 if (munstone(mdef
, FALSE
))
1057 if (poly_when_stoned(pd
)) {
1062 if (!resists_ston(mdef
)) {
1063 if (vis
&& canseemon(mdef
))
1064 pline("%s turns to stone!", Monnam(mdef
));
1069 else if (mdef
->mtame
&& !vis
)
1070 You(brief_feeling
, "peculiarly sad");
1071 return (MM_DEF_DIED
| (grow_up(magr
, mdef
) ? 0 : MM_AGR_DIED
));
1073 tmp
= (mattk
->adtyp
== AD_STON
? 0 : 1);
1076 if (!cancelled
&& tmp
< mdef
->mhp
&& !tele_restrict(mdef
)) {
1077 char mdef_Monnam
[BUFSZ
];
1078 boolean wasseen
= canspotmon(mdef
);
1079 /* save the name before monster teleports, otherwise
1080 we'll get "it" in the suddenly disappears message */
1082 Strcpy(mdef_Monnam
, Monnam(mdef
));
1083 mdef
->mstrategy
&= ~STRAT_WAITFORU
;
1084 (void) rloc(mdef
, TRUE
);
1085 if (vis
&& wasseen
&& !canspotmon(mdef
) && mdef
!= u
.usteed
)
1086 pline("%s suddenly disappears!", mdef_Monnam
);
1090 if (!cancelled
&& !mdef
->msleeping
1091 && sleep_monst(mdef
, rnd(10), -1)) {
1092 if (vis
&& canspotmon(mdef
)) {
1093 Strcpy(buf
, Monnam(mdef
));
1094 pline("%s is put to sleep by %s.", buf
, mon_nam(magr
));
1096 mdef
->mstrategy
&= ~STRAT_WAITFORU
;
1101 if (!cancelled
&& mdef
->mcanmove
) {
1102 if (vis
&& canspotmon(mdef
)) {
1103 Strcpy(buf
, Monnam(mdef
));
1104 pline("%s is frozen by %s.", buf
, mon_nam(magr
));
1106 paralyze_monst(mdef
, rnd(10));
1110 if (!cancelled
&& mdef
->mspeed
!= MSLOW
) {
1111 unsigned int oldspeed
= mdef
->mspeed
;
1113 mon_adjust_speed(mdef
, -1, (struct obj
*) 0);
1114 mdef
->mstrategy
&= ~STRAT_WAITFORU
;
1115 if (mdef
->mspeed
!= oldspeed
&& vis
&& canspotmon(mdef
))
1116 pline("%s slows down.", Monnam(mdef
));
1120 /* Since confusing another monster doesn't have a real time
1121 * limit, setting spec_used would not really be right (though
1122 * we still should check for it).
1124 if (!magr
->mcan
&& !mdef
->mconf
&& !magr
->mspec_used
) {
1125 if (vis
&& canseemon(mdef
))
1126 pline("%s looks confused.", Monnam(mdef
));
1128 mdef
->mstrategy
&= ~STRAT_WAITFORU
;
1132 if (can_blnd(magr
, mdef
, mattk
->aatyp
, (struct obj
*) 0)) {
1133 register unsigned rnd_tmp
;
1135 if (vis
&& mdef
->mcansee
&& canspotmon(mdef
))
1136 pline("%s is blinded.", Monnam(mdef
));
1137 rnd_tmp
= d((int) mattk
->damn
, (int) mattk
->damd
);
1138 if ((rnd_tmp
+= mdef
->mblinded
) > 127)
1140 mdef
->mblinded
= rnd_tmp
;
1142 mdef
->mstrategy
&= ~STRAT_WAITFORU
;
1147 if (!magr
->mcan
&& haseyes(pd
) && mdef
->mcansee
) {
1148 if (vis
&& canseemon(mdef
))
1149 pline("%s looks %sconfused.", Monnam(mdef
),
1150 mdef
->mconf
? "more " : "");
1152 mdef
->mstrategy
&= ~STRAT_WAITFORU
;
1157 if (!night() && (pa
== &mons
[PM_GREMLIN
]))
1159 if (!magr
->mcan
&& !rn2(10)) {
1160 mdef
->mcan
= 1; /* cancelled regardless of lifesave */
1161 mdef
->mstrategy
&= ~STRAT_WAITFORU
;
1162 if (is_were(pd
) && pd
->mlet
!= S_HUMAN
)
1164 if (pd
== &mons
[PM_CLAY_GOLEM
]) {
1165 if (vis
&& canseemon(mdef
)) {
1166 pline("Some writing vanishes from %s head!",
1167 s_suffix(mon_nam(mdef
)));
1168 pline("%s is destroyed!", Monnam(mdef
));
1173 else if (mdef
->mtame
&& !vis
)
1174 You(brief_feeling
, "strangely sad");
1176 | (grow_up(magr
, mdef
) ? 0 : MM_AGR_DIED
));
1180 You_hear("laughter.");
1181 else if (canseemon(magr
))
1182 pline("%s chuckles.", Monnam(magr
));
1190 /* technically incorrect; no check for stealing gold from
1191 * between mdef's feet...
1194 struct obj
*gold
= findgold(mdef
->minvent
);
1198 obj_extract_self(gold
);
1199 add_to_minv(magr
, gold
);
1201 mdef
->mstrategy
&= ~STRAT_WAITFORU
;
1202 if (vis
&& canseemon(mdef
)) {
1203 Strcpy(buf
, Monnam(magr
));
1204 pline("%s steals some gold from %s.", buf
, mon_nam(mdef
));
1206 if (!tele_restrict(magr
)) {
1207 boolean couldspot
= canspotmon(magr
);
1208 (void) rloc(magr
, TRUE
);
1209 if (vis
&& couldspot
&& !canspotmon(magr
))
1210 pline("%s suddenly disappears!", buf
);
1214 if (!cancelled
&& !rn2(3) && !resists_drli(mdef
)) {
1216 if (vis
&& canspotmon(mdef
))
1217 pline("%s suddenly seems weaker!", Monnam(mdef
));
1218 mdef
->mhpmax
-= tmp
;
1219 if (mdef
->m_lev
== 0)
1223 /* Automatic kill if drained past level 0 */
1227 case AD_SITM
: /* for now these are the same */
1231 /* find an object to steal, non-cursed if magr is tame */
1232 for (obj
= mdef
->minvent
; obj
; obj
= obj
->nobj
)
1233 if (!magr
->mtame
|| !obj
->cursed
)
1237 char onambuf
[BUFSZ
], mdefnambuf
[BUFSZ
];
1239 /* make a special x_monnam() call that never omits
1240 the saddle, and save it for later messages */
1242 x_monnam(mdef
, ARTICLE_THE
, (char *) 0, 0, FALSE
));
1245 if (u
.usteed
== mdef
&& otmp
== which_armor(mdef
, W_SADDLE
))
1246 /* "You can no longer ride <steed>." */
1247 dismount_steed(DISMOUNT_POLY
);
1248 obj_extract_self(otmp
);
1249 if (otmp
->owornmask
) {
1250 mdef
->misc_worn_check
&= ~otmp
->owornmask
;
1251 if (otmp
->owornmask
& W_WEP
)
1253 otmp
->owornmask
= 0L;
1254 update_mon_intrinsics(mdef
, otmp
, FALSE
, FALSE
);
1256 /* add_to_minv() might free otmp [if it merges] */
1258 Strcpy(onambuf
, doname(otmp
));
1259 (void) add_to_minv(magr
, otmp
);
1260 if (vis
&& canseemon(mdef
)) {
1261 Strcpy(buf
, Monnam(magr
));
1262 pline("%s steals %s from %s!", buf
, onambuf
, mdefnambuf
);
1264 possibly_unwield(mdef
, FALSE
);
1265 mdef
->mstrategy
&= ~STRAT_WAITFORU
;
1266 mselftouch(mdef
, (const char *) 0, FALSE
);
1269 | (grow_up(magr
, mdef
) ? 0 : MM_AGR_DIED
));
1270 if (pa
->mlet
== S_NYMPH
&& !tele_restrict(magr
)) {
1271 boolean couldspot
= canspotmon(magr
);
1272 (void) rloc(magr
, TRUE
);
1273 if (vis
&& couldspot
&& !canspotmon(magr
))
1274 pline("%s suddenly disappears!", buf
);
1280 if (!cancelled
&& !rn2(4))
1281 xdrainenergym(mdef
, vis
&& canspotmon(mdef
) && mattk
->aatyp
!= AT_ENGL
);
1287 if (!cancelled
&& !rn2(8)) {
1288 if (vis
&& canspotmon(magr
))
1289 pline("%s %s was poisoned!", s_suffix(Monnam(magr
)),
1290 mpoisons_subj(magr
, mattk
));
1291 if (resists_poison(mdef
)) {
1292 if (vis
&& canspotmon(mdef
) && canspotmon(magr
))
1293 pline_The("poison doesn't seem to affect %s.",
1299 if (vis
&& canspotmon(mdef
))
1300 pline_The("poison was deadly...");
1307 if (notonhead
|| !has_head(pd
)) {
1308 if (vis
&& canspotmon(mdef
))
1309 pline("%s doesn't seem harmed.", Monnam(mdef
));
1310 /* Not clear what to do for green slimes */
1314 if ((mdef
->misc_worn_check
& W_ARMH
) && rn2(8)) {
1315 if (vis
&& canspotmon(magr
) && canseemon(mdef
)) {
1316 Strcpy(buf
, s_suffix(Monnam(mdef
)));
1317 pline("%s helmet blocks %s attack to %s head.", buf
,
1318 s_suffix(mon_nam(magr
)), mhis(mdef
));
1322 res
= eat_brains(magr
, mdef
, vis
, &tmp
);
1326 break; /* physical damage only */
1327 if (!rn2(4) && !slimeproof(pd
)) {
1328 if (!munslime(mdef
, FALSE
) && mdef
->mhp
> 0) {
1329 if (newcham(mdef
, &mons
[PM_GREEN_SLIME
], FALSE
, vis
&& canseemon(mdef
)))
1331 mdef
->mstrategy
&= ~STRAT_WAITFORU
;
1334 /* munslime attempt could have been fatal,
1335 potentially to multiple monsters (SCR_FIRE) */
1347 case AD_WRAP
: /* monsters cannot grab one another, it's too hard */
1352 /* there's no msomearmor() function, so just do damage */
1353 /* if (cancelled) break; */
1362 if ((mdef
->mhp
-= tmp
) < 1) {
1363 if (m_at(mdef
->mx
, mdef
->my
) == magr
) { /* see gulpmm() */
1364 remove_monster(mdef
->mx
, mdef
->my
);
1365 mdef
->mhp
= 1; /* otherwise place_monster will complain */
1366 place_monster(mdef
, mdef
->mx
, mdef
->my
);
1369 monkilled(mdef
, "", (int) mattk
->adtyp
);
1371 return res
; /* mdef lifesaved */
1372 else if (res
== MM_AGR_DIED
)
1373 return (MM_DEF_DIED
| MM_AGR_DIED
);
1375 if (mattk
->adtyp
== AD_DGST
) {
1376 /* various checks similar to dog_eat and meatobj.
1377 * after monkilled() to provide better message ordering */
1378 if (mdef
->cham
>= LOW_PM
) {
1379 (void) newcham(magr
, (struct permonst
*) 0, FALSE
, TRUE
);
1380 } else if (pd
== &mons
[PM_GREEN_SLIME
] && !slimeproof(pa
)) {
1381 (void) newcham(magr
, &mons
[PM_GREEN_SLIME
], FALSE
, TRUE
);
1382 } else if (pd
== &mons
[PM_WRAITH
]) {
1383 (void) grow_up(magr
, (struct monst
*) 0);
1384 /* don't grow up twice */
1385 return (MM_DEF_DIED
| (magr
->mhp
> 0 ? 0 : MM_AGR_DIED
));
1386 } else if (pd
== &mons
[PM_NURSE
]) {
1387 magr
->mhp
= magr
->mhpmax
;
1390 /* caveat: above digestion handling doesn't keep `pa' up to date */
1392 return (MM_DEF_DIED
| (grow_up(magr
, mdef
) ? 0 : MM_AGR_DIED
));
1394 return (res
== MM_AGR_DIED
) ? MM_AGR_DIED
: MM_HIT
;
1398 paralyze_monst(mon
, amt
)
1407 mon
->meating
= 0; /* terminate any meal-in-progress */
1408 mon
->mstrategy
&= ~STRAT_WAITFORU
;
1411 /* `mon' is hit by a sleep attack; return 1 if it's affected, 0 otherwise */
1413 sleep_monst(mon
, amt
, how
)
1417 if (resists_sleep(mon
)
1418 || (how
>= 0 && resist(mon
, (char) how
, 0, NOTELL
))) {
1419 shieldeff(mon
->mx
, mon
->my
);
1420 } else if (mon
->mcanmove
) {
1421 finish_meating(mon
); /* terminate any meal-in-progress */
1422 amt
+= (int) mon
->mfrozen
;
1423 if (amt
> 0) { /* sleep for N turns */
1425 mon
->mfrozen
= min(amt
, 127);
1426 } else { /* sleep until awakened */
1434 /* sleeping grabber releases, engulfer doesn't; don't use for paralysis! */
1439 if ((mon
->msleeping
|| !mon
->mcanmove
) && mon
== u
.ustuck
1440 && !sticks(youmonst
.data
) && !u
.uswallow
) {
1441 pline("%s grip relaxes.", s_suffix(Monnam(mon
)));
1451 int dmgtyp
= -1, chance
= 1;
1454 return; /* just in case */
1455 /* AD_ACID and AD_ENCH are handled in passivemm() and passiveum() */
1456 if (dmgtype(mdef
->data
, AD_CORR
)) {
1457 dmgtyp
= ERODE_CORRODE
;
1458 } else if (dmgtype(mdef
->data
, AD_RUST
)) {
1459 dmgtyp
= ERODE_RUST
;
1460 } else if (dmgtype(mdef
->data
, AD_FIRE
)
1461 /* steam vortex: fire resist applies, fire damage doesn't */
1462 && mdef
->data
!= &mons
[PM_STEAM_VORTEX
]) {
1463 dmgtyp
= ERODE_BURN
;
1467 if (dmgtyp
>= 0 && !rn2(chance
))
1468 (void) erode_obj(obj
, (char *) 0, dmgtyp
, EF_GREASE
| EF_VERBOSE
);
1472 mswingsm(magr
, mdef
, otemp
)
1473 struct monst
*magr
, *mdef
;
1476 if (flags
.verbose
&& !Blind
&& mon_visible(magr
)) {
1477 pline("%s %s %s%s %s at %s.", Monnam(magr
),
1478 (objects
[otemp
->otyp
].oc_dir
& PIERCE
) ? "thrusts" : "swings",
1479 (otemp
->quan
> 1L) ? "one of " : "", mhis(magr
), xname(otemp
),
1485 * Passive responses by defenders. Does not replicate responses already
1486 * handled above. Returns same values as mattackm.
1489 passivemm(magr
, mdef
, mhit
, mdead
)
1490 register struct monst
*magr
, *mdef
;
1494 register struct permonst
*mddat
= mdef
->data
;
1495 register struct permonst
*madat
= magr
->data
;
1501 return (mdead
| mhit
); /* no passive attacks */
1502 if (mddat
->mattk
[i
].aatyp
== AT_NONE
)
1505 if (mddat
->mattk
[i
].damn
)
1506 tmp
= d((int) mddat
->mattk
[i
].damn
, (int) mddat
->mattk
[i
].damd
);
1507 else if (mddat
->mattk
[i
].damd
)
1508 tmp
= d((int) mddat
->mlevel
+ 1, (int) mddat
->mattk
[i
].damd
);
1512 /* These affect the enemy even if defender killed */
1513 switch (mddat
->mattk
[i
].adtyp
) {
1515 if (mhit
&& !rn2(2)) {
1516 Strcpy(buf
, Monnam(magr
));
1517 if (canseemon(magr
))
1518 pline("%s is splashed by %s %s!", buf
,
1519 s_suffix(mon_nam(mdef
)), hliquid("acid"));
1520 if (resists_acid(magr
)) {
1521 if (canseemon(magr
))
1522 pline("%s is not affected.", Monnam(magr
));
1528 erode_armor(magr
, ERODE_CORRODE
);
1530 acid_damage(MON_WEP(magr
));
1532 case AD_ENCH
: /* KMH -- remove enchantment (disenchanter) */
1533 if (mhit
&& !mdef
->mcan
&& otmp
) {
1534 (void) drain_item(otmp
, FALSE
);
1541 if (mdead
|| mdef
->mcan
)
1542 return (mdead
| mhit
);
1544 /* These affect the enemy only if defender is still alive */
1546 switch (mddat
->mattk
[i
].adtyp
) {
1547 case AD_PLYS
: /* Floating eye */
1550 if (mddat
== &mons
[PM_FLOATING_EYE
]) {
1553 if (magr
->mcansee
&& haseyes(madat
) && mdef
->mcansee
1554 && (perceives(madat
) || !mdef
->minvis
)) {
1555 Sprintf(buf
, "%s gaze is reflected by %%s %%s.",
1556 s_suffix(Monnam(mdef
)));
1557 if (mon_reflects(magr
,
1558 canseemon(magr
) ? buf
: (char *) 0))
1559 return (mdead
| mhit
);
1560 Strcpy(buf
, Monnam(magr
));
1561 if (canseemon(magr
))
1562 pline("%s is frozen by %s gaze!", buf
,
1563 s_suffix(mon_nam(mdef
)));
1564 paralyze_monst(magr
, tmp
);
1565 return (mdead
| mhit
);
1567 } else { /* gelatinous cube */
1568 Strcpy(buf
, Monnam(magr
));
1569 if (canseemon(magr
))
1570 pline("%s is frozen by %s.", buf
, mon_nam(mdef
));
1571 paralyze_monst(magr
, tmp
);
1572 return (mdead
| mhit
);
1576 if (resists_cold(magr
)) {
1577 if (canseemon(magr
)) {
1578 pline("%s is mildly chilly.", Monnam(magr
));
1579 golemeffects(magr
, AD_COLD
, tmp
);
1584 if (canseemon(magr
))
1585 pline("%s is suddenly very cold!", Monnam(magr
));
1586 mdef
->mhp
+= tmp
/ 2;
1587 if (mdef
->mhpmax
< mdef
->mhp
)
1588 mdef
->mhpmax
= mdef
->mhp
;
1589 if (mdef
->mhpmax
> ((int) (mdef
->m_lev
+ 1) * 8))
1590 (void) split_mon(mdef
, magr
);
1595 if (canseemon(magr
))
1596 pline("%s %s...", Monnam(magr
),
1597 makeplural(stagger(magr
->data
, "stagger")));
1602 if (resists_fire(magr
)) {
1603 if (canseemon(magr
)) {
1604 pline("%s is mildly warmed.", Monnam(magr
));
1605 golemeffects(magr
, AD_FIRE
, tmp
);
1610 if (canseemon(magr
))
1611 pline("%s is suddenly very hot!", Monnam(magr
));
1614 if (resists_elec(magr
)) {
1615 if (canseemon(magr
)) {
1616 pline("%s is mildly tingled.", Monnam(magr
));
1617 golemeffects(magr
, AD_ELEC
, tmp
);
1622 if (canseemon(magr
))
1623 pline("%s is jolted with electricity!", Monnam(magr
));
1633 if ((magr
->mhp
-= tmp
) <= 0) {
1634 monkilled(magr
, "", (int) mddat
->mattk
[i
].adtyp
);
1635 return (mdead
| mhit
| MM_AGR_DIED
);
1637 return (mdead
| mhit
);
1640 /* hero or monster has successfully hit target mon with drain energy attack */
1642 xdrainenergym(mon
, givemsg
)
1646 if (mon
->mspec_used
< 20 /* limit draining */
1647 && (attacktype(mon
->data
, AT_MAGC
)
1648 || attacktype(mon
->data
, AT_BREA
))) {
1649 mon
->mspec_used
+= d(2, 2);
1651 pline("%s seems lethargic.", Monnam(mon
));
1655 /* "aggressive defense"; what type of armor prevents specified attack
1656 from touching its target? */
1658 attk_protection(aatyp
)
1671 w_mask
= ~0L; /* special case; no defense needed */
1676 w_mask
= W_ARMG
; /* caller needs to check for weapon */
1685 w_mask
= (W_ARMC
| W_ARMG
); /* attacker needs both to be protected */
1692 w_mask
= 0L; /* no defense available */