- /* Cause extraneous event LINE to occur */
- Time -= xtime;
- switch (line) {
- case FSNOVA: /* Supernova */
- if (ipage==0) pause_game(1);
- ipage=1;
- snova(0,0);
- game.future[FSNOVA] = game.state.date + expran(0.5*intime);
- if (game.state.galaxy[quadx][quady] == 1000) return;
- break;
- case FSPY: /* Check with spy to see if S.C. should tractor beam */
- if (game.state.nscrem == 0 ||
- ictbeam+istract > 0 ||
- condit==IHDOCKED || isatb==1 || iscate==1) return;
- if (ientesc ||
- (energy < 2000 && torps < 4 && shield < 1250) ||
- (game.damage[DPHASER]>0 && (game.damage[DPHOTON]>0 || torps < 4)) ||
- (game.damage[DSHIELD] > 0 &&
- (energy < 2500 || game.damage[DPHASER] > 0) &&
- (torps < 5 || game.damage[DPHOTON] > 0))) {
- /* Tractor-beam her! */
- istract=1;
- yank = square(game.state.isx-quadx) + square(game.state.isy-quady);
- /*********TBEAM CODE***********/
- }
- else return;
- case FTBEAM: /* Tractor beam */
- if (line==FTBEAM) {
- if (game.state.remcom == 0) {
- game.future[FTBEAM] = 1e30;
- break;
- }
- i = Rand()*game.state.remcom+1.0;
- yank = square(game.state.cx[i]-quadx) + square(game.state.cy[i]-quady);
- if (istract || condit == IHDOCKED || yank == 0) {
- /* Drats! Have to reschedule */
- game.future[FTBEAM] = game.state.date + Time +
- expran(1.5*intime/game.state.remcom);
- break;
- }
- }
- /* tractor beaming cases merge here */
- yank = sqrt(yank);
- if (ipage==0) pause_game(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--");
- /* 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.");
- game.damage[DSHUTTL] = -10;
- iscraft = -1;
- }
- else {
- prout("Galileo, left on the planet surface, is well hidden.");
- }
- }
- if (line==0) {
- quadx = game.state.isx;
- quady = game.state.isy;
- }
- else {
- quadx = game.state.cx[i];
- quady = game.state.cy[i];
- }
- iran10(§x, §y);
- crmshp();
- proutn(" is pulled to ");
- proutn(cramlc(quadrant, quadx, quady));
- proutn(", ");
- prout(cramlc(sector, sectx, secty));
- if (resting) {
- prout("(Remainder of rest/repair period cancellegame.state.)");
- resting = 0;
- }
- if (shldup==0) {
- if (game.damage[DSHIELD]==0 && shield > 0) {
- doshield(2); /* Shldsup */
- shldchg=0;
- }
- else prout("(Shields not currently useable.)");
- }
- newqad(0);
- /* Adjust finish time to time of tractor beaming */
- fintim = game.state.date+Time;
- attack(0);
- if (game.state.remcom <= 0) game.future[FTBEAM] = 1e30;
- else game.future[FTBEAM] = game.state.date+Time+expran(1.5*intime/game.state.remcom);
- break;
- case FSNAP: /* Snapshot of the universe (for time warp) */
- game.snapsht = game.state;
- game.state.snap = 1;
- game.future[FSNAP] = game.state.date + expran(0.5 * intime);
- break;
- case FBATTAK: /* Commander attacks starbase */
- if (game.state.remcom==0 || game.state.rembase==0) {
- /* no can do */
- game.future[FBATTAK] = game.future[FCDBAS] = 1e30;
- break;
- }
- i = 0;
- for (j=1; j<=game.state.rembase; j++) {
- for (k=1; k<=game.state.remcom; k++)
- if (game.state.baseqx[j]==game.state.cx[k] && game.state.baseqy[j]==game.state.cy[k] &&
- (game.state.baseqx[j]!=quadx || game.state.baseqy[j]!=quady) &&
- (game.state.baseqx[j]!=game.state.isx || game.state.baseqy[j]!=game.state.isy)) {
- i = 1;
- break;
- }
- if (i == 1) break;
- }
- if (j>game.state.rembase) {
- /* no match found -- try later */
- game.future[FBATTAK] = game.state.date + expran(0.3*intime);
- game.future[FCDBAS] = 1e30;
- break;
- }
- /* commander + starbase combination found -- launch attack */
- batx = game.state.baseqx[j];
- baty = game.state.baseqy[j];
- game.future[FCDBAS] = game.state.date+1.0+3.0*Rand();
- if (isatb) /* extra time if SC already attacking */
- game.future[FCDBAS] += game.future[FSCDBAS]-game.state.date;
- game.future[FBATTAK] = game.future[FCDBAS] +expran(0.3*intime);
- iseenit = 0;
- if (game.damage[DRADIO] != 0.0 &&
- condit != IHDOCKED) break; /* No warning :-( */
- iseenit = 1;
- if (ipage==0) pause_game(1);
- ipage = 1;
- skip(1);
- proutn("Lt. Uhura- \"Captain, the starbase in ");
- prout(cramlc(quadrant, batx, baty));
- prout(" reports that it is under attack and that it can");
- proutn(" hold out only until stardate %d",
- (int)game.future[FCDBAS]);
- prout(".\"");
- if (resting) {
- skip(1);
- proutn("Mr. Spock- \"Captain, shall we cancel the rest period?\" ");
- if (ja()) {
- resting = 0;
- Time = 0.0;
- return;
- }
- }
- break;
- case FSCDBAS: /* Supercommander destroys base */
- game.future[FSCDBAS] = 1e30;
- isatb = 2;
- if (game.state.galaxy[game.state.isx][game.state.isy]%100 < 10) break; /* WAS RETURN! */
- ixhold = batx;
- iyhold = baty;
- batx = game.state.isx;
- baty = game.state.isy;
- case FCDBAS: /* Commander succeeds in destroying base */
- if (line==FCDBAS) {
- game.future[FCDBAS] = 1e30;
- /* find the lucky pair */
- for (i = 1; i <= game.state.remcom; i++)
- if (game.state.cx[i]==batx && game.state.cy[i]==baty) break;
- if (i > game.state.remcom || game.state.rembase == 0 ||
- game.state.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 (game.starch[batx][baty] == -1) game.starch[batx][baty] = 0;
- /* Handle case where base is in same quadrant as starship */
- if (batx==quadx && baty==quady) {
- if (game.starch[batx][baty] > 999) game.starch[batx][baty] -= 10;
- game.quad[basex][basey]= IHDOT;
- basex=basey=0;
- newcnd();
- skip(1);
- prout("Spock- \"Captain, I believe the starbase has been destroyegame.state.\"");
- }
- else if (game.state.rembase != 1 &&
- (game.damage[DRADIO] <= 0.0 || condit == IHDOCKED)) {
- /* Get word via subspace radio */
- if (ipage==0) pause_game(1);
- ipage = 1;
- skip(1);
- prout("Lt. Uhura- \"Captain, Starfleet Command reports that");
- proutn(" the starbase in ");
- proutn(cramlc(quadrant, batx, baty));
- prout(" has been destroyed by");
- if (isatb==2) prout("the Klingon Super-Commander");
- else prout("a Klingon Commander");
- }
- /* Remove Starbase from galaxy */
- game.state.galaxy[batx][baty] -= 10;
- for (i=1; i <= game.state.rembase; i++)
- if (game.state.baseqx[i]==batx && game.state.baseqy[i]==baty) {
- game.state.baseqx[i]=game.state.baseqx[game.state.rembase];
- game.state.baseqy[i]=game.state.baseqy[game.state.rembase];
- }
- game.state.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 */
- game.future[FSCMOVE] = game.state.date+0.2777;
- if (ientesc+istract==0 &&
- isatb!=1 &&
- (iscate!=1 || justin==1)) scom(&ipage);
- break;
- case FDSPROB: /* Move deep space probe */
- game.future[FDSPROB] = game.state.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 > GALSIZE || j < 1 || j > GALSIZE ||
- game.state.galaxy[probecx][probecy] == 1000) {
- // Left galaxy or ran into supernova
- if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) {
- if (ipage==0) pause_game(1);
- ipage = 1;
- skip(1);
- proutn("Lt. Uhura- \"The deep space probe ");
- if (i < 1 ||i > GALSIZE || j < 1 || j > GALSIZE)
- proutn("has left the galaxy");
- else
- proutn("is no longer transmitting");
- prout(".\"");
- }
- game.future[FDSPROB] = 1e30;
- break;
- }
- if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) {
- if (ipage==0) pause_game(1);
- ipage = 1;
- skip(1);
- proutn("Lt. Uhura- \"The deep space probe is now in ");
- proutn(cramlc(quadrant, probecx, probecy));
- prout(".\"");
- }
- }
- /* Update star chart if Radio is working or have access to
- radio. */
- if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED)
- game.starch[probecx][probecy] = game.damage[DRADIO] > 0.0 ?
- game.state.galaxy[probecx][probecy]+1000 : 1;
- proben--; // One less to travel
- if (proben == 0 && isarmed &&
- game.state.galaxy[probecx][probecy] % 10 > 0) {
- /* lets blow the sucker! */
- snova(1,0);
- game.future[FDSPROB] = 1e30;
- if (game.state.galaxy[quadx][quady] == 1000) return;
- }
- break;