1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.mhitu.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.mhitu.c,v 1.4 1999/11/16 10:26:36 marcel Exp $ */
4 /* $DragonFly: src/games/hack/hack.mhitu.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */
9 * mhitu: monster hits you
10 * returns 1 if monster dies (e.g. 'y', 'F'), 0 otherwise
13 mhitu(struct monst
*mtmp
)
15 struct permonst
*mdat
= mtmp
->data
;
20 /* If swallowed, can only be affected by hissers and by u.ustuck */
22 if (mtmp
!= u
.ustuck
) {
23 if (mdat
->mlet
== 'c' && !rn2(13)) {
24 pline("Outside, you hear %s's hissing!",
26 pline("%s gets turned to stone!",
28 pline("And the same fate befalls you.");
30 /* "notreached": not return(1); */
34 switch (mdat
->mlet
) { /* now mtmp == u.ustuck */
36 youswld(mtmp
, (u
.uac
> 0) ? u
.uac
+ 4 : 4,
40 youswld(mtmp
, rnd(6), 7, "The lurker above");
43 youswld(mtmp
, d(2, 4), 12, "The purple worm");
46 /* This is not impossible! */
47 pline("The mysterious monster totally digests you.");
55 if (mdat
->mlet
== 'c' && Stoned
)
58 /* make eels visible the moment they hit/miss us */
59 if (mdat
->mlet
== ';' && mtmp
->minvis
&& cansee(mtmp
->mx
, mtmp
->my
)) {
63 if (!strchr("1&DuxynNF", mdat
->mlet
))
64 tmp
= hitu(mtmp
, d(mdat
->damn
, mdat
->damd
));
67 if (strchr(UNDEAD
, mdat
->mlet
) && midnight())
68 tmp
+= hitu(mtmp
, d(mdat
->damn
, mdat
->damd
));
70 ctmp
= tmp
&& !mtmp
->mcan
&&
71 (!uarm
|| objects
[uarm
->otyp
].a_can
< rnd(3) || !rn2(50));
74 if (wiz_hit(mtmp
)) /* he disappeared */
78 if (!mtmp
->cham
&& !mtmp
->mcan
&& !rn2(13)) {
79 makemon(PM_DEMON
, u
.ux
, u
.uy
);
85 hitu(mtmp
, rn1(4, 2));
90 justswld(mtmp
, "The trapper");
94 justswld(mtmp
, "The lurker above");
98 if (!u
.ustuck
&& !rn2(10)) {
99 pline("%s swings itself around you!",
102 } else if (u
.ustuck
== mtmp
&&
103 levl
[mtmp
->mx
][mtmp
->my
].typ
== POOL
) {
104 pline("%s drowns you ...", Monnam(mtmp
));
110 if (ctmp
&& rn2(2)) {
111 if (Poison_resistance
)
112 pline("The sting doesn't seem to affect you.");
114 pline("You feel weaker!");
124 pline("You hear %s's hissing!", monnam(mtmp
));
125 if (ctmp
|| !rn2(20) || (flags
.moonphase
== NEW_MOON
126 && !carrying(DEAD_LIZARD
)))
131 if (rn2(6) || mtmp
->mcan
) {
132 hitu(mtmp
, d(3, 10));
137 kludge("%s breathes fire!", "The dragon");
138 buzz(-1, mtmp
->mx
, mtmp
->my
, u
.ux
- mtmp
->mx
, u
.uy
- mtmp
->my
);
141 hitu(mtmp
, d(2, (flags
.moonphase
== FULL_MOON
) ? 3 : 4));
149 kludge("%s explodes!", "The freezing sphere");
151 pline("You don't seem affected by it.");
154 if (17 - (u
.ulevel
/ 2) > rnd(20)) {
155 pline("You get blasted!");
158 pline("You duck the blast...");
161 losehp_m(d(dn
, 6), mtmp
);
166 if (ctmp
&& multi
>= 0 && !rn2(3)) {
167 kludge("You are frozen by %ss juices", "the cube'");
172 if (ctmp
&& multi
>= 0 && !rn2(5)) {
174 kludge("You are put to sleep by %ss bite!",
179 tmp
= hitu(mtmp
, rnd(3));
180 tmp
&= hitu(mtmp
, rnd(3));
187 if ((hitu(mtmp
, rnd(4)) || !rn2(3)) && ctmp
)
188 poisoned("bee's sting", mdat
->mname
);
195 if (mtmp
->mcan
&& !Blind
) {
196 pline("%s tries to seduce you, but you seem not interested.",
197 Amonnam(mtmp
, "plain"));
200 } else if (steal(mtmp
)) {
206 if (!uwep
&& !uarm
&& !uarmh
&& !uarms
&& !uarmg
) {
207 pline("%s hits! (I hope you don't mind)",
212 if (u
.uhp
> u
.uhpmax
)
223 tmp
= hitu(mtmp
, rnd(6));
224 if (hitu(mtmp
, rnd(6)) && tmp
&& /* hits with both paws */
225 !u
.ustuck
&& rn2(2)) {
227 kludge("%s has grabbed you!", "The owlbear");
229 } else if (u
.ustuck
== mtmp
) {
231 pline("You are being crushed.");
236 justswld(mtmp
, "The purple worm");
245 if (tmp
&& uarmh
&& !uarmh
->rustfree
&&
246 (int)uarmh
->spe
>= -1) {
247 pline("Your helmet rusts!");
249 } else if (ctmp
&& uarm
&& !uarm
->rustfree
&& /* Mike Newton */
250 uarm
->otyp
< STUDDED_LEATHER_ARMOR
&&
251 (int)uarm
->spe
>= -1) {
252 pline("Your armor rusts!");
258 poisoned("snake's bite", mdat
->mname
);
262 poisoned("scorpion's sting", mdat
->mname
);
282 if (ctmp
&& !u
.ustuck
)
308 long side
= rn2(2) ? RIGHT_SIDE
: LEFT_SIDE
;
309 pline("%s pricks in your %s leg!",
310 Monnam(mtmp
), (side
== RIGHT_SIDE
) ? "right" : "left");
311 set_wounded_legs(side
, rnd(50));
320 pline("You are blinded by a blast of light!");
335 hitu(struct monst
*mtmp
, int dam
)
344 if (mtmp
->mhide
&& mtmp
->mundetected
) {
345 mtmp
->mundetected
= 0;
348 if ((obj
= o_at(mtmp
->mx
, mtmp
->my
)) != NULL
)
349 pline("%s was hidden under %s!",
350 Xmonnam(mtmp
), doname(obj
));
355 /* give people with Ac = -10 at least some vulnerability */
357 dam
+= tmp
; /* decrease damage */
362 tmp
+= mtmp
->data
->mlevel
;
365 if ((Invis
&& mtmp
->data
->mlet
!= 'I') || !mtmp
->mcansee
)
369 if (tmp
<= rnd(20)) {
373 pline("%s misses.", Monnam(mtmp
));
379 pline("%s hits!", Monnam(mtmp
));