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"), KLINGKILLED, INKLINGTOT);
65 prout(_(", including %d Commander%s."), NKILLC, NKILLC==1?"":_("s"));
66 else if (NKILLK + NKILLSC > 0)
67 prout(_(", but no Commanders."));
70 if (game.skill > SKILL_FAIR)
71 prout(_("The Super Commander has %sbeen destroyed."),
72 game.state.nscrem?_("not "):"");
73 if (game.state.rembase != game.inbase) {
75 if (game.inbase-game.state.rembase==1)
76 proutn(_("has been 1 base"));
78 proutn(_("have been %d bases"), game.inbase-game.state.rembase);
80 prout(_(" destroyed, %d remaining."), game.state.rembase);
83 prout(_("There are %d bases."), game.inbase);
84 if (!damaged(DRADIO) || game.condition == docked || game.iseenit) {
85 /* Don't report this if not seen and
86 either the radio is dead or not at base! */
91 prout(_("%d casualt%s suffered so far."),
92 game.casual, game.casual==1? "y" : "ies");
94 prout(_("There were %d call%s for help."),
95 game.nhelp, game.nhelp==1 ? "" : _("s"));
96 if (game.ship == IHE) {
97 proutn(_("You have "));
99 proutn("%d", game.nprobes);
102 proutn(_(" deep space probe"));
107 if ((!damaged(DRADIO) || game.condition == docked)
108 && is_scheduled(FDSPROB)) {
110 proutn(_("An armed deep space probe is in "));
112 proutn(_("A deep space probe is in "));
113 proutn(cramlc(quadrant, game.probec));
117 if (game.cryprob <= .05)
118 prout(_("Dilithium crystals aboard ship... not yet used."));
122 while (game.cryprob > ai) {
126 prout(_("Dilithium crystals have been used %d time%s."),
127 i, i==1? "" : _("s"));
134 /* long-range sensor scan */
137 if (damaged(DLRSENS)) {
138 /* Now allow base's sensors if docked */
139 if (game.condition != docked) {
140 prout(_("LONG-RANGE SENSORS DAMAGED."));
143 prout(_("Starbase's long-range scan"));
146 prout(_("Long-range scan"));
148 for (x = game.quadrant.x-1; x <= game.quadrant.x+1; x++) {
150 for (y = game.quadrant.y-1; y <= game.quadrant.y+1; y++) {
151 if (!VALID_QUADRANT(x, y))
154 if (!damaged(DRADIO))
155 game.state.galaxy[x][y].charted = true;
156 game.state.chart[x][y].klingons = game.state.galaxy[x][y].klingons;
157 game.state.chart[x][y].starbase = game.state.galaxy[x][y].starbase;
158 game.state.chart[x][y].stars = game.state.galaxy[x][y].stars;
159 if (game.state.galaxy[x][y].supernova)
162 proutn(" %3d", game.state.chart[x][y].klingons*100 + game.state.chart[x][y].starbase * 10 + game.state.chart[x][y].stars);
169 void damagereport(void)
176 for (i = 0; i < NDEVICES; i++) {
179 prout(_("\tDEVICE\t\t\t-REPAIR TIMES-"));
180 prout(_("\t\t\tIN FLIGHT\t\tDOCKED"));
183 prout(" %-26s\t%8.2f\t\t%8.2f",
186 game.docfac*game.damage[i]+0.005);
190 prout(_("All devices functional."));
194 /* update the chart in the Enterprise's computer from galaxy data */
197 game.lastchart = game.state.date;
200 if (game.state.galaxy[i][j].charted) {
201 game.state.chart[i][j].klingons = game.state.galaxy[i][j].klingons;
202 game.state.chart[i][j].starbase = game.state.galaxy[i][j].starbase;
203 game.state.chart[i][j].stars = game.state.galaxy[i][j].stars;
208 /* display the star chart */
213 if (!damaged(DRADIO))
216 if (game.lastchart < game.state.date && game.condition == docked) {
217 prout(_("Spock- \"I revised the Star Chart from the starbase's records.\""));
221 prout(_(" STAR CHART FOR THE KNOWN GALAXY"));
222 if (game.state.date > game.lastchart)
223 prout(_("(Last surveillance update %d stardates ago)."),
224 (int)(game.state.date-game.lastchart));
225 prout(" 1 2 3 4 5 6 7 8");
230 if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
234 if (game.state.galaxy[i][j].supernova)
236 else if (!game.state.galaxy[i][j].charted && game.state.galaxy[i][j].starbase)
238 else if (game.state.galaxy[i][j].charted)
239 sprintf(buf, "%3d", game.state.chart[i][j].klingons*100 + game.state.chart[i][j].starbase * 10 + game.state.chart[i][j].stars);
243 if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
254 static void sectscan(int goodScan, int i, int j)
255 /* light up an individual dot in a sector */
257 if (goodScan || (abs(i-game.sector.x)<= 1 && abs(j-game.sector.y) <= 1)){
258 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)){
259 switch (game.condition) {
260 case red: textcolor(RED); break;
261 case green: textcolor(GREEN); break;
262 case yellow: textcolor(YELLOW); break;
263 case docked: textcolor(CYAN); break;
264 case dead: textcolor(BROWN);
266 if (game.quad[i][j] != game.ship)
269 proutn("%c ",game.quad[i][j]);
277 /* print status report lines */
279 #define RQ(n, a) if (!req || req == n) do { a } while(0)
280 char *cp = NULL, s[256];
284 prstat(_("Stardate"), _("%.1f, Time Left %.2f"), game.state.date, game.state.remtime);
288 if (game.condition != docked)
290 switch (game.condition) {
291 case red: cp = _("RED"); break;
292 case green: cp = _("GREEN"); break;
293 case yellow: cp = _("YELLOW"); break;
294 case docked: cp = _("DOCKED"); break;
295 case dead: cp = _("DEAD"); break;
297 for (t=0;t<NDEVICES;t++)
298 if (game.damage[t]>0)
300 prstat(_("Condition"), _("%s, %i DAMAGES"), cp, dam);
304 prstat(_("Position"), "%d - %d , %d - %d",
305 game.quadrant.x, game.quadrant.y, game.sector.x, game.sector.y);
309 if (damaged(DLIFSUP)) {
310 if (game.condition == docked)
311 sprintf(s, _("DAMAGED, Base provides"));
313 sprintf(s, _("DAMAGED, reserves=%4.2f"), game.lsupres);
316 sprintf(s, _("ACTIVE"));
317 prstat(_("Life Support"), s);
321 prstat(_("Warp Factor"), "%.1f", game.warpfac);
325 prstat(_("Energy"), "%.2f%s", game.energy,
326 (game.icrystl && (game.options & OPTION_SHOWME)) ? /* ESR */
327 _(" (have crystals)") : "");
331 prstat(_("Torpedoes"), "%d", game.torps);
335 if (damaged(DSHIELD))
336 strcpy(s, _("DAMAGED,"));
337 else if (game.shldup)
340 strcpy(s, _("DOWN,"));
341 sprintf(s + strlen(s), _(" %d%% %.1f units"),
342 (int)((100.0*game.shield)/game.inshld + 0.5), game.shield);
343 prstat(_("Shields"), s);
347 prstat(_("Klingons Left"), "%d", KLINGREM);
351 if (game.options & OPTION_WORLDS) {
352 int plnet = game.state.galaxy[game.quadrant.x][game.quadrant.y].planet;
353 if (plnet != NOPLANET && game.state.planets[plnet].inhabited != UNINHABITED)
354 prstat(_("Major system"), "%s", systnames[plnet]);
356 prout(_("Sector is uninhabited"));
370 static char requests[][3] =
371 {"da","co","po","ls","wa","en","to","sh","kl","sy", "ti"};
373 while (scan() == IHEOL)
374 proutn(_("Information desired? "));
376 for (req = 0; req < ARRAY_SIZE(requests); req++)
377 if (strncmp(citem, requests[req], min(2,strlen(citem)))==0)
379 if (req >= ARRAY_SIZE(requests)) {
380 prout(_("UNRECOGNIZED REQUEST. Legal requests are:"));
381 prout((" date, condition, position, lsupport, warpfactor,"));
382 prout((" energy, torpedoes, shields, klingons, system, time."));
389 /* short-range scan */
393 if (damaged(DSRSENS)) {
394 /* Allow base's sensors if docked */
395 if (game.condition != docked) {
396 prout(_(" S.R. SENSORS DAMAGED!"));
400 prout(_(" [Using Base's sensors]"));
403 prout(_(" Short-range scan"));
404 if (goodScan && !damaged(DRADIO)) {
405 game.state.chart[game.quadrant.x][game.quadrant.y].klingons = game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons;
406 game.state.chart[game.quadrant.x][game.quadrant.y].starbase = game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase;
407 game.state.chart[game.quadrant.x][game.quadrant.y].stars = game.state.galaxy[game.quadrant.x][game.quadrant.y].stars;
408 game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true;
410 prout(" 1 2 3 4 5 6 7 8 9 10");
411 if (game.condition != docked)
413 for (i = 1; i <= QUADSIZE; i++) {
416 sectscan(goodScan, i, j);
424 /* use computer to get estimated time of arrival for a warp jump */
427 bool wfl, prompt = false;
428 double ttime, twarp, tpower;
429 if (damaged(DCOMPTR)) {
430 prout(_("COMPUTER DAMAGED, USE A POCKET CALCULATOR."));
434 if (scan() != IHREAL) {
437 proutn(_("Destination quadrant and/or sector? "));
438 if (scan()!=IHREAL) {
444 if (scan() != IHREAL) {
449 if (scan() == IHREAL) {
451 if (scan() != IHREAL) {
458 if (game.quadrant.y>w1.x)
462 if (game.quadrant.x>w1.y)
468 if (!VALID_QUADRANT(w1.x, w1.y) || !VALID_SECTOR(w2.x, w2.y)) {
472 game.dist = sqrt(square(w1.y-game.quadrant.y+0.1*(w2.y-game.sector.y))+
473 square(w1.x-game.quadrant.x+0.1*(w2.x-game.sector.x)));
477 prout(_("Answer \"no\" if you don't know the value:"));
480 proutn(_("Time or arrival date? "));
481 if (scan()==IHREAL) {
483 if (ttime > game.state.date)
484 ttime -= game.state.date; // Actually a star date
485 if (ttime <= 1e-10 ||
486 (twarp=(floor(sqrt((10.0*game.dist)/ttime)*10.0)+1.0)/10.0) > 10) {
487 prout(_("We'll never make it, sir."));
496 proutn(_("Warp factor? "));
497 if (scan()== IHREAL) {
500 if (twarp<1.0 || twarp > 10.0) {
506 prout(_("Captain, certainly you can give me one of these."));
510 ttime = (10.0*game.dist)/square(twarp);
511 tpower = game.dist*twarp*twarp*twarp*(game.shldup+1);
512 if (tpower >= game.energy) {
513 prout(_("Insufficient energy, sir."));
514 if (!game.shldup || tpower > game.energy*2.0) {
517 proutn(_("New warp factor to try? "));
518 if (scan() == IHREAL) {
521 if (twarp<1.0 || twarp > 10.0) {
533 prout(_("But if you lower your shields,"));
534 proutn(_("remaining"));
538 proutn(_("Remaining"));
539 prout(_(" energy will be %.2f."), game.energy-tpower);
541 prout(_("And we will arrive at stardate %.2f."),
542 game.state.date+ttime);
545 prout(_("Any warp speed is adequate."));
547 prout(_("Minimum warp needed is %.2f,"), twarp);
548 prout(_("and we will arrive at stardate %.2f."),
549 game.state.date+ttime);
551 if (game.state.remtime < ttime)
552 prout(_("Unfortunately, the Federation will be destroyed by then."));
554 prout(_("You'll be taking risks at that speed, Captain"));
555 if ((game.isatb==1 && same(game.state.kscmdr, w1) &&
556 scheduled(FSCDBAS)< ttime+game.state.date)||
557 (scheduled(FCDBAS)<ttime+game.state.date && same(game.battle, w1)))
558 prout(_("The starbase there will be destroyed by then."));
559 proutn(_("New warp factor to try? "));
560 if (scan() == IHREAL) {
563 if (twarp<1.0 || twarp > 10.0) {
579 * A visual scan is made in a particular direction of three sectors
580 * in the general direction specified. This takes time, and
581 * Klingons can attack you, so it should be done only when sensors
582 * are out. Code swiped from BSD-Trek. Not presently used, as we
583 * automatically display all adjacent sectors on the short-range
584 * scan even when short-range sensors are out.
587 /* This struct[] has the delta x, delta y for particular directions */
608 if (scan() != IHREAL) {
610 proutn(_("Direction? "));
611 if (scan()!=IHREAL) {
616 if (aaitem < 0.0 || aaitem > 360.0)
618 co = (aaitem + 22) / 45;
620 ix = game.sector.x + v->x;
621 iy = game.sector.y + v->y;
622 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
625 co = game.quad[ix][iy];
626 printf("%d,%d %c ", ix, iy, co);
628 ix = game.sector.x + v->x;
629 iy = game.sector.y + v->y;
630 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
633 co = game.quad[ix][iy];
636 ix = game.sector.x + v->x;
637 iy = game.sector.y + v->y;
638 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
641 co = game.quad[ix][iy];
642 printf("%c %d,%d\n", co, ix, iy);