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