+#include <unistd.h>\r
#include "sst.h"\r
\r
static void getcd(int, int);\r
\r
-void move(void) {\r
+void imove(void) {\r
double angle, deltax, deltay, bigger, x, y,\r
- finald, finalx, finaly, stopegy;\r
- int trbeam = 0, n, l, ix, iy, kink, kinks, iquad;\r
+ finald, finalx, finaly, stopegy, probf;\r
+ int trbeam = 0, n, l, ix=0, iy=0, kink, kinks, iquad;\r
\r
if (inorbit) {\r
prout("Helmsman Sulu- \"Leaving standard orbit.\"");\r
quady = (iy+9)/10;\r
sectx = ix - 10*(quadx-1);\r
secty = iy - 10*(quady-1);\r
- proutn("\nEntering");\r
- cramlc(1, quadx, quady);\r
- skip(1);\r
+ proutn("\n\rEntering %s.",\r
+ cramlc(quadrant, quadx, quady));\r
game.quad[sectx][secty] = ship;\r
newqad(0);\r
+ if (skill>1) attack(0);\r
return;\r
}\r
iquad = game.quad[ix][iy];\r
case IHC:\r
case IHS:\r
case IHR:\r
+ case IHQUEST:\r
sectx = ix;\r
secty = iy;\r
ram(0, iquad, sectx, secty);\r
skip(1);\r
proutn("***");\r
crmshp();\r
- proutn(" pulled into black hole at");\r
- cramlc(2, ix, iy);\r
- skip(1);\r
- finish(FHOLE);\r
+ proutn(" pulled into black hole at ");\r
+ prout(cramlc(sector, ix, iy));\r
+ /*\r
+ * Getting pulled into a black \r
+ * hole was certain death in\r
+ * Almy's original. Stas \r
+ * Sergeev added a possibility\r
+ * that you'll get timewarped\r
+ * instead.\r
+ */\r
+ n=0;\r
+ for (l=1;l<=NDEVICES+1;l++)\r
+ if (game.damage[l]>0) n++;\r
+ probf=pow(1.4,(energy+shield)/5000.0-1.0)*\r
+ pow(1.3,1.0/(n+1)-1.0);\r
+ if (Rand()>probf) \r
+ timwrp();\r
+ else \r
+ finish(FHOLE);\r
return;\r
default:\r
/* something else */\r
skip(1);\r
crmshp();\r
if (iquad == IHWEB)\r
- proutn(" encounters Tholian web at");\r
+ proutn(" encounters Tholian web at ");\r
else\r
- proutn(" blocked by object at");\r
- cramlc(2, ix,iy);\r
+ proutn(" blocked by object at ");\r
+ proutn(cramlc(sector, ix,iy));\r
prout(";");\r
proutn("Emergency stop required ");\r
- cramf(stopegy, 0, 2);\r
- prout(" units of energy.");\r
+ prout("%2d units of energy.", (int)stopegy);\r
energy -= stopegy;\r
finalx = x-deltax+0.5;\r
sectx = finalx;\r
}\r
newcnd();\r
iattak = 0;\r
+#ifdef SERGEEV\r
+ drawmaps(0);\r
+#endif /* SERGEEV */\r
return;\r
}\r
\r
-void dock(void) {\r
+void dock(int l) {\r
chew();\r
- if (condit == IHDOCKED) {\r
+ if (condit == IHDOCKED && l) {\r
prout("Already docked.");\r
return;\r
}\r
return;\r
}\r
condit = IHDOCKED;\r
- prout("Docked.");\r
+ if (l) prout("Docked.");\r
+ ididit=1;\r
if (energy < inenrg) energy = inenrg;\r
shield = inshld;\r
torps = intorps;\r
(game.future[FCDBAS] < 1e30 || isatb == 1) && iseenit == 0) {\r
/* get attack report from base */\r
prout("Lt. Uhura- \"Captain, an important message from the starbase:\"");\r
- attakreport();\r
+ attakreport(0);\r
iseenit = 1;\r
}\r
}\r
are always displayed y - x, where +y is downward! */\r
\r
\r
- int irowq=quadx, icolq=quady, irows, icols, itemp=0, iprompt=0, key;\r
+ int irowq=quadx, icolq=quady, irows, icols, itemp=0, iprompt=0, key=0;\r
double xi, xj, xk, xl;\r
double deltax, deltay;\r
int automatic = -1;\r
if (!isprobe) {\r
if (itemp) {\r
if (iprompt) {\r
- proutn("Helmsman Sulu- \"Course locked in for");\r
- cramlc(2, irows, icols);\r
- prout(".\"");\r
+ proutn("Helmsman Sulu- \"Course locked in for %s.\"",\r
+ cramlc(sector, irows, icols));\r
}\r
}\r
else prout("Ensign Chekov- \"Course laid in, Captain.\"");\r
prout("First Officer Spock- \"Captain, the impulse engines");\r
prout("require 20.0 units to engage, plus 100.0 units per");\r
if (energy > 30) {\r
- proutn("quadrant. We can go, therefore, a maximum of ");\r
- cramf(0.01 * (energy-20.0)-0.05, 0, 1);\r
+ proutn("quadrant. We can go, therefore, a maximum of %d", \r
+ (int)(0.01 * (energy-20.0)-0.05));\r
prout(" quadrants.\"");\r
}\r
else {\r
if (Time >= game.state.remtime) {\r
prout("First Officer Spock- \"Captain, our speed under impulse");\r
prout("power is only 0.95 sectors per stardate. Are you sure");\r
- prout("we dare spend the time?\"");\r
+ proutn("we dare spend the time?\" ");\r
if (ja() == 0) return;\r
}\r
/* Activate impulse engines and pay the cost */\r
- move();\r
+ imove();\r
ididit = 1;\r
if (alldone) return;\r
power = 20.0 + 100.0*dist;\r
if (Time >= 0.8*game.state.remtime) {\r
skip(1);\r
prout("First Officer Spock- \"Captain, I compute that such");\r
- proutn(" a trip would require approximately ");\r
- cramf(100.0*Time/game.state.remtime, 0, 2);\r
+ proutn(" a trip would require approximately %2.0f",\r
+ 100.0*Time/game.state.remtime);\r
prout(" percent of our");\r
- prout(" remaining time. Are you sure this is wise?\"");\r
- if (ja() == 0) { ididit = 0; return;}\r
+ proutn(" remaining time. Are you sure this is wise?\" ");\r
+ if (ja() == 0) { ididit = 0; Time=0; return;}\r
}\r
}\r
/* Entry WARPX */\r
\r
\r
/* Activate Warp Engines and pay the cost */\r
- move();\r
+ imove();\r
if (alldone) return;\r
energy -= dist*warpfac*warpfac*warpfac*(shldup+1);\r
if (energy <= 0) finish(FNRG);\r
\r
while ((key=scan()) == IHEOL) {\r
chew();\r
- proutn("Warp factor-");\r
+ proutn("Warp factor- ");\r
}\r
chew();\r
if (key != IHREAL) {\r
warpfac = aaitem;\r
wfacsq=warpfac*warpfac;\r
if (warpfac <= oldfac || warpfac <= 6.0) {\r
- proutn("Helmsman Sulu- \"Warp factor ");\r
- cramf(warpfac, 0, 1);\r
- prout(", Captain.\"");\r
+ proutn("Helmsman Sulu- \"Warp factor %d, Captain.\"", \r
+ (int)warpfac);\r
return;\r
}\r
if (warpfac < 8.00) {\r
}\r
warpfac = 6.0+2.0*Rand();\r
wfacsq = warpfac * warpfac;\r
- proutn("Warp factor set to ");\r
- cramf(warpfac, 1, 1);\r
- skip(1);\r
+ prout("Warp factor set to %d", (int)warpfac);\r
power = 0.75*energy;\r
dist = power/(warpfac*warpfac*warpfac*(shldup+1));\r
distreq = 1.4142+Rand();\r
prout("***TIME WARP ENTERED.");\r
if (game.state.snap && Rand() < 0.5) {\r
/* Go back in time */\r
- proutn("You are traveling backwards in time ");\r
- cramf(game.state.date-game.snapsht.date, 0, 2);\r
- prout(" stardates.");\r
+ prout("You are traveling backwards in time %d stardates.",\r
+ (int)(game.state.date-game.snapsht.date));\r
game.state = game.snapsht;\r
game.state.snap = 0;\r
if (game.state.remcom) {\r
else {\r
/* Go forward in time */\r
Time = -0.5*intime*log(Rand());\r
- proutn("You are traveling forward in time ");\r
- cramf(Time, 1, 2);\r
- prout(" stardates.");\r
+ prout("You are traveling forward in time %d stardates.", (int)Time);\r
/* cheat to make sure no tractor beams occur during time warp */\r
game.future[FTBEAM] += Time;\r
game.damage[DRADIO] += Time;\r
}\r
newqad(0);\r
+#ifdef SERGEEV\r
+ events();\r
+#endif /* SERGEEV */\r
}\r
\r
void probe(void) {\r
key = scan();\r
}\r
else if (key == IHEOL) {\r
- proutn("Arm NOVAMAX warhead?");\r
+ proutn("Arm NOVAMAX warhead? ");\r
isarmed = ja();\r
}\r
getcd(TRUE, key);\r
probecy = quady;\r
game.future[FDSPROB] = game.state.date + 0.01; // Time to move one sector\r
prout("Ensign Chekov- \"The deep space probe is launched, Captain.\"");\r
+ ididit = 1;\r
return;\r
}\r
\r
void help(void) {\r
/* There's more than one way to move in this game! */\r
double ddist, xdist, probf;\r
- int line, l, ix, iy;\r
+ int line = 0, l, ix, iy;\r
+#ifdef SERGEEV\r
+ int pox, posy;\r
+#endif /* SERGEEV */\r
\r
chew();\r
/* Test for conditions which prevent calling for help */\r
}\r
/* dematerialize starship */\r
game.quad[sectx][secty]=IHDOT;\r
- proutn("Starbase in");\r
- cramlc(1, quadx, quady);\r
- proutn(" responds--");\r
+ proutn("Starbase in %s responds--", cramlc(quadrant, quadx, quady));\r
+ proutn("");\r
crmshp();\r
prout(" dematerializes.");\r
+#ifdef SERGEEV\r
+ sectx=0;\r
+ for (l = 1; l <= 5; l++) {\r
+ ix = basex+3.0*Rand()-1;\r
+ iy = basey+3.0*Rand()-1;\r
+ if (ix>=1 && ix<=10 && iy>=1 && iy<=10 && game.quad[ix][iy]==IHDOT) {\r
+ /* found one -- finish up */\r
+ sectx=ix;\r
+ secty=iy;\r
+ game.quad[ix][iy]=IHMATER0;\r
+ break;\r
+ }\r
+ }\r
+ if (sectx==0){\r
+ prout("You have been lost in space...");\r
+ finish(FMATERIALIZE);\r
+ return;\r
+ }\r
+#endif /* SERGEEV */\r
/* Give starbase three chances to rematerialize starship */\r
probf = pow((1.0 - pow(0.98,ddist)), 0.33333333);\r
for (l = 1; l <= 3; l++) {\r
sectx=ix;\r
secty=iy;\r
game.quad[ix][iy]=ship;\r
- dock();\r
+ dock(0);\r
skip(1);\r
prout("Lt. Uhura- \"Captain, we made it!\"");\r
return;\r