icas = 10.0+20.0*Rand();
prout("***Sickbay reports %d casualties", icas);
casual += icas;
- for (l=1; l <= NDEVICES; l++) {
- if (l == DDRAY) continue; // Don't damage deathray
- if (game.damage[l] < 0) continue;
+ for (l=0; l < NDEVICES; l++) {
+ if (l == DDRAY)
+ continue; // Don't damage deathray
+ if (game.damage[l] < 0)
+ continue;
extradm = (10.0*type*Rand()+1.0)*damfac;
game.damage[l] += Time + extradm; /* Damage for at least time of travel! */
}
static void fry(double hit)
{
double ncrit, extradm;
- int ktr=1, l, ll, j, cdam[NDEVICES+1];
+ int ktr=1, l, ll, j, cdam[NDEVICES];
/* a critical hit occured */
if (hit < (275.0-25.0*skill)*(1.0+0.5*Rand())) return;
ncrit = 1.0 + hit/(500.0+100.0*Rand());
proutn("***CRITICAL HIT--");
/* Select devices and cause damage */
- for (l = 1; l <= ncrit && l <= NDEVICES; l++) {
+ for (l = 0; l < ncrit && 0 < NDEVICES; l++) {
do {
- j = NDEVICES*Rand()+1.0;
+ j = NDEVICES*Rand();
/* Cheat to prevent shuttle damage unless on ship */
- } while (game.damage[j] < 0.0 || (j == DSHUTTL && iscraft != 1) ||
- j == DDRAY);
+ } while
+ (game.damage[j]<0.0 || (j==DSHUTTL && iscraft!=1) || j==DDRAY);
cdam[l] = j;
extradm = (hit*damfac)/(ncrit*(75.0+25.0*Rand()));
game.damage[j] += extradm;
- if (l > 1) {
+ if (l > 0) {
for (ll=2; ll<=l && j != cdam[ll-1]; ll++) ;
if (ll<=l) continue;
ktr += 1;
repair = xtime;
if (condit == IHDOCKED) repair /= docfac;
/* Don't fix Deathray here */
- for (l=1; l<=NDEVICES; l++)
+ for (l=0; l<NDEVICES; l++)
if (game.damage[l] > 0.0 && l != DDRAY)
game.damage[l] -= (game.damage[l]-repair > 0.0 ? repair : game.damage[l]);
/* If radio repaired, update star chart and attack reports */
* possibility that you'll get timewarped instead.
*/
n=0;
- for (l=1;l<=NDEVICES+1;l++)
- if (game.damage[l]>0) n++;
- probf=pow(1.4,(energy+shield)/5000.0-1.0)*
- pow(1.3,1.0/(n+1)-1.0);
+ for (l=0;l<NDEVICES;l++)
+ if (game.damage[l]>0)
+ n++;
+ probf=pow(1.4,(energy+shield)/5000.0-1.0)*pow(1.3,1.0/(n+1)-1.0);
if (Rand()>probf)
timwrp();
else
int jdam = FALSE, i;
chew();
- for (i = 1; i <= NDEVICES; i++) {
+ for (i = 0; i < NDEVICES; i++) {
if (game.damage[i] > 0.0) {
if (!jdam) {
prout("DEVICE -REPAIR TIMES-");
case IHDOCKED: cp = "DOCKED"; break;
case IHDEAD: cp="DEAD"; break;
}
- for (t=0;t<=NDEVICES;t++)
- if (game.damage[t]>0) dam++;
+ for (t=0;t<NDEVICES;t++)
+ if (game.damage[t]>0)
+ dam++;
proutn("Condition %s, %i DAMAGES", cp, dam);
break;
case 3:
iscraft=0; /* Gallileo disappears */
/* Resupply ship */
condit=IHDOCKED;
- for (l = 1; l <= NDEVICES; l++) game.damage[l] = 0.0;
+ for (l = 0; l < NDEVICES; l++)
+ game.damage[l] = 0.0;
game.damage[DSHUTTL] = -1;
energy = inenrg = 3000.0;
shield = inshld = 1250.0;
nprobes = (int)(3.0*Rand() + 2.0); /* Give them 2-4 of these wonders */
warpfac = 5.0;
wfacsq = warpfac * warpfac;
- for (i=0; i <= NDEVICES; i++) game.damage[i] = 0.0;
+ for (i=0; i < NDEVICES; i++)
+ game.damage[i] = 0.0;
// Set up assorted game parameters
batx = baty = 0;
game.state.date = indate = 100.0*(int)(31.0*Rand()+20.0);
proutn("Reset damage? ");
if (ja() != 0) {
int i;
- for (i=0; i <= NDEVICES; i++)
+ for (i=0; i < NDEVICES; i++)
if (game.damage[i] > 0.0)
game.damage[i] = 0.0;
stdamtim = 1e30;
proutn("Cause selective damage? ");
if (ja() != 0) {
int i, key;
- for (i=1; i <= NDEVICES; i++) {
+ for (i=0; i < NDEVICES; i++) {
proutn("Kill ");
proutn(device[i]);
proutn("? ");
// #define DEBUG
-#define NDEVICES (15) // Number of devices
#define PHASEFAC (2.0)
#define PLNETMAX (10)
#define NEVENTS (8)
#define OPTION_THINGY 0x00000010 /* Space Thingy can shoot back */
#define OPTION_PROBE 0x00000020 /* deep-space probes */
+/* Define devices */
+#define DSRSENS 0
+#define DLRSENS 1
+#define DPHASER 2
+#define DPHOTON 3
+#define DLIFSUP 4
+#define DWARPEN 5
+#define DIMPULS 6
+#define DSHIELD 7
+#define DRADIO 8
+#define DSHUTTL 9
+#define DCOMPTR 10
+#define DTRANSP 11
+#define DSHCTRL 12
+#define DDRAY 13 // Added deathray
+#define DDSP 14 // Added deep space probe
+#define NDEVICES (15) // Number of devices
+
// Scalar variables that are needed for freezing the game
// are placed in a structure. #defines are used to access by their
// original names. Gee, I could have done this with the d structure,
double kpower[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy energy levels
double kdist[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy distances
double kavgd[(QUADSIZE+1)*(QUADSIZE+1)]; // average distances
- double damage[NDEVICES+1]; // damage encountered
+ double damage[NDEVICES]; // damage encountered
double future[NEVENTS+1]; // future events
char passwd[10]; // Self Destruct password
int kx[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy sector locations
#define nprobes game.nprobes // number of probes available
/* the following global state doesn't need to be saved */
-EXTERN char *device[NDEVICES+1];
+EXTERN char *device[NDEVICES];
EXTERN int iscore, iskill; // Common PLAQ
EXTERN double perdate;
EXTERN double aaitem;
FHOLE} FINTYPE ;
enum loctype {neither, quadrant, sector};
-/* Define devices */
-#define DSRSENS 1
-#define DLRSENS 2
-#define DPHASER 3
-#define DPHOTON 4
-#define DLIFSUP 5
-#define DWARPEN 6
-#define DIMPULS 7
-#define DSHIELD 8
-#define DRADIO 9
-#define DSHUTTL 10
-#define DCOMPTR 11
-#define DTRANSP 12
-#define DSHCTRL 13
-#define DDRAY 14 // Added deathray
-#define DDSP 15 // Added deep space probe
-
/* Define future events */
#define FSPY 0 // Spy event happens always (no future[] entry)
// can cause SC to tractor beam Enterprise
#define FDSPROB 8 // Move deep space probe
#ifdef INCLUDED
-char *device[NDEVICES+1] = {
- "",
+char *device[NDEVICES] = {
"S. R. Sensors",
"L. R. Sensors",
"Phasers",
"Computer",
"Transporter",
"Shield Control",
- "Death Ray",
- "D. S. Probe"};
+ "Death Ray",
+ "D. S. Probe"};
#endif
#ifndef TRUE