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;
158 if (game.state.galaxy[x][y].supernova)
161 proutn(" %3d", game.state.chart[x][y].klingons*100 + game.state.chart[x][y].starbase * 10 + game.state.chart[x][y].stars);
168 void damagereport(void)
175 for (i = 0; i < NDEVICES; i++) {
178 prout(_("\tDEVICE\t\t\t-REPAIR TIMES-"));
179 prout(_("\t\t\tIN FLIGHT\t\tDOCKED"));
182 prout(" %-26s\t%8.2f\t\t%8.2f",
185 game.docfac*game.damage[i]+0.005);
189 prout(_("All devices functional."));
192 static void rechart_quad(int x, int y)
194 if (game.state.galaxy[x][y].charted) {
195 game.state.chart[x][y].klingons = game.state.galaxy[x][y].klingons;
196 game.state.chart[x][y].starbase = game.state.galaxy[x][y].starbase;
197 game.state.chart[x][y].stars = game.state.galaxy[x][y].stars;
201 static void rechart_dsradio(void)
202 /* update the chart in the Enterprise's computer from galaxy data */
205 game.lastchart = game.state.date;
206 for (i = 1; i <= GALSIZE; i++)
207 for (j = 1; j <= GALSIZE; j++)
211 static void rechart_lr(void)
212 /* update the chart in the Enterprise's computer from galaxy data */
215 for (i = game.quadrant.x-1; i <= game.quadrant.x+1; i++) {
216 for (j = game.quadrant.y-1; j <= game.quadrant.y+1; j++) {
217 if (i == game.quadrant.x && j == game.quadrant.y)
224 static void rechart_sr(void)
225 /* update the chart in the Enterprise's computer from galaxy data */
227 rechart_quad(game.quadrant.x, game.quadrant.y);
232 if (!damaged(DRADIO) || game.condition == docked) {
233 if (game.lastchart < game.state.date && game.condition == docked)
234 prout(_("Spock- \"I revised the Star Chart from the "
235 "starbase's records.\""));
238 if (!damaged(DLRSENS))
240 if (!damaged(DSRSENS))
246 /* display the star chart */
253 prout(_(" STAR CHART FOR THE KNOWN GALAXY"));
254 if (game.state.date > game.lastchart)
255 prout(_("(Last surveillance update %d stardates ago)."),
256 (int)(game.state.date-game.lastchart));
257 prout(" 1 2 3 4 5 6 7 8");
258 for (i = 1; i <= GALSIZE; i++) {
260 for (j = 1; j <= GALSIZE; j++) {
262 if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
266 if (game.state.galaxy[i][j].supernova)
268 else if (!game.state.galaxy[i][j].charted && game.state.galaxy[i][j].starbase)
270 else if (game.state.galaxy[i][j].charted)
271 sprintf(buf, "%3d", game.state.chart[i][j].klingons*100 + game.state.chart[i][j].starbase * 10 + game.state.chart[i][j].stars);
275 if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
286 static void sectscan(int goodScan, int i, int j)
287 /* light up an individual dot in a sector */
289 if (goodScan || (abs(i-game.sector.x)<= 1 && abs(j-game.sector.y) <= 1)){
290 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)){
291 switch (game.condition) {
292 case red: textcolor(RED); break;
293 case green: textcolor(GREEN); break;
294 case yellow: textcolor(YELLOW); break;
295 case docked: textcolor(CYAN); break;
296 case dead: textcolor(BROWN);
298 if (game.quad[i][j] != game.ship)
301 proutn("%c ",game.quad[i][j]);
309 /* print status report lines */
311 #define RQ(n, a) if (!req || req == n) do { a } while(0)
312 char *cp = NULL, s[256];
316 prstat(_("Stardate"), _("%.1f, Time Left %.2f"), game.state.date, game.state.remtime);
320 if (game.condition != docked)
322 switch (game.condition) {
323 case red: cp = _("RED"); break;
324 case green: cp = _("GREEN"); break;
325 case yellow: cp = _("YELLOW"); break;
326 case docked: cp = _("DOCKED"); break;
327 case dead: cp = _("DEAD"); break;
329 for (t=0;t<NDEVICES;t++)
330 if (game.damage[t]>0)
332 prstat(_("Condition"), _("%s, %i DAMAGES"), cp, dam);
336 prstat(_("Position"), "%d - %d , %d - %d",
337 game.quadrant.x, game.quadrant.y, game.sector.x, game.sector.y);
341 if (damaged(DLIFSUP)) {
342 if (game.condition == docked)
343 sprintf(s, _("DAMAGED, Base provides"));
345 sprintf(s, _("DAMAGED, reserves=%4.2f"), game.lsupres);
348 sprintf(s, _("ACTIVE"));
349 prstat(_("Life Support"), s);
353 prstat(_("Warp Factor"), "%.1f", game.warpfac);
357 prstat(_("Energy"), "%.2f%s", game.energy,
358 (game.icrystl && (game.options & OPTION_SHOWME)) ? /* ESR */
359 _(" (have crystals)") : "");
363 prstat(_("Torpedoes"), "%d", game.torps);
367 if (damaged(DSHIELD))
368 strcpy(s, _("DAMAGED,"));
369 else if (game.shldup)
372 strcpy(s, _("DOWN,"));
373 sprintf(s + strlen(s), _(" %d%% %.1f units"),
374 (int)((100.0*game.shield)/game.inshld + 0.5), game.shield);
375 prstat(_("Shields"), s);
379 prstat(_("Klingons Left"), "%d", game.state.remkl + game.state.remcom + game.state.nscrem);
383 if (game.options & OPTION_WORLDS) {
384 int plnet = game.state.galaxy[game.quadrant.x][game.quadrant.y].planet;
385 if (plnet != NOPLANET && game.state.planets[plnet].inhabited != UNINHABITED)
386 prstat(_("Major system"), "%s", systnames[plnet]);
388 prout(_("Sector is uninhabited"));
402 static char requests[][3] =
403 {"da","co","po","ls","wa","en","to","sh","kl","sy", "ti"};
405 while (scan() == IHEOL)
406 proutn(_("Information desired? "));
408 for (req = 0; req < ARRAY_SIZE(requests); req++)
409 if (strncmp(citem, requests[req], min(2,strlen(citem)))==0)
411 if (req >= ARRAY_SIZE(requests)) {
412 prout(_("UNRECOGNIZED REQUEST. Legal requests are:"));
413 prout((" date, condition, position, lsupport, warpfactor,"));
414 prout((" energy, torpedoes, shields, klingons, system, time."));
421 /* short-range scan */
425 if (damaged(DSRSENS)) {
426 /* Allow base's sensors if docked */
427 if (game.condition != docked) {
428 prout(_(" S.R. SENSORS DAMAGED!"));
432 prout(_(" [Using Base's sensors]"));
435 prout(_(" Short-range scan"));
437 game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true;
440 prout(" 1 2 3 4 5 6 7 8 9 10");
441 if (game.condition != docked)
443 for (i = 1; i <= QUADSIZE; i++) {
445 for (j = 1; j <= QUADSIZE; j++) {
446 sectscan(goodScan, i, j);
454 /* use computer to get estimated time of arrival for a warp jump */
457 bool wfl, prompt = false;
458 double ttime, twarp, tpower;
459 if (damaged(DCOMPTR)) {
460 prout(_("COMPUTER DAMAGED, USE A POCKET CALCULATOR."));
464 if (scan() != IHREAL) {
467 proutn(_("Destination quadrant and/or sector? "));
468 if (scan()!=IHREAL) {
474 if (scan() != IHREAL) {
479 if (scan() == IHREAL) {
481 if (scan() != IHREAL) {
488 if (game.quadrant.y>w1.x)
492 if (game.quadrant.x>w1.y)
498 if (!VALID_QUADRANT(w1.x, w1.y) || !VALID_SECTOR(w2.x, w2.y)) {
502 game.dist = sqrt(square(w1.y-game.quadrant.y+0.1*(w2.y-game.sector.y))+
503 square(w1.x-game.quadrant.x+0.1*(w2.x-game.sector.x)));
507 prout(_("Answer \"no\" if you don't know the value:"));
510 proutn(_("Time or arrival date? "));
511 if (scan()==IHREAL) {
513 if (ttime > game.state.date)
514 ttime -= game.state.date; // Actually a star date
515 if (ttime <= 1e-10 ||
516 (twarp=(floor(sqrt((10.0*game.dist)/ttime)*10.0)+1.0)/10.0) > 10) {
517 prout(_("We'll never make it, sir."));
526 proutn(_("Warp factor? "));
527 if (scan()== IHREAL) {
530 if (twarp<1.0 || twarp > 10.0) {
536 prout(_("Captain, certainly you can give me one of these."));
540 ttime = (10.0*game.dist)/square(twarp);
541 tpower = game.dist*twarp*twarp*twarp*(game.shldup+1);
542 if (tpower >= game.energy) {
543 prout(_("Insufficient energy, sir."));
544 if (!game.shldup || tpower > game.energy*2.0) {
547 proutn(_("New warp factor to try? "));
548 if (scan() == IHREAL) {
551 if (twarp<1.0 || twarp > 10.0) {
563 prout(_("But if you lower your shields,"));
564 proutn(_("remaining"));
568 proutn(_("Remaining"));
569 prout(_(" energy will be %.2f."), game.energy-tpower);
571 prout(_("And we will arrive at stardate %.2f."),
572 game.state.date+ttime);
575 prout(_("Any warp speed is adequate."));
577 prout(_("Minimum warp needed is %.2f,"), twarp);
578 prout(_("and we will arrive at stardate %.2f."),
579 game.state.date+ttime);
581 if (game.state.remtime < ttime)
582 prout(_("Unfortunately, the Federation will be destroyed by then."));
584 prout(_("You'll be taking risks at that speed, Captain"));
585 if ((game.isatb==1 && same(game.state.kscmdr, w1) &&
586 scheduled(FSCDBAS)< ttime+game.state.date)||
587 (scheduled(FCDBAS)<ttime+game.state.date && same(game.battle, w1)))
588 prout(_("The starbase there will be destroyed by then."));
589 proutn(_("New warp factor to try? "));
590 if (scan() == IHREAL) {
593 if (twarp<1.0 || twarp > 10.0) {
607 #ifdef BSD_BUG_FOR_BUG
609 * A visual scan is made in a particular direction of three sectors
610 * in the general direction specified. This takes time, and
611 * Klingons can attack you, so it should be done only when sensors
612 * are out. Code swiped from BSD-Trek. Not presently used, as we
613 * automatically display all adjacent sectors on the short-range
614 * scan even when short-range sensors are out.
617 /* This struct[] has the delta x, delta y for particular directions */
638 if (scan() != IHREAL) {
640 proutn(_("Direction? "));
641 if (scan()!=IHREAL) {
646 if (aaitem < 0.0 || aaitem > 360.0)
648 co = (aaitem + 22) / 45;
650 ix = game.sector.x + v->x;
651 iy = game.sector.y + v->y;
652 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
655 co = game.quad[ix][iy];
656 printf("%d,%d %c ", ix, iy, co);
658 ix = game.sector.x + v->x;
659 iy = game.sector.y + v->y;
660 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
663 co = game.quad[ix][iy];
666 ix = game.sector.x + v->x;
667 iy = game.sector.y + v->y;
668 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
671 co = game.quad[ix][iy];
672 printf("%c %d,%d\n", co, ix, iy);