]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.mhitu.c
2 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
6 static char rcsid
[] = "$Id: hack.mhitu.c,v 1.2 1993/08/02 17:17:21 mycroft Exp $";
10 extern struct monst
*makemon();
13 * mhitu: monster hits you
14 * returns 1 if monster dies (e.g. 'y', 'F'), 0 otherwise
17 register struct monst
*mtmp
;
19 register struct permonst
*mdat
= mtmp
->data
;
20 register int tmp
, ctmp
;
24 /* If swallowed, can only be affected by hissers and by u.ustuck */
26 if(mtmp
!= u
.ustuck
) {
27 if(mdat
->mlet
== 'c' && !rn2(13)) {
28 pline("Outside, you hear %s's hissing!",
30 pline("%s gets turned to stone!",
32 pline("And the same fate befalls you.");
34 /* "notreached": not return(1); */
38 switch(mdat
->mlet
) { /* now mtmp == u.ustuck */
40 youswld(mtmp
, (u
.uac
> 0) ? u
.uac
+4 : 4,
44 youswld(mtmp
,rnd(6),7,"The lurker above");
47 youswld(mtmp
,d(2,4),12,"The purple worm");
50 /* This is not impossible! */
51 pline("The mysterious monster totally digests you.");
54 if(u
.uhp
< 1) done_in_by(mtmp
);
58 if(mdat
->mlet
== 'c' && Stoned
)
61 /* make eels visible the moment they hit/miss us */
62 if(mdat
->mlet
== ';' && mtmp
->minvis
&& cansee(mtmp
->mx
,mtmp
->my
)){
66 if(!index("1&DuxynNF",mdat
->mlet
))
67 tmp
= hitu(mtmp
,d(mdat
->damn
,mdat
->damd
));
70 if(index(UNDEAD
, mdat
->mlet
) && midnight())
71 tmp
+= hitu(mtmp
,d(mdat
->damn
,mdat
->damd
));
73 ctmp
= tmp
&& !mtmp
->mcan
&&
74 (!uarm
|| objects
[uarm
->otyp
].a_can
< rnd(3) || !rn2(50));
77 if(wiz_hit(mtmp
)) return(1); /* he disappeared */
80 if(!mtmp
->cham
&& !mtmp
->mcan
&& !rn2(13)) {
81 (void) makemon(PM_DEMON
,u
.ux
,u
.uy
);
83 (void) hitu(mtmp
,d(2,6));
84 (void) hitu(mtmp
,d(2,6));
85 (void) hitu(mtmp
,rnd(3));
86 (void) hitu(mtmp
,rnd(3));
87 (void) hitu(mtmp
,rn1(4,2));
91 if(tmp
) justswld(mtmp
,"The trapper");
94 if(tmp
) 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
));
111 if(Poison_resistance
)
112 pline("The sting doesn't seem to affect you.");
114 pline("You feel weaker!");
120 (void) hitu(mtmp
,rnd(6));
124 pline("You hear %s's hissing!", monnam(mtmp
));
125 if(ctmp
|| !rn2(20) || (flags
.moonphase
== NEW_MOON
126 && !carrying(DEAD_LIZARD
))) {
128 /* pline("You get turned to stone!"); */
129 /* done_in_by(mtmp); */
134 if(rn2(6) || mtmp
->mcan
) {
135 (void) hitu(mtmp
,d(3,10));
136 (void) hitu(mtmp
,rnd(8));
137 (void) hitu(mtmp
,rnd(8));
140 kludge("%s breathes fire!","The dragon");
141 buzz(-1,mtmp
->mx
,mtmp
->my
,u
.ux
-mtmp
->mx
,u
.uy
-mtmp
->my
);
144 (void) hitu(mtmp
,d(2, (flags
.moonphase
== FULL_MOON
) ? 3 : 4));
147 (void) hitu(mtmp
,d(3,6));
150 if(mtmp
->mcan
) break;
151 kludge("%s explodes!","The freezing sphere");
152 if(Cold_resistance
) pline("You don't seem affected by it.");
155 if(17-(u
.ulevel
/2) > rnd(20)) {
156 pline("You get blasted!");
159 pline("You duck the blast...");
162 losehp_m(d(dn
,6), mtmp
);
167 if(ctmp
&& multi
>= 0 && !rn2(3)) {
168 kludge("You are frozen by %ss juices","the cube'");
173 if(ctmp
&& multi
>= 0 && !rn2(5)) {
175 kludge("You are put to sleep by %ss bite!",
180 tmp
= hitu(mtmp
,rnd(3));
181 tmp
&= hitu(mtmp
,rnd(3));
183 (void) hitu(mtmp
,rnd(4));
184 (void) hitu(mtmp
,rnd(4));
188 if((hitu(mtmp
,rnd(4)) || !rn2(3)) && ctmp
){
189 poisoned("bee's sting",mdat
->mname
);
193 if(tmp
) stealgold(mtmp
);
196 if(mtmp
->mcan
&& !Blind
) {
197 pline("%s tries to seduce you, but you seem not interested.",
198 Amonnam(mtmp
, "plain"));
199 if(rn2(3)) rloc(mtmp
);
200 } else if(steal(mtmp
)) {
206 if(!uwep
&& !uarm
&& !uarmh
&& !uarms
&& !uarmg
) {
207 pline("%s hits! (I hope you don't mind)",
210 if(!rn2(7)) u
.uhpmax
++;
211 if(u
.uhp
> u
.uhpmax
) u
.uhp
= u
.uhpmax
;
213 if(!rn2(50)) rloc(mtmp
);
215 (void) hitu(mtmp
,d(2,6));
216 (void) hitu(mtmp
,d(2,6));
220 tmp
= hitu(mtmp
,rnd(6));
221 if(hitu(mtmp
,rnd(6)) && tmp
&& /* hits with both paws */
222 !u
.ustuck
&& rn2(2)) {
224 kludge("%s has grabbed you!","The owlbear");
226 } else if(u
.ustuck
== mtmp
) {
228 pline("You are being crushed.");
233 justswld(mtmp
,"The purple worm");
235 (void) hitu(mtmp
,d(2,4));
238 (void) hitu(mtmp
,rnd(2));
239 (void) hitu(mtmp
,rnd(2));
242 if(tmp
&& uarmh
&& !uarmh
->rustfree
&&
243 (int) uarmh
->spe
>= -1) {
244 pline("Your helmet rusts!");
247 if(ctmp
&& uarm
&& !uarm
->rustfree
&& /* Mike Newton */
248 uarm
->otyp
< STUDDED_LEATHER_ARMOR
&&
249 (int) uarm
->spe
>= -1) {
250 pline("Your armor rusts!");
255 if(ctmp
&& !rn2(8)) {
256 poisoned("snake's bite",mdat
->mname
);
261 poisoned("scorpion's sting",mdat
->mname
);
263 (void) hitu(mtmp
,rnd(8));
264 (void) hitu(mtmp
,rnd(8));
267 (void) hitu(mtmp
,rnd(6));
268 (void) hitu(mtmp
,rnd(6));
271 if(!rn2(5)) rloc(mtmp
);
277 (void) hitu(mtmp
,d(3,4));
278 (void) hitu(mtmp
,d(3,4));
281 if(ctmp
&& !u
.ustuck
) u
.ustuck
= mtmp
;
292 if(tmp
) wormhit(mtmp
);
296 (void) hitu(mtmp
,rnd(5));
297 (void) hitu(mtmp
,rnd(5));
298 (void) hitu(mtmp
,rnd(5));
301 { register long side
= rn2(2) ? RIGHT_SIDE
: LEFT_SIDE
;
302 pline("%s pricks in your %s leg!",
303 Monnam(mtmp
), (side
== RIGHT_SIDE
) ? "right" : "left");
304 set_wounded_legs(side
, rnd(50));
309 if(mtmp
->mcan
) break;
312 pline("You are blinded by a blast of light!");
318 (void) hitu(mtmp
,rnd(6));
321 if(u
.uhp
< 1) done_in_by(mtmp
);
326 register struct monst
*mtmp
;
332 if(u
.uswallow
) return(0);
334 if(mtmp
->mhide
&& mtmp
->mundetected
) {
335 mtmp
->mundetected
= 0;
337 register struct obj
*obj
;
338 extern char * Xmonnam();
339 if(obj
= o_at(mtmp
->mx
,mtmp
->my
))
340 pline("%s was hidden under %s!",
341 Xmonnam(mtmp
), doname(obj
));
346 /* give people with Ac = -10 at least some vulnerability */
348 dam
+= tmp
; /* decrease damage */
349 if(dam
<= 0) dam
= 1;
352 tmp
+= mtmp
->data
->mlevel
;
353 if(multi
< 0) tmp
+= 4;
354 if((Invis
&& mtmp
->data
->mlet
!= 'I') || !mtmp
->mcansee
) tmp
-= 2;
355 if(mtmp
->mtrapped
) tmp
-= 2;
357 if(Blind
) pline("It misses.");
358 else pline("%s misses.",Monnam(mtmp
));
361 if(Blind
) pline("It hits!");
362 else pline("%s hits!",Monnam(mtmp
));