From: Stas Sergeev Date: Thu, 8 May 2008 11:15:44 +0000 (+0000) Subject: Starchart and base-attack tweaks. X-Git-Tag: 2.0~46 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=c873e794bf5a029fef3a5ee5385cc0fec6220fa0;p=super-star-trek.git Starchart and base-attack tweaks. - Allow startchart updates by sr and lr scans. Otherwise if you kill the enemies in the quadrant and the radio is not working, the evemies are still on a chart, etc. - Fix bug that the message about base under attack sticks when the base is killed by supernova. --- diff --git a/src/ai.c b/src/ai.c index 67e748e..91e3ec9 100644 --- a/src/ai.c +++ b/src/ai.c @@ -82,7 +82,7 @@ force is -1000. Having shields down subtracts an additional 1000. 346*K + 400*R + 500*(C+S) - 400 for expert and emeritus. Attacker Initial energy levels (nominal): -Klingon Romulan Commander Super-Commander + Klingon Romulan Commander Super-Commander Novice 400 700 1200 Fair 425 750 1250 Good 450 800 1300 1750 diff --git a/src/events.c b/src/events.c index 37a02d1..3362fdd 100644 --- a/src/events.c +++ b/src/events.c @@ -62,10 +62,11 @@ void events(void) { int evcode, i=0, j, k, l; double fintim = game.state.date + game.optime, datemin, xtime, repair, yank=0; - bool radio_was_broken, ictbeam = false, istract = false; + bool ictbeam = false, istract = false; struct quadrant *pdest, *q; coord w, hold; event *ev, *ev2; + bool fixed_dev[NDEVICES]; if (idebug) { prout("=== EVENTS from %.2f to %.2f:", game.state.date, fintim); @@ -91,8 +92,6 @@ void events(void) } } - radio_was_broken = damaged(DRADIO); - hold.x = hold.y = 0; for (;;) { /* Select earliest extraneous event, evcode==0 if no events */ @@ -137,11 +136,18 @@ void events(void) if (game.condition == docked) repair /= game.docfac; /* Don't fix Deathray here */ - for (l=0; l 0.0 && l != DDRAY) - game.damage[l] -= (game.damage[l]-repair > 0.0 ? repair : game.damage[l]); + for (l=0; l 0.0 && l != DDRAY) { + double reminder = (game.damage[l] > repair ? + game.damage[l] - repair : .0); + game.damage[l] = reminder; + if (!(reminder > 0)) + fixed_dev[l] = true; + } + } /* If radio repaired, update star chart and attack reports */ - if (radio_was_broken && !damaged(DRADIO)) { + if (fixed_dev[DRADIO]) { prout(_("Lt. Uhura- \"Captain, the sub-space radio is working and")); prout(_(" surveillance reports are coming in.")); skip(1); @@ -149,10 +155,11 @@ void events(void) attackreport(false); game.iseenit = true; } - rechart(); prout(_(" The star chart is now up to date.\"")); skip(1); } + if (fixed_dev[DRADIO] || fixed_dev[DLRSENS] || fixed_dev[DSRSENS]) + rechart(); /* Cause extraneous event EVCODE to occur */ game.optime -= xtime; switch (evcode) { @@ -541,7 +548,7 @@ void events(void) } else { prout(_("Uhura- Starfleet reports increased Klingon activity")); if (q->planet != NOPLANET) - proutn(_("near %s"), systnames[q->planet]); + proutn(_("near %s "), systnames[q->planet]); prout(_("in %s.\n"), cramlc(quadrant, w)); } } @@ -895,7 +902,11 @@ void supernova(bool induced, coord *w) game.state.nscrem = game.state.kscmdr.x = game.state.kscmdr.y = game.isatb = 0; game.iscate = false; unschedule(FSCMOVE); + } + if (same(nq, game.battle)) { unschedule(FSCDBAS); + unschedule(FCDBAS); + invalidate(game.battle); } if (game.state.remcom) { int maxloop = game.state.remcom, l; diff --git a/src/moving.c b/src/moving.c index ac16dc2..0d41dd1 100644 --- a/src/moving.c +++ b/src/moving.c @@ -759,8 +759,7 @@ void atover(bool igrab) crmshp(); skip(1); prout(_("safely out of quadrant.")); - if (!damaged(DRADIO)) - game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true; + game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true; /* Try to use warp engines */ if (damaged(DWARPEN)) { skip(1); diff --git a/src/reports.c b/src/reports.c index b53d0b9..5d7c3b1 100644 --- a/src/reports.c +++ b/src/reports.c @@ -153,8 +153,7 @@ void lrscan(void) if (!VALID_QUADRANT(x, y)) proutn(" -1"); else { - if (!damaged(DRADIO)) - game.state.galaxy[x][y].charted = true; + 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.chart[x][y].stars = game.state.galaxy[x][y].stars; @@ -192,18 +191,57 @@ void damagereport(void) prout(_("All devices functional.")); } -void rechart(void) +static void rechart_quad(int x, int y) +{ + if (game.state.galaxy[x][y].charted) { + 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.chart[x][y].stars = game.state.galaxy[x][y].stars; + } +} + +static void rechart_dsradio(void) /* update the chart in the Enterprise's computer from galaxy data */ { int i, j; game.lastchart = game.state.date; for (i = 1; i <= GALSIZE; i++) for (j = 1; j <= GALSIZE; j++) - if (game.state.galaxy[i][j].charted) { - game.state.chart[i][j].klingons = game.state.galaxy[i][j].klingons; - game.state.chart[i][j].starbase = game.state.galaxy[i][j].starbase; - game.state.chart[i][j].stars = game.state.galaxy[i][j].stars; - } + rechart_quad(i, j); +} + +static void rechart_lr(void) +/* update the chart in the Enterprise's computer from galaxy data */ +{ + int i, j; + for (i = game.quadrant.x-1; i <= game.quadrant.x+1; i++) { + for (j = game.quadrant.y-1; j <= game.quadrant.y+1; j++) { + if (i == game.quadrant.x && j == game.quadrant.y) + continue; + rechart_quad(i, j); + } + } +} + +static void rechart_sr(void) +/* update the chart in the Enterprise's computer from galaxy data */ +{ + rechart_quad(game.quadrant.x, game.quadrant.y); +} + +void rechart(void) +{ + if (!damaged(DRADIO) || game.condition == docked) { + if (game.lastchart < game.state.date && game.condition == docked) + prout(_("Spock- \"I revised the Star Chart from the " + "starbase's records.\"")); + rechart_dsradio(); + } else { + if (!damaged(DLRSENS)) + rechart_lr(); + if (!damaged(DSRSENS)) + rechart_sr(); + } } void chart(void) @@ -212,13 +250,7 @@ void chart(void) int i,j; chew(); - if (!damaged(DRADIO)) - rechart(); - - if (game.lastchart < game.state.date && game.condition == docked) { - prout(_("Spock- \"I revised the Star Chart from the starbase's records.\"")); - rechart(); - } + rechart(); prout(_(" STAR CHART FOR THE KNOWN GALAXY")); if (game.state.date > game.lastchart) @@ -403,11 +435,9 @@ void srscan(void) } else prout(_(" Short-range scan")); - 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; + if (goodScan) { game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true; + rechart(); } prout(" 1 2 3 4 5 6 7 8 9 10"); if (game.condition != docked) diff --git a/src/sst.py b/src/sst.py index f6ea2b3..00f6df3 100644 --- a/src/sst.py +++ b/src/sst.py @@ -2326,7 +2326,7 @@ def events(): else: prout(_("Uhura- Starfleet reports increased Klingon activity")) if q.planet != None: - proutn(_("near %s") % q.planet) + proutn(_("near %s ") % q.planet) prout(_("in Quadrant %s.") % w) def wait():