else {
chew();
if (game.damage[DSHIELD]) {
- prout("Shields damaged and down.");
+ prout(_("Shields damaged and down."));
return;
}
if (isit("up"))
}
}
if (action==NONE) {
- proutn("Do you wish to change shield energy? ");
+ proutn(_("Do you wish to change shield energy? "));
if (ja()) {
- proutn("Energy to transfer to shields- ");
+ proutn(_("Energy to transfer to shields- "));
action = NRG;
}
else if (game.damage[DSHIELD]) {
- prout("Shields damaged and down.");
+ prout(_("Shields damaged and down."));
return;
}
else if (game.shldup) {
- proutn("Shields are up. Do you want them down? ");
+ proutn(_("Shields are up. Do you want them down? "));
if (ja()) action = SHDN;
else {
chew();
}
}
else {
- proutn("Shields are down. Do you want them up? ");
+ proutn(_("Shields are down. Do you want them up? "));
if (ja()) action = SHUP;
else {
chew();
switch (action) {
case SHUP: /* raise shields */
if (game.shldup) {
- prout("Shields already up.");
+ prout(_("Shields already up."));
return;
}
- game.shldup = 1;
+ game.shldup = true;
game.shldchg = 1;
if (game.condit != IHDOCKED) game.energy -= 50.0;
- prout("Shields raised.");
+ prout(_("Shields raised."));
if (game.energy <= 0) {
skip(1);
- prout("Shields raising uses up last of energy.");
+ prout(_("Shields raising uses up last of energy."));
finish(FNRG);
return;
}
game.ididit=1;
return;
case SHDN:
- if (game.shldup==0) {
- prout("Shields already down.");
+ if (!game.shldup) {
+ prout(_("Shields already down."));
return;
}
- game.shldup=0;
+ game.shldup=false;
game.shldchg=1;
- prout("Shields lowered.");
+ prout(_("Shields lowered."));
game.ididit=1;
return;
case NRG:
while (scan() != IHREAL) {
chew();
- proutn("Energy to transfer to shields- ");
+ proutn(_("Energy to transfer to shields- "));
}
chew();
if (aaitem==0) return;
if (aaitem > game.energy) {
- prout("Insufficient ship energy.");
+ prout(_("Insufficient ship energy."));
return;
}
game.ididit = 1;
if (game.shield+aaitem >= game.inshld) {
- prout("Shield energy maximized.");
+ prout(_("Shield energy maximized."));
if (game.shield+aaitem > game.inshld) {
- prout("Excess energy requested returned to ship energy");
+ prout(_("Excess energy requested returned to ship energy"));
}
game.energy -= game.inshld-game.shield;
game.shield = game.inshld;
if (aaitem < 0.0 && game.energy-aaitem > game.inenrg) {
/* Prevent shield drain loophole */
skip(1);
- prout("Engineering to bridge--");
- prout(" Scott here. Power circuit problem, Captain.");
- prout(" I can't drain the shields.");
+ prout(_("Engineering to bridge--"));
+ prout(_(" Scott here. Power circuit problem, Captain."));
+ prout(_(" I can't drain the shields."));
game.ididit = 0;
return;
}
if (game.shield+aaitem < 0) {
- prout("All shield energy transferred to ship.");
+ prout(_("All shield energy transferred to ship."));
game.energy += game.shield;
game.shield = 0.0;
return;
}
- proutn("Scotty- \"");
+ proutn(_("Scotty- \""));
if (aaitem > 0)
- prout("Transferring energy to shields.\"");
+ prout(_("Transferring energy to shields.\""));
else
- prout("Draining energy from shields.\"");
+ prout(_("Draining energy from shields.\""));
game.shield += aaitem;
game.energy -= aaitem;
return;
}
}
-void ram(int ibumpd, int ienm, int ix, int iy)
+void ram(int ibumpd, int ienm, coord w)
{
double type = 1.0, extradm;
int icas, l;
- prouts("***RED ALERT! RED ALERT!");
+ prouts(_("***RED ALERT! RED ALERT!"));
skip(1);
- prout("***COLLISION IMMINENT.");
+ prout(_("***COLLISION IMMINENT."));
skip(2);
proutn("***");
crmshp();
case IHT: type = 0.5; break;
case IHQUEST: type = 4.0; break;
}
- proutn(ibumpd ? " rammed by " : " rams ");
- crmena(0, ienm, 2, ix, iy);
- if (ibumpd) proutn(" (original position)");
+ proutn(ibumpd ? _(" rammed by ") : _(" rams "));
+ crmena(0, ienm, 2, w);
+ if (ibumpd) proutn(_(" (original position)"));
skip(1);
- deadkl(ix, iy, ienm, game.sectx, game.secty);
+ deadkl(w, ienm, game.sector.x, game.sector.y);
proutn("***");
crmshp();
- prout(" heavily damaged.");
+ prout(_(" heavily damaged."));
icas = 10.0+20.0*Rand();
- prout("***Sickbay reports %d casualties", icas);
+ prout(_("***Sickbay reports %d casualties"), icas);
game.casual += icas;
for (l=0; l < NDEVICES; l++) {
if (l == DDRAY)
extradm = (10.0*type*Rand()+1.0)*game.damfac;
game.damage[l] += game.optime + extradm; /* Damage for at least time of travel! */
}
- game.shldup = 0;
+ game.shldup = false;
if (KLINGREM) {
pause_game(2);
dreprt();
void torpedo(double course, double r, int inx, int iny, double *hit, int i, int n)
{
- int l, iquad=0, ix=0, iy=0, jx=0, jy=0, shoved=0, ll;
+ int l, iquad=0, jx=0, jy=0, shoved=0, ll;
double ac=course + 0.25*r;
double angle = (15.0-ac)*0.5235988;
double bullseye = (15.0 - course)*0.5235988;
double deltax=-sin(angle), deltay=cos(angle), x=inx, y=iny, bigger;
double ang, temp, xx, yy, kp, h1;
+ coord w;
+ w.x = w.y = 0;
bigger = fabs(deltax);
if (fabs(deltay) > bigger) bigger = fabs(deltay);
deltax /= bigger;
/* Loop to move a single torpedo */
for (l=1; l <= 15; l++) {
x += deltax;
- ix = x + 0.5;
+ w.x = x + 0.5;
y += deltay;
- iy = y + 0.5;
- if (!VALID_SECTOR(ix, iy)) break;
- iquad=game.quad[ix][iy];
- tracktorpedo(ix, iy, l, i, n, iquad);
+ w.y = y + 0.5;
+ if (!VALID_SECTOR(w.x, w.y)) break;
+ iquad=game.quad[w.x][w.y];
+ tracktorpedo(w.x, w.y, l, i, n, iquad);
if (iquad==IHDOT) continue;
/* hit something */
setwnd(message_window);
case IHE: /* Hit our ship */
case IHF:
skip(1);
- proutn("Torpedo hits ");
+ proutn(_("Torpedo hits "));
crmshp();
prout(".");
*hit = 700.0 + 100.0*Rand() -
- 1000.0*sqrt(square(ix-inx)+square(iy-iny))*
+ 1000.0*sqrt(square(w.x-inx)+square(w.y-iny))*
fabs(sin(bullseye-angle));
*hit = fabs(*hit);
newcnd(); /* we're blown out of dock */
if (fabs(cos(ang)) > temp) temp = fabs(cos(ang));
xx = -sin(ang)/temp;
yy = cos(ang)/temp;
- jx=ix+xx+0.5;
- jy=iy+yy+0.5;
+ jx=w.x+xx+0.5;
+ jy=w.y+yy+0.5;
if (!VALID_SECTOR(jx, jy)) return;
if (game.quad[jx][jy]==IHBLANK) {
finish(FHOLE);
/* can't move into object */
return;
}
- game.sectx = jx;
- game.secty = jy;
+ game.sector.x = jx;
+ game.sector.y = jy;
crmshp();
shoved = 1;
break;
case IHC: /* Hit a commander */
case IHS:
if (Rand() <= 0.05) {
- crmena(1, iquad, 2, ix, iy);
- prout(" uses anti-photon device;");
- prout(" torpedo neutralized.");
+ crmena(1, iquad, 2, w);
+ prout(_(" uses anti-photon device;"));
+ prout(_(" torpedo neutralized."));
return;
}
case IHR: /* Hit a regular enemy */
case IHK:
/* find the enemy */
for_local_enemies(ll)
- if (ix==game.kx[ll] && iy==game.ky[ll]) break;
+ if (w.x==game.ks[ll].x && w.y==game.ks[ll].y) break;
kp = fabs(game.kpower[ll]);
h1 = 700.0 + 100.0*Rand() -
- 1000.0*sqrt(square(ix-inx)+square(iy-iny))*
+ 1000.0*sqrt(square(w.x-inx)+square(w.y-iny))*
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(ix, iy, iquad, ix, iy);
+ deadkl(w, iquad, w.x, w.y);
return;
}
- crmena(1, iquad, 2, ix, iy);
+ crmena(1, iquad, 2, w);
/* 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));
xx = -sin(ang)/temp;
yy = cos(ang)/temp;
- jx=ix+xx+0.5;
- jy=iy+yy+0.5;
+ jx=w.x+xx+0.5;
+ jy=w.y+yy+0.5;
if (!VALID_SECTOR(jx, jy)) {
- prout(" damaged but not destroyed.");
+ prout(_(" damaged but not destroyed."));
return;
}
if (game.quad[jx][jy]==IHBLANK) {
- prout(" buffeted into black hole.");
- deadkl(ix, iy, iquad, jx, jy);
+ prout(_(" buffeted into black hole."));
+ deadkl(w, iquad, jx, jy);
return;
}
if (game.quad[jx][jy]!=IHDOT) {
/* can't move into object */
- prout(" damaged but not destroyed.");
+ prout(_(" damaged but not destroyed."));
return;
}
- proutn(" damaged--");
- game.kx[ll] = jx;
- game.ky[ll] = jy;
+ proutn(_(" damaged--"));
+ game.ks[ll].x = jx;
+ game.ks[ll].y = jy;
shoved = 1;
break;
case IHB: /* Hit a base */
skip(1);
- prout("***STARBASE DESTROYED..");
+ prout(_("***STARBASE DESTROYED.."));
for_starbases(ll) {
- if (game.state.baseqx[ll]==game.quadx && game.state.baseqy[ll]==game.quady) {
- game.state.baseqx[ll]=game.state.baseqx[game.state.rembase];
- game.state.baseqy[ll]=game.state.baseqy[game.state.rembase];
+ if (game.state.baseq[ll].x==game.quadrant.x && game.state.baseq[ll].y==game.quadrant.y) {
+ game.state.baseq[ll].x=game.state.baseq[game.state.rembase].x;
+ game.state.baseq[ll].y=game.state.baseq[game.state.rembase].y;
break;
}
}
- game.quad[ix][iy]=IHDOT;
+ game.quad[w.x][w.y]=IHDOT;
game.state.rembase--;
- game.basex=game.basey=0;
- game.state.galaxy[game.quadx][game.quady].starbase--;
- game.state.chart[game.quadx][game.quady].starbase--;
+ game.base.x=game.base.y=0;
+ game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase--;
+ game.state.chart[game.quadrant.x][game.quadrant.y].starbase--;
game.state.basekl++;
newcnd();
return;
case IHP: /* Hit a planet */
- crmena(1, iquad, 2, ix, iy);
- prout(" destroyed.");
+ crmena(1, iquad, 2, w);
+ prout(_(" destroyed."));
game.state.nplankl++;
- game.state.galaxy[game.quadx][game.quady].planet = NULL;
+ game.state.galaxy[game.quadrant.x][game.quadrant.y].planet = NOPLANET;
DESTROY(&game.state.plnets[game.iplnet]);
game.iplnet = 0;
- game.plnetx = game.plnety = 0;
- game.quad[ix][iy] = IHDOT;
+ game.plnet.x = game.plnet.y = 0;
+ game.quad[w.x][w.y] = IHDOT;
if (game.landed==1) {
/* captain perishes on planet */
finish(FDPLANET);
}
return;
+ case IHW: /* Hit an inhabited world -- very bad! */
+ crmena(1, iquad, 2, w);
+ prout(_(" destroyed."));
+ game.state.nworldkl++;
+ game.state.galaxy[game.quadrant.x][game.quadrant.y].planet = NOPLANET;
+ DESTROY(&game.state.plnets[game.iplnet]);
+ game.iplnet = 0;
+ game.plnet.x = game.plnet.y = 0;
+ game.quad[w.x][w.y] = IHDOT;
+ if (game.landed==1) {
+ /* captain perishes on planet */
+ finish(FDPLANET);
+ }
+ prout("You have just destroyed an inhabited planet.");
+ prout("Celebratory rallies are being held on the Klingon homeworld.");
+ return;
case IHSTAR: /* Hit a star */
if (Rand() > 0.10) {
- nova(ix, iy);
+ nova(w.x, w.y);
return;
}
- crmena(1, IHSTAR, 2, ix, iy);
- prout(" unaffected by photon blast.");
+ crmena(1, IHSTAR, 2, w);
+ prout(_(" unaffected by photon blast."));
return;
case IHQUEST: /* Hit a thingy */
if (!(game.options & OPTION_THINGY) || Rand()>0.7) {
skip(1);
- prouts("AAAAIIIIEEEEEEEEAAAAAAAAUUUUUGGGGGHHHHHHHHHHHH!!!");
+ prouts(_("AAAAIIIIEEEEEEEEAAAAAAAAUUUUUGGGGGHHHHHHHHHHHH!!!"));
skip(1);
- prouts(" HACK! HACK! HACK! *CHOKE!* ");
+ prouts(_(" HACK! HACK! HACK! *CHOKE!* "));
skip(1);
- proutn("Mr. Spock-");
- prouts(" \"Fascinating!\"");
+ proutn(_("Mr. Spock-"));
+ prouts(_(" \"Fascinating!\""));
skip(1);
- deadkl(ix, iy, iquad, ix, iy);
+ deadkl(w, iquad, w.x, w.y);
} else {
/*
* Stas Sergeev added the possibility that
return;
case IHBLANK: /* Black hole */
skip(1);
- crmena(1, IHBLANK, 2, ix, iy);
- prout(" swallows torpedo.");
+ crmena(1, IHBLANK, 2, w);
+ prout(_(" swallows torpedo."));
return;
case IHWEB: /* hit the web */
skip(1);
- prout("***Torpedo absorbed by Tholian web.");
+ prout(_("***Torpedo absorbed by Tholian web."));
return;
case IHT: /* Hit a Tholian */
h1 = 700.0 + 100.0*Rand() -
- 1000.0*sqrt(square(ix-inx)+square(iy-iny))*
+ 1000.0*sqrt(square(w.x-inx)+square(w.y-iny))*
fabs(sin(bullseye-angle));
h1 = fabs(h1);
if (h1 >= 600) {
- game.quad[ix][iy] = IHDOT;
+ game.quad[w.x][w.y] = IHDOT;
game.ithere = 0;
- game.ithx = game.ithy = 0;
- deadkl(ix, iy, iquad, ix, iy);
+ game.tholian.x = game.tholian.y = 0;
+ deadkl(w, iquad, w.x, w.y);
return;
}
skip(1);
- crmena(1, IHT, 2, ix, iy);
+ crmena(1, IHT, 2, w);
if (Rand() > 0.05) {
- prout(" survives photon blast.");
+ prout(_(" survives photon blast."));
return;
}
- prout(" disappears.");
- game.quad[ix][iy] = IHWEB;
- game.ithere = game.ithx = game.ithy = 0;
+ prout(_(" disappears."));
+ game.quad[w.x][w.y] = IHWEB;
+ game.ithere = game.tholian.x = game.tholian.y = 0;
game.nenhere--;
{
- int dum, my;
- dropin(IHBLANK, &dum, &my);
+ coord dummy;
+ dropin(IHBLANK, &dummy);
}
return;
default: /* Problem! */
skip(1);
proutn("Don't know how to handle collision with ");
- crmena(1, iquad, 2, ix, iy);
+ crmena(1, iquad, 2, w);
skip(1);
return;
}
setwnd(message_window);
}
if (shoved) {
+ coord w;
+ w.x = jx; w.y = jy;
game.quad[jx][jy]=iquad;
- game.quad[ix][iy]=IHDOT;
- prout(" displaced by blast to %s ", cramlc(sector, jx, jy));
+ game.quad[w.x][w.y]=IHDOT;
+ prout(_(" displaced by blast to %s "), cramlc(sector, w));
for_local_enemies(ll)
- game.kdist[ll] = game.kavgd[ll] = sqrt(square(game.sectx-game.kx[ll])+square(game.secty-game.ky[ll]));
+ game.kdist[ll] = game.kavgd[ll] = sqrt(square(game.sector.x-game.ks[ll].x)+square(game.sector.y-game.ks[ll].y));
sortkl();
return;
}
skip(1);
- prout("Torpedo missed.");
+ prout(_("Torpedo missed."));
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--");
+ proutn(_("***CRITICAL HIT--"));
/* Select devices and cause damage */
for (l = 0; l < ncrit && 0 < NDEVICES; l++) {
do {
if (ll<=l) continue;
ktr += 1;
if (ktr==3) skip(1);
- proutn(" and ");
+ proutn(_(" and "));
}
proutn(device[j]);
}
- prout(" damaged.");
+ prout(_(" damaged."));
if (game.damage[DSHIELD] && game.shldup) {
- prout("***Shields knocked down.");
- game.shldup=0;
+ prout(_("***Shields knocked down."));
+ game.shldup=false;
}
}
void attack(int torps_ok)
{
/* torps_ok == 0 forces use of phasers in an attack */
- int percent, ihurt=0, l, i=0, jx, jy, iquad, itflag;
+ int percent, ihurt=0, l, i=0, iquad, itflag;
int atackd = 0, attempt = 0;
double hit;
double pfac, dustfac, hitmax=0.0, hittot=0.0, chgfac=1.0, r;
+ coord jay;
game.iattak = 1;
if (game.alldone) return;
-#ifdef DEBUG
- if (game.idebug) prout("ATTACK!");
-#endif
+ if (idebug) prout("=== ATTACK!");
if (game.ithere) movetho();
/* Increase chance of photon torpedos if docked or enemy energy low */
if (game.condit == IHDOCKED) r *= 0.25;
if (game.kpower[l] < 500) r *= 0.25;
- jx = game.kx[l];
- jy = game.ky[l];
- iquad = game.quad[jx][jy];
+ jay.x = game.ks[l].x;
+ jay.y = game.ks[l].y;
+ iquad = game.quad[jay.x][jay.y];
if (iquad==IHT || (iquad==IHQUEST && !iqengry)) continue;
itflag = (iquad == IHK && r > 0.0005) || !torps_ok ||
(iquad==IHC && r > 0.015) ||
game.kpower[l] *= 0.75;
}
else { /* Enemy used photon torpedo */
- double course = 1.90985*atan2((double)game.secty-jy, (double)jx-game.sectx);
+ double course = 1.90985*atan2((double)game.sector.y-jay.y, (double)jay.x-game.sector.x);
hit = 0;
- proutn("***TORPEDO INCOMING");
+ proutn(_("***TORPEDO INCOMING"));
if (game.damage[DSRSENS] <= 0.0) {
- proutn(" From ");
- crmena(0, iquad, i, jx, jy);
+ proutn(_(" From "));
+ crmena(0, iquad, i, jay);
}
attempt = 1;
prout(" ");
r = (Rand()+Rand())*0.5 -0.5;
r += 0.002*game.kpower[l]*r;
- torpedo(course, r, jx, jy, &hit, 1, 1);
+ torpedo(course, r, jay.x, jay.y, &hit, 1, 1);
if (KLINGREM==0)
finish(FWON); /* Klingons did themselves in! */
- if (game.state.galaxy[game.quadx][game.quady].supernova || game.alldone)
+ if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova || game.alldone)
return; /* Supernova or finished */
if (hit == 0) continue;
}
- if (game.shldup != 0 || game.shldchg != 0 || game.condit==IHDOCKED) {
+ if (game.shldup || game.shldchg != 0 || game.condit==IHDOCKED) {
/* shields will take hits */
double absorb, hitsh, propor = pfac*game.shield*(game.condit==IHDOCKED ? 2.1 : 1.0);
if(propor < 0.1) propor = 0.1;
/* It's a hit -- print out hit size */
atackd = 1; /* We weren't going to check casualties, etc. if
shields were down for some strange reason. This
- doesn't make any sense, so I've fixed it */
+ doesn't make any sense, so I've fw.xed it */
ihurt = 1;
- proutn("%d unit hit", (int)hit);
+ proutn(_("%d unit hit"), (int)hit);
if ((game.damage[DSRSENS] > 0 && itflag) || game.skill<=SKILL_FAIR) {
- proutn(" on the ");
+ proutn(_(" on the "));
crmshp();
}
if (game.damage[DSRSENS] <= 0.0 && itflag) {
- proutn(" from ");
- crmena(0, iquad, i, jx, jy);
+ proutn(_(" from "));
+ crmena(0, iquad, i, jay);
}
skip(1);
/* Decide if hit is critical */
if (hit > hitmax) hitmax = hit;
hittot += hit;
fry(hit);
- prout("Hit %g energy %g", hit, game.energy);
game.energy -= hit;
if (game.condit==IHDOCKED)
dock(0);
return;
}
if (attempt == 0 && game.condit == IHDOCKED)
- prout("***Enemies decide against attacking your ship.");
+ prout(_("***Enemies decide against attacking your ship."));
if (atackd == 0) return;
percent = 100.0*pfac*game.shield+0.5;
if (ihurt==0) {
/* Shields fully protect ship */
- proutn("Enemy attack reduces shield strength to ");
+ proutn(_("Enemy attack reduces shield strength to "));
}
else {
/* Print message if starship suffered hit(s) */
skip(1);
- proutn("Energy left %2d shields ", (int)game.energy);
- if (game.shldup) proutn("up ");
- else if (game.damage[DSHIELD] == 0) proutn("down ");
- else proutn("damaged, ");
+ proutn(_("Energy left %2d shields "), (int)game.energy);
+ if (game.shldup) proutn(_("up "));
+ else if (game.damage[DSHIELD] == 0) proutn(_("down "));
+ else proutn(_("damaged, "));
}
- prout("%d%%, torpedoes left %d", percent, game.torps);
+ prout(_("%d%%, torpedoes left %d"), percent, game.torps);
/* Check if anyone was hurt */
if (hitmax >= 200 || hittot >= 500) {
int icas= hittot*Rand()*0.015;
if (icas >= 2) {
skip(1);
- prout("Mc Coy- \"Sickbay to bridge. We suffered %d casualties", icas);
- prout(" in that last attack.\"");
+ prout(_("Mc Coy- \"Sickbay to bridge. We suffered %d casualties"), icas);
+ prout(_(" in that last attack.\""));
game.casual += icas;
}
}
return;
}
-void deadkl(int ix, int iy, int type, int ixx, int iyy)
+void deadkl(coord w, int type, int ixx, int iyy)
{
/* Added ixx and iyy allow enemy to "move" before dying */
-
+ coord mv;
int i,j;
+ mv.x = ixx; mv.y = iyy;
skip(1);
- crmena(1, type, 2, ixx, iyy);
+ crmena(1, type, 2, mv);
/* Decide what kind of enemy it is and update approriately */
if (type == IHR) {
/* chalk up a Romulan */
- game.state.galaxy[game.quadx][game.quady].romulans--;
+ game.state.galaxy[game.quadrant.x][game.quadrant.y].romulans--;
game.irhere--;
game.state.nromrem--;
}
}
else if (type == IHQUEST) {
/* Killed a Thingy */
- iqhere=iqengry=thingx=thingy=0;
+ iqhere=iqengry=thing.x=thing.y=0;
}
else {
/* Some type of a Klingon */
- game.state.galaxy[game.quadx][game.quady].klingons--;
+ game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons--;
game.klhere--;
switch (type) {
case IHC:
game.comhere = 0;
for_commanders (i)
- if (game.state.cx[i]==game.quadx && game.state.cy[i]==game.quady) break;
- game.state.cx[i] = game.state.cx[game.state.remcom];
- game.state.cy[i] = game.state.cy[game.state.remcom];
- game.state.cx[game.state.remcom] = 0;
- game.state.cy[game.state.remcom] = 0;
+ if (game.state.kcmdr[i].x==game.quadrant.x && game.state.kcmdr[i].y==game.quadrant.y) break;
+ game.state.kcmdr[i] = game.state.kcmdr[game.state.remcom];
+ game.state.kcmdr[game.state.remcom].x = 0;
+ game.state.kcmdr[game.state.remcom].y = 0;
game.state.remcom--;
- game.future[FTBEAM] = FOREVER;
+ unschedule(FTBEAM);
if (game.state.remcom != 0)
- game.future[FTBEAM] = game.state.date + expran(1.0*game.incom/game.state.remcom);
+ schedule(FTBEAM, expran(1.0*game.incom/game.state.remcom));
break;
case IHK:
game.state.remkl--;
break;
case IHS:
game.state.nscrem--;
- game.ishere = game.state.isx = game.state.isy = game.isatb = game.iscate = 0;
- game.future[FSCMOVE] = game.future[FSCDBAS] = FOREVER;
+ game.ishere = game.state.kscmdr.x = game.state.kscmdr.y = game.isatb = game.iscate = 0;
+ unschedule(FSCMOVE);
+ unschedule(FSCDBAS);
break;
}
}
/* For each kind of enemy, finish message to player */
- prout(" destroyed.");
- game.quad[ix][iy] = IHDOT;
+ prout(_(" destroyed."));
+ game.quad[w.x][w.y] = IHDOT;
if (KLINGREM==0) return;
game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);
/* Remove enemy ship from arrays describing local game.conditions */
- if (game.future[FCDBAS] < FOREVER && game.batx==game.quadx && game.baty==game.quady && type==IHC)
- game.future[FCDBAS] = FOREVER;
+ if (is_scheduled(FCDBAS) && game.battle.x==game.quadrant.x && game.battle.y==game.quadrant.y && type==IHC)
+ unschedule(FCDBAS);
for_local_enemies(i)
- if (game.kx[i]==ix && game.ky[i]==iy) break;
+ if (same(game.ks[i], w)) break;
game.nenhere--;
if (i <= game.nenhere) {
for (j=i; j<=game.nenhere; j++) {
- game.kx[j] = game.kx[j+1];
- game.ky[j] = game.ky[j+1];
+ game.ks[j] = game.ks[j+1];
game.kpower[j] = game.kpower[j+1];
game.kavgd[j] = game.kdist[j] = game.kdist[j+1];
}
}
- game.kx[game.nenhere+1] = 0;
- game.ky[game.nenhere+1] = 0;
+ game.ks[game.nenhere+1].x = 0;
+ game.ks[game.nenhere+1].x = 0;
game.kdist[game.nenhere+1] = 0;
game.kavgd[game.nenhere+1] = 0;
game.kpower[game.nenhere+1] = 0;
return;
}
-static int targetcheck(double x, double y, double *course)
+static bool targetcheck(double x, double y, double *course)
{
double deltx, delty;
- /* Return TRUE if target is invalid */
+ /* Return true if target is invalid */
if (!VALID_SECTOR(x, y)) {
huh();
- return 1;
+ return true;
}
- deltx = 0.1*(y - game.secty);
- delty = 0.1*(game.sectx - x);
+ deltx = 0.1*(y - game.sector.y);
+ delty = 0.1*(game.sector.x - x);
if (deltx==0 && delty== 0) {
skip(1);
- prout("Spock- \"Bridge to sickbay. Dr. McCoy,");
- prout(" I recommend an immediate review of");
- prout(" the Captain's psychological profile.\"");
+ prout(_("Spock- \"Bridge to sickbay. Dr. McCoy,"));
+ prout(_(" I recommend an immediate review of"));
+ prout(_(" the Captain's psychological profile.\""));
chew();
- return 1;
+ return true;
}
*course = 1.90985932*atan2(deltx, delty);
- return 0;
+ return false;
}
void photon(void)
game.ididit = 0;
if (game.damage[DPHOTON]) {
- prout("Photon tubes damaged.");
+ prout(_("Photon tubes damaged."));
chew();
return;
}
if (game.torps == 0) {
- prout("No torpedoes left.");
+ prout(_("No torpedoes left."));
chew();
return;
}
return;
}
else if (key == IHEOL) {
- prout("%d torpedoes left.", game.torps);
- proutn("Number of torpedoes to fire- ");
+ prout(_("%d torpedoes left."), game.torps);
+ proutn(_("Number of torpedoes to fire- "));
key = scan();
}
else /* key == IHREAL */ {
}
if (n > 3) {
chew();
- prout("Maximum of 3 torpedoes per burst.");
+ prout(_("Maximum of 3 torpedoes per burst."));
key = IHEOL;
return;
}
if (i == 1 && key == IHEOL) {
/* prompt for each one */
for (i = 1; i <= n; i++) {
- proutn("Target sector for torpedo number %d- ", i);
+ proutn(_("Target sector for torpedo number %d- "), i);
key = scan();
if (key != IHREAL) {
huh();
/* misfire! */
r = (Rand()+1.2) * r;
if (n>1) {
- prouts("***TORPEDO NUMBER %d MISFIRES", i);
+ prouts(_("***TORPEDO NUMBER %d MISFIRES"), i);
}
- else prouts("***TORPEDO MISFIRES.");
+ else prouts(_("***TORPEDO MISFIRES."));
skip(1);
if (i < n)
- prout(" Remainder of burst aborted.");
+ prout(_(" Remainder of burst aborted."));
osuabor=1;
if (Rand() <= 0.2) {
- prout("***Photon tubes damaged by misfire.");
+ prout(_("***Photon tubes damaged by misfire."));
game.damage[DPHOTON] = game.damfac*(1.0+2.0*Rand());
break;
}
}
if (game.shldup || game.condit == IHDOCKED)
r *= 1.0 + 0.0001*game.shield;
- torpedo(course[i], r, game.sectx, game.secty, &dummy, i, n);
- if (game.alldone || game.state.galaxy[game.quadx][game.quady].supernova)
+ torpedo(course[i], r, game.sector.x, game.sector.y, &dummy, i, n);
+ if (game.alldone || game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
return;
}
if (KLINGREM==0) finish(FWON);
if (rpow > 1500) {
double chekbrn = (rpow-1500.)*0.00038;
if (Rand() <= chekbrn) {
- prout("Weapons officer Sulu- \"Phasers overheated, sir.\"");
+ prout(_("Weapons officer Sulu- \"Phasers overheated, sir.\""));
game.damage[DPHASER] = game.damfac*(1.0 + Rand()) * (1.0+chekbrn);
}
}
skip(1);
if (Rand() < .998) {
- prout("Shields lowered.");
+ prout(_("Shields lowered."));
return 0;
}
/* Something bad has happened */
- prouts("***RED ALERT! RED ALERT!");
+ prouts(_("***RED ALERT! RED ALERT!"));
skip(2);
hit = rpow*game.shield/game.inshld;
game.energy -= rpow+hit*0.8;
game.shield -= hit*0.2;
if (game.energy <= 0.0) {
- prouts("Sulu- \"Captain! Shield malf***********************\"");
+ prouts(_("Sulu- \"Captain! Shield malf***********************\""));
skip(1);
stars();
finish(FPHASER);
return 1;
}
- prouts("Sulu- \"Captain! Shield malfunction! Phaser fire contained!\"");
+ prouts(_("Sulu- \"Captain! Shield malfunction! Phaser fire contained!\""));
skip(2);
- prout("Lt. Uhura- \"Sir, all decks reporting damage.\"");
+ prout(_("Lt. Uhura- \"Sir, all decks reporting damage.\""));
icas = hit*Rand()*0.012;
skip(1);
fry(0.8*hit);
if (icas) {
skip(1);
- prout("McCoy to bridge- \"Severe radiation burns, Jim.");
- prout(" %d casualties so far.\"", icas);
+ prout(_("McCoy to bridge- \"Severe radiation burns, Jim."));
+ prout(_(" %d casualties so far.\""), icas);
game.casual -= icas;
}
skip(1);
- prout("Phaser energy dispersed by shields.");
- prout("Enemy unaffected.");
+ prout(_("Phaser energy dispersed by shields."));
+ prout(_("Enemy unaffected."));
overheat(rpow);
return 1;
}
/* SR sensors and Computer */
if (game.damage[DSRSENS]+game.damage[DCOMPTR] > 0) ipoop = 0;
if (game.condit == IHDOCKED) {
- prout("Phasers can't be fired through base shields.");
+ prout(_("Phasers can't be fired through base shields."));
chew();
return;
}
if (game.damage[DPHASER] != 0) {
- prout("Phaser control damaged.");
+ prout(_("Phaser control damaged."));
chew();
return;
}
if (game.shldup) {
if (game.damage[DSHCTRL]) {
- prout("High speed shield control damaged.");
+ prout(_("High speed shield control damaged."));
chew();
return;
}
if (game.energy <= 200.0) {
- prout("Insufficient energy to activate high-speed shield control.");
+ prout(_("Insufficient energy to activate high-speed shield control."));
chew();
return;
}
- prout("Weapons Officer Sulu- \"High-speed shield control enabled, sir.\"");
+ prout(_("Weapons Officer Sulu- \"High-speed shield control enabled, sir.\""));
ifast = 1;
}
if (key == IHALPHA) {
if (isit("manual")) {
if (game.nenhere==0) {
- prout("There is no enemy present to select.");
+ prout(_("There is no enemy present to select."));
chew();
key = IHEOL;
automode=AUTOMATIC;
}
else {
if (game.nenhere==0)
- prout("Energy will be expended into space.");
+ prout(_("Energy will be expended into space."));
automode = AUTOMATIC;
key = scan();
}
}
else if (key == IHREAL) {
if (game.nenhere==0) {
- prout("Energy will be expended into space.");
+ prout(_("Energy will be expended into space."));
automode = AUTOMATIC;
}
else if (!ipoop)
else {
/* IHEOL */
if (game.nenhere==0) {
- prout("Energy will be expended into space.");
+ prout(_("Energy will be expended into space."));
automode = AUTOMATIC;
}
else if (!ipoop)
automode = FORCEMAN;
else
- proutn("Manual or automatic? ");
+ proutn(_("Manual or automatic? "));
}
}
key = scan();
}
if (key != IHREAL && game.nenhere != 0) {
- prout("Phasers locked on target. Energy available: %.2f",
+ prout(_("Phasers locked on target. Energy available: %.2f"),
ifast?game.energy-200.0:game.energy,1,2);
}
irec=0;
irec+=fabs(game.kpower[i])/(PHASEFAC*pow(0.90,game.kdist[i]))*
(1.01+0.05*Rand()) + 1.0;
kz=1;
- proutn("(%d) units required. ", irec);
+ proutn(_("(%d) units required. "), irec);
chew();
- proutn("Units to fire= ");
+ proutn(_("Units to fire= "));
key = scan();
if (key!=IHREAL) return;
rpow = aaitem;
if (rpow > (ifast?game.energy-200:game.energy)) {
- proutn("Energy available= %.2f",
+ proutn(_("Energy available= %.2f"),
ifast?game.energy-200:game.energy);
skip(1);
key = IHEOL;
}
if (extra > 0 && game.alldone == 0) {
if (game.ithere) {
- proutn("*** Tholian web absorbs ");
- if (game.nenhere>0) proutn("excess ");
- prout("phaser energy.");
+ proutn(_("*** Tholian web absorbs "));
+ if (game.nenhere>0) proutn(_("excess "));
+ prout(_("phaser energy."));
}
else {
- prout("%d expended on empty space.", (int)extra);
+ prout(_("%d expended on empty space."), (int)extra);
}
}
break;
chew();
key = IHEOL;
if (game.damage[DCOMPTR]!=0)
- prout("Battle comuter damaged, manual file only.");
+ prout(_("Battle comuter damaged, manual file only."));
else {
skip(1);
- prouts("---WORKING---");
+ prouts(_("---WORKING---"));
skip(1);
- prout("Short-range-sensors-damaged");
- prout("Insufficient-data-for-automatic-phaser-fire");
- prout("Manual-fire-must-be-used");
+ prout(_("Short-range-sensors-damaged"));
+ prout(_("Insufficient-data-for-automatic-phaser-fire"));
+ prout(_("Manual-fire-must-be-used"));
skip(1);
}
case MANUAL:
rpow = 0.0;
for (k = 1; k <= game.nenhere;) {
- int ii = game.kx[k], jj = game.ky[k];
- int ienm = game.quad[ii][jj];
+ coord aim = game.ks[k];
+ int ienm = game.quad[aim.x][aim.y];
if (msgflag) {
- proutn("Energy available= %.2f",
+ proutn(_("Energy available= %.2f"),
game.energy-.006-(ifast?200:0));
skip(1);
msgflag = 0;
rpow = 0.0;
}
- if (game.damage[DSRSENS] && !(abs(game.sectx-ii) < 2 && abs(game.secty-jj) < 2) &&
+ if (game.damage[DSRSENS] && !(abs(game.sector.x-aim.x) < 2 && abs(game.sector.y-aim.y) < 2) &&
(ienm == IHC || ienm == IHS)) {
cramen(ienm);
- prout(" can't be located without short range scan.");
+ prout(_(" can't be located without short range scan."));
chew();
key = IHEOL;
hits[k] = 0; /* prevent overflow -- thanks to Alexei Voitenko */
if (game.damage[DCOMPTR]==0) proutn("%d", irec);
else proutn("??");
proutn(") ");
- proutn("units to fire at ");
- crmena(0, ienm, 2, ii, jj);
+ proutn(_("units to fire at "));
+ crmena(0, ienm, 2, aim);
proutn("- ");
key = scan();
}
/* If total requested is too much, inform and start over */
if (rpow > (ifast?game.energy-200:game.energy)) {
- prout("Available energy exceeded -- try again.");
+ prout(_("Available energy exceeded -- try again."));
chew();
return;
}
skip(1);
if (no == 0) {
if (Rand() >= 0.99) {
- prout("Sulu- \"Sir, the high-speed shield control has malfunctioned . . .");
- prouts(" CLICK CLICK POP . . .");
- prout(" No response, sir!");
- game.shldup = 0;
+ prout(_("Sulu- \"Sir, the high-speed shield control has malfunctioned . . ."));
+ prouts(_(" CLICK CLICK POP . . ."));
+ prout(_(" No response, sir!"));
+ game.shldup = false;
}
else
- prout("Shields raised.");
+ prout(_("Shields raised."));
}
else
- game.shldup = 0;
+ game.shldup = false;
}
overheat(rpow);
}
void hittem(double *hits)
{
double kp, kpow, wham, hit, dustfac, kpini;
- int nenhr2=game.nenhere, k=1, kk=1, ii, jj, ienm;
+ int nenhr2=game.nenhere, k=1, kk=1, ienm;
+ coord w;
skip(1);
if (PHASEFAC*hit < kp) kp = PHASEFAC*hit;
game.kpower[kk] -= (game.kpower[kk] < 0 ? -kp: kp);
kpow = game.kpower[kk];
- ii = game.kx[kk];
- jj = game.ky[kk];
+ w = game.ks[kk];
if (hit > 0.005) {
if (game.damage[DSRSENS]==0)
- boom(ii, jj);
- proutn("%d unit hit on ", (int)hit);
+ boom(w.x, w.y);
+ proutn(_("%d unit hit on "), (int)hit);
}
else
- proutn("Very small hit on ");
- ienm = game.quad[ii][jj];
+ proutn(_("Very small hit on "));
+ ienm = game.quad[w.x][w.y];
if (ienm==IHQUEST) iqengry=1;
- crmena(0,ienm,2,ii,jj);
+ crmena(0,ienm,2,w);
skip(1);
if (kpow == 0) {
- deadkl(ii, jj, ienm, ii, jj);
+ deadkl(w, ienm, w.x, w.y);
if (KLINGREM==0) finish(FWON);
if (game.alldone) return;
kk--; /* don't do the increment */
else /* decide whether or not to emasculate klingon */
if (kpow > 0 && Rand() >= 0.9 &&
kpow <= ((0.4 + 0.4*Rand())*kpini)) {
- prout("***Mr. Spock- \"Captain, the vessel at ",
- cramlc(sector,ii,jj));
- prout(" has just lost its firepower.\"");
+ prout(_("***Mr. Spock- \"Captain, the vessel at "),
+ cramlc(sector, w));
+ prout(_(" has just lost its firepower.\""));
game.kpower[kk] = -kpow;
}
}