|
|
1.1 root 1: #ifndef lint
2: static char *sccsid = "@(#)assorted.c 1.1 83/03/17";
3: #endif
4: #define EXPLODE 5
5: #include "externs.h"
6:
7: table(rig, shot, hittable, onship, fromship, roll)
8: int rig, shot, hittable, onship, fromship, roll;
9: {
10: register int hhits = 0, chits = 0, ghits = 0, rhits = 0;
11: int Ghit = 0, Hhit = 0, Rhit = 0, Chit = 0;
12: int guns, car, pc, hull;
13: int crew[3];
14: register int n;
15: int rigg[4];
16: char message[60];
17: struct shipspecs *ptr;
18: struct File *ptr1;
19:
20: ptr = &specs[scene[game].ship[onship].shipnum];
21: ptr1 = scene[game].ship[onship].file;
22: pc = ptr1 -> pcrew;
23: hull = ptr -> hull;
24: crew[0] = ptr -> crew1;
25: crew[1] = ptr -> crew2;
26: crew[2] = ptr -> crew3;
27: rigg[0] = ptr -> rig1;
28: rigg[1] = ptr -> rig2;
29: rigg[2] = ptr -> rig3;
30: rigg[3] = ptr -> rig4;
31: if (shot == GRAPE)
32: Chit = chits = hittable;
33: else {
34: Chit = chits = rig ? RigTable[hittable][roll-1].C : HullTable[hittable][roll-1].C;
35: Rhit = rhits = rig ? RigTable[hittable][roll-1].R : HullTable[hittable][roll-1].R;
36: Hhit = hhits = rig ? RigTable[hittable][roll-1].H : HullTable[hittable][roll-1].H;
37: Ghit = ghits = rig ? RigTable[hittable][roll-1].G : HullTable[hittable][roll-1].G;
38: if (ptr1 -> FS)
39: rhits *= 2;
40: if (shot == CHAIN){
41: Ghit = ghits = 0;
42: Hhit = hhits = 0;
43: }
44: }
45: if (ptr1 -> captured > -1){
46: pc -= (chits + 1)/2;
47: chits /= 2;
48: }
49: for (n=0; n < 3; n++)
50: if (chits > crew[n]){
51: chits -= crew[n];
52: crew[n] = 0;
53: }
54: else {
55: crew[n] -= chits;
56: chits = 0;
57: }
58: for (n=0; n < 3; n++)
59: if (rhits > rigg[n]){
60: rhits -= rigg[n];
61: rigg[n] = 0;
62: }
63: else {
64: rigg[n] -= rhits;
65: rhits = 0;
66: }
67: if (rigg[3] != -1 && rhits > rigg[3]){
68: rhits -= rigg[3];
69: rigg[3] = 0;
70: } else if (rigg[3] != -1){
71: rigg[3] -= rhits;
72: }
73: if (rig && !rigg[2] && (!rigg[3] || rigg[3] == -1))
74: makesignal("dismasted!", 0, onship);
75: if (portside(fromship, onship, 0)){
76: guns = ptr -> gunL;
77: car = ptr -> carL;
78: } else {
79: guns = ptr -> gunR;
80: car = ptr -> carR;
81: }
82: if (ghits > car){
83: ghits -= car;
84: car = 0;
85: }
86: else {
87: car -= ghits;
88: ghits = 0;
89: }
90: if (ghits > guns){
91: ghits -= guns;
92: guns = 0;
93: }
94: else {
95: guns -= ghits;
96: ghits = 0;
97: }
98: hull -= ghits;
99: if (portside(fromship, onship, 0) && Ghit){
100: Write(SPECS + onship, 0, 20, guns);
101: Write(SPECS + onship, 0, 24, car);
102: }
103: else if (Ghit){
104: Write(SPECS + onship, 0, 22, guns);
105: Write(SPECS + onship, 0, 26, car);
106: }
107: hull -= hhits;
108: hull = hull < 0 ? 0 : hull;
109: if (ptr1 -> captured > -1 && Chit){
110: Write(FILES + onship, 0, 70, pc);
111: }
112: if (Hhit)
113: Write(SPECS + onship, 0, 10, hull);
114: if (Chit)
115: for (n=0; n < 3; n++)
116: Write(SPECS + onship, 0, 14 + 2*n, crew[n]);
117: if (Rhit)
118: for (n=0; n < 4; n++)
119: Write(SPECS + onship, 0, 28 + 2*n, rigg[n]);
120: switch(shot){
121: case ROUND:
122: strcpy(message, "firing round");
123: break;
124: case GRAPE:
125: strcpy(message, "firing grape");
126: break;
127: case CHAIN:
128: strcpy(message, "firing chain");
129: break;
130: case DOUBLE:
131: strcpy(message, "firing double");
132: break;
133: case EXPLODE:
134: strcpy(message, "exploding");
135: }
136: strcat(message, " shot on %s (%c%c)");
137: makesignal(message, onship, fromship);
138: if (roll == 6 && rig){
139: switch(Rhit){
140: case 0:
141: strcpy(message, "fore topsail sheets parted");
142: break;
143: case 1:
144: strcpy(message, "mizzen shrouds parted");
145: break;
146: case 2:
147: strcpy(message, "main topsail yard shot away");
148: break;
149: case 4:
150: strcpy(message, "fore topmast and foremast shrouds shot away");
151: break;
152: case 5:
153: strcpy(message, "mizzen mast and yard shot through");
154: break;
155: case 6:
156: strcpy(message, "foremast and spritsail yard shattered");
157: break;
158: case 7:
159: strcpy(message, "main topmast and mizzen mast shattered");
160: break;
161: }
162: makesignal(message, 0, onship);
163: }
164: else if (roll == 6) {
165: switch(Hhit){
166: case 0:
167: strcpy(message, "anchor cables severed");
168: break;
169: case 1:
170: strcpy(message, "two anchor stocks shot away");
171: break;
172: case 2:
173: strcpy(message, "quarterdeck bulwarks damaged");
174: break;
175: case 3:
176: strcpy(message, "three gun ports shot away");
177: break;
178: case 4:
179: strcpy(message, "four guns dismounted");
180: break;
181: case 5:
182: strcpy(message, "rudder cables shot through");
183: Write(SPECS + onship, 0, 4, 0);
184: break;
185: case 6:
186: strcpy(message, "shot holes below the water line");
187: break;
188: }
189: makesignal(message, 0, onship);
190: }
191: if ((Chit > 1 && ptr1 -> readyL <= -30000 && ptr1 -> readyR <= -30000) || Chit == 4){
192: ptr -> qual--;
193: if (ptr -> qual <= 0){
194: makesignal("crew mutinying!", 0, onship);
195: ptr -> qual = 5;
196: Write(FILES + onship, 0, 68, onship);
197: } else
198: makesignal("crew demoralized", 0, onship);
199: Write(SPECS + onship, 0, 12, ptr -> qual);
200: }
201: if (!hull)
202: strike(onship, fromship);
203: }
204:
205:
206: cleanfoul(fromship, toship, offset)
207: int fromship, toship, offset;
208: {
209: register int n = -1;
210:
211: Write(FILES + fromship, 0, 84 + offset*4, 0);
212: do {
213: n++;
214: } while ((!scene[game].ship[toship].file -> fouls[n].turnfoul || scene[game].ship[toship].file -> fouls[n].toship != fromship) && n < 10);
215: if (n < 10)
216: Write(FILES + toship, 0, 84 + 4*n, 0);
217: if (!grapple(fromship, toship) && !foul(fromship,toship)){
218: if (!fouled(fromship) && !grappled(fromship)){
219: unboard(fromship,fromship, 1); /* defense */
220: unboard(fromship,fromship, 0); /* defense */
221: } else
222: unboard(fromship,toship, 0); /* defense */
223: if (!fouled(toship) && !grappled(toship)){ /* defense */
224: unboard(toship,toship, 1);
225: unboard(toship,toship, 0);
226: } else
227: unboard(toship, fromship, 0); /* offense */
228: }
229: }
230:
231:
232: cleangrapple(fromship, toship, offset)
233: int fromship, toship, offset;
234: {
235: register int n = -1;
236:
237: Write(FILES + fromship, 0, 124 + offset*4, 0);
238: do {
239: n++;
240: } while ((!scene[game].ship[toship].file -> grapples[n].turnfoul || scene[game].ship[toship].file -> grapples[n].toship != fromship) && n < 10);
241: if (n < 10)
242: Write(FILES + toship, 0, 124 + 4*n, 0);
243: if (!grapple(fromship, toship) && !foul(fromship,toship)){
244: if (!fouled(fromship) && !grappled(fromship)){
245: unboard(fromship,fromship, 1); /* defense */
246: unboard(fromship,fromship, 0); /* defense */
247: } else
248: unboard(fromship,toship, 0); /* defense */
249: if (!fouled(toship) && !grappled(toship)){ /* defense */
250: unboard(toship,toship, 1);
251: unboard(toship,toship, 0);
252: } else
253: unboard(toship, fromship, 0); /* offense */
254: }
255: }
256:
257:
258: strike(shipnum, fromship)
259: int shipnum, fromship;
260: {
261: int points;
262:
263: if (!scene[game].ship[shipnum].file -> struck){
264: Write(FILES + shipnum, 0, 66, 1);
265: points = specs[scene[game].ship[shipnum].shipnum].pts + scene[game].ship[fromship].file -> points;
266: Write(FILES + fromship, 0, 20, points);
267: unboard(shipnum, shipnum, 0); /* all offense */
268: unboard(shipnum, shipnum, 1); /* all defense */
269: switch(die()){
270:
271: case 3:
272: case 4: /* ship may sink */
273: Write(FILES + shipnum, 0, 234, 1);
274: break;
275: case 5:
276: case 6: /* ship may explode */
277: Write(FILES + shipnum, 0, 232, 1);
278: break;
279: }
280: Write(FILES + shipnum, 1, 164, "striking her colours!");
281: }
282: }
283:
284:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.