#endif
/* Decide on being active or passive */
- flag = ((game.state.killc+game.state.killk)/(game.state.date+0.01-indate) < 0.1*skill*(skill+1.0) ||
+ flag = ((NKILLC+NKILLK)/(game.state.date+0.01-indate) < 0.1*skill*(skill+1.0) ||
(game.state.date-indate) < 3.0);
if (iscate==0 && flag) {
/* compute move away from Enterprise */
game.damage[l] += Time + extradm; /* Damage for at least time of travel! */
}
shldup = 0;
- if (game.state.remkl) {
+ if (KLINGREM) {
pause_game(2);
dreprt();
}
r = (Rand()+Rand())*0.5 -0.5;
r += 0.002*game.kpower[l]*r;
torpedo(course, r, jx, jy, &hit, 1, 1);
- if (game.state.remkl==0)
+ if (KLINGREM==0)
finish(FWON); /* Klingons did themselves in! */
if (game.state.galaxy[quadx][quady].supernova || alldone)
return; /* Supernova or finished */
/* chalk up a Romulan */
game.state.galaxy[quadx][quady].romulans--;
irhere--;
- game.state.nromkl++;
game.state.nromrem--;
}
else if (type == IHT) {
/* Some type of a Klingon */
game.state.galaxy[quadx][quady].klingons--;
klhere--;
- game.state.remkl--;
switch (type) {
case IHC:
comhere = 0;
game.future[FTBEAM] = FOREVER;
if (game.state.remcom != 0)
game.future[FTBEAM] = game.state.date + expran(1.0*incom/game.state.remcom);
- game.state.killc++;
break;
case IHK:
- game.state.killk++;
+ game.state.remkl--;
break;
case IHS:
- game.state.nscrem = ishere = game.state.isx = game.state.isy = isatb = iscate = 0;
- game.state.nsckill = 1;
+ game.state.nscrem--;
+ ishere = game.state.isx = game.state.isy = isatb = iscate = 0;
game.future[FSCMOVE] = game.future[FSCDBAS] = FOREVER;
break;
}
/* For each kind of enemy, finish message to player */
prout(" destroyed.");
game.quad[ix][iy] = IHDOT;
- if (game.state.remkl==0) return;
+ if (KLINGREM==0) return;
game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);
if (alldone || game.state.galaxy[quadx][quady].supernova)
return;
}
- if (game.state.remkl==0) finish(FWON);
+ if (KLINGREM==0) finish(FWON);
}
skip(1);
if (kpow == 0) {
deadkl(ii, jj, ienm, ii, jj);
- if (game.state.remkl==0) finish(FWON);
+ if (KLINGREM==0) finish(FWON);
if (alldone) return;
kk--; /* don't do the increment */
}
iscdead = 1;
game.future[FSCMOVE] = game.future[FSCDBAS] = FOREVER;
}
- game.state.remkl -= kldead;
if (game.state.remcom) {
int maxloop = game.state.remcom, l;
for (l = 1; l <= maxloop; l++) {
}
}
}
+ game.state.remkl -= kldead;
/* destroy Romulans and planets in supernovaed quadrant */
nrmdead = game.state.galaxy[nqx][nqy].romulans;
game.state.galaxy[nqx][nqy].romulans = 0;
if (insx) {
game.state.starkl += game.state.galaxy[nqx][nqy].stars;
game.state.basekl += game.state.galaxy[nqx][nqy].starbase;
- game.state.killk += kldead;
- game.state.killc += comdead;
- game.state.nromkl += nrmdead;
game.state.nplankl += npdead;
- game.state.nsckill += iscdead;
}
/* mark supernova in galaxy and in star chart */
if ((quadx == nqx && quady == nqy) ||
condit == IHDOCKED)
game.state.galaxy[nqx][nqy].supernova = TRUE;
/* If supernova destroys last klingons give special message */
- if (game.state.remkl==0 && (nqx != quadx || nqy != quady)) {
+ if (KLINGREM==0 && (nqx != quadx || nqy != quady)) {
skip(2);
if (insx == 0) prout("Lucky you!");
proutn("A supernova in %s has just destroyed the last Klingons.",
if (badpt < 100.0) badpt = 0.0; // Close enough!
if (game.state.date-indate < 5.0 ||
// killsPerDate >= RateMax
- (game.state.killk+game.state.killc+game.state.nsckill)/(game.state.date-indate) >=
+ KLINGKILLED/(game.state.date-indate) >=
0.1*skill*(skill+1.0) + 0.1 + 0.008*badpt) {
skip(1);
prout("In fact, you have done so well that Starfleet Command");
prout("conquered. Your starship is now Klingon property,");
prout("and you are put on trial as a war criminal. On the");
proutn("basis of your record, you are ");
- if (game.state.remkl*3.0 > inkling) {
+ if (KLINGREM*3.0 > INKLINGTOT) {
prout("aquitted.");
skip(1);
prout("LIVE LONG AND PROSPER.");
if (ship==IHF) ship= 0;
else if (ship == IHE) ship = IHF;
alive = 0;
- if (game.state.remkl != 0) {
+ if (KLINGREM != 0) {
double goodies = game.state.remres/inresor;
double baddies = (game.state.remkl + 2.0*game.state.remcom)/(inkling+2.0*incom);
if (goodies/baddies >= 1.0+0.5*Rand()) {
int ithperd, iwon, klship;
iskill = skill;
- if ((timused == 0 || game.state.remkl != 0) && timused < 5.0) timused = 5.0;
- perdate = (game.state.killc + game.state.killk + game.state.nsckill)/timused;
+ if ((timused == 0 || KLINGREM != 0) && timused < 5.0) timused = 5.0;
+ perdate = KLINGKILLED/timused;
ithperd = 500*perdate + 0.5;
iwon = 0;
if (gamewon) iwon = 100*skill;
else if (ship == IHF) klship = 1;
else klship = 2;
if (gamewon == 0) game.state.nromrem = 0; // None captured if no win
- iscore = 10*game.state.killk + 50*game.state.killc + ithperd + iwon
+ iscore = 10*NKILLK + 50*NKILLC + ithperd + iwon
- 100*game.state.basekl - 100*klship - 45*nhelp -5*game.state.starkl - casual
- + 20*game.state.nromkl + 200*game.state.nsckill - 10*game.state.nplankl + game.state.nromrem;
+ + 20*NKILLROM + 200*NKILLSC - 10*game.state.nplankl + game.state.nromrem;
if (alive == 0) iscore -= 200;
skip(2);
prout("Your score --");
- if (game.state.nromkl)
+ if (NKILLROM)
prout("%6d Romulans destroyed %5d",
- game.state.nromkl,20*game.state.nromkl);
+ NKILLROM,20*NKILLROM);
if (game.state.nromrem)
prout("%6d Romulans captured %5d",
game.state.nromrem, game.state.nromrem);
- if (game.state.killk)
+ if (NKILLK)
prout("%6d ordinary Klingons destroyed %5d",
- game.state.killk, 10*game.state.killk);
- if (game.state.killc)
+ NKILLK, 10*NKILLK);
+ if (NKILLC)
prout("%6d Klingon commanders destroyed %5d",
- game.state.killc, 50*game.state.killc);
- if (game.state.nsckill)
+ NKILLC, 50*NKILLC);
+ if (NKILLSC)
prout("%6d Super-Commander destroyed %5d",
- game.state.nsckill, 200*game.state.nsckill);
+ NKILLSC, 200*NKILLSC);
if (ithperd)
prout("%6.2f Klingons per stardate %5d",
perdate, ithperd);
} while
/* Repeat if another snova */
(game.state.galaxy[quadx][quady].supernova);
- if (game.state.remkl==0)
+ if (KLINGREM==0)
finish(FWON); /* Snova killed remaining enemy. */
}
while (nenhere > 0)
deadkl(game.kx[1],game.ky[1],game.quad[game.kx[1]][game.ky[1]],game.kx[1],game.ky[1]);
prout("Ensign Chekov- \"Congratulations, Captain!\"");
- if (game.state.remkl == 0) finish(FWON);
+ if (KLINGREM == 0) finish(FWON);
prout("Spock- \"Captain, I believe the `Experimental Death Ray'");
if (Rand() <= 0.05) {
prout(" is still operational.\"");
if (skill>SKILL_GOOD && thawed && !alldone) prout("No plaque is allowed.");
if (tourn) prout("This is tournament game %d.", tourn);
prout("Your secret password is \"%s\"",game.passwd);
- proutn("%d of %d Klingons have been killed",
- game.state.killk+game.state.killc+game.state.nsckill, inkling);
- if (game.state.killc) prout(", including %d Commander%s.", game.state.killc, game.state.killc==1?"":"s");
- else if (game.state.killk+game.state.nsckill > 0) prout(", but no Commanders.");
+ proutn("%d of %d Klingons have been killed", KLINGKILLED, INKLINGTOT);
+ if (NKILLC) prout(", including %d Commander%s.", NKILLC, NKILLC==1?"":"s");
+ else if (NKILLK + NKILLSC > 0) prout(", but no Commanders.");
else prout(".");
if (skill > SKILL_FAIR) prout("The Super Commander has %sbeen destroyed.",
game.state.nscrem?"not ":"");
(int)((100.0*shield)/inshld + 0.5), shield);
break;
case 9:
- proutn("Klingons Left %d", game.state.remkl);
+ proutn("Klingons Left %d", KLINGREM);
break;
case 10:
attakreport(1);
// Set up assorted game parameters
batx = baty = 0;
game.state.date = indate = 100.0*(int)(31.0*Rand()+20.0);
- game.state.killk = game.state.killc = nkinks = nhelp = resting = casual = game.state.nromkl = 0;
- isatb = iscate = imine = icrystl = icraft = game.state.nsckill = game.state.nplankl = 0;
+ nkinks = nhelp = resting = casual = 0;
+ isatb = iscate = imine = icrystl = icraft = game.state.nplankl = 0;
game.state.starkl = game.state.basekl = 0;
iscraft = 1;
landed = -1;
game.state.galaxy[i][j].charted = 0;
game.state.galaxy[i][j].planets = 0;
game.state.galaxy[i][j].romulans = 0;
+ game.state.galaxy[i][j].klingons = 0;
+ game.state.galaxy[i][j].starbase = 0;
+ game.state.galaxy[i][j].supernova = 0;
}
// Initialize times for extraneous events
game.future[FSNOVA] = game.state.date + expran(0.5 * intime);
game.state.chart[ix][iy].starbase = 1;
}
// Position ordinary Klingon Battle Cruisers
- krem = inkling - incom - game.state.nscrem;
+ krem = inkling;
klumper = 0.25*skill*(9.0-length)+1.0;
if (klumper > 9) klumper = 9; // Can't have more than 9 in quadrant
do {
prout("a deadly Klingon invasion force. As captain of the United");
prout("Starship U.S.S. Enterprise, it is your mission to seek out");
prout("and destroy this invasion force of %d battle cruisers.",
- inkling);
+ INKLINGTOT);
prout("You have an initial allotment of %d stardates to complete", (int)intime);
prout("your mission. As you proceed you may be given more time.");
prout("");
else {
prout("Stardate %d.", (int)game.state.date);
prout("");
- prout("%d Klingons.", inkling);
+ prout("%d Klingons.", INKLINGTOT);
prout("An unknown number of Romulans.");
if (game.state.nscrem) prout("and one (GULP) Super-Commander.");
prout("%d stardates.",(int)intime);
inbase = game.state.rembase;
if (game.options & OPTION_PLANETS)
inplan = (PLNETMAX/2) + (PLNETMAX/2+1)*Rand();
- game.state.nromrem = (2.0+Rand())*skill;
- game.state.nscrem = (skill > SKILL_FAIR ? 1 : 0);
+ game.state.nromrem = inrom = (2.0+Rand())*skill;
+ game.state.nscrem = inscom = (skill > SKILL_FAIR ? 1 : 0);
game.state.remtime = 7.0 * length;
intime = game.state.remtime;
- inkling = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15);
+ game.state.remkl = inkling = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15);
incom = skill + 0.0625*inkling*Rand();
- game.state.remcom= min(10, incom);
+ game.state.remcom = min(10, incom);
incom = game.state.remcom;
- game.state.remkl = inkling + incom + game.state.nscrem;
game.state.remres = (inkling+4*incom)*intime;
inresor = game.state.remres;
if (inkling > 50) {
int snap, // snapshot taken
remkl, // remaining klingons
remcom, // remaining commanders
+ nscrem, // remaining super commanders
rembase, // remaining bases
starkl, // destroyed stars
basekl, // destroyed bases
- killk, // Klingons killed
- killc, // commanders killed
cx[QUADSIZE+1],cy[QUADSIZE+1], // Commander quadrant coordinates
baseqx[BASEMAX+1], // Base quadrant X
baseqy[BASEMAX+1], // Base quadrant Y
isx, isy, // Coordinate of Super Commander
- nscrem, // remaining super commanders
- nromkl, // Romulans killed
nromrem, // Romulans remaining
- nsckill, // super commanders killed
nplankl; // destroyed planets
planet plnets[PLNETMAX]; // Planet information
double date, // stardate
} chart[GALSIZE+1][GALSIZE+1]; // the starchart (subscript 0 not used)
} snapshot; // Data that is snapshot
+#define NKILLK (inkling - game.state.remkl)
+#define NKILLC (incom - game.state.remcom)
+#define NKILLSC (inscom - game.state.nscrem)
+#define NKILLROM (inrom - game.state.nromrem)
+#define KLINGREM (game.state.remkl + game.state.remcom + game.state.nscrem)
+#define INKLINGTOT (inkling + incom + inscom)
+#define KLINGKILLED (INKLINGTOT - KLINGREM)
+
#define SKILL_NONE 0
#define SKILL_NOVICE 1
#define SKILL_FAIR 2
int inkling,
inbase,
incom,
+ inscom,
+ inrom,
instar,
intorps,
condit,
#define inkling game.inkling // Initial number of klingons
#define inbase game.inbase // Initial number of bases
#define incom game.incom // Initian number of commanders
+#define inscom game.inscom // Initian number of commanders
+#define inrom game.inrom // Initian number of commanders
#define instar game.instar // Initial stars
#define intorps game.intorps // Initial/Max torpedoes
#define condit game.condit // Condition (red/yellow/green/docked)