X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=moving.c;h=ec7bc91b4ca0676f45d481991a654879b84679cd;hb=cf91699c89b88f76dcf63c60624635184e8cb7eb;hp=0b9ecbed686f32c5b5997607e835ec29fc4fe9dc;hpb=77e371705e1e059173ec9c88f63be7a460e44e50;p=super-star-trek.git diff --git a/moving.c b/moving.c index 0b9ecbe..ec7bc91 100644 --- a/moving.c +++ b/moving.c @@ -1,11 +1,12 @@ +#include #include "sst.h" static void getcd(int, int); -void move(void) { +void imove(void) { double angle, deltax, deltay, bigger, x, y, - finald, finalx, finaly, stopegy; - int trbeam = 0, n, l, ix, iy, kink, kinks, iquad; + finald, finalx, finaly, stopegy, probf; + int trbeam = 0, n, l, ix=0, iy=0, kink, kinks, iquad; if (inorbit) { prout("Helmsman Sulu- \"Leaving standard orbit.\""); @@ -98,11 +99,11 @@ void move(void) { quady = (iy+9)/10; sectx = ix - 10*(quadx-1); secty = iy - 10*(quady-1); - proutn("\nEntering"); - cramlc(1, quadx, quady); - skip(1); + proutn("\n\rEntering %s.", + cramlc(quadrant, quadx, quady)); game.quad[sectx][secty] = ship; newqad(0); + if (skill>1) attack(0); return; } iquad = game.quad[ix][iy]; @@ -117,6 +118,7 @@ void move(void) { case IHC: case IHS: case IHR: + case IHQUEST: sectx = ix; secty = iy; ram(0, iquad, sectx, secty); @@ -129,24 +131,38 @@ void move(void) { skip(1); proutn("***"); crmshp(); - proutn(" pulled into black hole at"); - cramlc(2, ix, iy); - skip(1); - finish(FHOLE); + proutn(" pulled into black hole at "); + prout(cramlc(sector, ix, iy)); + /* + * Getting pulled into a black + * hole was certain death in + * Almy's original. Stas + * Sergeev added a possibility + * that you'll get timewarped + * instead. + */ + n=0; + for (l=1;l<=NDEVICES+1;l++) + if (game.damage[l]>0) n++; + probf=pow(1.4,(energy+shield)/5000.0-1.0)* + pow(1.3,1.0/(n+1)-1.0); + if (Rand()>probf) + timwrp(); + else + finish(FHOLE); return; default: /* something else */ skip(1); crmshp(); if (iquad == IHWEB) - proutn(" encounters Tholian web at"); + proutn(" encounters Tholian web at "); else - proutn(" blocked by object at"); - cramlc(2, ix,iy); + proutn(" blocked by object at "); + proutn(cramlc(sector, ix,iy)); prout(";"); proutn("Emergency stop required "); - cramf(stopegy, 0, 2); - prout(" units of energy."); + prout("%2d units of energy.", (int)stopegy); energy -= stopegy; finalx = x-deltax+0.5; sectx = finalx; @@ -188,9 +204,9 @@ label100: return; } -void dock(void) { +void dock(int l) { chew(); - if (condit == IHDOCKED) { + if (condit == IHDOCKED && l) { prout("Already docked."); return; } @@ -213,7 +229,7 @@ void dock(void) { (game.future[FCDBAS] < 1e30 || isatb == 1) && iseenit == 0) { /* get attack report from base */ prout("Lt. Uhura- \"Captain, an important message from the starbase:\""); - attakreport(); + attakreport(0); iseenit = 1; } } @@ -228,7 +244,7 @@ static void getcd(int isprobe, int akey) { are always displayed y - x, where +y is downward! */ - int irowq=quadx, icolq=quady, irows, icols, itemp=0, iprompt=0, key; + int irowq=quadx, icolq=quady, irows, icols, itemp=0, iprompt=0, key=0; double xi, xj, xk, xl; double deltax, deltay; int automatic = -1; @@ -357,9 +373,8 @@ static void getcd(int isprobe, int akey) { if (!isprobe) { if (itemp) { if (iprompt) { - proutn("Helmsman Sulu- \"Course locked in for"); - cramlc(2, irows, icols); - prout(".\""); + proutn("Helmsman Sulu- \"Course locked in for %s.\"", + cramlc(sector, irows, icols)); } } else prout("Ensign Chekov- \"Course laid in, Captain.\""); @@ -431,8 +446,8 @@ void impuls(void) { prout("First Officer Spock- \"Captain, the impulse engines"); prout("require 20.0 units to engage, plus 100.0 units per"); if (energy > 30) { - proutn("quadrant. We can go, therefore, a maximum of "); - cramf(0.01 * (energy-20.0)-0.05, 0, 1); + proutn("quadrant. We can go, therefore, a maximum of %d", + (int)(0.01 * (energy-20.0)-0.05)); prout(" quadrants.\""); } else { @@ -446,11 +461,11 @@ void impuls(void) { if (Time >= game.state.remtime) { prout("First Officer Spock- \"Captain, our speed under impulse"); prout("power is only 0.95 sectors per stardate. Are you sure"); - prout("we dare spend the time?\""); + proutn("we dare spend the time?\" "); if (ja() == 0) return; } /* Activate impulse engines and pay the cost */ - move(); + imove(); ididit = 1; if (alldone) return; power = 20.0 + 100.0*dist; @@ -500,10 +515,11 @@ void warp(int i) { prout("We can't do it, Captain. We haven't the energy."); } else { - proutn("We haven't the energy, but we could do it at warp "); - crami(iwarp, 1); - if (shldup) - prout(",\nif you'll lower the shields."); + proutn("We haven't the energy, but we could do it at warp %d", iwarp); + if (shldup) { + prout(","); + prout("if you'll lower the shields."); + } else prout("."); } @@ -518,11 +534,11 @@ void warp(int i) { if (Time >= 0.8*game.state.remtime) { skip(1); prout("First Officer Spock- \"Captain, I compute that such"); - proutn(" a trip would require approximately "); - cramf(100.0*Time/game.state.remtime, 0, 2); + proutn(" a trip would require approximately %2.0f", + 100.0*Time/game.state.remtime); prout(" percent of our"); - prout(" remaining time. Are you sure this is wise?\""); - if (ja() == 0) { ididit = 0; return;} + proutn(" remaining time. Are you sure this is wise?\" "); + if (ja() == 0) { ididit = 0; Time=0; return;} } } /* Entry WARPX */ @@ -577,7 +593,7 @@ void warp(int i) { /* Activate Warp Engines and pay the cost */ - move(); + imove(); if (alldone) return; energy -= dist*warpfac*warpfac*warpfac*(shldup+1); if (energy <= 0) finish(FNRG); @@ -602,7 +618,7 @@ void setwrp(void) { while ((key=scan()) == IHEOL) { chew(); - proutn("Warp factor-"); + proutn("Warp factor- "); } chew(); if (key != IHREAL) { @@ -630,9 +646,8 @@ void setwrp(void) { warpfac = aaitem; wfacsq=warpfac*warpfac; if (warpfac <= oldfac || warpfac <= 6.0) { - proutn("Helmsman Sulu- \"Warp factor "); - cramf(warpfac, 0, 1); - prout(", Captain.\""); + proutn("Helmsman Sulu- \"Warp factor %d, Captain.\"", + (int)warpfac); return; } if (warpfac < 8.00) { @@ -714,9 +729,7 @@ void atover(int igrab) { } warpfac = 6.0+2.0*Rand(); wfacsq = warpfac * warpfac; - proutn("Warp factor set to "); - cramf(warpfac, 1, 1); - skip(1); + prout("Warp factor set to %d", (int)warpfac); power = 0.75*energy; dist = power/(warpfac*warpfac*warpfac*(shldup+1)); distreq = 1.4142+Rand(); @@ -744,9 +757,8 @@ void timwrp() { prout("***TIME WARP ENTERED."); if (game.state.snap && Rand() < 0.5) { /* Go back in time */ - proutn("You are traveling backwards in time "); - cramf(game.state.date-game.snapsht.date, 0, 2); - prout(" stardates."); + prout("You are traveling backwards in time %d stardates.", + (int)(game.state.date-game.snapsht.date)); game.state = game.snapsht; game.state.snap = 0; if (game.state.remcom) { @@ -793,9 +805,7 @@ void timwrp() { else { /* Go forward in time */ Time = -0.5*intime*log(Rand()); - proutn("You are traveling forward in time "); - cramf(Time, 1, 2); - prout(" stardates."); + prout("You are traveling forward in time %d stardates.", (int)Time); /* cheat to make sure no tractor beams occur during time warp */ game.future[FTBEAM] += Time; game.damage[DRADIO] += Time; @@ -837,8 +847,7 @@ void probe(void) { if (key == IHEOL) { /* slow mode, so let Kirk know how many probes there are left */ - crami(nprobes,1); - prout(nprobes==1 ? " probe left." : " probes left."); + prout(nprobes==1 ? "%d probe left." : "%d probes left.", nprobes); proutn("Are you sure you want to fire a probe? "); if (ja()==0) return; } @@ -849,7 +858,7 @@ void probe(void) { key = scan(); } else if (key == IHEOL) { - proutn("Arm NOVAMAX warhead?"); + proutn("Arm NOVAMAX warhead? "); isarmed = ja(); } getcd(TRUE, key); @@ -922,9 +931,8 @@ void help(void) { } /* dematerialize starship */ game.quad[sectx][secty]=IHDOT; - proutn("Starbase in"); - cramlc(1, quadx, quady); - proutn(" responds--"); + proutn("Starbase in %s responds--", cramlc(quadrant, quadx, quady)); + proutn(""); crmshp(); prout(" dematerializes."); /* Give starbase three chances to rematerialize starship */ @@ -955,7 +963,7 @@ void help(void) { sectx=ix; secty=iy; game.quad[ix][iy]=ship; - dock(); + dock(0); skip(1); prout("Lt. Uhura- \"Captain, we made it!\""); return;