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 if (!damaged(DRADIO))
157 game.state.galaxy[x][y].charted = true;
158 game.state.chart[x][y].klingons = game.state.galaxy[x][y].klingons;
159 game.state.chart[x][y].starbase = game.state.galaxy[x][y].starbase;
160 game.state.chart[x][y].stars = game.state.galaxy[x][y].stars;
161 if (game.state.galaxy[x][y].supernova)
164 proutn(" %3d", game.state.chart[x][y].klingons*100 + game.state.chart[x][y].starbase * 10 + game.state.chart[x][y].stars);
171 void damagereport(void)
178 for (i = 0; i < NDEVICES; i++) {
181 prout(_("\tDEVICE\t\t\t-REPAIR TIMES-"));
182 prout(_("\t\t\tIN FLIGHT\t\tDOCKED"));
185 prout(" %-26s\t%8.2f\t\t%8.2f",
188 game.docfac*game.damage[i]+0.005);
192 prout(_("All devices functional."));
196 /* update the chart in the Enterprise's computer from galaxy data */
199 game.lastchart = game.state.date;
200 for (i = 1; i <= GALSIZE; i++)
201 for (j = 1; j <= GALSIZE; j++)
202 if (game.state.galaxy[i][j].charted) {
203 game.state.chart[i][j].klingons = game.state.galaxy[i][j].klingons;
204 game.state.chart[i][j].starbase = game.state.galaxy[i][j].starbase;
205 game.state.chart[i][j].stars = game.state.galaxy[i][j].stars;
210 /* display the star chart */
215 if (!damaged(DRADIO))
218 if (game.lastchart < game.state.date && game.condition == docked) {
219 prout(_("Spock- \"I revised the Star Chart from the starbase's records.\""));
223 prout(_(" STAR CHART FOR THE KNOWN GALAXY"));
224 if (game.state.date > game.lastchart)
225 prout(_("(Last surveillance update %d stardates ago)."),
226 (int)(game.state.date-game.lastchart));
227 prout(" 1 2 3 4 5 6 7 8");
228 for (i = 1; i <= GALSIZE; i++) {
230 for (j = 1; j <= GALSIZE; j++) {
232 if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
236 if (game.state.galaxy[i][j].supernova)
238 else if (!game.state.galaxy[i][j].charted && game.state.galaxy[i][j].starbase)
240 else if (game.state.galaxy[i][j].charted)
241 sprintf(buf, "%3d", game.state.chart[i][j].klingons*100 + game.state.chart[i][j].starbase * 10 + game.state.chart[i][j].stars);
245 if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
256 static void sectscan(int goodScan, int i, int j)
257 /* light up an individual dot in a sector */
259 if (goodScan || (abs(i-game.sector.x)<= 1 && abs(j-game.sector.y) <= 1)){
260 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)){
261 switch (game.condition) {
262 case red: textcolor(RED); break;
263 case green: textcolor(GREEN); break;
264 case yellow: textcolor(YELLOW); break;
265 case docked: textcolor(CYAN); break;
266 case dead: textcolor(BROWN);
268 if (game.quad[i][j] != game.ship)
271 proutn("%c ",game.quad[i][j]);
279 /* print status report lines */
281 #define RQ(n, a) if (!req || req == n) do { a } while(0)
282 char *cp = NULL, s[256];
286 prstat(_("Stardate"), _("%.1f, Time Left %.2f"), game.state.date, game.state.remtime);
290 if (game.condition != docked)
292 switch (game.condition) {
293 case red: cp = _("RED"); break;
294 case green: cp = _("GREEN"); break;
295 case yellow: cp = _("YELLOW"); break;
296 case docked: cp = _("DOCKED"); break;
297 case dead: cp = _("DEAD"); break;
299 for (t=0;t<NDEVICES;t++)
300 if (game.damage[t]>0)
302 prstat(_("Condition"), _("%s, %i DAMAGES"), cp, dam);
306 prstat(_("Position"), "%d - %d , %d - %d",
307 game.quadrant.x, game.quadrant.y, game.sector.x, game.sector.y);
311 if (damaged(DLIFSUP)) {
312 if (game.condition == docked)
313 sprintf(s, _("DAMAGED, Base provides"));
315 sprintf(s, _("DAMAGED, reserves=%4.2f"), game.lsupres);
318 sprintf(s, _("ACTIVE"));
319 prstat(_("Life Support"), s);
323 prstat(_("Warp Factor"), "%.1f", game.warpfac);
327 prstat(_("Energy"), "%.2f%s", game.energy,
328 (game.icrystl && (game.options & OPTION_SHOWME)) ? /* ESR */
329 _(" (have crystals)") : "");
333 prstat(_("Torpedoes"), "%d", game.torps);
337 if (damaged(DSHIELD))
338 strcpy(s, _("DAMAGED,"));
339 else if (game.shldup)
342 strcpy(s, _("DOWN,"));
343 sprintf(s + strlen(s), _(" %d%% %.1f units"),
344 (int)((100.0*game.shield)/game.inshld + 0.5), game.shield);
345 prstat(_("Shields"), s);
349 prstat(_("Klingons Left"), "%d", game.state.remkl + game.state.remcom + game.state.nscrem);
353 if (game.options & OPTION_WORLDS) {
354 int plnet = game.state.galaxy[game.quadrant.x][game.quadrant.y].planet;
355 if (plnet != NOPLANET && game.state.planets[plnet].inhabited != UNINHABITED)
356 prstat(_("Major system"), "%s", systnames[plnet]);
358 prout(_("Sector is uninhabited"));
372 static char requests[][3] =
373 {"da","co","po","ls","wa","en","to","sh","kl","sy", "ti"};
375 while (scan() == IHEOL)
376 proutn(_("Information desired? "));
378 for (req = 0; req < ARRAY_SIZE(requests); req++)
379 if (strncmp(citem, requests[req], min(2,strlen(citem)))==0)
381 if (req >= ARRAY_SIZE(requests)) {
382 prout(_("UNRECOGNIZED REQUEST. Legal requests are:"));
383 prout((" date, condition, position, lsupport, warpfactor,"));
384 prout((" energy, torpedoes, shields, klingons, system, time."));
391 /* short-range scan */
395 if (damaged(DSRSENS)) {
396 /* Allow base's sensors if docked */
397 if (game.condition != docked) {
398 prout(_(" S.R. SENSORS DAMAGED!"));
402 prout(_(" [Using Base's sensors]"));
405 prout(_(" Short-range scan"));
406 if (goodScan && !damaged(DRADIO)) {
407 game.state.chart[game.quadrant.x][game.quadrant.y].klingons = game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons;
408 game.state.chart[game.quadrant.x][game.quadrant.y].starbase = game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase;
409 game.state.chart[game.quadrant.x][game.quadrant.y].stars = game.state.galaxy[game.quadrant.x][game.quadrant.y].stars;
410 game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true;
412 prout(" 1 2 3 4 5 6 7 8 9 10");
413 if (game.condition != docked)
415 for (i = 1; i <= QUADSIZE; i++) {
417 for (j = 1; j <= QUADSIZE; j++) {
418 sectscan(goodScan, i, j);
426 /* use computer to get estimated time of arrival for a warp jump */
429 bool wfl, prompt = false;
430 double ttime, twarp, tpower;
431 if (damaged(DCOMPTR)) {
432 prout(_("COMPUTER DAMAGED, USE A POCKET CALCULATOR."));
436 if (scan() != IHREAL) {
439 proutn(_("Destination quadrant and/or sector? "));
440 if (scan()!=IHREAL) {
446 if (scan() != IHREAL) {
451 if (scan() == IHREAL) {
453 if (scan() != IHREAL) {
460 if (game.quadrant.y>w1.x)
464 if (game.quadrant.x>w1.y)
470 if (!VALID_QUADRANT(w1.x, w1.y) || !VALID_SECTOR(w2.x, w2.y)) {
474 game.dist = sqrt(square(w1.y-game.quadrant.y+0.1*(w2.y-game.sector.y))+
475 square(w1.x-game.quadrant.x+0.1*(w2.x-game.sector.x)));
479 prout(_("Answer \"no\" if you don't know the value:"));
482 proutn(_("Time or arrival date? "));
483 if (scan()==IHREAL) {
485 if (ttime > game.state.date)
486 ttime -= game.state.date; // Actually a star date
487 if (ttime <= 1e-10 ||
488 (twarp=(floor(sqrt((10.0*game.dist)/ttime)*10.0)+1.0)/10.0) > 10) {
489 prout(_("We'll never make it, sir."));
498 proutn(_("Warp factor? "));
499 if (scan()== IHREAL) {
502 if (twarp<1.0 || twarp > 10.0) {
508 prout(_("Captain, certainly you can give me one of these."));
512 ttime = (10.0*game.dist)/square(twarp);
513 tpower = game.dist*twarp*twarp*twarp*(game.shldup+1);
514 if (tpower >= game.energy) {
515 prout(_("Insufficient energy, sir."));
516 if (!game.shldup || tpower > game.energy*2.0) {
519 proutn(_("New warp factor to try? "));
520 if (scan() == IHREAL) {
523 if (twarp<1.0 || twarp > 10.0) {
535 prout(_("But if you lower your shields,"));
536 proutn(_("remaining"));
540 proutn(_("Remaining"));
541 prout(_(" energy will be %.2f."), game.energy-tpower);
543 prout(_("And we will arrive at stardate %.2f."),
544 game.state.date+ttime);
547 prout(_("Any warp speed is adequate."));
549 prout(_("Minimum warp needed is %.2f,"), twarp);
550 prout(_("and we will arrive at stardate %.2f."),
551 game.state.date+ttime);
553 if (game.state.remtime < ttime)
554 prout(_("Unfortunately, the Federation will be destroyed by then."));
556 prout(_("You'll be taking risks at that speed, Captain"));
557 if ((game.isatb==1 && same(game.state.kscmdr, w1) &&
558 scheduled(FSCDBAS)< ttime+game.state.date)||
559 (scheduled(FCDBAS)<ttime+game.state.date && same(game.battle, w1)))
560 prout(_("The starbase there will be destroyed by then."));
561 proutn(_("New warp factor to try? "));
562 if (scan() == IHREAL) {
565 if (twarp<1.0 || twarp > 10.0) {
579 #ifdef BSD_BUG_FOR_BUG
581 * A visual scan is made in a particular direction of three sectors
582 * in the general direction specified. This takes time, and
583 * Klingons can attack you, so it should be done only when sensors
584 * are out. Code swiped from BSD-Trek. Not presently used, as we
585 * automatically display all adjacent sectors on the short-range
586 * scan even when short-range sensors are out.
589 /* This struct[] has the delta x, delta y for particular directions */
610 if (scan() != IHREAL) {
612 proutn(_("Direction? "));
613 if (scan()!=IHREAL) {
618 if (aaitem < 0.0 || aaitem > 360.0)
620 co = (aaitem + 22) / 45;
622 ix = game.sector.x + v->x;
623 iy = game.sector.y + v->y;
624 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
627 co = game.quad[ix][iy];
628 printf("%d,%d %c ", ix, iy, co);
630 ix = game.sector.x + v->x;
631 iy = game.sector.y + v->y;
632 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
635 co = game.quad[ix][iy];
638 ix = game.sector.x + v->x;
639 iy = game.sector.y + v->y;
640 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
643 co = game.quad[ix][iy];
644 printf("%c %d,%d\n", co, ix, iy);