Rev 7142 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7142 | siemargl | 1 | #include |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #ifndef INCLUDED |
||
6 | #define EXTERN extern |
||
7 | #else |
||
8 | #define EXTERN |
||
9 | #endif |
||
10 | |||
11 | #ifdef WINDOWS |
||
12 | #define DEBUG |
||
13 | #define SCORE |
||
14 | #define CLOAKING |
||
15 | #define CAPTURE |
||
16 | #endif |
||
17 | |||
18 | #ifdef CLOAKING |
||
19 | #define ndevice (16) |
||
20 | #else |
||
21 | #define ndevice (15) // Number of devices |
||
22 | #endif |
||
23 | #define phasefac (2.0) |
||
24 | #define PLNETMAX (10) |
||
25 | #define NEVENTS (8) |
||
26 | |||
27 | typedef struct { |
||
28 | int x; /* Quadrant location of planet */ |
||
29 | int y; |
||
30 | int pclass; /* class M, N, or O (1, 2, or 3) */ |
||
31 | int crystals; /* has crystals */ |
||
32 | int known; /* =1 contents known, =2 shuttle on this planet */ |
||
33 | } PLANETS; |
||
34 | |||
35 | EXTERN struct foo { |
||
36 | int snap, // snapshot taken |
||
37 | remkl, // remaining klingons |
||
38 | remcom, // remaining commanders |
||
39 | rembase, // remaining bases |
||
40 | starkl, // destroyed stars |
||
41 | basekl, // destroyed bases |
||
42 | killk, // Klingons killed |
||
43 | killc, // commanders killed |
||
44 | galaxy[9][9], // The Galaxy (subscript 0 not used) |
||
45 | cx[11],cy[11], // Commander quadrant coordinates |
||
46 | baseqx[6], // Base quadrant X |
||
47 | baseqy[6], // Base quadrant Y |
||
48 | newstuf[9][9], // Extended galaxy goodies |
||
49 | isx, isy, // Coordinate of Super Commander |
||
50 | nscrem, // remaining super commanders |
||
51 | nromkl, // Romulans killed |
||
52 | nromrem, // Romulans remaining |
||
53 | nsckill, // super commanders killed |
||
54 | nplankl; // destroyed planets |
||
55 | PLANETS plnets[PLNETMAX+1]; // Planet information |
||
56 | #ifdef CAPTURE |
||
57 | int kcaptured, brigfree; |
||
58 | #endif |
||
59 | double date, // stardate |
||
60 | remres, // remaining resources |
||
61 | remtime; // remaining time |
||
62 | } d, snapsht; // Data that is snapshot |
||
63 | |||
64 | EXTERN char |
||
65 | quad[11][11]; // contents of our quadrant |
||
66 | |||
67 | // Scalar variables that are needed for freezing the game |
||
68 | // are placed in a structure. #defines are used to access by their |
||
69 | // original names. Gee, I could have done this with the d structure, |
||
70 | // but I just didn't think of it back when I started. |
||
71 | |||
72 | EXTERN struct foo2 { |
||
73 | int inkling, |
||
74 | inbase, |
||
75 | incom, |
||
76 | instar, |
||
77 | intorps, |
||
78 | condit, |
||
79 | torps, |
||
80 | ship, |
||
81 | quadx, |
||
82 | quady, |
||
83 | sectx, |
||
84 | secty, |
||
85 | length, |
||
86 | skill, |
||
87 | basex, |
||
88 | basey, |
||
89 | klhere, |
||
90 | comhere, |
||
91 | casual, |
||
92 | nhelp, |
||
93 | nkinks, |
||
94 | ididit, |
||
95 | gamewon, |
||
96 | alive, |
||
97 | justin, |
||
98 | alldone, |
||
99 | shldchg, |
||
100 | thingx, |
||
101 | thingy, |
||
102 | plnetx, |
||
103 | plnety, |
||
104 | inorbit, |
||
105 | landed, |
||
106 | iplnet, |
||
107 | imine, |
||
108 | inplan, |
||
109 | nenhere, |
||
110 | ishere, |
||
111 | neutz, |
||
112 | irhere, |
||
113 | icraft, |
||
114 | ientesc, |
||
115 | iscraft, |
||
116 | isatb, |
||
117 | iscate, |
||
118 | #ifdef DEBUG |
||
119 | idebug, |
||
120 | #endif |
||
121 | #ifdef CLOAKING |
||
122 | iscloaked, |
||
123 | iscloaking, |
||
124 | ncviol, |
||
125 | isviolreported, |
||
126 | #endif |
||
127 | #ifdef CAPTURE |
||
128 | brigcapacity, |
||
129 | #endif |
||
130 | iattak, |
||
131 | icrystl, |
||
132 | tourn, |
||
133 | thawed, |
||
134 | batx, |
||
135 | baty, |
||
136 | ithere, |
||
137 | ithx, |
||
138 | ithy, |
||
139 | iseenit, |
||
140 | probecx, |
||
141 | probecy, |
||
142 | proben, |
||
143 | isarmed, |
||
144 | nprobes; |
||
145 | |||
146 | double inresor, |
||
147 | intime, |
||
148 | inenrg, |
||
149 | inshld, |
||
150 | inlsr, |
||
151 | indate, |
||
152 | energy, |
||
153 | shield, |
||
154 | shldup, |
||
155 | warpfac, |
||
156 | wfacsq, |
||
157 | lsupres, |
||
158 | dist, |
||
159 | direc, |
||
160 | Time, |
||
161 | docfac, |
||
162 | resting, |
||
163 | damfac, |
||
164 | stdamtim, |
||
165 | cryprob, |
||
166 | probex, |
||
167 | probey, |
||
168 | probeinx, |
||
169 | probeiny; |
||
170 | } a; |
||
171 | |||
172 | #define inkling a.inkling // Initial number of klingons |
||
173 | #define inbase a.inbase // Initial number of bases |
||
174 | #define incom a.incom // Initian number of commanders |
||
175 | #define instar a.instar // Initial stars |
||
176 | #define intorps a.intorps // Initial/Max torpedoes |
||
177 | #define condit a.condit // Condition (red, yellow, green docked) |
||
178 | #define torps a.torps // number of torpedoes |
||
179 | #define ship a.ship // Ship type -- 'E' is Enterprise |
||
180 | #define quadx a.quadx // where we are |
||
181 | #define quady a.quady // |
||
182 | #define sectx a.sectx // where we are |
||
183 | #define secty a.secty // |
||
184 | #define length a.length // length of game |
||
185 | #define skill a.skill // skill level |
||
186 | #define basex a.basex // position of base in current quad |
||
187 | #define basey a.basey // |
||
188 | #define klhere a.klhere // klingons here |
||
189 | #define comhere a.comhere // commanders here |
||
190 | #define casual a.casual // causalties |
||
191 | #define nhelp a.nhelp // calls for help |
||
192 | #define nkinks a.nkinks // |
||
193 | #define ididit a.ididit // Action taken -- allows enemy to attack |
||
194 | #define gamewon a.gamewon // Finished! |
||
195 | #define alive a.alive // We are alive (not killed) |
||
196 | #define justin a.justin // just entered quadrant |
||
197 | #define alldone a.alldone // game is now finished |
||
198 | #define shldchg a.shldchg // shield is changing (affects efficiency) |
||
199 | #define thingx a.thingx // location of strange object in galaxy |
||
200 | #define thingy a.thingy // |
||
201 | #define plnetx a.plnetx // location of planet in quadrant |
||
202 | #define plnety a.plnety // |
||
203 | #define inorbit a.inorbit // orbiting |
||
204 | #define landed a.landed // party on planet (1), on ship (-1) |
||
205 | #define iplnet a.iplnet // planet # in quadrant |
||
206 | #define imine a.imine // mining |
||
207 | #define inplan a.inplan // initial planets |
||
208 | #define nenhere a.nenhere // Number of enemies in quadrant |
||
209 | #define ishere a.ishere // Super-commander in quandrant |
||
210 | #define neutz a.neutz // Romulan Neutral Zone |
||
211 | #define irhere a.irhere // Romulans in quadrant |
||
212 | #define icraft a.icraft // Kirk in Galileo |
||
213 | #define ientesc a.ientesc // Attempted escape from supercommander |
||
214 | #define iscraft a.iscraft // =1 if craft on ship, -1 if removed from game |
||
215 | #define isatb a.isatb // =1 if SuperCommander is attacking base |
||
216 | #define iscate a.iscate // Super Commander is here |
||
217 | #ifdef DEBUG |
||
218 | #define idebug a.idebug // Debug mode |
||
219 | #endif |
||
220 | #ifdef CLOAKING |
||
221 | #define iscloaked a.iscloaked // Cloaking is enabled |
||
222 | #define iscloaking a.iscloaking // However if iscloaking is TRUE then in process of cloaking and can be attacked |
||
223 | #define ncviol a.ncviol // Treaty violations |
||
224 | #define isviolreported a.isviolreported // Violation reported by Romulan in quadrant |
||
225 | #endif |
||
226 | #ifdef CAPTURE |
||
227 | #define kcaptured d.kcaptured // number of captured Klingons |
||
228 | #define brigfree d.brigfree // room in the brig |
||
229 | #define brigcapacity a.brigcapacity // How many Klingons the brig will hold |
||
230 | #endif |
||
231 | #define iattak a.iattak // attack recursion elimination (was cracks[4]) |
||
232 | #define icrystl a.icrystl // dilithium crystals aboard |
||
233 | #define tourn a.tourn // Tournament number |
||
234 | #define thawed a.thawed // Thawed game |
||
235 | #define batx a.batx // Base coordinates being attacked |
||
236 | #define baty a.baty // |
||
237 | #define ithere a.ithere // Tholean is here |
||
238 | #define ithx a.ithx // coordinates of tholean |
||
239 | #define ithy a.ithy |
||
240 | #define iseenit a.iseenit // Seen base attack report |
||
241 | #define inresor a.inresor // initial resources |
||
242 | #define intime a.intime // initial time |
||
243 | #define inenrg a.inenrg // Initial/Max Energy |
||
244 | #define inshld a.inshld // Initial/Max Shield |
||
245 | #define inlsr a.inlsr // initial life support resources |
||
246 | #define indate a.indate // Initial date |
||
247 | #define energy a.energy // Energy level |
||
248 | #define shield a.shield // Shield level |
||
249 | #define shldup a.shldup // Shields are up |
||
250 | #define warpfac a.warpfac // Warp speed |
||
251 | #define wfacsq a.wfacsq // squared warp factor |
||
252 | #define lsupres a.lsupres // life support reserves |
||
253 | #define dist a.dist // movement distance |
||
254 | #define direc a.direc // movement direction |
||
255 | #define Time a.Time // time taken by current operation |
||
256 | #define docfac a.docfac // repair factor when docking (constant?) |
||
257 | #define resting a.resting // rest time |
||
258 | #define damfac a.damfac // damage factor |
||
259 | #define stdamtim a.stdamtim // time that star chart was damaged |
||
260 | #define cryprob a.cryprob // probability that crystal will work |
||
261 | #define probex a.probex // location of probe |
||
262 | #define probey a.probey |
||
263 | #define probecx a.probecx // current probe quadrant |
||
264 | #define probecy a.probecy |
||
265 | #define probeinx a.probeinx // Probe x,y increment |
||
266 | #define probeiny a.probeiny |
||
267 | #define proben a.proben // number of moves for probe |
||
268 | #define isarmed a.isarmed // Probe is armed |
||
269 | #define nprobes a.nprobes // number of probes available |
||
270 | |||
271 | EXTERN int |
||
272 | kx[21], // enemy sector locations |
||
273 | ky[21], |
||
274 | starch[9][9]; // star chart |
||
275 | |||
276 | EXTERN int fromcommandline; // Game start from command line options |
||
277 | EXTERN int coordfixed; // Fix those dumb coordinates. |
||
278 | |||
279 | EXTERN char passwd[10], // Self Destruct password |
||
280 | *device[ndevice+1]; |
||
281 | |||
282 | EXTERN PLANETS nulplanet; // zeroed planet structure |
||
283 | |||
284 | EXTERN double |
||
285 | kpower[21], // enemy energy levels |
||
286 | kdist[21], // enemy distances |
||
287 | kavgd[21], // average distances |
||
288 | damage[ndevice+1], // damage encountered |
||
289 | future[NEVENTS+1]; // future events |
||
290 | |||
291 | EXTERN int iscore, iskill; // Common PLAQ |
||
292 | EXTERN double perdate; |
||
293 | |||
294 | typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE, |
||
295 | FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM, |
||
296 | FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET, |
||
297 | FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE, |
||
298 | FHOLE |
||
299 | #ifdef CLOAKING |
||
300 | , FCLOAK |
||
301 | #endif |
||
302 | } FINTYPE ; |
||
303 | |||
304 | /* Skill levels */ |
||
305 | typedef enum {SNOVICE=1, SFAIR, SGOOD, SEXPERT, SEMERITUS} SKILLTYPE; |
||
306 | |||
307 | EXTERN double aaitem; |
||
308 | EXTERN char citem[24]; |
||
309 | |||
310 | |||
311 | /* Define devices */ |
||
312 | #define DSRSENS 1 |
||
313 | #define DLRSENS 2 |
||
314 | #define DPHASER 3 |
||
315 | #define DPHOTON 4 |
||
316 | #define DLIFSUP 5 |
||
317 | #define DWARPEN 6 |
||
318 | #define DIMPULS 7 |
||
319 | #define DSHIELD 8 |
||
320 | #define DRADIO 9 |
||
321 | #define DSHUTTL 10 |
||
322 | #define DCOMPTR 11 |
||
323 | #define DTRANSP 12 |
||
324 | #define DSHCTRL 13 |
||
325 | #define DDRAY 14 // Added deathray |
||
326 | #define DDSP 15 // Added deep space probe |
||
327 | #define DCLOAK 16 // Added cloaking device |
||
328 | |||
329 | /* Define future events */ |
||
330 | #define FSPY 0 // Spy event happens always (no future[] entry) |
||
331 | // can cause SC to tractor beam Enterprise |
||
332 | #define FSNOVA 1 // Supernova |
||
333 | #define FTBEAM 2 // Commander tractor beams Enterprise |
||
334 | #define FSNAP 3 // Snapshot for time warp |
||
335 | #define FBATTAK 4 // Commander attacks base |
||
336 | #define FCDBAS 5 // Commander destroys base |
||
337 | #define FSCMOVE 6 // Supercommander moves (might attack base) |
||
338 | #define FSCDBAS 7 // Supercommander destroys base |
||
339 | #define FDSPROB 8 // Move deep space probe |
||
340 | |||
341 | #ifdef INCLUDED |
||
342 | PLANETS nulplanet = {0}; |
||
343 | char *device[ndevice+1] = { |
||
344 | "", |
||
345 | "S. R. Sensors", |
||
346 | "L. R. Sensors", |
||
347 | "Phasers", |
||
348 | "Photon Tubes", |
||
349 | "Life Support", |
||
350 | "Warp Engines", |
||
351 | "Impulse Engines", |
||
352 | "Shields", |
||
353 | "Subspace Radio", |
||
354 | "Shuttle Craft", |
||
355 | "Computer", |
||
356 | "Transporter", |
||
357 | "Shield Control", |
||
358 | "Death Ray", |
||
359 | "D. S. Probe" |
||
360 | #ifdef CLOAKING |
||
361 | ,"Cloaking Device" |
||
362 | #endif |
||
363 | }; |
||
364 | #endif |
||
365 | |||
366 | #define ALGERON (2311) /* Date of the Treaty of Algeron */ |
||
367 | |||
368 | #ifndef TRUE |
||
369 | #define TRUE (1) |
||
370 | #endif |
||
371 | #ifndef FALSE |
||
372 | #define FALSE (0) |
||
373 | #endif |
||
374 | |||
375 | #define IHR 'R' |
||
376 | #define IHK 'K' |
||
377 | #define IHC 'C' |
||
378 | #define IHS 'S' |
||
379 | #define IHSTAR '*' |
||
380 | #define IHP 'P' |
||
381 | #define IHB 'B' |
||
382 | #define IHBLANK ' ' |
||
383 | #define IHDOT '.' |
||
384 | #define IHQUEST '?' |
||
385 | #define IHE 'E' |
||
386 | #define IHF 'F' |
||
387 | #define IHT 'T' |
||
388 | #define IHWEB '#' |
||
389 | #define IHGREEN 'G' |
||
390 | #define IHYELLOW 'Y' |
||
391 | #define IHRED 'R' |
||
392 | #define IHDOCKED 'D' |
||
393 | |||
394 | |||
395 | /* Function prototypes */ |
||
396 | void prelim(void); |
||
397 | void attack(int); |
||
398 | int choose(void); |
||
399 | void setup(void); |
||
400 | void score(int); |
||
401 | void atover(int); |
||
402 | void srscan(int); |
||
403 | void lrscan(void); |
||
404 | void phasers(void); |
||
405 | void photon(void); |
||
406 | void warp(int); |
||
407 | void sheild(int); |
||
408 | void dock(void); |
||
409 | void dreprt(void); |
||
410 | void chart(int); |
||
411 | void impuls(void); |
||
412 | void waiting(void); |
||
413 | void setwrp(void); |
||
414 | void events(void); |
||
415 | void report(int); |
||
416 | void eta(void); |
||
417 | void help(void); |
||
418 | void abandn(void); |
||
419 | void finish(FINTYPE); |
||
420 | void dstrct(void); |
||
421 | void kaboom(void); |
||
422 | void freeze(int); |
||
423 | void thaw(void); |
||
424 | void plaque(void); |
||
425 | int scan(void); |
||
426 | #define IHEOL (0) |
||
427 | #define IHALPHA (1) |
||
428 | #define IHREAL (2) |
||
429 | void chew(void); |
||
430 | void chew2(void); |
||
431 | void skip(int); |
||
432 | void prout(char *s); |
||
433 | void proutn(char *s); |
||
434 | void stars(void); |
||
435 | void newqad(int); |
||
436 | int ja(void); |
||
437 | void cramen(int); |
||
438 | void crmshp(void); |
||
439 | void cramlc(int, int, int); |
||
440 | double expran(double); |
||
441 | double Rand(void); |
||
442 | void iran8(int *, int *); |
||
443 | void iran10(int *, int *); |
||
444 | double square(double); |
||
445 | void dropin(int, int*, int*); |
||
446 | void newcnd(void); |
||
447 | void sortkl(void); |
||
448 | void lmove(void); |
||
449 | void ram(int, int, int, int); |
||
450 | void crmena(int, int, int, int, int); |
||
451 | void deadkl(int, int, int, int, int); |
||
452 | void timwrp(void); |
||
453 | void movcom(void); |
||
454 | void torpedo(double, double, int, int, double *); |
||
455 | void cramf(double, int, int); |
||
456 | void crami(int, int); |
||
457 | void huh(void); |
||
458 | void pause(int); |
||
459 | void nova(int, int); |
||
460 | void snova(int, int); |
||
461 | void scom(int *); |
||
462 | void hittem(double *); |
||
463 | void prouts(char *); |
||
464 | int isit(char *); |
||
465 | void preport(void); |
||
466 | void orbit(void); |
||
467 | void sensor(void); |
||
468 | void beam(void); |
||
469 | void mine(void); |
||
470 | void usecrystals(void); |
||
471 | void shuttle(void); |
||
472 | void deathray(void); |
||
473 | void debugme(void); |
||
474 | void attakreport(void); |
||
475 | void movetho(void); |
||
476 | void probe(void); |
||
477 | |||
7185 | siemargl | 478 | #ifndef WINDOWS |
479 | #ifndef KOS32 |
||
7142 | siemargl | 480 | int min(int, int); |
481 | int max(int, int); |
||
7185 | siemargl | 482 | #endif |
483 | #endif |
||
7142 | siemargl | 484 | void randomize(void); |
485 | ///int getch(void); |
||
486 | |||
487 | #ifdef CLOAKING |
||
488 | void cloak(void); |
||
489 | #endif |
||
490 | #ifdef CAPTURE |
||
491 | void capture(void); |
||
492 | #endif |
||
493 | |||
494 | #ifdef CLOAKING |
||
495 | #define REPORTS ((condit==IHDOCKED || damage[DRADIO]<=0.0) && !iscloaked) |
||
496 | #else |
||
497 | #define REPORTS (condit==IHDOCKED || damage[DRADIO]<=0.0) |
||
498 | #endif=0.0) |