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 2018-03-12 20:53:49 +00:00
parent 524cab3cd8
commit 3a4ccc4ac4
20 changed files with 9854 additions and 17 deletions

View File

@ -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

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;

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) {
@ -46,3 +44,4 @@ getch// </editor-fold>
return chbuf[0];
}
#endif
#endif

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);

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);

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("‹¥©â¥­ ­â “åãà - \"Š ¯¨â ­, <20> §¢¥¤ª  ‡¢¥§¤­®£® ”«®â  ¤®ª« ¤ë¢ ¥â");
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("‹¥©â.“åãà - \"Š ¯¨â ­, <20> §¢¥¤ª  ‡¢¥§¤­®£® ”«®â  ¤®ª« ¤ë¢ ¥â");
/* 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

View File

@ -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

View File

@ -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

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(" <20>®¢ëå §¢¥§¤.");/*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(" <20>®¢ëå §¢¥§¤.");/*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("***Š®à ¡«ì ®â¡à®è¥­ <20>®¢®© §¢¥§¤®©.");/*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("‘¨«  <20>®¢®© §¢¥§¤ë ¯¥à¥¬¥á⨫  ª®à ¡«ì.");
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("***Ž<><E282AC>Žœ! Ž<><E282AC>Žœ!");
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("<EFBFBD>®¯ë⪠ íªáâ७­®£® ¯¥à¥å¢ â  ã¯à ¢«¥­¨ï");
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;
}

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("Š®¬¯ìîâ¥à ¯®¢à¥¦¤¥­; <20>¥¢®§¬®¦­® § ¯ãáâ¨âì á ¬®ã­¨ç⮦¥­¨¥.");
return;
}
skip(1);
/* prouts("---WORKING---"); skip(1);
prout("SELF-DESTRUCT-SEQUENCE-ACTIVATED");
*/ prouts("---Ž†ˆ„€‰’…---"); skip(1);
prout("<EFBFBD><EFBFBD>Ž…„“<EFBFBD>€-€ŒŽ“<C5BD>ˆŽ†…<E280A0>ˆŸ-€Šˆˆ<E2809A>Ž<E2809A>");
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("‚‚…„ˆ’…-<2D><>ˆœ<E280B9>Ž-<2D><EFBFBD>Žœ-„‹Ÿ-<2D><>Ž„Ž†…<E280A0>ˆŸ-");
prout("‡€<EFBFBD>Š€-<2D><>Ž…„“<E2809E>-€ŒŽ“<C5BD>ˆŽ†…<E280A0>ˆŸ-ˆ<>€—…-");
prout("<EFBFBD><EFBFBD>Ž…„“<EFBFBD>€-€ŒŽ“<C5BD>ˆŽ†…<E280A0>ˆŸ-<2D>“„…-€<>Ž<EFBFBD>ˆ<E28099>Ž<E2809A>");
scan();
chew();
if (strcmp(passwd, citem) != 0) {
/* prouts("PASSWORD-REJECTED;"); skip(1);
prout("CONTINUITY-EFFECTED");
*/ prouts("<EFBFBD><EFBFBD>Žœ-<2D><E2809A><EFBFBD>;"); skip(1);
prout("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Žœ-<2D>””…Šˆ<CB86>");
skip(1);
return;
}
prouts("<EFBFBD><EFBFBD>Žœ-<2D><>ˆ<EFBFBD>Ÿ"); 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("<EFBFBD><EFBFBD>Ž™€‰-†…‘’ŽŠˆ‰-Œˆ<C592>"); /*GOODBYE-CRUEL-WORLD*/
skip(1);
}
skip(2);
kaboom();
}
void kaboom(void) {
stars();
if (ship==IHE) prouts("***");
prouts("********* <20>­âய¨ï ");/*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("<EFBFBD>®á«¥¤­¨¥ %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("¯®¢ë蠥⠂ á ¢ §¢ ­¨¨ á \"<EFBFBD>®¢¨çª \" ¤® \"‘ « £¨\".");
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("¯®¢ë蠥⠂ á ¢ §¢ ­¨¨ á \"Žâ«¨ç­¨ª \" ¤® \"<EFBFBD>ªá¯¥àâ \".");
break;
case SEXPERT:
/* prout("promotes you to Commodore Emeritus."); */
prout("¯®¢ë蠥⠂ á ¢ §¢ ­¨¨ ¤® Š®¬¬ ­¤¥à  <20>¬¥à¨âãá.");
skip(1);
/* prout("Now that you think you're really good, try playing");
prout("the \"Emeritus\" game. It will splatter your ego.");
*/ prout("’¥¯¥àì, ¥á«¨ ‚ë áç¨â ¥â¥ ᥡ¥ ॠ«ì­® ªàãâë¬, ¯®¯à®¡ã©â¥");
prout("ã஢¥­ì á«®¦­®á⨠\"<EFBFBD>¬¥à¨âãá\". <20>â® ãâ¨å®¬¨à¨â ¢ è¥ í£®.");
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("Š®¬¯ìîâ¥à- Ž˜ˆ<CB9C>Š€-Ž˜ˆ<CB9C>Š€-Ž˜ˆ<CB9C>Š€-Ž˜ˆ<CB9C>Š€");
skip(1);
prout(" ‚€˜-Ž<>-<2D><>˜€…-Ž‡ŒŽ†<C5BD>Žˆ-<2D>Ž‰-<2D><>Žƒ<C5BD>€ŒŒ");
prout(" <20><>Žƒ<C5BD>€ŒŒ€-„Ž<E280B9>€-‚›†ˆ’œ");
prout(" <20><>Žƒ<C5BD>€ŒŒ€-„Ž<E280B9>€-‚›†ˆ’œ");
prout(" <20><>Žƒ<C5BD>€ŒŒ€-„Ž<E280B9>€-‚›†ˆ’œ");
prout(" <20><>Žƒ<C5BD>€ŒŒ€-„Ž<E280B9>€-?- „Ž<E280B9>€ ? - ‚›†? ? -? ˆ’œ");
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("‚ë å®â¨â¥ ­ ¯¥ç â âì ᯨ᮪ ᢮¨å ¢ë᪠§ë¢ ­¨©, Š®¬ ­¤¥à <20>¬¥à¨âãá?");
proutn("(‚ ¬ ¯®âॡã¥âáï 132-ᨬ¢®«ì­ë© ¯à¨­â¥à.)");
chew();
if (ja()) {
igotit = 1;
}
}
}
}
// Only grant long life if alive (original didn't!)
skip(1);
/* prout("LIVE LONG AND PROSPER."); */
prout("„Ž‹ƒŽ‰ ‚€Œ †ˆ<CB86>ˆ ˆ <20><>Ž<E28099>ˆŸ.");
}
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("<EFBFBD> áᬮâॢ ¢ è¨ ¤¥©á⢨ï, ‚ë ");
if (d.remkl*3.0 > inkling) {
prout("®¯à ¢¤ ­ë.");/*aquitted*/
skip(1);
prout("„Ž‹ƒŽ‰ ‚€Œ †ˆ<CB86>ˆ ˆ <20><>Ž<E28099>ˆŸ.");/*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("¯®«ãç¨âì ¢â®à®© è ­á. <20>® ¯®áª®«ìªã á⠭権 ¡®«ìè¥ ­¥â,");
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("<EFBFBD>¥§ ‚ è¥£® ª®¬ ­¤®¢ ­¨ï, ª®à ¡«ì ");
crmshp();
prout(" ¡ë« ã­¨ç⮦¥­.");
break;
case FDPLANET:
/* prout("You and your mining party perish.");
skip(1);
prout("That was a great shot.");
*/ prout("‚ë ¡¥áá«¥¤­® ¯à®¯ «¨ ¢¬¥á⥠á è åâ¥à ¬¨.");
skip(1);
prout("<EFBFBD>â® ¡ë«  å®à®è ï ¯®¯ë⪠.");
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("<EFBFBD>¥§ ‚ è¥£® ª®¬ ­¤®¢ ­¨ï, ª®à ¡«ì ");
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("<EFBFBD>®¬ã« ­áª ï ˆ¬¯¥à¨ï ­¨ª®£¤  ¡®«ìè¥ ­¥ ¯®¢¥à¨â ¢ ¬.");
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("<EFBFBD>®§¤à ¢«ï¥¬!");
}
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("¢®§¢¥¤ãâ áâ âî ¢ ‚ èã ç¥áâì. <20>®ª®©â¥áì á ¬¨à®¬ ¨ áâ à ©â¥áì");
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("<EFBFBD>  ¤ ­­ë© ¬®¬¥­â ¢ è¨ ¡ ««ë --");
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("<EFBFBD>®­ãá §  ¯®¡¥¤ã ");
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("ˆ£à  <20>®¢¨çª  "); break;
case SFAIR: proutn("ˆ£à  ‘ « £¨ "); break;
case SGOOD: proutn("ˆ£à  Žâ«¨ç­¨ª  "); break;
case SEXPERT: proutn("ˆ£à  <20>ªá¯¥àâ  "); break;
case SEMERITUS: proutn("ˆ£à  <20>¬¥à¨âãá "); 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("<EFBFBD>ŽŒ<EFBFBD>ˆ…--<2D> ««ë ­¨ç¥£® ­¥ §­ ç â, ¯®ª  ¬¨áá¨ï ­¥ ®ª®­ç¥­ !\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("<EFBFBD>¥¢¥à­®¥ ¨¬ï.\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, " \"Š®¬ ­¤®à <20>¬¥à¨âãá\"\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," ã஢¥­ì <20>ªá¯¥àâ \n\n"); break;
case SEMERITUS: fprintf(fp,"ã஢¥­ì <20>¬¥à¨âãá \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, " <20>â®â ¤¥­ì %.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, " <20>â®â ¤¥­ì %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);
}

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

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

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("<EFBFBD>®¢à¥¦¤¥­ë ¨ ¢ à¯- ¨ ¨¬¯ã«ìá­ë¥ ¤¢¨£ â¥«¨.");
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("<EFBFBD>ã«¥¢®© ‘ã«ã- \"‚ë室¨¬ ­  áâ ­¤ àâ­ãî ®à¡¨âã, ‘íà.\"");
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(" <20>« ­¥â  ¢");
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(" <20>®«ã祭­ë¥ ¤ ­­ë¥ ¯®ª §ë¢ îâ");
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("<EFBFBD>ˆˆ<EFBFBD> <20>ˆˆ<CB86> <20>ˆˆ<CB86>");
skip(2);
prout("\"Š¨àª - <20>­â¥à¯à ©§ã - ‡ å¢ â ¯® ª®®à¤¨­ â ¬...¢ª«îç ©â¥.\"");
}
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("<EFBFBD>““ˆˆˆŽŽˆˆˆ<EFBFBD>ƒ . . .<2E>ŸŒ");
skip(2);
/* prout("Scotty- \"Oh my God! I've lost them.\""); */
prout("‘ª®ââ¨- \"<EFBFBD>®¦¥ ¬®©! Ÿ ¯®â¥àï« ¨å.\"");
finish(FLOST);
return;
}
/* prouts(". . . . . . .E.E.EEEERRRRRIIIIIOOOHWW"); */
prouts(". . . . . . .….….….……………<E280A6><E280A6><EFBFBD><EFBFBD><EFBFBD>‰‰‰‰ˆˆˆˆŽŽŽŽŽ<C5BD>");
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("<EFBFBD>  ¯« ­¥â¥ ­¥â ¤¨«¨â¨¥¢ëå ªà¨áâ ««®¢.");
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("<EFBFBD>¥â ­¨ª ª®£® á¬ëá«  ¤®¡ë¢ âì ¥é¥.");
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(" \"€ªâ¨¢ æ¨ï ¯à®¨§¢¥¤¥­ ! - - —â® â® ­¥ â ª! <20>â® ¦¥***");
skip(2);
/* prouts("***RED ALERT! RED A*L********************************"); */
prouts("***Ž<><E282AC>Žœ! Ž<>€*<>Ž********************************");
skip(1);
stars();
/* prouts("****************** KA-BOOM!!!! *******************"); */
prouts("****************** Š€-<2D>“Œ!!!! *******************");
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("<EFBFBD> ­¥«ì ¯à¨¡®à®¢");
prout(" ¢á¡¥á¨« áì, ­® ï ¤ã¬ î, çâ® ¢á¥");
prout(" ¡ã¤¥â à ¡®â âì!! <20>®§¤à ¢«ïî, ‘íà!\"");
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("<EFBFBD>  Š®à®«¥¢¥ ”¥© ­¥â è ââ« .");
}
else if (damage[DSHUTTL] > 0)
/* prout("The Galileo is damaged."); */
prout("ƒ «¨«¥® ¯à®¢à¥¦¤¥­.");
/* else prout("Shuttle craft is now serving Big Mac's."); */
else prout("˜ â⫠ᥩç á à §¢®§¨â <20>¨£Œ ª¨.");
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("<EFBFBD>¥à¢ë© ®ä¨æ¥à ‘¯®ª- \"Š ¯¨â ­, ï à ááç¨â «, çâ® íâ®â");
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("<EFBFBD>®á ¤ª  § ¢¥à襭 .");/*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("¤«ï ¢®§¢à é¥­¨ï ­  <20>­â¥à¯à ©§.");
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("<EFBFBD>®«¥â § ¢¥à襭.");
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("<EFBFBD> àâ¨ï è åâ¥à®¢ ᮡࠫ áì ¢  ­£ à¥,");
prout("£®â®¢ë¥ ª ¯®á ¤ª¥ ­  è ââ« \"ƒ «¨«¥®\".");
skip(1);
prouts("„¢¥à¨  ­£ à  ®âªà뢠îâáï; ¯®«¥â ­ ç¨­ ¥âáï.");
skip(1);
icraft = 1;
iscraft = 0;
if (consumeTime()) return;
d.plnets[iplnet].known = 2;
landed = 1;
icraft = 0;
prout("<EFBFBD>®á ¤ª  § ¢¥à襭 ");
return;
}
}
void deathray(void) {
double r = Rand();
ididit = 0;
skip(1);
chew();
if (ship != IHE) {
/* prout("Ye Faerie Queene has no death ray."); */
prout("<EFBFBD>  Š®à®«¥¢¥ ”¥© ­¥â ‹ãç  ‘¬¥àâ¨.");
return;
}
if (nenhere==0) {
/* prout("Sulu- \"But Sir, there are no enemies in this quadrant.\""); */
prout("‘ã«ã- \"<EFBFBD>® ‘íà, ¢ í⮬ ª¢ ¤à ­â¥ ¢à £¨ ®âáãâáâ¢ãîâ.\"");
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("‘¯®ª- \"Š ¯¨â ­, '<27>ªá¯¥à¨¬¥­â «ì­ë© ‹ãç ‘¬¥àâ¨'");
prout(" ¢¥á쬠 ­¥¯à¥¤áª §ã¥¬. <20> áᬮâà¨â¥  «ìâ¥à­ â¨¢ë,");
prout(" ‚ë ã¢¥à¥­ë ¢ ࠧ㬭®á⨠í⮣®?\" ");
if (ja()==0) return;
/* prout("Spock- \"Acknowledged.\""); */
prout("‘¯®ª- \"<EFBFBD>®¤â¢¥à¦¥­¨¥ ¯à¨­ïâ®.\"");
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("‘¯®ª- \"<EFBFBD>®¤£®â®¢ª  ‹ãç  § ¢¥à襭 , ‘íà.\"");
prout("Š¨àª- \"‚ª«îç ©!\"");
skip(1);
prouts("ˆˆˆˆˆ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
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("Œ¨ç¬ ­ —¥å®¢- \"<EFBFBD>®§¤à ¢«¥­¨ï, Š ¯¨â ­!\"");
if (d.remkl == 0) finish(FWON);
/* prout("Spock- \"Captain, I believe the `Experimental Death Ray'"); */
prout("‘¯®ª- \"Š ¯¨â ­, ï ¤ã¬ î, `<60>ªá¯¥à¨¬¥­â «ì­ë© ‹ãç ‘¬¥àâ¨'");
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("***Ž<><E282AC>Žœ! Ž<><E282AC>Žœ!");
skip(1);
prout("***<2A>ˆ<CB86>…†…<E280A0> <E2809A><>ˆŒ€<E28099>ˆˆ!");
skip(1);
prouts("***Ž<><E282AC>Žœ! Ž<>€*<>Ž********************************");
skip(1);
stars();
prouts("****************** Š€-<2D>“Œ!!!! *******************");
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("Š¨àª- \"<EFBFBD>  ãå! <20>  ãå!\"");
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("‘ã«ã- \"Š ¯¨â ­! <20>â® --—’Ž?!?!\"");
skip(2);
proutn("‘¯®ª- \"Ÿ ¤ã¬ î ¯®¤å®¤ï饥 á«®¢®");
prouts(" *“„ˆˆœ<E280B9>Ž*");
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(" - - - - - - *<2A>…—ŽŒ*.");
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;
}

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("<EFBFBD>â® âãà­¨à­ ï ¨£à  %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("<EFBFBD>ë«® ");
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("<EFBFBD> §¢¥¤ë¢ â¥«ì­ë© §®­¤ á ¡®¥£®«®¢ª®© ¢ â®çª¥");
else
proutn("<EFBFBD> §¢¥¤ë¢ â¥«ì­ë© §®­¤ ¢ â®çª¥");/*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("<EFBFBD>Ž<EFBFBD> „€œ<E280B9>…ƒŽ Ž<>‡Ž<E280A1><20>Ž<C5BD>…†„…<E2809E>.");
return;
}
skip(1);
/* proutn("Starbase's long-range scan for"); */
proutn("ˆá¯®«ì§ã¥¬ ᥭá®àë á⠭樨 ¤«ï");
}
else {
skip(1);
/* proutn("Long-range scan for"); */
proutn("<EFBFBD>ந§¢®¤¨¬ ¤ «ì­¥¥ ᪠­¨à®¢ ­¨¥ ¤«ï");
}
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("<EFBFBD>Ž„ˆ…Œ€ -<>…ŒŸ <20><20>…ŒŽ<C592>-");
prout(" ŠŽ‘ŒŽ‘… <20><E28099>ˆˆ");
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("…‡„<EFBFBD>€Ÿ Š€<C5A0>ˆ<E28098>Ž‰ —€‘’ˆ ƒ€‹€Š’ˆŠˆ");
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("(<28>®á«¥¤­¥¥ ®¡­®¢«¥­¨¥ ¤ ­­ëå ");/*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("<EFBFBD>ˆ<EFBFBD>ˆ<E28098>Ž<E28098> <20>Ž<C5BD>…†„…<E2809E>");
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("‡€<EFBFBD><EFBFBD>Ž <20><EFBFBD><E282AC>Ž‡<C5BD><EFBFBD>. Š®à४â­ë¥ § ¯à®áë (¤¢¥ ¡ãª¢ë):\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 = "Š<EFBFBD><EFBFBD>"; break;/*RED*/
case IHGREEN: cp = "‡…<EFBFBD>"; break;/*GREEN*/
case IHYELLOW: cp = "†…‹’›‰"; break;/*YELLOW*/
case IHDOCKED: cp = "<EFBFBD><EFBFBD>ˆŠŽ<EFBFBD>"; break;/*DOCKED*/
}
/* printf(" Condition %s", cp); */
printf(" ‘®áâ®ï­¨¥/‘â âãá %s", cp);
#ifdef CLOAKING
if (iscloaked) printf(", Œ€Šˆ<C5A0>Ž<E2809A>");/*CLOAKED*/
#endif
break;
case 3:
printf(" <20>®«®¦¥­¨¥ ");/*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("<EFBFBD>Ž<EFBFBD>…†„…<EFBFBD>Ž, ¯¨â ¥¬áï ®â á⠭樨");
else
printf("<EFBFBD>Ž<EFBFBD>…†„…<EFBFBD>Ž, १¥à¢=%4.2f", lsupres);
}
else
printf("€Šˆ<EFBFBD>Ž");/*ACTIVE*/
break;
case 5:
printf(" ‚ à¯-ä ªâ®à %.1f", warpfac);/*Warp Factor*/
break;
case 6:
printf(" <20>­¥à£¨ï %.2f", energy);/*Energy */
break;
case 7:
printf(" ’®à¯¥¤ %d", torps);/*Torpedoes*/
break;
case 8:
printf(" ‘¨«®¢ë¥ é¨âë ");/*Shields*/
if (damage[DSHIELD] != 0)
printf("<EFBFBD>Ž<EFBFBD>…†„…<EFBFBD>,");/*DAMAGED*/
else if (shldup)
printf("€Šˆ<EFBFBD>,");/*UP*/
else
printf("ŽŠž—…<EFBFBD>,");/*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("ŠŽŒ<EFBFBD>œž<EFBFBD> <20>Ž<C5BD>…†„…<E2809E>, ˆ<CB86>Žœ‡“ž <20>Žœ<E280B9>‰ Š€œŠ“ŸŽ<E28099>.");
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("<EFBFBD>¥¤®áâ â®ç­® í­¥à£¨¨, ‘íà: ­ ¬ ­ã¦­® ");
cramf(tpower, 1, 1);
proutn (" ¥¤¨­¨æ.");/*units*/
if (shldup==0 || tpower > energy*2.0) {
if (!wfl) return;
/* proutn("New warp factor to try? "); */
proutn("<EFBFBD>஡㥬 ¤à㣮© ¢ à¯-ä ªâ®à? ");
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("<EFBFBD>® ¥á«¨ ®¯ãáâ¨âì ᨫ®¢ë¥ é¨âë,");
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("<EFBFBD> á ãáâந⠫ï ᪮à®áâì ¢ à¯ .");
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("<EFBFBD>¥ç «ì­®, ­® ª ⮬㠢६¥­¨ ”¥¤¥à æ¨ï ¡ã¤¥â ã­¨ç⮦¥­ .");
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("<EFBFBD>஡㥬 ¤à㣮© ¢ à¯-ä ªâ®à? ");
if (scan() == IHREAL) {
wfl = TRUE;
twarp = aaitem;
if (twarp<1.0 || twarp > 10.0) {
huh();
return;
}
}
else {
chew();
skip(1);
return;
}
}
}

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("<EFBFBD>¥¢®§¬®¦­® á®åà ­¨âì ¨£àã ¢ ä ©« ");
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("<EFBFBD>¥ ¬®£ã ­ ©â¨ ä ©« ");/*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("<EFBFBD>  Š®à®«¥¢¥ ”¥© ®âáãâáâ¢ã¥â è ââ«.");
return;
}
if (damage[DSHUTTL]<0) {
/* prout("Shuttle craft now serving Big Mac's."); */
prout("˜ â⫠⥯¥àì ¨á¯®«ì§ã¥âáï ¤«ï à §¢®§ª¨ <20>¨£Œ ª®¢.");
return;
}
if (damage[DSHUTTL]>0) {
/* prout("Shuttle craft damaged."); */
prout("˜ ââ« ¯®¢à¥¦¤¥­.");
return;
}
if (landed==1) {
/* prout("You must be aboard the Enterprise."); */
prout("‚ë ¤®«¦­ë ¡ëâì ­  ¡®àâã <20>­â¥à¯à ©§ .");
return;
}
if (iscraft!=1) {
/* prout("Shuttle craft not currently available."); */
prout("˜ ââ« ¢ ­ áâ®ï騩 ¬®¬¥­â ­¥¤®áâ㯥­.");
return;
}
/* Print abandon ship messages */
skip(1);
/* prouts("***ABANDON SHIP! ABANDON SHIP!"); */
prouts("***<2A>€Š“€ˆŸ! <20>€Š“€ˆŸ!");
skip(1);
/* prouts("***ALL HANDS ABANDON SHIP!"); */
prouts("***‚‘…Œ <20>…Œ…„<E280B9><E280A6>Ž <20>ŽŠˆ<C5A0>œ ŠŽ<C5A0><EFBFBD>œ!");
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"
"”«®â  ž... <20>­â¥à¯à ©§, ¢ è¥ § ¤ ­¨¥ ­ ©â¨ ¨ ã­¨ç⮦¨âì\n"
"¢â®à£è¨¥áï á¨«ë ¢ ª®«¨ç¥á⢥ %d «¨­¥©­ëå ªà¥©á¥à®¢.\n",
inkling);
printf("‚ ¬ ¯¥à¢®­ ç «ì­® ®â¢¥¤¥­® %d §¢¥§¤­ëå «¥â ­  § ¢¥à襭¨¥\n"
"¬¨áᨨ. <20>® 室㠢믮«­¥­¨ï ¢à¥¬ï ¬®¦¥â ¡ëâì 㢥«¨ç¥­®.\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("<EFBFBD>­â¥à¯à ©§ ­ å®¤¨âáï ¢ â®çª¥");
cramlc(1, quadx, quady);
proutn(" ");
cramlc(2, sectx, secty);
skip(2);
/* prout("Good Luck!"); */
prout("“¤ ç¨!");
if (d.nscrem) proutn(" Ž<>€ ‚€Œ <20><>ˆƒŽ„ˆŸ.");/*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("<EFBFBD> ¡¥à¨â¥ ­®¬¥à âãà­¨à -");
}
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("‚ë ¨£à®ª ã஢­ï <20>®¢¨ç®ª(novice), ‘ « £ (fair), Žâ«¨ç­¨ª(good), <20>ªá¯¥àâ(expert), ¨«¨ <20>¬¥à¨âãá(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("<EFBFBD><EFBFBD>˜ˆœ! Ž<E28099>ƒˆœ <20>…‰<E280B0>œ<E280B9>“ž ‡Ž<E280A1><20>ŽŒ“<E280B9>.");
prout("<EFBFBD>…Œ…„<EFBFBD><EFBFBD>Ž “‹…’€‰’…, ˆˆ <20>“„…… “<>ˆŽ†…<E280A0>!");
}
}
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("Œˆ<EFBFBD> <>ŽŠ- \"Š ¯¨â ­, íâ® ®ç¥­ì áâà ­­®.");
prout(" <20>®¦ «ã©áâ  ¯®á¬®âà¨â¥ ­  ¡«¨¦­¨© ᪠­¥à.\"");
}
}
}
// 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);
}

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("<EFBFBD>¥à¥ç¥­ì ª®¬ ­¤:");
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(" <20> ©¤¨â¥ ä ©« 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("ŠŽŒ€<EFBFBD>„€ <20><20><E282AC>Ž‡<C5BD><EFBFBD>€. „…‰‘’‚“ž™ˆ… ŠŽŒ€<C592>:");
listCommands(TRUE);
}
else prout("ŠŽŒ€<EFBFBD>„€ <20><20><E282AC>Ž‡<C5BD><EFBFBD>€.");/*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("<EFBFBD>ˆŒ€<EFBFBD>ˆ…--‘®åà ­¥­­ë¥ ¨£àë ­¥ ¤ îâ ­ £à ¤!");
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("<EFBFBD>ãáâì ‚¥«¨ª ï ƒ « ªâ¨ç¥áª ï <20>â¨æ  ᮢì¥â £­¥§¤® ­  ‚ è¥© த­®© ¯« ­¥â¥.");
return 0;
}
void cramen(int i) {
/* return an enemy */
char *s;
switch (i) {
case IHR: s = "<EFBFBD>®¬ã« ­¥æ"; 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 = "<EFBFBD>« ­¥â "; 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 = "<EFBFBD>Ž??"; 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 = "<EFBFBD>­â¥à¯à ©§"; 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("<EFBFBD>®¦ «ã©áâ  ®â¢¥âì⥠\"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("[<5B>Ž“—…<E28094>Ž Ž<>šŸ<E280B9>ˆ…...]");/*ANNOUNCEMENT ARRIVING*/
else
/* prout("[IMPORTANT ANNOUNCEMENT ARRIVING -- HIT ENTER TO CONTINUE]"); */
prout("[<5B>Ž“—…<E28094>Ž €†<E282AC>Ž… Ž<>šŸ<E280B9>ˆ… -- <20>€†Œˆ… ENTER „‹Ÿ <20><>Ž„Ž†…<E280A0>ˆŸ]");
getchar();
}
else {
if (skill > SFAIR)
proutn("[<5B><>Ž„Žˆœ?]");/*CONTINUE*/
else
proutn("[<5B>€†Œˆ… ENTER „‹Ÿ <20><>Ž„Ž†…<E280A0>ˆŸ]");/*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("<EFBFBD>à®áâ¨â¥, ­¥ ¯®­ï«, Š ¯¨â ­?");
}
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

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" */
"<EFBFBD>«¨¦­¨¥ ᥭá®àë",
"„ «ì­¨¥ ᥭá®àë",
"” §¥àë",
"”®â®­­ë¥ â®à¯¥¤ë",
"†¨§­¥®¡¥á¯¥ç¥­¨¥",
"‚ à¯-¤¢¨£ â¥«¨",
"ˆ¬¯ã«ìá­ë¥ ¤¢¨£.",
"‘¨«®¢ë¥ é¨âë",
"<EFBFBD> ¤¨®áâ ­æ¨ï",
"˜ ââ«",
"Š®¬¯ìîâ¥à",
"’࠭ᯮàâ¥à",
"<EFBFBD>¥£ã«ïâ®à é¨â®¢",
"‹ãç ‘¬¥àâ¨",
"‡®­¤ë £«ã¡.᪠­"
#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