Abstract out damage checks.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 19 Sep 2006 18:13:35 +0000 (18:13 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 19 Sep 2006 18:13:35 +0000 (18:13 +0000)
Implement BSD-Trek check in abandon-ship routine that transporter is
operational and an inhabited planet is nearby before crew can beam
down, otherwise they die in space.  (But this isn't counted against
your score yet.)

src/ai.c
src/battle.c
src/events.c
src/finish.c
src/io.c
src/moving.c
src/planets.c
src/reports.c
src/setup.c
src/sst.h

index 734a5b5334bb7739defc394a63edb4726ce20962..4b73b7488e190009efc01578eb494ee156b3db5f 100644 (file)
--- a/src/ai.c
+++ b/src/ai.c
@@ -26,7 +26,7 @@ static bool tryexit(int lookx, int looky, int ienm, int loccom, int irun)
     }
     /* print escape message and move out of quadrant.
        We know this if either short or long range sensors are working */
     }
     /* print escape message and move out of quadrant.
        We know this if either short or long range sensors are working */
-    if (game.damage[DSRSENS] == 0.0 || game.damage[DLRSENS] == 0.0 ||
+    if (!damaged(DSRSENS) || !damaged(DLRSENS) ||
        game.condit == IHDOCKED) {
        crmena(1, ienm, 2, game.ks[loccom]);
        prout(_(" escapes to %s (and regains strength)."),
        game.condit == IHDOCKED) {
        crmena(1, ienm, 2, game.ks[loccom]);
        prout(_(" escapes to %s (and regains strength)."),
@@ -87,7 +87,7 @@ static void movebaddy(coord com, int loccom, int ienm)
 
     /* If SC, check with spy to see if should hi-tail it */
     if (ienm==IHS &&
 
     /* If SC, check with spy to see if should hi-tail it */
     if (ienm==IHS &&
-       (game.kpower[loccom] <= 500.0 || (game.condit==IHDOCKED && game.damage[DPHOTON]==0))) {
+       (game.kpower[loccom] <= 500.0 || (game.condit==IHDOCKED && !damaged(DPHOTON)))) {
        irun = 1;
        motion = -QUADSIZE;
     }
        irun = 1;
        motion = -QUADSIZE;
     }
@@ -133,12 +133,12 @@ static void movebaddy(coord com, int loccom, int ienm)
 
        forces = game.kpower[loccom]+100.0*game.nenhere+400*(nbaddys-1);
        if (!game.shldup) forces += 1000; /* Good for enemy if shield is down! */
 
        forces = game.kpower[loccom]+100.0*game.nenhere+400*(nbaddys-1);
        if (!game.shldup) forces += 1000; /* Good for enemy if shield is down! */
-       if (game.damage[DPHASER] == 0.0 || game.damage[DPHOTON] == 0.0) {
-           if (game.damage[DPHASER] != 0) /* phasers damaged */
+       if (!damaged(DPHASER) || !damaged(DPHOTON)) {
+           if (damaged(DPHASER)) /* phasers damaged */
                forces += 300.0;
            else
                forces -= 0.2*(game.energy - 2500.0);
                forces += 300.0;
            else
                forces -= 0.2*(game.energy - 2500.0);
-           if (game.damage[DPHOTON] != 0) /* photon torpedoes damaged */
+           if (damaged(DPHOTON)) /* photon torpedoes damaged */
                forces += 300.0;
            else
                forces -= 50.0*game.torps;
                forces += 300.0;
            else
                forces -= 50.0*game.torps;
@@ -244,7 +244,7 @@ static void movebaddy(coord com, int loccom, int ienm)
        game.ks[loccom].y = next.y;
        game.kdist[loccom] = game.kavgd[loccom] =
            sqrt(square(game.sector.x-next.x)+square(game.sector.y-next.y));
        game.ks[loccom].y = next.y;
        game.kdist[loccom] = game.kavgd[loccom] =
            sqrt(square(game.sector.x-next.x)+square(game.sector.y-next.y));
-       if (game.damage[DSRSENS] == 0 || game.condit == IHDOCKED) {
+       if (!damaged(DSRSENS) || game.condit == IHDOCKED) {
            proutn("***");
            cramen(ienm);
            proutn(_(" from %s"), cramlc(2, com));
            proutn("***");
            cramen(ienm);
            proutn(_(" from %s"), cramlc(2, com));
@@ -339,7 +339,7 @@ static bool movescom(coord iq, bool flag, bool *ipage)
            /* destroy the planet */
            DESTROY(&game.state.plnets[i]);
            game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].planet = NOPLANET;
            /* destroy the planet */
            DESTROY(&game.state.plnets[i]);
            game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].planet = NOPLANET;
-           if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) {
+           if (!damaged(DRADIO) || game.condit == IHDOCKED) {
                if (*ipage==0) pause_game(1);
                *ipage = 1;
                prout(_("Lt. Uhura-  \"Captain, Starfleet Intelligence reports"));
                if (*ipage==0) pause_game(1);
                *ipage = 1;
                prout(_("Lt. Uhura-  \"Captain, Starfleet Intelligence reports"));
@@ -494,7 +494,7 @@ void scom(bool *ipage)
            schedule(FSCDBAS, 1.0 +2.0*Rand());
            if (is_scheduled(FCDBAS)) 
                postpone(FSCDBAS, scheduled(FCDBAS)-game.state.date);
            schedule(FSCDBAS, 1.0 +2.0*Rand());
            if (is_scheduled(FCDBAS)) 
                postpone(FSCDBAS, scheduled(FCDBAS)-game.state.date);
-           if (game.damage[DRADIO] > 0 && game.condit != IHDOCKED)
+           if (damaged(DRADIO) && game.condit != IHDOCKED)
                return; /* no warning */
            game.iseenit = 1;
            if (*ipage == 0)  pause_game(1);
                return; /* no warning */
            game.iseenit = 1;
            if (*ipage == 0)  pause_game(1);
@@ -517,7 +517,7 @@ void scom(bool *ipage)
     if (
        !idebug &&
        (Rand() > 0.2 ||
     if (
        !idebug &&
        (Rand() > 0.2 ||
-        (game.damage[DRADIO] > 0.0 && game.condit != IHDOCKED) ||
+        (damaged(DRADIO) && game.condit != IHDOCKED) ||
         !game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].charted))
        return;
     if (*ipage==0) pause_game(1);
         !game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].charted))
        return;
     if (*ipage==0) pause_game(1);
index 22cc13649df9e51cdc71546222d451b5fb99e465..eb6fbe6df20682104d9e5c8f9d1aa6ea55d56d26 100644 (file)
@@ -15,7 +15,7 @@ void doshield(int i)
                action = NRG;
            else {
                chew();
                action = NRG;
            else {
                chew();
-               if (game.damage[DSHIELD]) {
+               if (!damaged(DSHIELD)) {
                    prout(_("Shields damaged and down."));
                    return;
                }
                    prout(_("Shields damaged and down."));
                    return;
                }
@@ -31,7 +31,7 @@ void doshield(int i)
                proutn(_("Energy to transfer to shields- "));
                action = NRG;
            }
                proutn(_("Energy to transfer to shields- "));
                action = NRG;
            }
-           else if (game.damage[DSHIELD]) {
+           else if (damaged(DSHIELD)) {
                prout(_("Shields damaged and down."));
                return;
            }
                prout(_("Shields damaged and down."));
                return;
            }
@@ -191,7 +191,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
     if (fabs(deltay) > bigger) bigger = fabs(deltay);
     deltax /= bigger;
     deltay /= bigger;
     if (fabs(deltay) > bigger) bigger = fabs(deltay);
     deltax /= bigger;
     deltay /= bigger;
-    if (game.damage[DSRSENS]==0 || game.condit==IHDOCKED) 
+    if (!damaged(DSRSENS) || game.condit==IHDOCKED) 
        setwnd(srscan_window);
     else 
        setwnd(message_window);
        setwnd(srscan_window);
     else 
        setwnd(message_window);
@@ -466,7 +466,7 @@ static void fry(double hit)
        proutn(device[j]);
     }
     prout(_(" damaged."));
        proutn(device[j]);
     }
     prout(_(" damaged."));
-    if (game.damage[DSHIELD] && game.shldup) {
+    if (damaged(DSHIELD) && game.shldup) {
        prout(_("***Shields knocked down."));
        game.shldup=false;
     }
        prout(_("***Shields knocked down."));
        game.shldup=false;
     }
@@ -525,7 +525,7 @@ void attack(int torps_ok)
            double course = 1.90985*atan2((double)game.sector.y-jay.y, (double)jay.x-game.sector.x);
            hit = 0;
            proutn(_("***TORPEDO INCOMING"));
            double course = 1.90985*atan2((double)game.sector.y-jay.y, (double)jay.x-game.sector.x);
            hit = 0;
            proutn(_("***TORPEDO INCOMING"));
-           if (game.damage[DSRSENS] <= 0.0) {
+           if (!damaged(DSRSENS)) {
                proutn(_(" From "));
                crmena(0, iquad, i, jay);
            }
                proutn(_(" From "));
                crmena(0, iquad, i, jay);
            }
@@ -559,11 +559,11 @@ void attack(int torps_ok)
                       doesn't make any sense, so I've fw.xed it */
        ihurt = 1;
        proutn(_("%d unit hit"), (int)hit);
                       doesn't make any sense, so I've fw.xed it */
        ihurt = 1;
        proutn(_("%d unit hit"), (int)hit);
-       if ((game.damage[DSRSENS] > 0 && itflag) || game.skill<=SKILL_FAIR) {
+       if ((damaged(DSRSENS) && itflag) || game.skill<=SKILL_FAIR) {
            proutn(_(" on the "));
            crmshp();
        }
            proutn(_(" on the "));
            crmshp();
        }
-       if (game.damage[DSRSENS] <= 0.0 && itflag) {
+       if (!damaged(DSRSENS) && itflag) {
            proutn(_(" from "));
            crmena(0, iquad, i, jay);
        }
            proutn(_(" from "));
            crmena(0, iquad, i, jay);
        }
@@ -594,7 +594,7 @@ void attack(int torps_ok)
        skip(1);
        proutn(_("Energy left %2d    shields "), (int)game.energy);
        if (game.shldup) proutn(_("up "));
        skip(1);
        proutn(_("Energy left %2d    shields "), (int)game.energy);
        if (game.shldup) proutn(_("up "));
-       else if (game.damage[DSHIELD] == 0) proutn(_("down "));
+       else if (!damaged(DSHIELD)) proutn(_("down "));
        else proutn(_("damaged, "));
     }
     prout(_("%d%%,   torpedoes left %d"), percent, game.torps);
        else proutn(_("damaged, "));
     }
     prout(_("%d%%,   torpedoes left %d"), percent, game.torps);
@@ -726,7 +726,7 @@ void photon(void)
 
     game.ididit = 0;
 
 
     game.ididit = 0;
 
-    if (game.damage[DPHOTON]) {
+    if (damaged(DPHOTON)) {
        prout(_("Photon tubes damaged."));
        chew();
        return;
        prout(_("Photon tubes damaged."));
        chew();
        return;
@@ -911,19 +911,19 @@ void phasers(void)
 
     skip(1);
     /* SR sensors and Computer */
 
     skip(1);
     /* SR sensors and Computer */
-    if (game.damage[DSRSENS]+game.damage[DCOMPTR] > 0) ipoop = 0;
+    if (damaged(DSRSENS) || damaged(DCOMPTR)) ipoop = 0;
     if (game.condit == IHDOCKED) {
        prout(_("Phasers can't be fired through base shields."));
        chew();
        return;
     }
     if (game.condit == IHDOCKED) {
        prout(_("Phasers can't be fired through base shields."));
        chew();
        return;
     }
-    if (game.damage[DPHASER] != 0) {
+    if (damaged(DPHASER)) {
        prout(_("Phaser control damaged."));
        chew();
        return;
     }
     if (game.shldup) {
        prout(_("Phaser control damaged."));
        chew();
        return;
     }
     if (game.shldup) {
-       if (game.damage[DSHCTRL]) {
+       if (damaged(DSHCTRL)) {
            prout(_("High speed shield control damaged."));
            chew();
            return;
            prout(_("High speed shield control damaged."));
            chew();
            return;
@@ -1073,7 +1073,7 @@ void phasers(void)
     case FORCEMAN:
        chew();
        key = IHEOL;
     case FORCEMAN:
        chew();
        key = IHEOL;
-       if (game.damage[DCOMPTR]!=0)
+       if (damaged(DCOMPTR))
            prout(_("Battle comuter damaged, manual file only."));
        else {
            skip(1);
            prout(_("Battle comuter damaged, manual file only."));
        else {
            skip(1);
@@ -1096,7 +1096,7 @@ void phasers(void)
                msgflag = 0;
                rpow = 0.0;
            }
                msgflag = 0;
                rpow = 0.0;
            }
-           if (game.damage[DSRSENS] && !(abs(game.sector.x-aim.x) < 2 && abs(game.sector.y-aim.y) < 2) &&
+           if (damaged(DSRSENS) && !(abs(game.sector.x-aim.x) < 2 && abs(game.sector.y-aim.y) < 2) &&
                (ienm == IHC || ienm == IHS)) {
                cramen(ienm);
                prout(_(" can't be located without short range scan."));
                (ienm == IHC || ienm == IHS)) {
                cramen(ienm);
                prout(_(" can't be located without short range scan."));
@@ -1113,7 +1113,7 @@ void phasers(void)
                        (1.01+0.05*Rand()) + 1.0;
                kz = k;
                proutn("(");
                        (1.01+0.05*Rand()) + 1.0;
                kz = k;
                proutn("(");
-               if (game.damage[DCOMPTR]==0) proutn("%d", irec);
+               if (!damaged(DCOMPTR)) proutn("%d", irec);
                else proutn("??");
                proutn(")  ");
                proutn(_("units to fire at "));
                else proutn("??");
                proutn(")  ");
                proutn(_("units to fire at "));
@@ -1211,7 +1211,7 @@ void hittem(double *hits)
        kpow = game.kpower[kk];
        w = game.ks[kk];
        if (hit > 0.005) {
        kpow = game.kpower[kk];
        w = game.ks[kk];
        if (hit > 0.005) {
-           if (game.damage[DSRSENS]==0)
+           if (!damaged(DSRSENS))
                boom(w.x, w.y);
            proutn(_("%d unit hit on "), (int)hit);
        }
                boom(w.x, w.y);
            proutn(_("%d unit hit on "), (int)hit);
        }
index 7fdf27157544123fc86abd57e31ab597d2e4f206..079fea41ef72529ff8d1f6022b4cd187ce2717ec 100644 (file)
@@ -89,7 +89,7 @@ void events(void)
        }
     }
 
        }
     }
 
-    radio_was_broken = (game.damage[DRADIO] != 0.0);
+    radio_was_broken = damaged(DRADIO);
 
     for (;;) {
        /* Select earliest extraneous event, evcode==0 if no events */
 
     for (;;) {
        /* Select earliest extraneous event, evcode==0 if no events */
@@ -113,7 +113,7 @@ void events(void)
            return;
        }
        /* Is life support adequate? */
            return;
        }
        /* Is life support adequate? */
-       if (game.damage[DLIFSUP] && game.condit != IHDOCKED) {
+       if (damaged(DLIFSUP) && game.condit != IHDOCKED) {
            if (game.lsupres < xtime && game.damage[DLIFSUP] > game.lsupres) {
                finish(FLIFESUP);
                return;
            if (game.lsupres < xtime && game.damage[DLIFSUP] > game.lsupres) {
                finish(FLIFESUP);
                return;
@@ -129,7 +129,7 @@ void events(void)
            if (game.damage[l] > 0.0 && l != DDRAY)
                game.damage[l] -= (game.damage[l]-repair > 0.0 ? repair : game.damage[l]);
        /* If radio repaired, update star chart and attack reports */
            if (game.damage[l] > 0.0 && l != DDRAY)
                game.damage[l] -= (game.damage[l]-repair > 0.0 ? repair : game.damage[l]);
        /* If radio repaired, update star chart and attack reports */
-       if (radio_was_broken && game.damage[DRADIO] == 0.0) {
+       if (radio_was_broken && !damaged(DRADIO)) {
            prout(_("Lt. Uhura- \"Captain, the sub-space radio is working and"));
            prout(_("   surveillance reports are coming in."));
            skip(1);
            prout(_("Lt. Uhura- \"Captain, the sub-space radio is working and"));
            prout(_("   surveillance reports are coming in."));
            skip(1);
@@ -157,10 +157,10 @@ void events(void)
                game.condit==IHDOCKED || game.isatb==1 || game.iscate==1) return;
            if (game.ientesc ||
                (game.energy < 2000 && game.torps < 4 && game.shield < 1250) ||
                game.condit==IHDOCKED || game.isatb==1 || game.iscate==1) return;
            if (game.ientesc ||
                (game.energy < 2000 && game.torps < 4 && game.shield < 1250) ||
-               (game.damage[DPHASER]>0 && (game.damage[DPHOTON]>0 || game.torps < 4)) ||
-               (game.damage[DSHIELD] > 0 &&
-                (game.energy < 2500 || game.damage[DPHASER] > 0) &&
-                (game.torps < 5 || game.damage[DPHOTON] > 0))) {
+               (damaged(DPHASER) && (damaged(DPHOTON) || game.torps < 4)) ||
+               (damaged(DSHIELD) &&
+                (game.energy < 2500 || damaged(DPHASER)) &&
+                (game.torps < 5 || damaged(DPHOTON)))) {
                /* Tractor-beam her! */
                istract=1;
                yank = square(game.state.kscmdr.x-game.quadrant.x) + square(game.state.kscmdr.y-game.quadrant.y);
                /* Tractor-beam her! */
                istract=1;
                yank = square(game.state.kscmdr.x-game.quadrant.x) + square(game.state.kscmdr.y-game.quadrant.y);
@@ -227,7 +227,7 @@ void events(void)
                game.resting = false;
            }
            if (!game.shldup) {
                game.resting = false;
            }
            if (!game.shldup) {
-               if (game.damage[DSHIELD]==0 && game.shield > 0) {
+               if (!damaged(DSHIELD) && game.shield > 0) {
                    doshield(2); /* Shldsup */
                    game.shldchg=0;
                }
                    doshield(2); /* Shldsup */
                    game.shldchg=0;
                }
@@ -276,7 +276,7 @@ void events(void)
                postpone(FCDBAS, scheduled(FSCDBAS)-game.state.date);
            game.future[FBATTAK].date = game.future[FCDBAS].date + expran(0.3*game.intime);
            game.iseenit = 0;
                postpone(FCDBAS, scheduled(FSCDBAS)-game.state.date);
            game.future[FBATTAK].date = game.future[FCDBAS].date + expran(0.3*game.intime);
            game.iseenit = 0;
-           if (game.damage[DRADIO] != 0.0 && game.condit != IHDOCKED) 
+           if (!damaged(DRADIO) && game.condit != IHDOCKED) 
                break; /* No warning :-( */
            game.iseenit = 1;
            if (!ipage) pause_game(1);
                break; /* No warning :-( */
            game.iseenit = 1;
            if (!ipage) pause_game(1);
@@ -325,7 +325,7 @@ void events(void)
                prout(_("Spock-  \"Captain, I believe the starbase has been destroyed.\""));
            }
            else if (game.state.rembase != 1 &&
                prout(_("Spock-  \"Captain, I believe the starbase has been destroyed.\""));
            }
            else if (game.state.rembase != 1 &&
-                    (game.damage[DRADIO] <= 0.0 || game.condit == IHDOCKED)) {
+                    (!damaged(DRADIO) || game.condit == IHDOCKED)) {
                /* Get word via subspace radio */
                if (!ipage) pause_game(1);
                ipage = true;
                /* Get word via subspace radio */
                if (!ipage) pause_game(1);
                ipage = true;
@@ -372,7 +372,7 @@ void events(void)
                if (!VALID_QUADRANT(i, j) ||
                    game.state.galaxy[game.probec.x][game.probec.y].supernova) {
                    // Left galaxy or ran into supernova
                if (!VALID_QUADRANT(i, j) ||
                    game.state.galaxy[game.probec.x][game.probec.y].supernova) {
                    // Left galaxy or ran into supernova
-                   if (game.damage[DRADIO]==0.0 || game.condit == IHDOCKED) {
+                   if (!damaged(DRADIO) || game.condit == IHDOCKED) {
                        if (ipage==0) pause_game(1);
                        ipage = 1;
                        skip(1);
                        if (ipage==0) pause_game(1);
                        ipage = 1;
                        skip(1);
@@ -386,7 +386,7 @@ void events(void)
                    unschedule(FDSPROB);
                    break;
                }
                    unschedule(FDSPROB);
                    break;
                }
-               if (game.damage[DRADIO]==0.0   || game.condit == IHDOCKED) {
+               if (!damaged(DRADIO) || game.condit == IHDOCKED) {
                    if (ipage==0) pause_game(1);
                    ipage = 1;
                    skip(1);
                    if (ipage==0) pause_game(1);
                    ipage = 1;
                    skip(1);
@@ -398,7 +398,7 @@ void events(void)
            pdest = &game.state.galaxy[game.probec.x][game.probec.y];
            /* Update star chart if Radio is working or have access to
               radio. */
            pdest = &game.state.galaxy[game.probec.x][game.probec.y];
            /* Update star chart if Radio is working or have access to
               radio. */
-           if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) {
+           if (!damaged(DRADIO) || game.condit == IHDOCKED) {
                struct page *chp = &game.state.chart[game.probec.x][game.probec.y];
 
                chp->klingons = pdest->klingons;
                struct page *chp = &game.state.chart[game.probec.x][game.probec.y];
 
                chp->klingons = pdest->klingons;
@@ -442,7 +442,7 @@ void events(void)
            q->status = distressed;
 
            /* tell the captain about it if we can */
            q->status = distressed;
 
            /* tell the captain about it if we can */
-           if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED)
+           if (!damaged(DRADIO) || game.condit == IHDOCKED)
            {
                prout("Uhura- Captain, %s in %s reports it is under attack",
                      systemname(q->planet), cramlc(quadrant, w));
            {
                prout("Uhura- Captain, %s in %s reports it is under attack",
                      systemname(q->planet), cramlc(quadrant, w));
@@ -466,7 +466,7 @@ void events(void)
            ev2->quadrant = ev->quadrant;
 
            /* report the disaster if we can */
            ev2->quadrant = ev->quadrant;
 
            /* report the disaster if we can */
-           if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED)
+           if (!damaged(DRADIO) || game.condit == IHDOCKED)
            {
                prout("Uhura- We've lost contact with starsystem %s",
                      systemname(q->planet));
            {
                prout("Uhura- We've lost contact with starsystem %s",
                      systemname(q->planet));
@@ -519,7 +519,7 @@ void events(void)
            /* recompute time left */
            game.state.remtime = game.state.remres/(game.state.remkl+4*game.state.remcom);
            /* report the disaster if we can */
            /* recompute time left */
            game.state.remtime = game.state.remres/(game.state.remkl+4*game.state.remcom);
            /* report the disaster if we can */
-           if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED)
+           if (!damaged(DRADIO) || game.condit == IHDOCKED)
            {
                if (same(game.quadrant, w)) {
                    prout("Spock- sensors indicate the Klingons have");
            {
                if (same(game.quadrant, w)) {
                    prout("Spock- sensors indicate the Klingons have");
@@ -821,7 +821,7 @@ void snova(int insx, int insy)
 
        if (nq.x != game.quadrant.y || nq.y != game.quadrant.y || game.justin != 0) {
            /* it isn't here, or we just entered (treat as inroute) */
 
        if (nq.x != game.quadrant.y || nq.y != game.quadrant.y || game.justin != 0) {
            /* it isn't here, or we just entered (treat as inroute) */
-           if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) {
+           if (!damaged(DRADIO) || game.condit == IHDOCKED) {
                skip(1);
                prout(_("Message from Starfleet Command       Stardate %.2f"), game.state.date);
                prout(_("     Supernova in %s; caution advised."),
                skip(1);
                prout(_("Message from Starfleet Command       Stardate %.2f"), game.state.date);
                prout(_("     Supernova in %s; caution advised."),
@@ -919,7 +919,7 @@ void snova(int insx, int insy)
        game.state.nplankl += npdead;
     }
     /* mark supernova in galaxy and in star chart */
        game.state.nplankl += npdead;
     }
     /* mark supernova in galaxy and in star chart */
-    if (same(game.quadrant, nq) || game.damage[DRADIO] == 0 || game.condit == IHDOCKED)
+    if (same(game.quadrant, nq) || !damaged(DRADIO) || game.condit == IHDOCKED)
        game.state.galaxy[nq.x][nq.y].supernova = true;
     /* If supernova destroys last Klingons give special message */
     if (KLINGREM==0 && (nq.x != game.quadrant.x || nq.y != game.quadrant.y)) {
        game.state.galaxy[nq.x][nq.y].supernova = true;
     /* If supernova destroys last Klingons give special message */
     if (KLINGREM==0 && (nq.x != game.quadrant.x || nq.y != game.quadrant.y)) {
index 54b5beaca08a7db10f4b5b19f89706390adf1b15..78680d871953b89d5ef573e3ad17db178d30998a 100644 (file)
@@ -6,7 +6,7 @@ void dstrct()
 {
     /* Finish with a BANG! */
     chew();
 {
     /* Finish with a BANG! */
     chew();
-    if (game.damage[DCOMPTR] != 0.0) {
+    if (damaged(DCOMPTR)) {
        prout(_("Computer damaged; cannot execute destruct sequence."));
        return;
     }
        prout(_("Computer damaged; cannot execute destruct sequence."));
        return;
     }
index dc4ce744fee5cf1350af13c2c991a2096ba46441..ecbe87aff9ddb1d373d471a0925f867d41e4dd4a 100644 (file)
--- a/src/io.c
+++ b/src/io.c
@@ -398,7 +398,7 @@ void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad)
            skip(1);
        proutn("%d - %d   ", ix, iy);
     } else {
            skip(1);
        proutn("%d - %d   ", ix, iy);
     } else {
-       if (game.damage[DSRSENS]==0 || game.condit==IHDOCKED) {
+       if (!damaged(DSRSENS) || game.condit==IHDOCKED) {
            if (i != 1 && l == 1) {
                drawmaps(2);
                delay(400);
            if (i != 1 && l == 1) {
                drawmaps(2);
                delay(400);
index e966bed76a47899bb6633828656301df8f619ee3..b273c60051e0ad32c38e6afe7715a18e99fbfd53 100644 (file)
@@ -237,7 +237,7 @@ void dock(int l)
     game.shield = game.inshld;
     game.torps = game.intorps;
     game.lsupres = game.inlsr;
     game.shield = game.inshld;
     game.torps = game.intorps;
     game.lsupres = game.inlsr;
-    if (game.damage[DRADIO] == 0.0 &&
+    if (!damaged(DRADIO) &&
        (is_scheduled(FCDBAS) || game.isatb == 1) && game.iseenit == 0) {
        /* get attack report from base */
        prout("Lt. Uhura- \"Captain, an important message from the starbase:\"");
        (is_scheduled(FCDBAS) || game.isatb == 1) && game.iseenit == 0) {
        /* get attack report from base */
        prout("Lt. Uhura- \"Captain, an important message from the starbase:\"");
@@ -276,7 +276,7 @@ static void getcd(bool isprobe, int akey) {
                return;
        }
        while (automatic == -1) {
                return;
        }
        while (automatic == -1) {
-               if (game.damage[DCOMPTR]) {
+               if (damaged(DCOMPTR)) {
                        if (isprobe)
                                prout("Computer damaged; manual navigation only");
                        else
                        if (isprobe)
                                prout("Computer damaged; manual navigation only");
                        else
@@ -438,7 +438,7 @@ void impuls(void)
     double power;
 
     game.ididit = 0;
     double power;
 
     game.ididit = 0;
-    if (game.damage[DIMPULS]) {
+    if (damaged(DIMPULS)) {
        chew();
        skip(1);
        prout("Engineer Scott- \"The impulse engines are damaged, Sir.\"");
        chew();
        skip(1);
        prout("Engineer Scott- \"The impulse engines are damaged, Sir.\"");
@@ -502,7 +502,7 @@ void warp(bool timewarp)
            prout("Engineer Scott- \"The impulse engines are damaged, Sir.\"");
            return;
        }
            prout("Engineer Scott- \"The impulse engines are damaged, Sir.\"");
            return;
        }
-       if (game.damage[DWARPEN] > 0.0 && game.warpfac > 4.0) {
+       if (damaged(DWARPEN) && game.warpfac > 4.0) {
            chew();
            skip(1);
            prout("Engineer Scott- \"Sorry, Captain. Until this damage");
            chew();
            skip(1);
            prout("Engineer Scott- \"Sorry, Captain. Until this damage");
@@ -641,7 +641,7 @@ void setwrp(void)
        prout("Warp engines inoperative.");
        return;
     }
        prout("Warp engines inoperative.");
        return;
     }
-    if (game.damage[DWARPEN] > 0.0 && aaitem > 4.0) {
+    if (damaged(DWARPEN) && aaitem > 4.0) {
        prout("Engineer Scott- \"I'm doing my best, Captain,");
        prout("  but right now we can only go warp 4.\"");
        return;
        prout("Engineer Scott- \"I'm doing my best, Captain,");
        prout("  but right now we can only go warp 4.\"");
        return;
@@ -681,7 +681,7 @@ void atover(int igrab)
     chew();
     /* is captain on planet? */
     if (game.landed==1) {
     chew();
     /* is captain on planet? */
     if (game.landed==1) {
-       if (game.damage[DTRANSP]) {
+       if (damaged(DTRANSP)) {
            finish(FPNOVA);
            return;
        }
            finish(FPNOVA);
            return;
        }
@@ -731,10 +731,10 @@ void atover(int igrab)
        crmshp();
        skip(1);
        prout("safely out of quadrant.");
        crmshp();
        skip(1);
        prout("safely out of quadrant.");
-       if (game.damage[DRADIO] == 0.0)
+       if (!damaged(DRADIO))
            game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true;
        /* Try to use warp engines */
            game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true;
        /* Try to use warp engines */
-       if (game.damage[DWARPEN]) {
+       if (damaged(DWARPEN)) {
            skip(1);
            prout("Warp engines damaged.");
            finish(FSNOVAED);
            skip(1);
            prout("Warp engines damaged.");
            finish(FSNOVAED);
@@ -841,7 +841,7 @@ void probe(void)
            prout("Ye Faerie Queene has no deep space probes.");
        return;
     }
            prout("Ye Faerie Queene has no deep space probes.");
        return;
     }
-    if (game.damage[DDSP] != 0.0) {
+    if (damaged(DDSP)) {
        chew();
        skip(1);
        prout("Engineer Scott- \"The probe launcher is damaged, Sir.\"");
        chew();
        skip(1);
        prout("Engineer Scott- \"The probe launcher is damaged, Sir.\"");
@@ -850,7 +850,7 @@ void probe(void)
     if (is_scheduled(FDSPROB)) {
        chew();
        skip(1);
     if (is_scheduled(FDSPROB)) {
        chew();
        skip(1);
-       if (game.damage[DRADIO] != 0 && game.condit != IHDOCKED) {
+       if (damaged(DRADIO) && game.condit != IHDOCKED) {
            prout("Spock-  \"Records show the previous probe has not yet");
            prout("   reached its destination.\"");
        }
            prout("Spock-  \"Records show the previous probe has not yet");
            prout("   reached its destination.\"");
        }
@@ -911,7 +911,7 @@ void mayday(void)
        prout("Lt. Uhura-  \"But Captain, we're already docked.\"");
        return;
     }
        prout("Lt. Uhura-  \"But Captain, we're already docked.\"");
        return;
     }
-    if (game.damage[DRADIO] != 0) {
+    if (damaged(DRADIO)) {
        prout("Subspace radio damaged.");
        return;
     }
        prout("Subspace radio damaged.");
        return;
     }
index 25a4dfc5ebd23f940938eef4e65078cb8fc9d742..8471848718b1cc544ef51b2e48b3c2d3f2d319e9 100644 (file)
@@ -62,7 +62,7 @@ void orbit(void)
        prout("Already in standard orbit.");
        return;
     }
        prout("Already in standard orbit.");
        return;
     }
-    if (game.damage[DWARPEN] != 0 && game.damage[DIMPULS] != 0) {
+    if (damaged(DWARPEN) && damaged(DIMPULS)) {
        prout("Both warp and impulse engines damaged.");
        return;
     }
        prout("Both warp and impulse engines damaged.");
        return;
     }
@@ -86,7 +86,7 @@ void sensor(void)
 {
     skip(1);
     chew();
 {
     skip(1);
     chew();
-    if (game.damage[DSRSENS] != 0.0) {
+    if (damaged(DSRSENS)) {
        prout("Short range sensors damaged.");
        return;
     }
        prout("Short range sensors damaged.");
        return;
     }
@@ -113,9 +113,9 @@ void beam(void)
 {
     chew();
     skip(1);
 {
     chew();
     skip(1);
-    if (game.damage[DTRANSP] != 0) {
+    if (damaged(DTRANSP)) {
        prout("Transporter damaged.");
        prout("Transporter damaged.");
-       if (game.damage[DSHUTTL]==0 && (game.state.plnets[game.iplnet].known==shuttle_down || game.iscraft == 1)) {
+       if (!damaged(DSHUTTL) && (game.state.plnets[game.iplnet].known==shuttle_down || game.iscraft == 1)) {
            skip(1);
            proutn("Spock-  \"May I suggest the shuttle craft, Sir?\" ");
            if (ja() != 0) shuttle();
            skip(1);
            proutn("Spock-  \"May I suggest the shuttle craft, Sir?\" ");
            if (ja() != 0) shuttle();
@@ -287,7 +287,7 @@ void shuttle(void)
 {
     chew();
     skip(1);
 {
     chew();
     skip(1);
-    if(game.damage[DSHUTTL] != 0.0) {
+    if(damaged(DSHUTTL)) {
        if (game.damage[DSHUTTL] == -1.0) {
            if (game.inorbit && game.state.plnets[game.iplnet].known == shuttle_down)
                prout("Ye Faerie Queene has no shuttle craft bay to dock it at.");
        if (game.damage[DSHUTTL] == -1.0) {
            if (game.inorbit && game.state.plnets[game.iplnet].known == shuttle_down)
                prout("Ye Faerie Queene has no shuttle craft bay to dock it at.");
@@ -296,7 +296,8 @@ void shuttle(void)
        }
        else if (game.damage[DSHUTTL] > 0)
            prout("The Galileo is damaged.");
        }
        else if (game.damage[DSHUTTL] > 0)
            prout("The Galileo is damaged.");
-       else prout("Shuttle craft is now serving Big Macs.");
+       else /* game.damage[DSHUTTL] < 0 */ 
+           prout("Shuttle craft is now serving Big Macs.");
        return;
     }
     if (!game.inorbit) {
        return;
     }
     if (!game.inorbit) {
@@ -338,7 +339,7 @@ void shuttle(void)
        /* Kirk on planet */
        if (game.iscraft==1) {
            /* Galileo on ship! */
        /* Kirk on planet */
        if (game.iscraft==1) {
            /* Galileo on ship! */
-           if (game.damage[DTRANSP]==0) {
+           if (!damaged(DTRANSP)) {
                proutn("Spock-  \"Would you rather use the transporter?\" ");
                if (ja() != 0) {
                    beam();
                proutn("Spock-  \"Would you rather use the transporter?\" ");
                if (ja() != 0) {
                    beam();
@@ -412,7 +413,7 @@ void deathray(void)
        prout("Sulu-  \"But Sir, there are no enemies in this quadrant.\"");
        return;
     }
        prout("Sulu-  \"But Sir, there are no enemies in this quadrant.\"");
        return;
     }
-    if (game.damage[DDRAY] > 0.0) {
+    if (damaged(DDRAY)) {
        prout("Death Ray is damaged.");
        return;
     }
        prout("Death Ray is damaged.");
        return;
     }
index e1b6cc710cf2e69349d553358961e4e8bb1e9932..b2ee2b7d2bd04e0d1429812aa68eca380e8f82a3 100644 (file)
@@ -69,7 +69,7 @@ void report(void)
        prout(" destroyed, %d remaining.", game.state.rembase);
     }
     else prout("There are %d bases.", game.inbase);
        prout(" destroyed, %d remaining.", game.state.rembase);
     }
     else prout("There are %d bases.", game.inbase);
-    if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED || game.iseenit) {
+    if (!damaged(DRADIO) || game.condit == IHDOCKED || game.iseenit) {
        /* Don't report this if not seen and
           either the radio is dead or not at base! */
        attakreport(0);
        /* Don't report this if not seen and
           either the radio is dead or not at base! */
        attakreport(0);
@@ -87,7 +87,7 @@ void report(void)
        if (game.nprobes!=1) proutn("s");
        prout(".");
     }
        if (game.nprobes!=1) proutn("s");
        prout(".");
     }
-    if ((game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED)
+    if ((!damaged(DRADIO) || game.condit == IHDOCKED)
                && is_scheduled(FDSPROB)) {
        if (game.isarmed) 
            proutn("An armed deep space probe is in");
                && is_scheduled(FDSPROB)) {
        if (game.isarmed) 
            proutn("An armed deep space probe is in");
@@ -117,7 +117,7 @@ void lrscan(void)
 {
     int x, y;
     chew();
 {
     int x, y;
     chew();
-    if (game.damage[DLRSENS] != 0.0) {
+    if (damaged(DLRSENS)) {
        /* Now allow base's sensors if docked */
        if (game.condit != IHDOCKED) {
            prout("LONG-RANGE SENSORS DAMAGED.");
        /* Now allow base's sensors if docked */
        if (game.condit != IHDOCKED) {
            prout("LONG-RANGE SENSORS DAMAGED.");
@@ -134,7 +134,7 @@ void lrscan(void)
            if (!VALID_QUADRANT(x, y))
                proutn("  -1");
            else {
            if (!VALID_QUADRANT(x, y))
                proutn("  -1");
            else {
-               if (!game.damage[DRADIO])
+               if (!damaged(DRADIO))
                    game.state.galaxy[x][y].charted = true;
                game.state.chart[x][y].klingons = game.state.galaxy[x][y].klingons;
                game.state.chart[x][y].starbase = game.state.galaxy[x][y].starbase;
                    game.state.galaxy[x][y].charted = true;
                game.state.chart[x][y].klingons = game.state.galaxy[x][y].klingons;
                game.state.chart[x][y].starbase = game.state.galaxy[x][y].starbase;
@@ -156,7 +156,7 @@ void dreprt(void)
     chew();
 
     for (i = 0; i < NDEVICES; i++) {
     chew();
 
     for (i = 0; i < NDEVICES; i++) {
-       if (game.damage[i] > 0.0) {
+       if (damaged(i)) {
            if (!jdam) {
                prout("DEVICE            -REPAIR TIMES-");
                prout("                IN FLIGHT   DOCKED");
            if (!jdam) {
                prout("DEVICE            -REPAIR TIMES-");
                prout("                IN FLIGHT   DOCKED");
@@ -190,7 +190,7 @@ void chart(int nn)
     int i,j;
     chew();
 
     int i,j;
     chew();
 
-    if (game.damage[DRADIO] == 0.0)
+    if (!damaged(DRADIO))
        rechart();
 
     if (game.lastchart < game.state.date && game.condit == IHDOCKED) {
        rechart();
 
     if (game.lastchart < game.state.date && game.condit == IHDOCKED) {
@@ -280,7 +280,7 @@ static void status(int req)
        break;
     case 4:
        proutn("Life Support  ");
        break;
     case 4:
        proutn("Life Support  ");
-       if (game.damage[DLIFSUP] != 0.0) {
+       if (damaged(DLIFSUP)) {
            if (game.condit == IHDOCKED)
                proutn("DAMAGED, Base provides");
            else
            if (game.condit == IHDOCKED)
                proutn("DAMAGED, Base provides");
            else
@@ -302,7 +302,7 @@ static void status(int req)
        break;
     case 8:
        proutn("Shields       ");
        break;
     case 8:
        proutn("Shields       ");
-       if (game.damage[DSHIELD] != 0)
+       if (damaged(DSHIELD))
            proutn("DAMAGED,");
        else if (game.shldup)
            proutn("UP,");
            proutn("DAMAGED,");
        else if (game.shldup)
            proutn("UP,");
@@ -340,7 +340,7 @@ int srscan(int l)
     int goodScan=true, leftside=true, rightside=true, nn=false; 
     switch (l) {
     case SCAN_FULL: // SRSCAN
     int goodScan=true, leftside=true, rightside=true, nn=false; 
     switch (l) {
     case SCAN_FULL: // SRSCAN
-       if (game.damage[DSRSENS] != 0) {
+       if (damaged(DSRSENS)) {
            /* Allow base's sensors if docked */
            if (game.condit != IHDOCKED) {
                prout("   S.R. SENSORS DAMAGED!");
            /* Allow base's sensors if docked */
            if (game.condit != IHDOCKED) {
                prout("   S.R. SENSORS DAMAGED!");
@@ -350,7 +350,7 @@ int srscan(int l)
                prout("  [Using Base's sensors]");
        }
        else prout("     Short-range scan");
                prout("  [Using Base's sensors]");
        }
        else prout("     Short-range scan");
-       if (goodScan && !game.damage[DRADIO]) { 
+       if (goodScan && !damaged(DRADIO)) { 
            game.state.chart[game.quadrant.x][game.quadrant.y].klingons = game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons;
            game.state.chart[game.quadrant.x][game.quadrant.y].starbase = game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase;
            game.state.chart[game.quadrant.x][game.quadrant.y].stars = game.state.galaxy[game.quadrant.x][game.quadrant.y].stars;
            game.state.chart[game.quadrant.x][game.quadrant.y].klingons = game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons;
            game.state.chart[game.quadrant.x][game.quadrant.y].starbase = game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase;
            game.state.chart[game.quadrant.x][game.quadrant.y].stars = game.state.galaxy[game.quadrant.x][game.quadrant.y].stars;
@@ -410,7 +410,7 @@ void eta(void)
     int ix1, ix2, iy1, iy2;
     bool wfl, prompt = false;
     double ttime, twarp, tpower;
     int ix1, ix2, iy1, iy2;
     bool wfl, prompt = false;
     double ttime, twarp, tpower;
-    if (game.damage[DCOMPTR] != 0.0) {
+    if (damaged(DCOMPTR)) {
        prout("COMPUTER DAMAGED, USE A POCKET CALCULATOR.");
        skip(1);
        return;
        prout("COMPUTER DAMAGED, USE A POCKET CALCULATOR.");
        skip(1);
        return;
index 77f58bd899cb4d6479d9de30a4b8769bad3809d2..03d9e794f36a50d7f250dd18c0bd244464e01395 100644 (file)
@@ -92,9 +92,31 @@ int thaw(void)
     return 0;
 }
 
     return 0;
 }
 
+/*
+**  Abandon Ship
+**
+**     The ship is abandoned.  If your current ship is the Faire
+**     Queene, or if your shuttlecraft is dead, you're out of
+**     luck.  You need the shuttlecraft in order for the captain
+**     (that's you!!) to escape.
+**
+**     Your crew can beam to an inhabited starsystem in the
+**     quadrant, if there is one and if the transporter is working.
+**     If there is no inhabited starsystem, or if the transporter
+**     is out, they are left to die in outer space.
+**
+**     If there are no starbases left, you are captured by the
+**     Klingons, who torture you mercilessly.  However, if there
+**     is at least one starbase, you are returned to the
+**     Federation in a prisoner of war exchange.  Of course, this
+**     can't happen unless you have taken some prisoners.
+**
+*/
+
 void abandn(void) 
 {
     int nb, l;
 void abandn(void) 
 {
     int nb, l;
+    struct quadrant *q;
 
     chew();
     if (game.condit==IHDOCKED) {
 
     chew();
     if (game.condit==IHDOCKED) {
@@ -132,13 +154,23 @@ void abandn(void)
        prouts("***ALL HANDS ABANDON SHIP!");
        skip(2);
        prout("Captain and crew escape in shuttle craft.");
        prouts("***ALL HANDS ABANDON SHIP!");
        skip(2);
        prout("Captain and crew escape in shuttle craft.");
-       prout("Remainder of ship's complement beam down");
-       prout("to nearest habitable planet.");
        if (game.state.rembase==0) {
            /* Oops! no place to go... */
            finish(FABANDN);
            return;
        }
        if (game.state.rembase==0) {
            /* Oops! no place to go... */
            finish(FABANDN);
            return;
        }
+       q = &game.state.galaxy[game.quadrant.x][game.quadrant.y];
+       /* Dispose of crew */
+       if (!(game.options & OPTION_WORLDS) && !damaged(DTRANSP)) {
+           prout("Remainder of ship's complement beam down");
+           prout("to nearest habitable planet.");
+       } else if (q->planet != NOPLANET && !damaged(DTRANSP)) {
+           prout("Remainder of ship's complement beam down");
+           prout("to %s.", systemname(q->planet));
+       } else {
+           prout("Entire crew of %d left to die in outer space.");
+       }
+
        /* If at least one base left, give 'em the Faerie Queene */
        skip(1);
        game.icrystl = 0; /* crystals are lost */
        /* If at least one base left, give 'em the Faerie Queene */
        skip(1);
        game.icrystl = 0; /* crystals are lost */
@@ -175,7 +207,7 @@ void abandn(void)
     prout("still useable.");
     if (game.icrystl!=0) prout("The dilithium crystals have been moved.");
     game.imine=0;
     prout("still useable.");
     if (game.icrystl!=0) prout("The dilithium crystals have been moved.");
     game.imine=0;
-    game.iscraft=0; /* Gallileo disappears */
+    game.iscraft=0; /* Galileo disappears */
     /* Resupply ship */
     game.condit=IHDOCKED;
     for (l = 0; l < NDEVICES; l++) 
     /* Resupply ship */
     game.condit=IHDOCKED;
     for (l = 0; l < NDEVICES; l++) 
@@ -650,7 +682,7 @@ void newqad(int shutup)
     // Check for RNZ
     if (game.irhere > 0 && game.klhere == 0 && (here->planet == NOPLANET || game.state.plnets[here->planet].inhabited == UNINHABITED)) {
        game.neutz = 1;
     // Check for RNZ
     if (game.irhere > 0 && game.klhere == 0 && (here->planet == NOPLANET || game.state.plnets[here->planet].inhabited == UNINHABITED)) {
        game.neutz = 1;
-       if (game.damage[DRADIO] <= 0.0) {
+       if (!damaged(DRADIO)) {
            skip(1);
            prout("LT. Uhura- \"Captain, an urgent message.");
            prout("  I'll put it on audio.\"  CLICK");
            skip(1);
            prout("LT. Uhura- \"Captain, an urgent message.");
            prout("  I'll put it on audio.\"  CLICK");
@@ -671,7 +703,7 @@ void newqad(int shutup)
            game.kdist[game.nenhere] = game.kavgd[game.nenhere] =
                sqrt(square(game.sector.x-w.x) + square(game.sector.y-w.y));
            game.kpower[game.nenhere] = Rand()*6000.0 +500.0 +250.0*game.skill;
            game.kdist[game.nenhere] = game.kavgd[game.nenhere] =
                sqrt(square(game.sector.x-w.x) + square(game.sector.y-w.y));
            game.kpower[game.nenhere] = Rand()*6000.0 +500.0 +250.0*game.skill;
-           if (game.damage[DSRSENS] == 0.0) {
+           if (!damaged(DSRSENS)) {
                skip(1);
                prout("MR. SPOCK- \"Captain, this is most unusual.");
                prout("    Please examine your short-range scan.\"");
                skip(1);
                prout("MR. SPOCK- \"Captain, this is most unusual.");
                prout("    Please examine your short-range scan.\"");
index 81c1a411758f26d1f55d33248b641ac1d0f4b30f..d58fea381e2faa3141a64dfa612b76cd039dd3e6 100644 (file)
--- a/src/sst.h
+++ b/src/sst.h
@@ -146,6 +146,8 @@ typedef struct {
 #define DDSP    14  // Added deep space probe
 #define NDEVICES (15)  // Number of devices
 
 #define DDSP    14  // Added deep space probe
 #define NDEVICES (15)  // Number of devices
 
+#define damaged(dev)   game.damage[dev] != 0.0
+
 #define FOREVER        1e30
 
 /* Define future events */
 #define FOREVER        1e30
 
 /* Define future events */