1 /* $NetBSD: command7.c,v 1.2 2003/08/07 09:37:01 agc Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
35 static char sccsid
[] = "@(#)com7.c 8.2 (Berkeley) 4/28/95";
37 __RCSID("$NetBSD: command7.c,v 1.2 2003/08/07 09:37:01 agc Exp $");
44 fight(int enemy
, int strength
)
48 char auxbuf
[LINELENGTH
];
58 exhaustion
= CYCLE
/ (snooze
- ourtime
);
60 puts("You collapse exhausted, and he pulverizes your skull.");
63 if (snooze
- ourtime
< 20)
64 puts("You look tired! I hope you're able to fight.");
65 next
= getcom(auxbuf
, LINELENGTH
, "<fight!>-: ", 0);
66 for (i
= 0; next
&& i
< 10; i
++)
67 next
= getword(next
, words
[i
], -1);
69 switch (wordvalue
[wordnumber
]) {
73 if (testbit(inven
, TWO_HANDED
))
74 hurt
= rnd(70) - 2 * card(injuries
, NUMOFINJURIES
) -
75 ucard(wear
) - exhaustion
;
76 else if (testbit(inven
, SWORD
) || testbit(inven
, BROAD
))
77 hurt
= rnd(50) % (WEIGHT
- carrying
) -
78 card(injuries
, NUMOFINJURIES
) - encumber
-
80 else if (testbit(inven
, KNIFE
) || testbit(inven
, MALLET
) ||
81 testbit(inven
, CHAIN
) || testbit(inven
, MACE
) ||
82 testbit(inven
, HALBERD
))
83 hurt
= rnd(15) - card(injuries
, NUMOFINJURIES
) -
86 hurt
= rnd(7) - encumber
;
91 puts("You swung wide and missed.");
94 puts("He checked your blow. CLASH! CLANG!");
97 printf("His filthy tunic hangs by one less ");
101 else if (hurt
< 10) {
104 puts("He's bleeding.");
107 puts("A trickle of blood runs down his face.");
110 printf("A huge purple bruise is forming on ");
111 puts("the side of his face.");
115 } else if (hurt
< 20) {
118 puts("He staggers back quavering.");
121 printf("He jumps back with his hand over ");
125 printf("His shirt falls open with a swath ");
126 puts("across the chest.");
130 } else if (hurt
< 30) {
133 printf("A bloody gash opens up on his %s ",
134 (rnd(2) ? "left" : "right"));
138 printf("The steel bites home and scrapes ");
139 puts("along his ribs.");
142 printf("You pierce him, and his breath ");
143 puts("hisses through clenched teeth.");
147 } else if (hurt
< 40) {
150 puts("You smite him to the ground.");
151 if (strength
- lifeline
> 20) {
152 printf("But in a flurry of steel he ");
153 puts("regains his feet!");
157 printf("The force of your blow sends him to ");
159 puts("His arm swings lifeless at his side.");
162 printf("Clutching his blood drenched shirt, ");
163 puts("he collapses stunned.");
170 printf("His ribs crack under your powerful ");
171 puts("swing, flooding his lungs with blood.");
174 printf("You shatter his upheld arm in a ");
175 printf("spray of blood. The blade ");
176 puts("continues deep");
177 printf("into his back, severing the ");
178 puts("spinal cord.");
182 printf("With a mighty lunge the steel ");
183 printf("slides in, and gasping, he falls ");
184 puts("to the ground.");
193 if (enemy
== DARK
&& lifeline
> strength
* 0.33) {
194 printf("He throws you back against the rock and ");
195 puts("pummels your face.");
196 if (testbit(inven
, AMULET
) || testbit(wear
, AMULET
)) {
197 printf("Lifting the amulet from you, ");
198 if (testbit(inven
, MEDALION
) ||
199 testbit(wear
, MEDALION
)) {
200 printf("his power grows and the ");
201 printf("walls of\nthe earth ");
202 printf("tremble.\n");
203 printf("When he touches the ");
204 printf("medallion, your chest ");
205 printf("explodes and the foundations ");
206 printf("of the\nearth collapse.\n");
207 printf("The planet is consumed by ");
211 if (testbit(inven
, AMULET
)) {
212 clearbit(inven
, AMULET
);
213 carrying
-= objwt
[AMULET
];
214 encumber
-= objcumber
[AMULET
];
216 clearbit(wear
, AMULET
);
217 puts("he flees down the dark caverns.");
218 clearbit(location
[position
].objects
, DARK
);
220 followfight
= ourtime
;
223 puts("I'm afraid you have been killed.");
227 printf("You escape stunned and disoriented from ");
229 printf("A victorious bellow echoes from the ");
230 puts("battlescene.");
231 if (back
&& position
!= back
)
232 moveplayer(back
, BACK
);
233 else if (ahead
&& position
!= ahead
)
234 moveplayer(ahead
, AHEAD
);
235 else if (left
&& position
!= left
)
236 moveplayer(left
, LEFT
);
237 else if (right
&& position
!= right
)
238 moveplayer(right
, RIGHT
);
240 moveplayer(location
[position
].down
, AHEAD
);
245 if (testbit(inven
, LASER
)) {
246 if (strength
- lifeline
<= 50) {
247 printf("The %s took a direct hit!\n",
251 printf("With his bare hand he deflects the ");
252 printf("laser blast and whips the pistol ");
254 clearbit(inven
, LASER
);
255 setbit(location
[position
].objects
, LASER
);
256 carrying
-= objwt
[LASER
];
257 encumber
-= objcumber
[LASER
];
260 puts("Unfortunately, you don't have a blaster handy.");
270 puts("You don't have a chance; he is too quick.");
274 if (lifeline
>= strength
) {
275 printf("You have killed the %s.\n", objsht
[enemy
]);
276 if (enemy
== ELF
|| enemy
== DARK
)
277 printf("A watery black smoke consumes his body and ");
278 puts("then vanishes with a peal of thunder!");
279 clearbit(location
[position
].objects
, enemy
);
284 puts("He attacks...");
285 /* Some embellishments. */
286 hurt
= rnd(NUMOFINJURIES
) - (testbit(inven
, SHIELD
) != 0) -
287 (testbit(wear
, MAIL
) != 0) - (testbit(wear
, HELM
) != 0);
288 hurt
+= (testbit(wear
, AMULET
) != 0) +
289 (testbit(wear
, MEDALION
) != 0) + (testbit(wear
, TALISMAN
) != 0);
290 hurt
= hurt
< 0 ? 0 : hurt
;
291 hurt
= hurt
>= NUMOFINJURIES
? NUMOFINJURIES
- 1 : hurt
;
292 if (!injuries
[hurt
]) {
294 printf("I'm afraid you have suffered %s.\n", ouch
[hurt
]);
296 puts("You emerge unscathed.");
297 if (injuries
[SKULL
] && injuries
[INCISE
] && injuries
[NECK
]) {
298 puts("I'm afraid you have suffered fatal injuries.");