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.3 2004/11/06 12:29:17 eirikn Exp $ */
7 extern struct monst *makemon();
10 * mhitu: monster hits you
11 * returns 1 if monster dies (e.g. 'y', 'F'), 0 otherwise
16 struct permonst *mdat = mtmp->data;
21 /* If swallowed, can only be affected by hissers and by u.ustuck */
23 if(mtmp != u.ustuck) {
24 if(mdat->mlet == 'c' && !rn2(13)) {
25 pline("Outside, you hear %s's hissing!",
27 pline("%s gets turned to stone!",
29 pline("And the same fate befalls you.");
31 /* "notreached": not return(1); */
35 switch(mdat->mlet) { /* now mtmp == u.ustuck */
37 youswld(mtmp, (u.uac > 0) ? u.uac+4 : 4,
41 youswld(mtmp,rnd(6),7,"The lurker above");
44 youswld(mtmp,d(2,4),12,"The purple worm");
47 /* This is not impossible! */
48 pline("The mysterious monster totally digests you.");
51 if(u.uhp < 1) done_in_by(mtmp);
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(!index("1&DuxynNF",mdat->mlet))
64 tmp = hitu(mtmp,d(mdat->damn,mdat->damd));
67 if(index(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)) return(1); /* he disappeared */
77 if(!mtmp->cham && !mtmp->mcan && !rn2(13)) {
78 (void) makemon(PM_DEMON,u.ux,u.uy);
80 (void) hitu(mtmp,d(2,6));
81 (void) hitu(mtmp,d(2,6));
82 (void) hitu(mtmp,rnd(3));
83 (void) hitu(mtmp,rnd(3));
84 (void) hitu(mtmp,rn1(4,2));
88 if(tmp) justswld(mtmp,"The trapper");
91 if(tmp) justswld(mtmp, "The lurker above");
95 if(!u.ustuck && !rn2(10)) {
96 pline("%s swings itself around you!",
99 } else if(u.ustuck == mtmp &&
100 levl[mtmp->mx][mtmp->my].typ == POOL) {
101 pline("%s drowns you ...", Monnam(mtmp));
108 if(Poison_resistance)
109 pline("The sting doesn't seem to affect you.");
111 pline("You feel weaker!");
117 (void) hitu(mtmp,rnd(6));
121 pline("You hear %s's hissing!", monnam(mtmp));
122 if(ctmp || !rn2(20) || (flags.moonphase == NEW_MOON
123 && !carrying(DEAD_LIZARD))) {
125 /* pline("You get turned to stone!"); */
126 /* done_in_by(mtmp); */
131 if(rn2(6) || mtmp->mcan) {
132 (void) hitu(mtmp,d(3,10));
133 (void) hitu(mtmp,rnd(8));
134 (void) hitu(mtmp,rnd(8));
137 kludge("%s breathes fire!","The dragon");
138 buzz(-1,mtmp->mx,mtmp->my,u.ux-mtmp->mx,u.uy-mtmp->my);
141 (void) hitu(mtmp,d(2, (flags.moonphase == FULL_MOON) ? 3 : 4));
144 (void) hitu(mtmp,d(3,6));
147 if(mtmp->mcan) break;
148 kludge("%s explodes!","The freezing sphere");
149 if(Cold_resistance) pline("You don't seem affected by it.");
152 if(17-(u.ulevel/2) > rnd(20)) {
153 pline("You get blasted!");
156 pline("You duck the blast...");
159 losehp_m(d(dn,6), mtmp);
164 if(ctmp && multi >= 0 && !rn2(3)) {
165 kludge("You are frozen by %ss juices","the cube'");
170 if(ctmp && multi >= 0 && !rn2(5)) {
172 kludge("You are put to sleep by %ss bite!",
177 tmp = hitu(mtmp,rnd(3));
178 tmp &= hitu(mtmp,rnd(3));
180 (void) hitu(mtmp,rnd(4));
181 (void) hitu(mtmp,rnd(4));
185 if((hitu(mtmp,rnd(4)) || !rn2(3)) && ctmp){
186 poisoned("bee's sting",mdat->mname);
190 if(tmp) stealgold(mtmp);
193 if(mtmp->mcan && !Blind) {
194 pline("%s tries to seduce you, but you seem not interested.",
195 Amonnam(mtmp, "plain"));
196 if(rn2(3)) rloc(mtmp);
197 } else if(steal(mtmp)) {
203 if(!uwep && !uarm && !uarmh && !uarms && !uarmg) {
204 pline("%s hits! (I hope you don't mind)",
207 if(!rn2(7)) u.uhpmax++;
208 if(u.uhp > u.uhpmax) u.uhp = u.uhpmax;
210 if(!rn2(50)) rloc(mtmp);
212 (void) hitu(mtmp,d(2,6));
213 (void) hitu(mtmp,d(2,6));
217 tmp = hitu(mtmp,rnd(6));
218 if(hitu(mtmp,rnd(6)) && tmp && /* hits with both paws */
219 !u.ustuck && rn2(2)) {
221 kludge("%s has grabbed you!","The owlbear");
223 } else if(u.ustuck == mtmp) {
225 pline("You are being crushed.");
230 justswld(mtmp,"The purple worm");
232 (void) hitu(mtmp,d(2,4));
235 (void) hitu(mtmp,rnd(2));
236 (void) hitu(mtmp,rnd(2));
239 if(tmp && uarmh && !uarmh->rustfree &&
240 (int) uarmh->spe >= -1) {
241 pline("Your helmet rusts!");
244 if(ctmp && uarm && !uarm->rustfree && /* Mike Newton */
245 uarm->otyp < STUDDED_LEATHER_ARMOR &&
246 (int) uarm->spe >= -1) {
247 pline("Your armor rusts!");
252 if(ctmp && !rn2(8)) {
253 poisoned("snake's bite",mdat->mname);
258 poisoned("scorpion's sting",mdat->mname);
260 (void) hitu(mtmp,rnd(8));
261 (void) hitu(mtmp,rnd(8));
264 (void) hitu(mtmp,rnd(6));
265 (void) hitu(mtmp,rnd(6));
268 if(!rn2(5)) rloc(mtmp);
274 (void) hitu(mtmp,d(3,4));
275 (void) hitu(mtmp,d(3,4));
278 if(ctmp && !u.ustuck) u.ustuck = mtmp;
289 if(tmp) wormhit(mtmp);
293 (void) hitu(mtmp,rnd(5));
294 (void) hitu(mtmp,rnd(5));
295 (void) hitu(mtmp,rnd(5));
298 { long side = rn2(2) ? RIGHT_SIDE : LEFT_SIDE;
299 pline("%s pricks in your %s leg!",
300 Monnam(mtmp), (side == RIGHT_SIDE) ? "right" : "left");
301 set_wounded_legs(side, rnd(50));
306 if(mtmp->mcan) break;
309 pline("You are blinded by a blast of light!");
315 (void) hitu(mtmp,rnd(6));
318 if(u.uhp < 1) done_in_by(mtmp);
329 if(u.uswallow) return(0);
331 if(mtmp->mhide && mtmp->mundetected) {
332 mtmp->mundetected = 0;
335 extern char * Xmonnam();
336 if(obj = o_at(mtmp->mx,mtmp->my))
337 pline("%s was hidden under %s!",
338 Xmonnam(mtmp), doname(obj));
343 /* give people with Ac = -10 at least some vulnerability */
345 dam += tmp; /* decrease damage */
346 if(dam <= 0) dam = 1;
349 tmp += mtmp->data->mlevel;
350 if(multi < 0) tmp += 4;
351 if((Invis && mtmp->data->mlet != 'I') || !mtmp->mcansee) tmp -= 2;
352 if(mtmp->mtrapped) tmp -= 2;
354 if(Blind) pline("It misses.");
355 else pline("%s misses.",Monnam(mtmp));
358 if(Blind) pline("It hits!");
359 else pline("%s hits!",Monnam(mtmp));