E.g., with the body on the same line as the guard. They're bad style
and make the code hard to read, and I got fed up,
/* avoid intruding on another commander's territory */
if (ienm == IHC) {
for_commanders(n)
/* avoid intruding on another commander's territory */
if (ienm == IHC) {
for_commanders(n)
- if (same(game.state.kcmdr[n],iq)) return false;
+ if (same(game.state.kcmdr[n],iq))
+ return false;
/* refuse to leave if currently attacking starbase */
/* refuse to leave if currently attacking starbase */
- if (same(game.battle, game.quadrant)) return false;
+ if (same(game.battle, game.quadrant))
+ return false;
}
/* don't leave if over 1000 units of energy */
}
/* don't leave if over 1000 units of energy */
- if (game.kpower[loccom] > 1000.) return false;
+ if (game.kpower[loccom] > 1000.0)
+ return false;
}
/* print escape message and move out of quadrant.
We know this if either short or long range sensors are working */
}
/* print escape message and move out of quadrant.
We know this if either short or long range sensors are working */
game.kdist[loccom] = game.kdist[game.nenhere];
game.klhere--;
game.nenhere--;
game.kdist[loccom] = game.kdist[game.nenhere];
game.klhere--;
game.nenhere--;
- if (game.condition != docked) 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++;
/* 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 (idebug)
proutn("=== MOTION = %d, FORCES = %1.2f, ", motion, forces);
/* don't move if no motion */
if (idebug)
proutn("=== MOTION = %d, FORCES = %1.2f, ", motion, forces);
/* don't move if no motion */
+ if (motion==0)
+ return;
/* Limit motion according to skill */
/* Limit motion according to skill */
- if (abs(motion) > game.skill) motion = (motion < 0) ? -game.skill : game.skill;
+ if (abs(motion) > game.skill)
+ motion = (motion < 0) ? -game.skill : game.skill;
}
/* calculate preferred number of steps */
nsteps = motion < 0 ? -motion : motion;
}
/* calculate preferred number of steps */
nsteps = motion < 0 ? -motion : motion;
/* Compute preferred values of delta X and Y */
mx = game.sector.x - com.x;
my = game.sector.y - com.y;
/* Compute preferred values of delta X and Y */
mx = game.sector.x - com.x;
my = game.sector.y - com.y;
- if (2.0 * abs(mx) < abs(my)) mx = 0;
- if (2.0 * abs(my) < abs(game.sector.x-com.x)) my = 0;
- if (mx != 0) mx = mx*motion < 0 ? -1 : 1;
- if (my != 0) my = my*motion < 0 ? -1 : 1;
+ if (2.0 * abs(mx) < abs(my))
+ mx = 0;
+ if (2.0 * abs(my) < abs(game.sector.x-com.x))
+ my = 0;
+ if (mx != 0)
+ mx = mx*motion < 0 ? -1 : 1;
+ if (my != 0)
+ my = my*motion < 0 ? -1 : 1;
next = com;
/* main move loop */
for (ll = 0; ll < nsteps; ll++) {
next = com;
/* main move loop */
for (ll = 0; ll < nsteps; ll++) {
if (look.x < 1 || look.x > QUADSIZE) {
if (motion < 0 && tryexit(look, ienm, loccom, irun))
return;
if (look.x < 1 || look.x > QUADSIZE) {
if (motion < 0 && tryexit(look, ienm, loccom, irun))
return;
- if (krawlx == mx || my == 0) break;
+ if (krawlx == mx || my == 0)
+ break;
look.x = next.x + krawlx;
krawlx = -krawlx;
}
else if (look.y < 1 || look.y > QUADSIZE) {
if (motion < 0 && tryexit(look, ienm, loccom, irun))
return;
look.x = next.x + krawlx;
krawlx = -krawlx;
}
else if (look.y < 1 || look.y > QUADSIZE) {
if (motion < 0 && tryexit(look, ienm, loccom, irun))
return;
- if (krawly == my || mx == 0) break;
+ if (krawly == my || mx == 0)
+ break;
look.y = next.y + krawly;
krawly = -krawly;
}
look.y = next.y + krawly;
krawly = -krawly;
}
look.y = next.y + krawly;
krawly = -krawly;
}
look.y = next.y + krawly;
krawly = -krawly;
}
- else break; /* we have failed */
+ else
+ break; /* we have failed */
}
if (success) {
next = look;
if (idebug)
proutn(cramlc(neither, next));
}
}
if (success) {
next = look;
if (idebug)
proutn(cramlc(neither, next));
}
- else break; /* done early */
+ else
+ break; /* done early */
proutn("***");
cramen(ienm);
proutn(_(" from %s"), cramlc(2, com));
proutn("***");
cramen(ienm);
proutn(_(" from %s"), cramlc(2, com));
- if (game.kdist[loccom] < dist1) proutn(_(" advances to "));
- else proutn(_(" retreats to "));
+ if (game.kdist[loccom] < dist1)
+ proutn(_(" advances to "));
+ else
+ proutn(_(" retreats to "));
prout(cramlc(sector, next));
}
}
prout(cramlc(sector, next));
}
}
- if (idebug) prout("== MOVCOM");
+ if (idebug)
+ prout("== MOVCOM");
/* Figure out which Klingon is the commander (or Supercommander)
and do move */
/* Figure out which Klingon is the commander (or Supercommander)
and do move */
if (same(game.state.baseq[i], iq))
return true;
}
if (same(game.state.baseq[i], iq))
return true;
}
- if (game.justin && !game.iscate) return true;
+ if (game.justin && !game.iscate)
+ return true;
/* do the move */
game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].klingons--;
game.state.kscmdr = iq;
/* do the move */
game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].klingons--;
game.state.kscmdr = iq;
game.ientesc = false;
unschedule(FSCDBAS);
for_local_enemies(i)
game.ientesc = false;
unschedule(FSCDBAS);
for_local_enemies(i)
- if (game.quad[game.ks[i].x][game.ks[i].y] == IHS) break;
+ if (game.quad[game.ks[i].x][game.ks[i].y] == IHS)
+ break;
game.quad[game.ks[i].x][game.ks[i].y] = IHDOT;
game.ks[i] = game.ks[game.nenhere];
game.kdist[i] = game.kdist[game.nenhere];
game.quad[game.ks[i].x][game.ks[i].y] = IHDOT;
game.ks[i] = game.ks[game.nenhere];
game.kdist[i] = game.kdist[game.nenhere];
game.kpower[i] = game.kpower[game.nenhere];
game.klhere--;
game.nenhere--;
game.kpower[i] = game.kpower[game.nenhere];
game.klhere--;
game.nenhere--;
- if (game.condition!=docked) newcnd();
+ if (game.condition!=docked)
+ newcnd();
sortkl();
}
/* check for a helpful planet */
sortkl();
}
/* check for a helpful planet */
DESTROY(&game.state.plnets[i]);
game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].planet = NOPLANET;
if (!damaged(DRADIO) || game.condition == docked) {
DESTROY(&game.state.plnets[i]);
game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].planet = NOPLANET;
if (!damaged(DRADIO) || game.condition == docked) {
- if (!*ipage) pause_game(true);
+ if (!*ipage)
+ pause_game(true);
*ipage = true;
prout(_("Lt. Uhura- \"Captain, Starfleet Intelligence reports"));
proutn(_(" a planet in "));
*ipage = true;
prout(_("Lt. Uhura- \"Captain, Starfleet Intelligence reports"));
proutn(_(" a planet in "));
double bdist[BASEMAX+1];
bool flag;
double bdist[BASEMAX+1];
bool flag;
- if (idebug) prout("== SCOM");
+ if (idebug)
+ prout("== SCOM");
/* Decide on being active or passive */
flag = ((NKILLC+NKILLK)/(game.state.date+0.01-game.indate) < 0.1*game.skill*(game.skill+1.0) ||
/* Decide on being active or passive */
flag = ((NKILLC+NKILLK)/(game.state.date+0.01-game.indate) < 0.1*game.skill*(game.skill+1.0) ||
ideltay = ibq.y - game.state.kscmdr.y;
}
/* Maximum movement is 1 quadrant in either or both axis */
ideltay = ibq.y - game.state.kscmdr.y;
}
/* Maximum movement is 1 quadrant in either or both axis */
- if (ideltax > 1) ideltax = 1;
- if (ideltax < -1) ideltax = -1;
- if (ideltay > 1) ideltay = 1;
- if (ideltay < -1) ideltay = -1;
+ if (ideltax > 1)
+ ideltax = 1;
+ if (ideltax < -1)
+ ideltax = -1;
+ if (ideltay > 1)
+ ideltay = 1;
+ if (ideltay < -1)
+ ideltay = -1;
/* try moving in both x and y directions */
iq.x = game.state.kscmdr.x + ideltax;
/* try moving in both x and y directions */
iq.x = game.state.kscmdr.x + ideltax;
if (damaged(DRADIO) && game.condition != docked)
return; /* no warning */
game.iseenit = true;
if (damaged(DRADIO) && game.condition != docked)
return; /* no warning */
game.iseenit = true;
- if (!*ipage) pause_game(true);
+ if (!*ipage)
+ pause_game(true);
*ipage = true;
proutn(_("Lt. Uhura- \"Captain, the starbase in "));
proutn(cramlc(quadrant, game.state.kscmdr));
*ipage = true;
proutn(_("Lt. Uhura- \"Captain, the starbase in "));
proutn(cramlc(quadrant, game.state.kscmdr));
prout(_(" reports that it is under attack from the Klingon Super-commander."));
proutn(_(" It can survive until stardate %d.\""),
(int)scheduled(FSCDBAS));
prout(_(" reports that it is under attack from the Klingon Super-commander."));
proutn(_(" It can survive until stardate %d.\""),
(int)scheduled(FSCDBAS));
- if (!game.resting) return;
+ if (!game.resting)
+ return;
prout(_("Mr. Spock- \"Captain, shall we cancel the rest period?\""));
prout(_("Mr. Spock- \"Captain, shall we cancel the rest period?\""));
- if (ja() == false) return;
+ if (ja() == false)
+ return;
game.resting = false;
game.optime = 0.0; /* actually finished */
return;
game.resting = false;
game.optime = 0.0; /* actually finished */
return;
(damaged(DRADIO) && game.condition != docked) ||
!game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].charted))
return;
(damaged(DRADIO) && game.condition != docked) ||
!game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].charted))
return;
- if (!*ipage) pause_game(true);
+ if (!*ipage)
+ pause_game(true);
*ipage = true;
prout(_("Lt. Uhura- \"Captain, Starfleet Intelligence reports"));
proutn(_(" the Super-commander is in "));
*ipage = true;
prout(_("Lt. Uhura- \"Captain, Starfleet Intelligence reports"));
proutn(_(" the Super-commander is in "));
{
int idx, idy, im, i;
/* Move the Tholian */
{
int idx, idy, im, i;
/* Move the Tholian */
- if (!game.ithere || game.justin) return;
+ if (!game.ithere || game.justin)
+ return;
if (game.tholian.x == 1 && game.tholian.y == 1) {
idx = 1; idy = QUADSIZE;
if (game.tholian.x == 1 && game.tholian.y == 1) {
idx = 1; idy = QUADSIZE;
}
/* Do nothing if we are blocked */
}
/* Do nothing if we are blocked */
- if (game.quad[idx][idy]!= IHDOT && game.quad[idx][idy]!= IHWEB) return;
+ if (game.quad[idx][idy]!= IHDOT && game.quad[idx][idy]!= IHWEB)
+ return;
game.quad[game.tholian.x][game.tholian.y] = IHWEB;
if (game.tholian.x != idx) {
game.quad[game.tholian.x][game.tholian.y] = IHWEB;
if (game.tholian.x != idx) {
im = fabs((double)idx - game.tholian.x)/((double)idx - game.tholian.x);
while (game.tholian.x != idx) {
game.tholian.x += im;
im = fabs((double)idx - game.tholian.x)/((double)idx - game.tholian.x);
while (game.tholian.x != idx) {
game.tholian.x += im;
- if (game.quad[game.tholian.x][game.tholian.y]==IHDOT) game.quad[game.tholian.x][game.tholian.y] = IHWEB;
+ if (game.quad[game.tholian.x][game.tholian.y]==IHDOT)
+ game.quad[game.tholian.x][game.tholian.y] = IHWEB;
}
}
else if (game.tholian.y != idy) {
}
}
else if (game.tholian.y != idy) {
im = fabs((double)idy - game.tholian.y)/((double)idy - game.tholian.y);
while (game.tholian.y != idy) {
game.tholian.y += im;
im = fabs((double)idy - game.tholian.y)/((double)idy - game.tholian.y);
while (game.tholian.y != idy) {
game.tholian.y += im;
- if (game.quad[game.tholian.x][game.tholian.y]==IHDOT) game.quad[game.tholian.x][game.tholian.y] = IHWEB;
+ if (game.quad[game.tholian.x][game.tholian.y]==IHDOT)
+ game.quad[game.tholian.x][game.tholian.y] = IHWEB;
}
}
game.quad[game.tholian.x][game.tholian.y] = IHT;
}
}
game.quad[game.tholian.x][game.tholian.y] = IHT;
/* check to see if all holes plugged */
for_sectors(i) {
/* check to see if all holes plugged */
for_sectors(i) {
- if (game.quad[1][i]!=IHWEB && game.quad[1][i]!=IHT) return;
- if (game.quad[QUADSIZE][i]!=IHWEB && game.quad[QUADSIZE][i]!=IHT) return;
- if (game.quad[i][1]!=IHWEB && game.quad[i][1]!=IHT) return;
- if (game.quad[i][QUADSIZE]!=IHWEB && game.quad[i][QUADSIZE]!=IHT) return;
+ if (game.quad[1][i]!=IHWEB && game.quad[1][i]!=IHT)
+ return;
+ if (game.quad[QUADSIZE][i]!=IHWEB && game.quad[QUADSIZE][i]!=IHT)
+ return;
+ if (game.quad[i][1]!=IHWEB && game.quad[i][1]!=IHT)
+ return;
+ if (game.quad[i][QUADSIZE]!=IHWEB && game.quad[i][QUADSIZE]!=IHT)
+ return;
}
/* All plugged up -- Tholian splits */
game.quad[game.tholian.x][game.tholian.y]=IHWEB;
}
/* All plugged up -- Tholian splits */
game.quad[game.tholian.x][game.tholian.y]=IHWEB;
}
else if (game.shldup) {
proutn(_("Shields are up. Do you want them down? "));
}
else if (game.shldup) {
proutn(_("Shields are up. Do you want them down? "));
- if (ja() == true) action = SHDN;
+ if (ja() == true)
+ action = SHDN;
}
else {
proutn(_("Shields are down. Do you want them up? "));
}
else {
proutn(_("Shields are down. Do you want them up? "));
- if (ja() == true) action = SHUP;
+ if (ja() == true)
+ action = SHUP;
}
game.shldup = true;
game.shldchg = true;
}
game.shldup = true;
game.shldchg = true;
- if (game.condition != docked) game.energy -= 50.0;
+ if (game.condition != docked)
+ game.energy -= 50.0;
prout(_("Shields raised."));
if (game.energy <= 0) {
skip(1);
prout(_("Shields raised."));
if (game.energy <= 0) {
skip(1);
proutn(_("Energy to transfer to shields- "));
}
chew();
proutn(_("Energy to transfer to shields- "));
}
chew();
+ if (aaitem==0)
+ return;
if (aaitem > game.energy) {
prout(_("Insufficient ship energy."));
return;
if (aaitem > game.energy) {
prout(_("Insufficient ship energy."));
return;
}
proutn(ibumpd ? _(" rammed by ") : _(" rams "));
crmena(false, ienm, sector, w);
}
proutn(ibumpd ? _(" rammed by ") : _(" rams "));
crmena(false, ienm, sector, w);
- if (ibumpd) proutn(_(" (original position)"));
+ if (ibumpd)
+ proutn(_(" (original position)"));
skip(1);
deadkl(w, ienm, game.sector);
proutn("***");
skip(1);
deadkl(w, ienm, game.sector);
proutn("***");
pause_game(true);
dreprt();
}
pause_game(true);
dreprt();
}
w.x = w.y = jw.x = jw.y = 0;
bigger = fabs(deltax);
w.x = w.y = jw.x = jw.y = 0;
bigger = fabs(deltax);
- if (fabs(deltay) > bigger) bigger = fabs(deltay);
+ if (fabs(deltay) > bigger)
+ bigger = fabs(deltay);
deltax /= bigger;
deltay /= bigger;
if (!damaged(DSRSENS) || game.condition==docked)
deltax /= bigger;
deltay /= bigger;
if (!damaged(DSRSENS) || game.condition==docked)
w.x = x + 0.5;
y += deltay;
w.y = y + 0.5;
w.x = x + 0.5;
y += deltay;
w.y = y + 0.5;
- if (!VALID_SECTOR(w.x, w.y)) break;
+ if (!VALID_SECTOR(w.x, w.y))
+ break;
iquad=game.quad[w.x][w.y];
tracktorpedo(w, l, i, n, iquad);
iquad=game.quad[w.x][w.y];
tracktorpedo(w, l, i, n, iquad);
- if (iquad==IHDOT) continue;
+ if (iquad==IHDOT)
+ continue;
/* hit something */
setwnd(message_window);
if (damaged(DSRSENS) && !game.condition==docked)
/* hit something */
setwnd(message_window);
if (damaged(DSRSENS) && !game.condition==docked)
return; /* Cheat if on a planet */
ang = angle + 2.5*(Rand()-0.5);
temp = fabs(sin(ang));
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));
+ if (fabs(cos(ang)) > temp)
+ temp = fabs(cos(ang));
xx = -sin(ang)/temp;
yy = cos(ang)/temp;
jw.x=w.x+xx+0.5;
jw.y=w.y+yy+0.5;
xx = -sin(ang)/temp;
yy = cos(ang)/temp;
jw.x=w.x+xx+0.5;
jw.y=w.y+yy+0.5;
- if (!VALID_SECTOR(jw.x, jw.y)) return;
+ if (!VALID_SECTOR(jw.x, jw.y))
+ return;
if (game.quad[jw.x][jw.y]==IHBLANK) {
finish(FHOLE);
return;
if (game.quad[jw.x][jw.y]==IHBLANK) {
finish(FHOLE);
return;
h1 = 700.0 + 100.0*Rand() -
1000.0 * distance(w, in) * fabs(sin(bullseye-angle));
h1 = fabs(h1);
h1 = 700.0 + 100.0*Rand() -
1000.0 * distance(w, in) * fabs(sin(bullseye-angle));
h1 = fabs(h1);
+ if (kp < h1)
+ h1 = kp;
game.kpower[ll] -= (game.kpower[ll]<0 ? -h1 : h1);
if (game.kpower[ll] == 0) {
deadkl(w, iquad, w);
game.kpower[ll] -= (game.kpower[ll]<0 ? -h1 : h1);
if (game.kpower[ll] == 0) {
deadkl(w, iquad, w);
/* If enemy damaged but not destroyed, try to displace */
ang = angle + 2.5*(Rand()-0.5);
temp = fabs(sin(ang));
/* If enemy damaged but not destroyed, try to displace */
ang = angle + 2.5*(Rand()-0.5);
temp = fabs(sin(ang));
- if (fabs(cos(ang)) > temp) temp = fabs(cos(ang));
+ if (fabs(cos(ang)) > temp)
+ temp = fabs(cos(ang));
xx = -sin(ang)/temp;
yy = cos(ang)/temp;
jw.x=w.x+xx+0.5;
xx = -sin(ang)/temp;
yy = cos(ang)/temp;
jw.x=w.x+xx+0.5;
int ktr=1, loop1, loop2, j, cdam[NDEVICES];
/* a critical hit occured */
int ktr=1, loop1, loop2, j, cdam[NDEVICES];
/* a critical hit occured */
- if (hit < (275.0-25.0*game.skill)*(1.0+0.5*Rand())) return;
+ if (hit < (275.0-25.0*game.skill)*(1.0+0.5*Rand()))
+ return;
ncrit = 1.0 + hit/(500.0+100.0*Rand());
proutn(_("***CRITICAL HIT--"));
ncrit = 1.0 + hit/(500.0+100.0*Rand());
proutn(_("***CRITICAL HIT--"));
game.damage[j] += extradm;
if (loop1 > 0) {
for (loop2 = 0; loop2 < loop1 && j != cdam[loop2]; loop2++) ;
game.damage[j] += extradm;
if (loop1 > 0) {
for (loop2 = 0; loop2 < loop1 && j != cdam[loop2]; loop2++) ;
- if (loop2 < loop1) continue;
+ if (loop2 < loop1)
+ continue;
ktr += 1;
if (ktr==3) skip(1);
proutn(_(" and "));
ktr += 1;
if (ktr==3) skip(1);
proutn(_(" and "));
/* set up partial hits if attack happens during shield status change */
pfac = 1.0/game.inshld;
/* set up partial hits if attack happens during shield status change */
pfac = 1.0/game.inshld;
- if (game.shldchg) chgfac = 0.25+0.5*Rand();
+ if (game.shldchg)
+ chgfac = 0.25+0.5*Rand();
/* compute hit strength and diminish shield power */
r = Rand();
/* Increase chance of photon torpedos if docked or enemy energy low */
/* compute hit strength and diminish shield power */
r = Rand();
/* Increase chance of photon torpedos if docked or enemy energy low */
- if (game.condition == docked) r *= 0.25;
- if (game.kpower[loop] < 500) 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];
jay = game.ks[loop];
iquad = game.quad[jay.x][jay.y];
- if (iquad==IHT || (iquad==IHQUEST && !iqengry)) continue;
+ if (iquad==IHT || (iquad==IHQUEST && !iqengry))
+ continue;
/* different enemies have different probabilities of throwing a torp */
usephasers = !torps_ok || \
(iquad == IHK && r > 0.0005) ||
/* different enemies have different probabilities of throwing a torp */
usephasers = !torps_ok || \
(iquad == IHK && r > 0.0005) ||
finish(FWON); /* Klingons did themselves in! */
if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova || game.alldone)
return; /* Supernova or finished */
finish(FWON); /* Klingons did themselves in! */
if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova || game.alldone)
return; /* Supernova or finished */
- if (hit == 0) continue;
+ if (hit == 0)
+ continue;
}
/* incoming phaser or torpedo, shields may dissipate it */
if (game.shldup || game.shldchg || game.condition==docked) {
/* shields will take hits */
double absorb, hitsh, propor = pfac*game.shield*(game.condition==docked ? 2.1 : 1.0);
}
/* incoming phaser or torpedo, shields may dissipate it */
if (game.shldup || game.shldchg || game.condition==docked) {
/* shields will take hits */
double absorb, hitsh, propor = pfac*game.shield*(game.condition==docked ? 2.1 : 1.0);
- if (propor < 0.1) propor = 0.1;
+ if (propor < 0.1)
+ propor = 0.1;
hitsh = propor*chgfac*hit+1.0;
absorb = 0.8*hitsh;
hitsh = propor*chgfac*hit+1.0;
absorb = 0.8*hitsh;
- if (absorb > game.shield) absorb = game.shield;
+ if (absorb > game.shield)
+ absorb = game.shield;
game.shield -= absorb;
hit -= hitsh;
/* taking a hit blasts us out of a starbase dock */
game.shield -= absorb;
hit -= hitsh;
/* taking a hit blasts us out of a starbase dock */
}
skip(1);
/* Decide if hit is critical */
}
skip(1);
/* Decide if hit is critical */
- if (hit > hitmax) hitmax = hit;
+ if (hit > hitmax)
+ hitmax = hit;
hittot += hit;
fry(hit);
game.energy -= hit;
hittot += hit;
fry(hit);
game.energy -= hit;
}
if (!attempt && game.condition == docked)
prout(_("***Enemies decide against attacking your ship."));
}
if (!attempt && game.condition == docked)
prout(_("***Enemies decide against attacking your ship."));
percent = 100.0*pfac*game.shield+0.5;
if (!ihurt) {
/* Shields fully protect ship */
percent = 100.0*pfac*game.shield+0.5;
if (!ihurt) {
/* Shields fully protect ship */
/* Print message if starship suffered hit(s) */
skip(1);
proutn(_("Energy left %2d shields "), (int)game.energy);
/* Print message if starship suffered hit(s) */
skip(1);
proutn(_("Energy left %2d shields "), (int)game.energy);
- if (game.shldup) proutn(_("up "));
- else if (!damaged(DSHIELD)) proutn(_("down "));
- else proutn(_("damaged, "));
+ if (game.shldup)
+ proutn(_("up "));
+ else if (!damaged(DSHIELD))
+ proutn(_("down "));
+ else
+ proutn(_("damaged, "));
}
prout(_("%d%%, torpedoes left %d"), percent, game.torps);
/* Check if anyone was hurt */
}
prout(_("%d%%, torpedoes left %d"), percent, game.torps);
/* Check if anyone was hurt */
/* For each kind of enemy, finish message to player */
prout(_(" destroyed."));
game.quad[w.x][w.y] = IHDOT;
/* For each kind of enemy, finish message to player */
prout(_(" destroyed."));
game.quad[w.x][w.y] = IHDOT;
- if (KLINGREM==0) return;
+ if (KLINGREM==0)
+ return;
game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);
game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);
if (is_scheduled(FCDBAS) && same(game.battle, game.quadrant) && type==IHC)
unschedule(FCDBAS);
for_local_enemies(i)
if (is_scheduled(FCDBAS) && same(game.battle, game.quadrant) && type==IHC)
unschedule(FCDBAS);
for_local_enemies(i)
- if (same(game.ks[i], w)) break;
+ if (same(game.ks[i], w))
+ break;
game.nenhere--;
if (i <= game.nenhere) {
for (j=i; j<=game.nenhere; j++) {
game.nenhere--;
if (i <= game.nenhere) {
for (j=i; j<=game.nenhere; j++) {
- if (n <= game.torps) break;
+ if (n <= game.torps)
+ break;
return;
}
targ[i][2] = aaitem;
return;
}
targ[i][2] = aaitem;
- if (targetcheck(targ[i][1], targ[i][2], &course[i])) return;
+ if (targetcheck(targ[i][1], targ[i][2], &course[i]))
+ return;
}
chew();
if (i == 1 && key == IHEOL) {
}
chew();
if (i == 1 && key == IHEOL) {
}
targ[i][2] = aaitem;
chew();
}
targ[i][2] = aaitem;
chew();
- if (targetcheck(targ[i][1], targ[i][2], &course[i])) return;
+ if (targetcheck(targ[i][1], targ[i][2], &course[i]))
+ return;
}
}
game.ididit = true;
/* Loop for moving <n> torpedoes */
for (i = 1; i <= n; i++) {
}
}
game.ididit = true;
/* Loop for moving <n> torpedoes */
for (i = 1; i <= n; i++) {
- if (game.condition != docked) game.torps--;
+ if (game.condition != docked)
+ game.torps--;
r = (Rand()+Rand())*0.5 -0.5;
if (fabs(r) >= 0.47) {
/* misfire! */
r = (Rand()+Rand())*0.5 -0.5;
if (fabs(r) >= 0.47) {
/* misfire! */
if (n>1) {
prouts(_("***TORPEDO NUMBER %d MISFIRES"), i);
}
if (n>1) {
prouts(_("***TORPEDO NUMBER %d MISFIRES"), i);
}
- else prouts(_("***TORPEDO MISFIRES."));
+ else
+ prouts(_("***TORPEDO MISFIRES."));
skip(1);
if (i < n)
prout(_(" Remainder of burst aborted."));
skip(1);
if (i < n)
prout(_(" Remainder of burst aborted."));
if (game.alldone || game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
return;
}
if (game.alldone || game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
return;
}
- if (KLINGREM==0) finish(FWON);
+ if (KLINGREM==0)
+ finish(FWON);
chew();
proutn(_("Units to fire= "));
key = scan();
chew();
proutn(_("Units to fire= "));
key = scan();
- if (key!=IHREAL) return;
+ if (key!=IHREAL)
+ return;
rpow = aaitem;
if (rpow > (ifast?game.energy-200:game.energy)) {
proutn(_("Energy available= %.2f"),
rpow = aaitem;
if (rpow > (ifast?game.energy-200:game.energy)) {
proutn(_("Energy available= %.2f"),
}
if (ifast) {
game.energy -= 200; /* Go and do it! */
}
if (ifast) {
game.energy -= 200; /* Go and do it! */
- if (checkshctrl(rpow)) return;
+ if (checkshctrl(rpow))
+ return;
}
chew();
game.energy -= rpow;
}
chew();
game.energy -= rpow;
powrem = rpow;
for_local_enemies(i) {
hits[i] = 0.0;
powrem = rpow;
for_local_enemies(i) {
hits[i] = 0.0;
- if (powrem <= 0) continue;
+ if (powrem <= 0)
+ continue;
hits[i] = fabs(game.kpower[i])/(PHASEFAC*pow(0.90,game.kdist[i]));
over = (0.01 + 0.05*Rand())*hits[i];
temp = powrem;
powrem -= hits[i] + over;
hits[i] = fabs(game.kpower[i])/(PHASEFAC*pow(0.90,game.kdist[i]));
over = (0.01 + 0.05*Rand())*hits[i];
temp = powrem;
powrem -= hits[i] + over;
- if (powrem <= 0 && temp < hits[i]) hits[i] = temp;
- if (powrem <= 0) over = 0.0;
+ if (powrem <= 0 && temp < hits[i])
+ hits[i] = temp;
+ if (powrem <= 0)
+ over = 0.0;
- if (powrem > 0.0) extra += powrem;
+ if (powrem > 0.0)
+ extra += powrem;
hittem(hits);
game.ididit = true;
}
if (extra > 0 && !game.alldone) {
if (game.ithere) {
proutn(_("*** Tholian web absorbs "));
hittem(hits);
game.ididit = true;
}
if (extra > 0 && !game.alldone) {
if (game.ithere) {
proutn(_("*** Tholian web absorbs "));
- if (game.nenhere>0) proutn(_("excess "));
+ if (game.nenhere>0)
+ proutn(_("excess "));
prout(_("phaser energy."));
}
else {
prout(_("phaser energy."));
}
else {
(1.01+0.05*Rand()) + 1.0;
kz = k;
proutn("(");
(1.01+0.05*Rand()) + 1.0;
kz = k;
proutn("(");
- if (!damaged(DCOMPTR)) proutn("%d", irec);
- else proutn("??");
+ if (!damaged(DCOMPTR))
+ proutn("%d", irec);
+ else
+ proutn("??");
proutn(") ");
proutn(_("units to fire at "));
crmena(false, ienm, sector, aim);
proutn(") ");
proutn(_("units to fire at "));
crmena(false, ienm, sector, aim);
chew();
if (ifast) {
game.energy -= 200.0;
chew();
if (ifast) {
game.energy -= 200.0;
- if (checkshctrl(rpow)) return;
+ if (checkshctrl(rpow))
+ return;
}
hittem(hits);
game.ididit = true;
}
hittem(hits);
game.ididit = true;
skip(1);
for (; k <= nenhr2; k++, kk++) {
skip(1);
for (; k <= nenhr2; k++, kk++) {
- if ((wham = hits[k])==0) continue;
+ if ((wham = hits[k])==0)
+ continue;
dustfac = 0.9 + 0.01*Rand();
hit = wham*pow(dustfac,game.kdist[kk]);
kpini = game.kpower[kk];
kp = fabs(kpini);
dustfac = 0.9 + 0.01*Rand();
hit = wham*pow(dustfac,game.kdist[kk]);
kpini = game.kpower[kk];
kp = fabs(kpini);
- if (PHASEFAC*hit < kp) kp = PHASEFAC*hit;
+ if (PHASEFAC*hit < kp)
+ kp = PHASEFAC*hit;
game.kpower[kk] -= (game.kpower[kk] < 0 ? -kp: kp);
kpow = game.kpower[kk];
w = game.ks[kk];
game.kpower[kk] -= (game.kpower[kk] < 0 ? -kp: kp);
kpow = game.kpower[kk];
w = game.ks[kk];
else
proutn(_("Very small hit on "));
ienm = game.quad[w.x][w.y];
else
proutn(_("Very small hit on "));
ienm = game.quad[w.x][w.y];
- if (ienm==IHQUEST) iqengry = true;
+ if (ienm==IHQUEST)
+ iqengry = true;
crmena(false,ienm,sector,w);
skip(1);
if (kpow == 0) {
deadkl(w, ienm, w);
crmena(false,ienm,sector,w);
skip(1);
if (kpow == 0) {
deadkl(w, ienm, w);
- if (KLINGREM==0) finish(FWON);
- if (game.alldone) return;
+ if (KLINGREM==0)
+ finish(FWON);
+ if (game.alldone)
+ return;
kk--; /* don't do the increment */
}
else /* decide whether or not to emasculate klingon */
kk--; /* don't do the increment */
}
else /* decide whether or not to emasculate klingon */
for (;;) {
/* Select earliest extraneous event, evcode==0 if no events */
evcode = FSPY;
for (;;) {
/* Select earliest extraneous event, evcode==0 if no events */
evcode = FSPY;
- if (game.alldone) return;
+ if (game.alldone)
+ return;
datemin = fintim;
for (l = 1; l < NEVENTS; l++)
if (game.future[l].date < datemin) {
datemin = fintim;
for (l = 1; l < NEVENTS; l++)
if (game.future[l].date < datemin) {
return;
}
game.lsupres -= xtime;
return;
}
game.lsupres -= xtime;
- if (game.damage[DLIFSUP] <= xtime) game.lsupres = game.inlsr;
+ if (game.damage[DLIFSUP] <= xtime)
+ game.lsupres = game.inlsr;
}
/* Fix devices */
repair = xtime;
}
/* Fix devices */
repair = xtime;
- if (game.condition == docked) 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)
/* Don't fix Deathray here */
for (l=0; l<NDEVICES; l++)
if (game.damage[l] > 0.0 && l != DDRAY)
game.optime -= xtime;
switch (evcode) {
case FSNOVA: /* Supernova */
game.optime -= xtime;
switch (evcode) {
case FSNOVA: /* Supernova */
- if (!ipage) pause_game(true);
+ if (!ipage)
+ pause_game(true);
ipage=true;
snova(false, NULL);
schedule(FSNOVA, expran(0.5*game.intime));
ipage=true;
snova(false, NULL);
schedule(FSNOVA, expran(0.5*game.intime));
- if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) return;
+ if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
+ return;
break;
case FSPY: /* Check with spy to see if S.C. should tractor beam */
if (game.state.nscrem == 0 ||
break;
case FSPY: /* Check with spy to see if S.C. should tractor beam */
if (game.state.nscrem == 0 ||
yank = distance(game.state.kscmdr, game.quadrant);
/********* fall through to FTBEAM code ***********/
}
yank = distance(game.state.kscmdr, game.quadrant);
/********* fall through to FTBEAM code ***********/
}
case FTBEAM: /* Tractor beam */
if (evcode==FTBEAM) {
if (game.state.remcom == 0) {
case FTBEAM: /* Tractor beam */
if (evcode==FTBEAM) {
if (game.state.remcom == 0) {
}
/* tractor beaming cases merge here */
yank = sqrt(yank);
}
/* tractor beaming cases merge here */
yank = sqrt(yank);
- if (!ipage) pause_game(true);
+ if (!ipage)
+ pause_game(true);
ipage=true;
game.optime = (10.0/(7.5*7.5))*yank; /* 7.5 is yank rate (warp 7.5) */
ictbeam = true;
ipage=true;
game.optime = (10.0/(7.5*7.5))*yank; /* 7.5 is yank rate (warp 7.5) */
ictbeam = true;
prout(_(" caught in long range tractor beam--"));
/* If Kirk & Co. screwing around on planet, handle */
atover(true); /* atover(true) is Grab */
prout(_(" caught in long range tractor beam--"));
/* If Kirk & Co. screwing around on planet, handle */
atover(true); /* atover(true) is Grab */
- if (game.alldone) return;
+ if (game.alldone)
+ return;
if (game.icraft) { /* Caught in Galileo? */
finish(FSTRACTOR);
return;
if (game.icraft) { /* Caught in Galileo? */
finish(FSTRACTOR);
return;
doshield(true); /* raise shields */
game.shldchg=false;
}
doshield(true); /* raise shields */
game.shldchg=false;
}
- else prout(_("(Shields not currently useable.)"));
+ else
+ prout(_("(Shields not currently useable.)"));
}
newqad(false);
/* Adjust finish time to time of tractor beaming */
fintim = game.state.date+game.optime;
attack(false);
}
newqad(false);
/* Adjust finish time to time of tractor beaming */
fintim = game.state.date+game.optime;
attack(false);
- if (game.state.remcom <= 0) unschedule(FTBEAM);
- else schedule(FTBEAM, game.optime+expran(1.5*game.intime/game.state.remcom));
+ if (game.state.remcom <= 0)
+ unschedule(FTBEAM);
+ else
+ schedule(FTBEAM, game.optime+expran(1.5*game.intime/game.state.remcom));
break;
case FSNAP: /* Snapshot of the universe (for time warp) */
game.snapsht = game.state;
break;
case FSNAP: /* Snapshot of the universe (for time warp) */
game.snapsht = game.state;
}
if (j>game.state.rembase) {
/* no match found -- try later */
}
if (j>game.state.rembase) {
/* no match found -- try later */
if (!damaged(DRADIO) && game.condition != docked)
break; /* No warning :-( */
game.iseenit = true;
if (!damaged(DRADIO) && game.condition != docked)
break; /* No warning :-( */
game.iseenit = true;
- if (!ipage) pause_game(true);
+ if (!ipage)
+ pause_game(true);
ipage = true;
skip(1);
proutn(_("Lt. Uhura- \"Captain, the starbase in "));
ipage = true;
skip(1);
proutn(_("Lt. Uhura- \"Captain, the starbase in "));
else if (game.state.rembase != 1 &&
(!damaged(DRADIO) || game.condition == docked)) {
/* Get word via subspace radio */
else if (game.state.rembase != 1 &&
(!damaged(DRADIO) || game.condition == docked)) {
/* Get word via subspace radio */
- if (!ipage) pause_game(true);
+ if (!ipage)
+ pause_game(true);
ipage = true;
skip(1);
prout(_("Lt. Uhura- \"Captain, Starfleet Command reports that"));
ipage = true;
skip(1);
prout(_("Lt. Uhura- \"Captain, Starfleet Command reports that"));
prout(_(" has been destroyed by"));
if (game.isatb == 2)
prout(_("the Klingon Super-Commander"));
prout(_(" has been destroyed by"));
if (game.isatb == 2)
prout(_("the Klingon Super-Commander"));
- else prout(_("a Klingon Commander"));
+ else
+ prout(_("a Klingon Commander"));
game.state.chart[game.battle.x][game.battle.y].starbase = false;
}
/* Remove Starbase from galaxy */
game.state.chart[game.battle.x][game.battle.y].starbase = false;
}
/* Remove Starbase from galaxy */
game.state.galaxy[game.probec.x][game.probec.y].supernova) {
// Left galaxy or ran into supernova
if (!damaged(DRADIO) || game.condition == docked) {
game.state.galaxy[game.probec.x][game.probec.y].supernova) {
// Left galaxy or ran into supernova
if (!damaged(DRADIO) || game.condition == docked) {
- if (!ipage) pause_game(true);
+ if (!ipage)
+ pause_game(true);
ipage = true;
skip(1);
proutn(_("Lt. Uhura- \"The deep space probe "));
ipage = true;
skip(1);
proutn(_("Lt. Uhura- \"The deep space probe "));
break;
}
if (!damaged(DRADIO) || game.condition == docked) {
break;
}
if (!damaged(DRADIO) || game.condition == docked) {
- if (!ipage) pause_game(true);
+ if (!ipage)
+ pause_game(true);
ipage = true;
skip(1);
proutn(_("Lt. Uhura- \"The deep space probe is now in "));
ipage = true;
skip(1);
proutn(_("Lt. Uhura- \"The deep space probe is now in "));
game.ididit = false;
for (;;) {
key = scan();
game.ididit = false;
for (;;) {
key = scan();
- if (key != IHEOL) break;
+ if (key != IHEOL)
+ break;
proutn(_("How long? "));
}
chew();
proutn(_("How long? "));
}
chew();
return;
}
origTime = delay = aaitem;
return;
}
origTime = delay = aaitem;
- if (delay <= 0.0) return;
+ if (delay <= 0.0)
+ return;
if (delay >= game.state.remtime || game.nenhere != 0) {
proutn(_("Are you sure? "));
if (delay >= game.state.remtime || game.nenhere != 0) {
proutn(_("Are you sure? "));
- if (ja() == false) return;
+ if (ja() == false)
+ return;
}
/* Alternate resting periods (events) with attacks */
game.resting = true;
do {
}
/* Alternate resting periods (events) with attacks */
game.resting = true;
do {
- if (delay <= 0) game.resting = false;
+ if (delay <= 0)
+ game.resting = false;
if (!game.resting) {
prout(_("%d stardates left."), (int)game.state.remtime);
return;
if (!game.resting) {
prout(_("%d stardates left."), (int)game.state.remtime);
return;
if (game.nenhere) {
double rtime = 1.0 + Rand();
if (game.nenhere) {
double rtime = 1.0 + Rand();
- if (rtime < temp) temp = rtime;
+ if (rtime < temp)
+ temp = rtime;
- if (game.optime < delay) attack(false);
- if (game.alldone) return;
+ if (game.optime < delay)
+ attack(false);
+ if (game.alldone)
+ return;
events();
game.ididit = true;
events();
game.ididit = true;
- if (game.alldone) return;
+ if (game.alldone)
+ return;
delay -= temp;
/* Repair Deathray if long rest at starbase */
if (origTime-delay >= 9.99 && game.condition == docked)
delay -= temp;
/* Repair Deathray if long rest at starbase */
if (origTime-delay >= 9.99 && game.condition == docked)
for (mm = bot; mm <= top; mm++)
for (nn = 1; nn <= 3; nn++) /* nn,j represents coordinates around current */
for (j = 1; j <= 3; j++) {
for (mm = bot; mm <= top; mm++)
for (nn = 1; nn <= 3; nn++) /* nn,j represents coordinates around current */
for (j = 1; j <= 3; j++) {
- if (j==2 && nn== 2) continue;
+ if (j==2 && nn== 2)
+ continue;
scratch.x = hits[mm][1]+nn-2;
scratch.y = hits[mm][2]+j-2;
scratch.x = hits[mm][1]+nn-2;
scratch.y = hits[mm][2]+j-2;
- if (!VALID_SECTOR(scratch.y, scratch.x)) continue;
+ if (!VALID_SECTOR(scratch.y, scratch.x))
+ continue;
iquad = game.quad[scratch.x][scratch.y];
switch (iquad) {
// case IHDOT: /* Empty space ends reaction
iquad = game.quad[scratch.x][scratch.y];
switch (iquad) {
// case IHDOT: /* Empty space ends reaction
case IHF:
prout(_("***Starship buffeted by nova."));
if (game.shldup) {
case IHF:
prout(_("***Starship buffeted by nova."));
if (game.shldup) {
- if (game.shield >= 2000.0) game.shield -= 2000.0;
+ if (game.shield >= 2000.0)
+ game.shield -= 2000.0;
else {
double diff = 2000.0 - game.shield;
game.energy -= diff;
else {
double diff = 2000.0 - game.shield;
game.energy -= diff;
game.damage[DSHIELD] += 0.005*game.damfac*Rand()*diff;
}
}
game.damage[DSHIELD] += 0.005*game.damfac*Rand()*diff;
}
}
- else game.energy -= 2000.0;
+ else
+ game.energy -= 2000.0;
if (game.energy <= 0) {
finish(FNOVA);
return;
if (game.energy <= 0) {
finish(FNOVA);
return;
case IHS:
case IHR:
for_local_enemies(ll)
case IHS:
case IHR:
for_local_enemies(ll)
- if (same(game.ks[ll], scratch)) break;
+ if (same(game.ks[ll], scratch))
+ break;
game.kpower[ll] -= 800.0; /* If firepower is lost, die */
if (game.kpower[ll] <= 0.0) {
deadkl(scratch, iquad, scratch);
game.kpower[ll] -= 800.0; /* If firepower is lost, die */
if (game.kpower[ll] <= 0.0) {
deadkl(scratch, iquad, scratch);
/* Starship affected by nova -- kick it away. */
game.dist = kount*0.1;
/* Starship affected by nova -- kick it away. */
game.dist = kount*0.1;
- if (icx) icx = (icx < 0 ? -1 : 1);
- if (icy) icy = (icy < 0 ? -1 : 1);
+ if (icx)
+ icx = (icx < 0 ? -1 : 1);
+ if (icy)
+ icy = (icy < 0 ? -1 : 1);
game.direc = course[3*(icx+1)+icy+2];
game.direc = course[3*(icx+1)+icy+2];
- if (game.direc == 0.0) game.dist = 0.0;
- if (game.dist == 0.0) return;
+ if (game.direc == 0.0)
+ game.dist = 0.0;
+ if (game.dist == 0.0)
+ return;
game.optime = 10.0*game.dist/16.0;
skip(1);
prout(_("Force of nova displaces starship."));
game.optime = 10.0*game.dist/16.0;
skip(1);
prout(_("Force of nova displaces starship."));
for_quadrants(nq.x) {
for_quadrants(nq.y) {
num -= game.state.galaxy[nq.x][nq.y].stars;
for_quadrants(nq.x) {
for_quadrants(nq.y) {
num -= game.state.galaxy[nq.x][nq.y].stars;
}
if (idebug) {
proutn("=== Super nova here?");
}
if (idebug) {
proutn("=== Super nova here?");
for_sectors(ns.y) {
if (game.quad[ns.x][ns.y]==IHSTAR) {
num--;
for_sectors(ns.y) {
if (game.quad[ns.x][ns.y]==IHSTAR) {
num--;
invalidate(game.state.kcmdr[game.state.remcom]);
game.state.remcom--;
kldead--;
invalidate(game.state.kcmdr[game.state.remcom]);
game.state.remcom--;
kldead--;
- if (game.state.remcom==0) unschedule(FTBEAM);
+ if (game.state.remcom==0)
+ unschedule(FTBEAM);
/* If supernova destroys last Klingons give special message */
if (KLINGREM==0 && !same(nq, game.quadrant)) {
skip(2);
/* If supernova destroys last Klingons give special message */
if (KLINGREM==0 && !same(nq, game.quadrant)) {
skip(2);
- if (!induced) prout(_("Lucky you!"));
+ if (!induced)
+ prout(_("Lucky you!"));
proutn(_("A supernova in %s has just destroyed the last Klingons."),
cramlc(quadrant, nq));
finish(FWON);
return;
}
/* if some Klingons remain, continue or die in supernova */
proutn(_("A supernova in %s has just destroyed the last Klingons."),
cramlc(quadrant, nq));
finish(FWON);
return;
}
/* if some Klingons remain, continue or die in supernova */
- if (game.alldone) finish(FSNOVAED);
+ if (game.alldone)
+ finish(FSNOVAED);
void kaboom(void)
{
stars();
void kaboom(void)
{
stars();
- if (game.ship==IHE) prouts("***");
+ if (game.ship==IHE)
+ prouts("***");
prouts(_("********* Entropy of "));
crmshp();
prouts(_(" maximized *********"));
prouts(_("********* Entropy of "));
crmshp();
prouts(_(" maximized *********"));
double badpt;
badpt = 5.0*game.state.starkl + game.casual + 10.0*game.state.nplankl +
45.*game.nhelp+100.*game.state.basekl+3.*game.abandoned;
double badpt;
badpt = 5.0*game.state.starkl + game.casual + 10.0*game.state.nplankl +
45.*game.nhelp+100.*game.state.basekl+3.*game.abandoned;
- if (game.ship == IHF) badpt += 100.0;
- else if (game.ship == 0) badpt += 200.0;
- if (badpt < 100.0) badpt = 0.0; // Close enough!
+ if (game.ship == IHF)
+ badpt += 100.0;
+ else if (game.ship == 0)
+ badpt += 200.0;
+ if (badpt < 100.0)
+ badpt = 0.0; // Close enough!
if (game.state.date-game.indate < 5.0 ||
// killsPerDate >= RateMax
KLINGKILLED/(game.state.date-game.indate) >=
if (game.state.date-game.indate < 5.0 ||
// killsPerDate >= RateMax
KLINGKILLED/(game.state.date-game.indate) >=
prout(_("LIVE LONG AND PROSPER."));
}
score();
prout(_("LIVE LONG AND PROSPER."));
}
score();
+ if (igotit)
+ plaque();
return;
case FDEPLETE: // Federation Resources Depleted
prout(_("Your time has run out and the Federation has been"));
return;
case FDEPLETE: // Federation Resources Depleted
prout(_("Your time has run out and the Federation has been"));
prout(_("Your last crew member has died."));
break;
}
prout(_("Your last crew member has died."));
break;
}
- if (game.ship==IHF) game.ship= 0;
- else if (game.ship == IHE) game.ship = IHF;
+ if (game.ship==IHF)
+ game.ship= 0;
+ else if (game.ship == IHE)
+ game.ship = IHF;
game.alive = false;
if (KLINGREM != 0) {
double goodies = game.state.remres/game.inresor;
game.alive = false;
if (KLINGREM != 0) {
double goodies = game.state.remres/game.inresor;
int ithperd, iwon, klship;
iskill = game.skill;
int ithperd, iwon, klship;
iskill = game.skill;
- if ((timused == 0 || KLINGREM != 0) && timused < 5.0) timused = 5.0;
+ if ((timused == 0 || KLINGREM != 0) && timused < 5.0)
+ timused = 5.0;
perdate = KLINGKILLED/timused;
ithperd = 500*perdate + 0.5;
iwon = 0;
perdate = KLINGKILLED/timused;
ithperd = 500*perdate + 0.5;
iwon = 0;
- if (game.gamewon) iwon = 100*game.skill;
- if (game.ship == IHE) klship = 0;
- else if (game.ship == IHF) klship = 1;
- else klship = 2;
- if (!game.gamewon) game.state.nromrem = 0; // None captured if no win
+ if (game.gamewon)
+ iwon = 100*game.skill;
+ if (game.ship == IHE)
+ klship = 0;
+ else if (game.ship == IHF)
+ klship = 1;
+ else
+ klship = 2;
+ if (!game.gamewon)
+ game.state.nromrem = 0; // None captured if no win
iscore = 10*NKILLK + 50*NKILLC + ithperd + iwon
- 100*game.state.basekl - 100*klship - 45*game.nhelp -5*game.state.starkl - game.casual
+ 20*NKILLROM + 200*NKILLSC - 10*game.state.nplankl - 300*game.state.nworldkl + game.state.nromrem;
iscore = 10*NKILLK + 50*NKILLC + ithperd + iwon
- 100*game.state.basekl - 100*klship - 45*game.nhelp -5*game.state.starkl - game.casual
+ 20*NKILLROM + 200*NKILLSC - 10*game.state.nplankl - 300*game.state.nworldkl + game.state.nromrem;
- if (!game.alive) iscore -= 200;
+ if (!game.alive)
+ iscore -= 200;
skip(2);
prout(_("Your score --"));
if (NKILLROM)
skip(2);
prout(_("Your score --"));
if (NKILLROM)
char winner[128];
skip(2);
char winner[128];
skip(2);
while (fp == NULL) {
proutn(_("File or device name for your plaque: "));
cgetline(winner, sizeof(winner));
while (fp == NULL) {
proutn(_("File or device name for your plaque: "));
cgetline(winner, sizeof(winner));
*/
if (game.skill > SKILL_GOOD && game.klhere > 0 && !game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
attack(false);
*/
if (game.skill > SKILL_GOOD && game.klhere > 0 && !game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
attack(false);
- if (game.alldone) return;
+ if (game.alldone)
+ return;
}
/* compute final position -- new quadrant and sector */
x = QUADSIZE*(game.quadrant.x-1)+game.sector.x;
}
/* compute final position -- new quadrant and sector */
x = QUADSIZE*(game.quadrant.x-1)+game.sector.x;
w.y = (GALSIZE*QUADSIZE*2)+1 - w.y;
kink = 1;
}
w.y = (GALSIZE*QUADSIZE*2)+1 - w.y;
kink = 1;
}
} while (kink);
if (kinks) {
} while (kink);
if (kinks) {
prout(_("Entering %s."), cramlc(quadrant, game.quadrant));
game.quad[game.sector.x][game.sector.y] = game.ship;
newqad(false);
prout(_("Entering %s."), cramlc(quadrant, game.quadrant));
game.quad[game.sector.x][game.sector.y] = game.ship;
newqad(false);
- if (game.skill>SKILL_NOVICE) attack(false);
+ if (game.skill>SKILL_NOVICE)
+ attack(false);
return;
}
iquad = game.quad[w.x][w.y];
return;
}
iquad = game.quad[w.x][w.y];
return;
}
game.condition = docked;
return;
}
game.condition = docked;
- if (verbose) prout(_("Docked."));
+ if (verbose)
+ prout(_("Docked."));
- if (game.energy < game.inenrg) game.energy = game.inenrg;
+ if (game.energy < game.inenrg)
+ game.energy = game.inenrg;
game.shield = game.inshld;
game.torps = game.intorps;
game.lsupres = game.inlsr;
game.shield = game.inshld;
game.torps = game.intorps;
game.lsupres = game.inlsr;
cramlc(sector, incr));
}
}
cramlc(sector, incr));
}
}
- else prout(_("Ensign Chekov- \"Course laid in, Captain.\""));
+ else
+ prout(_("Ensign Chekov- \"Course laid in, Captain.\""));
}
deltax = icolq - game.quadrant.y + 0.1*(incr.x-game.sector.y);
deltay = game.quadrant.x - irowq + 0.1*(game.sector.x-incr.y);
}
deltax = icolq - game.quadrant.y + 0.1*(incr.x-game.sector.y);
deltay = game.quadrant.x - irowq + 0.1*(game.sector.x-incr.y);
}
game.dist = sqrt(deltax*deltax + deltay*deltay);
game.direc = atan2(deltax, deltay)*1.90985932;
}
game.dist = sqrt(deltax*deltax + deltay*deltay);
game.direc = atan2(deltax, deltay)*1.90985932;
- if (game.direc < 0.0) game.direc += 12.0;
+ if (game.direc < 0.0)
+ game.direc += 12.0;
if (game.energy > 30.0) {
getcd(false, 0);
if (game.energy > 30.0) {
getcd(false, 0);
- if (game.direc == -1.0) return;
+ if (game.direc == -1.0)
+ return;
power = 20.0 + 100.0*game.dist;
}
else
power = 20.0 + 100.0*game.dist;
}
else
prout(_("First Officer Spock- \"Captain, our speed under impulse"));
prout(_("power is only 0.95 sectors per stardate. Are you sure"));
proutn(_("we dare spend the time?\" "));
prout(_("First Officer Spock- \"Captain, our speed under impulse"));
prout(_("power is only 0.95 sectors per stardate. Are you sure"));
proutn(_("we dare spend the time?\" "));
- if (ja() == false) return;
+ if (ja() == false)
+ return;
}
/* Activate impulse engines and pay the cost */
imove(false);
game.ididit = true;
}
/* Activate impulse engines and pay the cost */
imove(false);
game.ididit = true;
- if (game.alldone) return;
+ if (game.alldone)
+ return;
power = 20.0 + 100.0*game.dist;
game.energy -= power;
game.optime = game.dist/0.095;
power = 20.0 + 100.0*game.dist;
game.energy -= power;
game.optime = game.dist/0.095;
- if (game.energy <= 0) finish(FNRG);
+ if (game.energy <= 0)
+ finish(FNRG);
/* Read in course and distance */
getcd(false, 0);
/* Read in course and distance */
getcd(false, 0);
- if (game.direc == -1.0) return;
+ if (game.direc == -1.0)
+ return;
/* Make sure starship has enough energy for the trip */
power = (game.dist+0.05)*game.warpfac*game.warpfac*game.warpfac*(game.shldup+1);
/* Make sure starship has enough energy for the trip */
power = (game.dist+0.05)*game.warpfac*game.warpfac*game.warpfac*(game.shldup+1);
game.dist = Rand()*game.dist;
}
/* Decide if time warp will occur */
game.dist = Rand()*game.dist;
}
/* Decide if time warp will occur */
- if (0.5*game.dist*pow(7.0,game.warpfac-10.0) > Rand()) twarp = true;
+ if (0.5*game.dist*pow(7.0,game.warpfac-10.0) > Rand())
+ twarp = true;
if (idebug && game.warpfac==10 && !twarp) {
blooey = false;
proutn("=== Force time warp? ");
if (idebug && game.warpfac==10 && !twarp) {
blooey = false;
proutn("=== Force time warp? ");
- if (ja() == true) twarp = true;
+ if (ja() == true)
+ twarp = true;
}
if (blooey || twarp) {
/* If time warp or engine damage, check path */
}
if (blooey || twarp) {
/* If time warp or engine damage, check path */
ix = x + 0.5;
y += deltay;
iy = y +0.5;
ix = x + 0.5;
y += deltay;
iy = y +0.5;
- if (!VALID_SECTOR(ix, iy)) break;
+ if (!VALID_SECTOR(ix, iy))
+ break;
if (game.quad[ix][iy] != IHDOT) {
blooey = false;
twarp = false;
if (game.quad[ix][iy] != IHDOT) {
blooey = false;
twarp = false;
/* Activate Warp Engines and pay the cost */
imove(false);
/* Activate Warp Engines and pay the cost */
imove(false);
- if (game.alldone) return;
+ if (game.alldone)
+ return;
game.energy -= game.dist*game.warpfac*game.warpfac*game.warpfac*(game.shldup+1);
game.energy -= game.dist*game.warpfac*game.warpfac*game.warpfac*(game.shldup+1);
- if (game.energy <= 0) finish(FNRG);
+ if (game.energy <= 0)
+ finish(FNRG);
game.optime = 10.0*game.dist/game.wfacsq;
game.optime = 10.0*game.dist/game.wfacsq;
if (blooey) {
game.damage[DWARPEN] = game.damfac*(3.0*Rand()+1.0);
skip(1);
if (blooey) {
game.damage[DWARPEN] = game.damfac*(3.0*Rand()+1.0);
skip(1);
/* Check to see if captain in shuttle craft */
/* Check to see if captain in shuttle craft */
- if (game.icraft) finish(FSTRACTOR);
- if (game.alldone) return;
+ if (game.icraft)
+ finish(FSTRACTOR);
+ if (game.alldone)
+ return;
/* Inform captain of attempt to reach safety */
skip(1);
/* Inform captain of attempt to reach safety */
skip(1);
power = 0.75*game.energy;
game.dist = power/(game.warpfac*game.warpfac*game.warpfac*(game.shldup+1));
distreq = 1.4142+Rand();
power = 0.75*game.energy;
game.dist = power/(game.warpfac*game.warpfac*game.warpfac*(game.shldup+1));
distreq = 1.4142+Rand();
- if (distreq < game.dist) game.dist = distreq;
+ if (distreq < game.dist)
+ game.dist = distreq;
game.optime = 10.0*game.dist/game.wfacsq;
game.direc = 12.0*Rand(); /* How dumb! */
game.justin = false;
game.optime = 10.0*game.dist/game.wfacsq;
game.direc = 12.0*Rand(); /* How dumb! */
game.justin = false;
warp(true);
if (!game.justin) {
/* This is bad news, we didn't leave quadrant. */
warp(true);
if (!game.justin) {
/* This is bad news, we didn't leave quadrant. */
- if (game.alldone) return;
+ if (game.alldone)
+ return;
skip(1);
prout(_("Insufficient energy to leave quadrant."));
finish(FSNOVAED);
skip(1);
prout(_("Insufficient energy to leave quadrant."));
finish(FSNOVAED);
/* next snapshot will be sooner */
schedule(FSNAP, expran(0.25*game.state.remtime));
/* next snapshot will be sooner */
schedule(FSNAP, expran(0.25*game.state.remtime));
- if (game.state.nscrem) schedule(FSCMOVE, 0.2777);
+ if (game.state.nscrem)
+ schedule(FSCMOVE, 0.2777);
game.isatb = 0;
unschedule(FCDBAS);
unschedule(FSCDBAS);
game.isatb = 0;
unschedule(FCDBAS);
unschedule(FSCDBAS);
/* slow mode, so let Kirk know how many probes there are left */
prout(game.nprobes==1 ? _("%d probe left.") : _("%d probes left."), game.nprobes);
proutn(_("Are you sure you want to fire a probe? "));
/* slow mode, so let Kirk know how many probes there are left */
prout(game.nprobes==1 ? _("%d probe left.") : _("%d probes left."), game.nprobes);
proutn(_("Are you sure you want to fire a probe? "));
- if (ja() == false) return;
+ if (ja() == false)
+ return;
game.isarmed = ja();
}
getcd(true, key);
game.isarmed = ja();
}
getcd(true, key);
- if (game.direc == -1.0) return;
+ if (game.direc == -1.0)
+ return;
game.nprobes--;
angle = ((15.0 - game.direc) * 0.5235988);
game.probeinx = -sin(angle);
game.nprobes--;
angle = ((15.0 - game.direc) * 0.5235988);
game.probeinx = -sin(angle);
}
textcolor(RED);
warble();
}
textcolor(RED);
warble();
- if (Rand() > probf) break;
+ if (Rand() > probf)
+ break;
prout(_("fails."));
delay(500);
textcolor(DEFAULT);
prout(_("fails."));
delay(500);
textcolor(DEFAULT);
prout(_("Starfleet puts you in command of another ship,"));
prout(_("the Faerie Queene, which is antiquated but,"));
prout(_("still useable."));
prout(_("Starfleet puts you in command of another ship,"));
prout(_("the Faerie Queene, which is antiquated but,"));
prout(_("still useable."));
- if (game.icrystl) prout(_("The dilithium crystals have been moved."));
+ if (game.icrystl)
+ prout(_("The dilithium crystals have been moved."));
game.imine = false;
game.iscraft = offship; /* Galileo disappears */
/* Resupply ship */
game.imine = false;
game.iscraft = offship; /* Galileo disappears */
/* Resupply ship */
proutn(_(" class "));
proutn(classes[game.state.plnets[i].pclass]);
proutn(" ");
proutn(_(" class "));
proutn(classes[game.state.plnets[i].pclass]);
proutn(" ");
- if (game.state.plnets[i].crystals != present) proutn(_("no "));
+ if (game.state.plnets[i].crystals != present)
+ proutn(_("no "));
prout(_("dilithium crystals present."));
if (game.state.plnets[i].known==shuttle_down)
prout(_(" Shuttle Craft Galileo on surface."));
}
}
prout(_("dilithium crystals present."));
if (game.state.plnets[i].known==shuttle_down)
prout(_(" Shuttle Craft Galileo on surface."));
}
}
- if (!iknow) prout(_("No information available."));
+ if (!iknow)
+ prout(_("No information available."));
game.optime = 0.02+0.03*Rand();
prout(_("Helmsman Sulu- \"Entering standard orbit, Sir.\""));
newcnd();
game.optime = 0.02+0.03*Rand();
prout(_("Helmsman Sulu- \"Entering standard orbit, Sir.\""));
newcnd();
- if (consumeTime()) return;
+ if (consumeTime())
+ return;
game.height = (1400.0+7200.0*Rand());
prout(_("Sulu- \"Entered orbit at altitude %.2f kilometers.\""), game.height);
game.inorbit = true;
game.height = (1400.0+7200.0*Rand());
prout(_("Sulu- \"Entered orbit at altitude %.2f kilometers.\""), game.height);
game.inorbit = true;
if (game.state.plnets[game.iplnet].known==shuttle_down)
prout(_(" Sensors show Galileo still on surface."));
proutn(_(" Readings indicate"));
if (game.state.plnets[game.iplnet].known==shuttle_down)
prout(_(" Sensors show Galileo still on surface."));
proutn(_(" Readings indicate"));
- if (game.state.plnets[game.iplnet].crystals != present) proutn(_(" no"));
+ if (game.state.plnets[game.iplnet].crystals != present)
+ proutn(_(" no"));
prout(_(" dilithium crystals present.\""));
prout(_(" dilithium crystals present.\""));
- if (game.state.plnets[game.iplnet].known == unknown) game.state.plnets[game.iplnet].known = known;
+ if (game.state.plnets[game.iplnet].known == unknown)
+ game.state.plnets[game.iplnet].known = known;
if (!damaged(DSHUTTL) && (game.state.plnets[game.iplnet].known==shuttle_down || game.iscraft == onship)) {
skip(1);
proutn(_("Spock- \"May I suggest the shuttle craft, Sir?\" "));
if (!damaged(DSHUTTL) && (game.state.plnets[game.iplnet].known==shuttle_down || game.iscraft == onship)) {
skip(1);
proutn(_("Spock- \"May I suggest the shuttle craft, Sir?\" "));
- if (ja() == true) shuttle();
+ if (ja() == true)
+ shuttle();
return;
}
game.optime = (0.1+0.2*Rand())*game.state.plnets[game.iplnet].pclass;
return;
}
game.optime = (0.1+0.2*Rand())*game.state.plnets[game.iplnet].pclass;
- if (consumeTime()) return;
+ if (consumeTime())
+ return;
prout(_("Mining operation complete."));
game.state.plnets[game.iplnet].crystals = mined;
game.imine = game.ididit = true;
prout(_("Mining operation complete."));
game.state.plnets[game.iplnet].crystals = mined;
game.imine = game.ididit = true;
prout(_(" boards Galileo and swoops toward planet surface."));
game.iscraft = offship;
skip(1);
prout(_(" boards Galileo and swoops toward planet surface."));
game.iscraft = offship;
skip(1);
- if (consumeTime()) return;
+ if (consumeTime())
+ return;
game.state.plnets[game.iplnet].known=shuttle_down;
prout(_("Trip complete."));
return;
game.state.plnets[game.iplnet].known=shuttle_down;
prout(_("Trip complete."));
return;
game.icraft = true;
skip(1);
game.landed = false;
game.icraft = true;
skip(1);
game.landed = false;
- if (consumeTime()) return;
+ if (consumeTime())
+ return;
game.iscraft = onship;
game.icraft = false;
if (game.imine) {
game.iscraft = onship;
game.icraft = false;
if (game.imine) {
skip(1);
game.icraft = true;
game.iscraft = offship;
skip(1);
game.icraft = true;
game.iscraft = offship;
- if (consumeTime()) return;
+ if (consumeTime())
+ return;
game.state.plnets[game.iplnet].known = shuttle_down;
game.landed = true;
game.icraft = false;
game.state.plnets[game.iplnet].known = shuttle_down;
game.landed = true;
game.icraft = false;
prout(_("Spock- \"Captain, the 'Experimental Death Ray'"));
prout(_(" is highly unpredictible. Considering the alternatives,"));
proutn(_(" are you sure this is wise?\" "));
prout(_("Spock- \"Captain, the 'Experimental Death Ray'"));
prout(_(" is highly unpredictible. Considering the alternatives,"));
proutn(_(" are you sure this is wise?\" "));
- if (ja() == false) return;
+ if (ja() == false)
+ return;
prout(_("Spock- \"Acknowledged.\""));
skip(1);
game.ididit = true;
prout(_("Spock- \"Acknowledged.\""));
skip(1);
game.ididit = true;
while (game.nenhere > 0)
deadkl(game.ks[1], game.quad[game.ks[1].x][game.ks[1].y],game.ks[1]);
prout(_("Ensign Chekov- \"Congratulations, Captain!\""));
while (game.nenhere > 0)
deadkl(game.ks[1], game.quad[game.ks[1].x][game.ks[1].y],game.ks[1]);
prout(_("Ensign Chekov- \"Congratulations, Captain!\""));
- if (KLINGREM == 0) finish(FWON);
+ if (KLINGREM == 0)
+ finish(FWON);
if ((game.options & OPTION_PLAIN) == 0) {
prout(_("Spock- \"Captain, I believe the `Experimental Death Ray'"));
if (Rand() <= 0.05) {
if ((game.options & OPTION_PLAIN) == 0) {
prout(_("Spock- \"Captain, I believe the `Experimental Death Ray'"));
if (Rand() <= 0.05) {
prout(_(" Mr. Sulu."));
for_sectors(i)
for_sectors(j)
prout(_(" Mr. Sulu."));
for_sectors(i)
for_sectors(j)
- if (game.quad[i][j] == IHDOT) game.quad[i][j] = IHQUEST;
+ if (game.quad[i][j] == IHDOT)
+ game.quad[i][j] = IHQUEST;
prout(_(" Captain, our quadrant is now infested with"));
prouts(_(" - - - - - - *THINGS*."));
skip(1);
prout(_(" Captain, our quadrant is now infested with"));
prouts(_(" - - - - - - *THINGS*."));
skip(1);
skip(1);
prout(_("You %s a %s%s %s game."),
game.alldone? _("were playing") : _("are playing"), s1, s2, s3);
skip(1);
prout(_("You %s a %s%s %s game."),
game.alldone? _("were playing") : _("are playing"), s1, s2, s3);
- if (game.skill>SKILL_GOOD && game.thawed && !game.alldone) prout(_("No plaque is allowed."));
- if (game.tourn) prout(_("This is tournament game %d."), game.tourn);
+ if (game.skill>SKILL_GOOD && game.thawed && !game.alldone)
+ prout(_("No plaque is allowed."));
+ if (game.tourn)
+ prout(_("This is tournament game %d."), game.tourn);
prout(_("Your secret password is \"%s\""),game.passwd);
proutn(_("%d of %d Klingons have been killed"), KLINGKILLED, INKLINGTOT);
prout(_("Your secret password is \"%s\""),game.passwd);
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 (game.skill > SKILL_FAIR) prout(_("The Super Commander has %sbeen destroyed."),
- game.state.nscrem?_("not "):"");
+ if (NKILLC)
+ prout(_(", including %d Commander%s."), NKILLC, NKILLC==1?"":_("s"));
+ else if (NKILLK + NKILLSC > 0)
+ prout(_(", but no Commanders."));
+ else
+ prout(".");
+ if (game.skill > SKILL_FAIR)
+ prout(_("The Super Commander has %sbeen destroyed."),
+ game.state.nscrem?_("not "):"");
if (game.state.rembase != game.inbase) {
proutn(_("There "));
if (game.state.rembase != game.inbase) {
proutn(_("There "));
- if (game.inbase-game.state.rembase==1) proutn(_("has been 1 base"));
+ if (game.inbase-game.state.rembase==1)
+ proutn(_("has been 1 base"));
else {
proutn(_("have been %d bases"), game.inbase-game.state.rembase);
}
prout(_(" destroyed, %d remaining."), game.state.rembase);
}
else {
proutn(_("have been %d bases"), game.inbase-game.state.rembase);
}
prout(_(" destroyed, %d remaining."), game.state.rembase);
}
- else prout(_("There are %d bases."), game.inbase);
+ else
+ prout(_("There are %d bases."), game.inbase);
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);
game.iseenit = true;
}
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);
game.iseenit = true;
}
- if (game.casual) prout(_("%d casualt%s suffered so far."),
- game.casual, game.casual==1? "y" : "ies");
- if (game.nhelp) prout(_("There were %d call%s for help."),
- game.nhelp, game.nhelp==1 ? "" : _("s"));
+ if (game.casual)
+ prout(_("%d casualt%s suffered so far."),
+ game.casual, game.casual==1? "y" : "ies");
+ if (game.nhelp)
+ prout(_("There were %d call%s for help."),
+ game.nhelp, game.nhelp==1 ? "" : _("s"));
if (game.ship == IHE) {
proutn(_("You have "));
if (game.ship == IHE) {
proutn(_("You have "));
- if (game.nprobes) proutn("%d", game.nprobes);
- else proutn(_("no"));
+ if (game.nprobes)
+ proutn("%d", game.nprobes);
+ else
+ proutn(_("no"));
proutn(_(" deep space probe"));
proutn(_(" deep space probe"));
- if (game.nprobes!=1) proutn(_("s"));
+ if (game.nprobes!=1)
+ proutn(_("s"));
prout(".");
}
if ((!damaged(DRADIO) || game.condition == docked)
prout(".");
}
if ((!damaged(DRADIO) || game.condition == docked)
game.docfac*game.damage[i]+0.005);
}
}
game.docfac*game.damage[i]+0.005);
}
}
- if (!jdam) prout(_("All devices functional."));
+ if (!jdam)
+ prout(_("All devices functional."));
proutn(" ");
}
proutn(" |");
proutn(" ");
}
proutn(" |");
- if (i<GALSIZE) skip(1);
+ if (i<GALSIZE)
+ skip(1);
- if (game.condition != docked) newcnd();
+ if (game.condition != docked)
+ newcnd();
switch (game.condition) {
case red: cp = _("RED"); break;
case green: cp = _("GREEN"); break;
switch (game.condition) {
case red: cp = _("RED"); break;
case green: cp = _("GREEN"); break;
else
prout(_(" [Using Base's sensors]"));
}
else
prout(_(" [Using Base's sensors]"));
}
- else prout(_(" Short-range scan"));
+ else
+ prout(_(" Short-range scan"));
if (goodScan && !damaged(DRADIO)) {
game.state.chart[game.quadrant.x][game.quadrant.y].klingons = game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons;
game.state.chart[game.quadrant.x][game.quadrant.y].starbase = game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase;
if (goodScan && !damaged(DRADIO)) {
game.state.chart[game.quadrant.x][game.quadrant.y].klingons = game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons;
game.state.chart[game.quadrant.x][game.quadrant.y].starbase = game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase;
game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true;
}
prout(" 1 2 3 4 5 6 7 8 9 10");
game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true;
}
prout(" 1 2 3 4 5 6 7 8 9 10");
- if (game.condition != docked) newcnd();
+ if (game.condition != docked)
+ newcnd();
for (i = 1; i <= QUADSIZE; i++) {
proutn("%2d ", i);
for_sectors(j) {
for (i = 1; i <= QUADSIZE; i++) {
proutn("%2d ", i);
for_sectors(j) {
w2.x = aaitem + 0.5;
}
else {
w2.x = aaitem + 0.5;
}
else {
- if (game.quadrant.y>w1.x) w2.x = 1;
- else w2.x=QUADSIZE;
- if (game.quadrant.x>w1.y) w2.y = 1;
- else w2.y=QUADSIZE;
+ if (game.quadrant.y>w1.x)
+ w2.x = 1;
+ else
+ w2.x=QUADSIZE;
+ if (game.quadrant.x>w1.y)
+ w2.y = 1;
+ else
+ w2.y=QUADSIZE;
}
if (!VALID_QUADRANT(w1.x, w1.y) || !VALID_SECTOR(w2.x, w2.y)) {
}
if (!VALID_QUADRANT(w1.x, w1.y) || !VALID_SECTOR(w2.x, w2.y)) {
square(w1.x-game.quadrant.x+0.1*(w2.x-game.sector.x)));
wfl = false;
square(w1.x-game.quadrant.x+0.1*(w2.x-game.sector.x)));
wfl = false;
- if (prompt) prout(_("Answer \"no\" if you don't know the value:"));
+ if (prompt)
+ prout(_("Answer \"no\" if you don't know the value:"));
for (;;) {
chew();
proutn(_("Time or arrival date? "));
for (;;) {
chew();
proutn(_("Time or arrival date? "));
- if (twarp < 1.0) twarp = 1.0;
+ if (twarp < 1.0)
+ twarp = 1.0;
if (tpower >= game.energy) {
prout(_("Insufficient energy, sir."));
if (!game.shldup || tpower > game.energy*2.0) {
if (tpower >= game.energy) {
prout(_("Insufficient energy, sir."));
if (!game.shldup || tpower > game.energy*2.0) {
proutn(_("New warp factor to try? "));
if (scan() == IHREAL) {
wfl = true;
proutn(_("New warp factor to try? "));
if (scan() == IHREAL) {
wfl = true;
do {
double r = Rand();
int klump = (1.0 - r*r)*klumper;
do {
double r = Rand();
int klump = (1.0 - r*r)*klumper;
- if (klump > krem) klump = krem;
+ if (klump > krem)
+ klump = krem;
krem -= klump;
do w = randplace(GALSIZE);
while (game.state.galaxy[w.x][w.y].supernova ||
krem -= klump;
do w = randplace(GALSIZE);
while (game.state.galaxy[w.x][w.y].supernova ||
skip(1);
prout(_("%d Klingons."), INKLINGTOT);
prout(_("An unknown number of Romulans."));
skip(1);
prout(_("%d Klingons."), INKLINGTOT);
prout(_("An unknown number of Romulans."));
- if (game.state.nscrem) prout(_("And one (GULP) Super-Commander."));
+ if (game.state.nscrem)
+ prout(_("And one (GULP) Super-Commander."));
prout(_("%d stardates."),(int)game.intime);
proutn(_("%d starbases in "), game.inbase);
}
prout(_("%d stardates."),(int)game.intime);
proutn(_("%d starbases in "), game.inbase);
}
proutn(cramlc(sector, game.sector));
skip(2);
prout(_("Good Luck!"));
proutn(cramlc(sector, game.sector));
skip(2);
prout(_("Good Luck!"));
- if (game.state.nscrem) prout(_(" YOU'LL NEED IT."));
+ if (game.state.nscrem)
+ prout(_(" YOU'LL NEED IT."));
waitfor();
newqad(false);
waitfor();
newqad(false);
- if (game.nenhere-iqhere-game.ithere) game.shldup = true;
- if (game.neutz) attack(false); // bad luck to start in a Romulan Neutral Zone
+ if (game.nenhere-iqhere-game.ithere)
+ game.shldup = true;
+ if (game.neutz) // bad luck to start in a Romulan Neutral Zone
+ attack(false);
}
bool choose(bool needprompt)
}
bool choose(bool needprompt)
break;
}
if (isit("saved") || isit("frozen")) {
break;
}
if (isit("saved") || isit("frozen")) {
+ if (thaw())
+ continue;
- if (*game.passwd==0) continue;
- if (!game.alldone) game.thawed = 1; // No plaque if not finished
+ if (*game.passwd==0)
+ continue;
+ if (!game.alldone)
+ game.thawed = true; // No plaque if not finished
report();
waitfor();
return true;
}
report();
waitfor();
return true;
}
- if (isit("regular")) break;
+ if (isit("regular"))
+ break;
proutn(_("What is \""));
proutn(citem);
prout("\"?");
proutn(_("What is \""));
proutn(citem);
prout("\"?");
}
while (game.length==0 || game.skill==SKILL_NONE) {
if (scan() == IHALPHA) {
}
while (game.length==0 || game.skill==SKILL_NONE) {
if (scan() == IHALPHA) {
- if (isit("short")) game.length = 1;
- else if (isit("medium")) game.length = 2;
- else if (isit("long")) game.length = 4;
- else if (isit("novice")) game.skill = SKILL_NOVICE;
- else if (isit("fair")) game.skill = SKILL_FAIR;
- else if (isit("good")) game.skill = SKILL_GOOD;
- else if (isit("expert")) game.skill = SKILL_EXPERT;
- else if (isit("emeritus")) game.skill = SKILL_EMERITUS;
+ if (isit("short"))
+ game.length = 1;
+ else if (isit("medium"))
+ game.length = 2;
+ else if (isit("long"))
+ game.length = 4;
+ else if (isit("novice"))
+ game.skill = SKILL_NOVICE;
+ else if (isit("fair"))
+ game.skill = SKILL_FAIR;
+ else if (isit("good"))
+ game.skill = SKILL_GOOD;
+ else if (isit("expert"))
+ game.skill = SKILL_EXPERT;
+ else if (isit("emeritus"))
+ game.skill = SKILL_EMERITUS;
else {
proutn(_("What is \""));
proutn(citem);
else {
proutn(_("What is \""));
proutn(citem);
- if (game.length==0) proutn(_("Would you like a Short, Medium, or Long game? "));
- else if (game.skill == SKILL_NONE) proutn(_("Are you a Novice, Fair, Good, Expert, or Emeritus player? "));
+ if (game.length==0)
+ proutn(_("Would you like a Short, Medium, or Long game? "));
+ else if (game.skill == SKILL_NONE)
+ proutn(_("Are you a Novice, Fair, Good, Expert, or Emeritus player? "));
}
}
// Choose game options -- added by ESR for SST2K
}
}
// Choose game options -- added by ESR for SST2K
/* update our alert status */
{
game.condition = green;
/* update our alert status */
{
game.condition = green;
- if (game.energy < 1000.0) game.condition = yellow;
+ 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.condition = red;
if (game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons || game.state.galaxy[game.quadrant.x][game.quadrant.y].romulans)
game.condition = red;
- if (!game.alive) game.condition=dead;
+ if (!game.alive)
+ game.condition=dead;
distance(game.sector, game.tholian);
game.kpower[game.nenhere] = Rand()*400.0 +100.0 +25.0*game.skill;
/* Reserve unocupied corners */
distance(game.sector, game.tholian);
game.kpower[game.nenhere] = Rand()*400.0 +100.0 +25.0*game.skill;
/* Reserve unocupied corners */
- if (game.quad[1][1]==IHDOT) game.quad[1][1] = 'X';
- if (game.quad[1][QUADSIZE]==IHDOT) game.quad[1][QUADSIZE] = 'X';
- if (game.quad[QUADSIZE][1]==IHDOT) game.quad[QUADSIZE][1] = 'X';
- if (game.quad[QUADSIZE][QUADSIZE]==IHDOT) game.quad[QUADSIZE][QUADSIZE] = 'X';
+ if (game.quad[1][1]==IHDOT)
+ game.quad[1][1] = 'X';
+ if (game.quad[1][QUADSIZE]==IHDOT)
+ game.quad[1][QUADSIZE] = 'X';
+ if (game.quad[QUADSIZE][1]==IHDOT)
+ game.quad[QUADSIZE][1] = 'X';
+ if (game.quad[QUADSIZE][QUADSIZE]==IHDOT)
+ game.quad[QUADSIZE][QUADSIZE] = 'X';
// Take out X's in corners if Tholian present
if (game.ithere) {
// Take out X's in corners if Tholian present
if (game.ithere) {
- if (game.quad[1][1]=='X') game.quad[1][1] = IHDOT;
- if (game.quad[1][QUADSIZE]=='X') game.quad[1][QUADSIZE] = IHDOT;
- if (game.quad[QUADSIZE][1]=='X') game.quad[QUADSIZE][1] = IHDOT;
- if (game.quad[QUADSIZE][QUADSIZE]=='X') game.quad[QUADSIZE][QUADSIZE] = IHDOT;
+ if (game.quad[1][1]=='X')
+ game.quad[1][1] = IHDOT;
+ if (game.quad[1][QUADSIZE]=='X')
+ game.quad[1][QUADSIZE] = IHDOT;
+ if (game.quad[QUADSIZE][1]=='X')
+ game.quad[QUADSIZE][1] = IHDOT;
+ if (game.quad[QUADSIZE][QUADSIZE]=='X')
+ game.quad[QUADSIZE][QUADSIZE] = IHDOT;
// The author liked bubble sort. So we will use it. :-(
// The author liked bubble sort. So we will use it. :-(
- if (game.nenhere-iqhere-game.ithere < 2) return;
+ if (game.nenhere-iqhere-game.ithere < 2)
+ return;
proutn(_("Please type in a secret password- "));
scan();
strcpy(game.passwd, citem);
proutn(_("Please type in a secret password- "));
scan();
strcpy(game.passwd, citem);
- if (*game.passwd != 0) break;
+ if (*game.passwd != 0)
+ break;
- for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));
+ for(i=0;i<3;i++)
+ game.passwd[i]=(char)(97+(int)(Rand()*25));
key = scan();
}
setwnd(message_window);
key = scan();
}
setwnd(message_window);
- if (key == IHEOL) return;
+ if (key == IHEOL)
+ return;
for (i = 0; i < NUMCOMMANDS; i++) {
if (ACCEPT(i) && strcasecmp(commands[i].name, citem)==0) {
i = commands[i].value;
break;
}
}
for (i = 0; i < NUMCOMMANDS; i++) {
if (ACCEPT(i) && strcasecmp(commands[i].name, citem)==0) {
i = commands[i].value;
break;
}
}
- if (i != NUMCOMMANDS) break;
+ if (i != NUMCOMMANDS)
+ break;
skip(1);
listCommands();
key = IHEOL;
skip(1);
listCommands();
key = IHEOL;
break;
case PHASERS: // phasers
phasers();
break;
case PHASERS: // phasers
phasers();
- if (game.ididit) hitme = true;
+ if (game.ididit)
+ hitme = true;
break;
case TORPEDO: // photons
photon();
break;
case TORPEDO: // photons
photon();
- if (game.ididit) hitme = true;
+ if (game.ididit)
+ hitme = true;
break;
case MOVE: // move
warp(false);
break;
case MOVE: // move
warp(false);
break;
case DOCK: // dock
dock(true);
break;
case DOCK: // dock
dock(true);
- if (game.ididit) attack(false);
+ if (game.ididit)
+ attack(false);
break;
case DAMAGES: // damages
dreprt();
break;
case DAMAGES: // damages
dreprt();
break;
case REST: // rest
wait();
break;
case REST: // rest
wait();
- if (game.ididit) hitme = true;
+ if (game.ididit)
+ hitme = true;
break;
case WARP: // warp
setwrp();
break;
case WARP: // warp
setwrp();
break;
case ORBIT: // orbit
orbit();
break;
case ORBIT: // orbit
orbit();
- if (game.ididit) hitme = true;
+ if (game.ididit)
+ hitme = true;
break;
case TRANSPORT: // transport "beam"
beam();
break;
case MINE: // mine
mine();
break;
case TRANSPORT: // transport "beam"
beam();
break;
case MINE: // mine
mine();
- if (game.ididit) hitme = true;
+ if (game.ididit)
+ hitme = true;
break;
case CRYSTALS: // crystals
usecrystals();
break;
case CRYSTALS: // crystals
usecrystals();
- if (game.ididit) hitme = true;
+ if (game.ididit)
+ hitme = true;
break;
case SHUTTLE: // shuttle
shuttle();
break;
case SHUTTLE: // shuttle
shuttle();
- if (game.ididit) hitme = true;
+ if (game.ididit)
+ hitme = true;
break;
case PLANETS: // Planet list
preport();
break;
case PLANETS: // Planet list
preport();
break;
case PROBE:
probe(); // Launch probe
break;
case PROBE:
probe(); // Launch probe
- if (game.ididit) hitme = true;
+ if (game.ididit)
+ hitme = true;
break;
case ABANDON: // Abandon Ship
abandn();
break;
case ABANDON: // Abandon Ship
abandn();
break;
case DEATHRAY: // Try a desparation measure
deathray();
break;
case DEATHRAY: // Try a desparation measure
deathray();
- if (game.ididit) hitme = true;
+ if (game.ididit)
+ hitme = true;
break;
case DEBUGCMD: // What do we want for debug???
debugme();
break;
case MAYDAY: // Call for help
mayday();
break;
case DEBUGCMD: // What do we want for debug???
debugme();
break;
case MAYDAY: // Call for help
mayday();
- if (game.ididit) hitme = true;
+ if (game.ididit)
+ hitme = true;
break;
case QUIT:
game.alldone = true; // quit the game
break;
case QUIT:
game.alldone = true; // quit the game
}
if (hitme && !game.justin) {
attack(true);
}
if (hitme && !game.justin) {
attack(true);
- if (game.alldone) break;
+ if (game.alldone)
+ break;
if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) { // went NOVA!
atover(false);
hitme = true;
if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) { // went NOVA!
atover(false);
hitme = true;
- if (game.alldone) break;
+ if (game.alldone)
+ break;
- if (idebug) prout("=== Ending");
+ if (idebug)
+ prout("=== Ending");
replayfp = fopen(optarg, "r");
if (replayfp == NULL) {
fprintf(stderr, "sst: can't open replay file %s\n", optarg);
replayfp = fopen(optarg, "r");
if (replayfp == NULL) {
fprintf(stderr, "sst: can't open replay file %s\n", optarg);
}
if (fscanf(replayfp, "seed %d\n", &seed) != 1) {
fprintf(stderr, "sst: replay file %s is ill-formed\n", optarg);
}
if (fscanf(replayfp, "seed %d\n", &seed) != 1) {
fprintf(stderr, "sst: replay file %s is ill-formed\n", optarg);
}
/* FALL THROUGH */
case 't':
}
/* FALL THROUGH */
case 't':
score();
game.alldone = false;
}
score();
game.alldone = false;
}
skip(1);
stars();
skip(1);
skip(1);
stars();
skip(1);
}
}
proutn(_("Do you want to play again? "));
}
}
proutn(_("Do you want to play again? "));
}
skip(1);
prout(_("May the Great Bird of the Galaxy roost upon your home planet."));
}
skip(1);
prout(_("May the Great Bird of the Galaxy roost upon your home planet."));
{
static char buf[32];
buf[0] = '\0';
{
static char buf[32];
buf[0] = '\0';
- if (key == quadrant) strcpy(buf, _("Quadrant "));
- else if (key == sector) strcpy(buf, _("Sector "));
+ if (key == quadrant)
+ strcpy(buf, _("Quadrant "));
+ else if (key == sector)
+ strcpy(buf, _("Sector "));
sprintf(buf+strlen(buf), "%d - %d", w.x, w.y);
return buf;
}
sprintf(buf+strlen(buf), "%d - %d", w.x, w.y);
return buf;
}
void crmena(bool stars, feature enemy, enum loctype key, coord w)
/* print an enemy and his location */
{
void crmena(bool stars, feature enemy, enum loctype key, coord w)
/* print an enemy and his location */
{
- if (stars) proutn("***");
+ if (stars)
+ proutn("***");
cramen(enemy);
proutn(_(" at "));
proutn(cramlc(key, w));
cramen(enemy);
proutn(_(" at "));
proutn(cramlc(key, w));
// Treat as alpha
cp = citem;
while (*linep && *linep!=' ') {
// Treat as alpha
cp = citem;
while (*linep && *linep!=' ') {
- if ((cp - citem) < 9) *cp++ = tolower(*linep);
+ if ((cp - citem) < 9)
+ *cp++ = tolower(*linep);
for(;;) {
scan();
chew();
for(;;) {
scan();
chew();
- if (*citem == 'y') return true;
- if (*citem == 'n') return false;
+ if (*citem == 'y')
+ return true;
+ if (*citem == 'n')
+ return false;
proutn(_("Please answer with \"y\" or \"n\": "));
}
}
proutn(_("Please answer with \"y\" or \"n\": "));
}
}
{
proutn("Reset levels? ");
if (ja() == true) {
{
proutn("Reset levels? ");
if (ja() == true) {
- if (game.energy < game.inenrg) game.energy = game.inenrg;
+ if (game.energy < game.inenrg)
+ game.energy = game.inenrg;
game.shield = game.inshld;
game.torps = game.intorps;
game.lsupres = game.inlsr;
game.shield = game.inshld;
game.torps = game.intorps;
game.lsupres = game.inlsr;
proutn("Toggle debug flag? ");
if (ja() == true) {
idebug = !idebug;
proutn("Toggle debug flag? ");
if (ja() == true) {
idebug = !idebug;
- if (idebug) prout("Debug output ON");
- else prout("Debug output OFF");
+ if (idebug)
+ prout("Debug output ON");
+ else
+ prout("Debug output OFF");
}
proutn("Cause selective damage? ");
if (ja() == true) {
}
proutn("Cause selective damage? ");
if (ja() == true) {
Note that the game.quad, game.snap.galaxy and game.snap.chart members
are not actually arrays but dictioaries indixed by coord tuples. Be setting
Note that the game.quad, game.snap.galaxy and game.snap.chart members
are not actually arrays but dictioaries indixed by coord tuples. Be setting
-the hash of a coord exual to the hash of a literal tuple containing its
+the hash of a coord equal to the hash of a literal tuple containing its
coordinate data, we ensure these can be indexed both ways.
"""
coordinate data, we ensure these can be indexed both ways.
"""
return "%d - %d" % (self.x, self.y)
class feature:
return "%d - %d" % (self.x, self.y)
class feature:
- "A feature in the current quadrant (ship, star, black hole, etc)."
+ "A feature in the current quadrant (ship, star, black hole, base, etc)."
def __init__(self):
self.type = None # name of feature type
self.sector = None # sector location
def distance(self):
return self.sector.distance(game.sector)
def __str__(self):
def __init__(self):
self.type = None # name of feature type
self.sector = None # sector location
def distance(self):
return self.sector.distance(game.sector)
def __str__(self):
+ "This will be overridden by subclasses."
return self.name[0]
def sectormove(self, dest):
"Move this feature within the current quadrant."
return self.name[0]
def sectormove(self, dest):
"Move this feature within the current quadrant."
game.quad[dest] = self
self.sector = dest
game.quad[dest] = self
self.sector = dest
-empty = None # Value of empty space in game.quad
-
- "An enemy ship in the current quadrant."
- def __init__(self):
+ "A starship, frindly or enemy."
+ def __init__(self, type, power):
- self.type = None # klingon, romulan, commander,
- # supercommander, tholian
- self.power = None # power
+ self.type = type # klingon, romulan, commander,
+ # supercommander, tholian,
+ # enterprise, faerie queene.
+ self.power = power # power
if self.type in ("Klingon", "Commander", "Super-Commander"):
game.remkl += 1
elif self.type == "Romulan":
if self.type in ("Klingon", "Commander", "Super-Commander"):
game.remkl += 1
elif self.type == "Romulan":
elif self.type == "Romulan":
game.romrem -= 1
elif self.type == "Romulan":
game.romrem -= 1
+class space(feature):
+ "Empty space. Has no state, just knows how to identify iself."
+ def __str__(self):
+ return '*'
+
+class star(feature):
+ "A star. Has no state, just knows how to identify iself."
+ def __str__(self):
+ return '*'
+
class planet(feature):
"A planet. May be inhabited or not, may hold dilithium crystals or not."
def __init(self):
class planet(feature):
"A planet. May be inhabited or not, may hold dilithium crystals or not."
def __init(self):
self.crystals = None # "absent", "present", or "mined"
self.inhabited = False
self.known = "unknown" # Other values: "known" and "shuttle down"
self.crystals = None # "absent", "present", or "mined"
self.inhabited = False
self.known = "unknown" # Other values: "known" and "shuttle down"
+ game.state.planets.append(self)
+ def __del__(self):
+ game.state.planets.remove(self)
def __str__(self):
if self.inhabited:
return '@'
else:
return 'P'
def __str__(self):
if self.inhabited:
return '@'
else:
return 'P'
-class star(feature):
- "A star. Has no state, just knows how to identify iself."
- def __init(self):
- feature.__init__(self)
- def __str__(self):
- return '*'
-
class web(feature):
"A bit of Tholian web. Has no state, just knows how to identify iself."
class web(feature):
"A bit of Tholian web. Has no state, just knows how to identify iself."
- def __init(self):
- feature.__init__(self)
def __str__(self):
return '*'
class blackhole(feature):
"A black hole. Has no hair, just knows how to identify iself."
def __str__(self):
return '*'
class blackhole(feature):
"A black hole. Has no hair, just knows how to identify iself."
- def __init(self):
- feature.__init__(self)
class starbase(feature):
"Starbases also have no features, just a location."
class starbase(feature):
"Starbases also have no features, just a location."
game.state.bases.remove(self)
def __str__(self):
return 'B'
game.state.bases.remove(self)
def __str__(self):
return 'B'
- def __del__(self):
- feature.__del__(self)
class quadrant:
def __init__(self):
class quadrant:
def __init__(self):
self.starkl = None # destroyed stars
self.basekl = None # destroyed bases
self.nromrem = None # Romulans remaining
self.starkl = None # destroyed stars
self.basekl = None # destroyed bases
self.nromrem = None # Romulans remaining
- self.nplankl = None # destroyed uninhabited planets
- self.nworldkl = None # destroyed inhabited planets
- self.plnets = []; # List of planets known
+ self.nplankl = None # destroyed uninhabited planets self.nworldkl = None # destroyed inhabited planets
+ self.planets = []; # List of planets known
self.date = None # stardate
self.remres = None # remaining resources
self. remtime = None # remaining time
self.date = None # stardate
self.remres = None # remaining resources
self. remtime = None # remaining time
game.state.kscmdr = iq
game.state.galaxy[game.state.kscmdr].klingons += 1
# check for a helpful planet in the destination quadrant
game.state.kscmdr = iq
game.state.galaxy[game.state.kscmdr].klingons += 1
# check for a helpful planet in the destination quadrant
- for planet in game.state.plnets:
+ for planet in game.state.planets:
if planet.location == game.state.kscmdr and planet.crystals=="present":
# destroy the planet
if planet.location == game.state.kscmdr and planet.crystals=="present":
# destroy the planet
- game.state.plnets.remove(planet)
if communicating():
if not ipage:
pause_game(True)
if communicating():
if not ipage:
pause_game(True)
passive = ((NKILLC+NKILLK)/(game.state.date+0.01-game.indate) < 0.1*game.skill*(game.skill+1.0) \
or (game.state.date-game.indate) < 3.0)
if not game.iscate and passive:
passive = ((NKILLC+NKILLK)/(game.state.date+0.01-game.indate) < 0.1*game.skill*(game.skill+1.0) \
or (game.state.date-game.indate) < 3.0)
if not game.iscate and passive:
- # compute move away from Enterprise
- idelta = game.state.kscmdr - game.quadrant
+ # coxmpute move away from Enterprise
+ delta = game.state.kscmdr - game.quadrant
if distance(game.state.kscmdr) > 2.0:
# circulate in space
if distance(game.state.kscmdr) > 2.0:
# circulate in space
- idelta,x = game.state.kscmdr.y-game.quadrant.y
- idelta,y = game.quadrant.x-game.state.kscmdr.x
+ delta.x = game.state.kscmdr.y-game.quadrant.y
+ delta.y = game.quadrant.x-game.state.kscmdr.x
else:
if len(game.state.bases):
unschedule("FSCMOVE")
else:
if len(game.state.bases):
unschedule("FSCMOVE")
if len(nearest) == 0:
return # Nothing suitable -- wait until next time
# decide how to move toward base
if len(nearest) == 0:
return # Nothing suitable -- wait until next time
# decide how to move toward base
- idelta = ibq - game.state.kscmdr
+ delta = ibq - game.state.kscmdr
# maximum movement is 1 quadrant in either or both axis
delta = delta.sgn()
# try moving in both x and y directions
# maximum movement is 1 quadrant in either or both axis
delta = delta.sgn()
# try moving in both x and y directions
- iq = game.state.kscmdr + idelta
+ iq = game.state.kscmdr + delta
if movescom(iq, passive):
# failed -- try some other maneuvers
if movescom(iq, passive):
# failed -- try some other maneuvers
- if ideltax==0 or ideltay==0:
+ if delta.x==0 or delta.y==0:
iq.y = game.state.kscmdr.y + 1
if movescom(iq, passive):
iq.y = game.state.kscmdr.y - 1
iq.y = game.state.kscmdr.y + 1
if movescom(iq, passive):
iq.y = game.state.kscmdr.y - 1
# try moving just in x or y
iq.y = game.state.kscmdr.y
if movescom(iq, passive):
# try moving just in x or y
iq.y = game.state.kscmdr.y
if movescom(iq, passive):
- iq.y = game.state.kscmdr.y + ideltay
+ iq.y = game.state.kscmdr.y + delta.y
iq.x = game.state.kscmdr.x
movescom(iq, passive)
# check for a base
iq.x = game.state.kscmdr.x
movescom(iq, passive)
# check for a base
game.tholian = None
return
# Do nothing if we are blocked
game.tholian = None
return
# Do nothing if we are blocked
- if game.quad[next] != empty and not isinstance(game.quad[next]. web):
+ if not (isinstance(game.quad[next], space) or isinstance(game.quad[next], web)):
return
# Now place some web
im = (next - game.tholian.location).sgn()
return
# Now place some web
im = (next - game.tholian.location).sgn()
# move in x axis
while game.tholian.location.x != next.x:
game.tholian.location.x += im.x
# move in x axis
while game.tholian.location.x != next.x:
game.tholian.location.x += im.x
- if game.quad[game.tholian.location] == empty:
+ if isinstance(game.quad[game.tholian.location], space):
game.quad[game.tholian.location] = web()
elif game.tholian.y != next.y:
# move in y axis
while game.tholian.y != next.y:
game.tholian.y += im.y
game.quad[game.tholian.location] = web()
elif game.tholian.y != next.y:
# move in y axis
while game.tholian.y != next.y:
game.tholian.y += im.y
- if game.quad[game.tholian.location] == empty:
+ if isinstance(game.quad[game.tholian.location], space):
game.quad[game.tholian.location] = web()
# web is done, move ship
game.tholian.movesector(next)
game.quad[game.tholian.location] = web()
# web is done, move ship
game.tholian.movesector(next)
void sound(unsigned int freq)
{
#ifdef HAVE_LINUX_KD_H
void sound(unsigned int freq)
{
#ifdef HAVE_LINUX_KD_H
- if(fd==0) fd=open("/dev/console", O_RDONLY);
- if(fd>0) ioctl(fd, KDMKTONE, 1193180/freq + (0xFFFF<<16));
+ if (fd==0)
+ fd=open("/dev/console", O_RDONLY);
+ if (fd>0)
+ ioctl(fd, KDMKTONE, 1193180/freq + (0xFFFF<<16));
#endif
}
void nosound(void)
{
#ifdef HAVE_LINUX_KD_H
#endif
}
void nosound(void)
{
#ifdef HAVE_LINUX_KD_H
- if(fd>0) ioctl(fd, KDMKTONE, 0);
+ if(fd>0)
+ ioctl(fd, KDMKTONE, 0);