Starchart and base-attack tweaks.
authorStas Sergeev <stsp@aknet.ru>
Thu, 8 May 2008 11:15:44 +0000 (11:15 +0000)
committerStas Sergeev <stsp@aknet.ru>
Thu, 8 May 2008 11:15:44 +0000 (11:15 +0000)
- 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.

src/ai.c
src/events.c
src/moving.c
src/reports.c
src/sst.py

index 67e748eeeaa2590991fad3c183f37e06b93aa7c9..91e3ec9f91c8cce5616e97715fd95a3199d88217 100644 (file)
--- 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):
 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
 Novice    400        700        1200        
 Fair      425        750        1250
 Good      450        800        1300        1750
index 37a02d1bc92c93d81fc432fdd8a181e85fc26b32..3362fddf818368d526d4ceb6372207c797ac8502 100644 (file)
@@ -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;
 {
     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;
     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);
 
     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 */
     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 */
        if (game.condition == docked)
            repair /= game.docfac;
        /* Don't fix Deathray here */
-       for (l=0; l<NDEVICES; l++)
-           if (game.damage[l] > 0.0 && l != DDRAY)
-               game.damage[l] -= (game.damage[l]-repair > 0.0 ? repair : game.damage[l]);
+       for (l=0; l<NDEVICES; l++) {
+           fixed_dev[l] = false;
+           if (game.damage[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 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);
            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;
            }
                attackreport(false);
                game.iseenit = true;
            }
-           rechart();
            prout(_("   The star chart is now up to date.\""));
            skip(1);
        }
            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) {
        /* 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)
                } 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));
                }
            }
                    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);
        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(FSCDBAS);
+       unschedule(FCDBAS);
+       invalidate(game.battle);
     }
     if (game.state.remcom) {
        int maxloop = game.state.remcom, l;
     }
     if (game.state.remcom) {
        int maxloop = game.state.remcom, l;
index ac16dc2f31aa72fa6eb0167c6242b9e64668139e..0d41dd18f10950eac57bfe95845f30a2ffe0de2f 100644 (file)
@@ -759,8 +759,7 @@ void atover(bool igrab)
        crmshp();
        skip(1);
        prout(_("safely out of quadrant."));
        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);
        /* Try to use warp engines */
        if (damaged(DWARPEN)) {
            skip(1);
index b53d0b9f0f66452a3751aef8a3d20625f7bfbe09..5d7c3b1750de58edebfa98a1e2fae93ba2997502 100644 (file)
@@ -153,8 +153,7 @@ void lrscan(void)
            if (!VALID_QUADRANT(x, y))
                proutn("  -1");
            else {
            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;
                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."));
 }
 
        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++)
 /* 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)
 }
 
 void chart(void)
@@ -212,13 +250,7 @@ void chart(void)
     int i,j;
     chew();
 
     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)
 
     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"));
     }
     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;
        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)
     }
     prout("    1 2 3 4 5 6 7 8 9 10");
     if (game.condition != docked)
index f6ea2b3cc74def8b17eaad490e7303650f879257..00f6df3dfa65ec08b449a6fa8c933283ebca08ca 100644 (file)
@@ -2326,7 +2326,7 @@ def events():
                else:
                    prout(_("Uhura- Starfleet reports increased Klingon activity"))
                    if q.planet != None:
                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():
                    prout(_("in Quadrant %s.") % w)
                                
 def wait():