6 void attakreport(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) prout(_("No plaque is allowed."));
59 if (game.tourn) prout(_("This is tournament game %d."), game.tourn);
60 prout(_("Your secret password is \"%s\""),game.passwd);
61 proutn(_("%d of %d Klingons have been killed"), KLINGKILLED, INKLINGTOT);
62 if (NKILLC) prout(_(", including %d Commander%s."), NKILLC, NKILLC==1?"":_("s"));
63 else if (NKILLK + NKILLSC > 0) prout(_(", but no Commanders."));
65 if (game.skill > SKILL_FAIR) prout(_("The Super Commander has %sbeen destroyed."),
66 game.state.nscrem?_("not "):"");
67 if (game.state.rembase != game.inbase) {
69 if (game.inbase-game.state.rembase==1) proutn(_("has been 1 base"));
71 proutn(_("have been %d bases"), game.inbase-game.state.rembase);
73 prout(_(" destroyed, %d remaining."), game.state.rembase);
75 else prout(_("There are %d bases."), game.inbase);
76 if (!damaged(DRADIO) || game.condition == docked || game.iseenit) {
77 /* Don't report this if not seen and
78 either the radio is dead or not at base! */
82 if (game.casual) prout(_("%d casualt%s suffered so far."),
83 game.casual, game.casual==1? "y" : "ies");
84 if (game.nhelp) prout(_("There were %d call%s for help."),
85 game.nhelp, game.nhelp==1 ? "" : _("s"));
86 if (game.ship == IHE) {
87 proutn(_("You have "));
88 if (game.nprobes) proutn("%d", game.nprobes);
90 proutn(_(" deep space probe"));
91 if (game.nprobes!=1) proutn(_("s"));
94 if ((!damaged(DRADIO) || game.condition == docked)
95 && is_scheduled(FDSPROB)) {
97 proutn(_("An armed deep space probe is in"));
99 proutn(_("A deep space probe is in"));
100 proutn(cramlc(quadrant, game.probec));
104 if (game.cryprob <= .05)
105 prout(_("Dilithium crystals aboard ship... not yet used."));
109 while (game.cryprob > ai) {
113 prout(_("Dilithium crystals have been used %d time%s."),
114 i, i==1? "" : _("s"));
121 /* long-range sensor scan */
124 if (damaged(DLRSENS)) {
125 /* Now allow base's sensors if docked */
126 if (game.condition != docked) {
127 prout(_("LONG-RANGE SENSORS DAMAGED."));
130 prout(_("Starbase's long-range scan"));
133 prout(_("Long-range scan"));
135 for (x = game.quadrant.x-1; x <= game.quadrant.x+1; x++) {
137 for (y = game.quadrant.y-1; y <= game.quadrant.y+1; y++) {
138 if (!VALID_QUADRANT(x, y))
141 if (!damaged(DRADIO))
142 game.state.galaxy[x][y].charted = true;
143 game.state.chart[x][y].klingons = game.state.galaxy[x][y].klingons;
144 game.state.chart[x][y].starbase = game.state.galaxy[x][y].starbase;
145 game.state.chart[x][y].stars = game.state.galaxy[x][y].stars;
146 if (game.state.galaxy[x][y].supernova)
149 proutn(" %3d", game.state.chart[x][y].klingons*100 + game.state.chart[x][y].starbase * 10 + game.state.chart[x][y].stars);
163 for (i = 0; i < NDEVICES; i++) {
166 prout(_("DEVICE -REPAIR TIMES-"));
167 prout(_(" IN FLIGHT DOCKED"));
170 prout(" %16s %8.2f %8.2f",
173 game.docfac*game.damage[i]+0.005);
176 if (!jdam) prout(_("All devices functional."));
180 /* update the chart in the Enterprise's computer from galaxy data */
183 game.lastchart = game.state.date;
186 if (game.state.galaxy[i][j].charted) {
187 game.state.chart[i][j].klingons = game.state.galaxy[i][j].klingons;
188 game.state.chart[i][j].starbase = game.state.galaxy[i][j].starbase;
189 game.state.chart[i][j].stars = game.state.galaxy[i][j].stars;
194 /* display the star chart */
199 if (!damaged(DRADIO))
202 if (game.lastchart < game.state.date && game.condition == docked) {
203 prout(_("Spock- \"I revised the Star Chart from the starbase's records.\""));
207 prout(_(" STAR CHART FOR THE KNOWN GALAXY"));
208 if (game.state.date > game.lastchart)
209 prout(_("(Last surveillance update %d stardates ago)."),
210 (int)(game.state.date-game.lastchart));
211 prout(" 1 2 3 4 5 6 7 8");
216 if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
220 if (game.state.galaxy[i][j].supernova)
222 else if (!game.state.galaxy[i][j].charted && game.state.galaxy[i][j].starbase)
224 else if (game.state.galaxy[i][j].charted)
225 sprintf(buf, "%3d", game.state.chart[i][j].klingons*100 + game.state.chart[i][j].starbase * 10 + game.state.chart[i][j].stars);
229 if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
235 if (i<GALSIZE) skip(1);
239 static void sectscan(int goodScan, int i, int j)
240 /* light up an individual dot in a sector */
242 if (goodScan || (abs(i-game.sector.x)<= 1 && abs(j-game.sector.y) <= 1)){
243 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)){
244 switch (game.condition) {
245 case red: textcolor(RED); break;
246 case green: textcolor(GREEN); break;
247 case yellow: textcolor(YELLOW); break;
248 case docked: textcolor(CYAN); break;
249 case dead: textcolor(BROWN);
251 if (game.quad[i][j] != game.ship)
254 proutn("%c ",game.quad[i][j]);
262 /* print status report lines */
264 #define RQ(n, a) if (!req || req == n) do { a } while(0)
265 char *cp = NULL, s[256];
269 prstat(_("Stardate"), _("%.1f, Time Left %.2f"), game.state.date, game.state.remtime);
273 if (game.condition != docked) newcnd();
274 switch (game.condition) {
275 case red: cp = _("RED"); break;
276 case green: cp = _("GREEN"); break;
277 case yellow: cp = _("YELLOW"); break;
278 case docked: cp = _("DOCKED"); break;
279 case dead: cp = _("DEAD"); break;
281 for (t=0;t<NDEVICES;t++)
282 if (game.damage[t]>0)
284 prstat(_("Condition"), _("%s, %i DAMAGES"), cp, dam);
288 prstat(_("Position"), "%d - %d , %d - %d",
289 game.quadrant.x, game.quadrant.y, game.sector.x, game.sector.y);
293 if (damaged(DLIFSUP)) {
294 if (game.condition == docked)
295 sprintf(s, _("DAMAGED, Base provides"));
297 sprintf(s, _("DAMAGED, reserves=%4.2f"), game.lsupres);
300 sprintf(s, _("ACTIVE"));
301 prstat(_("Life Support"), s);
305 prstat(_("Warp Factor"), "%.1f", game.warpfac);
309 prstat(_("Energy"), "%.2f%s", game.energy,
310 (game.icrystl && (game.options & OPTION_SHOWME)) ? /* ESR */
311 _(" (have crystals)") : "");
315 prstat(_("Torpedoes"), "%d", game.torps);
319 if (damaged(DSHIELD))
320 strcpy(s, _("DAMAGED,"));
321 else if (game.shldup)
324 strcpy(s, _("DOWN,"));
325 sprintf(s + strlen(s), _(" %d%% %.1f units"),
326 (int)((100.0*game.shield)/game.inshld + 0.5), game.shield);
327 prstat(_("Shields"), s);
331 prstat(_("Klingons Left"), "%d", KLINGREM);
335 if (game.options & OPTION_WORLDS) {
336 int plnet = game.state.galaxy[game.quadrant.x][game.quadrant.y].planet;
337 if (plnet != NOPLANET && game.state.plnets[plnet].inhabited != UNINHABITED)
338 prstat(_("Major system"), "%s", systnames[plnet]);
340 prout(_("Sector is uninhabited"));
354 static char requests[][3] =
355 {"da","co","po","ls","wa","en","to","sh","kl","sy", "ti"};
357 while (scan() == IHEOL)
358 proutn(_("Information desired? "));
360 for (req = 0; req < ARRAY_SIZE(requests); req++)
361 if (strncmp(citem, requests[req], min(2,strlen(citem)))==0)
363 if (req >= ARRAY_SIZE(requests)) {
364 prout(_("UNRECOGNIZED REQUEST. Legal requests are:"));
365 prout((" date, condition, position, lsupport, warpfactor,"));
366 prout((" energy, torpedoes, shields, klingons, system, time."));
373 /* short-range scan */
377 if (damaged(DSRSENS)) {
378 /* Allow base's sensors if docked */
379 if (game.condition != docked) {
380 prout(_(" S.R. SENSORS DAMAGED!"));
384 prout(_(" [Using Base's sensors]"));
386 else prout(_(" Short-range scan"));
387 if (goodScan && !damaged(DRADIO)) {
388 game.state.chart[game.quadrant.x][game.quadrant.y].klingons = game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons;
389 game.state.chart[game.quadrant.x][game.quadrant.y].starbase = game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase;
390 game.state.chart[game.quadrant.x][game.quadrant.y].stars = game.state.galaxy[game.quadrant.x][game.quadrant.y].stars;
391 game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true;
393 prout(" 1 2 3 4 5 6 7 8 9 10");
394 if (game.condition != docked) newcnd();
395 for (i = 1; i <= QUADSIZE; i++) {
398 sectscan(goodScan, i, j);
406 /* use computer to get estimated time of arrival for a warp jump */
409 bool wfl, prompt = false;
410 double ttime, twarp, tpower;
411 if (damaged(DCOMPTR)) {
412 prout(_("COMPUTER DAMAGED, USE A POCKET CALCULATOR."));
416 if (scan() != IHREAL) {
419 proutn(_("Destination quadrant and/or sector? "));
420 if (scan()!=IHREAL) {
426 if (scan() != IHREAL) {
431 if (scan() == IHREAL) {
433 if (scan() != IHREAL) {
440 if (game.quadrant.y>w1.x) w2.x = 1;
442 if (game.quadrant.x>w1.y) w2.y = 1;
446 if (!VALID_QUADRANT(w1.x, w1.y) || !VALID_SECTOR(w2.x, w2.y)) {
450 game.dist = sqrt(square(w1.y-game.quadrant.y+0.1*(w2.y-game.sector.y))+
451 square(w1.x-game.quadrant.x+0.1*(w2.x-game.sector.x)));
454 if (prompt) prout(_("Answer \"no\" if you don't know the value:"));
457 proutn(_("Time or arrival date? "));
458 if (scan()==IHREAL) {
460 if (ttime > game.state.date) ttime -= game.state.date; // Actually a star date
461 if (ttime <= 1e-10 ||
462 (twarp=(floor(sqrt((10.0*game.dist)/ttime)*10.0)+1.0)/10.0) > 10) {
463 prout(_("We'll never make it, sir."));
467 if (twarp < 1.0) twarp = 1.0;
471 proutn(_("Warp factor? "));
472 if (scan()== IHREAL) {
475 if (twarp<1.0 || twarp > 10.0) {
481 prout(_("Captain, certainly you can give me one of these."));
485 ttime = (10.0*game.dist)/square(twarp);
486 tpower = game.dist*twarp*twarp*twarp*(game.shldup+1);
487 if (tpower >= game.energy) {
488 prout(_("Insufficient energy, sir."));
489 if (!game.shldup || tpower > game.energy*2.0) {
491 proutn(_("New warp factor to try? "));
492 if (scan() == IHREAL) {
495 if (twarp<1.0 || twarp > 10.0) {
507 prout(_("But if you lower your shields,"));
508 proutn(_("remaining"));
512 proutn(_("Remaining"));
513 prout(_(" energy will be %.2f."), game.energy-tpower);
515 prout(_("And we will arrive at stardate %.2f."),
516 game.state.date+ttime);
519 prout(_("Any warp speed is adequate."));
521 prout(_("Minimum warp needed is %.2f,"), twarp);
522 prout(_("and we will arrive at stardate %.2f."),
523 game.state.date+ttime);
525 if (game.state.remtime < ttime)
526 prout(_("Unfortunately, the Federation will be destroyed by then."));
528 prout(_("You'll be taking risks at that speed, Captain"));
529 if ((game.isatb==1 && same(game.state.kscmdr, w1) &&
530 scheduled(FSCDBAS)< ttime+game.state.date)||
531 (scheduled(FCDBAS)<ttime+game.state.date && same(game.battle, w1)))
532 prout(_("The starbase there will be destroyed by then."));
533 proutn(_("New warp factor to try? "));
534 if (scan() == IHREAL) {
537 if (twarp<1.0 || twarp > 10.0) {
553 * A visual scan is made in a particular direction of three sectors
554 * in the general direction specified. This takes time, and
555 * Klingons can attack you, so it should be done only when sensors
556 * are out. Code swiped from BSD-Trek. Not presently used, as we
557 * automatically display all adjacent sectors on the short-range
558 * scan even when short-range sensors are out.
561 /* This struct[] has the delta x, delta y for particular directions */
582 if (scan() != IHREAL) {
584 proutn(_("Direction? "));
585 if (scan()!=IHREAL) {
590 if (aaitem < 0.0 || aaitem > 360.0)
592 co = (aaitem + 22) / 45;
594 ix = game.sector.x + v->x;
595 iy = game.sector.y + v->y;
596 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
599 co = game.quad[ix][iy];
600 printf("%d,%d %c ", ix, iy, co);
602 ix = game.sector.x + v->x;
603 iy = game.sector.y + v->y;
604 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
607 co = game.quad[ix][iy];
610 ix = game.sector.x + v->x;
611 iy = game.sector.y + v->y;
612 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
615 co = game.quad[ix][iy];
616 printf("%c %d,%d\n", co, ix, iy);