/* print escape message and move out of quadrant.
We know this if either short or long range sensors are working */
if (!damaged(DSRSENS) || !damaged(DLRSENS) ||
- game.condit == IHDOCKED) {
+ game.condition == docked) {
crmena(1, ienm, sector, game.ks[loccom]);
prout(_(" escapes to %s (and regains strength)."),
cramlc(quadrant, iq));
game.kdist[loccom] = game.kdist[game.nenhere];
game.klhere--;
game.nenhere--;
- if (game.condit != IHDOCKED) newcnd();
+ if (game.condition != docked) newcnd();
/* Handle global matters related to escape */
game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons--;
game.state.galaxy[iq.x][iq.y].klingons++;
/* If SC, check with spy to see if should hi-tail it */
if (ienm==IHS &&
- (game.kpower[loccom] <= 500.0 || (game.condit==IHDOCKED && !damaged(DPHOTON)))) {
+ (game.kpower[loccom] <= 500.0 || (game.condition==docked && !damaged(DPHOTON)))) {
irun = true;
motion = -QUADSIZE;
}
forces += 1000.0;
}
motion = 0;
- if (forces <= 1000.0 && game.condit != IHDOCKED) /* Typical situation */
+ if (forces <= 1000.0 && game.condition != docked) /* Typical situation */
motion = ((forces+200.0*Rand())/150.0) - 5.0;
else {
if (forces > 1000.0) /* Very strong -- move in for kill */
motion = (1.0-square(Rand()))*dist1 + 1.0;
- if (game.condit==IHDOCKED && (game.options & OPTION_BASE)) /* protected by base -- back off ! */
+ if (game.condition==docked && (game.options & OPTION_BASE)) /* protected by base -- back off ! */
motion -= game.skill*(2.0-square(Rand()));
}
if (idebug)
/* it moved */
game.ks[loccom] = next;
game.kdist[loccom] = game.kavgd[loccom] = distance(game.sector, next);
- if (!damaged(DSRSENS) || game.condit == IHDOCKED) {
+ if (!damaged(DSRSENS) || game.condition == docked) {
proutn("***");
cramen(ienm);
proutn(_(" from %s"), cramlc(2, com));
game.kpower[i] = game.kpower[game.nenhere];
game.klhere--;
game.nenhere--;
- if (game.condit!=IHDOCKED) newcnd();
+ if (game.condition!=docked) newcnd();
sortkl();
}
/* check for a helpful planet */
/* destroy the planet */
DESTROY(&game.state.plnets[i]);
game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].planet = NOPLANET;
- if (!damaged(DRADIO) || game.condit == IHDOCKED) {
+ if (!damaged(DRADIO) || game.condition == docked) {
if (*ipage==0) pause_game(1);
*ipage = 1;
prout(_("Lt. Uhura- \"Captain, Starfleet Intelligence reports"));
schedule(FSCDBAS, 1.0 +2.0*Rand());
if (is_scheduled(FCDBAS))
postpone(FSCDBAS, scheduled(FCDBAS)-game.state.date);
- if (damaged(DRADIO) && game.condit != IHDOCKED)
+ if (damaged(DRADIO) && game.condition != docked)
return; /* no warning */
game.iseenit = true;
if (*ipage == 0) pause_game(1);
if (
!idebug &&
(Rand() > 0.2 ||
- (damaged(DRADIO) && game.condit != IHDOCKED) ||
+ (damaged(DRADIO) && game.condition != docked) ||
!game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].charted))
return;
if (*ipage==0) pause_game(1);
}
game.shldup = true;
game.shldchg = 1;
- if (game.condit != IHDOCKED) game.energy -= 50.0;
+ if (game.condition != docked) game.energy -= 50.0;
prout(_("Shields raised."));
if (game.energy <= 0) {
skip(1);
if (fabs(deltay) > bigger) bigger = fabs(deltay);
deltax /= bigger;
deltay /= bigger;
- if (!damaged(DSRSENS) || game.condit==IHDOCKED)
+ if (!damaged(DSRSENS) || game.condition==docked)
setwnd(srscan_window);
else
setwnd(message_window);
*hit = fabs(*hit);
newcnd(); /* we're blown out of dock */
/* We may be displaced. */
- if (game.landed==1 || game.condit==IHDOCKED) return; /* Cheat if on a planet */
+ if (game.landed==1 || game.condition==docked) return; /* Cheat if on a planet */
ang = angle + 2.5*(Rand()-0.5);
temp = fabs(sin(ang));
if (fabs(cos(ang)) > temp) temp = fabs(cos(ang));
/* compute hit strength and diminsh shield power */
r = Rand();
/* Increase chance of photon torpedos if docked or enemy energy low */
- if (game.condit == IHDOCKED) r *= 0.25;
+ if (game.condition == docked) r *= 0.25;
if (game.kpower[loop] < 500) r *= 0.25;
jay = game.ks[loop];
iquad = game.quad[jay.x][jay.y];
(iquad==IHQUEST && r > 0.05);
if (itflag) {
/* Enemy uses phasers */
- if (game.condit == IHDOCKED) continue; /* Don't waste the effort! */
+ if (game.condition == docked) continue; /* Don't waste the effort! */
attempt = true; /* Attempt to attack */
dustfac = 0.8+0.05*Rand();
hit = game.kpower[loop]*pow(dustfac,game.kavgd[loop]);
return; /* Supernova or finished */
if (hit == 0) continue;
}
- if (game.shldup || game.shldchg != 0 || game.condit==IHDOCKED) {
+ if (game.shldup || game.shldchg != 0 || game.condition==docked) {
/* shields will take hits */
- double absorb, hitsh, propor = pfac*game.shield*(game.condit==IHDOCKED ? 2.1 : 1.0);
+ double absorb, hitsh, propor = pfac*game.shield*(game.condition==docked ? 2.1 : 1.0);
if(propor < 0.1) propor = 0.1;
hitsh = propor*chgfac*hit+1.0;
atackd = true;
if (absorb > game.shield) absorb = game.shield;
game.shield -= absorb;
hit -= hitsh;
- if (game.condit==IHDOCKED) dock(false);
+ if (game.condition==docked) dock(false);
if (propor > 0.1 && hit < 0.005*game.energy) continue;
}
/* It's a hit -- print out hit size */
hittot += hit;
fry(hit);
game.energy -= hit;
- if (game.condit==IHDOCKED)
+ if (game.condition==docked)
dock(false);
}
if (game.energy <= 0) {
finish(FBATTLE);
return;
}
- if (!attempt && game.condit == IHDOCKED)
+ if (!attempt && game.condition == docked)
prout(_("***Enemies decide against attacking your ship."));
if (!atackd) return;
percent = 100.0*pfac*game.shield+0.5;
game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);
- /* Remove enemy ship from arrays describing local game.conditions */
+ /* Remove enemy ship from arrays describing local conditions */
if (is_scheduled(FCDBAS) && game.battle.x==game.quadrant.x && game.battle.y==game.quadrant.y && type==IHC)
unschedule(FCDBAS);
for_local_enemies(i)
/* Loop for moving <n> torpedoes */
osuabor = false;
for (i = 1; i <= n && !osuabor; i++) {
- if (game.condit != IHDOCKED) game.torps--;
+ if (game.condition != docked) game.torps--;
r = (Rand()+Rand())*0.5 -0.5;
if (fabs(r) >= 0.47) {
/* misfire! */
break;
}
}
- if (game.shldup || game.condit == IHDOCKED)
+ if (game.shldup || game.condition == docked)
r *= 1.0 + 0.0001*game.shield;
torpedo(course[i], r, game.sector, &dummy, i, n);
if (game.alldone || game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
skip(1);
/* SR sensors and Computer */
if (damaged(DSRSENS) || damaged(DCOMPTR)) ipoop = false;
- if (game.condit == IHDOCKED) {
+ if (game.condition == docked) {
prout(_("Phasers can't be fired through base shields."));
chew();
return;
return;
}
/* Is life support adequate? */
- if (damaged(DLIFSUP) && game.condit != IHDOCKED) {
+ if (damaged(DLIFSUP) && game.condition != docked) {
if (game.lsupres < xtime && game.damage[DLIFSUP] > game.lsupres) {
finish(FLIFESUP);
return;
}
/* Fix devices */
repair = xtime;
- if (game.condit == IHDOCKED) repair /= game.docfac;
+ if (game.condition == docked) repair /= game.docfac;
/* Don't fix Deathray here */
for (l=0; l<NDEVICES; l++)
if (game.damage[l] > 0.0 && l != DDRAY)
case FSPY: /* Check with spy to see if S.C. should tractor beam */
if (game.state.nscrem == 0 ||
ictbeam || istract ||
- game.condit==IHDOCKED || game.isatb==1 || game.iscate==1) return;
+ game.condition==docked || game.isatb==1 || game.iscate==1) return;
if (game.ientesc ||
(game.energy < 2000 && game.torps < 4 && game.shield < 1250) ||
(damaged(DPHASER) && (damaged(DPHOTON) || game.torps < 4)) ||
}
i = Rand()*game.state.remcom+1.0;
yank = square(game.state.kcmdr[i].x-game.quadrant.x) + square(game.state.kcmdr[i].y-game.quadrant.y);
- if (istract || game.condit == IHDOCKED || yank == 0) {
+ if (istract || game.condition == docked || yank == 0) {
/* Drats! Have to reschedule */
schedule(FTBEAM,
game.optime + expran(1.5*game.intime/game.state.remcom));
postpone(FCDBAS, scheduled(FSCDBAS)-game.state.date);
game.future[FBATTAK].date = game.future[FCDBAS].date + expran(0.3*game.intime);
game.iseenit = false;
- if (!damaged(DRADIO) && game.condit != IHDOCKED)
+ if (!damaged(DRADIO) && game.condition != docked)
break; /* No warning :-( */
game.iseenit = true;
if (!ipage) pause_game(1);
prout(_("Spock- \"Captain, I believe the starbase has been destroyed.\""));
}
else if (game.state.rembase != 1 &&
- (!damaged(DRADIO) || game.condit == IHDOCKED)) {
+ (!damaged(DRADIO) || game.condition == docked)) {
/* Get word via subspace radio */
if (!ipage) pause_game(1);
ipage = true;
if (!VALID_QUADRANT(i, j) ||
game.state.galaxy[game.probec.x][game.probec.y].supernova) {
// Left galaxy or ran into supernova
- if (!damaged(DRADIO) || game.condit == IHDOCKED) {
+ if (!damaged(DRADIO) || game.condition == docked) {
if (ipage==0) pause_game(1);
ipage = 1;
skip(1);
unschedule(FDSPROB);
break;
}
- if (!damaged(DRADIO) || game.condit == IHDOCKED) {
+ if (!damaged(DRADIO) || game.condition == docked) {
if (ipage==0) pause_game(1);
ipage = 1;
skip(1);
pdest = &game.state.galaxy[game.probec.x][game.probec.y];
/* Update star chart if Radio is working or have access to
radio. */
- if (!damaged(DRADIO) || game.condit == IHDOCKED) {
+ if (!damaged(DRADIO) || game.condition == docked) {
struct page *chp = &game.state.chart[game.probec.x][game.probec.y];
chp->klingons = pdest->klingons;
q->status = distressed;
/* tell the captain about it if we can */
- if (!damaged(DRADIO) || game.condit == IHDOCKED)
+ if (!damaged(DRADIO) || game.condition == docked)
{
prout("Uhura- Captain, %s in %s reports it is under attack",
systemname(q->planet), cramlc(quadrant, w));
ev2->quadrant = ev->quadrant;
/* report the disaster if we can */
- if (!damaged(DRADIO) || game.condit == IHDOCKED)
+ if (!damaged(DRADIO) || game.condition == docked)
{
prout("Uhura- We've lost contact with starsystem %s",
systemname(q->planet));
/* recompute time left */
game.state.remtime = game.state.remres/(game.state.remkl+4*game.state.remcom);
/* report the disaster if we can */
- if (!damaged(DRADIO) || game.condit == IHDOCKED)
+ if (!damaged(DRADIO) || game.condition == docked)
{
if (same(game.quadrant, w)) {
prout("Spock- sensors indicate the Klingons have");
if (game.alldone) return;
delay -= temp;
/* Repair Deathray if long rest at starbase */
- if (origTime-delay >= 9.99 && game.condit == IHDOCKED)
+ if (origTime-delay >= 9.99 && game.condition == docked)
game.damage[DDRAY] = 0.0;
} while
// leave if quadrant supernovas
if (!same(nq, game.quadrant) || game.justin) {
/* it isn't here, or we just entered (treat as enroute) */
- if (!damaged(DRADIO) || game.condit == IHDOCKED) {
+ if (!damaged(DRADIO) || game.condition == docked) {
skip(1);
prout(_("Message from Starfleet Command Stardate %.2f"), game.state.date);
prout(_(" Supernova in %s; caution advised."),
game.state.nplankl += npdead;
}
/* mark supernova in galaxy and in star chart */
- if (same(game.quadrant, nq) || !damaged(DRADIO) || game.condit == IHDOCKED)
+ if (same(game.quadrant, nq) || !damaged(DRADIO) || game.condition == docked)
game.state.galaxy[nq.x][nq.y].supernova = true;
/* If supernova destroys last Klingons give special message */
if (KLINGREM==0 && !same(nq, game.quadrant)) {
skip(1);
proutn("%d - %d ", w.x, w.y);
} else {
- if (!damaged(DSRSENS) || game.condit==IHDOCKED) {
+ if (!damaged(DSRSENS) || game.condition==docked) {
if (i != 1 && l == 1) {
drawmaps(2);
delay(400);
/* If tractor beam is to occur, don't move full distance */
if (game.state.date+game.optime >= scheduled(FTBEAM)) {
trbeam = true;
- game.condit = IHRED;
+ game.condition = red;
game.dist = game.dist*(scheduled(FTBEAM)-game.state.date)/game.optime + 0.1;
game.optime = scheduled(FTBEAM) - game.state.date + 1e-5;
}
game.kavgd[m] = 0.5 * (finald + game.kdist[m]);
}
/*
- * Stas Sergeev added the game.condition
+ * Stas Sergeev added the condition
* that attacks only happen if Klingons
* are present and your skill is good.
*/
/* dock our ship at a starbase */
{
chew();
- if (game.condit == IHDOCKED && verbose) {
+ if (game.condition == docked && verbose) {
prout(_("Already docked."));
return;
}
prout(_(" not adjacent to base."));
return;
}
- game.condit = IHDOCKED;
+ game.condition = docked;
if (verbose) prout(_("Docked."));
game.ididit = true;
if (game.energy < game.inenrg) game.energy = game.inenrg;
if (is_scheduled(FDSPROB)) {
chew();
skip(1);
- if (damaged(DRADIO) && game.condit != IHDOCKED) {
+ if (damaged(DRADIO) && game.condition != docked) {
prout(_("Spock- \"Records show the previous probe has not yet"));
prout(_(" reached its destination.\""));
}
int line = 0, m, ix, iy;
chew();
- /* Test for game.conditions which prevent calling for help */
- if (game.condit == IHDOCKED) {
+ /* Test for conditions which prevent calling for help */
+ if (game.condition == docked) {
prout(_("Lt. Uhura- \"But Captain, we're already docked.\""));
return;
}
}
if (game.energy >= 1000) {
prout(_("Spock- \"Captain, Starfleet Regulations prohibit such an operation"));
- prout(_(" except when condition Yellow exists."));
+ prout(_(" except when Condition Yellow exists."));
return;
}
prout(_("Spock- \"Captain, I must warn you that loading"));
prout(_("You will have to beam down to retrieve the shuttle craft."));
return;
}
- if (game.shldup || game.condit == IHDOCKED) {
+ if (game.shldup || game.condition == docked) {
prout(_("Shuttle craft cannot pass through shields."));
return;
}
prout(_(" destroyed, %d remaining."), game.state.rembase);
}
else prout(_("There are %d bases."), game.inbase);
- if (!damaged(DRADIO) || game.condit == IHDOCKED || game.iseenit) {
+ if (!damaged(DRADIO) || game.condition == docked || game.iseenit) {
/* Don't report this if not seen and
either the radio is dead or not at base! */
attakreport(false);
if (game.nprobes!=1) proutn(_("s"));
prout(".");
}
- if ((!damaged(DRADIO) || game.condit == IHDOCKED)
+ if ((!damaged(DRADIO) || game.condition == docked)
&& is_scheduled(FDSPROB)) {
if (game.isarmed)
proutn(_("An armed deep space probe is in"));
chew();
if (damaged(DLRSENS)) {
/* Now allow base's sensors if docked */
- if (game.condit != IHDOCKED) {
+ if (game.condition != docked) {
prout(_("LONG-RANGE SENSORS DAMAGED."));
return;
}
if (!damaged(DRADIO))
rechart();
- if (game.lastchart < game.state.date && game.condit == IHDOCKED) {
+ if (game.lastchart < game.state.date && game.condition == docked) {
prout(_("Spock- \"I revised the Star Chart from the starbase's records.\""));
rechart();
}
{
if (goodScan || (abs(i-game.sector.x)<= 1 && abs(j-game.sector.y) <= 1)){
if ((game.quad[i][j]==IHMATER0)||(game.quad[i][j]==IHMATER1)||(game.quad[i][j]==IHMATER2)||(game.quad[i][j]==IHE)||(game.quad[i][j]==IHF)){
- switch (game.condit) {
- case IHRED: textcolor(RED); break;
- case IHGREEN: textcolor(GREEN); break;
- case IHYELLOW: textcolor(YELLOW); break;
- case IHDOCKED: textcolor(CYAN); break;
- case IHDEAD: textcolor(BROWN);
+ switch (game.condition) {
+ case red: textcolor(RED); break;
+ case green: textcolor(GREEN); break;
+ case yellow: textcolor(YELLOW); break;
+ case docked: textcolor(CYAN); break;
+ case dead: textcolor(BROWN);
}
if (game.quad[i][j] != game.ship)
highvideo();
proutn(_("Stardate %.1f, Time Left %.2f"), game.state.date, game.state.remtime);
break;
case 2:
- if (game.condit != IHDOCKED) newcnd();
- switch (game.condit) {
- case IHRED: cp = "RED"; break;
- case IHGREEN: cp = "GREEN"; break;
- case IHYELLOW: cp = "YELLOW"; break;
- case IHDOCKED: cp = "DOCKED"; break;
- case IHDEAD: cp="DEAD"; break;
+ if (game.condition != docked) newcnd();
+ switch (game.condition) {
+ case red: cp = "RED"; break;
+ case green: cp = "GREEN"; break;
+ case yellow: cp = "YELLOW"; break;
+ case docked: cp = "DOCKED"; break;
+ case dead: cp="DEAD"; break;
}
for (t=0;t<NDEVICES;t++)
if (game.damage[t]>0)
case 4:
proutn(_("Life Support "));
if (damaged(DLIFSUP)) {
- if (game.condit == IHDOCKED)
+ if (game.condition == docked)
proutn(_("DAMAGED, Base provides"));
else
proutn(_("DAMAGED, reserves=%4.2f"), game.lsupres);
case SCAN_FULL: // SRSCAN
if (damaged(DSRSENS)) {
/* Allow base's sensors if docked */
- if (game.condit != IHDOCKED) {
+ if (game.condition != docked) {
prout(_(" S.R. SENSORS DAMAGED!"));
goodScan=false;
}
leftside=false;
break;
}
- if (game.condit != IHDOCKED) newcnd();
+ if (game.condition != docked) newcnd();
for (i = 1; i <= max(QUADSIZE, sizeof(requests)/sizeof(requests[0])); i++) {
jj = (req!=0 ? req : i);
if (leftside && i <= QUADSIZE) {
struct quadrant *q;
chew();
- if (game.condit==IHDOCKED) {
+ if (game.condition==docked) {
if (game.ship!=IHE) {
prout("You cannot abandon Ye Faerie Queene.");
return;
game.imine = false;
game.iscraft=0; /* Galileo disappears */
/* Resupply ship */
- game.condit=IHDOCKED;
+ game.condition=docked;
for (l = 0; l < NDEVICES; l++)
game.damage[l] = 0.0;
game.damage[DSHUTTL] = -1;
void newcnd(void)
/* update our alert status */
{
- game.condit = IHGREEN;
- if (game.energy < 1000.0) game.condit = IHYELLOW;
+ game.condition = green;
+ if (game.energy < 1000.0) game.condition = yellow;
if (game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons || game.state.galaxy[game.quadrant.x][game.quadrant.y].romulans)
- game.condit = IHRED;
- if (!game.alive) game.condit=IHDEAD;
+ game.condition = red;
+ if (!game.alive) game.condition=dead;
}
coord newkling(int i)
else
game.plnet = dropin(IHW);
}
- // Check for game.condition
+ // Check for condition
newcnd();
// And finally the stars
for (i = 1; i <= q->stars; i++)
icrystl, // dilithium crystals aboard
iseenit, // seen base attack report
thawed; // thawed game
+ enum {
+ green = 'G',
+ yellow = 'Y',
+ red = 'R',
+ docked = 'D',
+ dead = 'Z',
+ } condition; // condition (red/yellow/green/docked)
int inkling, // initial number of klingons
inbase, // initial number of bases
incom, // initial number of commanders
inrom, // initial number of commanders
instar, // initial stars
intorps, // initial/Max torpedoes
- condit, // condition (red/yellow/green/docked)
torps, // number of torpedoes
ship, // ship type -- 'E' is Enterprise
abandoned, // count of crew abandoned in space
#define IHF 'F'
#define IHT 'T'
#define IHWEB '#'
-#define IHGREEN 'G'
-#define IHYELLOW 'Y'
-#define IHRED 'R'
-#define IHDOCKED 'D'
-#define IHDEAD 'Z'
#define IHMATER0 '-'
#define IHMATER1 'o'
#define IHMATER2 '0'
-
/* Function prototypes */
void prelim(void);
void attack(bool);