From 2cae1cd3feb922843b40af851f43f9e08bb18f0d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 19 Sep 2006 18:13:35 +0000 Subject: [PATCH] Abstract out damage checks. 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 | 18 +++++++++--------- src/battle.c | 32 ++++++++++++++++---------------- src/events.c | 36 ++++++++++++++++++------------------ src/finish.c | 2 +- src/io.c | 2 +- src/moving.c | 22 +++++++++++----------- src/planets.c | 17 +++++++++-------- src/reports.c | 22 +++++++++++----------- src/setup.c | 42 +++++++++++++++++++++++++++++++++++++----- src/sst.h | 2 ++ 10 files changed, 115 insertions(+), 80 deletions(-) diff --git a/src/ai.c b/src/ai.c index 734a5b5..4b73b74 100644 --- 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 */ - 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)."), @@ -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 && - (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; } @@ -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! */ - 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); - if (game.damage[DPHOTON] != 0) /* photon torpedoes damaged */ + if (damaged(DPHOTON)) /* photon torpedoes damaged */ 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)); - if (game.damage[DSRSENS] == 0 || game.condit == IHDOCKED) { + if (!damaged(DSRSENS) || game.condit == IHDOCKED) { 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; - 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")); @@ -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); - 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); @@ -517,7 +517,7 @@ void scom(bool *ipage) 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); diff --git a/src/battle.c b/src/battle.c index 22cc136..eb6fbe6 100644 --- a/src/battle.c +++ b/src/battle.c @@ -15,7 +15,7 @@ void doshield(int i) action = NRG; else { chew(); - if (game.damage[DSHIELD]) { + if (!damaged(DSHIELD)) { prout(_("Shields damaged and down.")); return; } @@ -31,7 +31,7 @@ void doshield(int i) proutn(_("Energy to transfer to shields- ")); action = NRG; } - else if (game.damage[DSHIELD]) { + else if (damaged(DSHIELD)) { 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 (game.damage[DSRSENS]==0 || game.condit==IHDOCKED) + if (!damaged(DSRSENS) || game.condit==IHDOCKED) setwnd(srscan_window); else setwnd(message_window); @@ -466,7 +466,7 @@ static void fry(double hit) proutn(device[j]); } prout(_(" damaged.")); - if (game.damage[DSHIELD] && game.shldup) { + if (damaged(DSHIELD) && game.shldup) { 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")); - if (game.damage[DSRSENS] <= 0.0) { + if (!damaged(DSRSENS)) { 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); - if ((game.damage[DSRSENS] > 0 && itflag) || game.skill<=SKILL_FAIR) { + if ((damaged(DSRSENS) && itflag) || game.skill<=SKILL_FAIR) { proutn(_(" on the ")); crmshp(); } - if (game.damage[DSRSENS] <= 0.0 && itflag) { + if (!damaged(DSRSENS) && itflag) { 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 ")); - 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); @@ -726,7 +726,7 @@ void photon(void) game.ididit = 0; - if (game.damage[DPHOTON]) { + if (damaged(DPHOTON)) { prout(_("Photon tubes damaged.")); chew(); return; @@ -911,19 +911,19 @@ void phasers(void) 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.damage[DPHASER] != 0) { + if (damaged(DPHASER)) { prout(_("Phaser control damaged.")); chew(); return; } if (game.shldup) { - if (game.damage[DSHCTRL]) { + if (damaged(DSHCTRL)) { prout(_("High speed shield control damaged.")); chew(); return; @@ -1073,7 +1073,7 @@ void phasers(void) case FORCEMAN: chew(); key = IHEOL; - if (game.damage[DCOMPTR]!=0) + if (damaged(DCOMPTR)) prout(_("Battle comuter damaged, manual file only.")); else { skip(1); @@ -1096,7 +1096,7 @@ void phasers(void) 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.")); @@ -1113,7 +1113,7 @@ void phasers(void) (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 ")); @@ -1211,7 +1211,7 @@ void hittem(double *hits) 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); } diff --git a/src/events.c b/src/events.c index 7fdf271..079fea4 100644 --- a/src/events.c +++ b/src/events.c @@ -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 */ @@ -113,7 +113,7 @@ void events(void) 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; @@ -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 (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); @@ -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.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); @@ -227,7 +227,7 @@ void events(void) 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; } @@ -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; - 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); @@ -325,7 +325,7 @@ void events(void) 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; @@ -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 (game.damage[DRADIO]==0.0 || game.condit == IHDOCKED) { + if (!damaged(DRADIO) || game.condit == IHDOCKED) { if (ipage==0) pause_game(1); ipage = 1; skip(1); @@ -386,7 +386,7 @@ void events(void) 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); @@ -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. */ - 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; @@ -442,7 +442,7 @@ void events(void) 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)); @@ -466,7 +466,7 @@ void events(void) 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)); @@ -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 */ - 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"); @@ -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 (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."), @@ -919,7 +919,7 @@ void snova(int insx, int insy) 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)) { diff --git a/src/finish.c b/src/finish.c index 54b5bea..78680d8 100644 --- a/src/finish.c +++ b/src/finish.c @@ -6,7 +6,7 @@ void dstrct() { /* Finish with a BANG! */ chew(); - if (game.damage[DCOMPTR] != 0.0) { + if (damaged(DCOMPTR)) { prout(_("Computer damaged; cannot execute destruct sequence.")); return; } diff --git a/src/io.c b/src/io.c index dc4ce74..ecbe87a 100644 --- 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 { - if (game.damage[DSRSENS]==0 || game.condit==IHDOCKED) { + if (!damaged(DSRSENS) || game.condit==IHDOCKED) { if (i != 1 && l == 1) { drawmaps(2); delay(400); diff --git a/src/moving.c b/src/moving.c index e966bed..b273c60 100644 --- a/src/moving.c +++ b/src/moving.c @@ -237,7 +237,7 @@ void dock(int l) 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:\""); @@ -276,7 +276,7 @@ static void getcd(bool isprobe, int akey) { return; } while (automatic == -1) { - if (game.damage[DCOMPTR]) { + if (damaged(DCOMPTR)) { if (isprobe) prout("Computer damaged; manual navigation only"); else @@ -438,7 +438,7 @@ void impuls(void) double power; game.ididit = 0; - if (game.damage[DIMPULS]) { + if (damaged(DIMPULS)) { 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; } - 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"); @@ -641,7 +641,7 @@ void setwrp(void) 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; @@ -681,7 +681,7 @@ void atover(int igrab) chew(); /* is captain on planet? */ if (game.landed==1) { - if (game.damage[DTRANSP]) { + if (damaged(DTRANSP)) { finish(FPNOVA); return; } @@ -731,10 +731,10 @@ void atover(int igrab) 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 */ - if (game.damage[DWARPEN]) { + if (damaged(DWARPEN)) { 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; } - if (game.damage[DDSP] != 0.0) { + if (damaged(DDSP)) { 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 (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.\""); } @@ -911,7 +911,7 @@ void mayday(void) prout("Lt. Uhura- \"But Captain, we're already docked.\""); return; } - if (game.damage[DRADIO] != 0) { + if (damaged(DRADIO)) { prout("Subspace radio damaged."); return; } diff --git a/src/planets.c b/src/planets.c index 25a4dfc..8471848 100644 --- a/src/planets.c +++ b/src/planets.c @@ -62,7 +62,7 @@ void orbit(void) 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; } @@ -86,7 +86,7 @@ void sensor(void) { skip(1); chew(); - if (game.damage[DSRSENS] != 0.0) { + if (damaged(DSRSENS)) { prout("Short range sensors damaged."); return; } @@ -113,9 +113,9 @@ void beam(void) { chew(); skip(1); - if (game.damage[DTRANSP] != 0) { + if (damaged(DTRANSP)) { 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(); @@ -287,7 +287,7 @@ void shuttle(void) { 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."); @@ -296,7 +296,8 @@ void shuttle(void) } 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) { @@ -338,7 +339,7 @@ void shuttle(void) /* 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(); @@ -412,7 +413,7 @@ void deathray(void) 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; } diff --git a/src/reports.c b/src/reports.c index e1b6cc7..b2ee2b7 100644 --- a/src/reports.c +++ b/src/reports.c @@ -69,7 +69,7 @@ void report(void) 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); @@ -87,7 +87,7 @@ void report(void) 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"); @@ -117,7 +117,7 @@ void lrscan(void) { 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."); @@ -134,7 +134,7 @@ void lrscan(void) 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; @@ -156,7 +156,7 @@ void dreprt(void) 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"); @@ -190,7 +190,7 @@ void chart(int nn) int i,j; chew(); - if (game.damage[DRADIO] == 0.0) + if (!damaged(DRADIO)) 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 "); - if (game.damage[DLIFSUP] != 0.0) { + if (damaged(DLIFSUP)) { if (game.condit == IHDOCKED) proutn("DAMAGED, Base provides"); else @@ -302,7 +302,7 @@ static void status(int req) break; case 8: proutn("Shields "); - if (game.damage[DSHIELD] != 0) + if (damaged(DSHIELD)) 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 - if (game.damage[DSRSENS] != 0) { + if (damaged(DSRSENS)) { /* 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"); - 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; @@ -410,7 +410,7 @@ void eta(void) 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; diff --git a/src/setup.c b/src/setup.c index 77f58bd..03d9e79 100644 --- a/src/setup.c +++ b/src/setup.c @@ -92,9 +92,31 @@ int thaw(void) 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; + struct quadrant *q; 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."); - 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; } + 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 */ @@ -175,7 +207,7 @@ void abandn(void) 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++) @@ -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; - 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"); @@ -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; - 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.\""); diff --git a/src/sst.h b/src/sst.h index 81c1a41..d58fea3 100644 --- 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 damaged(dev) game.damage[dev] != 0.0 + #define FOREVER 1e30 /* Define future events */ -- 2.31.1