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 $ */
6 extern struct monst *makemon();
9 * mhitu: monster hits you
10 * returns 1 if monster dies (e.g. 'y', 'F'), 0 otherwise
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 (void) makemon(PM_DEMON,u.ux,u.uy);
79 (void) hitu(mtmp,d(2,6));
80 (void) hitu(mtmp,d(2,6));
81 (void) hitu(mtmp,rnd(3));
82 (void) hitu(mtmp,rnd(3));
83 (void) hitu(mtmp,rn1(4,2));
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!");
116 (void) hitu(mtmp,rnd(6));
120 pline("You hear %s's hissing!", monnam(mtmp));
121 if(ctmp || !rn2(20) || (flags.moonphase == NEW_MOON
122 && !carrying(DEAD_LIZARD))) {
124 /* pline("You get turned to stone!"); */
125 /* done_in_by(mtmp); */
130 if(rn2(6) || mtmp->mcan) {
131 (void) hitu(mtmp,d(3,10));
132 (void) hitu(mtmp,rnd(8));
133 (void) hitu(mtmp,rnd(8));
136 kludge("%s breathes fire!","The dragon");
137 buzz(-1,mtmp->mx,mtmp->my,u.ux-mtmp->mx,u.uy-mtmp->my);
140 (void) hitu(mtmp,d(2, (flags.moonphase == FULL_MOON) ? 3 : 4));
143 (void) hitu(mtmp,d(3,6));
146 if(mtmp->mcan) break;
147 kludge("%s explodes!","The freezing sphere");
148 if(Cold_resistance) pline("You don't seem affected by it.");
151 if(17-(u.ulevel/2) > rnd(20)) {
152 pline("You get blasted!");
155 pline("You duck the blast...");
158 losehp_m(d(dn,6), mtmp);
163 if(ctmp && multi >= 0 && !rn2(3)) {
164 kludge("You are frozen by %ss juices","the cube'");
169 if(ctmp && multi >= 0 && !rn2(5)) {
171 kludge("You are put to sleep by %ss bite!",
176 tmp = hitu(mtmp,rnd(3));
177 tmp &= hitu(mtmp,rnd(3));
179 (void) hitu(mtmp,rnd(4));
180 (void) hitu(mtmp,rnd(4));
184 if((hitu(mtmp,rnd(4)) || !rn2(3)) && ctmp){
185 poisoned("bee's sting",mdat->mname);
189 if(tmp) stealgold(mtmp);
192 if(mtmp->mcan && !Blind) {
193 pline("%s tries to seduce you, but you seem not interested.",
194 Amonnam(mtmp, "plain"));
195 if(rn2(3)) rloc(mtmp);
196 } else if(steal(mtmp)) {
202 if(!uwep && !uarm && !uarmh && !uarms && !uarmg) {
203 pline("%s hits! (I hope you don't mind)",
206 if(!rn2(7)) u.uhpmax++;
207 if(u.uhp > u.uhpmax) u.uhp = u.uhpmax;
209 if(!rn2(50)) rloc(mtmp);
211 (void) hitu(mtmp,d(2,6));
212 (void) hitu(mtmp,d(2,6));
216 tmp = hitu(mtmp,rnd(6));
217 if(hitu(mtmp,rnd(6)) && tmp && /* hits with both paws */
218 !u.ustuck && rn2(2)) {
220 kludge("%s has grabbed you!","The owlbear");
222 } else if(u.ustuck == mtmp) {
224 pline("You are being crushed.");
229 justswld(mtmp,"The purple worm");
231 (void) hitu(mtmp,d(2,4));
234 (void) hitu(mtmp,rnd(2));
235 (void) hitu(mtmp,rnd(2));
238 if(tmp && uarmh && !uarmh->rustfree &&
239 (int) uarmh->spe >= -1) {
240 pline("Your helmet rusts!");
243 if(ctmp && uarm && !uarm->rustfree && /* Mike Newton */
244 uarm->otyp < STUDDED_LEATHER_ARMOR &&
245 (int) uarm->spe >= -1) {
246 pline("Your armor rusts!");
251 if(ctmp && !rn2(8)) {
252 poisoned("snake's bite",mdat->mname);
257 poisoned("scorpion's sting",mdat->mname);
259 (void) hitu(mtmp,rnd(8));
260 (void) hitu(mtmp,rnd(8));
263 (void) hitu(mtmp,rnd(6));
264 (void) hitu(mtmp,rnd(6));
267 if(!rn2(5)) rloc(mtmp);
273 (void) hitu(mtmp,d(3,4));
274 (void) hitu(mtmp,d(3,4));
277 if(ctmp && !u.ustuck) u.ustuck = mtmp;
288 if(tmp) wormhit(mtmp);
292 (void) hitu(mtmp,rnd(5));
293 (void) hitu(mtmp,rnd(5));
294 (void) hitu(mtmp,rnd(5));
297 { long side = rn2(2) ? RIGHT_SIDE : LEFT_SIDE;
298 pline("%s pricks in your %s leg!",
299 Monnam(mtmp), (side == RIGHT_SIDE) ? "right" : "left");
300 set_wounded_legs(side, rnd(50));
305 if(mtmp->mcan) break;
308 pline("You are blinded by a blast of light!");
314 (void) hitu(mtmp,rnd(6));
317 if(u.uhp < 1) done_in_by(mtmp);
328 if(u.uswallow) return(0);
330 if(mtmp->mhide && mtmp->mundetected) {
331 mtmp->mundetected = 0;
334 extern char * Xmonnam();
335 if(obj = o_at(mtmp->mx,mtmp->my))
336 pline("%s was hidden under %s!",
337 Xmonnam(mtmp), doname(obj));
342 /* give people with Ac = -10 at least some vulnerability */
344 dam += tmp; /* decrease damage */
345 if(dam <= 0) dam = 1;
348 tmp += mtmp->data->mlevel;
349 if(multi < 0) tmp += 4;
350 if((Invis && mtmp->data->mlet != 'I') || !mtmp->mcansee) tmp -= 2;
351 if(mtmp->mtrapped) tmp -= 2;
353 if(Blind) pline("It misses.");
354 else pline("%s misses.",Monnam(mtmp));
357 if(Blind) pline("It hits!");
358 else pline("%s hits!",Monnam(mtmp));