More BSD features.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 19 Sep 2006 19:04:35 +0000 (19:04 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 19 Sep 2006 19:04:35 +0000 (19:04 +0000)
You can now lose if your entire crew dies in battle.  When abandoning
ship in a game with inhabited worlds enabled, they must have one in
the quadrant to beam down to; otherwise they die in space and this
counts heavily against your score (BSD Trek had score adjustment as a
to-do).  Docking at a starbase replenishes your crew.

src/battle.c
src/events.c
src/finish.c
src/moving.c
src/setup.c
src/sst.c
src/sst.h

index eb6fbe6df20682104d9e5c8f9d1aa6ea55d56d26..b200f4d2c280443150e6eac7be4a6ce521abf154 100644 (file)
@@ -158,6 +158,7 @@ void ram(int ibumpd, int ienm, coord w)
     icas = 10.0+20.0*Rand();
     prout(_("***Sickbay reports %d casualties"), icas);
     game.casual += icas;
     icas = 10.0+20.0*Rand();
     prout(_("***Sickbay reports %d casualties"), icas);
     game.casual += icas;
+    game.state.crew -= icas;
     for (l=0; l < NDEVICES; l++) {
        if (l == DDRAY) 
            continue; // Don't damage deathray 
     for (l=0; l < NDEVICES; l++) {
        if (l == DDRAY) 
            continue; // Don't damage deathray 
@@ -550,13 +551,13 @@ void attack(int torps_ok)
            if (absorb > game.shield) absorb = game.shield;
            game.shield -= absorb;
            hit -= hitsh;
            if (absorb > game.shield) absorb = game.shield;
            game.shield -= absorb;
            hit -= hitsh;
-           if (game.condit==IHDOCKED) dock(0);
+           if (game.condit==IHDOCKED) dock(false);
            if (propor > 0.1 && hit < 0.005*game.energy) continue;
        }
        /* It's a hit -- print out hit size */
        atackd = 1; /* We weren't going to check casualties, etc. if
                       shields were down for some strange reason. This
            if (propor > 0.1 && hit < 0.005*game.energy) continue;
        }
        /* It's a hit -- print out hit size */
        atackd = 1; /* We weren't going to check casualties, etc. if
                       shields were down for some strange reason. This
-                      doesn't make any sense, so I've fw.xed it */
+                      doesn't make any sense, so I've fixed it */
        ihurt = 1;
        proutn(_("%d unit hit"), (int)hit);
        if ((damaged(DSRSENS) && itflag) || game.skill<=SKILL_FAIR) {
        ihurt = 1;
        proutn(_("%d unit hit"), (int)hit);
        if ((damaged(DSRSENS) && itflag) || game.skill<=SKILL_FAIR) {
@@ -574,7 +575,7 @@ void attack(int torps_ok)
        fry(hit);
        game.energy -= hit;
        if (game.condit==IHDOCKED) 
        fry(hit);
        game.energy -= hit;
        if (game.condit==IHDOCKED) 
-           dock(0);
+           dock(false);
     }
     if (game.energy <= 0) {
        /* Returning home upon your shield, not with it... */
     }
     if (game.energy <= 0) {
        /* Returning home upon your shield, not with it... */
@@ -606,6 +607,7 @@ void attack(int torps_ok)
            prout(_("Mc Coy-  \"Sickbay to bridge.  We suffered %d casualties"), icas);
            prout(_("   in that last attack.\""));
            game.casual += icas;
            prout(_("Mc Coy-  \"Sickbay to bridge.  We suffered %d casualties"), icas);
            prout(_("   in that last attack.\""));
            game.casual += icas;
+           game.state.crew -= icas;
        }
     }
     /* After attack, reset average distance to enemies */
        }
     }
     /* After attack, reset average distance to enemies */
@@ -891,7 +893,8 @@ static int checkshctrl(double rpow)
        skip(1);
        prout(_("McCoy to bridge- \"Severe radiation burns, Jim."));
        prout(_("  %d casualties so far.\""), icas);
        skip(1);
        prout(_("McCoy to bridge- \"Severe radiation burns, Jim."));
        prout(_("  %d casualties so far.\""), icas);
-       game.casual -= icas;
+       game.casual += icas;
+       game.state.crew -= icas;
     }
     skip(1);
     prout(_("Phaser energy dispersed by shields."));
     }
     skip(1);
     prout(_("Phaser energy dispersed by shields."));
index 079fea41ef72529ff8d1f6022b4cd187ce2717ec..995440148009341200d19fe9f21e9a877e0c9ab3 100644 (file)
@@ -112,6 +112,11 @@ void events(void)
            finish(FDEPLETE);
            return;
        }
            finish(FDEPLETE);
            return;
        }
+       /* Any crew left alive? */
+       if (game.state.crew <=0) {
+           finish(FCREW);
+           return;
+       }
        /* Is life support adequate? */
        if (damaged(DLIFSUP) && game.condit != IHDOCKED) {
            if (game.lsupres < xtime && game.damage[DLIFSUP] > game.lsupres) {
        /* Is life support adequate? */
        if (damaged(DLIFSUP) && game.condit != IHDOCKED) {
            if (game.lsupres < xtime && game.damage[DLIFSUP] > game.lsupres) {
index 78680d871953b89d5ef573e3ad17db178d30998a..9c518b6c4bfed28dfe2496ef8ea0fa63e85510e4 100644 (file)
@@ -88,7 +88,7 @@ void finish(FINTYPE ifin)
        if (game.alive) {
            double badpt;
            badpt = 5.0*game.state.starkl + game.casual + 10.0*game.state.nplankl +
        if (game.alive) {
            double badpt;
            badpt = 5.0*game.state.starkl + game.casual + 10.0*game.state.nplankl +
-               45.*game.nhelp+100.*game.state.basekl;
+               45.*game.nhelp+100.*game.state.basekl+3.*game.abandoned;
            if (game.ship == IHF) badpt += 100.0;
            else if (game.ship == 0) badpt += 200.0;
            if (badpt < 100.0) badpt = 0.0;     // Close enough!
            if (game.ship == IHF) badpt += 100.0;
            else if (game.ship == 0) badpt += 200.0;
            if (badpt < 100.0) badpt = 0.0;     // Close enough!
@@ -278,6 +278,9 @@ void finish(FINTYPE ifin)
        prout(_("Your ship is drawn to the center of the black hole."));
        prout(_("You are crushed into extremely dense matter."));
        break;
        prout(_("Your ship is drawn to the center of the black hole."));
        prout(_("You are crushed into extremely dense matter."));
        break;
+    case FCREW:
+       prout(_("Your last crew member has died."));
+       break;
     }
     if (game.ship==IHF) game.ship= 0;
     else if (game.ship == IHE) game.ship = IHF;
     }
     if (game.ship==IHF) game.ship= 0;
     else if (game.ship == IHE) game.ship = IHF;
@@ -366,6 +369,9 @@ void score(void)
     if (game.casual)
        prout(_("%6d casualties incurred                %5d"),
              game.casual, -game.casual);
     if (game.casual)
        prout(_("%6d casualties incurred                %5d"),
              game.casual, -game.casual);
+    if (game.abandoned)
+       prout(_("%6d crew abandoned in space            %5d"),
+             game.abandoned, -3*game.abandoned);
     if (klship)
        prout(_("%6d ship(s) lost or destroyed          %5d"),
              klship, -100*klship);
     if (klship)
        prout(_("%6d ship(s) lost or destroyed          %5d"),
              klship, -100*klship);
index f9986c47d6eb3cf9ac560e52fbd093aa6a8ecbbe..126d3baa13ecd63c12158781a8ddfeefdf7c3a97 100644 (file)
@@ -214,10 +214,10 @@ no_quad_change:
     return;
 }
 
     return;
 }
 
-void dock(int l
+void dock(bool verbose
 {
     chew();
 {
     chew();
-    if (game.condit == IHDOCKED && l) {
+    if (game.condit == IHDOCKED && verbose) {
        prout(_("Already docked."));
        return;
     }
        prout(_("Already docked."));
        return;
     }
@@ -231,12 +231,13 @@ void dock(int l)
        return;
     }
     game.condit = IHDOCKED;
        return;
     }
     game.condit = IHDOCKED;
-    if (l) prout(_("Docked."));
+    if (verbose) prout(_("Docked."));
     game.ididit=1;
     if (game.energy < game.inenrg) game.energy = game.inenrg;
     game.shield = game.inshld;
     game.torps = game.intorps;
     game.lsupres = game.inlsr;
     game.ididit=1;
     if (game.energy < game.inenrg) game.energy = game.inenrg;
     game.shield = game.inshld;
     game.torps = game.intorps;
     game.lsupres = game.inlsr;
+    game.state.crew = FULLCREW;
     if (!damaged(DRADIO) &&
        (is_scheduled(FCDBAS) || game.isatb == 1) && game.iseenit == 0) {
        /* get attack report from base */
     if (!damaged(DRADIO) &&
        (is_scheduled(FCDBAS) || game.isatb == 1) && game.iseenit == 0) {
        /* get attack report from base */
index 94c74163e478582bf54518ed63cc89a89a35c9ad..812a6c177a6be30f6497e53aafec93801797117e 100644 (file)
@@ -28,7 +28,7 @@ void freeze(bool boss)
     }
     else {
        if ((key = scan()) == IHEOL) {
     }
     else {
        if ((key = scan()) == IHEOL) {
-           proutn("File name: ");
+           proutn(_("File name: "));
            key = scan();
        }
        if (key != IHALPHA) {
            key = scan();
        }
        if (key != IHALPHA) {
@@ -41,7 +41,7 @@ void freeze(bool boss)
        }
     }
     if ((fp = fopen(citem, "wb")) == NULL) {
        }
     }
     if ((fp = fopen(citem, "wb")) == NULL) {
-       proutn("Can't freeze game as file ");
+       proutn(_("Can't freeze game as file "));
        proutn(citem);
        skip(1);
        return;
        proutn(citem);
        skip(1);
        return;
@@ -169,6 +169,8 @@ void abandn(void)
            prout("to %s.", systemname(q->planet));
        } else {
            prout("Entire crew of %d left to die in outer space.");
            prout("to %s.", systemname(q->planet));
        } else {
            prout("Entire crew of %d left to die in outer space.");
+           game.casual += game.state.crew;
+           game.abandoned += game.state.crew;
        }
 
        /* If at least one base left, give 'em the Faerie Queene */
        }
 
        /* If at least one base left, give 'em the Faerie Queene */
@@ -202,6 +204,7 @@ void abandn(void)
     }
     /* Get new commission */
     game.quad[game.sector.x][game.sector.y] = game.ship = IHF;
     }
     /* Get new commission */
     game.quad[game.sector.x][game.sector.y] = game.ship = IHF;
+    game.state.crew = FULLCREW;
     prout("Starfleet puts you in command of another ship,");
     prout("the Faerie Queene, which is antiquated but,");
     prout("still useable.");
     prout("Starfleet puts you in command of another ship,");
     prout("the Faerie Queene, which is antiquated but,");
     prout("still useable.");
@@ -232,6 +235,7 @@ void setup(int needprompt)
     // Prepare the Enterprise
     game.alldone = game.gamewon = 0;
     game.ship = IHE;
     // Prepare the Enterprise
     game.alldone = game.gamewon = 0;
     game.ship = IHE;
+    game.state.crew = FULLCREW;
     game.energy = game.inenrg = 5000.0;
     game.shield = game.inshld = 2500.0;
     game.shldchg = 0;
     game.energy = game.inenrg = 5000.0;
     game.shield = game.inshld = 2500.0;
     game.shldchg = 0;
@@ -249,7 +253,7 @@ void setup(int needprompt)
     // Set up assorted game parameters
     game.battle.x = game.battle.y = 0;
     game.state.date = game.indate = 100.0*(int)(31.0*Rand()+20.0);
     // Set up assorted game parameters
     game.battle.x = game.battle.y = 0;
     game.state.date = game.indate = 100.0*(int)(31.0*Rand()+20.0);
-    game.nkinks = game.nhelp = game.casual = 0;
+    game.nkinks = game.nhelp = game.casual = game.abandoned = 0;
     game.resting = false;
     game.isatb = game.iscate = game.imine = game.icrystl = game.icraft = game.state.nplankl = 0;
     game.state.starkl = game.state.basekl = 0;
     game.resting = false;
     game.isatb = game.iscate = game.imine = game.icrystl = game.icraft = game.state.nplankl = 0;
     game.state.starkl = game.state.basekl = 0;
index 021e3d9bef3885a69f8c290e46043ca4d6b9b5ab..95ab355dadb846d11bf906a4757b8644d28c91cd 100644 (file)
--- a/src/sst.c
+++ b/src/sst.c
@@ -162,6 +162,12 @@ for a lot of magic numbers and refactored the heck out of it.
       type is "plain" or "almy".)
 
    6. User input is now logged so we can do regression testing.
       type is "plain" or "almy".)
 
    6. User input is now logged so we can do regression testing.
+
+   7. More BSD-Trek features: You can now lose if your entire crew
+      dies in battle.  When abandoning ship in a game with inhabited
+      worlds enabled, they must have one in the quadrant to beam down
+      to; otherwise they die in space and this counts heavily against
+      your score.  Docking at a starbase replenishes your crew.
 */
 
 /* the input queue */
 */
 
 /* the input queue */
index d58fea381e2faa3141a64dfa612b76cd039dd3e6..8651afd849224e987eff13a79403326a6b2a5c45 100644 (file)
--- a/src/sst.h
+++ b/src/sst.h
@@ -58,6 +58,8 @@ typedef struct {
 
 typedef struct {
     int snap,          // snapshot taken
 
 typedef struct {
     int snap,          // snapshot taken
+       crew,           // crew complement
+#define FULLCREW       428     /* BSD Trek was 387, that's wrong */
        remkl,                  // remaining klingons
        remcom,                 // remaining commanders
        nscrem,                 // remaining super commanders
        remkl,                  // remaining klingons
        remcom,                 // remaining commanders
        nscrem,                 // remaining super commanders
@@ -224,6 +226,7 @@ struct game {
        condit,         // condition (red/yellow/green/docked)
        torps,          // number of torpedoes
        ship,           // ship type -- 'E' is Enterprise
        condit,         // condition (red/yellow/green/docked)
        torps,          // number of torpedoes
        ship,           // ship type -- 'E' is Enterprise
+       abandoned,      // count of crew abandoned in space
        length,         // length of game
        skill,          // skill level
        klhere,         // klingons here
        length,         // length of game
        skill,          // skill level
        klhere,         // klingons here
@@ -295,7 +298,7 @@ typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
               FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
                          FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
                          FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
               FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
                          FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
                          FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
-                         FHOLE} FINTYPE ;
+             FHOLE, FCREW} FINTYPE ;
 enum loctype {neither, quadrant, sector};
 
 #define IHR 'R'
 enum loctype {neither, quadrant, sector};
 
 #define IHR 'R'
@@ -336,7 +339,7 @@ void phasers(void);
 void photon(void);
 void warp(bool);
 void doshield(int);
 void photon(void);
 void warp(bool);
 void doshield(int);
-void dock(int);
+void dock(bool);
 void dreprt(void);
 void chart(int);
 void rechart(void);
 void dreprt(void);
 void chart(int);
 void rechart(void);