- deltay /= bigger;
- deltax /= bigger;
-
- /* If tractor beam is to occur, don't move full distance */
- if (game.state.date+Time >= game.future[FTBEAM]) {
- trbeam = 1;
- condit = IHRED;
- dist = dist*(game.future[FTBEAM]-game.state.date)/Time + 0.1;
- Time = game.future[FTBEAM] - game.state.date + 1e-5;
- }
- /* Move within the quadrant */
- game.quad[sectx][secty] = IHDOT;
- x = sectx;
- y = secty;
- n = 10.0*dist*bigger+0.5;
-
- if (n > 0) {
- for (l = 1; l <= n; l++) {
- ix = (x += deltax) + 0.5;
- iy = (y += deltay) + 0.5;
- if (ix < 1 || ix > 10 || iy < 1 || iy > 10) {
- /* Leaving quadrant -- allow final enemy attack */
- /* Don't do it if being pushed by Nova */
- if (nenhere != 0 && iattak != 2) {
- newcnd();
- for (l = 1; l <= nenhere; l++) {
- finald = sqrt((ix-game.kx[l])*(double)(ix-game.kx[l]) +
- (iy-game.ky[l])*(double)(iy-game.ky[l]));
- game.kavgd[l] = 0.5 * (finald+game.kdist[l]);
- }
-#ifdef SERGEEV
- if (skill > 3 && klhere > 0 && game.state.galaxy[quadx][quady] != 1000)
- attack(0);
-#else
- if (game.state.galaxy[quadx][quady] != 1000) attack(0);
-#endif /* SERGEEV */
- if (alldone) return;
- }
- /* compute final position -- new quadrant and sector */
- x = 10*(quadx-1)+sectx;
- y = 10*(quady-1)+secty;
- ix = x+10.0*dist*bigger*deltax+0.5;
- iy = y+10.0*dist*bigger*deltay+0.5;
- /* check for edge of galaxy */
- kinks = 0;
- do {
- kink = 0;
- if (ix <= 0) {
- ix = -ix + 1;
- kink = 1;
- }
- if (iy <= 0) {
- iy = -iy + 1;
- kink = 1;
- }
- if (ix > 80) {
- ix = 161 - ix;
- kink = 1;
- }
- if (iy > 80) {
- iy = 161 - iy;
- kink = 1;
- }
- if (kink) kinks = 1;
- } while (kink);
-
- if (kinks) {
- nkinks += 1;
- if (nkinks == 3) {
- /* Three strikes -- you're out! */
- finish(FNEG3);
- return;
- }
- prout("\n\rYOU HAVE ATTEMPTED TO CROSS THE NEGATIVE ENERGY BARRIER\n\r"
- "AT THE EDGE OF THE GALAXY. THE THIRD TIME YOU TRY THIS,\n\r"
- "YOU WILL BE DESTROYED.\n\r");
- }
- /* Compute final position in new quadrant */
- if (trbeam) return; /* Don't bother if we are to be beamed */
- quadx = (ix+9)/10;
- quady = (iy+9)/10;
- sectx = ix - 10*(quadx-1);
- secty = iy - 10*(quady-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];
- if (iquad != IHDOT) {
- /* object encountered in flight path */
- stopegy = 50.0*dist/Time;
- dist=0.1*sqrt((sectx-ix)*(double)(sectx-ix) +
- (secty-iy)*(double)(secty-iy));
- switch (iquad) {
- case IHT: /* Ram a Tholian */
- case IHK: /* Ram enemy ship */
- case IHC:
- case IHS:
- case IHR:
- case IHQUEST:
- sectx = ix;
- secty = iy;
- ram(0, iquad, sectx, secty);
- finalx = sectx;
- finaly = secty;
- break;
- case IHBLANK:
- skip(1);
- prouts("***RED ALERT! RED ALERT!");
- skip(1);
- proutn("***");
- crmshp();
- 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 ");
- else
- proutn(" blocked by object at ");
- proutn(cramlc(sector, ix,iy));
- prout(";");
- proutn("Emergency stop required ");
- prout("%2d units of energy.", (int)stopegy);
- energy -= stopegy;
- finalx = x-deltax+0.5;
- sectx = finalx;
- finaly = y-deltay+0.5;
- secty = finaly;
- if (energy <= 0) {
- finish(FNRG);
- return;
- }
- break;
- }
- goto label100; /* sorry! */
- }
- }
- dist = 0.1*sqrt((sectx-ix)*(double)(sectx-ix) +
- (secty-iy)*(double)(secty-iy));
- sectx = ix;
- secty = iy;
- }
- finalx = sectx;
- finaly = secty;
-label100:
- /* No quadrant change -- compute new avg enemy distances */
- game.quad[sectx][secty] = ship;
- if (nenhere) {
- for (l = 1; l <= nenhere; l++) {
+ deltay /= bigger;
+ deltax /= bigger;
+
+ /* If tractor beam is to occur, don't move full distance */
+ if (game.state.date+Time >= game.future[FTBEAM]) {
+ trbeam = 1;
+ condit = IHRED;
+ dist = dist*(game.future[FTBEAM]-game.state.date)/Time + 0.1;
+ Time = game.future[FTBEAM] - game.state.date + 1e-5;
+ }
+ /* Move within the quadrant */
+ game.quad[sectx][secty] = IHDOT;
+ x = sectx;
+ y = secty;
+ n = 10.0*dist*bigger+0.5;
+
+ if (n > 0) {
+ for (l = 1; l <= n; l++) {
+ ix = (x += deltax) + 0.5;
+ iy = (y += deltay) + 0.5;
+ if (!VALID_SECTOR(ix, iy)) {
+ /* Leaving quadrant -- allow final enemy attack */
+ /* Don't do it if being pushed by Nova */
+ if (nenhere != 0 && iattak != 2) {
+ newcnd();
+ for_local_enemies(l) {