startrek rus version-help en, adapt for current tcc

git-svn-id: svn://kolibrios.org@7185 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
siemargl committed 2018-03-12 20:53:49 +00:00
1 parent 524cab3cd8
commit 3a4ccc4ac4
20 files changed
+9854 -17

No files matched your search

@@ -1,5 +1,5 @@
rem To build under Windows, execute
SET TCC=D:\_bin\ktcc_26_161007
SET TCC=D:\_bin\tcc_26_180312
%TCC%\kos32-tcc -I%TCC%\INCLUDE -L%TCC%\LIB -DWINDOWS -DKOS32 sst.c ai.c battle.c events.c finish.c moving.c osx.c planets.c reports.c setup.c -lck -o SStarTrek -g
%TCC%\kos32-tcc -I%TCC%\INCLUDE -L%TCC%\LIB -DKOS32 sst.c ai.c battle.c events.c finish.c moving.c osx.c planets.c reports.c setup.c -lck -o SStarTrek -g
+2 -1
View File
@@ -457,7 +457,8 @@ void plaque(void) {
fgets(winner, 128, stdin);
#else
gets(winner);
#endif winner[strlen(winner)-1] = '\0';
#endif
winner[strlen(winner)-1] = '\0';
winner[30] = '\0';
nskip = 64 - strlen(winner)/2;
+8 -9
View File
@@ -1,25 +1,20 @@
#include <stdlib.h>
#include <stdio.h>
#ifndef KOS32
#include <time.h>
#else
#include <kos32sys1.h>
#endif
#ifndef WINDOWS
#ifndef KOS32
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
#endif
#endif
void randomize(void) {
#ifndef KOS32
srand((int)time(NULL));
#else
srand(get_tick_count());
#endif
}
///#ifndef WINDOWS
#if !defined(KOS32) && !defined(__TINYC__)
int max(int a, int b) {
if (a > b) return a;
return b;
@@ -29,7 +24,10 @@ int min(int a, int b) {
if (a < b) return a;
return b;
}
#endif
#ifndef WINDOWS
#ifndef KOS32
int // <editor-fold defaultstate="collapsed" desc="comment">
getch// </editor-fold>
(void) {
@@ -45,4 +43,5 @@ getch// </editor-fold>
tcsetattr(0, TCSANOW, &oldstate);
return chbuf[0];
}
#endif
#endif
+12 -3
View File
@@ -1,14 +1,18 @@
#include <ctype.h>
#ifdef MSDOS
#include <dos.h>
#endif
#ifdef WINDOWS
#include <windows.h>
#endif
#ifndef KOS32
#include <time.h>
#else
#include <conio.h>
#include <kos32sys1.h>
#include <kos32sys0.h>
#endif
#define INCLUDED // Define externs here
@@ -435,6 +439,11 @@ int main(int argc, char **argv) {
con_set_title("-SUPER- STAR TREK");
con_set_flags(CON_COLOR_GREEN);
#endif
#ifdef WINDOWS
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // Get handle to standard output
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN);
#endif
prelim();
@@ -585,7 +594,7 @@ int scan(void) {
}
#ifdef KOS32
cp = gets(line);
if (!cp) exit();
if (!cp) exit(0);
#else
// We should really be using fgets
fgets(line,sizeof(line),stdin);
+4 -2
View File
@@ -475,10 +475,12 @@ void attakreport(void);
void movetho(void);
void probe(void);
///#ifndef WINDOWS
#ifndef WINDOWS
#ifndef KOS32
int min(int, int);
int max(int, int);
///#endif
#endif
#endif
void randomize(void);
///int getch(void);
+617
View File
@@ -0,0 +1,617 @@
#include "sst.h"
static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) {
int iqx, iqy, l;
iqx = quadx+(lookx+9)/10 - 1;
iqy = quady+(looky+9)/10 - 1;
if (iqx < 1 || iqx > 8 || iqy < 1 || iqy > 8 ||
d.galaxy[iqx][iqy] > 899)
return 0; /* no can do -- neg energy, supernovae, or >8 Klingons */
if (ienm == IHR) return 0; /* Romulans cannot escape! */
if (irun == 0) {
/* avoid intruding on another commander's territory */
if (ienm == IHC) {
for (l = 1; l <= d.remcom; l++)
if (d.cx[l]==iqx && d.cy[l]==iqy) return 0;
/* refuse to leave if currently attacking starbase */
if (batx==quadx && baty==quady) return 0;
}
/* don't leave if over 1000 units of energy */
if (kpower[loccom] > 1000.) return 0;
}
/* print escape message and move out of quadrant.
We know this if either short or long range sensors are working */
if (damage[DSRSENS] == 0.0 || damage[DLRSENS] == 0.0 ||
condit == IHDOCKED) {
proutn("***");
cramen(ienm);
proutn(" отступил в"); /* escapes to */
cramlc(1, iqx, iqy);
prout(" (и перезарядился)."); /*(and regains strength).*/
}
/* handle local matters related to escape */
kx[loccom] = kx[nenhere];
ky[loccom] = ky[nenhere];
kavgd[loccom] = kavgd[nenhere];
kpower[loccom] = kpower[nenhere];
kdist[loccom] = kdist[nenhere];
klhere--;
nenhere--;
if (condit != IHDOCKED) newcnd();
/* Handle global matters related to escape */
d.galaxy[quadx][quady] -= 100;
d.galaxy[iqx][iqy] += 100;
if (ienm==IHS) {
ishere=0;
iscate=0;
ientesc=0;
isatb=0;
future[FSCMOVE]=0.2777+d.date;
future[FSCDBAS]=1e30;
d.isx=iqx;
d.isy=iqy;
}
else {
for (l=1; l<=d.remcom; l++) {
if (d.cx[l]==quadx && d.cy[l]==quady) {
d.cx[l]=iqx;
d.cy[l]=iqy;
break;
}
}
comhere = 0;
}
return 1; /* success */
}
static void movebaddy(int comx, int comy, int loccom, int ienm) {
int motion, mdist, nsteps, mx, my, nextx, nexty, lookx, looky, ll;
int irun = 0;
int krawlx, krawly;
int success;
int attempts;
/* This should probably be just comhere + ishere */
int nbaddys = skill > SGOOD ?
(int)((comhere*2 + ishere*2+klhere*1.23+irhere*1.5)/2.0):
(comhere + ishere);
double dist1, forces;
dist1 = kdist[loccom];
mdist = dist1 + 0.5; /* Nearest integer distance */
/* If SC, check with spy to see if should hi-tail it */
if (ienm==IHS &&
(kpower[loccom] <= 500.0 || (condit==IHDOCKED && damage[DPHOTON]==0))) {
irun = 1;
motion = -10;
}
else {
/* decide whether to advance, retreat, or hold position */
/* Algorithm:
* Enterprise has "force" based on condition of phaser and photon torpedoes.
If both are operating full strength, force is 1000. If both are damaged,
force is -1000. Having shields down subtracts an additional 1000.
* Enemy has forces equal to the energy of the attacker plus
100*(K+R) + 500*(C+S) - 400 for novice through good levels OR
346*K + 400*R + 500*(C+S) - 400 for expert and emeritus.
Attacker Initial energy levels (nominal):
Klingon Romulan Commander Super-Commander
Novice 400 700 1200
Fair 425 750 1250
Good 450 800 1300 1750
Expert 475 850 1350 1875
Emeritus 500 900 1400 2000
VARIANCE 75 200 200 200
Enemy vessels only move prior to their attack. In Novice - Good games
only commanders move. In Expert games, all enemy vessels move if there
is a commander present. In Emeritus games all enemy vessels move.
* If Enterprise is not docked, an agressive action is taken if enemy
forces are 1000 greater than Enterprise.
Agressive action on average cuts the distance between the ship and
the enemy to 1/4 the original.
* At lower energy advantage, movement units are proportional to the
advantage with a 650 advantage being to hold ground, 800 to move forward
1, 950 for two, 150 for back 4, etc. Variance of 100.
If docked, is reduced by roughly 1.75*skill, generally forcing a
retreat, especially at high skill levels.
* Motion is limited to skill level, except for SC hi-tailing it out.
*/
forces = kpower[loccom]+100.0*nenhere+400*(nbaddys-1);
if (shldup==0) forces += 1000; /* Good for enemy if shield is down! */
if (damage[DPHASER] == 0.0 || damage[DPHOTON] == 0.0) {
if (damage[DPHASER] != 0) /* phasers damaged */
forces += 300.0;
else
forces -= 0.2*(energy - 2500.0);
if (damage[DPHOTON] != 0) /* photon torpedoes damaged */
forces += 300.0;
else
forces -= 50.0*torps;
}
else {
/* phasers and photon tubes both out! */
forces += 1000.0;
}
motion = 0;
if (forces <= 1000.0 && condit != IHDOCKED) /* Typical situation */
motion = ((forces+200.0*Rand())/150.0) - 5.0;
else {
if (forces > 1000.0) /* Very strong -- move in for kill */
motion = (1.0-square(Rand()))*dist1 + 1.0;
if (condit==IHDOCKED) /* protected by base -- back off ! */
motion -= skill*(2.0-square(Rand()));
}
#ifdef DEBUG
if (idebug) {
proutn("MOTION = ");
cramf(motion, 1, 2);
proutn(" FORCES = ");
cramf(forces, 1, 2);
skip(1);
}
#endif
/* don't move if no motion */
if (motion==0) return;
/* Limit motion according to skill */
if (abs(motion) > skill) motion = (motion < 0) ? -skill : skill;
}
/* calcuate preferred number of steps */
nsteps = motion < 0 ? -motion : motion;
if (motion > 0 && nsteps > mdist) nsteps = mdist; /* don't overshoot */
if (nsteps > 10) nsteps = 10; /* This shouldn't be necessary */
if (nsteps < 1) nsteps = 1; /* This shouldn't be necessary */
#ifdef DEBUG
if (idebug) {
proutn("NSTEPS = ");
crami(nsteps, 1);
skip(1);
}
#endif
/* Compute preferred values of delta X and Y */
mx = sectx - comx;
my = secty - comy;
if (2.0 * abs(mx) < abs(my)) mx = 0;
if (2.0 * abs(my) < abs(sectx-comx)) my = 0;
if (mx != 0) mx = mx*motion < 0 ? -1 : 1;
if (my != 0) my = my*motion < 0 ? -1 : 1;
nextx = comx;
nexty = comy;
quad[comx][comy] = IHDOT;
/* main move loop */
for (ll = 1; ll <= nsteps; ll++) {
#ifdef DEBUG
if (idebug) {
crami(ll,2);
skip(1);
}
#endif
/* Check if preferred position available */
lookx = nextx + mx;
looky = nexty + my;
krawlx = mx < 0 ? 1 : -1;
krawly = my < 0 ? 1 : -1;
success = 0;
attempts = 0; /* Settle mysterious hang problem */
while (attempts++ < 20 && !success) {
if (lookx < 1 || lookx > 10) {
if (motion < 0 && tryexit(lookx, looky, ienm, loccom, irun))
return;
if (krawlx == mx || my == 0) break;
lookx = nextx + krawlx;
krawlx = -krawlx;
}
else if (looky < 1 || looky > 10) {
if (motion < 0 && tryexit(lookx, looky, ienm, loccom, irun))
return;
if (krawly == my || mx == 0) break;
looky = nexty + krawly;
krawly = -krawly;
}
else if (quad[lookx][looky] != IHDOT) {
/* See if we should ram ship */
if (quad[lookx][looky] == ship &&
(ienm == IHC || ienm == IHS)) {
ram(1, ienm, comx, comy);
return;
}
if (krawlx != mx && my != 0) {
lookx = nextx + krawlx;
krawlx = -krawlx;
}
else if (krawly != my && mx != 0) {
looky = nexty + krawly;
krawly = -krawly;
}
else break; /* we have failed */
}
else success = 1;
}
if (success) {
nextx = lookx;
nexty = looky;
#ifdef DEBUG
if (idebug) {
cramlc(0, nextx, nexty);
skip(1);
}
#endif
}
else break; /* done early */
}
/* Put commander in place within same quadrant */
quad[nextx][nexty] = ienm;
if (nextx != comx || nexty != comy) {
/* it moved */
kx[loccom] = nextx;
ky[loccom] = nexty;
kdist[loccom] = kavgd[loccom] =
sqrt(square(sectx-nextx)+square(secty-nexty));
if (damage[DSRSENS] == 0 || condit == IHDOCKED) {
proutn("***");
cramen(ienm);
if (kdist[loccom] < dist1) proutn(" наступает в"); /*advances to*/
else proutn(" отступил в"); /*retreats to*/
cramlc(2, nextx, nexty);
skip(1);
}
}
}
void movcom(void) {
int ix, iy, i;
#ifdef DEBUG
if (idebug) prout("MOVCOM");
#endif
/* Figure out which Klingon is the commander (or Supercommander)
and do move */
if (comhere) for (i = 1; i <= nenhere; i++) {
ix = kx[i];
iy = ky[i];
if (quad[ix][iy] == IHC) {
movebaddy(ix, iy, i, IHC);
break;
}
}
if (ishere) for (i = 1; i <= nenhere; i++) {
ix = kx[i];
iy = ky[i];
if (quad[ix][iy] == IHS) {
movebaddy(ix, iy, i, IHS);
break;
}
}
/* if skill level is high, move other Klingons and Romulans too!
Move these last so they can base their actions on what the
commander(s) do. */
if (skill > SGOOD) for (i = 1; i <= nenhere; i++) {
ix = kx[i];
iy = ky[i];
if (quad[ix][iy] == IHK || quad[ix][iy] == IHR)
movebaddy(ix, iy, i, quad[ix][iy]);
}
sortkl();
}
static int checkdest(int iqx, int iqy, int flag, int *ipage) {
int i, j;
if ((iqx==quadx && iqy==quady) ||
iqx < 1 || iqx > 8 || iqy < 1 || iqy > 8 ||
d.galaxy[iqx][iqy] > 899) return 1;
if (flag) {
/* Avoid quadrants with bases if we want to avoid Enterprise */
for (i = 1; i <= d.rembase; i++)
if (d.baseqx[i]==iqx && d.baseqy[i]==iqy) return 1;
}
/* do the move */
d.galaxy[d.isx][d.isy] -= 100;
d.isx = iqx;
d.isy = iqy;
d.galaxy[d.isx][d.isy] += 100;
if (iscate) {
/* SC has scooted, Remove him from current quadrant */
iscate=0;
isatb=0;
ishere=0;
ientesc=0;
future[FSCDBAS]=1e30;
for (i = 1; i <= nenhere; i++)
if (quad[kx[i]][ky[i]] == IHS) break;
quad[kx[i]][ky[i]] = IHDOT;
kx[i] = kx[nenhere];
ky[i] = ky[nenhere];
kdist[i] = kdist[nenhere];
kavgd[i] = kavgd[nenhere];
kpower[i] = kpower[nenhere];
klhere--;
nenhere--;
if (condit!=IHDOCKED) newcnd();
sortkl();
}
/* check for a helpful planet */
for (i = 1; i <= inplan; i++) {
if (d.plnets[i].x==d.isx && d.plnets[i].y==d.isy &&
d.plnets[i].crystals == 1) {
/* destroy the planet */
d.plnets[i] = nulplanet;
d.newstuf[d.isx][d.isy] -= 1;
if (REPORTS) {
if (*ipage==0) pause(1);
*ipage = 1;
/* prout("Lt. Uhura- \"Captain, Starfleet Intelligence reports");*/
prout("Лейтенант Ухура- \"Капитан, Разведка Звездного Флота докладывает");
proutn(" планета в"); /*a planet in*/
cramlc(1, d.isx, d.isy);
prout(" была уничтожена"); /*has been destroyed*/
prout(" Супер-Коммандером.\""); /*by the Super-commander.*/
}
break;
}
}
return 0; /* looks good! */
}
void scom(int *ipage) {
int i, i2, j, ideltax, ideltay, ibqx, ibqy, sx, sy, ifindit, iwhichb;
int iqx, iqy;
int basetbl[6];
double bdist[6];
int flag;
#ifdef DEBUG
if (idebug) prout("SCOM");
#endif
/* Decide on being active or passive */
flag = ((d.killc+d.killk)/(d.date+0.01-indate) < 0.1*skill*(skill+1.0) ||
(d.date-indate) < 3.0);
if (iscate==0 && flag) {
/* compute move away from Enterprise */
ideltax = d.isx-quadx;
ideltay = d.isy-quady;
if (sqrt(ideltax*(double)ideltax+ideltay*(double)ideltay) > 2.0) {
/* circulate in space */
ideltax = d.isy-quady;
ideltay = quadx-d.isx;
}
}
else {
/* compute distances to starbases */
if (d.rembase <= 0) {
/* nothing left to do */
future[FSCMOVE] = 1e30;
return;
}
sx = d.isx;
sy = d.isy;
for (i = 1; i <= d.rembase; i++) {
basetbl[i] = i;
ibqx = d.baseqx[i];
ibqy = d.baseqy[i];
bdist[i] = sqrt(square(ibqx-sx) + square(ibqy-sy));
}
if (d.rembase > 1) {
/* sort into nearest first order */
int iswitch;
do {
iswitch = 0;
for (i=1; i < d.rembase-1; i++) {
if (bdist[i] > bdist[i+1]) {
int ti = basetbl[i];
double t = bdist[i];
bdist[i] = bdist[i+1];
bdist[i+1] = t;
basetbl[i] = basetbl[i+1];
basetbl[i+1] =ti;
iswitch = 1;
}
}
} while (iswitch);
}
/* look for nearest base without a commander, no Enterprise, and
without too many Klingons, and not already under attack. */
ifindit = iwhichb = 0;
for (i2 = 1; i2 <= d.rembase; i2++) {
i = basetbl[i2]; /* bug in original had it not finding nearest*/
ibqx = d.baseqx[i];
ibqy = d.baseqy[i];
if ((ibqx == quadx && ibqy == quady) ||
(ibqx == batx && ibqy == baty) ||
d.galaxy[ibqx][ibqy] > 899) continue;
/* if there is a commander, an no other base is appropriate,
we will take the one with the commander */
for (j = 1; j <= d.remcom; j++) {
if (ibqx==d.cx[j] && ibqy==d.cy[j] && ifindit!= 2) {
ifindit = 2;
iwhichb = i;
break;
}
}
if (j > d.remcom) { /* no commander -- use this one */
ifindit = 1;
iwhichb = i;
break;
}
}
if (ifindit==0) return; /* Nothing suitable -- wait until next time*/
ibqx = d.baseqx[iwhichb];
ibqy = d.baseqy[iwhichb];
/* decide how to move toward base */
ideltax = ibqx - d.isx;
ideltay = ibqy - d.isy;
}
/* 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;
/* try moving in both x and y directions */
iqx = d.isx + ideltax;
iqy = d.isy + ideltax;
if (checkdest(iqx, iqy, flag, ipage)) {
/* failed -- try some other maneuvers */
if (ideltax==0 || ideltay==0) {
/* attempt angle move */
if (ideltax != 0) {
iqy = d.isy + 1;
if (checkdest(iqx, iqy, flag, ipage)) {
iqy = d.isy - 1;
checkdest(iqx, iqy, flag, ipage);
}
}
else {
iqx = d.isx + 1;
if (checkdest(iqx, iqy, flag, ipage)) {
iqx = d.isx - 1;
checkdest(iqx, iqy, flag, ipage);
}
}
}
else {
/* try moving just in x or y */
iqy = d.isy;
if (checkdest(iqx, iqy, flag, ipage)) {
iqy = d.isy + ideltay;
iqx = d.isx;
checkdest(iqx, iqy, flag, ipage);
}
}
}
/* check for a base */
if (d.rembase == 0) {
future[FSCMOVE] = 1e30;
}
else for (i=1; i<=d.rembase; i++) {
ibqx = d.baseqx[i];
ibqy = d.baseqy[i];
if (ibqx==d.isx && ibqy == d.isy && d.isx != batx && d.isy != baty) {
/* attack the base */
if (flag) return; /* no, don't attack base! */
iseenit = 0;
isatb=1;
future[FSCDBAS] = d.date + 1.0 +2.0*Rand();
if (batx != 0) future[FSCDBAS] += future[FCDBAS]-d.date;
if (!REPORTS)
return; /* no warning */
iseenit = 1;
if (*ipage == 0) pause(1);
*ipage=1;
/* proutn("Lt. Uhura- \"Captain, the starbase in");*/
proutn("Лейт.Ухура- \"Капитан, станция в");
cramlc(1, d.isx, d.isy);
skip(1);
/* prout(" reports that it is under attack from the Klingon Super-commander.");*/
proutn(" It can survive until stardate ");
prout(" докладывает, что находится под атакой Супер-Коммандером Клингонов.");
proutn(" Она продержится максимум до ");
cramf(future[FSCDBAS], 0, 1);
prout(" .\"");
if (resting==0) return;
/* prout("Mr. Spock- \"Captain, shall we cancel the rest period?\"");*/
prout("Мистер Спок- \"Капитан, мы должны прекратить отдых?\"");
if (ja()==0) return;
resting = 0;
Time = 0.0; /* actually finished */
return;
}
}
/* Check for intelligence report */
if (
#ifdef DEBUG
idebug==0 &&
#endif
(Rand() > 0.2 ||
(!REPORTS) ||
starch[d.isx][d.isy] > 0))
return;
if (*ipage==0) pause(1);
*ipage = 1;
/* prout("Lt. Uhura- \"Captain, Starfleet Intelligence reports");*/
prout("Лейт.Ухура- \"Капитан, Разведка Звездного Флота докладывает");
/* proutn(" the Super-commander is in");*/
proutn(" Супер-Коммандер находится в");
cramlc(1, d.isx, d.isy);
prout(".\"");
return;
}
void movetho(void) {
int idx, idy, im, i, dum, my;
/* Move the Tholean */
if (ithere==0 || justin == 1) return;
if (ithx == 1 && ithy == 1) {
idx = 1; idy = 10;
}
else if (ithx == 1 && ithy == 10) {
idx = 10; idy = 10;
}
else if (ithx == 10 && ithy == 10) {
idx = 10; idy = 1;
}
else if (ithx == 10 && ithy == 1) {
idx = 1; idy = 1;
}
else {
/* something is wrong! */
ithere = 0;
return;
}
/* Do nothing if we are blocked */
if (quad[idx][idy]!= IHDOT && quad[idx][idy]!= IHWEB) return;
quad[ithx][ithy] = IHWEB;
if (ithx != idx) {
/* move in x axis */
im = fabs((double)idx - ithx)/((double)idx - ithx);
while (ithx != idx) {
ithx += im;
if (quad[ithx][ithy]==IHDOT) quad[ithx][ithy] = IHWEB;
}
}
else if (ithy != idy) {
/* move in y axis */
im = fabs((double)idy - ithy)/((double)idy - ithy);
while (ithy != idy) {
ithy += im;
if (quad[ithx][ithy]==IHDOT) quad[ithx][ithy] = IHWEB;
}
}
quad[ithx][ithy] = IHT;
/* check to see if all holes plugged */
for (i = 1; i < 11; i++) {
if (quad[1][i]!=IHWEB && quad[1][i]!=IHT) return;
if (quad[10][i]!=IHWEB && quad[10][i]!=IHT) return;
if (quad[i][1]!=IHWEB && quad[i][1]!=IHT) return;
if (quad[i][10]!=IHWEB && quad[i][10]!=IHT) return;
}
/* All plugged up -- Tholian splits */
quad[ithx][ithy]=IHWEB;
dropin(IHBLANK, &dum, &my);
crmena(1,IHT, 2, ithx, ithy);
prout(" сеть создана."); /*completes web*/
ithere = ithx = ithy = 0;
return;
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,5 @@
rem To build under Windows, execute
SET TCC=D:\_bin\tcc_26_180312
%TCC%\kos32-tcc -I%TCC%\INCLUDE -L%TCC%\LIB -DKOS32 sst.c ai.c battle.c events.c finish.c moving.c osx.c planets.c reports.c setup.c -lck -o SStarTrek -g
@@ -0,0 +1,2 @@
To build under Windows, execute
cl -DWINDOWS sst.c ai.c battle.c events.c finish.c moving.c osx.c planets.c reports.c setup.c
+810
View File
@@ -0,0 +1,810 @@
#include "sst.h"
#include <math.h>
void events(void) {
int ictbeam=0, ipage=0, istract=0, line, i, j, k, l, ixhold, iyhold;
double fintim = d.date + Time, datemin, xtime, repair, yank;
#ifdef DEBUG
if (idebug) prout("EVENTS");
#endif
if (stdamtim == 1e30 && !REPORTS)
{
/* chart will no longer be updated because radio is dead */
stdamtim = d.date;
for (i=1; i <= 8 ; i++)
for (j=1; j <= 8; j++)
if (starch[i][j] == 1) starch[i][j] = d.galaxy[i][j]+1000;
}
for (;;) {
/* Select earliest extraneous event, line==0 if no events */
line = FSPY;
if (alldone) return;
datemin = fintim;
for (l=1; l<=NEVENTS; l++)
if (future[l] <= datemin) {
line = l;
datemin = future[l];
}
xtime = datemin-d.date;
#ifdef CLOAKING
if (iscloaking) {
energy -= xtime*500.0;
if (energy <= 0.) {
finish(FNRG);
return;
}
}
#endif
d.date = datemin;
/* Decrement Federation resources and recompute remaining time */
d.remres -= (d.remkl+4*d.remcom)*xtime;
d.remtime = d.remres/(d.remkl+4*d.remcom);
if (d.remtime <=0) {
finish(FDEPLETE);
return;
}
/* Is life support adequate? */
if (damage[DLIFSUP] && condit != IHDOCKED) {
if (lsupres < xtime && damage[DLIFSUP] > lsupres) {
finish(FLIFESUP);
return;
}
lsupres -= xtime;
if (damage[DLIFSUP] <= xtime) lsupres = inlsr;
}
/* Fix devices */
repair = xtime;
if (condit == IHDOCKED) repair /= docfac;
/* Don't fix Deathray here */
for (l=1; l<=ndevice; l++)
if (damage[l] > 0.0 && l != DDRAY)
damage[l] -= (damage[l]-repair > 0.0 ? repair : damage[l]);
/* Fix Deathray if docked */
if (damage[DDRAY] > 0.0 && condit == IHDOCKED)
damage[DDRAY] -= (damage[l] - xtime > 0.0 ? xtime : damage[DDRAY]);
/* If radio repaired, update star chart and attack reports */
if (stdamtim != 1e30 && REPORTS) {
stdamtim = 1e30;
/* prout("Lt. Uhura- \"Captain, the sub-space radio is working and");
prout(" surveillance reports are coming in.");*/
prout("Лейтенант Ухура- \"Капитан, подпространственная связь работает");
prout(" и мы принимаем отчет разведки.");
skip(1);
for (i=1; i <= 8 ; i++)
for (j=1; j <= 8; j++)
if (starch[i][j] > 999) starch[i][j] = 1;
if (iseenit==0) {
attakreport();
iseenit = 1;
}
skip(1);
/* prout(" The star chart is now up to date.\"");*/
prout(" Звездная карта обновлена.\"");
skip(1);
}
/* Cause extraneous event LINE to occur */
Time -= xtime;
switch (line) {
case FSNOVA: /* Supernova */
if (ipage==0) pause(1);
ipage=1;
snova(0,0);
future[FSNOVA] = d.date + expran(0.5*intime);
if (d.galaxy[quadx][quady] == 1000) return;
break;
case FSPY: /* Check with spy to see if S.C. should tractor beam */
if (d.nscrem == 0 ||
#ifdef CLOAKING
iscloaked || /* Cannot tractor beam if we can't be seen! */
#endif
ictbeam+istract > 0 ||
condit==IHDOCKED || isatb==1 || iscate==1) return;
if (ientesc ||
(energy < 2000 && torps < 4 && shield < 1250) ||
(damage[DPHASER]>0 && (damage[DPHOTON]>0 || torps < 4)) ||
(damage[DSHIELD] > 0 &&
(energy < 2500 || damage[DPHASER] > 0) &&
(torps < 5 || damage[DPHOTON] > 0))) {
/* Tractor-beam her! */
istract=1;
yank = square(d.isx-quadx) + square(d.isy-quady);
/*********TBEAM CODE***********/
}
else return;
case FTBEAM: /* Tractor beam */
if (line==FTBEAM) {
if (d.remcom == 0) {
future[FTBEAM] = 1e30;
break;
}
i = Rand()*d.remcom+1.0;
yank = square(d.cx[i]-quadx) + square(d.cy[i]-quady);
if (istract || condit == IHDOCKED ||
#ifdef CLOAKING
iscloaked || /* cannot tractor beam if we can't be seen */
#endif
yank == 0) {
/* Drats! Have to reschedule */
future[FTBEAM] = d.date + Time +
expran(1.5*intime/d.remcom);
break;
}
}
/* tractor beaming cases merge here */
yank = sqrt(yank);
if (ipage==0) pause(1);
ipage=1;
Time = (10.0/(7.5*7.5))*yank; /* 7.5 is yank rate (warp 7.5) */
ictbeam = 1;
skip(1);
proutn("***");
crmshp();
/* prout(" caught in long range tractor beam--");*/
prout(" пойманы притягивающим лучом--");
/* If Kirk & Co. screwing around on planet, handle */
atover(1); /* atover(1) is Grab */
if (alldone) return;
if (icraft == 1) { /* Caught in Galileo? */
finish(FSTRACTOR);
return;
}
/* Check to see if shuttle is aboard */
if (iscraft==0) {
skip(1);
if (Rand() >0.5) {
/* prout("Galileo, left on the planet surface, is captured");
prout("by aliens and made into a flying McDonald's.");*/
prout("Галилео, оставшийся на поверхности планеты, был захвачен");
prout("инопланетянами и превращен в летающий МакДональдс.");
damage[DSHUTTL] = -10;
iscraft = -1;
}
else {
/* prout("Galileo, left on the planet surface, is well hidden.");*/
prout("Галилео, оставшийся на поверхности планеты, надежно спрятан.");
}
}
if (line==0) {
quadx = d.isx;
quady = d.isy;
}
else {
quadx = d.cx[i];
quady = d.cy[i];
}
iran10(&sectx, &secty);
crmshp();
proutn(" притянут в точку");/*is pulled to*/
cramlc(1, quadx, quady);
proutn(", ");
cramlc(2, sectx, secty);
skip(1);
if (resting) {
/* prout("(Remainder of rest/repair period cancelled.)");*/
prout("(Отдых/ремонт досрочно прерван.)");
resting = 0;
}
if (shldup==0) {
if (damage[DSHIELD]==0 && shield > 0) {
sheild(2); /* Shldsup */
shldchg=0;
}
else prout("(Силовые щиты не готовы к работе.)");/*Shields not currently useable*/
}
newqad(0);
/* Adjust finish time to time of tractor beaming */
fintim = d.date+Time;
if (d.remcom <= 0) future[FTBEAM] = 1e30;
else future[FTBEAM] = d.date+Time+expran(1.5*intime/d.remcom);
break;
case FSNAP: /* Snapshot of the universe (for time warp) */
snapsht = d;
d.snap = 1;
future[FSNAP] = d.date + expran(0.5 * intime);
break;
case FBATTAK: /* Commander attacks starbase */
if (d.remcom==0 || d.rembase==0) {
/* no can do */
future[FBATTAK] = future[FCDBAS] = 1e30;
break;
}
i = 0;
for (j=1; j<=d.rembase; j++) {
for (k=1; k<=d.remcom; k++)
if (d.baseqx[j]==d.cx[k] && d.baseqy[j]==d.cy[k] &&
(d.baseqx[j]!=quadx || d.baseqy[j]!=quady) &&
(d.baseqx[j]!=d.isx || d.baseqy[j]!=d.isy)) {
i = 1;
break;
}
if (i == 1) break;
}
if (j>d.rembase) {
/* no match found -- try later */
future[FBATTAK] = d.date + expran(0.3*intime);
future[FCDBAS] = 1e30;
break;
}
/* commander + starbase combination found -- launch attack */
batx = d.baseqx[j];
baty = d.baseqy[j];
future[FCDBAS] = d.date+1.0+3.0*Rand();
if (isatb) /* extra time if SC already attacking */
future[FCDBAS] += future[FSCDBAS]-d.date;
future[FBATTAK] = future[FCDBAS] +expran(0.3*intime);
iseenit = 0;
if (!REPORTS)
break; /* No warning :-( */
iseenit = 1;
if (ipage==0) pause(1);
ipage = 1;
skip(1);
/* proutn("Lt. Uhura- \"Captain, the starbase in"); */
proutn("Лейтенант Ухура- \"Капитан, обнаруженная станция в точке");
cramlc(1, batx, baty);
skip(1);
/* prout(" reports that it is under atttack and that it can");
proutn(" hold out only until stardate ");
*/ prout(" докладывает, что находится под атакой");
proutn(" и продержится максимум до ");
cramf(future[FCDBAS],1,1);
prout(".\"");
if (resting) {
skip(1);
/* proutn("Mr. Spock- \"Captain, shall we cancel the rest period?\"");
*/ proutn("Мистер Спок- \"Капитан, мы должны прервать отдых?\"");
if (ja()) {
resting = 0;
Time = 0.0;
return;
}
}
break;
case FSCDBAS: /* Supercommander destroys base */
future[FSCDBAS] = 1e30;
isatb = 2;
if (d.galaxy[d.isx][d.isy]%100 < 10) break; /* WAS RETURN! */
ixhold = batx;
iyhold = baty;
batx = d.isx;
baty = d.isy;
case FCDBAS: /* Commander succeeds in destroying base */
if (line==FCDBAS) {
future[FCDBAS] = 1e30;
/* find the lucky pair */
for (i = 1; i <= d.remcom; i++)
if (d.cx[i]==batx && d.cy[i]==baty) break;
if (i > d.remcom || d.rembase == 0 ||
d.galaxy[batx][baty] % 100 < 10) {
/* No action to take after all */
batx = baty = 0;
break;
}
}
/* Code merges here for any commander destroying base */
/* Not perfect, but will have to do */
if (starch[batx][baty] == -1) starch[batx][baty] = 0;
/* Handle case where base is in same quadrant as starship */
if (batx==quadx && baty==quady) {
if (starch[batx][baty] > 999) starch[batx][baty] -= 10;
quad[basex][basey]= IHDOT;
basex=basey=0;
newcnd();
skip(1);
/* prout("Spock- \"Captain, I believe the starbase has been destroyed.\""); */
prout("Спок- \"Капитан, я полагаю, что станция была уничтожена.\"");
}
else if (d.rembase != 1 && REPORTS) {
/* Get word via subspace radio */
if (ipage==0) pause(1);
ipage = 1;
skip(1);
/* prout("Lt. Uhura- \"Captain, Starfleet Command reports that");
proutn(" the starbase in"); */
prout("Лейтенант Ухура- \"Капитан, Звездное Командование сообщает,");
proutn(" станция в");
cramlc(1, batx, baty);
prout(" была уничтожена");/* has been destroyed by */
if (isatb==2) prout("клингонским СуперКоммандером");/* the Klingon Super-Commander */
else prout("клингонским Коммандером");/* the Klingon Commander */
}
/* Remove Starbase from galaxy */
d.galaxy[batx][baty] -= 10;
for (i=1; i <= d.rembase; i++)
if (d.baseqx[i]==batx && d.baseqy[i]==baty) {
d.baseqx[i]=d.baseqx[d.rembase];
d.baseqy[i]=d.baseqy[d.rembase];
}
d.rembase--;
if (isatb == 2) {
/* reinstate a commander's base attack */
batx = ixhold;
baty = iyhold;
isatb = 0;
}
else {
batx = baty = 0;
}
break;
case FSCMOVE: /* Supercommander moves */
future[FSCMOVE] = d.date+0.2777;
if (ientesc+istract==0 &&
isatb!=1 &&
(iscate!=1 || justin==1)) scom(&ipage);
break;
case FDSPROB: /* Move deep space probe */
future[FDSPROB] = d.date + 0.01;
probex += probeinx;
probey += probeiny;
i = (int)(probex/10 +0.05);
j = (int)(probey/10 + 0.05);
if (probecx != i || probecy != j) {
probecx = i;
probecy = j;
if (i < 1 || i > 8 || j < 1 || j > 8 ||
d.galaxy[probecx][probecy] == 1000) {
// Left galaxy or ran into supernova
if (REPORTS) {
if (ipage==0) pause(1);
ipage = 1;
skip(1);
/* proutn("Lt. Uhura- \"The deep space probe "); */
proutn("Лейтенант Ухура- \"Зонд дальней разведки ");
if (i < 1 ||i > 8 || j < 1 || j > 8)
/* proutn("has left the galaxy"); */
proutn("покинул галактику");
else
/* proutn("is no longer transmitting"); */
proutn("более недоступен");
prout(".\"");
}
future[FDSPROB] = 1e30;
break;
}
if (REPORTS) {
if (ipage==0) pause(1);
ipage = 1;
skip(1);
/* proutn("Lt. Uhura- \"The deep space probe is now in "); */
proutn("Лейтенант Ухура- \"Зонд дальней разведки сейчас в");
cramlc(1, probecx, probecy);
prout(".\"");
}
}
/* Update star chart if Radio is working or have access to
radio. */
if (REPORTS)
starch[probecx][probecy] = damage[DRADIO] > 0.0 ?
d.galaxy[probecx][probecy]+1000 : 1;
proben--; // One less to travel
if (proben == 0 && isarmed &&
d.galaxy[probecx][probecy] % 10 > 0) {
/* lets blow the sucker! */
snova(1,0);
future[FDSPROB] = 1e30;
if (d.galaxy[quadx][quady] == 1000) return;
}
break;
}
}
}
void waiting(void) {
int key;
double temp, delay, origTime;
ididit = 0;
for (;;) {
key = scan();
if (key != IHEOL) break;
proutn("How long? ");
}
chew();
if (key != IHREAL) {
huh();
return;
}
origTime = delay = aaitem;
if (delay <= 0.0) return;
if (delay >= d.remtime || nenhere != 0) {
/* prout("Are you sure? "); */
prout("Вы уверены? ");
if (ja() == 0) return;
}
/* Alternate resting periods (events) with attacks */
resting = 1;
do {
if (delay <= 0) resting = 0;
if (resting == 0) {
cramf(d.remtime, 0, 2);
/* prout(" stardates left."); */
prout(" звездных лет осталось.");
return;
}
temp = Time = delay;
if (nenhere) {
double rtime = 1.0 + Rand();
if (rtime < temp) temp = rtime;
Time = temp;
}
if (Time < delay) attack(0);
if (nenhere==0) movetho();
if (alldone) return;
events();
ididit = 1;
if (alldone) return;
delay -= temp;
} while (d.galaxy[quadx][quady] != 1000); // leave if quadrant supernovas
resting = 0;
Time = 0;
}
void nova(int ix, int iy) {
static double course[] =
{0.0, 10.5, 12.0, 1.5, 9.0, 0.0, 3.0, 7.5, 6.0, 4.5};
int bot, top, top2, burst, hits[11][3], kount, icx, icy, mm, nn, j;
int iquad, iquad1, i, ll, newcx, newcy, ii, jj;
if (Rand() < 0.05) {
/* Wow! We've supernova'ed */
snova(ix, iy);
return;
}
/* handle initial nova */
quad[ix][iy] = IHDOT;
crmena(1, IHSTAR, 2, ix, iy);
prout(" Новых звезд.");/*novas*/
d.galaxy[quadx][quady] -= 1;
d.starkl++;
/* Set up stack to recursively trigger adjacent stars */
bot = top = top2 = 1;
kount = 0;
icx = icy = 0;
hits[1][1] = ix;
hits[1][2] = iy;
while (1) {
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;
ii = hits[mm][1]+nn-2;
jj = hits[mm][2]+j-2;
if (ii < 1 || ii > 10 || jj < 1 || jj > 10) continue;
iquad = quad[ii][jj];
switch (iquad) {
// case IHDOT: /* Empty space ends reaction
// case IHQUEST:
// case IHBLANK:
// case IHT:
// case IHWEB:
default:
break;
case IHSTAR: /* Affect another star */
if (Rand() < 0.05) {
/* This star supernovas */
snova(ii,jj);
return;
}
top2++;
hits[top2][1]=ii;
hits[top2][2]=jj;
d.galaxy[quadx][quady] -= 1;
d.starkl++;
crmena(1, IHSTAR, 2, ii, jj);
prout(" Новых звезд.");/*novas*/
quad[ii][jj] = IHDOT;
break;
case IHP: /* Destroy planet */
d.newstuf[quadx][quady] -= 1;
d.nplankl++;
crmena(1, IHP, 2, ii, jj);
prout(" уничтожена.");/*destroyed*/
d.plnets[iplnet] = nulplanet;
iplnet = plnetx = plnety = 0;
if (landed == 1) {
finish(FPNOVA);
return;
}
quad[ii][jj] = IHDOT;
break;
case IHB: /* Destroy base */
d.galaxy[quadx][quady] -= 10;
for (i = 1; i <= d.rembase; i++)
if (d.baseqx[i]==quadx && d.baseqy[i]==quady) break;
d.baseqx[i] = d.baseqx[d.rembase];
d.baseqy[i] = d.baseqy[d.rembase];
d.rembase--;
basex = basey = 0;
d.basekl++;
newcnd();
crmena(1, IHB, 2, ii, jj);
prout(" уничтожена.");/*destroyed*/
quad[ii][jj] = IHDOT;
break;
case IHE: /* Buffet ship */
case IHF:
prout("***Корабль отброшен Новой звездой.");/*Starship buffeted by nova*/
if (shldup) {
if (shield >= 2000.0) shield -= 2000.0;
else {
double diff = 2000.0 - shield;
energy -= diff;
shield = 0.0;
shldup = 0;
prout("***Силовые щиты повреждены.");/*Shields knocked out*/
damage[DSHIELD] += 0.005*damfac*Rand()*diff;
}
}
else energy -= 2000.0;
if (energy <= 0) {
finish(FNOVA);
return;
}
/* add in course nova contributes to kicking starship*/
icx += sectx-hits[mm][1];
icy += secty-hits[mm][2];
kount++;
break;
case IHK: /* kill klingon */
deadkl(ii,jj,iquad, ii, jj);
break;
case IHC: /* Damage/destroy big enemies */
case IHS:
case IHR:
for (ll = 1; ll <= nenhere; ll++)
if (kx[ll]==ii && ky[ll]==jj) break;
kpower[ll] -= 800.0; /* If firepower is lost, die */
if (kpower[ll] <= 0.0) {
deadkl(ii, jj, iquad, ii, jj);
break;
}
newcx = ii + ii - hits[mm][1];
newcy = jj + jj - hits[mm][2];
crmena(1, iquad, 2, ii, jj);
proutn(" повреждены");/*damaged*/
if (newcx<1 || newcx>10 || newcy<1 || newcy>10) {
/* can't leave quadrant */
skip(1);
break;
}
iquad1 = quad[newcx][newcy];
if (iquad1 == IHBLANK) {
proutn(", взрыв в точке");/*blasted into*/
crmena(0, IHBLANK, 2, newcx, newcy);
skip(1);
deadkl(ii, jj, iquad, newcx, newcy);
break;
}
if (iquad1 != IHDOT) {
/* can't move into something else */
skip(1);
break;
}
proutn(", отброшен в");/*buffeted to*/
cramlc(2, newcx, newcy);
quad[ii][jj] = IHDOT;
quad[newcx][newcy] = iquad;
kx[ll] = newcx;
ky[ll] = newcy;
kavgd[ll] = sqrt(square(sectx-newcx)+square(secty-newcy));
kdist[ll] = kavgd[ll];
skip(1);
break;
}
}
if (top == top2) break;
bot = top + 1;
top = top2;
}
if (kount==0) return;
/* Starship affected by nova -- kick it away. */
dist = kount*0.1;
if (icx) icx = (icx < 0 ? -1 : 1);
if (icy) icy = (icy < 0 ? -1 : 1);
direc = course[3*(icx+1)+icy+2];
if (direc == 0.0) dist = 0.0;
if (dist == 0.0) return;
Time = 10.0*dist/16.0;
skip(1);
/* prout("Force of nova displaces starship."); */
prout("Сила Новой звезды переместила корабль.");
iattak=2; /* Eliminates recursion problem */
lmove();
Time = 10.0*dist/16.0;
return;
}
void snova(int insx, int insy) {
int comdead, nqx, nqy, nsx, nsy, num, kldead, iscdead;
int nrmdead, npdead;
int insipient=0;
nsx = insx;
nsy = insy;
if (insy== 0) {
if (insx == 1) {
/* NOVAMAX being used */
nqx = probecx;
nqy = probecy;
}
else {
int stars = 0;
/* Scheduled supernova -- select star */
/* logic changed here so that we won't favor quadrants in top
left of universe */
for (nqx = 1; nqx<=8; nqx++) {
for (nqy = 1; nqy<=8; nqy++) {
stars += d.galaxy[nqx][nqy] % 10;
}
}
if (stars == 0) return; /* nothing to supernova exists */
num = Rand()*stars + 1;
for (nqx = 1; nqx<=8; nqx++) {
for (nqy = 1; nqy<=8; nqy++) {
num -= d.galaxy[nqx][nqy] % 10;
if (num <= 0) break;
}
if (num <=0) break;
}
#ifdef DEBUG
if (idebug) {
proutn("Super nova here?");
if (ja()==1) {
nqx = quadx;
nqy = quady;
}
}
#endif
}
if (nqx != quady || nqy != quady || justin != 0) {
/* it isn't here, or we just entered (treat as inroute) */
if (REPORTS) {
skip(1);
/* proutn("Message from Starfleet Command Stardate "); */
proutn("Сообщение от Звездного Командования Звездная Дата ");
cramf(d.date, 0, 1);
skip(1);
proutn(" Сверновая в точке");/*Supernova in*/
cramlc(1, nqx, nqy);
prout("; осторожно.");/*caution advised*/
}
}
else {
/* we are in the quadrant! */
insipient = 1;
num = Rand()* (d.galaxy[nqx][nqy]%10) + 1;
for (nsx=1; nsx < 10; nsx++) {
for (nsy=1; nsy < 10; nsy++) {
if (quad[nsx][nsy]==IHSTAR) {
num--;
if (num==0) break;
}
}
if (num==0) break;
}
}
}
else {
insipient = 1;
}
if (insipient) {
skip(1);
/* prouts("***RED ALERT! RED ALERT!"); */
prouts("***ОПАСНОСТЬ! ОПАСНОСТЬ!");
skip(1);
/* proutn("***Incipient supernova detected at"); */
proutn("***Взрыв сверхновой обнаружен в");
cramlc(2, nsx, nsy);
skip(1);
nqx = quadx;
nqy = quady;
if (square(nsx-sectx) + square(nsy-secty) <= 2.1) {
/* proutn("Emergency override attempts t"); */
proutn("Попытка экстренного перехвата управления");
prouts("***************");
skip(1);
stars();
alldone=1;
}
}
/* destroy any Klingons in supernovaed quadrant */
num=d.galaxy[nqx][nqy];
kldead = num/100;
d.remkl -= kldead; // Moved here to correctly set remaining Klingon count
comdead = iscdead = 0;
if (nqx==d.isx && nqy == d.isy) {
/* did in the Supercommander! */
d.nscrem = d.isx = d.isy = isatb = iscate = 0;
iscdead = 1;
kldead--; /* Get proper kill credit */
future[FSCMOVE] = future[FSCDBAS] = 1e30;
}
if (d.remcom) {
int maxloop = d.remcom, l;
for (l = 1; l <= maxloop; l++) {
if (d.cx[l] == nqx && d.cy[l] == nqy) {
d.cx[l] = d.cx[d.remcom];
d.cy[l] = d.cy[d.remcom];
d.cx[d.remcom] = d.cy[d.remcom] = 0;
d.remcom--;
kldead--;
comdead++;
if (d.remcom==0) future[FTBEAM] = 1e30;
break;
}
}
}
/* destroy Romulans and planets in supernovaed quadrant */
num = d.newstuf[nqx][nqy];
d.newstuf[nqx][nqy] = 0;
nrmdead = num/10;
d.nromrem -= nrmdead;
npdead = num - nrmdead*10;
if (npdead) {
int l;
for (l = 1; l <= inplan; l++)
if (d.plnets[l].x == nqx && d.plnets[l].y == nqy) {
d.plnets[l] = nulplanet;
}
}
/* Destroy any base in supernovaed quadrant */
if (d.rembase) {
int maxloop = d.rembase, l;
for (l = 1; l <= maxloop; l++)
if (d.baseqx[l]==nqx && d.baseqy[l]==nqy) {
d.baseqx[l] = d.baseqx[d.rembase];
d.baseqy[l] = d.baseqy[d.rembase];
d.baseqx[d.rembase] = d.baseqy[d.rembase] = 0;
d.rembase--;
break;
}
}
/* If starship caused supernova, tally up destruction */
if (insx) {
num = d.galaxy[nqx][nqy] % 100;
d.starkl += num % 10;
d.basekl += num/10;
d.killk += kldead;
d.killc += comdead;
d.nromkl += nrmdead;
d.nplankl += npdead;
d.nsckill += iscdead;
}
/* mark supernova in galaxy and in star chart */
if ((quadx == nqx && quady == nqy) || REPORTS)
starch[nqx][nqy] = 1;
d.galaxy[nqx][nqy] = 1000;
/* If supernova destroys last klingons give special message */
if (d.remkl==0 && (nqx != quadx || nqy != quady)) {
skip(2);
if (insx == 0) prout("Счастливчики!");/*Lucky you*/
proutn("Сверновая в точке");/*A supernova in*/
cramlc(1, nqx, nqy);
/* prout(" has just destroyed the last Klingons."); */
prout(" только что уничтожила последних Клингонов.");
finish(FWON);
return;
}
/* if some Klingons remain, continue or die in supernova */
if (alldone) finish(FSNOVAED);
return;
}
+669
View File
@@ -0,0 +1,669 @@
#include "sst.h"
#include <string.h>
#ifndef KOS32
#include <time.h>
#else
#include <kolibrisys.h>
#endif
void dstrct() {
/* Finish with a BANG! */
chew();
if (damage[DCOMPTR] != 0.0) {
/* prout("Computer damaged; cannot execute destruct sequence."); */
prout("Компьютер поврежден; Невозможно запустить самоуничтожение.");
return;
}
skip(1);
/* prouts("---WORKING---"); skip(1);
prout("SELF-DESTRUCT-SEQUENCE-ACTIVATED");
*/ prouts("---ОЖИДАЙТЕ---"); skip(1);
prout("ПРОЦЕДУРА-САМОУНИЧТОЖЕНИЯ-АКТИВИРОВАНА");
prouts(" 10"); skip(1);
prouts(" 9"); skip(1);
prouts(" 8"); skip(1);
prouts(" 7"); skip(1);
prouts(" 6"); skip(1);
/* prout("ENTER-CORRECT-PASSWORD-TO-CONTINUE-");
prout("SELF-DESTRUCT-SEQUENCE-OTHERWISE-");
prout("SELF-DESTRUCT-SEQUENCE-WILL-BE-ABORTED");
*/ prout("ВВЕДИТЕ-ПРАВИЛЬНО-ПАРОЛЬ-ДЛЯ-ПРОДОЛЖЕНИЯ-");
prout("ЗАПУСКА-ПРОЦЕДУРЫ-САМОУНИЧТОЖЕНИЯ-ИНАЧЕ-");
prout("ПРОЦЕДУРА-САМОУНИЧТОЖЕНИЯ-БУДЕТ-АБОРТИРОВАНА");
scan();
chew();
if (strcmp(passwd, citem) != 0) {
/* prouts("PASSWORD-REJECTED;"); skip(1);
prout("CONTINUITY-EFFECTED");
*/ prouts("ПАРОЛЬ-НЕВЕРЕН;"); skip(1);
prout("НЕПРЕРЫВНОСТЬ-ЭФФЕКТИВНА");
skip(1);
return;
}
prouts("ПАРОЛЬ-ПРИНЯТ"); skip(1); /*PASSWORD-ACCEPTED*/
prouts(" 5"); skip(1);
prouts(" 4"); skip(1);
prouts(" 3"); skip(1);
prouts(" 2"); skip(1);
prouts(" 1"); skip(1);
if (Rand() < 0.15) {
prouts("ПРОЩАЙ-ЖЕСТОКИЙ-МИР"); /*GOODBYE-CRUEL-WORLD*/
skip(1);
}
skip(2);
kaboom();
}
void kaboom(void) {
stars();
if (ship==IHE) prouts("***");
prouts("********* Энтропия ");/*Entropy of*/
crmshp();
prouts(" максимизирована *********");/*maximized*/
skip(1);
stars();
skip(1);
if (nenhere != 0) {
double whammo = 25.0 * energy;
int l=1;
while (l <= nenhere) {
if (kpower[l]*kdist[l] <= whammo)
deadkl(kx[l],ky[l], quad[kx[l]][ky[l]], kx[l], ky[l]);
l++;
}
}
finish(FDILITHIUM);
}
void finish(FINTYPE ifin) {
int igotit = 0;
alldone = 1;
skip(3);
/* printf("It is stardate %.1f .\n\n", d.date); */
printf("Звездное время %.1f .\n\n", d.date);
switch (ifin) {
case FWON: // Game has been won
if (d.nromrem != 0)
/* printf("The remaining %d Romulans surrender to Starfleet Command.\n", */
printf("Последние %d ромуланцев сдались на милость Звездного Командования.\n",
d.nromrem);
/* prout("You have smashed the Klingon invasion fleet and saved");
prout("the Federation.");
*/ prout("Вы сломали хребет вторжению клингонов и спасли Федерацию.");
#ifdef CAPTURE
if (alive && brigcapacity-brigfree > 0) { // captured Klingon crew will get transfered to starbase
kcaptured += brigcapacity-brigfree;
/* printf("The %d captured Klingons are transferred to Star Fleet Command.\n", */
printf("Захваченные в плен %d клингонов переданы Звездному Командованию.\n",
brigcapacity-brigfree);
}
#endif
gamewon=1;
if (alive) {
double badpt;
badpt = 5.*d.starkl + casual + 10.*d.nplankl +
45.*nhelp+100.*d.basekl;
if (ship == IHF) badpt += 100.0;
else if (ship == 0) badpt += 200.0;
if (badpt < 100.0) badpt = 0.0; // Close enough!
if (d.date-indate < 5.0 ||
// killsPerDate >= RateMax
(d.killk+d.killc+d.nsckill)/(d.date-indate) >=
0.1*skill*(skill+1.0) + 0.1 + 0.008*badpt) {
skip(1);
/* prout("In fact, you have done so well that Starfleet Command"); */
prout("Вы неплохо справились с заданием, и Звездное Командование");
switch (skill) {
case SNOVICE:
/* prout("promotes you one step in rank from \"Novice\" to \"Fair\"."); */
prout("повышает Вас в звании с \"Новичка\" до \"Салаги\".");
break;
case SFAIR:
/* prout("promotes you one step in rank from \"Fair\" to \"Good\"."); */
prout("повышает Вас в звании с \"Обнадеживающего\" до \"Отличника\".");
break;
case SGOOD:
/* prout("promotes you one step in rank from \"Good\" to \"Expert\"."); */
prout("повышает Вас в звании с \"Отличника\" до \"Эксперта\".");
break;
case SEXPERT:
/* prout("promotes you to Commodore Emeritus."); */
prout("повышает Вас в звании до Коммандера Эмеритус.");
skip(1);
/* prout("Now that you think you're really good, try playing");
prout("the \"Emeritus\" game. It will splatter your ego.");
*/ prout("Теперь, если Вы считаете себе реально крутым, попробуйте");
prout("уровень сложности \"Эмеритус\". Это утихомирит ваше эго.");
break;
case SEMERITUS:
skip(1);
/* prout("Computer- ERROR-ERROR-ERROR-ERROR");
skip(1);
prout(" YOUR-SKILL-HAS-EXCEEDED-THE-CAPACITY-OF-THIS-PROGRAM");
prout(" THIS-PROGRAM-MUST-SURVIVE");
prout(" THIS-PROGRAM-MUST-SURVIVE");
prout(" THIS-PROGRAM-MUST-SURVIVE");
prout(" THIS-PROGRAM-MUST?- MUST ? - SUR? ? -? VI");
skip(1);
prout("Now you can retire and write your own Star Trek game!");
*/ prout("Компьютер- ОШИБКА-ОШИБКА-ОШИБКА-ОШИБКА");
skip(1);
prout(" ВАШ-ОПЫТ-ПРЕВЫШАЕТ-ВОЗМОЖНОСТИ-ЭТОЙ-ПРОГРАММЫ");
prout(" ПРОГРАММА-ДОЛЖНА-ВЫЖИТЬ");
prout(" ПРОГРАММА-ДОЛЖНА-ВЫЖИТЬ");
prout(" ПРОГРАММА-ДОЛЖНА-ВЫЖИТЬ");
prout(" ПРОГРАММА-ДОЛЖНА-?- ДОЛЖНА ? - ВЫЖ? ? -? ИТЬ");
skip(1);
prout("Теперь можете со спокойной душой уйти в отсавку и написать собственную игру Стар Трек!");
skip(1);
break;
}
if (skill > SGOOD) {
if (thawed
#ifdef DEBUG
&& !idebug
#endif
)
/* prout("You cannot get a citation, so..."); */
prout("Вас не запишут в анналы, так что...");
else {
/* prout("Do you want your Commodore Emeritus Citation printed?");
proutn("(You need a 132 column printer.)");
*/ prout("Вы хотите напечатать список своих высказываний, Командер Эмеритус?");
proutn("(Вам потребуется 132-символьный принтер.)");
chew();
if (ja()) {
igotit = 1;
}
}
}
}
// Only grant long life if alive (original didn't!)
skip(1);
/* prout("LIVE LONG AND PROSPER."); */
prout("ДОЛГОЙ ВАМ ЖИЗНИ И ПРОЦВЕТАНИЯ.");
}
score(0);
if (igotit != 0) plaque();
return;
case FDEPLETE: // Federation Resources Depleted
/* prout("Your time has run out and the Federation has been");
prout("conquered. Your starship is now Klingon property,");
prout("and you are put on trial as a war criminal. On the");
proutn("basis of your record, you are ");
*/ prout("Ваше время вышло и Федерация была захвачена.");
prout("Ваш корабль теперь трофей клингонов,");
prout("и Вас будут судить как военного преступника.");
proutn("Рассмотрев ваши действия, Вы ");
if (d.remkl*3.0 > inkling) {
prout("оправданы.");/*aquitted*/
skip(1);
prout("ДОЛГОЙ ВАМ ЖИЗНИ И ПРОЦВЕТАНИЯ.");/*LIVE LONG AND PROSPER*/
}
else {
/* prout("found guilty and");
prout("sentenced to death by slow torture.");
*/ prout("признаны виновным");
prout("и приговорены к смерти под пытками.");
alive = 0;
}
score(0);
return;
case FLIFESUP:
/* prout("Your life support reserves have run out, and");
prout("you die of thirst, starvation, and asphyxiation.");
prout("Your starship is a derelict in space.");
*/ prout("У вас кончились запасы воздуха и пищи и");
prout("вы с командой умерли от голода и жажды, задыхаясь.");
prout("Ваш мертвый корабль дрейфует в космосе.");
break;
case FNRG:
/* prout("Your energy supply is exhausted.");
skip(1);
prout("Your starship is a derelict in space.");
*/ prout("У корабля кончились запасы энергии.");
skip(1);
prout("Ваш мертвый корабль дрейфует в космосе.");
break;
case FBATTLE:
/* proutn("The ");
crmshp();
prout("has been destroyed in battle.");
skip(1);
prout("Dulce et decorum est pro patria mori.");
*/ proutn("Ваш корабль ");
crmshp();
prout("был уничтожен в бою.");
skip(1);
prout("Dulce et decorum est pro patria mori.");
prout("/Сладка и прекрасна за родину смерть./");
break;
case FNEG3:
/* prout("You have made three attempts to cross the negative energy");
prout("barrier which surrounds the galaxy.");
skip(1);
prout("Your navigation is abominable.");
*/ prout("Вы сделали три попытки пересечь барьер отрицательной энергии");
prout(" окружающий галактику.");
skip(1);
prout("Вы ужасный навигатор.");
score(0);
return;
case FNOVA:
/* prout("Your starship has been destroyed by a nova.");
prout("That was a great shot.");
*/ prout("Ваш корабль был уничтожен новой звездой.");
prout("Хорошая попытка.");
skip(1);
break;
case FSNOVAED:
/* proutn("The ");
crmshp();
prout(" has been fried by a supernova.");
prout("...Not even cinders remain...");
*/ proutn("Ваш корабль ");
crmshp();
prout(" был уничтожен сверхновой.");
prout("...И не осталось даже пепла...");
break;
case FABANDN:
/* prout("You have been captured by the Klingons. If you still");
prout("had a starbase to be returned to, you would have been");
prout("repatriated and given another chance. Since you have");
prout("no starbases, you will be mercilessly tortured to death.");
*/ prout("Вы были захвачены клингонами. Если бы у вас ");
prout("осталась хоть одна станция для возвращения, вы могли бы");
prout("получить второй шанс. Но поскольку станций больше нет,");
prout("вас беспощадно запытают до смерти.");
break;
case FDILITHIUM:
/* prout("Your starship is now an expanding cloud of subatomic particles"); */
prout("Ваш корабль превратился в облако субатомных частиц");
break;
case FMATERIALIZE:
/* prout("Starbase was unable to re-materialize your starship.");
prout("Sic transit gloria muntdi");
*/ prout("Станция не смогла обратно материализовать ваш корабль.");
prout("Sic transit gloria muntdi");
prout("/Так проходит мирская слава/");
break;
case FPHASER:
/* proutn("The ");
crmshp();
prout(" has been cremated by its own phasers.");
*/ proutn("Ваш корабль ");
crmshp();
prout(" самоуничтожился огнем собственных фазеров.");
break;
case FLOST:
/* prout("You and your landing party have been");
prout("converted to energy, dissipating through space.");
*/ prout("Вы и группа высадки ");
prout("превратились в чистую энергию, распыленную в космосе.");
break;
case FMINING:
/* prout("You are left with your landing party on");
prout("a wild jungle planet inhabited by primitive cannibals.");
skip(1);
prout("They are very fond of \"Captain Kirk\" soup.");
skip(1);
proutn("Without your leadership, the ");
crmshp();
prout(" is destroyed.");
*/ prout("Вы остались вместе с группой высадки");
prout("на дикой планете, населенной доисторическими каннибалами.");
skip(1);
prout("Они очень любят суп \"Капитан Кирк\".");
skip(1);
proutn("Без Вашего командования, корабль ");
crmshp();
prout(" был уничтожен.");
break;
case FDPLANET:
/* prout("You and your mining party perish.");
skip(1);
prout("That was a great shot.");
*/ prout("Вы бесследно пропали вместе с шахтерами.");
skip(1);
prout("Это была хорошая попытка.");
skip(1);
break;
case FSSC:
/* prout("The Galileo is instantly annihilated by the supernova."); */
prout("Галилео был мгновенно аннигилирован суперновой.");
// no break;
case FPNOVA:
/* prout("You and your mining party are atomized.");
skip(1);
proutn("Mr. Spock takes command of the ");
crmshp();
prout(" and");
prout("joins the Romulans, reigning terror on the Federation.");
*/ prout("Вы с группой шахтеров распались на атомы.");
skip(1);
proutn("Мистер Спок принял командование ");
crmshp();
prout(" и");
prout("присоединился к ромуланцам, сея разрушение и террор по всей Федерации.");
break;
case FSTRACTOR:
/* prout("The shuttle craft Galileo is also caught,");
prout("and breaks up under the strain.");
skip(1);
prout("Your debris is scattered for millions of miles.");
proutn("Without your leadership, the ");
crmshp();
prout(" is destroyed.");
*/ prout("Шаттл Галилео попал в поле действия силового луча,");
prout("и был разорван силами тяготения.");
skip(1);
prout("Ваши обломки рассеяны на миллионы миль.");
proutn("Без Вашего командования, корабль ");
crmshp();
prout(" был уничтожен.");
break;
case FDRAY:
/* prout("The mutants attack and kill Spock.");
prout("Your ship is captured by Klingons, and");
prout("your crew is put on display in a Klingon zoo.");
*/ prout("Мутанты атаковали и убили Спока.");
prout("Ваш корабль был захвачен клингонами и теперь");
prout("ваша команда представлена в клингонском зоопарке.");
break;
case FTRIBBLE:
/* prout("Tribbles consume all remaining water,");
prout("food, and oxygen on your ship.");
skip(1);
prout("You die of thirst, starvation, and asphyxiation.");
prout("Your starship is a derelict in space.");
*/ prout("Трибблы сожрали всю оставшуюся воду,");
prout("еду и кислород на вашем корабле.");
skip(1);
prout("Вы с командой умерли от голода и жажды, задыхаясь.");
prout("Ваш мертвый корабль дрейфует в космосе.");
break;
case FHOLE:
/* prout("Your ship is drawn to the center of the black hole.");
prout("You are crushed into extremely dense matter.");
*/ prout("Вас затянуло в центр черной дыры.");
prout("Вы теперь исключительно маленькая и сверхтвердая пылинка.");
break;
#ifdef CLOAKING
case FCLOAK:
ncviol++;
/* prout("You have violated the Treaty of Algeron.");
prout("The Romulan Empire can never trust you again.");
*/ prout("Вы нарушили Алгеронское Соглашение.");
prout("Ромуланская Империя никогда больше не поверит вам.");
break;
#endif
}
#ifdef CLOAKING
if (ifin!=FWON && ifin!=FCLOAK && iscloaked!=0) {
/* prout("Your ship was cloaked so your subspace radio did not receive anything.");
prout("You may have missed some warning messages.");
*/ prout("Ваш корабль был невидим, так что подпространсвенное радио не работало.");
prout("Вы могли пропустить некоторые предупредительные сообщения.");
skip(1);
}
#endif
if (ship==IHF) ship= 0;
else if (ship == IHE) ship = IHF;
alive = 0;
if (d.remkl != 0) {
double goodies = d.remres/inresor;
double baddies = (d.remkl + 2.0*d.remcom)/(inkling+2.0*incom);
if (goodies/baddies >= 1.0+0.5*Rand()) {
/* prout("As a result of your actions, a treaty with the Klingon");
prout("Empire has been signed. The terms of the treaty are");
*/ prout("В результате ваших дествий, было подписано мирное");
prout("соглашение с клингонами. Условия соглашения были");
if (goodies/baddies >= 3.0+Rand()) {
/* prout("favorable to the Federation.");
skip(1);
prout("Congratulations!");
*/ prout("выгодными для Федерации.");
skip(1);
prout("Поздравляем!");
}
else
/* prout("highly unfavorable to the Federation."); */
prout("исключительно невыгодными для Федерации.");
}
else
/* prout("The Federation will be destroyed."); */
prout("Федерация будет уничтожена.");
}
else {
/* prout("Since you took the last Klingon with you, you are a");
prout("martyr and a hero. Someday maybe they'll erect a");
prout("statue in your memory. Rest in peace, and try not");
prout("to think about pigeons.");
*/ prout("Вы забрали последнего клингона с собой на тот свет.");
prout("Ваша героическая жертва не будет забыта и, возможно, потомки даже");
prout("возведут статю в Вашу честь. Покойтесь с миром и старайтесь");
prout("не думать о голубях.");
gamewon = 1;
}
score(0);
}
void score(int inGame) {
double timused = d.date - indate;
int ithperd, iwon, klship;
int dnromrem = d.nromrem; // Leave global value alone
if (!inGame) pause(0);
iskill = skill;
if ((timused == 0 || d.remkl != 0) && timused < 5.0) timused = 5.0;
perdate = (d.killc + d.killk + d.nsckill)/timused;
ithperd = 500*perdate + 0.5;
iwon = 0;
if (gamewon) iwon = 100*skill;
if (ship == IHE) klship = 0;
else if (ship == IHF) klship = 1;
else klship = 2;
if (gamewon == 0 || inGame) dnromrem = 0; // None captured if no win or if still in the game
iscore = 10*d.killk + 50*d.killc + ithperd + iwon
- 100*d.basekl - 100*klship - 45*nhelp -5*d.starkl - casual
+ 20*d.nromkl + 200*d.nsckill - 10*d.nplankl + dnromrem;
#ifdef CLOAKING
iscore -= 100*ncviol;
#endif
#ifdef CAPTURE
iscore += 3*kcaptured;
#endif
if (alive == 0) iscore -= 200;
skip(2);
/* if (inGame) prout("Your score so far --");
else prout("Your score --");
*/ if (inGame) prout("На данный момент ваши баллы --");
else prout("Ваши баллы --");
if (d.nromkl)
/* printf(d.nromkl> 1 ? "%6d Romulan ships destroyed %5d\n" : "%6d Romulan ship destroyed %5d\n", */
printf(d.nromkl> 1 ? "%6d ромуланских кораблей уничтожено %5d\n" : "%6d ромуланских кораблей уничтожено %5d\n",
d.nromkl, 20*d.nromkl);
if (dnromrem)
/* printf(dnromrem > 1 ? "%6d Romulan ships captured %5d\n" : "%6d Romulan ship captured %5d\n", */
printf(dnromrem > 1 ? "%6d ромуланских кораблей захвачено %5d\n" : "%6d ромуланских кораблей захвачено %5d\n",
dnromrem, dnromrem);
if (d.killk)
/* printf(d.killk > 1 ? "%6d ordinary Klingon ships destroyed %5d\n" : "%6d ordinary Klingon ship destroyed %5d\n", */
printf(d.killk > 1 ? "%6d боевых кораблей клингонов уничтожено %5d\n" : "%6d боевых кораблей клингонов уничтожено %5d\n",
d.killk, 10*d.killk);
if (d.killc)
/* printf(d.killc > 1 ? "%6d Klingon Commander ships destroyed %5d\n" : "%6d Klingon Commander ship destroyed %5d\n", */
printf(d.killc > 1 ? "%6d клингонских Командеров уничтожено %5d\n" : "%6d клингонских Командеров уничтожено %5d\n",
d.killc, 50*d.killc);
if (d.nsckill)
/* printf("%6d Super-Commander ship destroyed %5d\n", */
printf("%6d СуперКоммандеров уничтожено %5d\n",
d.nsckill, 200*d.nsckill);
if (ithperd)
/* printf("%6.2f Klingons per stardate %5d\n", */
printf("%6.2f клингонов в среднем за дату %5d\n",
perdate, ithperd);
#ifdef CAPTURE
if (kcaptured)
/* printf(kcaptured > 1 ? "%6d Klingons captured %5d\n" : "%6d Klingon captured %5d\n", */
printf(kcaptured > 1 ? "%6d клингонов захвачено %5d\n" : "%6d клингонов захвачено %5d\n",
kcaptured, 3*kcaptured);
#endif
if (d.starkl)
/* printf(d.starkl > 1 ? "%6d stars destroyed by your action %5d\n" : "%6d star destroyed by your action %5d\n", */
printf(d.starkl > 1 ? "%6d звезд уничтожено вашими действиями %5d\n" : "%6d звезд уничтожено вашими действиями %5d\n",
d.starkl, -5*d.starkl);
if (d.nplankl)
/* printf(d.nplankl > 1 ? "%6d planets destroyed by your action %5d\n" : "%6d planet destroyed by your action %5d\n", */
printf(d.nplankl > 1 ? "%6d планет уничтожено вашими действиями %5d\n" : "%6d планет уничтожено вашими действиями %5d\n",
d.nplankl, -10*d.nplankl);
if (d.basekl)
printf(d.basekl > 1 ? "%6d станций уничтожено вашими действиями %5d\n" : "%6d станций уничтожено вашими действиями %5d\n",
d.basekl, -100*d.basekl);
if (nhelp)
printf(nhelp > 1 ? "%6d вызовов о помощи со станций %5d\n" : "%6d вызовов о помощи со станций %5d\n",
nhelp, -45*nhelp);
if (casual)
printf(casual > 1 ? "%6d потерь среди экипажа %5d\n" : "%6d потерь среди экипажа %5d\n",
casual, -casual);
if (klship)
printf(klship > 1 ? "%6d кораблей потеряно или уничтожено %5d\n" : "%6d кораблей потеряно или уничтожено %5d\n",
klship, -100*klship);
#ifdef CLOAKING
if (ncviol>0)
printf(ncviol > 1 ? "%6d нарушений Алгеронского соглашения %5d\n" : "%6d нарушений Алгеронского соглашения %5d\n",
ncviol, -100*ncviol);
#endif
if (alive==0)
/* prout("Penalty for getting yourself killed -200"); */
prout("Штраф за то, что Вы дали себя убить -200");
if (gamewon) {
skip(1);
/* proutn("Bonus for winning "); */
proutn("Бонус за победу ");
switch (skill) {
/* case SNOVICE: proutn("Novice game "); break;
case SFAIR: proutn("Fair game "); break;
case SGOOD: proutn("Good game "); break;
case SEXPERT: proutn("Expert game "); break;
case SEMERITUS: proutn("Emeritus game"); break;
*/ case SNOVICE: proutn("Игра Новичка "); break;
case SFAIR: proutn("Игра Салаги "); break;
case SGOOD: proutn("Игра Отличника "); break;
case SEXPERT: proutn("Игра Эксперта "); break;
case SEMERITUS: proutn("Игра Эмеритуса"); break;
}
printf(" %5d\n", iwon);
}
skip(2);
printf("Итоговый балл %5d\n", iscore);/*TOTAL SCORE*/
/* if (inGame && skill < SGOOD) printf("REMEMBER--The score doesn't really matter until the mission is accomplished!\n"); */
if (inGame && skill < SGOOD) printf("ПОМНИТЕ--Баллы ничего не значат, пока миссия не окончена!\n");
}
void plaque(void) {
FILE *fp=NULL;
#ifndef KOS32
time_t t;
#else
int kos_date, kos_time;
#endif
char *timestring;
int nskip;
char winner[128];
skip(2);
while (fp == NULL) {
/* printf("File or device name for your plaque:"); */
printf("Введите имя файла для ваших достижений:");
#ifndef KOS32
fgets(winner, 128, stdin);
#else
gets(winner);
#endif
winner[strlen(winner)-1] = '\0';
fp = fopen(winner, "w");
if (fp==NULL) {
printf("Неверное имя.\n");/*Invalid name*/
}
}
/* printf("Enter name to go on plaque (up to 30 characters):"); */
printf("Введите имя для памятного значка (максимум 30 символов):");
#ifndef KOS32
fgets(winner, 128, stdin);
#else
gets(winner);
#endif
winner[strlen(winner)-1] = '\0';
winner[30] = '\0';
nskip = 64 - strlen(winner)/2;
fprintf(fp,"\n\n\n\n");
/* --------DRAW ENTERPRISE PICTURE. */
fprintf(fp, " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n" );
fprintf(fp, " EEE E : : : E\n" );
fprintf(fp, " EE EEE E : : NCC-1701 : E\n");
fprintf(fp, " EEEEEEEEEEEEEEEE EEEEEEEEEEEEEEE E : : : E\n");
fprintf(fp, " E E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n");
fprintf(fp, " EEEEEEEEE EEEEEEEEEEEEE E E\n");
fprintf(fp, " EEEEEEE EEEEE E E E E\n");
fprintf(fp, " EEE E E E E\n");
fprintf(fp, " E E E E\n");
fprintf(fp, " EEEEEEEEEEEEE E E\n");
fprintf(fp, " EEE : EEEEEEE EEEEEEEE\n");
fprintf(fp, " :E : EEEE E\n");
fprintf(fp, " .-E -:----- E\n");
fprintf(fp, " :E : E\n");
fprintf(fp, " EE : EEEEEEEE\n");
fprintf(fp, " EEEEEEEEEEEEEEEEEEEEEEE\n");
fprintf(fp, "\n\n\n");
fprintf(fp, " U. S. S. ENTERPRISE\n");
fprintf(fp, "\n\n\n\n");
/* fprintf(fp, " For demonstrating outstanding ability as a starship captain\n"); */
fprintf(fp, " За проявленные выдающиеся достижения в должности капитана космического корабля\n");
fprintf(fp, "\n");
/* fprintf(fp, " Starfleet Command bestows to you\n"); */
fprintf(fp, " Звездное Командование представляет Вас\n");
fprintf(fp, "\n");
fprintf(fp,"%*s%s\n\n", nskip, "", winner);
/* fprintf(fp, " the rank of\n\n");
fprintf(fp, " \"Commodore Emeritus\"\n\n");
*/ fprintf(fp, " к званию\n\n");
fprintf(fp, " \"Командор Эмеритус\"\n\n");
fprintf(fp, " ");
switch (iskill) {
/* case SEXPERT: fprintf(fp," Expert level\n\n"); break;
case SEMERITUS: fprintf(fp,"Emeritus level\n\n"); break;
default: fprintf(fp," Cheat level\n\n"); break;
*/ case SEXPERT: fprintf(fp," уровень Эксперта\n\n"); break;
case SEMERITUS: fprintf(fp,"уровень Эмеритуса\n\n"); break;
default: fprintf(fp," обычный читерский уровень\n\n"); break;
}
#ifndef KOS32
t = time(NULL);
timestring = ctime(&t);
/* fprintf(fp, " This day of %.6s %.4s, %.8s\n\n", */
fprintf(fp, " Этот день %.6s %.4s, %.8s\n\n",
timestring+4, timestring+20, timestring+11);
#else
kos_date = _ksys_get_date();
kos_time = _ksys_get_system_clock();
/* fprintf(fp, " This day of %02i/%02i/%02i %02i:%02i:%02i\n\n", */
fprintf(fp, " Этот день %02i/%02i/%02i %02i:%02i:%02i\n\n",
kos_date >> 16, (kos_date & 0xFF00) >> 8, (kos_date & 0xFF) + 2000,
kos_time & 0xFF, (kos_time & 0xFF00) >> 8, kos_time >> 16 );
#endif
/* fprintf(fp," Your score: %d\n\n", iscore);
fprintf(fp," Klingons per stardate: %.2f\n", perdate);
*/ fprintf(fp," Ваш балл: %d\n\n", iscore);
fprintf(fp," Клингонов на дату: %.2f\n", perdate);
fclose(fp);
}
+19
View File
@@ -0,0 +1,19 @@
# CFLAGS= -O -DSCORE -DCAPTURE -DCLOAKING -Wno-unused-result
CFLAGS= -O -Wno-unused-result -DWINDOWS
CC=gcc
.c.o:
$(CC) $(CFLAGS) -c $<
OFILES= sst.o finish.o reports.o setup.o osx.o moving.o battle.o events.o ai.o planets.o
HFILES= sst.h
sst: $(OFILES)
gcc -o sst $(OFILES) -lm
clean:
rm $(OFILES)
$(OFILES): $(HFILES)
File diff suppressed because it is too large. Load diff
+47
View File
@@ -0,0 +1,47 @@
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#ifndef WINDOWS
#ifndef KOS32
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
#endif
#endif
void randomize(void) {
srand((int)time(NULL));
}
#if !defined(KOS32) && !defined(__TINYC__)
int max(int a, int b) {
if (a > b) return a;
return b;
}
int min(int a, int b) {
if (a < b) return a;
return b;
}
#endif
#ifndef WINDOWS
#ifndef KOS32
int // <editor-fold defaultstate="collapsed" desc="comment">
getch// </editor-fold>
(void) {
char chbuf[1];
struct termios oldstate, newstate;
fflush(stdout);
tcgetattr(0, &oldstate);
newstate = oldstate;
newstate.c_lflag &= ~ICANON;
newstate.c_lflag &= ~ECHO;
tcsetattr(0, TCSANOW, &newstate);
read(0, &chbuf, 1);
tcsetattr(0, TCSANOW, &oldstate);
return chbuf[0];
}
#endif
#endif
+660
View File
@@ -0,0 +1,660 @@
#include "sst.h"
static char classes[4][2]={"","M","N","O"};
static int height;
static int consumeTime(void) {
/* I think most of this avoidance was caused by overlay scheme.
Let's see what happens if all events can occur here */
// double asave;
ididit = 1;
#if 0
/* Don't wory about this */
if (future[FTBEAM] <= d.date+Time && d.remcom != 0 && condit != IHDOCKED) {
/* We are about to be tractor beamed -- operation fails */
return 1;
}
#endif
// asave = future[FSNOVA];
// future[FSNOVA] = 1e30; /* defer supernovas */
events(); /* Used to avoid if future[FSCMOVE] within time */
// future[FSNOVA] = asave;
/*fails if game over, quadrant super-novas or we've moved to new quadrant*/
if (alldone || d.galaxy[quadx][quady] == 1000 || justin != 0) return 1;
return 0;
}
void preport(void) {
int iknow = 0, i;
skip(1);
chew();
/* prout("Spock- \"Planet report follows, Captain.\""); */
prout("Спок- \"Отчет по планете, Капитан.\"");
skip(1);
for (i = 1; i <= inplan; i++) {
if (d.plnets[i].known
#ifdef DEBUG
|| ( idebug && d.plnets[i].x !=0)
#endif
) {
iknow = 1;
#ifdef DEBUG
if (idebug && d.plnets[i].known==0) proutn("(Unknown) ");
#endif
cramlc(1, d.plnets[i].x, d.plnets[i].y);
proutn(" класс ");/*class*/
proutn(classes[d.plnets[i].pclass]);
proutn(" ");
if (d.plnets[i].crystals == 0) proutn("нет ");/*no*/
/* prout("dilithium crystals present."); */
prout("дилитиевых кристаллов обнаружено.");
if (d.plnets[i].known==2)
/* prout(" Shuttle Craft Galileo on surface."); */
prout(" Шаттл Галилео на поверхности.");
}
}
/* if (iknow==0) prout("No information available."); */
if (iknow==0) prout("Информация отсутствует.");
}
void orbit(void) {
double asave;
skip(1);
chew();
ididit=0;
if (inorbit!=0) {
/* prout("Already in standard orbit."); */
prout("Уже находимся на стандартной орбите.");
return;
}
if (damage[DWARPEN] != 0 && damage[DIMPULS] != 0) {
/* prout("Both warp and impulse engines damaged."); */
prout("Повреждены и варп- и импульсные двигатели.");
return;
}
if (plnetx == 0 || abs(sectx-plnetx) > 1 || abs(secty-plnety) > 1) {
crmshp();
/* prout(" not adjacent to planet.\n"); */
prout(" не рядом с планетой.\n");
return;
}
Time = 0.02+0.03*Rand();
/* prout("Helmsman Sulu- \"Entering standard orbit, Sir.\""); */
prout("Рулевой Сулу- \"Выходим на стандартную орбиту, Сэр.\"");
newcnd();
if (consumeTime()) return;
/* proutn("Sulu- \"Entered orbit at altitude "); */
proutn("Сулу- \"Вышли на орбиту на высоте ");
cramf(height = (1400.+7200.*Rand()), 0, 2);
prout(" километров.\"");/*kilometers*/
inorbit = 1;
return;
}
void sensor(void) {
skip(1);
chew();
if (damage[DSRSENS] != 0.0) {
/* prout("Short range sensors damaged."); */
prout("Сенсоры ближнего радиуса действия повреждены.");
return;
}
if (plnetx == 0) {
/* prout("No planet in this quadrant."); */
prout("В этом квадранте нет планет.");
return;
}
/* proutn("Spock- \"Sensor scan for"); */
proutn("Спок- \"Сканирование");
cramlc(1, quadx, quady);
prout("-");
skip(1);
/* proutn(" Planet at"); */
proutn(" Планета в");
cramlc(2, plnetx, plnety);
/* proutn(" is of class "); */
proutn(" класса ");
proutn(classes[d.plnets[iplnet].pclass]);
prout(".");
if (d.plnets[iplnet].known==2)
/* prout(" Sensors show Galileo still on surface."); */
prout(" Сенсоры показывают, что Галилео еще на поверхности.");
/* proutn(" Readings indicate"); */
proutn(" Полученные данные показывают");
if (d.plnets[iplnet].crystals == 0) proutn(" нет"); /*no*/
else proutn(" наличие");
/* prout(" dilithium crystals present.\""); */
prout(" дилитиевых кристаллов.\"");
if (d.plnets[iplnet].known == 0) d.plnets[iplnet].known = 1;
return;
}
void beam(void) {
chew();
skip(1);
if (damage[DTRANSP] != 0) {
/* prout("Transporter damaged."); */
prout("Транспортатор поврежден.");
if (damage[DSHUTTL]==0 && (d.plnets[iplnet].known==2 || iscraft == 1)) {
skip(1);
/* prout("Spock- \"May I suggest the shuttle craft, Sir?\" "); */
prout("Спок- \"Могу предложить использовать шаттл, Сэр?\" ");
if (ja() != 0) shuttle();
}
return;
}
if (inorbit==0) {
crmshp();
/* prout(" not in standard orbit."); */
prout(" не находимся на стандартной орбите.");
return;
}
if (shldup!=0) {
/* prout("Impossible to transport through shields."); */
prout("Транспортировка невозможна сквозь щиты.");
return;
}
if (d.plnets[iplnet].known==0) {
/* prout("Spock- \"Captain, we have no information on this planet");
prout(" and Starfleet Regulations clearly state that in this situation");
prout(" you may not go down.\"");
*/ prout("Спок- \"Капитан, у нас нет информации по данной планете");
prout(" и Устав Звездного Флота однозначно описывает данную ситуацию - ");
prout(" высадка запрещена.\"");
return;
}
if (landed==1) {
/* Coming from planet */
if (d.plnets[iplnet].known==2) {
/* proutn("Spock- \"Wouldn't you rather take the Galileo?\" "); */
proutn("Спок- \"Может Вы возьмете Галилео?\" ");
if (ja() != 0) {
chew();
return;
}
/* prout("Your crew hides the Galileo to prevent capture by aliens."); */
prout("Ваша команда спрятала Галилео от аборигенов.");
}
/* prout("Landing party assembled, ready to beam up.");
skip(1);
prout("Kirk whips out communicator...");
prouts("BEEP BEEP BEEP");
skip(2);
prout("\"Kirk to enterprise- Lock on coordinates...energize.\"");
*/ prout("Группа высадки готова к транспортировке.");
skip(1);
prout("Кирк включил коммуникатор...");
prouts("БИИП БИИП БИИП");
skip(2);
prout("\"Кирк - Энтерпрайзу - Захват по координатам...включайте.\"");
}
else {
/* Going to planet */
if (d.plnets[iplnet].crystals==0) {
/* prout("Spock- \"Captain, I fail to see the logic in");
prout(" exploring a planet with no dilithium crystals.");
proutn(" Are you sure this is wise?\" ");
*/ prout("Спок- \"Капитан, не вижу никакой логики в том,");
prout(" чтобы исследовать планету без дилитиевых кристаллов.");
proutn(" Вы уверены, что это мудро?\" ");
if (ja()==0) {
chew();
return;
}
}
/* prout("Scotty- \"Transporter room ready, Sir.\"");
skip(1);
prout("Kirk, and landing party prepare to beam down to planet surface.");
skip(1);
prout("Kirk- \"Energize.\"");
*/ prout("Скотти- \"Транспортаторная готова, Сэр.\"");
skip(1);
prout("Кирк и группа высадки готова к транспортации на поверхность.");
skip(1);
prout("Кирк- \"Включай.\"");
}
skip(1);
/* prouts("WWHOOOIIIIIRRRRREEEE.E.E. . . . . . ."); */
prouts("УУУУУИИИИЙЙЙЙЙЕЕЕ.Е.Е. . . . . . .");
skip(2);
if (Rand() > 0.98) {
/* prouts("BOOOIIIOOOIIOOOOIIIOIING . . ."); */
prouts("БУУИИИООИИИНГ . . .БЛЯМ");
skip(2);
/* prout("Scotty- \"Oh my God! I've lost them.\""); */
prout("Скотти- \"Боже мой! Я потерял их.\"");
finish(FLOST);
return;
}
/* prouts(". . . . . . .E.E.EEEERRRRRIIIIIOOOHWW"); */
prouts(". . . . . . .Е.Е.Е.ЕЕЕЕЕРРРРРЙЙЙЙИИИИОООООПС");
skip(2);
prout("Транспортировка завершена.");/*Transport complete*/
landed = -landed;
if (landed==1 && d.plnets[iplnet].known==2) {
/* prout("The shuttle craft Galileo is here!"); */
prout("Шаттл Галилео на месте!");
}
if (landed!=1 && imine==1) {
icrystl = 1;
cryprob = 0.05;
}
imine = 0;
return;
}
void mine(void) {
ididit = 0;
skip(1);
chew();
if (landed!= 1) {
/* prout("Mining party not on planet."); */
prout("Шахтеры не находятся на планете.");
return;
}
if (d.plnets[iplnet].crystals == 0) {
/* prout("No dilithium crystals on this planet."); */
prout("На планете нет дилитиевых кристаллов.");
return;
}
if (imine == 1) {
/* prout("You've already mined enough crystals for this trip."); */
prout("Вы уже добыли максимум кристаллов для одного рейса.");
return;
}
if (icrystl == 1 && cryprob == 0.05) {
/* proutn("With all those fresh crystals aboard the "); */
proutn("У нас полно свежих кристаллов на борту ");
crmshp();
skip(1);
/* prout("there's no reason to mine more at this time."); */
prout("Нет никакого смысла добывать еще.");
return;
}
Time = (0.1+0.2*Rand())*d.plnets[iplnet].pclass;
if (consumeTime()) return;
/* prout("Mining operation complete."); */
prout("Операция добычи кристаллов завершена.");
imine = 1;
return;
}
void usecrystals(void) {
skip(1);
chew();
if (icrystl!=1) {
/* prout("No dilithium crystals available."); */
prout("Дилитиевые кристаллы отсутствуют.");
return;
}
if (energy >= 1000) {
/* prout("Spock- \"Captain, Starfleet Regulations prohibit such an operation");
prout(" except when condition Yellow exists.");
*/ prout("Спок- \"Капитан, Устав Звездного Флота запрещает такие операции");
prout(" кроме как при желтом коде опасности.");
return;
}
/* prout("Spock- \"Captain, I must warn you that loading");
prout(" raw dilithium crystals into the ship's power");
prout(" system may risk a severe explosion.");
proutn(" Are you sure this is wise?\" ");
*/ prout("Спок- \"Капитан, я должен предупредить Вас - ");
prout(" загрузка в энергосистему необработанных дилитиевых");
prout(" кристаллов может привести к взрыву.");
proutn(" Вы уверены?\" ");
if (ja()==0) {
chew();
return;
}
skip(1);
/* prout("Engineering Officer Scott- \"(GULP) Aye Sir.");
prout(" Mr. Spock and I will try it.\"");
skip(1);
prout("Spock- \"Crystals in place, Sir.");
prout(" Ready to activate circuit.\"");
skip(1);
prouts("Scotty- \"Keep your fingers crossed, Sir!\"");
*/ prout("Инженер-офицер Скотт \"(Сглотнув) Так точно, Сэр.");
prout(" Мистер Спок и я попробуем сделать это.\"");
skip(1);
prout("Спок- \"Кристаллы загружены, Сэр.");
prout(" Готовы к активации реактора.\"");
skip(1);
prouts("Скотти- \"Скрестите пальцы на удачу, Сэр!\"");
skip(1);
if (Rand() <= cryprob) {
/* prouts(" \"Activating now! - - No good! It's***"); */
prouts(" \"Активация произведена! - - Что то не так! Это же***");
skip(2);
/* prouts("***RED ALERT! RED A*L********************************"); */
prouts("***ОПАСНОСТЬ! ОПА*СНО********************************");
skip(1);
stars();
/* prouts("****************** KA-BOOM!!!! *******************"); */
prouts("****************** КА-БУМ!!!! *******************");
skip(1);
kaboom();
return;
}
energy += 5000.0*(1.0 + 0.9*Rand());
/* prouts(" \"Activating now! - - ");
prout("The instruments");
prout(" are going crazy, but I think it's");
prout(" going to work!! Congratulations, Sir!\"");
*/ prouts(" \"Активация произведена! - - ");
prout("Панель приборов");
prout(" всбесилась, но я думаю, что все");
prout(" будет работать!! Поздравляю, Сэр!\"");
cryprob *= 2.0;
return;
}
void shuttle(void) {
chew();
skip(1);
ididit = 0;
if(damage[DSHUTTL] != 0.0) {
if (damage[DSHUTTL] == -1.0) {
if (inorbit && d.plnets[iplnet].known == 2)
/* prout("Ye Faerie Queene has no shuttle craft bay to dock it at."); */
prout("Королева Фей не имеет посадочного отсека для шаттла.");
else
/* prout("Ye Faerie Queene had no shuttle craft."); */
prout("На Королеве Фей нет шаттла.");
}
else if (damage[DSHUTTL] > 0)
/* prout("The Galileo is damaged."); */
prout("Галилео проврежден.");
/* else prout("Shuttle craft is now serving Big Mac's."); */
else prout("Шаттл сейчас развозит БигМаки.");
return;
}
if (inorbit==0) {
crmshp();
/* prout(" not in standard orbit."); */
prout(" не находимся на стандартной орбите.");
return;
}
if ((d.plnets[iplnet].known != 2) && iscraft != 1) {
/* prout("Shuttle craft not currently available."); */
prout("Шаттл в данный момент недоступен.");
return;
}
if (landed==-1 && d.plnets[iplnet].known==2) {
/* prout("You will have to beam down to retrieve the shuttle craft."); */
prout("Вам нужно активировать силовой луч, чтобы поднять шаттл с поверхности.");
return;
}
if (shldup!=0 || condit == IHDOCKED) {
/* prout("Shuttle craft cannot pass through shields."); */
prout("Шаттл невозможно транспортировать сквозь щиты.");
return;
}
if (d.plnets[iplnet].known==0) {
/* prout("Spock- \"Captain, we have no information on this planet");
prout(" and Starfleet Regulations clearly state that in this situation");
prout(" you may not fly down.\"");
*/ prout("Спок- \"Капитан, у нас нет информации по данной планете");
prout(" и Устав Звездного Флота однозначно описывает данную ситуацию - ");
prout(" высадка запрещена.\"");
return;
}
Time = 3.0e-5*height;
if (Time >= 0.8*d.remtime) {
/* prout("First Officer Spock- \"Captain, I compute that such");
prout(" a maneuver would require approximately ");
*/ prout("Первый офицер Спок- \"Капитан, я рассчитал, что этот");
prout(" маневр займет приблизительно ");
cramf(100*Time/d.remtime,0,4);
/* prout("% of our");
prout("remaining time.");
prout("Are you sure this is wise?\" ");
*/ prout("% от нашего");
prout("оставшегося времени.");
prout("Вы уверены?\" ");
if (ja()==0) {
Time = 0.0;
return;
}
}
if (landed == 1) {
/* Kirk on planet */
if (iscraft==1) {
/* Galileo on ship! */
if (damage[DTRANSP]==0) {
/* proutn("Spock- \"Would you rather use the transporter?\" "); */
proutn("Спок- \"Может, лучше использовать транспортатор?\" ");
if (ja() != 0) {
beam();
return;
}
proutn("Команда шаттла");/*Shuttle crew*/
}
else
proutn("Спасательная команда");/*Rescue party*/
/* prout(" boards Galileo and swoops toward planet surface."); */
prout(" села на Галилео и отправиласть на поверхность.");
iscraft = 0;
skip(1);
if (consumeTime()) return;
d.plnets[iplnet].known=2;
prout("Посадка завершена.");/*Trip complete*/
return;
}
else {
/* Ready to go back to ship */
/* prout("You and your mining party board the");
prout("shuttle craft for the trip back to the Enterprise.");
skip(1);
prout("The short hop begins . . .");
*/ prout("Вы с партией шахтеров сели в шаттл");
prout("для возвращения на Энтерпрайз.");
skip(1);
/* prout("The short hop begins . . ."); */
prout("Обратный отсчет пошел . . .");
d.plnets[iplnet].known=1;
icraft = 1;
skip(1);
landed = -1;
if (consumeTime()) return;
iscraft = 1;
icraft = 0;
if (imine!=0) {
icrystl = 1;
cryprob = 0.05;
}
imine = 0;
/* prout("Trip complete."); */
prout("Полет завершен.");
return;
}
}
else {
/* Kirk on ship */
/* and so is Galileo */
/* prout("Mining party assembles in the hangar deck,");
prout("ready to board the shuttle craft \"Galileo\".");
skip(1);
prouts("The hangar doors open; the trip begins.");
*/ prout("Партия шахтеров собралась в ангаре,");
prout("готовые к посадке на шаттл \"Галилео\".");
skip(1);
prouts("Двери ангара открываются; полет начинается.");
skip(1);
icraft = 1;
iscraft = 0;
if (consumeTime()) return;
d.plnets[iplnet].known = 2;
landed = 1;
icraft = 0;
prout("Посадка завершена");
return;
}
}
void deathray(void) {
double r = Rand();
ididit = 0;
skip(1);
chew();
if (ship != IHE) {
/* prout("Ye Faerie Queene has no death ray."); */
prout("На Королеве Фей нет Луча Смерти.");
return;
}
if (nenhere==0) {
/* prout("Sulu- \"But Sir, there are no enemies in this quadrant.\""); */
prout("Сулу- \"Но Сэр, в этом квадранте враги отсутствуют.\"");
return;
}
if (damage[DDRAY] > 0.0) {
/* prout("Death Ray is damaged."); */
prout("Луч Смерти поврежден.");
return;
}
/* prout("Spock- \"Captain, the 'Experimental Death Ray'");
prout(" is highly unpredictable. Considering the alternatives,");
prout(" are you sure this is wise?\" ");
*/ prout("Спок- \"Капитан, 'Экспериментальный Луч Смерти'");
prout(" весьма непредсказуем. Рассмотрите альтернативы,");
prout(" Вы уверены в разумности этого?\" ");
if (ja()==0) return;
/* prout("Spock- \"Acknowledged.\""); */
prout("Спок- \"Подтвержение принято.\"");
skip(1);
ididit=1;
/* prouts("WHOOEE ... WHOOEE ... WHOOEE ... WHOOEE");
skip(1);
prout("Crew scrambles in emergency preparation.");
prout("Spock and Scotty ready the death ray and");
prout("prepare to channel all ship's power to the device.");
skip(1);
prout("Spock- \"Preparations complete, sir.\"");
prout("Kirk- \"Engage!\"");
skip(1);
prouts("WHIRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR");
*/ prouts("УУУИИИ ... УУУИИИ ... УУУИИИ ... УУУИИИ");
skip(1);
prout("Команда приготовилась по аварийному протоколу.");
prout("Спок и Скотти приготовили Луч Смерти и");
prout("приготовили канал подачи энергии на устройство.");
skip(1);
prout("Спок- \"Подготовка Луча завершена, Сэр.\"");
prout("Кирк- \"Включай!\"");
skip(1);
prouts("УИИИИИРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРР");
skip(1);
if (r > .30) {
/* prouts("Sulu- \"Captain! It's working!\""); */
prouts("Сулу- \"Капитан! Он сработал!\"");
skip(2);
while (nenhere > 0) {
deadkl(kx[1],ky[1],quad[kx[1]][ky[1]],kx[1],ky[1]);
}
/* prout("Ensign Chekov- \"Congratulations, Captain!\""); */
prout("Мичман Чехов- \"Поздравления, Капитан!\"");
if (d.remkl == 0) finish(FWON);
/* prout("Spock- \"Captain, I believe the `Experimental Death Ray'"); */
prout("Спок- \"Капитан, я думаю, `Экспериментальный Луч Смерти'");
if (Rand() <= 0.05) {
/* prout(" is still operational.\""); */
prout(" полностью работоспособен.\"");
}
else {
/* prout(" has been rendered dysfunctional.\""); */
prout(" вышел из строя.\"");
damage[DDRAY] = 39.95;
}
return;
}
r = Rand(); // Pick failure method
if (r <= .30) {
/* prouts("Sulu- \"Captain! It's working!\"");
skip(1);
prouts("***RED ALERT! RED ALERT!");
skip(1);
prout("***MATTER-ANTIMATTER IMPLOSION IMMINENT!");
skip(1);
prouts("***RED ALERT! RED A*L********************************");
skip(1);
stars();
prouts("****************** KA-BOOM!!!! *******************");
*/ prouts("Сулу- \"Капитан! Оно работает!\"");
skip(1);
prouts("***ОПАСНОСТЬ! ОПАСНОСТЬ!");
skip(1);
prout("***НЕИЗБЕЖЕН ВЗРЫВ АНТИМАТЕРИИ!");
skip(1);
prouts("***ОПАСНОСТЬ! ОПА*СНО********************************");
skip(1);
stars();
prouts("****************** КА-БУМ!!!! *******************");
skip(1);
kaboom();
return;
}
if (r <= .55) {
/* prouts("Sulu- \"Captain! Yagabandaghangrapl, brachriigringlanbla!\"");
skip(1);
prout("Lt. Uhura- \"Graaeek! Graaeek!\"");
skip(1);
prout("Spock- \"Fascinating! . . . All humans aboard");
prout(" have apparently been transformed into strange mutations.");
prout(" Vulcans do not seem to be affected.");
skip(1);
prout("Kirk- \"Raauch! Raauch!\"");
*/ prouts("Сулу- \"Капитан! Ягабандагхаарграпл, бранхириигринглабла!\"");
skip(1);
prout("Лейтенант Ухура- \"Грааеек! Грааеек!\"");
skip(1);
prout("Спок- \"Великолепно! . . . Все люди на борту");
prout(" внезапно подверглись странным мутациям.");
prout(" Вулканцы не подвержены такому воздействию Луча.");
skip(1);
prout("Кирк- \"Рааух! Рааух!\"");
finish(FDRAY);
return;
}
if (r <= 0.75) {
int i,j;
/* prouts("Sulu- \"Captain! It's --WHAT?!?!\"");
skip(2);
proutn("Spock- \"I believe the word is");
prouts(" *ASTONISHING*");
prout(" Mr. Sulu.");
*/ prouts("Сулу- \"Капитан! Это --ЧТО?!?!\"");
skip(2);
proutn("Спок- \"Я думаю подходящее слово");
prouts(" *УДИВИТЕЛЬНО*");
prout(" Мистер Сулу.");
for (i=1; i<=10; i++)
for (j=1; j<=10; j++)
if (quad[i][j] == IHDOT) quad[i][j] = IHQUEST;
/* prout(" Captain, our quadrant is now infested with");
prouts(" - - - - - - *THINGS*.");
skip(1);
prout(" I have no logical explanation.\"");
*/ prout(" Капитан, наш квадрант заселен");
prouts(" - - - - - - *НЕЧТОМ*.");
skip(1);
prout(" У меня нет логического объяснения.\"");
return;
}
/* prouts("Sulu- \"Captain! The Death Ray is creating tribbles!\"");
skip(1);
prout("Scotty- \"There are so many tribbles down here");
prout(" in Engineering, we can't move for 'em, Captain.\"");
*/ prouts("Сулу- \"Капитан! Луч Смерти создал трибблов!\"");
skip(1);
prout("Скотти- \"Что то их слишком уж много");
prout(" в инженерном отсеке, мы не можем двигаться из-за них, Капитан.\"");
finish(FTRIBBLE);
return;
}
+624
View File
@@ -0,0 +1,624 @@
#include "sst.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
void attakreport(void) {
if (future[FCDBAS] < 1e30) {
proutn("Станция в");/*Starbase in*/
cramlc(1, batx, baty);
/* prout(" is currently under attack.");
proutn("It can hold out until Stardate ");
*/ prout(" находится под атакой.");
proutn("Она продержится максимум до ");
cramf(future[FCDBAS], 0,1);
prout(".");
}
if (isatb == 1) {
proutn("Станция в");/*Starbase in*/
cramlc(1, d.isx, d.isy);
/* prout(" is under Super-commander attack.");
proutn("It can hold out until Stardate ");
*/ prout(" находится под атакой СуперКоммандера.");
proutn("Она продержится максимум до ");
cramf(future[FSCDBAS], 0, 1);
prout(".");
}
}
void report(int f) {
char *s1,*s2,*s3;
chew();
s1 = (thawed?"сохраненную ":"");/*thawed*/
switch (length) {
case 1: s2="быструю/short"; break;
case 2: s2="среднюю/medium"; break;
case 4: s2="длинную/long"; break;
default: s2="неизвестной длительности/unknown length"; break;
}
switch (skill) {
case SNOVICE: s3="новичок"; break;/*novice*/
case SFAIR: s3="салага"; break;/*fair*/
case SGOOD: s3="отличник"; break;/*good*/
case SEXPERT: s3="эксперт"; break;/*expert*/
case SEMERITUS: s3="эмеритус"; break;/*emeritus*/
default: s3="опытный"; break;/*skilled*/
}
/* printf("\nYou %s playing a %s%s %s game.\n",
alldone? "were": "are now", s1, s2, s3);
*/ printf("\nВы %s a %s%s игру на сложности %s.\n",
alldone? "сыграли": "сейчас играете", s1, s2, s3);
if (skill>SGOOD && thawed && !alldone) prout("Знак отличия не выдается.");/*No plaque is allowed*/
/* if (tourn) printf("This is tournament game %d.\n", tourn); */
if (tourn) printf("Это турнирная игра %d.\n", tourn);
/* if (f) printf("Your secret password is \"%s\"\n",passwd); */
if (f) printf("Ваш секретный пароль \"%s\"\n",passwd);
/* printf("%d of %d Klingon ships have been destroyed", */
printf("%d из %d клингонских кораблей уничтожено",
d.killk+d.killc+d.nsckill, inkling);
/* if (d.killc) printf(", including %d Commander%s.\n", d.killc, d.killc==1?"":"s"); */
if (d.killc) printf(", включая %d Коммандер%s.\n", d.killc, d.killc==1?"а":"ов");
else if (d.killk+d.nsckill > 0) prout(", но ни одного Коммандера.");/*but no Commanders*/
else prout(".");
/* if (skill > SFAIR) printf("The Super Commander has %sbeen destroyed.\n",
d.nscrem?"not ":"");
*/ if (skill > SFAIR) printf("СуперКоммандер %sбыл уничтожен.\n",
d.nscrem?"не ":"");
if (d.rembase != inbase) {
/* proutn("There ");
if (inbase-d.rembase==1) proutn("has been 1 base");
else {
proutn("have been ");
crami(inbase-d.rembase, 1);
proutn(" bases");
}
proutn(" destroyed, ");
crami(d.rembase, 1);
prout(" remaining.");
*/
if (inbase-d.rembase==1) proutn("Единственная станция была уничтожена,");
else {
proutn("Было ");
crami(inbase-d.rembase, 1);
proutn(" станций уничтожено, ");
}
crami(d.rembase, 1);
prout(" осталось.");
}
else printf("Всего %d станций.\n", inbase);/*There are %d bases*/
if (REPORTS || iseenit) {
/* Don't report this if not seen and
either the radio is dead or not at base! */
attakreport();
iseenit = 1;
}
/* if (casual) printf("%d casualt%s suffered so far.\n",
casual, casual==1? "y" : "ies");
*/ if (casual) printf("%d смерт%s среди экипажа.\n",
casual, casual==1? "ь" : "ей");
#ifdef CAPTURE
/* if (brigcapacity != brigfree) printf("%d Klingon%s in brig.\n",
brigcapacity-brigfree, brigcapacity-brigfree>1 ? "s" : "");
*/ if (brigcapacity != brigfree) printf("%d клингон%s на бриге.\n",
brigcapacity-brigfree, brigcapacity-brigfree>1 ? "ов" : "");
/* if (kcaptured > 0) printf("%d captured Klingon%s turned in to Star Fleet.\n",
kcaptured, kcaptured>1 ? "s" : "");
*/ if (kcaptured > 0) printf("%d пленных клингон%s присоединились к Звездному Флоту.\n",
kcaptured, kcaptured>1 ? "ов" : "");
#endif
/* if (nhelp) printf("There were %d call%s for help.\n",
nhelp, nhelp==1 ? "" : "s");
*/ if (nhelp) printf("Зафиксировано %d вызов%s о помощи.\n",
nhelp, nhelp==1 ? "" : "ов");
if (ship == IHE) {
proutn("У вас осталось ");/**/
if (nprobes) crami(nprobes,1);
else proutn("0");/*no*/
proutn(" разведзонд");/*deep space probe*/
if (nprobes!=1) proutn("ов");/*s*/
prout(".");
}
if (REPORTS && future[FDSPROB] != 1e30) {
if (isarmed)
/* proutn("An armed deep space probe is in"); */
proutn("Разведывательный зонд с боеголовкой в точке");
else
proutn("Разведывательный зонд в точке");/*A deep space probe is in*/
cramlc(1, probecx, probecy);
prout(".");
}
if (icrystl) {
if (cryprob <= .05)
/* prout("Dilithium crystals aboard ship...not yet used."); */
prout("Дилитиевые кристаллы на борту...не были использованы.");
else {
int i=0;
double ai = 0.05;
while (cryprob > ai) {
ai *= 2.0;
i++;
}
/* printf("Dilithium crystals have been used %d time%s.\n",
i, i==1? "" : "s");
*/ printf("Дилитиевые кристалл использовались %d раз%s.\n",
i, (i>1 && i<5)? "а" : "");
}
}
skip(1);
}
void lrscan(void) {
int x, y;
chew();
if (damage[DLRSENS] != 0.0) {
/* Now allow base's sensors if docked */
if (condit != IHDOCKED) {
/* prout("LONG-RANGE SENSORS DAMAGED."); */
prout("СЕНСОРЫ ДАЛЬНЕГО ОБЗОРА ПОВРЕЖДЕНЫ.");
return;
}
skip(1);
/* proutn("Starbase's long-range scan for"); */
proutn("Используем сенсоры станции для");
}
else {
skip(1);
/* proutn("Long-range scan for"); */
proutn("Производим дальнее сканирование для");
}
cramlc(1, quadx, quady);
skip(1);
if (coordfixed)
for (y = quady+1; y >= quady-1; y--) {
for (x = quadx-1; x <= quadx+1; x++) {
if (x == 0 || x > 8 || y == 0 || y > 8)
printf(" -1");
else {
printf("%5d", d.galaxy[x][y]);
// If radio works, mark star chart so
// it will show current information.
// Otherwise mark with current
// value which is fixed.
starch[x][y] = damage[DRADIO] > 0 ? d.galaxy[x][y]+1000 :1;
}
}
putchar('\n');
}
else
for (x = quadx-1; x <= quadx+1; x++) {
for (y = quady-1; y <= quady+1; y++) {
if (x == 0 || x > 8 || y == 0 || y > 8)
printf(" -1");
else {
printf("%5d", d.galaxy[x][y]);
// If radio works, mark star chart so
// it will show current information.
// Otherwise mark with current
// value which is fixed.
starch[x][y] = damage[DRADIO] > 0 ? d.galaxy[x][y]+1000 :1;
}
}
putchar('\n');
}
}
void dreprt(void) {
int jdam = FALSE, i;
chew();
for (i = 1; i <= ndevice; i++) {
if (damage[i] > 0.0) {
if (!jdam) {
skip(1);
/* prout("DEVICE -REPAIR TIMES-");
prout(" IN FLIGHT DOCKED");
*/ prout("ПОДСИСТЕМА -ВРЕМЯ НА РЕМОНТ-");
prout(" В КОСМОСЕ НА СТАНЦИИ");
jdam = TRUE;
}
printf(" %16s ", device[i]);
cramf(damage[i]+0.05, 8, 2);
proutn(" ");
cramf(docfac*damage[i]+0.005, 8, 2);
skip(1);
}
}
/* if (!jdam) prout("All devices functional."); */
if (!jdam) prout("Все подсистемы исправны.");
}
void chart(int nn) {
int i,j;
chew();
skip(1);
if (stdamtim != 1e30 && stdamtim != d.date && condit == IHDOCKED) {
/* prout("Spock- \"I revised the Star Chart from the");
prout(" starbase's records.\"");
*/ prout("Спок- \"Я обновил звездную карту");
prout(" по данным станции.\"");
skip(1);
}
/* if (nn == 0) prout("STAR CHART FOR THE KNOWN GALAXY"); */
if (nn == 0) prout("ЗВЕЗДНАЯ КАРТА ИЗВЕСТНОЙ ЧАСТИ ГАЛАКТИКИ");
if (stdamtim != 1e30) {
if (condit == IHDOCKED) {
/* We are docked, so restore chart from base information -- these values won't update! */
stdamtim = d.date;
for (i=1; i <= 8 ; i++)
for (j=1; j <= 8; j++)
if (starch[i][j] == 1) starch[i][j] = d.galaxy[i][j]+1000;
}
else {
proutn("(Последнее обновление данных ");/*Last surveillance update*/
cramf(d.date-stdamtim, 0, 1);
prout(" звездных лет назад.)");/*stardates ago*/
}
}
if (nn ==0) skip(1);
prout(" 1 2 3 4 5 6 7 8");
prout(" ----------------------------------------");
if (nn==0) prout(" -");
if (coordfixed)
for (j = 8; j >= 1; j--) {
printf("%d -", j);
for (i = 1; i <= 8; i++) {
if (starch[i][j] < 0) // We know only about the bases
printf(" .1.");
else if (starch[i][j] == 0) // Unknown
printf(" ...");
else if (starch[i][j] > 999) // Memorized value
printf("%5d", starch[i][j]-1000);
else
printf("%5d", d.galaxy[i][j]); // What is actually there (happens when value is 1)
}
prout(" -");
}
else
for (i = 1; i <= 8; i++) {
printf("%d -", i);
for (j = 1; j <= 8; j++) {
if (starch[i][j] < 0) // We know only about the bases
printf(" .1.");
else if (starch[i][j] == 0) // Unknown
printf(" ...");
else if (starch[i][j] > 999) // Memorized value
printf("%5d", starch[i][j]-1000);
else
printf("%5d", d.galaxy[i][j]); // What is actually there (happens when value is 1)
}
prout(" -");
}
if (nn == 0) {
skip(1);
crmshp();
proutn(" находится в точке");/*is currently in*/
cramlc(1, quadx, quady);
skip(1);
}
}
void srscan(int l) {
static char requests[][3] =
{"","da","co","po","ls","wa","en","to","sh","kl","ti"};
char *cp;
int leftside=TRUE, rightside=TRUE, i, j, jj, k=0, nn=FALSE;
int goodScan=TRUE;
switch (l) {
case 1: // SRSCAN
if (damage[DSRSENS] != 0) {
/* Allow base's sensors if docked */
if (condit != IHDOCKED) {
/* prout("SHORT-RANGE SENSORS DAMAGED"); */
prout("БЛИЖНИЕ СЕНСОРЫ ПОВРЕЖДЕНЫ");
goodScan=FALSE;
}
else
/* prout("[Using starbase's sensors]"); */
prout("[Используем сенсоры станции]");
}
if (goodScan)
starch[quadx][quady] = damage[DRADIO]>0.0 ?
d.galaxy[quadx][quady]+1000:1;
scan();
if (isit("chart")) nn = TRUE;
if (isit("no")) rightside = FALSE;
chew();
prout("\n 1 2 3 4 5 6 7 8 9 10");
break;
case 2: // REQUEST
while (scan() == IHEOL)
/* printf("Information desired? "); */
printf("Желаемая информация? ");
chew();
for (k = 1; k <= 10; k++)
if (strncmp(citem,requests[k],min(2,strlen(citem)))==0)
break;
if (k > 10) {
/* prout("UNRECOGNIZED REQUEST. Legal requests are:\n"
" date, condition, position, lsupport, warpfactor,\n"
" energy, torpedoes, shields, klingons, time.");
*/ prout("ЗАПРОС НЕРАСПОЗНАН. Корректные запросы (две буквы):\n"
" date(дата), condition(состояние), position(положение),\n"
" lsupport (жизнеобеспечение), warpfactor (варп-фактор),\n"
" energy(энергия), torpedoes(торпеды), shields (силовые щиты),\n"
" klingons(клингоны), time(время).");
return;
}
// no "break"
case 3: // STATUS
chew();
leftside = FALSE;
skip(1);
}
for (i = 1; i <= 10; i++) {
int jj = (k!=0 ? k : i);
if (leftside) {
if (coordfixed) {
printf("%2d ", 11-i);
for (j = 1; j <= 10; j++) {
if (goodScan || (abs((11-i)-secty)<= 1 && abs(j-sectx) <= 1))
printf("%c ",quad[j][11-i]);
else
printf("- ");
}
} else {
printf("%2d ", i);
for (j = 1; j <= 10; j++) {
if (goodScan || (abs(i-sectx)<= 1 && abs(j-secty) <= 1))
printf("%c ",quad[i][j]);
else
printf("- ");
}
}
}
if (rightside) {
switch (jj) {
case 1:
printf(" Звездная дата %.1f", d.date);/*Stardate*/
break;
case 2:
if (condit != IHDOCKED) newcnd();
switch (condit) {
case IHRED: cp = "КРАСНЫЙ"; break;/*RED*/
case IHGREEN: cp = "ЗЕЛЕНЫЙ"; break;/*GREEN*/
case IHYELLOW: cp = "ЖЕЛТЫЙ"; break;/*YELLOW*/
case IHDOCKED: cp = "ПРИСТЫКОВАН"; break;/*DOCKED*/
}
/* printf(" Condition %s", cp); */
printf(" Состояние/Статус %s", cp);
#ifdef CLOAKING
if (iscloaked) printf(", МАКИРОВАН");/*CLOAKED*/
#endif
break;
case 3:
printf(" Положение ");/*Position*/
cramlc(0, quadx, quady);
putchar(',');
cramlc(0, sectx, secty);
break;
case 4:
printf(" Жизнеобеспечение ");/*Life Support*/
if (damage[DLIFSUP] != 0.0) {
if (condit == IHDOCKED)
/* printf("DAMAGED, supported by starbase");
else
printf("DAMAGED, reserves=%4.2f", lsupres);
*/ printf("ПОВРЕЖДЕНО, питаемся от станции");
else
printf("ПОВРЕЖДЕНО, резерв=%4.2f", lsupres);
}
else
printf("АКТИВНО");/*ACTIVE*/
break;
case 5:
printf(" Варп-фактор %.1f", warpfac);/*Warp Factor*/
break;
case 6:
printf(" Энергия %.2f", energy);/*Energy */
break;
case 7:
printf(" Торпед %d", torps);/*Torpedoes*/
break;
case 8:
printf(" Силовые щиты ");/*Shields*/
if (damage[DSHIELD] != 0)
printf("ПОВРЕЖДЕНЫ,");/*DAMAGED*/
else if (shldup)
printf("АКТИВНЫ,");/*UP*/
else
printf("ОТКЛЮЧЕНЫ,");/*DOWN*/
printf(" %d%% %.1f единиц",/*units*/
(int)((100.0*shield)/inshld + 0.5), shield);
break;
case 9:
printf(" Клингонов осталось %d", d.remkl);/*Klingons Left*/
break;
case 10:
printf(" Времени осталось %.2f", d.remtime);/*Time Left*/
break;
}
}
skip(1);
if (k!=0) return;
}
if (nn) chart(1);
}
void eta(void) {
int key, ix1, ix2, iy1, iy2, prompt=FALSE;
int wfl;
double ttime, twarp, tpower;
if (damage[DCOMPTR] != 0.0) {
/* prout("COMPUTER DAMAGED, USE A POCKET CALCULATOR."); */
prout("КОМПЬЮТЕР ПОВРЕЖДЕН, ИСПОЛЬЗУЮ НАСТОЛЬНЫЙ КАЛЬКУЛЯТОР.");
skip(1);
return;
}
if (scan() != IHREAL) {
prompt = TRUE;
chew();
/* proutn("Destination quadrant and/or sector? "); */
proutn("Квадрант назначения и/или сектор? ");
if (scan()!=IHREAL) {
huh();
return;
}
}
iy1 = aaitem +0.5;
if (scan() != IHREAL) {
huh();
return;
}
ix1 = aaitem + 0.5;
if (scan() == IHREAL) {
iy2 = aaitem + 0.5;
if (scan() != IHREAL) {
huh();
return;
}
ix2 = aaitem + 0.5;
}
else { // same quadrant
ix2 = ix1;
iy2 = iy1;
ix1 = quady; // ya got me why x and y are reversed!
iy1 = quadx;
}
if (ix1 > 8 || ix1 < 1 || iy1 > 8 || iy1 < 1 ||
ix2 > 10 || ix2 < 1 || iy2 > 10 || iy2 < 1) {
huh();
return;
}
dist = sqrt(square(iy1-quadx+0.1*(iy2-sectx))+
square(ix1-quady+0.1*(ix2-secty)));
wfl = FALSE;
/* if (prompt) prout("Answer \"no\" if you don't know the value:"); */
if (prompt) prout("Ответьте \"no\" если вы не знаете значение:");
while (TRUE) {
chew();
/* proutn("Time or arrival date? "); */
proutn("Время или дата прибытия? ");
if (scan()==IHREAL) {
ttime = aaitem;
if (ttime > d.date) ttime -= d.date; // Actually a star date
if (ttime <= 1e-10 ||
(twarp=(floor(sqrt((10.0*dist)/ttime)*10.0)+1.0)/10.0) > 10) {
/* prout("We'll never make it, sir."); */
prout("Мы никогда не сделаем это, Сэр.");
chew();
return;
}
if (twarp < 1.0) twarp = 1.0;
break;
}
chew();
proutn("Варп-фактор? ");/*Warp factor*/
if (scan()== IHREAL) {
wfl = TRUE;
twarp = aaitem;
if (twarp<1.0 || twarp > 10.0) {
huh();
return;
}
break;
}
/* prout("Captain, certainly you can give me one of these."); */
prout("Капитан, мне определенно нужно знать один из вариантов.");
}
while (TRUE) {
chew();
ttime = (10.0*dist)/square(twarp);
tpower = dist*twarp*twarp*twarp*(shldup+1);
if (tpower >= energy) { // Suggestion from Ethan Staffin -- give amount needed
/* prout("Insufficient energy, sir: we would need "); */
prout("Недостаточно энергии, Сэр: нам нужно ");
cramf(tpower, 1, 1);
proutn (" единиц.");/*units*/
if (shldup==0 || tpower > energy*2.0) {
if (!wfl) return;
/* proutn("New warp factor to try? "); */
proutn("Пробуем другой варп-фактор? ");
if (scan() == IHREAL) {
wfl = TRUE;
twarp = aaitem;
if (twarp<1.0 || twarp > 10.0) {
huh();
return;
}
continue;
}
else {
chew();
skip(1);
return;
}
}
/* prout("But if you lower your shields,");
proutn("remaining");
*/ prout("Но если опустить силовые щиты,");
proutn("останется");
tpower /= 2;
}
else
proutn("Останется"); /*Remaining*/
proutn(" энергии ");/*energy will be*/
cramf(energy-tpower, 1, 1);
prout(".");
if (wfl) {
/* proutn("And we will arrive at stardate "); */
proutn("И мы прилетим в нужную точку к дате ");
cramf(d.date+ttime, 1, 1);
prout(".");
}
else if (twarp==1.0)
/* prout("Any warp speed is adequate."); */
prout("Нас устроит любая скорость варпа.");
else {
/* proutn("Minimum warp needed is "); */
proutn("Минимально требуемая варп-скорость ");
cramf(twarp, 1, 2);
skip(1);
/* proutn("and we will arrive at stardate "); */
proutn("и мы прилетим в нужную точку к дате ");
cramf(d.date+ttime, 1, 2);
prout(".");
}
if (d.remtime < ttime)
/* prout("Unfortunately, the Federation will be destroyed by then."); */
prout("Печально, но к тому времени Федерация будет уничтожена.");
if (twarp > 6.0)
/* prout("You'll be taking risks at that speed, Captain"); */
prout("Вы должны понимать риски такой скорости, Капитан");
if ((isatb==1 && d.isy == ix1 && d.isx == iy1 &&
future[FSCDBAS]< ttime+d.date)||
(future[FCDBAS]<ttime+d.date && baty==ix1 && batx == iy1))
/* prout("The starbase there will be destroyed by then."); */
prout("Станция будет уже уничтожена к этому времени.");
/* proutn("New warp factor to try? "); */
proutn("Пробуем другой варп-фактор? ");
if (scan() == IHREAL) {
wfl = TRUE;
twarp = aaitem;
if (twarp<1.0 || twarp > 10.0) {
huh();
return;
}
}
else {
chew();
skip(1);
return;
}
}
}
+775
View File
@@ -0,0 +1,775 @@
#include <time.h>
#include "sst.h"
void prelim(void) {
skip(2);
prout("-SUPER- STAR TREK");
skip(1);
prout("Latest update-21 Sept 78");
skip(1);
prout("Версия перевода от 27 февраля 18");
skip(1);
}
void freeze(int boss) {
char *x, *y;
FILE *fp;
int key;
if (boss) {
strcpy(citem, "emsave.trk");
}
else {
if ((key = scan()) == IHEOL) {
/* proutn("File name(9 characters maximum): "); */
proutn("Имя файла(9 символов максимум): ");
key = scan();
}
if (key != IHALPHA) {
huh();
return;
}
chew();
if (strchr(citem, '.') == NULL) {
strcat(citem, ".trk");
}
}
if ((fp = fopen(citem, "wb")) == NULL) {
/* proutn("Can't freeze game as file "); */
proutn("Невозможно сохранить игру в файл ");
proutn(citem);
skip(1);
return;
}
fwrite(&d, sizeof(d), 1, fp);
fwrite(&snapsht, sizeof(snapsht), 1, fp);
fwrite(quad, sizeof(quad), 1, fp);
fwrite(kx, sizeof(kx), 1, fp);
fwrite(ky, sizeof(ky), 1, fp);
fwrite(starch, sizeof(starch), 1, fp);
fwrite(kpower, sizeof(kpower), 1, fp);
fwrite(kdist, sizeof(kdist), 1, fp);
fwrite(kavgd, sizeof(kavgd), 1, fp);
fwrite(damage, sizeof(damage), 1, fp);
fwrite(future, sizeof(future), 1, fp);
fwrite(&a, sizeof(a), 1, fp);
fwrite(passwd, sizeof(passwd), 1, fp);
fclose(fp);
/* I hope that's enough! */
}
void thaw(void) {
char *x, *y;
FILE *fp;
int key;
passwd[0] = '\0';
if ((key = scan()) == IHEOL) {
proutn("Имя файла: ");/*File name*/
key = scan();
}
if (key != IHALPHA) {
huh();
return;
}
chew();
if (strchr(citem, '.') == NULL) {
strcat(citem, ".trk");
}
if ((fp = fopen(citem, "rb")) == NULL) {
proutn("Не могу найти файл ");/*Can't find game file*/
proutn(citem);
skip(1);
return;
}
fread(&d, sizeof(d), 1, fp);
fread(&snapsht, sizeof(snapsht), 1, fp);
fread(quad, sizeof(quad), 1, fp);
fread(kx, sizeof(kx), 1, fp);
fread(ky, sizeof(ky), 1, fp);
fread(starch, sizeof(starch), 1, fp);
fread(kpower, sizeof(kpower), 1, fp);
fread(kdist, sizeof(kdist), 1, fp);
fread(kavgd, sizeof(kavgd), 1, fp);
fread(damage, sizeof(damage), 1, fp);
fread(future, sizeof(future), 1, fp);
fread(&a, sizeof(a), 1, fp);
fread(passwd, sizeof(passwd), 1, fp);
fclose(fp);
/* I hope that's enough! */
}
void abandn(void) {
int nb, l;
chew();
if (condit==IHDOCKED) {
if (ship!=IHE) {
/* prout("You cannot abandon Ye Faerie Queene."); */
prout("Вы неможете покинуть Королеву Фей.");
return;
}
}
else {
/* Must take shuttle craft to exit */
if (damage[DSHUTTL]==-1) {
/* prout("Ye Faerie Queene has no shuttle craft."); */
prout("На Королеве Фей отсутствует шаттл.");
return;
}
if (damage[DSHUTTL]<0) {
/* prout("Shuttle craft now serving Big Mac's."); */
prout("Шаттл теперь используется для развозки БигМаков.");
return;
}
if (damage[DSHUTTL]>0) {
/* prout("Shuttle craft damaged."); */
prout("Шаттл поврежден.");
return;
}
if (landed==1) {
/* prout("You must be aboard the Enterprise."); */
prout("Вы должны быть на борту Энтерпрайза.");
return;
}
if (iscraft!=1) {
/* prout("Shuttle craft not currently available."); */
prout("Шаттл в настоящий момент недоступен.");
return;
}
/* Print abandon ship messages */
skip(1);
/* prouts("***ABANDON SHIP! ABANDON SHIP!"); */
prouts("***ЭВАКУАЦИЯ! ЭВАКУАЦИЯ!");
skip(1);
/* prouts("***ALL HANDS ABANDON SHIP!"); */
prouts("***ВСЕМ НЕМЕДЛЕННО ПОКИНУТЬ КОРАБЛЬ!");
skip(2);
/* prout("Captain and crew escape in shuttle craft.");
prout("Remainder of ship's complement beam down");
prout("to nearest habitable planet.");
*/ prout("Капитан и экипаж покинули корабль на шаттле.");
prout("Остатки корабля упали на");
prout("близлежащую населенную планету.");
if (d.rembase==0) {
/* Ops! no place to go... */
finish(FABANDN);
return;
}
/* If at least one base left, give 'em the Faerie Queene */
skip(1);
icrystl = 0; /* crystals are lost */
nprobes = 0; /* No probes */
/* prout("You are captured by Klingons and released to");
prout("the Federation in a prisoner-of-war exchange.");
*/ prout("Вы были захвачены клингонами и отправлены");
prout("в Федерацию по программе обмена пленными.");
nb = Rand()*d.rembase+1;
/* Set up quadrant and position FQ adjacient to base */
if (quadx!=d.baseqx[nb] || quady!=d.baseqy[nb]) {
quadx = d.baseqx[nb];
quady = d.baseqy[nb];
sectx = secty = 5;
newqad(1);
}
for (;;) {
/* position next to base by trial and error */
quad[sectx][secty] = IHDOT;
for (l = 1; l <= 10; l++) {
sectx = 3.0*Rand() - 1.0 + basex;
secty = 3.0*Rand() - 1.0 + basey;
if (sectx >= 1 && sectx <= 10 &&
secty >= 1 && secty <= 10 &&
quad[sectx][secty] == IHDOT) break;
}
if (l < 11) break; /* found a spot */
sectx=5;
secty=5;
newqad(1);
}
}
/* Get new commission */
quad[sectx][secty] = ship = IHF;
/* prout("Starfleet puts you in command of another ship,");
prout("the Faerie Queene, which is antiquated but,");
prout("still useable.");
*/ prout("Звездное Командование выдало под Ваше руководство");
prout("Королеву Фей, корабль хоть и устаревший,");
prout("но в неплохом состоянии.");
/* if (icrystl!=0) prout("The dilithium crystals have been moved."); */
if (icrystl!=0) prout("Дилитиевые кристаллы перенесены.");
imine=0;
iscraft=0; /* Gallileo disappears */
#ifdef CAPTURE
brigcapacity = 300; // Less capacity now
brigfree = brigcapacity;
#endif
#ifdef CLOAKING
iscloaked = iscloaking = FALSE;
#endif
/* Resupply ship */
condit=IHDOCKED;
for (l = 1; l <= ndevice; l++) damage[l] = 0.0;
damage[DSHUTTL] = -1;
energy = inenrg = 3000.0;
shield = inshld = 1250.0;
torps = intorps = 6;
lsupres=inlsr=3.0;
shldup=0;
warpfac=5.0;
wfacsq=25.0;
return;
}
void setup(void) {
int i,j, krem, klumper;
int ix, iy;
alldone = gamewon = 0;
#ifdef DEBUG
idebug = 0;
#endif
// Decide how many of everything
if (choose()) return; // frozen game
// Prepare the Enterprise
ship = IHE;
energy = inenrg = 5000.0;
shield = inshld = 2500.0;
shldchg = shldup = 0;
inlsr = 4.0;
lsupres = 4.0;
iran8(&quadx, &quady);
iran10(&sectx, &secty);
torps = intorps = 10;
nprobes = (int)(3.0*Rand() + 2.0); /* Give them 2-4 of these wonders */
warpfac = 5.0;
wfacsq = warpfac * warpfac;
for (i=0; i <= ndevice; i++) damage[i] = 0.0;
// Set up assorted game parameters
batx = baty = 0;
d.date = indate = 100.0*(int)(31.0*Rand()+20.0);
d.killk = d.killc = nkinks = nhelp = resting = casual = d.nromkl = 0;
// Added d.starkl=0 6/2015
isatb = iscate = imine = icrystl = icraft = d.nsckill = d.nplankl = d.starkl = 0;
iscraft = 1;
landed = -1;
alive = 1;
docfac = 0.25;
for (i = 1; i <= 8; i++)
for (j = 1; j <= 8; j++) d.newstuf[i][j] = starch[i][j] = 0;
// Initialize times for extraneous events
future[FSNOVA] = d.date + expran(0.5 * intime);
future[FTBEAM] = d.date + expran(1.5 * (intime / d.remcom));
future[FSNAP] = d.date + 1.0 + Rand(); // Force an early snapshot
future[FBATTAK] = d.date + expran(0.3*intime);
future[FCDBAS] = 1e30;
future[FSCMOVE] = d.nscrem ? d.date+0.2777 : 1e30;
future[FSCDBAS] = 1e30;
future[FDSPROB] = 1e30;
// Starchart is functional
stdamtim = 1e30;
// Put stars in the galaxy
instar = 0;
for (i=1; i<=8; i++)
for (j=1; j<=8; j++) {
int k = Rand()*9.0 + 1.0;
instar += k;
d.galaxy[i][j] = k;
}
// Locate star bases in galaxy
for (i = 1; i <= inbase; i++) {
int contflag;
do {
do iran8(&ix, &iy);
while (d.galaxy[ix][iy] >= 10);
contflag = FALSE;
for (j = i-1; j > 0; j--) {
/* Improved placement algorithm to spread out bases */
double distq = square(ix-d.baseqx[j]) + square(iy-d.baseqy[j]);
if (distq < 6.0*(6-inbase) && Rand() < 0.75) {
contflag = TRUE;
#ifdef DEBUG
printf("DEBUG: Abandoning base #%d at %d-%d\n", i, ix, iy);
#endif
break;
}
#ifdef DEBUG
else if (distq < 6.0 * (6-inbase)) {
printf("DEBUG: saving base #%d, close to #%d\n", i, j);
}
#endif
}
} while (contflag);
d.baseqx[i] = ix;
d.baseqy[i] = iy;
starch[ix][iy] = -1;
d.galaxy[ix][iy] += 10;
}
// Position ordinary Klingon Battle Cruisers
krem = inkling - incom - d.nscrem;
klumper = 0.25*skill*(9.0-length)+1.0;
if (klumper > 9) klumper = 9; // Can't have more than 9 in quadrant
do {
double r = Rand();
int klump = (1.0 - r*r)*klumper;
if (klump > krem) klump = krem;
krem -= klump;
klump *= 100;
do iran8(&ix, &iy);
while (d.galaxy[ix][iy] + klump >= 1000);
d.galaxy[ix][iy] += klump;
} while (krem > 0);
// Position Klingon Commander Ships
#ifdef DEBUG
klumper = 1;
#endif
for (i = 1; i <= incom; i++) {
do {
do { /* IF debugging, put commanders by bases, always! */
#ifdef DEBUG
if (idebug && klumper <= inbase) {
ix = d.baseqx[klumper];
iy = d.baseqy[klumper];
klumper++;
}
else
#endif
iran8(&ix, &iy);
}
while ((d.galaxy[ix][iy] < 99 && Rand() < 0.75)||
d.galaxy[ix][iy]>899);
// check for duplicate
for (j = 1; j < i; j++)
if (d.cx[j]==ix && d.cy[j]==iy) break;
} while (j < i);
d.galaxy[ix][iy] += 100;
d.cx[i] = ix;
d.cy[i] = iy;
}
// Locate planets in galaxy
for (i = 1; i <= inplan; i++) {
do iran8(&ix, &iy);
while (d.newstuf[ix][iy] > 0);
d.newstuf[ix][iy] = 1;
d.plnets[i].x = ix;
d.plnets[i].y = iy;
d.plnets[i].pclass = Rand()*3.0 + 1.0; // Planet class M N or O
d.plnets[i].crystals = 1.5*Rand(); // 1 in 3 chance of crystals
d.plnets[i].known = 0;
}
// Locate Romulans
for (i = 1; i <= d.nromrem; i++) {
iran8(&ix, &iy);
d.newstuf[ix][iy] += 10;
}
// Locate the Super Commander
if (d.nscrem > 0) {
do iran8(&ix, &iy);
while (d.galaxy[ix][iy] >= 900);
d.isx = ix;
d.isy = iy;
d.galaxy[ix][iy] += 100;
}
// Place thing (in tournament game, thingx == -1, don't want one!)
if (Rand() < 0.1 && thingx != -1) {
iran8(&thingx, &thingy);
}
else {
thingx = thingy = 0;
}
// idate = date;
skip(3);
d.snap = 0;
if (skill == SNOVICE) {
/* printf("It is stardate %d. The Federation is being attacked by\n", */
/* (int)d.date);
printf("a deadly Klingon invasion force. As captain of the United\n"
"Starship U.S.S. Enterprise, it is your mission to seek out\n"
"and destroy this invasion force of %d battle cruisers.\n",
inkling);
printf("You have an initial allotment of %d stardates to complete\n"
"your mission. As you proceed you may be given more time.\n\n"
"You will have %d supporting starbases.\n"
"Starbase locations- ",
(int)intime, inbase);
*/ printf("Звездная дата %d. Федерация атакована смертельно опасным\n",
(int)d.date);
printf("флотом вторжения клингонов. Как капитан корабля Звездного\n"
"Флота Ю.С.С. Энтерпрайз, ваше задание найти и уничтожить\n"
"вторгшиеся силы в количестве %d линейных крейсеров.\n",
inkling);
printf("Вам первоначально отведено %d звездных лет на завершение\n"
"миссии. По ходу выполнения время может быть увеличено.\n\n"
"Также Вы располагаете %d станций поддержки.\n"
"Местоположение станций- ",
(int)intime, inbase);
}
else {
/* printf("Stardate %d.\n\n"
"%d Klingons,\nan unknown number of Romulans\n",
(int)d.date, inkling);
if (d.nscrem) printf("and one (GULP) Super-Commander.\n");
printf("%d stardates\n%d starbases in ",(int)intime, inbase);
*/ printf("Звездная дата %d.\n\n"
"%d клингонов,\nи неизвестное количество ромуланцев\n",
(int)d.date, inkling);
if (d.nscrem) printf("и один (черт) СуперКоммандер.\n");
printf("%d звездных лет\n%d станций в точках ",(int)intime, inbase);
}
for (i = 1; i <= inbase; i++) {
cramlc(0, d.baseqx[i], d.baseqy[i]);
if (i < inbase) proutn(" ");
}
skip(2);
/* proutn("The Enterprise is currently in"); */
proutn("Энтерпрайз находится в точке");
cramlc(1, quadx, quady);
proutn(" ");
cramlc(2, sectx, secty);
skip(2);
/* prout("Good Luck!"); */
prout("Удачи!");
if (d.nscrem) proutn(" ОНА ВАМ ПРИГОДИТСЯ.");/*YOU'LL NEED IT*/
skip(1);
newqad(0);
if (nenhere) shldup=1.0;
if (neutz) attack(0); // bad luck to start in a Romulan Neutral Zone
}
int choose(void) {
tourn = 0;
thawed = 0;
skill = 0;
length = 0;
while (TRUE) {
if (fromcommandline) /* Can start with command line options */
fromcommandline = 0;
else
prout("[Все команды в игре отдаются на английском языке.\n Допустимо сокращать до двух первых букв.]");
/* proutn("Would you like a regular, tournament, or frozen game?"); */
proutn("Вы начинаете обычную(regular), турнирную(tournament), \nили сохраненную(frozen) игру?");
scan();
if (strlen(citem)==0) continue; // Try again
if (isit("tournament")) {
while (scan() == IHEOL) {
/* proutn("Type in tournament number-"); */
proutn("Наберите номер турнира-");
}
if (aaitem == 0) {
chew();
continue; // We don't want a blank entry
}
tourn = (int)aaitem;
thingx = -1;
srand((unsigned int)(int)aaitem);
break;
}
if (isit("frozen")) {
thaw();
chew();
if (*passwd==0) continue;
randomize();
Rand(); Rand(); Rand(); Rand();
if (!alldone) thawed = 1; // No plaque if not finished
report(1);
return TRUE;
}
if (isit("regular")) {
skip(2);
randomize();
Rand(); Rand(); Rand(); Rand();
break;
}
proutn("Что еще за \"");/*What is*/
proutn(citem);
prout("\"?");
chew();
}
while (length==0 || skill==0) {
if (scan() == IHALPHA) {
if (isit("short")) length = 1;
else if (isit("medium")) length = 2;
else if (isit("long")) length = 4;
else if (isit("novice")) skill = SNOVICE;
else if (isit("fair")) skill = SFAIR;
else if (isit("good")) skill = SGOOD;
else if (isit("expert")) skill = SEXPERT;
else if (isit("emeritus")) skill = SEMERITUS;
else {
proutn("Что еще за \"");/*What is*/
proutn(citem);
prout("\"?");
}
}
else {
chew();
/* if (length==0) proutn("Would you like a Short, Medium, or Long game? ");
else if (skill == 0) proutn("Are you a Novice, Fair, Good, Expert, or Emeritus player?");
*/ if (length==0) proutn("Вы предпочитаете короткую (short), среднюю (medium), или длинную(long) игру? ");
else if (skill == 0) proutn("Вы игрок уровня Новичок(novice), Салага(fair), Отличник(good), Эксперт(expert), или Эмеритус(emeritus)?");
}
}
while (TRUE) {
scan();
strcpy(passwd, citem);
chew();
if (*passwd != 0) break;
/* proutn("Please type in a secret password (9 characters maximum)-"); */
proutn("Введите секретный пароль (9 символов максимум)-");
}
#ifdef DEBUG
if (strcmp(passwd, "debug")==0) idebug = 1;
#endif
// Use parameters to generate initial values of things
damfac = 0.5 * skill;
d.rembase = 3.0*Rand()+2.0;
inbase = d.rembase;
inplan = (PLNETMAX/2) + (PLNETMAX/2+1)*Rand();
d.nromrem = (2.0+Rand())*skill;
d.nscrem = (skill > SFAIR? 1 : 0);
d.remtime = 7.0 * length;
intime = d.remtime;
d.remkl = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15); // d.remkl and inkling includes commanders and SC
inkling = d.remkl;
incom = skill + 0.0625*inkling*Rand();
d.remcom= min(10, incom);
incom = d.remcom;
d.remres = (inkling+4*incom)*intime;
inresor = d.remres;
if (inkling > 50) {
inbase = (d.rembase += 1);
}
#ifdef CAPTURE
brigcapacity = 400;
brigfree = brigcapacity;
kcaptured = 0; // TAA fix 6/2015
#endif
#ifdef CLOAKING
ncviol = 0; // TAA fix 6/2015
iscloaked = FALSE;
iscloaking = FALSE;
#endif
return FALSE;
}
void dropin(int iquad, int *ix, int *iy) {
do iran10(ix, iy);
while (quad[*ix][*iy] != IHDOT);
quad[*ix][*iy] = iquad;
}
void newcnd(void) {
condit = IHGREEN;
if (energy < 1000.0) condit = IHYELLOW;
if (d.galaxy[quadx][quady] > 99 || d.newstuf[quadx][quady] > 9)
condit = IHRED;
}
void newqad(int shutup) {
int quadnum = d.galaxy[quadx][quady];
int newnum = d.newstuf[quadx][quady];
int i, j, ix, iy, nplan;
iattak = 1;
justin = 1;
basex = basey = 0;
klhere = 0;
comhere = 0;
plnetx = plnety = 0;
ishere = 0;
irhere = 0;
iplnet = 0;
nenhere = 0;
neutz = 0;
inorbit = 0;
landed = -1;
ientesc = 0;
ithere = 0;
iseenit = 0;
#ifdef CLOAKING
isviolreported = FALSE;
#endif
if (iscate) {
// Attempt to escape Super-commander, so tbeam back!
iscate = 0;
ientesc = 1;
}
// Clear quadrant
for (i=1; i <= 10; i++)
for (j=1; j <= 10; j++) quad[i][j] = IHDOT;
// cope with supernova
if (quadnum > 999) {
return;
}
klhere = quadnum/100;
irhere = newnum/10;
nplan = newnum%10;
nenhere = klhere + irhere;
// Position Starship
quad[sectx][secty] = ship;
// Decide if quadrant needs a Tholian
if ((skill < SGOOD && Rand() <= 0.02) || /* Lighten up if skill is low */
(skill == SGOOD && Rand() <= 0.05) ||
(skill > SGOOD && Rand() <= 0.08)
#ifdef DEBUG
|| strcmp(passwd, "tholianx")==0
#endif
) {
do {
ithx = Rand() > 0.5 ? 10 : 1;
ithy = Rand() > 0.5 ? 10 : 1;
} while (quad[ithx][ithy] != IHDOT);
quad[ithx][ithy] = IHT;
ithere = 1;
/* Reserve unocupied corners */
if (quad[1][1]==IHDOT) quad[1][1] = 'X';
if (quad[1][10]==IHDOT) quad[1][10] = 'X';
if (quad[10][1]==IHDOT) quad[10][1] = 'X';
if (quad[10][10]==IHDOT) quad[10][10] = 'X';
}
if (quadnum >= 100) {
// Position ordinary Klingons
quadnum -= 100*klhere;
for (i = 1; i <= klhere; i++) {
dropin(IHK, &ix, &iy);
kx[i] = ix;
ky[i] = iy;
kdist[i] = kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy));
kpower[i] = Rand()*150.0 +300.0 +25.0*skill;
}
// If we need a commander, promote a Klingon
for (i = 1; i <= d.remcom ; i++)
if (d.cx[i]==quadx && d.cy[i]==quady) break;
if (i <= d.remcom) {
quad[ix][iy] = IHC;
kpower[klhere] = 950.0+400.0*Rand()+50.0*skill;
comhere = 1;
}
// If we need a super-commander, promote a Klingon
if (quadx == d.isx && quady == d.isy) {
quad[kx[1]][ky[1]] = IHS;
kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill;
iscate = 1;
ishere = 1;
}
}
// Put in Romulans if needed
for (i = klhere+1; i <= nenhere; i++) {
dropin(IHR, &ix, &iy);
kx[i] = ix;
ky[i] = iy;
kdist[i] = kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy));
kpower[i] = Rand()*400.0 + 450.0 + 50.0*skill;
}
sortkl();
// If quadrant needs a starbase, put it in
if (quadnum >= 10) {
quadnum -= 10;
dropin(IHB, &basex, &basey);
}
if (nplan) {
// If quadrant needs a planet, put it in
for (i=1; i <= inplan; i++)
if (d.plnets[i].x == quadx && d.plnets[i].y == quady) break;
if (i <= inplan) {
iplnet = i;
dropin(IHP, &plnetx, &plnety);
}
}
// Check for condition
newcnd();
// And finally the stars
for (i = 1; i <= quadnum; i++) dropin(IHSTAR, &ix, &iy);
// Check for RNZ
if (irhere > 0 && klhere == 0 && basex == 0) {
neutz = 1;
if (REPORTS) {
skip(1);
/* prout("LT. UHURA- \"Captain, an urgent message.");
prout(" I'll put it on audio.\" CLICK");
skip(1);
prout("INTRUDER! YOU HAVE VIOLATED THE ROMULAN NEUTRAL ZONE.");
prout("LEAVE AT ONCE, OR YOU WILL BE DESTROYED!");
*/ prout("Лейтенант Ухура- \"Капитан, срочное сообщение.");
prout(" Я включу на громкую связь.\" CLICK");
skip(1);
prout("НАРУШИТЕЛЬ! ВЫ ВТОРГЛИСЬ В НЕЙТРАЛЬНУЮ ЗОНУ РОМУЛАН.");
prout("НЕМЕДЛЕННО УЛЕТАЙТЕ, ИЛИ БУДЕТЕ УНИЧТОЖЕНЫ!");
}
}
if (shutup==0) {
// Put in THING if needed
if (thingx == quadx && thingy == quady) {
dropin(IHQUEST, &ix, &iy);
thingx = thingy = 0; // Transient
if (damage[DSRSENS] == 0.0) {
skip(1);
/* prout("MR. SPOCK- \"Captain, this is most unusual.");
prout(" Please examine your short-range scan.\"");
*/ prout("МИСТЕР СПОК- \"Капитан, это очень странно.");
prout(" Пожалуйста посмотрите на ближний сканер.\"");
}
}
}
// Put in a few black holes
for (i = 1; i <= 3; i++)
if (Rand() > 0.5) dropin(IHBLANK, &ix, &iy);
// Take out X's in corners if Tholian present
if (ithere) {
if (quad[1][1]=='X') quad[1][1] = IHDOT;
if (quad[1][10]=='X') quad[1][10] = IHDOT;
if (quad[10][1]=='X') quad[10][1] = IHDOT;
if (quad[10][10]=='X') quad[10][10] = IHDOT;
}
}
void sortkl(void) {
double t;
int sw, j, k;
// The author liked bubble sort. So we will use it. :-(
if (nenhere < 2) return;
do {
sw = FALSE;
for (j = 1; j < nenhere; j++)
if (kdist[j] > kdist[j+1]) {
sw = TRUE;
t = kdist[j];
kdist[j] = kdist[j+1];
kdist[j+1] = t;
t = kavgd[j];
kavgd[j] = kavgd[j+1];
kavgd[j+1] = t;
k = kx[j];
kx[j] = kx[j+1];
kx[j+1] = k;
k = ky[j];
ky[j] = ky[j+1];
ky[j+1] = k;
t = kpower[j];
kpower[j] = kpower[j+1];
kpower[j+1] = t;
}
} while (sw);
}
+843
View File
@@ -0,0 +1,843 @@
#include <ctype.h>
#ifdef MSDOS
#include <dos.h>
#endif
#ifdef WINDOWS
#include <windows.h>
#endif
#include <time.h>
#ifdef KOS32
#include <conio.h>
#include <kos32sys0.h>
#endif
#define INCLUDED // Define externs here
#include "sst.h"
/*int getch(void);
*/
static char line[128], *linep = line;
static int linecount; /* for paging */
static void clearscreen(void);
/* Compared to original version, I've changed the "help" command to
"call" and the "terminate" command to "quit" to better match
user expectations. The DECUS version apparently made those changes
as well as changing "freeze" to "save". However I like "freeze".
When I got a later version of Super Star Trek that I was converting
from, I added the emexit command.
That later version also mentions srscan and lrscan working when
docked (using the starbase's scanners), so I made some changes here
to do this (and indicating that fact to the player), and then realized
the base would have a subspace radio as well -- doing a Chart when docked
updates the star chart, and all radio reports will be heard. The Dock
command will also give a report if a base is under attack.
Movecom no longer reports movement if sensors are damaged so you wouldn't
otherwise know it.
Also added:
1. Better base positioning at startup
2. deathray improvement (but keeping original failure alternatives)
3. Tholian Web
4. Enemies can ram the Enterprise. Regular Klingons and Romulans can
move in Expert and Emeritus games. This code could use improvement.
5. The deep space probe looks interesting! DECUS version
6. Cloaking (with contributions from Erik Olofsen) and Capturing (BSD version).
*/
// I don't like the way this is done, relying on an index. But I don't
// want to invest the time to make this nice and table driven.
static char *commands[] = {
"srscan",
"lrscan",
"phasers",
"photons",
"move",
"shields",
"dock",
"damages",
"chart",
"impulse",
"rest",
"warp",
"status",
"sensors",
"orbit",
"transport",
"mine",
"crystals",
"shuttle",
"planets",
"request",
"report",
"computer",
"commands",
"emexit",
"probe",
"cloak",
"capture",
"score",
"abandon",
"destruct",
"freeze",
"deathray",
"debug",
"call",
"quit",
"help"
};
#define NUMCOMMANDS (sizeof(commands)/sizeof(char *))
static void listCommands(int x) {
prout(" SRSCAN MOVE PHASERS CALL\n"
" STATUS IMPULSE PHOTONS ABANDON\n"
" LRSCAN WARP SHIELDS DESTRUCT\n"
" CHART REST DOCK QUIT\n"
" DAMAGES REPORT SENSORS ORBIT\n"
" TRANSPORT MINE CRYSTALS SHUTTLE\n"
" PLANETS REQUEST DEATHRAY FREEZE\n"
" COMPUTER EMEXIT PROBE COMMANDS");
proutn(" ");
#ifdef SCORE
proutn("SCORE ");
#endif
#ifdef CLOAKING
proutn("CLOAK ");
#endif
#ifdef CAPTURE
proutn("CAPTURE ");
#endif
if (x) proutn("HELP ");
prout("");
}
static void helpme(void) {
int i, j;
char cmdbuf[32];
char linebuf[132];
FILE *fp;
/* Give help on commands */
int key;
key = scan();
while (TRUE) {
if (key == IHEOL) {
/* proutn("Help on what command?"); */
proutn("Справку по какой команде?");
key = scan();
}
if (key == IHEOL) return;
for (i = 0; i < NUMCOMMANDS; i++) {
if (strcmp(commands[i], citem)==0) break;
}
if (i != NUMCOMMANDS) break;
skip(1);
/* prout("Valid commands:"); */
prout("Перечень команд:");
listCommands(FALSE);
key = IHEOL;
chew();
skip(1);
}
if (i == 23) {
strcpy(cmdbuf, " ABBREV");
}
else {
strcpy(cmdbuf, " Mnemonic: ");
j = 0;
while ((cmdbuf[j+13] = toupper(commands[i][j])) != 0) j++;
}
fp = fopen("sst.doc", "r");
if (fp == NULL) {
/* prout("Spock- \"Captain, that information is missing from the");
prout(" computer. You need to find SST.DOC and put it in the");
prout(" current directory.\"");
*/ prout("Спок- \"Капитан, вся справочная информация пропала с нашего компьютера.");
prout(" Найдите файл SST.DOC и положите в текущую папку.\"");
return;
}
i = strlen(cmdbuf);
do {
if (fgets(linebuf, 132, fp) == NULL) {
/* prout("Spock- \"Captain, there is no information on that command.\""); */
prout("Спок- \"Капитан, по этой команде справочная информация не найдена.\"");
fclose(fp);
return;
}
} while (strncmp(linebuf, cmdbuf, i) != 0);
skip(1);
/* prout("Spock- \"Captain, I've found the following information:\""); */
prout("Спок- \"Капитан, я нашел следующую информацию:\"");
skip(1);
do {
if (linebuf[0]!=12) { // ignore page break lines
linebuf[strlen(linebuf)-1] = '\0'; // No \n at end
prout(linebuf);
}
fgets(linebuf,132,fp);
} while (strstr(linebuf, "******")==NULL);
fclose(fp);
}
static void makemoves(void) {
int i, hitme;
char ch;
while (TRUE) { /* command loop */
hitme = FALSE;
justin = 0;
Time = 0.0;
i = -1;
while (TRUE) { /* get a command */
chew();
skip(1);
proutn("COMMAND> ");
if (scan() == IHEOL) continue;
for (i=0; i < 29; i++) // Abbreviations allowed for the first 29 commands, only.
if (isit(commands[i]))
break;
if (i < 29) break;
for (; i < NUMCOMMANDS; i++)
if (strcmp(commands[i], citem) == 0) break;
if (i < NUMCOMMANDS
#ifndef CLOAKING
&& i != 26 // ignore the CLOAK command
#endif
#ifndef CAPTURE
&& i != 27 // ignore the CAPTURE command
#endif
#ifndef SCORE
&& i != 28 // ignore the SCORE command
#endif
#ifndef DEBUG
&& i != 33 // ignore the DEBUG command
#endif
) break;
if (skill <= SFAIR) {
/* prout("UNRECOGNIZED COMMAND. LEGAL COMMANDS ARE:"); */
prout("КОМАНДА НЕ РАСПОЗНАНА. ДЕЙСТВУЮЩИЕ КОМАНДЫ:");
listCommands(TRUE);
}
else prout("КОМАНДА НЕ РАСПОЗНАНА.");/*UNRECOGNIZED COMMAND*/
}
switch (i) { /* command switch */
case 0: // srscan
srscan(1);
break;
case 1: // lrscan
lrscan();
break;
case 2: // phasers
phasers();
if (ididit) {
#ifdef CLOAKING
if (irhere && d.date >= ALGERON && !isviolreported && iscloaked) {
/* prout("The Romulan ship discovers you are breaking the Treaty of Algeron!"); */
prout("Корабль ромуланцев заметил ваше нарушение Алгеронского соглашения!");
ncviol++;
isviolreported = TRUE;
}
#endif
hitme = TRUE;
}
break;
case 3: // photons
photon();
if (ididit) {
#ifdef CLOAKING
if (irhere && d.date >= ALGERON && !isviolreported && iscloaked) {
/* prout("The Romulan ship discovers you are breaking the Treaty of Algeron!"); */
prout("Корабль ромуланцев заметил ваше нарушение Алгеронского соглашения!");
ncviol++;
isviolreported = TRUE;
}
#endif
hitme = TRUE;
}
break;
case 4: // move
warp(1);
break;
case 5: // shields
sheild(1);
if (ididit) {
attack(2);
shldchg = 0;
}
break;
case 6: // dock
dock();
break;
case 7: // damages
dreprt();
break;
case 8: // chart
chart(0);
break;
case 9: // impulse
impuls();
break;
case 10: // rest
waiting();
if (ididit) hitme = TRUE;
break;
case 11: // warp
setwrp();
break;
case 12: // status
srscan(3);
break;
case 13: // sensors
sensor();
break;
case 14: // orbit
orbit();
if (ididit) hitme = TRUE;
break;
case 15: // transport "beam"
beam();
break;
case 16: // mine
mine();
if (ididit) hitme = TRUE;
break;
case 17: // crystals
usecrystals();
break;
case 18: // shuttle
shuttle();
if (ididit) hitme = TRUE;
break;
case 19: // Planet list
preport();
break;
case 20: // Status information
srscan(2);
break;
case 21: // Game Report
report(0);
break;
case 22: // use COMPUTER!
eta();
break;
case 23:
listCommands(TRUE);
break;
case 24: // Emergency exit
clearscreen(); // Hide screen
freeze(TRUE); // forced save
#ifdef KOS32
con_exit(1);
#endif
exit(1); // And quick exit
break;
case 25:
probe(); // Launch probe
break;
#ifdef CLOAKING
case 26:
cloak(); // turn on/off cloaking
if (iscloaking) {
attack(2); // We will be seen while we cloak
iscloaking = FALSE;
iscloaked = TRUE;
}
break;
#endif
#ifdef CAPTURE
case 27:
capture(); // Attempt to get Klingon ship to surrender
if (ididit) hitme = TRUE;
break;
#endif
#ifdef SCORE
case 28:
score(1); // get the score
break;
#endif
case 29: // Abandon Ship
abandn();
break;
case 30: // Self Destruct
dstrct();
break;
case 31: // Save Game
freeze(FALSE);
if (skill > SGOOD)
/* prout("WARNING--Frozen games produce no plaques!"); */
prout("ВНИМАНИЕ--Сохраненные игры не дают наград!");
break;
case 32: // Try a desparation measure
deathray();
if (ididit) hitme = TRUE;
break;
#ifdef DEBUG
case 33: // What do we want for debug???
debugme();
break;
#endif
case 34: // Call for help
help();
break;
case 35:
alldone = 1; // quit the game
#ifdef DEBUG
if (idebug) score(0);
#endif
break;
case 36:
helpme(); // get help
break;
}
for (;;) {
if (alldone) break; // Game has ended
#ifdef DEBUG
if (idebug) prout("2500");
#endif
if (Time != 0.0) {
events();
if (alldone) break; // Events did us in
}
if (d.galaxy[quadx][quady] == 1000) { // Galaxy went Nova!
atover(0);
continue;
}
if (nenhere == 0) movetho();
if (hitme && justin==0) {
attack(2);
if (alldone) break;
if (d.galaxy[quadx][quady] == 1000) { // went NOVA!
atover(0);
hitme = TRUE;
continue;
}
}
break;
}
if (alldone) break;
}
}
int main(int argc, char **argv) {
int i;
int hitme;
char ch;
#ifdef KOS32
if (con_init_console_dll()) return 1; // init fail
con_set_title("-SUPER- STAR TREK");
con_set_flags(CON_COLOR_GREEN);
#endif
#ifdef WINDOWS
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // Get handle to standard output
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN);
#endif
prelim();
if (argc > 1) { // look for -f option
if (strcmp(argv[1], "-f")== 0) {
coordfixed = 1;
argc--;
argv++;
}
}
if (argc > 1) {
fromcommandline = 1;
line[0] = '\0';
while (--argc > 0) {
strcat(line, *(++argv));
strcat(line, " ");
}
}
else fromcommandline = 0;
while (TRUE) { /* Play a game */
setup();
if (alldone) {
score(0);
alldone = 0;
}
else makemoves();
skip(2);
stars();
skip(1);
if (tourn && alldone) {
/* printf("Do you want your score recorded?"); */
printf("Вы хотите записать свои достижения?");
if (ja()) {
chew2();
freeze(FALSE);
}
}
/* printf("Do you want to play again?"); */
printf("Желаете сыграть заново?");
if (!ja()) break;
}
skip(1);
/* prout("May the Great Bird of the Galaxy roost upon your home planet."); */
prout("Пусть Великая Галактическая Птица совьет гнездо на Вашей родной планете.");
return 0;
}
void cramen(int i) {
/* return an enemy */
char *s;
switch (i) {
case IHR: s = "Ромуланец"; break;/*Romulan*/
case IHK: s = "Клингон"; break;/*Klingon*/
case IHC: s = "Коммандер"; break;/*Commander*/
case IHS: s = "СуперКоммандер"; break;/*Super-commander*/
case IHSTAR: s = "Звезда"; break;/*Star*/
case IHP: s = "Планета"; break;/*Planet*/
case IHB: s = "Станция"; break;/*Starbase*/
case IHBLANK: s = "Черная дыра"; break;/*Black hole*/
case IHT: s = "Толиан"; break;/*Tholean*/
case IHWEB: s = "Толианская сеть"; break;/*Tholean web*/
default: s = "НЛО??"; break;/*Unknown*/
}
proutn(s);
}
void cramlc(int key, int x, int y) {
if (key == 1) proutn(" Квадрант");/*Quadrant*/
else if (key == 2) proutn(" Сектор");/*Sector*/
proutn(" ");
crami(x, 1);
proutn(" - ");
crami(y, 1);
}
void crmena(int i, int enemy, int key, int x, int y) {
if (i == 1) proutn("***");
cramen(enemy);
proutn(" at");
cramlc(key, x, y);
}
void crmshp(void) {
char *s;
switch (ship) {
case IHE: s = "Энтерпрайз"; break;/*Enterprise*/
case IHF: s = "Королева Фей"; break;/*Faerie Queene*/
default: s = "Корабль???"; break;/*Ship*/
}
proutn(s);
}
void stars(void) {
prouts("******************************************************");
skip(1);
}
double expran(double avrage) {
return -avrage*log(1e-7 + Rand());
}
double Rand(void) {
return rand()/(1.0 + (double)RAND_MAX);
}
void iran8(int *i, int *j) {
*i = Rand()*8.0 + 1.0;
*j = Rand()*8.0 + 1.0;
}
void iran10(int *i, int *j) {
*i = Rand()*10.0 + 1.0;
*j = Rand()*10.0 + 1.0;
}
void chew(void) {
linecount = 0;
linep = line;
*linep = 0;
}
void chew2(void) {
/* return IHEOL next time */
linecount = 0;
linep = line+1;
*linep = 0;
}
int scan(void) {
int i;
char *cp;
linecount = 0;
// Init result
aaitem = 0.0;
*citem = 0;
// Read a line if nothing here
if (*linep == 0) {
if (linep != line) {
chew();
return IHEOL;
}
#ifdef KOS32
cp = gets(line);
if (!cp) exit(1);
#else
// We should really be using fgets
fgets(line,sizeof(line),stdin);
#endif
if (line[strlen(line)-1] == '\n')
line[strlen(line)-1] = '\0';
linep = line;
}
// Skip leading white space
while (*linep == ' ') linep++;
// Nothing left
if (*linep == 0) {
chew();
return IHEOL;
}
if (isdigit(*linep) || *linep=='+' || *linep=='-' || *linep=='.') {
// treat as a number
if (sscanf(linep, "%lf%n", &aaitem, &i) < 1) {
linep = line; // Invalid numbers are ignored
*linep = 0;
return IHEOL;
}
else {
// skip to end
linep += i;
return IHREAL;
}
}
// Treat as alpha
cp = citem;
while (*linep && *linep!=' ') {
if ((cp - citem) < 9) *cp++ = tolower(*linep);
linep++;
}
*cp = 0;
return IHALPHA;
}
int ja(void) {
chew();
while (TRUE) {
scan();
chew();
if (*citem == 'y') return TRUE;
if (*citem == 'n') return FALSE;
/* proutn("Please answer with \"Y\" or \"N\":"); */
proutn("Пожалуйста ответьте \"y\" or \"n\":");
}
}
void cramf(double x, int w, int d) {
char buf[64];
sprintf(buf, "%*.*f", w, d, x);
proutn(buf);
}
void crami(int i, int w) {
char buf[16];
sprintf(buf, "%*d", w, i);
proutn(buf);
}
double square(double i) { return i*i; }
static void clearscreen(void) {
/* Somehow we need to clear the screen */
proutn("\033[2J\033[0;0H"); /* Hope for an ANSI display */
}
/* We will pull these out in case we want to do something special later */
void pause(int i) {
#ifdef CLOAKING
if (iscloaked) return;
#endif
putchar('\n');
if (i==1) {
if (skill > SFAIR)
prout("[ПОЛУЧЕНО ОБЪЯВЛЕНИЕ...]");/*ANNOUNCEMENT ARRIVING*/
else
/* prout("[IMPORTANT ANNOUNCEMENT ARRIVING -- HIT ENTER TO CONTINUE]"); */
prout("[ПОЛУЧЕНО ВАЖНОЕ ОБЪЯВЛЕНИЕ -- НАЖМИТЕ ENTER ДЛЯ ПРОДОЛЖЕНИЯ]");
getchar();
}
else {
if (skill > SFAIR)
proutn("[ПРОДОЛЖИТЬ?]");/*CONTINUE*/
else
proutn("[НАЖМИТЕ ENTER ДЛЯ ПРОДОЛЖЕНИЯ]");/*HIT ENTER TO CONTINUE*/
getchar();
proutn("\r \r");
}
if (i != 0) {
clearscreen();
}
linecount = 0;
}
void skip(int i) {
while (i-- > 0) {
linecount++;
if (linecount >= 23)
pause(0);
else
putchar('\n');
}
}
void proutn(char *s) {
#ifndef KOS32
fputs(s, stdout);
#else
con_write_asciiz(s);
#endif
}
void prout(char *s) {
proutn(s);
skip(1);
}
void prouts(char *s) {
#ifdef KOS32
#define clock_t long int
#define clock() get_tick_count()
#define CLOCKS_PER_SEC 100
#endif
clock_t endTime;
/* print slowly! */
while (*s) {
endTime = clock() + CLOCKS_PER_SEC*0.05;
while (clock() < endTime) ;
putchar(*s++);
#ifndef KOS32
fflush(stdout);
#endif
}
}
void huh(void) {
chew();
skip(1);
/* prout("Beg your pardon, Captain?"); */
prout("Простите, не понял, Капитан?");
}
int isit(char *s) {
/* New function -- compares s to scaned citem and returns true if it
matches to the length of s */
return strncmp(s, citem, max(1, strlen(citem))) == 0;
}
#ifdef DEBUG
void debugme(void) {
proutn("Reset levels? ");
if (ja() != 0) {
if (energy < inenrg) energy = inenrg;
shield = inshld;
torps = intorps;
lsupres = inlsr;
}
proutn("Reset damage? ");
if (ja() != 0) {
int i;
for (i=0; i <= ndevice; i++) if (damage[i] > 0.0) damage[i] = 0.0;
stdamtim = 1e30;
}
proutn("Toggle idebug? ");
if (ja() != 0) {
idebug = !idebug;
if (idebug) prout("Debug output ON");
else prout("Debug output OFF");
}
proutn("Cause selective damage? ");
if (ja() != 0) {
int i, key;
for (i=1; i <= ndevice; i++) {
proutn("Kill ");
proutn(device[i]);
proutn("? ");
chew();
key = scan();
if (key == IHALPHA && isit("y")) {
damage[i] = 10.0;
if (i == DRADIO) stdamtim = d.date;
}
}
}
proutn("Examine/change events? ");
if (ja() != 0) {
int i;
for (i = 1; i < NEVENTS; i++) {
int key;
if (future[i] == 1e30) continue;
switch (i) {
case FSNOVA: proutn("Supernova "); break;
case FTBEAM: proutn("T Beam "); break;
case FSNAP: proutn("Snapshot "); break;
case FBATTAK: proutn("Base Attack "); break;
case FCDBAS: proutn("Base Destroy "); break;
case FSCMOVE: proutn("SC Move "); break;
case FSCDBAS: proutn("SC Base Destroy "); break;
}
cramf(future[i]-d.date, 8, 2);
chew();
proutn(" ?");
key = scan();
if (key == IHREAL) {
future[i] = d.date + aaitem;
}
}
chew();
}
proutn("Make universe visible? ");
if (ja() != 0) {
int i, j;
for (i = 1; i < 9; i++)
{
for (j = 1; j < 9; j++)
{
starch[i][j] = 1;
}
}
}
}
#endif
File diff suppressed because it is too large. Load diff
+514
View File
@@ -0,0 +1,514 @@
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#ifndef INCLUDED
#define EXTERN extern
#else
#define EXTERN
#endif
#ifdef WINDOWS
#define DEBUG
#define SCORE
#define CLOAKING
#define CAPTURE
#endif
#ifdef CLOAKING
#define ndevice (16)
#else
#define ndevice (15) // Number of devices
#endif
#define phasefac (2.0)
#define PLNETMAX (10)
#define NEVENTS (8)
typedef struct {
int x; /* Quadrant location of planet */
int y;
int pclass; /* class M, N, or O (1, 2, or 3) */
int crystals; /* has crystals */
int known; /* =1 contents known, =2 shuttle on this planet */
} PLANETS;
EXTERN struct foo {
int snap, // snapshot taken
remkl, // remaining klingons
remcom, // remaining commanders
rembase, // remaining bases
starkl, // destroyed stars
basekl, // destroyed bases
killk, // Klingons killed
killc, // commanders killed
galaxy[9][9], // The Galaxy (subscript 0 not used)
cx[11],cy[11], // Commander quadrant coordinates
baseqx[6], // Base quadrant X
baseqy[6], // Base quadrant Y
newstuf[9][9], // Extended galaxy goodies
isx, isy, // Coordinate of Super Commander
nscrem, // remaining super commanders
nromkl, // Romulans killed
nromrem, // Romulans remaining
nsckill, // super commanders killed
nplankl; // destroyed planets
PLANETS plnets[PLNETMAX+1]; // Planet information
#ifdef CAPTURE
int kcaptured, brigfree;
#endif
double date, // stardate
remres, // remaining resources
remtime; // remaining time
} d, snapsht; // Data that is snapshot
EXTERN char
quad[11][11]; // contents of our quadrant
// Scalar variables that are needed for freezing the game
// are placed in a structure. #defines are used to access by their
// original names. Gee, I could have done this with the d structure,
// but I just didn't think of it back when I started.
EXTERN struct foo2 {
int inkling,
inbase,
incom,
instar,
intorps,
condit,
torps,
ship,
quadx,
quady,
sectx,
secty,
length,
skill,
basex,
basey,
klhere,
comhere,
casual,
nhelp,
nkinks,
ididit,
gamewon,
alive,
justin,
alldone,
shldchg,
thingx,
thingy,
plnetx,
plnety,
inorbit,
landed,
iplnet,
imine,
inplan,
nenhere,
ishere,
neutz,
irhere,
icraft,
ientesc,
iscraft,
isatb,
iscate,
#ifdef DEBUG
idebug,
#endif
#ifdef CLOAKING
iscloaked,
iscloaking,
ncviol,
isviolreported,
#endif
#ifdef CAPTURE
brigcapacity,
#endif
iattak,
icrystl,
tourn,
thawed,
batx,
baty,
ithere,
ithx,
ithy,
iseenit,
probecx,
probecy,
proben,
isarmed,
nprobes;
double inresor,
intime,
inenrg,
inshld,
inlsr,
indate,
energy,
shield,
shldup,
warpfac,
wfacsq,
lsupres,
dist,
direc,
Time,
docfac,
resting,
damfac,
stdamtim,
cryprob,
probex,
probey,
probeinx,
probeiny;
} a;
#define inkling a.inkling // Initial number of klingons
#define inbase a.inbase // Initial number of bases
#define incom a.incom // Initian number of commanders
#define instar a.instar // Initial stars
#define intorps a.intorps // Initial/Max torpedoes
#define condit a.condit // Condition (red, yellow, green docked)
#define torps a.torps // number of torpedoes
#define ship a.ship // Ship type -- 'E' is Enterprise
#define quadx a.quadx // where we are
#define quady a.quady //
#define sectx a.sectx // where we are
#define secty a.secty //
#define length a.length // length of game
#define skill a.skill // skill level
#define basex a.basex // position of base in current quad
#define basey a.basey //
#define klhere a.klhere // klingons here
#define comhere a.comhere // commanders here
#define casual a.casual // causalties
#define nhelp a.nhelp // calls for help
#define nkinks a.nkinks //
#define ididit a.ididit // Action taken -- allows enemy to attack
#define gamewon a.gamewon // Finished!
#define alive a.alive // We are alive (not killed)
#define justin a.justin // just entered quadrant
#define alldone a.alldone // game is now finished
#define shldchg a.shldchg // shield is changing (affects efficiency)
#define thingx a.thingx // location of strange object in galaxy
#define thingy a.thingy //
#define plnetx a.plnetx // location of planet in quadrant
#define plnety a.plnety //
#define inorbit a.inorbit // orbiting
#define landed a.landed // party on planet (1), on ship (-1)
#define iplnet a.iplnet // planet # in quadrant
#define imine a.imine // mining
#define inplan a.inplan // initial planets
#define nenhere a.nenhere // Number of enemies in quadrant
#define ishere a.ishere // Super-commander in quandrant
#define neutz a.neutz // Romulan Neutral Zone
#define irhere a.irhere // Romulans in quadrant
#define icraft a.icraft // Kirk in Galileo
#define ientesc a.ientesc // Attempted escape from supercommander
#define iscraft a.iscraft // =1 if craft on ship, -1 if removed from game
#define isatb a.isatb // =1 if SuperCommander is attacking base
#define iscate a.iscate // Super Commander is here
#ifdef DEBUG
#define idebug a.idebug // Debug mode
#endif
#ifdef CLOAKING
#define iscloaked a.iscloaked // Cloaking is enabled
#define iscloaking a.iscloaking // However if iscloaking is TRUE then in process of cloaking and can be attacked
#define ncviol a.ncviol // Treaty violations
#define isviolreported a.isviolreported // Violation reported by Romulan in quadrant
#endif
#ifdef CAPTURE
#define kcaptured d.kcaptured // number of captured Klingons
#define brigfree d.brigfree // room in the brig
#define brigcapacity a.brigcapacity // How many Klingons the brig will hold
#endif
#define iattak a.iattak // attack recursion elimination (was cracks[4])
#define icrystl a.icrystl // dilithium crystals aboard
#define tourn a.tourn // Tournament number
#define thawed a.thawed // Thawed game
#define batx a.batx // Base coordinates being attacked
#define baty a.baty //
#define ithere a.ithere // Tholean is here
#define ithx a.ithx // coordinates of tholean
#define ithy a.ithy
#define iseenit a.iseenit // Seen base attack report
#define inresor a.inresor // initial resources
#define intime a.intime // initial time
#define inenrg a.inenrg // Initial/Max Energy
#define inshld a.inshld // Initial/Max Shield
#define inlsr a.inlsr // initial life support resources
#define indate a.indate // Initial date
#define energy a.energy // Energy level
#define shield a.shield // Shield level
#define shldup a.shldup // Shields are up
#define warpfac a.warpfac // Warp speed
#define wfacsq a.wfacsq // squared warp factor
#define lsupres a.lsupres // life support reserves
#define dist a.dist // movement distance
#define direc a.direc // movement direction
#define Time a.Time // time taken by current operation
#define docfac a.docfac // repair factor when docking (constant?)
#define resting a.resting // rest time
#define damfac a.damfac // damage factor
#define stdamtim a.stdamtim // time that star chart was damaged
#define cryprob a.cryprob // probability that crystal will work
#define probex a.probex // location of probe
#define probey a.probey
#define probecx a.probecx // current probe quadrant
#define probecy a.probecy
#define probeinx a.probeinx // Probe x,y increment
#define probeiny a.probeiny
#define proben a.proben // number of moves for probe
#define isarmed a.isarmed // Probe is armed
#define nprobes a.nprobes // number of probes available
EXTERN int
kx[21], // enemy sector locations
ky[21],
starch[9][9]; // star chart
EXTERN int fromcommandline; // Game start from command line options
EXTERN int coordfixed; // Fix those dumb coordinates.
EXTERN char passwd[10], // Self Destruct password
*device[ndevice+1];
EXTERN PLANETS nulplanet; // zeroed planet structure
EXTERN double
kpower[21], // enemy energy levels
kdist[21], // enemy distances
kavgd[21], // average distances
damage[ndevice+1], // damage encountered
future[NEVENTS+1]; // future events
EXTERN int iscore, iskill; // Common PLAQ
EXTERN double perdate;
typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
FHOLE
#ifdef CLOAKING
, FCLOAK
#endif
} FINTYPE ;
/* Skill levels */
typedef enum {SNOVICE=1, SFAIR, SGOOD, SEXPERT, SEMERITUS} SKILLTYPE;
EXTERN double aaitem;
EXTERN char citem[24];
/* Define devices */
#define DSRSENS 1
#define DLRSENS 2
#define DPHASER 3
#define DPHOTON 4
#define DLIFSUP 5
#define DWARPEN 6
#define DIMPULS 7
#define DSHIELD 8
#define DRADIO 9
#define DSHUTTL 10
#define DCOMPTR 11
#define DTRANSP 12
#define DSHCTRL 13
#define DDRAY 14 // Added deathray
#define DDSP 15 // Added deep space probe
#define DCLOAK 16 // Added cloaking device
/* Define future events */
#define FSPY 0 // Spy event happens always (no future[] entry)
// can cause SC to tractor beam Enterprise
#define FSNOVA 1 // Supernova
#define FTBEAM 2 // Commander tractor beams Enterprise
#define FSNAP 3 // Snapshot for time warp
#define FBATTAK 4 // Commander attacks base
#define FCDBAS 5 // Commander destroys base
#define FSCMOVE 6 // Supercommander moves (might attack base)
#define FSCDBAS 7 // Supercommander destroys base
#define FDSPROB 8 // Move deep space probe
#ifdef INCLUDED
PLANETS nulplanet = {0};
char *device[ndevice+1] = {
"",
/* "S. R. Sensors",
"L. R. Sensors",
"Phasers",
"Photon Tubes",
"Life Support",
"Warp Engines",
"Impulse Engines",
"Shields",
"Subspace Radio",
"Shuttle Craft",
"Computer",
"Transporter",
"Shield Control",
"Death Ray",
"D. S. Probe" */
"Ближние сенсоры",
"Дальние сенсоры",
"Фазеры",
"Фотонные торпеды",
"Жизнеобеспечение",
"Варп-двигатели",
"Импульсные двиг.",
"Силовые щиты",
"Радиостанция",
"Шаттл",
"Компьютер",
"Транспортер",
"Регулятор щитов",
"Луч Смерти",
"Зонды глуб.скан"
#ifdef CLOAKING
/* ,"Cloaking Device" */
,"Генератор невид."
#endif
};
#endif
#define ALGERON (2311) /* Date of the Treaty of Algeron */
#ifndef TRUE
#define TRUE (1)
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#define IHR 'R'
#define IHK 'K'
#define IHC 'C'
#define IHS 'S'
#define IHSTAR '*'
#define IHP 'P'
#define IHB 'B'
#define IHBLANK ' '
#define IHDOT '.'
#define IHQUEST '?'
#define IHE 'E'
#define IHF 'F'
#define IHT 'T'
#define IHWEB '#'
#define IHGREEN 'G'
#define IHYELLOW 'Y'
#define IHRED 'R'
#define IHDOCKED 'D'
/* Function prototypes */
void prelim(void);
void attack(int);
int choose(void);
void setup(void);
void score(int);
void atover(int);
void srscan(int);
void lrscan(void);
void phasers(void);
void photon(void);
void warp(int);
void sheild(int);
void dock(void);
void dreprt(void);
void chart(int);
void impuls(void);
void waiting(void);
void setwrp(void);
void events(void);
void report(int);
void eta(void);
void help(void);
void abandn(void);
void finish(FINTYPE);
void dstrct(void);
void kaboom(void);
void freeze(int);
void thaw(void);
void plaque(void);
int scan(void);
#define IHEOL (0)
#define IHALPHA (1)
#define IHREAL (2)
void chew(void);
void chew2(void);
void skip(int);
void prout(char *s);
void proutn(char *s);
void stars(void);
void newqad(int);
int ja(void);
void cramen(int);
void crmshp(void);
void cramlc(int, int, int);
double expran(double);
double Rand(void);
void iran8(int *, int *);
void iran10(int *, int *);
double square(double);
void dropin(int, int*, int*);
void newcnd(void);
void sortkl(void);
void lmove(void);
void ram(int, int, int, int);
void crmena(int, int, int, int, int);
void deadkl(int, int, int, int, int);
void timwrp(void);
void movcom(void);
void torpedo(double, double, int, int, double *);
void cramf(double, int, int);
void crami(int, int);
void huh(void);
void pause(int);
void nova(int, int);
void snova(int, int);
void scom(int *);
void hittem(double *);
void prouts(char *);
int isit(char *);
void preport(void);
void orbit(void);
void sensor(void);
void beam(void);
void mine(void);
void usecrystals(void);
void shuttle(void);
void deathray(void);
void debugme(void);
void attakreport(void);
void movetho(void);
void probe(void);
#ifndef WINDOWS
#ifndef KOS32
int min(int, int);
int max(int, int);
#endif
#endif
void randomize(void);
///int getch(void);
#ifdef CLOAKING
void cloak(void);
#endif
#ifdef CAPTURE
void capture(void);
#endif
#ifdef CLOAKING
#define REPORTS ((condit==IHDOCKED || damage[DRADIO]<=0.0) && !iscloaked)
#else
#define REPORTS (condit==IHDOCKED || damage[DRADIO]<=0.0)
#endif