First round of changes from Stas Sergeev.
[super-star-trek.git] / moving.c
index 07eb148b3eecdbc0eb4c9af5925aac61ff736c82..ec7bc91b4ca0676f45d481991a654879b84679cd 100644 (file)
--- a/moving.c
+++ b/moving.c
@@ -1,11 +1,12 @@
+#include <unistd.h>\r
 #include "sst.h"\r
 \r
 static void getcd(int, int);\r
 \r
 void imove(void) {\r
        double angle, deltax, deltay, bigger, x, y,\r
-       finald, finalx, finaly, stopegy;\r
-       int trbeam = 0, n, l, ix, iy, kink, kinks, iquad;\r
+        finald, finalx, finaly, stopegy, probf;\r
+        int trbeam = 0, n, l, ix=0, iy=0, kink, kinks, iquad;\r
 \r
        if (inorbit) {\r
                prout("Helmsman Sulu- \"Leaving standard orbit.\"");\r
@@ -98,11 +99,11 @@ void imove(void) {
                                quady = (iy+9)/10;\r
                                sectx = ix - 10*(quadx-1);\r
                                secty = iy - 10*(quady-1);\r
-                               prout("");\r
-                               prout("Entering %s.",\r
+                               proutn("\n\rEntering %s.",\r
                                      cramlc(quadrant, quadx, quady));\r
                                game.quad[sectx][secty] = ship;\r
                                newqad(0);\r
+                                if (skill>1) attack(0);\r
                                return;\r
                        }\r
                        iquad = game.quad[ix][iy];\r
@@ -117,6 +118,7 @@ void imove(void) {
                                        case IHC:\r
                                        case IHS:\r
                                        case IHR:\r
+                                        case IHQUEST:\r
                                                sectx = ix;\r
                                                secty = iy;\r
                                                ram(0, iquad, sectx, secty);\r
@@ -131,7 +133,23 @@ void imove(void) {
                                                crmshp();\r
                                                proutn(" pulled into black hole at ");\r
                                                prout(cramlc(sector, ix, iy));\r
-                                               finish(FHOLE);\r
+                                               /*\r
+                                                * Getting pulled into a black \r
+                                                * hole was certain death in\r
+                                                * Almy's original.  Stas \r
+                                                * Sergeev added a possibility\r
+                                                * that you'll get timewarped\r
+                                                * instead.\r
+                                                */\r
+                                                n=0;\r
+                                                for (l=1;l<=NDEVICES+1;l++)\r
+                                                    if (game.damage[l]>0) n++;\r
+                                                probf=pow(1.4,(energy+shield)/5000.0-1.0)*\r
+                                                       pow(1.3,1.0/(n+1)-1.0);\r
+                                                if (Rand()>probf) \r
+                                                   timwrp();\r
+                                                else \r
+                                                   finish(FHOLE);\r
                                                return;\r
                                        default:\r
                                                /* something else */\r
@@ -186,9 +204,9 @@ label100:
        return;\r
 }\r
 \r
-void dock(void) {\r
+void dock(int l) {\r
        chew();\r
-       if (condit == IHDOCKED) {\r
+        if (condit == IHDOCKED && l) {\r
                prout("Already docked.");\r
                return;\r
        }\r
@@ -211,7 +229,7 @@ void dock(void) {
                (game.future[FCDBAS] < 1e30 || isatb == 1) && iseenit == 0) {\r
                /* get attack report from base */\r
                prout("Lt. Uhura- \"Captain, an important message from the starbase:\"");\r
-               attakreport();\r
+               attakreport(0);\r
                iseenit = 1;\r
        }\r
 }\r
@@ -226,7 +244,7 @@ static void getcd(int isprobe, int akey) {
           are always displayed y - x, where +y is downward! */\r
 \r
        \r
-       int irowq=quadx, icolq=quady, irows, icols, itemp=0, iprompt=0, key;\r
+        int irowq=quadx, icolq=quady, irows, icols, itemp=0, iprompt=0, key=0;\r
        double xi, xj, xk, xl;\r
        double deltax, deltay;\r
        int automatic = -1;\r
@@ -443,7 +461,7 @@ void impuls(void) {
        if (Time >= game.state.remtime) {\r
                prout("First Officer Spock- \"Captain, our speed under impulse");\r
                prout("power is only 0.95 sectors per stardate. Are you sure");\r
-               prout("we dare spend the time?\"");\r
+               proutn("we dare spend the time?\" ");\r
                if (ja() == 0) return;\r
        }\r
        /* Activate impulse engines and pay the cost */\r
@@ -519,8 +537,8 @@ void warp(int i) {
                        proutn("  a trip would require approximately %2.0f",\r
                                100.0*Time/game.state.remtime);\r
                        prout(" percent of our");\r
-                       prout(" remaining time.  Are you sure this is wise?\"");\r
-                       if (ja() == 0) { ididit = 0; return;}\r
+                        proutn("  remaining time.  Are you sure this is wise?\" ");\r
+                        if (ja() == 0) { ididit = 0; Time=0; return;}\r
                }\r
        }\r
        /* Entry WARPX */\r
@@ -600,7 +618,7 @@ void setwrp(void) {
        \r
        while ((key=scan()) == IHEOL) {\r
                chew();\r
-               proutn("Warp factor-");\r
+               proutn("Warp factor- ");\r
        }\r
        chew();\r
        if (key != IHREAL) {\r
@@ -628,7 +646,7 @@ void setwrp(void) {
        warpfac = aaitem;\r
        wfacsq=warpfac*warpfac;\r
        if (warpfac <= oldfac || warpfac <= 6.0) {\r
-               proutn("Helmsman Sulu- \"Warp factor %do, Captain.\"", \r
+               proutn("Helmsman Sulu- \"Warp factor %d, Captain.\"", \r
                        (int)warpfac);\r
                return;\r
        }\r
@@ -840,7 +858,7 @@ void probe(void) {
                key = scan();\r
        }\r
        else if (key == IHEOL) {\r
-               proutn("Arm NOVAMAX warhead?");\r
+               proutn("Arm NOVAMAX warhead? ");\r
                isarmed = ja();\r
        }\r
        getcd(TRUE, key);\r
@@ -945,7 +963,7 @@ void help(void) {
                        sectx=ix;\r
                        secty=iy;\r
                        game.quad[ix][iy]=ship;\r
-                       dock();\r
+                       dock(0);\r
                        skip(1);\r
                        prout("Lt. Uhura-  \"Captain, we made it!\"");\r
                        return;\r