Added the ability to suppress newer features with a game type option.
[super-star-trek.git] / setup.c
diff --git a/setup.c b/setup.c
index 2b360686b7ee282a0c99a0d5880601b91b104377..88884671d08a488c83ddda8e44045680c4ef9b3b 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -219,8 +219,8 @@ void setup(int needprompt)
     // Set up assorted game parameters
     batx = baty = 0;
     game.state.date = indate = 100.0*(int)(31.0*Rand()+20.0);
-    game.state.killk = game.state.killc = nkinks = nhelp = resting = casual = game.state.nromkl = 0;
-    isatb = iscate = imine = icrystl = icraft = game.state.nsckill = game.state.nplankl = 0;
+    nkinks = nhelp = resting = casual = 0;
+    isatb = iscate = imine = icrystl = icraft = game.state.nplankl = 0;
     game.state.starkl = game.state.basekl = 0;
     iscraft = 1;
     landed = -1;
@@ -231,18 +231,21 @@ void setup(int needprompt)
            game.state.galaxy[i][j].charted = 0;
            game.state.galaxy[i][j].planets = 0;
            game.state.galaxy[i][j].romulans = 0;
+           game.state.galaxy[i][j].klingons = 0;
+           game.state.galaxy[i][j].starbase = 0;
+           game.state.galaxy[i][j].supernova = 0;
        }
     // Initialize times for extraneous events
     game.future[FSNOVA] = game.state.date + expran(0.5 * intime);
     game.future[FTBEAM] = game.state.date + expran(1.5 * (intime / game.state.remcom));
     game.future[FSNAP] = game.state.date + 1.0 + Rand(); // Force an early snapshot
     game.future[FBATTAK] = game.state.date + expran(0.3*intime);
-    game.future[FCDBAS] = 1e30;
-    game.future[FSCMOVE] = game.state.nscrem ? game.state.date+0.2777 : 1e30;
-    game.future[FSCDBAS] = 1e30;
-    game.future[FDSPROB] = 1e30;
-    // Starchart is functional
-    stdamtim = 1e30;
+    game.future[FCDBAS] = FOREVER;
+    game.future[FSCMOVE] = game.state.nscrem ? game.state.date+0.2777 : FOREVER;
+    game.future[FSCDBAS] = FOREVER;
+    game.future[FDSPROB] = FOREVER;
+    // Starchart is functional but we've never seen it
+    lastchart = FOREVER;
     // Put stars in the galaxy
     instar = 0;
     for_quadrants(i)
@@ -261,16 +264,16 @@ void setup(int needprompt)
            for (j = i-1; j > 0; j--) {
                /* Improved placement algorithm to spread out bases */
                double distq = square(ix-game.state.baseqx[j]) + square(iy-game.state.baseqy[j]);
-               if (distq < 6.0*(BASEMAX-inbase) && Rand() < 0.75) {
+               if (distq < 6.0*(BASEMAX+1-inbase) && Rand() < 0.75) {
                    contflag = TRUE;
 #ifdef DEBUG
-                   proutn("DEBUG: Abandoning base #%d at %d-%d\n", i, ix, iy);
+                   prout("DEBUG: Abandoning base #%d at %d-%d", i, ix, iy);
 #endif
                    break;
                }
 #ifdef DEBUG
-               else if (distq < 6.0 * (BASEMAX-inbase)) {
-                   proutn("DEBUG: saving base #%d, close to #%d\n", i, j);
+               else if (distq < 6.0 * (BASEMAX+1-inbase)) {
+                   prout("DEBUG: saving base #%d, close to #%d", i, j);
                }
 #endif
            }
@@ -282,7 +285,7 @@ void setup(int needprompt)
        game.state.chart[ix][iy].starbase = 1;
     }
     // Position ordinary Klingon Battle Cruisers
-    krem = inkling - incom - game.state.nscrem;
+    krem = inkling;
     klumper = 0.25*skill*(9.0-length)+1.0;
     if (klumper > 9) klumper = 9; // Can't have more than 9 in quadrant
     do {
@@ -290,7 +293,9 @@ void setup(int needprompt)
        int klump = (1.0 - r*r)*klumper;
        if (klump > krem) klump = krem;
        krem -= klump;
-       do iran(GALSIZE,&ix,&iy); while (game.state.galaxy[ix][iy].supernova);
+       do iran(GALSIZE,&ix,&iy);
+       while (game.state.galaxy[ix][iy].supernova ||
+               game.state.galaxy[ix][iy].klingons + klump > 9);
        game.state.galaxy[ix][iy].klingons += klump;
     } while (krem > 0);
     // Position Klingon Commander Ships
@@ -362,7 +367,7 @@ void setup(int needprompt)
        prout("a deadly Klingon invasion force. As captain of the United");
        prout("Starship U.S.S. Enterprise, it is your mission to seek out");
        prout("and destroy this invasion force of %d battle cruisers.",
-             inkling);
+             INKLINGTOT);
        prout("You have an initial allotment of %d stardates to complete", (int)intime);
        prout("your mission.  As you proceed you may be given more time.");
        prout("");
@@ -372,7 +377,7 @@ void setup(int needprompt)
     else {
        prout("Stardate %d.", (int)game.state.date);
        prout("");
-       prout("%d Klingons.", inkling);
+       prout("%d Klingons.", INKLINGTOT);
        prout("An unknown number of Romulans.");
        if (game.state.nscrem) prout("and one (GULP) Super-Commander.");
        prout("%d stardates.",(int)intime);
@@ -462,6 +467,23 @@ int choose(int needprompt)
            else if (skill == SKILL_NONE) proutn("Are you a Novice, Fair, Good, Expert, or Emeritus player? ");
        }
     }
+    // Choose game options -- added by ESR for SST2K
+    if (scan() != IHALPHA) {
+       chew();
+       proutn("Choose your game options: ");
+       scan();
+    }
+    if (isit("plain"))
+       // Approximates the UT FORTRAN version.
+       game.options &=~ (OPTION_THOLIAN | OPTION_PLANETS | OPTION_THINGY | OPTION_PROBE | OPTION_RAMMING | OPTION_MVBADDY | OPTION_BLKHOLE | OPTION_BASE);
+    if (isit("almy"))
+       // Approximates Tom Almy's version.
+       game.options &=~ (OPTION_THINGY | OPTION_BLKHOLE | OPTION_BASE);
+    else if (strlen(citem)) {
+           proutn("What is \"");
+           proutn(citem);
+           prout("\"?");
+    }
     setpassword();
 #ifdef DEBUG
     if (strcmp(game.passwd, "debug")==0) idebug = 1;
@@ -469,18 +491,17 @@ int choose(int needprompt)
 
     // Use parameters to generate initial values of things
     damfac = 0.5 * skill;
-    game.state.rembase = 3.0*Rand()+2.0;
+    game.state.rembase = 2.0 + Rand()*(BASEMAX-2.0);
     inbase = game.state.rembase;
     if (game.options & OPTION_PLANETS)
        inplan = (PLNETMAX/2) + (PLNETMAX/2+1)*Rand();
-    game.state.nromrem = (2.0+Rand())*skill;
-    game.state.nscrem = (skill > SKILL_FAIR ? 1 : 0);
+    game.state.nromrem = inrom = (2.0+Rand())*skill;
+    game.state.nscrem = inscom = (skill > SKILL_FAIR ? 1 : 0);
     game.state.remtime = 7.0 * length;
     intime = game.state.remtime;
-    game.state.remkl = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15);
-    inkling = game.state.remkl;
+    game.state.remkl = inkling = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15);
     incom = skill + 0.0625*inkling*Rand();
-    game.state.remcom= min(10, incom);
+    game.state.remcom = min(10, incom);
     incom = game.state.remcom;
     game.state.remres = (inkling+4*incom)*intime;
     inresor = game.state.remres;
@@ -559,7 +580,7 @@ void newqad(int shutup)
            game.kpower[i] = Rand()*150.0 +300.0 +25.0*skill;
        }
        // If we need a commander, promote a Klingon
-       for (i = 1; i <= game.state.remcom ; i++) 
+       for_commanders(i)
            if (game.state.cx[i]==quadx && game.state.cy[i]==quady) break;
                        
        if (i <= game.state.remcom) {