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.");
50 if(u
.uhp
< 1) done_in_by(mtmp
);
54 if(mdat
->mlet
== 'c' && Stoned
)
57 /* make eels visible the moment they hit/miss us */
58 if(mdat
->mlet
== ';' && mtmp
->minvis
&& cansee(mtmp
->mx
,mtmp
->my
)){
62 if(!index("1&DuxynNF",mdat
->mlet
))
63 tmp
= hitu(mtmp
,d(mdat
->damn
,mdat
->damd
));
66 if(index(UNDEAD
, mdat
->mlet
) && midnight())
67 tmp
+= hitu(mtmp
,d(mdat
->damn
,mdat
->damd
));
69 ctmp
= tmp
&& !mtmp
->mcan
&&
70 (!uarm
|| objects
[uarm
->otyp
].a_can
< rnd(3) || !rn2(50));
73 if(wiz_hit(mtmp
)) return(1); /* he disappeared */
76 if(!mtmp
->cham
&& !mtmp
->mcan
&& !rn2(13)) {
77 makemon(PM_DEMON
,u
.ux
,u
.uy
);
87 if(tmp
) justswld(mtmp
,"The trapper");
90 if(tmp
) justswld(mtmp
, "The lurker above");
94 if(!u
.ustuck
&& !rn2(10)) {
95 pline("%s swings itself around you!",
98 } else if(u
.ustuck
== mtmp
&&
99 levl
[mtmp
->mx
][mtmp
->my
].typ
== POOL
) {
100 pline("%s drowns you ...", Monnam(mtmp
));
107 if(Poison_resistance
)
108 pline("The sting doesn't seem to affect you.");
110 pline("You feel weaker!");
120 pline("You hear %s's hissing!", monnam(mtmp
));
121 if(ctmp
|| !rn2(20) || (flags
.moonphase
== NEW_MOON
122 && !carrying(DEAD_LIZARD
))) {
128 if(rn2(6) || mtmp
->mcan
) {
134 kludge("%s breathes fire!","The dragon");
135 buzz(-1,mtmp
->mx
,mtmp
->my
,u
.ux
-mtmp
->mx
,u
.uy
-mtmp
->my
);
138 hitu(mtmp
,d(2, (flags
.moonphase
== FULL_MOON
) ? 3 : 4));
144 if(mtmp
->mcan
) break;
145 kludge("%s explodes!","The freezing sphere");
146 if(Cold_resistance
) pline("You don't seem affected by it.");
149 if(17-(u
.ulevel
/2) > rnd(20)) {
150 pline("You get blasted!");
153 pline("You duck the blast...");
156 losehp_m(d(dn
,6), mtmp
);
161 if(ctmp
&& multi
>= 0 && !rn2(3)) {
162 kludge("You are frozen by %ss juices","the cube'");
167 if(ctmp
&& multi
>= 0 && !rn2(5)) {
169 kludge("You are put to sleep by %ss bite!",
174 tmp
= hitu(mtmp
,rnd(3));
175 tmp
&= hitu(mtmp
,rnd(3));
182 if((hitu(mtmp
,rnd(4)) || !rn2(3)) && ctmp
){
183 poisoned("bee's sting",mdat
->mname
);
187 if(tmp
) stealgold(mtmp
);
190 if(mtmp
->mcan
&& !Blind
) {
191 pline("%s tries to seduce you, but you seem not interested.",
192 Amonnam(mtmp
, "plain"));
193 if(rn2(3)) rloc(mtmp
);
194 } else if(steal(mtmp
)) {
200 if(!uwep
&& !uarm
&& !uarmh
&& !uarms
&& !uarmg
) {
201 pline("%s hits! (I hope you don't mind)",
204 if(!rn2(7)) u
.uhpmax
++;
205 if(u
.uhp
> u
.uhpmax
) u
.uhp
= u
.uhpmax
;
207 if(!rn2(50)) rloc(mtmp
);
214 tmp
= hitu(mtmp
,rnd(6));
215 if(hitu(mtmp
,rnd(6)) && tmp
&& /* hits with both paws */
216 !u
.ustuck
&& rn2(2)) {
218 kludge("%s has grabbed you!","The owlbear");
220 } else if(u
.ustuck
== mtmp
) {
222 pline("You are being crushed.");
227 justswld(mtmp
,"The purple worm");
236 if(tmp
&& uarmh
&& !uarmh
->rustfree
&&
237 (int) uarmh
->spe
>= -1) {
238 pline("Your helmet rusts!");
241 if(ctmp
&& uarm
&& !uarm
->rustfree
&& /* Mike Newton */
242 uarm
->otyp
< STUDDED_LEATHER_ARMOR
&&
243 (int) uarm
->spe
>= -1) {
244 pline("Your armor rusts!");
249 if(ctmp
&& !rn2(8)) {
250 poisoned("snake's bite",mdat
->mname
);
255 poisoned("scorpion's sting",mdat
->mname
);
265 if(!rn2(5)) rloc(mtmp
);
275 if(ctmp
&& !u
.ustuck
) u
.ustuck
= mtmp
;
286 if(tmp
) wormhit(mtmp
);
295 { long side
= rn2(2) ? RIGHT_SIDE
: LEFT_SIDE
;
296 pline("%s pricks in your %s leg!",
297 Monnam(mtmp
), (side
== RIGHT_SIDE
) ? "right" : "left");
298 set_wounded_legs(side
, rnd(50));
303 if(mtmp
->mcan
) break;
306 pline("You are blinded by a blast of light!");
315 if(u
.uhp
< 1) done_in_by(mtmp
);
320 hitu(struct monst
*mtmp
, int dam
)
326 if(u
.uswallow
) return(0);
328 if(mtmp
->mhide
&& mtmp
->mundetected
) {
329 mtmp
->mundetected
= 0;
332 if((obj
= o_at(mtmp
->mx
,mtmp
->my
)))
333 pline("%s was hidden under %s!",
334 Xmonnam(mtmp
), doname(obj
));
339 /* give people with Ac = -10 at least some vulnerability */
341 dam
+= tmp
; /* decrease damage */
342 if(dam
<= 0) dam
= 1;
345 tmp
+= mtmp
->data
->mlevel
;
346 if(multi
< 0) tmp
+= 4;
347 if((Invis
&& mtmp
->data
->mlet
!= 'I') || !mtmp
->mcansee
) tmp
-= 2;
348 if(mtmp
->mtrapped
) tmp
-= 2;
350 if(Blind
) pline("It misses.");
351 else pline("%s misses.",Monnam(mtmp
));
354 if(Blind
) pline("It hits!");
355 else pline("%s hits!",Monnam(mtmp
));