6 void attackreport(bool curt)
7 /* report status of bases under attack */
10 if (is_scheduled(FCDBAS)) {
11 prout(_("Starbase in %s is currently under Commander attack."),
12 cramlc(quadrant, game.battle));
13 prout(_("It can hold out until Stardate %d."),
14 (int)scheduled(FCDBAS));
16 else if (game.isatb == 1) {
17 prout(_("Starbase in %s is under Super-commander attack."),
18 cramlc(quadrant, game.state.kscmdr));
19 prout(_("It can hold out until Stardate %d."),
20 (int)scheduled(FSCDBAS));
22 prout(_("No Starbase is currently under attack."));
25 if (is_scheduled(FCDBAS))
26 proutn(_("Base in %i - %i attacked by C. Alive until %.1f"), game.battle.x, game.battle.y, scheduled(FCDBAS));
28 proutn(_("Base in %i - %i attacked by S. Alive until %.1f"), game.state.kscmdr.x, game.state.kscmdr.y, scheduled(FSCDBAS));
35 /* report on general game status */
40 s1 = (game.thawed?_("thawed "):"");
41 switch (game.length) {
42 case 1: s2=_("short"); break;
43 case 2: s2=_("medium"); break;
44 case 4: s2=_("long"); break;
45 default: s2=_("unknown length"); break;
48 case SKILL_NOVICE: s3=_("novice"); break;
49 case SKILL_FAIR: s3=_("fair"); break;
50 case SKILL_GOOD: s3=_("good"); break;
51 case SKILL_EXPERT: s3=_("expert"); break;
52 case SKILL_EMERITUS: s3=_("emeritus"); break;
53 default: s3=_("skilled"); break;
56 prout(_("You %s a %s%s %s game."),
57 game.alldone? _("were playing") : _("are playing"), s1, s2, s3);
58 if (game.skill>SKILL_GOOD && game.thawed && !game.alldone)
59 prout(_("No plaque is allowed."));
61 prout(_("This is tournament game %d."), game.tourn);
62 prout(_("Your secret password is \"%s\""),game.passwd);
63 proutn(_("%d of %d Klingons have been killed"),
64 ((game.inkling + game.incom + game.inscom) - (game.state.remkl + game.state.remcom + game.state.nscrem)),
65 (game.inkling + game.incom + game.inscom));
66 if (game.incom - game.state.remcom)
67 prout(_(", including %d Commander%s."), game.incom - game.state.remcom, (game.incom - game.state.remcom)==1?"":_("s"));
68 else if (game.inkling - game.state.remkl + (game.inscom - game.state.nscrem) > 0)
69 prout(_(", but no Commanders."));
72 if (game.skill > SKILL_FAIR)
73 prout(_("The Super Commander has %sbeen destroyed."),
74 game.state.nscrem?_("not "):"");
75 if (game.state.rembase != game.inbase) {
77 if (game.inbase-game.state.rembase==1)
78 proutn(_("has been 1 base"));
80 proutn(_("have been %d bases"), game.inbase-game.state.rembase);
82 prout(_(" destroyed, %d remaining."), game.state.rembase);
85 prout(_("There are %d bases."), game.inbase);
86 if (!damaged(DRADIO) || game.condition == docked || game.iseenit) {
87 // Don't report this if not seen and
88 // either the radio is dead or not at base!
93 prout(_("%d casualt%s suffered so far."),
94 game.casual, game.casual==1? "y" : "ies");
96 prout(_("There were %d call%s for help."),
97 game.nhelp, game.nhelp==1 ? "" : _("s"));
98 if (game.ship == IHE) {
99 proutn(_("You have "));
101 proutn("%d", game.nprobes);
104 proutn(_(" deep space probe"));
109 if ((!damaged(DRADIO) || game.condition == docked)
110 && is_scheduled(FDSPROB)) {
112 proutn(_("An armed deep space probe is in "));
114 proutn(_("A deep space probe is in "));
115 proutn(cramlc(quadrant, game.probec));
119 if (game.cryprob <= .05)
120 prout(_("Dilithium crystals aboard ship... not yet used."));
124 while (game.cryprob > ai) {
128 prout(_("Dilithium crystals have been used %d time%s."),
129 i, i==1? "" : _("s"));
136 /* long-range sensor scan */
139 if (damaged(DLRSENS)) {
140 /* Now allow base's sensors if docked */
141 if (game.condition != docked) {
142 prout(_("LONG-RANGE SENSORS DAMAGED."));
145 prout(_("Starbase's long-range scan"));
148 prout(_("Long-range scan"));
150 for (x = game.quadrant.x-1; x <= game.quadrant.x+1; x++) {
152 for (y = game.quadrant.y-1; y <= game.quadrant.y+1; y++) {
153 if (!VALID_QUADRANT(x, y))
156 game.state.galaxy[x][y].charted = true;
157 game.state.chart[x][y].klingons = game.state.galaxy[x][y].klingons;
158 game.state.chart[x][y].starbase = game.state.galaxy[x][y].starbase;
159 game.state.chart[x][y].stars = game.state.galaxy[x][y].stars;
160 if (game.state.galaxy[x][y].supernova)
163 proutn(" %3d", game.state.chart[x][y].klingons*100 + game.state.chart[x][y].starbase * 10 + game.state.chart[x][y].stars);
170 void damagereport(void)
177 for (i = 0; i < NDEVICES; i++) {
180 prout(_("\tDEVICE\t\t\t-REPAIR TIMES-"));
181 prout(_("\t\t\tIN FLIGHT\t\tDOCKED"));
184 prout(" %-26s\t%8.2f\t\t%8.2f",
187 game.docfac*game.damage[i]+0.005);
191 prout(_("All devices functional."));
194 static void rechart_quad(int x, int y)
196 if (game.state.galaxy[x][y].charted) {
197 game.state.chart[x][y].klingons = game.state.galaxy[x][y].klingons;
198 game.state.chart[x][y].starbase = game.state.galaxy[x][y].starbase;
199 game.state.chart[x][y].stars = game.state.galaxy[x][y].stars;
203 static void rechart_dsradio(void)
204 /* update the chart in the Enterprise's computer from galaxy data */
207 game.lastchart = game.state.date;
208 for (i = 1; i <= GALSIZE; i++)
209 for (j = 1; j <= GALSIZE; j++)
213 static void rechart_lr(void)
214 /* update the chart in the Enterprise's computer from galaxy data */
217 for (i = game.quadrant.x-1; i <= game.quadrant.x+1; i++) {
218 for (j = game.quadrant.y-1; j <= game.quadrant.y+1; j++) {
219 if (i == game.quadrant.x && j == game.quadrant.y)
226 static void rechart_sr(void)
227 /* update the chart in the Enterprise's computer from galaxy data */
229 rechart_quad(game.quadrant.x, game.quadrant.y);
234 if (!damaged(DRADIO) || game.condition == docked) {
235 if (game.lastchart < game.state.date && game.condition == docked)
236 prout(_("Spock- \"I revised the Star Chart from the "
237 "starbase's records.\""));
240 if (!damaged(DLRSENS))
242 if (!damaged(DSRSENS))
248 /* display the star chart */
255 prout(_(" STAR CHART FOR THE KNOWN GALAXY"));
256 if (game.state.date > game.lastchart)
257 prout(_("(Last surveillance update %d stardates ago)."),
258 (int)(game.state.date-game.lastchart));
259 prout(" 1 2 3 4 5 6 7 8");
260 for (i = 1; i <= GALSIZE; i++) {
262 for (j = 1; j <= GALSIZE; j++) {
264 if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
268 if (game.state.galaxy[i][j].supernova)
270 else if (!game.state.galaxy[i][j].charted && game.state.galaxy[i][j].starbase)
272 else if (game.state.galaxy[i][j].charted)
273 sprintf(buf, "%3d", game.state.chart[i][j].klingons*100 + game.state.chart[i][j].starbase * 10 + game.state.chart[i][j].stars);
277 if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
288 static void sectscan(int goodScan, int i, int j)
289 /* light up an individual dot in a sector */
291 if (goodScan || (abs(i-game.sector.x)<= 1 && abs(j-game.sector.y) <= 1)){
292 if ((game.quad[i][j]==IHMATER0)||(game.quad[i][j]==IHMATER1)||(game.quad[i][j]==IHMATER2)||(game.quad[i][j]==IHE)||(game.quad[i][j]==IHF)){
293 switch (game.condition) {
294 case red: textcolor(RED); break;
295 case green: textcolor(GREEN); break;
296 case yellow: textcolor(YELLOW); break;
297 case docked: textcolor(CYAN); break;
298 case dead: textcolor(BROWN);
300 if (game.quad[i][j] != game.ship)
303 proutn("%c ",game.quad[i][j]);
311 /* print status report lines */
313 #define RQ(n, a) if (!req || req == n) do { a } while(0)
314 char *cp = NULL, s[256];
318 prstat(_("Stardate"), _("%.1f, Time Left %.2f"), game.state.date, game.state.remtime);
322 if (game.condition != docked)
324 switch (game.condition) {
325 case red: cp = _("RED"); break;
326 case green: cp = _("GREEN"); break;
327 case yellow: cp = _("YELLOW"); break;
328 case docked: cp = _("DOCKED"); break;
329 case dead: cp = _("DEAD"); break;
331 for (t=0;t<NDEVICES;t++)
332 if (game.damage[t]>0)
334 prstat(_("Condition"), _("%s, %i DAMAGES"), cp, dam);
338 prstat(_("Position"), "%d - %d , %d - %d",
339 game.quadrant.x, game.quadrant.y, game.sector.x, game.sector.y);
343 if (damaged(DLIFSUP)) {
344 if (game.condition == docked)
345 sprintf(s, _("DAMAGED, Base provides"));
347 sprintf(s, _("DAMAGED, reserves=%4.2f"), game.lsupres);
350 sprintf(s, _("ACTIVE"));
351 prstat(_("Life Support"), s);
355 prstat(_("Warp Factor"), "%.1f", game.warpfac);
359 prstat(_("Energy"), "%.2f%s", game.energy,
360 (game.icrystl && (game.options & OPTION_SHOWME)) ? /* ESR */
361 _(" (have crystals)") : "");
365 prstat(_("Torpedoes"), "%d", game.torps);
369 if (damaged(DSHIELD))
370 strcpy(s, _("DAMAGED,"));
371 else if (game.shldup)
374 strcpy(s, _("DOWN,"));
375 sprintf(s + strlen(s), _(" %d%% %.1f units"),
376 (int)((100.0*game.shield)/game.inshld + 0.5), game.shield);
377 prstat(_("Shields"), s);
381 prstat(_("Klingons Left"), "%d", game.state.remkl + game.state.remcom + game.state.nscrem);
385 if (game.options & OPTION_WORLDS) {
386 int plnet = game.state.galaxy[game.quadrant.x][game.quadrant.y].planet;
387 if (plnet != NOPLANET && game.state.planets[plnet].inhabited != UNINHABITED)
388 prstat(_("Major system"), "%s", systnames[plnet]);
390 prout(_("Sector is uninhabited"));
404 static char requests[][3] =
405 {"da","co","po","ls","wa","en","to","sh","kl","sy", "ti"};
407 while (scan() == IHEOL)
408 proutn(_("Information desired? "));
410 for (req = 0; req < ARRAY_SIZE(requests); req++)
411 if (strncmp(citem, requests[req], min(2,strlen(citem)))==0)
413 if (req >= ARRAY_SIZE(requests)) {
414 prout(_("UNRECOGNIZED REQUEST. Legal requests are:"));
415 prout((" date, condition, position, lsupport, warpfactor,"));
416 prout((" energy, torpedoes, shields, klingons, system, time."));
423 /* short-range scan */
427 if (damaged(DSRSENS)) {
428 /* Allow base's sensors if docked */
429 if (game.condition != docked) {
430 prout(_(" S.R. SENSORS DAMAGED!"));
434 prout(_(" [Using Base's sensors]"));
437 prout(_(" Short-range scan"));
439 game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true;
442 prout(" 1 2 3 4 5 6 7 8 9 10");
443 if (game.condition != docked)
445 for (i = 1; i <= QUADSIZE; i++) {
447 for (j = 1; j <= QUADSIZE; j++) {
448 sectscan(goodScan, i, j);
456 /* use computer to get estimated time of arrival for a warp jump */
459 bool wfl, prompt = false;
460 double ttime, twarp, tpower;
461 if (damaged(DCOMPTR)) {
462 prout(_("COMPUTER DAMAGED, USE A POCKET CALCULATOR."));
466 if (scan() != IHREAL) {
469 proutn(_("Destination quadrant and/or sector? "));
470 if (scan()!=IHREAL) {
476 if (scan() != IHREAL) {
481 if (scan() == IHREAL) {
483 if (scan() != IHREAL) {
490 if (game.quadrant.y>w1.x)
494 if (game.quadrant.x>w1.y)
500 if (!VALID_QUADRANT(w1.x, w1.y) || !VALID_SECTOR(w2.x, w2.y)) {
504 game.dist = sqrt(square(w1.y-game.quadrant.y+0.1*(w2.y-game.sector.y))+
505 square(w1.x-game.quadrant.x+0.1*(w2.x-game.sector.x)));
509 prout(_("Answer \"no\" if you don't know the value:"));
512 proutn(_("Time or arrival date? "));
513 if (scan()==IHREAL) {
515 if (ttime > game.state.date)
516 ttime -= game.state.date; // Actually a star date
517 if (ttime <= 1e-10 ||
518 (twarp=(floor(sqrt((10.0*game.dist)/ttime)*10.0)+1.0)/10.0) > 10) {
519 prout(_("We'll never make it, sir."));
528 proutn(_("Warp factor? "));
529 if (scan()== IHREAL) {
532 if (twarp<1.0 || twarp > 10.0) {
538 prout(_("Captain, certainly you can give me one of these."));
542 ttime = (10.0*game.dist)/square(twarp);
543 tpower = game.dist*twarp*twarp*twarp*(game.shldup+1);
544 if (tpower >= game.energy) {
545 prout(_("Insufficient energy, sir."));
546 if (!game.shldup || tpower > game.energy*2.0) {
549 proutn(_("New warp factor to try? "));
550 if (scan() == IHREAL) {
553 if (twarp<1.0 || twarp > 10.0) {
565 prout(_("But if you lower your shields,"));
566 proutn(_("remaining"));
570 proutn(_("Remaining"));
571 prout(_(" energy will be %.2f."), game.energy-tpower);
573 prout(_("And we will arrive at stardate %.2f."),
574 game.state.date+ttime);
577 prout(_("Any warp speed is adequate."));
579 prout(_("Minimum warp needed is %.2f,"), twarp);
580 prout(_("and we will arrive at stardate %.2f."),
581 game.state.date+ttime);
583 if (game.state.remtime < ttime)
584 prout(_("Unfortunately, the Federation will be destroyed by then."));
586 prout(_("You'll be taking risks at that speed, Captain"));
587 if ((game.isatb==1 && same(game.state.kscmdr, w1) &&
588 scheduled(FSCDBAS)< ttime+game.state.date)||
589 (scheduled(FCDBAS)<ttime+game.state.date && same(game.battle, w1)))
590 prout(_("The starbase there will be destroyed by then."));
591 proutn(_("New warp factor to try? "));
592 if (scan() == IHREAL) {
595 if (twarp<1.0 || twarp > 10.0) {
609 #ifdef BSD_BUG_FOR_BUG
611 * A visual scan is made in a particular direction of three sectors
612 * in the general direction specified. This takes time, and
613 * Klingons can attack you, so it should be done only when sensors
614 * are out. Code swiped from BSD-Trek. Not presently used, as we
615 * automatically display all adjacent sectors on the short-range
616 * scan even when short-range sensors are out.
619 /* This struct[] has the delta x, delta y for particular directions */
640 if (scan() != IHREAL) {
642 proutn(_("Direction? "));
643 if (scan()!=IHREAL) {
648 if (aaitem < 0.0 || aaitem > 360.0)
650 co = (aaitem + 22) / 45;
652 ix = game.sector.x + v->x;
653 iy = game.sector.y + v->y;
654 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
657 co = game.quad[ix][iy];
658 printf("%d,%d %c ", ix, iy, co);
660 ix = game.sector.x + v->x;
661 iy = game.sector.y + v->y;
662 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
665 co = game.quad[ix][iy];
668 ix = game.sector.x + v->x;
669 iy = game.sector.y + v->y;
670 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
673 co = game.quad[ix][iy];
674 printf("%c %d,%d\n", co, ix, iy);