X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=ai.c;h=a1b4bbf6f92ef101dc9ac53ed5a8b3af39f8fcde;hp=fd9cf8ceecedcc77db509c839758e6a6208b5128;hb=6b396c7a585fcf5c54caf29c527b195999d23bfe;hpb=070639b283c6f4e324a24bbf604f3ce2b6900899 diff --git a/ai.c b/ai.c index fd9cf8c..a1b4bbf 100644 --- a/ai.c +++ b/ai.c @@ -49,7 +49,7 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) ientesc=0; isatb=0; game.future[FSCMOVE]=0.2777+game.state.date; - game.future[FSCDBAS]=1e30; + game.future[FSCDBAS]=FOREVER; game.state.isx=iqx; game.state.isy=iqy; } @@ -151,7 +151,7 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) else { if (forces > 1000.0) /* Very strong -- move in for kill */ motion = (1.0-square(Rand()))*dist1 + 1.0; - if (condit==IHDOCKED) /* protected by base -- back off ! */ + if (condit==IHDOCKED && (game.options & OPTION_BASE)) /* protected by base -- back off ! */ motion -= skill*(2.0-square(Rand())); } #ifdef DEBUG @@ -213,7 +213,7 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) looky = nexty + krawly; krawly = -krawly; } - else if (game.quad[lookx][looky] != IHDOT) { + else if ((game.options & OPTION_RAMMING) && game.quad[lookx][looky] != IHDOT) { /* See if we should ram ship */ if (game.quad[lookx][looky] == ship && (ienm == IHC || ienm == IHS)) { @@ -294,12 +294,13 @@ void movcom(void) /* if skill level is high, move other Klingons and Romulans too! Move these last so they can base their actions on what the commander(s) do. */ - if (skill >= SKILL_EXPERT) for_local_enemies(i) { - ix = game.kx[i]; - iy = game.ky[i]; - if (game.quad[ix][iy] == IHK || game.quad[ix][iy] == IHR) - movebaddy(ix, iy, i, game.quad[ix][iy]); - } + if (skill >= SKILL_EXPERT && (game.options & OPTION_MVBADDY)) + for_local_enemies(i) { + ix = game.kx[i]; + iy = game.ky[i]; + if (game.quad[ix][iy] == IHK || game.quad[ix][iy] == IHR) + movebaddy(ix, iy, i, game.quad[ix][iy]); + } sortkl(); } @@ -330,7 +331,7 @@ static int movescom(int iqx, int iqy, int flag, int *ipage) isatb=0; ishere=0; ientesc=0; - game.future[FSCDBAS]=1e30; + game.future[FSCDBAS]=FOREVER; for_local_enemies(i) if (game.quad[game.kx[i]][game.ky[i]] == IHS) break; game.quad[game.kx[i]][game.ky[i]] = IHDOT; @@ -370,15 +371,15 @@ void scom(int *ipage) { int i, i2, j, ideltax, ideltay, ibqx, ibqy, sx, sy, ifindit, iwhichb; int iqx, iqy; - int basetbl[BASEMAX]; - double bdist[BASEMAX]; + int basetbl[BASEMAX+1]; + double bdist[BASEMAX+1]; int flag; #ifdef DEBUG if (idebug) prout("SCOM"); #endif /* Decide on being active or passive */ - flag = ((game.state.killc+game.state.killk)/(game.state.date+0.01-indate) < 0.1*skill*(skill+1.0) || + flag = ((NKILLC+NKILLK)/(game.state.date+0.01-indate) < 0.1*skill*(skill+1.0) || (game.state.date-indate) < 3.0); if (iscate==0 && flag) { /* compute move away from Enterprise */ @@ -394,7 +395,7 @@ void scom(int *ipage) /* compute distances to starbases */ if (game.state.rembase <= 0) { /* nothing left to do */ - game.future[FSCMOVE] = 1e30; + game.future[FSCMOVE] = FOREVER; return; } sx = game.state.isx; @@ -498,7 +499,7 @@ void scom(int *ipage) } /* check for a base */ if (game.state.rembase == 0) { - game.future[FSCMOVE] = 1e30; + game.future[FSCMOVE] = FOREVER; } else for_starbases(i) { ibqx = game.state.baseqx[i]; @@ -509,7 +510,7 @@ void scom(int *ipage) iseenit = 0; isatb=1; game.future[FSCDBAS] = game.state.date + 1.0 +2.0*Rand(); - if (game.future[FCDBAS] < 1e30) game.future[FSCDBAS] += + if (game.future[FCDBAS] < FOREVER) game.future[FSCDBAS] += game.future[FCDBAS]-game.state.date; if (game.damage[DRADIO] > 0 && condit != IHDOCKED) return; /* no warning */