These are unused.
[super-star-trek.git] / ai.c
diff --git a/ai.c b/ai.c
index d2223cab385e9ab9892bffb269b8da889aeceb53..ba970a36ee9f18dcdbf2f43aa1fcf564e19788cc 100644 (file)
--- a/ai.c
+++ b/ai.c
@@ -24,13 +24,12 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) {
           We know this if either short or long range sensors are working */\r
        if (game.damage[DSRSENS] == 0.0 || game.damage[DLRSENS] == 0.0 ||\r
                condit == IHDOCKED) {\r
-               proutn("***");\r
-               cramen(ienm);\r
-               proutn(" escapes to");\r
-               cramlc(1, iqx, iqy);\r
-               prout(" (and regains strength).");\r
+               crmena(1, ienm, 2, game.kx[loccom], game.ky[loccom]);\r
+               proutn(" escapes to %s (and regains strength).",\r
+                      cramlc(quadrant, iqx, iqy));\r
        }\r
        /* handle local matters related to escape */\r
+       game.quad[game.kx[loccom]][game.ky[loccom]] = IHDOT;\r
        game.kx[loccom] = game.kx[nenhere];\r
        game.ky[loccom] = game.ky[nenhere];\r
        game.kavgd[loccom] = game.kavgd[nenhere];\r
@@ -154,11 +153,8 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) {
                }\r
 #ifdef DEBUG\r
                if (idebug) {\r
-                       proutn("MOTION = ");\r
-                       cramf(motion, 1, 2);\r
-            proutn("  FORCES = ");\r
-                       cramf(forces, 1, 2);\r
-                       skip(1);\r
+                       proutn("MOTION = %1.2f", motion);\r
+                       proutn("  FORCES = %1,2f", forces);\r
                }\r
 #endif\r
                /* don't move if no motion */\r
@@ -173,9 +169,7 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) {
        if (nsteps < 1) nsteps = 1; /* This shouldn't be necessary */\r
 #ifdef DEBUG\r
        if (idebug) {\r
-               proutn("NSTEPS = ");\r
-               crami(nsteps, 1);\r
-               skip(1);\r
+               prout("NSTEPS = %d", nsteps);\r
        }\r
 #endif\r
        /* Compute preferred values of delta X and Y */\r
@@ -187,13 +181,11 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) {
        if (my != 0) my = my*motion < 0 ? -1 : 1;\r
        nextx = comx;\r
        nexty = comy;\r
-       game.quad[comx][comy] = IHDOT;\r
        /* main move loop */\r
        for (ll = 1; ll <= nsteps; ll++) {\r
 #ifdef DEBUG\r
                if (idebug) {\r
-                       crami(ll,2);\r
-                       skip(1);\r
+                       prout("%d", ll);\r
                }\r
 #endif\r
                /* Check if preferred position available */\r
@@ -242,14 +234,14 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) {
                        nexty = looky;\r
 #ifdef DEBUG\r
                        if (idebug) {\r
-                               cramlc(0, nextx, nexty);\r
-                               skip(1);\r
+                               prout(cramlc(neither, nextx, nexty));\r
                        }\r
 #endif\r
                }\r
                else break; /* done early */\r
        }\r
        /* Put commander in place within same quadrant */\r
+       game.quad[comx][comy] = IHDOT;\r
        game.quad[nextx][nexty] = ienm;\r
        if (nextx != comx || nexty != comy) {\r
                /* it moved */\r
@@ -260,10 +252,11 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) {
                if (game.damage[DSRSENS] == 0 || condit == IHDOCKED) {\r
                        proutn("***");\r
                        cramen(ienm);\r
+                       proutn(" from");\r
+                       cramlc(2, comx, comy);\r
                        if (game.kdist[loccom] < dist1) proutn(" advances to");\r
-                       else proutn(" retreats to");\r
-                       cramlc(2, nextx, nexty);\r
-                       skip(1);\r
+                       else proutn(" retreats to ");\r
+                       prout(cramlc(sector, nextx, nexty));\r
                }\r
        }\r
 }\r
@@ -306,8 +299,8 @@ void movcom(void) {
        sortkl();\r
 }\r
 \r
-static int checkdest(int iqx, int iqy, int flag, int *ipage) {\r
-       int i, j;\r
+static int movescom(int iqx, int iqy, int flag, int *ipage) {\r
+       int i;\r
 \r
        if ((iqx==quadx && iqy==quady) ||\r
                iqx < 1 || iqx > 8 || iqy < 1 || iqy > 8 ||\r
@@ -317,13 +310,13 @@ static int checkdest(int iqx, int iqy, int flag, int *ipage) {
                for (i = 1; i <= game.state.rembase; i++)\r
                        if (game.state.baseqx[i]==iqx && game.state.baseqy[i]==iqy) return 1;\r
        }\r
-\r
+       if (justin && !iscate) return 1;\r
        /* do the move */\r
        game.state.galaxy[game.state.isx][game.state.isy] -= 100;\r
        game.state.isx = iqx;\r
        game.state.isy = iqy;\r
        game.state.galaxy[game.state.isx][game.state.isy] += 100;\r
-       if (iscate) {\r
+       if (ishere) {\r
                /* SC has scooted, Remove him from current quadrant */\r
                iscate=0;\r
                isatb=0;\r
@@ -351,11 +344,11 @@ static int checkdest(int iqx, int iqy, int flag, int *ipage) {
                        DESTROY(&game.state.plnets[i]);\r
                        game.state.newstuf[game.state.isx][game.state.isy] -= 1;\r
                        if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
-                               if (*ipage==0) pause(1);\r
+                               if (*ipage==0) pause_game(1);\r
                                *ipage = 1;\r
                                prout("Lt. Uhura-  \"Captain, Starfleet Intelligence reports");\r
-                               proutn("   a planet in");\r
-                               cramlc(1, game.state.isx, game.state.isy);\r
+                               proutn("   a planet in ");\r
+                               proutn(cramlc(quadrant, game.state.isx, game.state.isy));\r
                                prout(" has been destroyed");\r
                                prout("   by the Super-commander.\"");\r
                        }\r
@@ -467,32 +460,32 @@ void scom(int *ipage) {
        /* try moving in both x and y directions */\r
        iqx = game.state.isx + ideltax;\r
        iqy = game.state.isy + ideltax;\r
-       if (checkdest(iqx, iqy, flag, ipage)) {\r
+       if (movescom(iqx, iqy, flag, ipage)) {\r
                /* failed -- try some other maneuvers */\r
                if (ideltax==0 || ideltay==0) {\r
                        /* attempt angle move */\r
                        if (ideltax != 0) {\r
                                iqy = game.state.isy + 1;\r
-                               if (checkdest(iqx, iqy, flag, ipage)) {\r
+                               if (movescom(iqx, iqy, flag, ipage)) {\r
                                        iqy = game.state.isy - 1;\r
-                                       checkdest(iqx, iqy, flag, ipage);\r
+                                       movescom(iqx, iqy, flag, ipage);\r
                                }\r
                        }\r
                        else {\r
                                iqx = game.state.isx + 1;\r
-                               if (checkdest(iqx, iqy, flag, ipage)) {\r
+                               if (movescom(iqx, iqy, flag, ipage)) {\r
                                        iqx = game.state.isx - 1;\r
-                                       checkdest(iqx, iqy, flag, ipage);\r
+                                       movescom(iqx, iqy, flag, ipage);\r
                                }\r
                        }\r
                }\r
                else {\r
                        /* try moving just in x or y */\r
                        iqy = game.state.isy;\r
-                       if (checkdest(iqx, iqy, flag, ipage)) {\r
+                       if (movescom(iqx, iqy, flag, ipage)) {\r
                                iqy = game.state.isy + ideltay;\r
                                iqx = game.state.isx;\r
-                               checkdest(iqx, iqy, flag, ipage);\r
+                               movescom(iqx, iqy, flag, ipage);\r
                        }\r
                }\r
        }\r
@@ -509,19 +502,19 @@ void scom(int *ipage) {
                        iseenit = 0;\r
                        isatb=1;\r
                        game.future[FSCDBAS] = game.state.date + 1.0 +2.0*Rand();\r
-                       if (batx != 0) game.future[FSCDBAS] += game.future[FCDBAS]-game.state.date;\r
+                       if (game.future[FCDBAS] < 1e30) game.future[FSCDBAS] +=\r
+                               game.future[FCDBAS]-game.state.date;\r
                        if (game.damage[DRADIO] > 0 && condit != IHDOCKED)\r
                                return; /* no warning */\r
                        iseenit = 1;\r
-                       if (*ipage == 0)  pause(1);\r
+                       if (*ipage == 0)  pause_game(1);\r
                        *ipage=1;\r
-                       proutn("Lt. Uhura-  \"Captain, the starbase in");\r
-                       cramlc(1, game.state.isx, game.state.isy);\r
+                       proutn("Lt. Uhura-  \"Captain, the starbase in ");\r
+                       proutn(cramlc(quadrant, game.state.isx, game.state.isy));\r
                        skip(1);\r
                        prout("   reports that it is under attack from the Klingon Super-commander.");\r
-                       proutn("   It can survive until stardate ");\r
-                       cramf(game.future[FSCDBAS], 0, 1);\r
-                       prout(" .\"");\r
+                       proutn("   It can survive until stardate %d.\"",\r
+                              (int)game.future[FSCDBAS]);\r
                        if (resting==0) return;\r
                        prout("Mr. Spock-  \"Captain, shall we cancel the rest period?\"");\r
                        if (ja()==0) return;\r
@@ -539,11 +532,11 @@ void scom(int *ipage) {
                 (game.damage[DRADIO] > 0.0 && condit != IHDOCKED) ||\r
                 game.starch[game.state.isx][game.state.isy] > 0))\r
                return;\r
-       if (*ipage==0) pause(1);\r
+       if (*ipage==0) pause_game(1);\r
        *ipage = 1;\r
        prout("Lt. Uhura-  \"Captain, Starfleet Intelligence reports");\r
-       proutn("   the Super-commander is in");\r
-       cramlc(1, game.state.isx, game.state. isy);\r
+       proutn("   the Super-commander is in ");\r
+       proutn(cramlc(quadrant, game.state.isx, game.state. isy));\r
        prout(".\"");\r
        return;\r
 }\r
@@ -592,6 +585,8 @@ void movetho(void) {
                }\r
        }\r
        game.quad[ithx][ithy] = IHT;\r
+        game.kx[nenhere]=ithx;\r
+        game.ky[nenhere]=ithy;\r
 \r
        /* check to see if all holes plugged */\r
        for (i = 1; i < 11; i++) {\r
@@ -606,5 +601,6 @@ void movetho(void) {
        crmena(1,IHT, 2, ithx, ithy);\r
        prout(" completes web.");\r
        ithere = ithx = ithy = 0;\r
+       nenhere--;\r
        return;\r
 }\r