]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.mhitu.c
1 /* $NetBSD: hack.mhitu.c,v 1.6 2003/04/02 18:36:37 jsm Exp $ */
4 * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
12 * - Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * - Neither the name of the Stichting Centrum voor Wiskunde en
20 * Informatica, nor the names of its contributors may be used to endorse or
21 * promote products derived from this software without specific prior
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
25 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
27 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
28 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 * Copyright (c) 1982 Jay Fenlason <hack@gnu.org>
39 * All rights reserved.
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution.
49 * 3. The name of the author may not be used to endorse or promote products
50 * derived from this software without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
53 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
54 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
55 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
56 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
57 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
58 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
59 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
60 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
61 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 #include <sys/cdefs.h>
66 __RCSID("$NetBSD: hack.mhitu.c,v 1.6 2003/04/02 18:36:37 jsm Exp $");
73 * mhitu: monster hits you
74 * returns 1 if monster dies (e.g. 'y', 'F'), 0 otherwise
80 const struct permonst
*mdat
= mtmp
->data
;
85 /* If swallowed, can only be affected by hissers and by u.ustuck */
87 if (mtmp
!= u
.ustuck
) {
88 if (mdat
->mlet
== 'c' && !rn2(13)) {
89 pline("Outside, you hear %s's hissing!",
91 pline("%s gets turned to stone!",
93 pline("And the same fate befalls you.");
95 /* "notreached": not return(1); */
99 switch (mdat
->mlet
) { /* now mtmp == u.ustuck */
101 youswld(mtmp
, (u
.uac
> 0) ? u
.uac
+ 4 : 4,
105 youswld(mtmp
, rnd(6), 7, "The lurker above");
108 youswld(mtmp
, d(2, 4), 12, "The purple worm");
111 /* This is not impossible! */
112 pline("The mysterious monster totally digests you.");
119 if (mdat
->mlet
== 'c' && Stoned
)
122 /* make eels visible the moment they hit/miss us */
123 if (mdat
->mlet
== ';' && mtmp
->minvis
&& cansee(mtmp
->mx
, mtmp
->my
)) {
127 if (!strchr("1&DuxynNF", mdat
->mlet
))
128 tmp
= hitu(mtmp
, d(mdat
->damn
, mdat
->damd
));
131 if (strchr(UNDEAD
, mdat
->mlet
) && midnight())
132 tmp
+= hitu(mtmp
, d(mdat
->damn
, mdat
->damd
));
134 ctmp
= tmp
&& !mtmp
->mcan
&&
135 (!uarm
|| objects
[uarm
->otyp
].a_can
< rnd(3) || !rn2(50));
136 switch (mdat
->mlet
) {
139 return (1); /* he disappeared */
142 if (!mtmp
->cham
&& !mtmp
->mcan
&& !rn2(13)) {
143 (void) makemon(PM_DEMON
, u
.ux
, u
.uy
);
145 (void) hitu(mtmp
, d(2, 6));
146 (void) hitu(mtmp
, d(2, 6));
147 (void) hitu(mtmp
, rnd(3));
148 (void) hitu(mtmp
, rnd(3));
149 (void) hitu(mtmp
, rn1(4, 2));
154 justswld(mtmp
, "The trapper");
158 justswld(mtmp
, "The lurker above");
162 if (!u
.ustuck
&& !rn2(10)) {
163 pline("%s swings itself around you!",
166 } else if (u
.ustuck
== mtmp
&&
167 levl
[mtmp
->mx
][mtmp
->my
].typ
== POOL
) {
168 pline("%s drowns you ...", Monnam(mtmp
));
174 if (ctmp
&& rn2(2)) {
175 if (Poison_resistance
)
176 pline("The sting doesn't seem to affect you.");
178 pline("You feel weaker!");
184 (void) hitu(mtmp
, rnd(6));
188 pline("You hear %s's hissing!", monnam(mtmp
));
189 if (ctmp
|| !rn2(20) || (flags
.moonphase
== NEW_MOON
190 && !carrying(DEAD_LIZARD
))) {
192 /* pline("You get turned to stone!"); */
193 /* done_in_by(mtmp); */
198 if (rn2(6) || mtmp
->mcan
) {
199 (void) hitu(mtmp
, d(3, 10));
200 (void) hitu(mtmp
, rnd(8));
201 (void) hitu(mtmp
, rnd(8));
204 kludge("%s breathes fire!", "The dragon");
205 buzz(-1, mtmp
->mx
, mtmp
->my
, u
.ux
- mtmp
->mx
, u
.uy
- mtmp
->my
);
208 (void) hitu(mtmp
, d(2, (flags
.moonphase
== FULL_MOON
) ? 3 : 4));
211 (void) hitu(mtmp
, d(3, 6));
216 kludge("%s explodes!", "The freezing sphere");
218 pline("You don't seem affected by it.");
221 if (17 - (u
.ulevel
/ 2) > rnd(20)) {
222 pline("You get blasted!");
225 pline("You duck the blast...");
228 losehp_m(d(dn
, 6), mtmp
);
233 if (ctmp
&& multi
>= 0 && !rn2(3)) {
234 kludge("You are frozen by %ss juices", "the cube'");
239 if (ctmp
&& multi
>= 0 && !rn2(5)) {
241 kludge("You are put to sleep by %ss bite!",
246 tmp
= hitu(mtmp
, rnd(3));
247 tmp
&= hitu(mtmp
, rnd(3));
249 (void) hitu(mtmp
, rnd(4));
250 (void) hitu(mtmp
, rnd(4));
254 if ((hitu(mtmp
, rnd(4)) || !rn2(3)) && ctmp
) {
255 poisoned("bee's sting", mdat
->mname
);
263 if (mtmp
->mcan
&& !Blind
) {
264 pline("%s tries to seduce you, but you seem not interested.",
265 Amonnam(mtmp
, "plain"));
268 } else if (steal(mtmp
)) {
274 if (!uwep
&& !uarm
&& !uarmh
&& !uarms
&& !uarmg
) {
275 pline("%s hits! (I hope you don't mind)",
280 if (u
.uhp
> u
.uhpmax
)
286 (void) hitu(mtmp
, d(2, 6));
287 (void) hitu(mtmp
, d(2, 6));
291 tmp
= hitu(mtmp
, rnd(6));
292 if (hitu(mtmp
, rnd(6)) && tmp
&& /* hits with both paws */
293 !u
.ustuck
&& rn2(2)) {
295 kludge("%s has grabbed you!", "The owlbear");
297 } else if (u
.ustuck
== mtmp
) {
299 pline("You are being crushed.");
304 justswld(mtmp
, "The purple worm");
306 (void) hitu(mtmp
, d(2, 4));
309 (void) hitu(mtmp
, rnd(2));
310 (void) hitu(mtmp
, rnd(2));
313 if (tmp
&& uarmh
&& !uarmh
->rustfree
&&
314 (int) uarmh
->spe
>= -1) {
315 pline("Your helmet rusts!");
317 } else if (ctmp
&& uarm
&& !uarm
->rustfree
&& /* Mike Newton */
318 uarm
->otyp
< STUDDED_LEATHER_ARMOR
&&
319 (int) uarm
->spe
>= -1) {
320 pline("Your armor rusts!");
325 if (ctmp
&& !rn2(8)) {
326 poisoned("snake's bite", mdat
->mname
);
330 if (tmp
&& !rn2(8)) {
331 poisoned("scorpion's sting", mdat
->mname
);
333 (void) hitu(mtmp
, rnd(8));
334 (void) hitu(mtmp
, rnd(8));
337 (void) hitu(mtmp
, rnd(6));
338 (void) hitu(mtmp
, rnd(6));
348 (void) hitu(mtmp
, d(3, 4));
349 (void) hitu(mtmp
, d(3, 4));
352 if (ctmp
&& !u
.ustuck
)
372 (void) hitu(mtmp
, rnd(5));
373 (void) hitu(mtmp
, rnd(5));
374 (void) hitu(mtmp
, rnd(5));
378 long side
= rn2(2) ? RIGHT_SIDE
: LEFT_SIDE
;
379 pline("%s pricks in your %s leg!",
380 Monnam(mtmp
), (side
== RIGHT_SIDE
) ? "right" : "left");
381 set_wounded_legs(side
, rnd(50));
390 pline("You are blinded by a blast of light!");
396 (void) hitu(mtmp
, rnd(6));
415 if (mtmp
->mhide
&& mtmp
->mundetected
) {
416 mtmp
->mundetected
= 0;
419 if ((obj
= o_at(mtmp
->mx
, mtmp
->my
)) != NULL
)
420 pline("%s was hidden under %s!",
421 Xmonnam(mtmp
), doname(obj
));
425 /* give people with Ac = -10 at least some vulnerability */
427 dam
+= tmp
; /* decrease damage */
432 tmp
+= mtmp
->data
->mlevel
;
435 if ((Invis
&& mtmp
->data
->mlet
!= 'I') || !mtmp
->mcansee
)
439 if (tmp
<= rnd(20)) {
443 pline("%s misses.", Monnam(mtmp
));
449 pline("%s hits!", Monnam(mtmp
));