1 /* @(#)com7.c 8.2 (Berkeley) 4/28/95 */
2 /* $NetBSD: command7.c,v 1.4 2018/02/04 08:48:05 mrg Exp $ */
5 * Copyright (c) 1983, 1993
6 * The Regents of the University of California. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 fight(int enemy
, int strength
)
40 char auxbuf
[LINELENGTH
];
50 exhaustion
= CYCLE
/ (snooze
- ourtime
);
52 puts("You collapse exhausted, and he pulverizes your skull.");
55 if (snooze
- ourtime
< 20)
56 puts("You look tired! I hope you're able to fight.");
57 next
= getcom(auxbuf
, LINELENGTH
, "<fight!>-: ", 0);
58 for (i
= 0; next
&& i
< 10; i
++)
59 next
= getword(next
, words
[i
], -1);
61 switch (wordvalue
[wordnumber
]) {
65 if (testbit(inven
, TWO_HANDED
))
66 hurt
= rnd(70) - 2 * card(injuries
, NUMOFINJURIES
) -
67 ucard(wear
) - exhaustion
;
68 else if (testbit(inven
, SWORD
) || testbit(inven
, BROAD
))
69 hurt
= rnd(50) % (WEIGHT
- carrying
) -
70 card(injuries
, NUMOFINJURIES
) - encumber
-
72 else if (testbit(inven
, KNIFE
) || testbit(inven
, MALLET
) ||
73 testbit(inven
, CHAIN
) || testbit(inven
, MACE
) ||
74 testbit(inven
, HALBERD
))
75 hurt
= rnd(15) - card(injuries
, NUMOFINJURIES
) -
78 hurt
= rnd(7) - encumber
;
83 puts("You swung wide and missed.");
86 puts("He checked your blow. CLASH! CLANG!");
89 printf("His filthy tunic hangs by one less ");
96 puts("He's bleeding.");
99 puts("A trickle of blood runs down his face.");
102 printf("A huge purple bruise is forming on ");
103 puts("the side of his face.");
107 } else if (hurt
< 20) {
110 puts("He staggers back quavering.");
113 printf("He jumps back with his hand over ");
117 printf("His shirt falls open with a swath ");
118 puts("across the chest.");
122 } else if (hurt
< 30) {
125 printf("A bloody gash opens up on his %s ",
126 (rnd(2) ? "left" : "right"));
130 printf("The steel bites home and scrapes ");
131 puts("along his ribs.");
134 printf("You pierce him, and his breath ");
135 puts("hisses through clenched teeth.");
139 } else if (hurt
< 40) {
142 puts("You smite him to the ground.");
143 if (strength
- lifeline
> 20) {
144 printf("But in a flurry of steel he ");
145 puts("regains his feet!");
149 printf("The force of your blow sends him to ");
151 puts("His arm swings lifeless at his side.");
154 printf("Clutching his blood drenched shirt, ");
155 puts("he collapses stunned.");
162 printf("His ribs crack under your powerful ");
163 puts("swing, flooding his lungs with blood.");
166 printf("You shatter his upheld arm in a ");
167 printf("spray of blood. The blade ");
168 puts("continues deep");
169 printf("into his back, severing the ");
170 puts("spinal cord.");
174 printf("With a mighty lunge the steel ");
175 printf("slides in, and gasping, he falls ");
176 puts("to the ground.");
185 if (enemy
== DARK
&& lifeline
> strength
* 0.33) {
186 printf("He throws you back against the rock and ");
187 puts("pummels your face.");
188 if (testbit(inven
, AMULET
) || testbit(wear
, AMULET
)) {
189 printf("Lifting the amulet from you, ");
190 if (testbit(inven
, MEDALION
) ||
191 testbit(wear
, MEDALION
)) {
192 printf("his power grows and the ");
193 printf("walls of\nthe earth ");
194 printf("tremble.\n");
195 printf("When he touches the ");
196 printf("medallion, your chest ");
197 printf("explodes and the foundations ");
198 printf("of the\nearth collapse.\n");
199 printf("The planet is consumed by ");
203 if (testbit(inven
, AMULET
)) {
204 clearbit(inven
, AMULET
);
205 carrying
-= objwt
[AMULET
];
206 encumber
-= objcumber
[AMULET
];
208 clearbit(wear
, AMULET
);
209 puts("he flees down the dark caverns.");
210 clearbit(location
[position
].objects
, DARK
);
212 followfight
= ourtime
;
215 puts("I'm afraid you have been killed.");
219 printf("You escape stunned and disoriented from ");
221 printf("A victorious bellow echoes from the ");
222 puts("battlescene.");
223 if (back
&& position
!= back
)
224 moveplayer(back
, BACK
);
225 else if (ahead
&& position
!= ahead
)
226 moveplayer(ahead
, AHEAD
);
227 else if (left
&& position
!= left
)
228 moveplayer(left
, LEFT
);
229 else if (right
&& position
!= right
)
230 moveplayer(right
, RIGHT
);
232 moveplayer(location
[position
].down
, AHEAD
);
237 if (testbit(inven
, LASER
)) {
238 if (strength
- lifeline
<= 50) {
239 printf("The %s took a direct hit!\n",
243 printf("With his bare hand he deflects the ");
244 printf("laser blast and whips the pistol ");
246 clearbit(inven
, LASER
);
247 setbit(location
[position
].objects
, LASER
);
248 carrying
-= objwt
[LASER
];
249 encumber
-= objcumber
[LASER
];
252 puts("Unfortunately, you don't have a blaster handy.");
262 puts("You don't have a chance; he is too quick.");
266 if (lifeline
>= strength
) {
267 printf("You have killed the %s.\n", objsht
[enemy
]);
268 if (enemy
== ELF
|| enemy
== DARK
) {
269 printf("A watery black smoke consumes his body and ");
270 puts("then vanishes with a peal of thunder!");
272 clearbit(location
[position
].objects
, enemy
);
277 puts("He attacks...");
278 /* Some embellishments. */
279 hurt
= rnd(NUMOFINJURIES
) - (testbit(inven
, SHIELD
) != 0) -
280 (testbit(wear
, MAIL
) != 0) - (testbit(wear
, HELM
) != 0);
281 hurt
+= (testbit(wear
, AMULET
) != 0) +
282 (testbit(wear
, MEDALION
) != 0) + (testbit(wear
, TALISMAN
) != 0);
283 hurt
= hurt
< 0 ? 0 : hurt
;
284 hurt
= hurt
>= NUMOFINJURIES
? NUMOFINJURIES
- 1 : hurt
;
285 if (!injuries
[hurt
]) {
287 printf("I'm afraid you have suffered %s.\n", ouch
[hurt
]);
289 puts("You emerge unscathed.");
290 if (injuries
[SKULL
] && injuries
[INCISE
] && injuries
[NECK
]) {
291 puts("I'm afraid you have suffered fatal injuries.");