1 /*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)com7.c 8.2 (Berkeley) 04/28/95";
10 #endif /* not lint */
11
12 #include "extern.h"
13
fight(enemy,strength)14 fight(enemy,strength)
15 int enemy,strength;
16 {
17 int lifeline = 0;
18 int hurt;
19 char auxbuf[LINELENGTH];
20 char *next;
21 int i;
22 int exhaustion;
23
24 fighton:
25 time++;
26 snooze -= 5;
27 if (snooze > time)
28 exhaustion = CYCLE/(snooze - time);
29 else {
30 puts("You collapse exhausted, and he pulverizes your skull.");
31 die();
32 }
33 if (snooze - time < 20)
34 puts("You look tired! I hope you're able to fight.");
35 next = getcom(auxbuf, LINELENGTH, "<fight!>-: ", 0);
36 for (i=0; next && i < 10; i++)
37 next = getword(next, words[i], -1);
38 parse();
39 switch(wordvalue[wordnumber]){
40
41 case KILL:
42 case SMITE:
43 if (testbit(inven,TWO_HANDED))
44 hurt = rnd(70) - 2 * card(injuries,NUMOFINJURIES) - ucard(wear) - exhaustion;
45 else if (testbit(inven,SWORD) || testbit(inven, BROAD))
46 hurt = rnd(50)%(WEIGHT-carrying)-card(injuries,NUMOFINJURIES)-encumber - exhaustion;
47 else if (testbit(inven,KNIFE) || testbit(inven,MALLET) || testbit(inven,CHAIN) || testbit(inven,MACE) || testbit(inven,HALBERD))
48 hurt = rnd(15) - card(injuries,NUMOFINJURIES) - exhaustion;
49 else
50 hurt = rnd(7) - encumber;
51 if (hurt < 5)
52 switch(rnd(3)){
53
54 case 0:
55 puts("You swung wide and missed.");
56 break;
57 case 1:
58 puts("He checked your blow. CLASH! CLANG!");
59 break;
60 case 2:
61 puts("His filthy tunic hangs by one less thread.");
62 break;
63 }
64 else if (hurt < 10){
65 switch(rnd(3)){
66 case 0:
67 puts("He's bleeding.");
68 break;
69 case 1:
70 puts("A trickle of blood runs down his face.");
71 break;
72 case 2:
73 puts("A huge purple bruise is forming on the side of his face.");
74 break;
75 }
76 lifeline++;
77 }
78 else if (hurt < 20){
79 switch(rnd(3)){
80 case 0:
81 puts("He staggers back quavering.");
82 break;
83 case 1:
84 puts("He jumps back with his hand over the wound.");
85 break;
86 case 2:
87 puts("His shirt falls open with a swath across the chest.");
88 break;
89 }
90 lifeline += 5;
91 }
92 else if (hurt < 30){
93 switch(rnd(3)){
94 case 0:
95 printf("A bloody gash opens up on his %s side.\n",(rnd(2) ? "left" : "right"));
96 break;
97 case 1:
98 puts("The steel bites home and scrapes along his ribs.");
99 break;
100 case 2:
101 puts("You pierce him, and his breath hisses through clenched teeth.");
102 break;
103 }
104 lifeline += 10;
105 }
106 else if (hurt < 40){
107 switch(rnd(3)){
108 case 0:
109 puts("You smite him to the ground.");
110 if (strength - lifeline > 20)
111 puts("But in a flurry of steel he regains his feet!");
112 break;
113 case 1:
114 puts("The force of your blow sends him to his knees.");
115 puts("His arm swings lifeless at his side.");
116 break;
117 case 2:
118 puts("Clutching his blood drenched shirt, he collapses stunned.");
119 break;
120 }
121 lifeline += 20;
122 }
123 else {
124 switch(rnd(3)){
125 case 0:
126 puts("His ribs crack under your powerful swing, flooding his lungs with blood.");
127 break;
128 case 1:
129 puts("You shatter his upheld arm in a spray of blood. The blade continues deep");
130 puts("into his back, severing the spinal cord.");
131 lifeline += 25;
132 break;
133 case 2:
134 puts("With a mighty lunge the steel slides in, and gasping, he falls to the ground.");
135 lifeline += 25;
136 break;
137 }
138 lifeline += 30;
139 }
140 break;
141
142 case BACK:
143 if (enemy == DARK && lifeline > strength * 0.33){
144 puts("He throws you back against the rock and pummels your face.");
145 if (testbit(inven,AMULET) || testbit(wear,AMULET)){
146 printf("Lifting the amulet from you, ");
147 if (testbit(inven,MEDALION) || testbit(wear,MEDALION)){
148 puts("his power grows and the walls of\nthe earth tremble.");
149 puts("When he touches the medallion, your chest explodes and the foundations of the\nearth collapse.");
150 puts("The planet is consumed by darkness.");
151 die();
152 }
153 if (testbit(inven,AMULET)){
154 clearbit(inven,AMULET);
155 carrying -= objwt[AMULET];
156 encumber -= objcumber[AMULET];
157 }
158 else
159 clearbit(wear,AMULET);
160 puts("he flees down the dark caverns.");
161 clearbit(location[position].objects,DARK);
162 injuries[SKULL] = 1;
163 followfight = time;
164 return (0);
165 }
166 else{
167 puts("I'm afraid you have been killed.");
168 die();
169 }
170 }
171 else{
172 puts("You escape stunned and disoriented from the fight.");
173 puts("A victorious bellow echoes from the battlescene.");
174 if (back && position != back)
175 move(back,BACK);
176 else if (ahead &&position != ahead)
177 move(ahead,AHEAD);
178 else if (left && position != left)
179 move(left,LEFT);
180 else if (right && position != right)
181 move(right,RIGHT);
182 else
183 move(location[position].down,AHEAD);
184 return(0);
185 }
186
187 case SHOOT:
188 if (testbit(inven,LASER)){
189 if (strength - lifeline <= 50){
190 printf("The %s took a direct hit!\n",objsht[enemy]);
191 lifeline += 50;
192 }
193 else {
194 puts("With his bare hand he deflects the laser blast and whips the pistol from you!");
195 clearbit(inven,LASER);
196 setbit(location[position].objects,LASER);
197 carrying -= objwt[LASER];
198 encumber -= objcumber[LASER];
199 }
200 }
201 else
202 puts("Unfortunately, you don't have a blaster handy.");
203 break;
204
205 case DROP:
206 case DRAW:
207 cypher();
208 time--;
209 break;
210
211 default:
212 puts("You don't have a chance, he is too quick.");
213 break;
214
215 }
216 if (lifeline >= strength){
217 printf("You have killed the %s.\n", objsht[enemy]);
218 if (enemy == ELF || enemy == DARK)
219 puts("A watery black smoke consumes his body and then vanishes with a peal of thunder!");
220 clearbit(location[position].objects,enemy);
221 power += 2;
222 notes[JINXED]++;
223 return(0);
224 }
225 puts("He attacks...");
226 /* some embellisments */
227 hurt = rnd(NUMOFINJURIES) - (testbit(inven,SHIELD) != 0) - (testbit(wear,MAIL) != 0) - (testbit(wear,HELM) != 0);
228 hurt += (testbit(wear,AMULET) != 0) + (testbit(wear,MEDALION) != 0) + (testbit(wear,TALISMAN) != 0);
229 hurt = hurt < 0 ? 0 : hurt;
230 hurt = hurt >= NUMOFINJURIES ? NUMOFINJURIES -1 : hurt;
231 if (!injuries[hurt]){
232 injuries[hurt] = 1;
233 printf("I'm afraid you have suffered %s.\n", ouch[hurt]);
234 }
235 else
236 puts("You emerge unscathed.");
237 if (injuries[SKULL] && injuries[INCISE] && injuries[NECK]){
238 puts("I'm afraid you have suffered fatal injuries.");
239 die();
240 }
241 goto fighton;
242 }
243