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