- iqx = quadx+(lookx+(QUADSIZE-1))/QUADSIZE - 1;
- iqy = quady+(looky+(QUADSIZE-1))/QUADSIZE - 1;
- if (iqx < 1 || iqx > GALSIZE || iqy < 1 || iqy > GALSIZE ||
- game.state.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 <= game.state.remcom; l++)
- if (game.state.cx[l]==iqx && game.state.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 (game.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 (game.damage[DSRSENS] == 0.0 || game.damage[DLRSENS] == 0.0 ||
- condit == IHDOCKED) {
- crmena(1, ienm, 2, game.kx[loccom], game.ky[loccom]);
- prout(" escapes to %s (and regains strength).",
- cramlc(quadrant, iqx, iqy));
- }
- /* handle local matters related to escape */
- game.quad[game.kx[loccom]][game.ky[loccom]] = IHDOT;
- game.kx[loccom] = game.kx[nenhere];
- game.ky[loccom] = game.ky[nenhere];
- game.kavgd[loccom] = game.kavgd[nenhere];
- game.kpower[loccom] = game.kpower[nenhere];
- game.kdist[loccom] = game.kdist[nenhere];
- klhere--;
- nenhere--;
- if (condit != IHDOCKED) newcnd();
- /* Handle global matters related to escape */
- game.state.galaxy[quadx][quady] -= 100;
- game.state.galaxy[iqx][iqy] += 100;
- if (ienm==IHS) {
- ishere=0;
- iscate=0;
- ientesc=0;
- isatb=0;
- game.future[FSCMOVE]=0.2777+game.state.date;
- game.future[FSCDBAS]=1e30;
- game.state.isx=iqx;
- game.state.isy=iqy;
+ iqx = quadx+(lookx+(QUADSIZE-1))/QUADSIZE - 1;
+ iqy = quady+(looky+(QUADSIZE-1))/QUADSIZE - 1;
+ if (!VALID_QUADRANT(iqx,iqy) ||
+ game.state.galaxy[iqx][iqy].supernova ||
+ game.state.galaxy[iqx][iqy].klingons > 8)
+ 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_commanders(l)
+ if (game.state.cx[l]==iqx && game.state.cy[l]==iqy) return 0;
+ /* refuse to leave if currently attacking starbase */
+ if (batx==quadx && baty==quady) return 0;