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 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));
23 if (is_scheduled(FCDBAS))
24 proutn(_("Base in %i - %i attacked by C. Alive until %.1f"), game.battle.x, game.battle.y, scheduled(FCDBAS));
26 proutn(_("Base in %i - %i attacked by S. Alive until %.1f"), game.state.kscmdr.x, game.state.kscmdr.y, scheduled(FSCDBAS));
33 /* report on general game status */
38 s1 = (game.thawed?_("thawed "):"");
39 switch (game.length) {
40 case 1: s2=_("short"); break;
41 case 2: s2=_("medium"); break;
42 case 4: s2=_("long"); break;
43 default: s2=_("unknown length"); break;
46 case SKILL_NOVICE: s3=_("novice"); break;
47 case SKILL_FAIR: s3=_("fair"); break;
48 case SKILL_GOOD: s3=_("good"); break;
49 case SKILL_EXPERT: s3=_("expert"); break;
50 case SKILL_EMERITUS: s3=_("emeritus"); break;
51 default: s3=_("skilled"); break;
54 prout(_("You %s a %s%s %s game."),
55 game.alldone? _("were playing") : _("are playing"), s1, s2, s3);
56 if (game.skill>SKILL_GOOD && game.thawed && !game.alldone) prout(_("No plaque is allowed."));
57 if (game.tourn) prout(_("This is tournament game %d."), game.tourn);
58 prout(_("Your secret password is \"%s\""),game.passwd);
59 proutn(_("%d of %d Klingons have been killed"), KLINGKILLED, INKLINGTOT);
60 if (NKILLC) prout(_(", including %d Commander%s."), NKILLC, NKILLC==1?"":_("s"));
61 else if (NKILLK + NKILLSC > 0) prout(_(", but no Commanders."));
63 if (game.skill > SKILL_FAIR) prout(_("The Super Commander has %sbeen destroyed."),
64 game.state.nscrem?_("not "):"");
65 if (game.state.rembase != game.inbase) {
67 if (game.inbase-game.state.rembase==1) proutn(_("has been 1 base"));
69 proutn(_("have been %d bases"), game.inbase-game.state.rembase);
71 prout(_(" destroyed, %d remaining."), game.state.rembase);
73 else prout(_("There are %d bases."), game.inbase);
74 if (!damaged(DRADIO) || game.condition == docked || game.iseenit) {
75 /* Don't report this if not seen and
76 either the radio is dead or not at base! */
80 if (game.casual) prout(_("%d casualt%s suffered so far."),
81 game.casual, game.casual==1? "y" : "ies");
82 if (game.nhelp) prout(_("There were %d call%s for help."),
83 game.nhelp, game.nhelp==1 ? "" : _("s"));
84 if (game.ship == IHE) {
85 proutn(_("You have "));
86 if (game.nprobes) proutn("%d", game.nprobes);
88 proutn(_(" deep space probe"));
89 if (game.nprobes!=1) proutn(_("s"));
92 if ((!damaged(DRADIO) || game.condition == docked)
93 && is_scheduled(FDSPROB)) {
95 proutn(_("An armed deep space probe is in"));
97 proutn(_("A deep space probe is in"));
98 proutn(cramlc(quadrant, game.probec));
102 if (game.cryprob <= .05)
103 prout(_("Dilithium crystals aboard ship... not yet used."));
107 while (game.cryprob > ai) {
111 prout(_("Dilithium crystals have been used %d time%s."),
112 i, i==1? "" : _("s"));
119 /* long-range sensor scan */
123 if (damaged(DLRSENS)) {
124 /* Now allow base's sensors if docked */
125 if (game.condition != docked) {
126 prout(_("LONG-RANGE SENSORS DAMAGED."));
129 prout(_("Starbase's long-range scan"));
132 prout(_("Long-range scan"));
134 for (x = game.quadrant.x-1; x <= game.quadrant.x+1; x++) {
136 for (y = game.quadrant.y-1; y <= game.quadrant.y+1; y++) {
137 if (!VALID_QUADRANT(x, y))
140 if (!damaged(DRADIO))
141 game.state.galaxy[x][y].charted = true;
142 game.state.chart[x][y].klingons = game.state.galaxy[x][y].klingons;
143 game.state.chart[x][y].starbase = game.state.galaxy[x][y].starbase;
144 game.state.chart[x][y].stars = game.state.galaxy[x][y].stars;
145 if (game.state.galaxy[x][y].supernova)
148 proutn(" %3d", game.state.chart[x][y].klingons*100 + game.state.chart[x][y].starbase * 10 + game.state.chart[x][y].stars);
162 for (i = 0; i < NDEVICES; i++) {
165 prout(_("DEVICE -REPAIR TIMES-"));
166 prout(_(" IN FLIGHT DOCKED"));
169 prout(" %16s %8.2f %8.2f",
172 game.docfac*game.damage[i]+0.005);
175 if (!jdam) prout(_("All devices functional."));
179 /* update the chart in the Enterprise's computer from galaxy data */
182 game.lastchart = game.state.date;
185 if (game.state.galaxy[i][j].charted) {
186 game.state.chart[i][j].klingons = game.state.galaxy[i][j].klingons;
187 game.state.chart[i][j].starbase = game.state.galaxy[i][j].starbase;
188 game.state.chart[i][j].stars = game.state.galaxy[i][j].stars;
192 void chart(bool title)
193 /* display the star chart */
198 if (!damaged(DRADIO))
201 if (game.lastchart < game.state.date && game.condition == docked) {
202 prout(_("Spock- \"I revised the Star Chart from the starbase's records.\""));
206 if (!title) prout(_(" STAR CHART FOR THE KNOWN GALAXY"));
207 if (game.state.date > game.lastchart)
208 prout(_("(Last surveillance update %d stardates ago)."),
209 (int)(game.state.date-game.lastchart));
210 prout(" 1 2 3 4 5 6 7 8");
215 if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
219 if (game.state.galaxy[i][j].supernova)
221 else if (!game.state.galaxy[i][j].charted && game.state.galaxy[i][j].starbase)
223 else if (game.state.galaxy[i][j].charted)
224 sprintf(buf, "%3d", game.state.chart[i][j].klingons*100 + game.state.chart[i][j].starbase * 10 + game.state.chart[i][j].stars);
228 if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
234 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]);
261 static void status(int req)
262 /* print status report lines */
268 proutn(_("Stardate %.1f, Time Left %.2f"), game.state.date, game.state.remtime);
271 if (game.condition != docked) newcnd();
272 switch (game.condition) {
273 case red: cp = _("RED"); break;
274 case green: cp = _("GREEN"); break;
275 case yellow: cp = _("YELLOW"); break;
276 case docked: cp = _("DOCKED"); break;
277 case dead: cp = _("DEAD"); break;
279 for (t=0;t<NDEVICES;t++)
280 if (game.damage[t]>0)
282 proutn(_("Condition %s, %i DAMAGES"), cp, dam);
285 proutn(_("Position %d - %d , %d - %d"),
286 game.quadrant.x, game.quadrant.y, game.sector.x, game.sector.y);
289 proutn(_("Life Support "));
290 if (damaged(DLIFSUP)) {
291 if (game.condition == docked)
292 proutn(_("DAMAGED, Base provides"));
294 proutn(_("DAMAGED, reserves=%4.2f"), game.lsupres);
300 proutn(_("Warp Factor %.1f"), game.warpfac);
303 proutn(_("Energy %.2f"), game.energy);
304 if (game.icrystl && (game.options & OPTION_SHOWME)) /* ESR */
305 proutn(_(" (have crystals)"));
308 proutn(_("Torpedoes %d"), game.torps);
311 proutn(_("Shields "));
312 if (damaged(DSHIELD))
313 proutn(_("DAMAGED,"));
314 else if (game.shldup)
318 proutn(_(" %d%% %.1f units"),
319 (int)((100.0*game.shield)/game.inshld + 0.5), game.shield);
322 proutn(_("Klingons Left %d"), KLINGREM);
325 if (game.options & OPTION_WORLDS) {
326 int plnet = game.state.galaxy[game.quadrant.x][game.quadrant.y].planet;
327 if (plnet != NOPLANET && game.state.plnets[plnet].inhabited != UNINHABITED)
328 proutn(_("Major system %s"), systnames[plnet]);
330 proutn(_("Sector is uninhabited"));
340 void srscan(scantype type)
341 /* short-range scan */
343 /* the "sy" request is undocumented */
344 static char requests[][3] =
345 {"","da","co","po","ls","wa","en","to","sh","kl","sy", "ti"};
348 int goodScan=true, leftside=true, rightside=true, title=false;
350 case SCAN_FULL: // SRSCAN
351 if (damaged(DSRSENS)) {
352 /* Allow base's sensors if docked */
353 if (game.condition != docked) {
354 prout(_(" S.R. SENSORS DAMAGED!"));
358 prout(_(" [Using Base's sensors]"));
360 else prout(_(" Short-range scan"));
361 if (goodScan && !damaged(DRADIO)) {
362 game.state.chart[game.quadrant.x][game.quadrant.y].klingons = game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons;
363 game.state.chart[game.quadrant.x][game.quadrant.y].starbase = game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase;
364 game.state.chart[game.quadrant.x][game.quadrant.y].stars = game.state.galaxy[game.quadrant.x][game.quadrant.y].stars;
365 game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true;
368 if (isit("chart")) title = true;
369 if (isit("no")) rightside = false;
371 prout(" 1 2 3 4 5 6 7 8 9 10");
374 while (scan() == IHEOL)
375 proutn(_("Information desired? "));
377 for (req = 1; req <= sizeof(requests)/sizeof(requests[0]); req++)
378 if (strncmp(citem,requests[req],min(2,strlen(citem)))==0)
380 if (req > sizeof(requests)/sizeof(requests[0])) {
381 prout(_("UNRECOGNIZED REQUEST. Legal requests are:"));
382 prout((" date, condition, position, lsupport, warpfactor,"));
383 prout((" energy, torpedoes, shields, klingons, time, system, bases."));
387 case SCAN_STATUS: // STATUS
392 case SCAN_NO_LEFTSIDE: // REQUEST
396 if (game.condition != docked) newcnd();
397 for (i = 1; i <= max(QUADSIZE, sizeof(requests)/sizeof(requests[0])); i++) {
398 jj = (req!=0 ? req : i);
399 if (leftside && i <= QUADSIZE) {
402 sectscan(goodScan, i, j);
407 if (i<sizeof(requests)/sizeof(requests[0])) skip(1);
411 if (title) chart(true);
416 /* use computer to get estimated time of arrival for a warp jump */
419 bool wfl, prompt = false;
420 double ttime, twarp, tpower;
421 if (damaged(DCOMPTR)) {
422 prout(_("COMPUTER DAMAGED, USE A POCKET CALCULATOR."));
426 if (scan() != IHREAL) {
429 proutn(_("Destination quadrant and/or sector? "));
430 if (scan()!=IHREAL) {
436 if (scan() != IHREAL) {
441 if (scan() == IHREAL) {
443 if (scan() != IHREAL) {
450 if (game.quadrant.y>w1.x) w2.x = 1;
452 if (game.quadrant.x>w1.y) w2.y = 1;
456 if (!VALID_QUADRANT(w1.x, w1.y) || !VALID_SECTOR(w2.x, w2.y)) {
460 game.dist = sqrt(square(w1.y-game.quadrant.y+0.1*(w2.y-game.sector.y))+
461 square(w1.x-game.quadrant.x+0.1*(w2.x-game.sector.x)));
464 if (prompt) prout(_("Answer \"no\" if you don't know the value:"));
467 proutn(_("Time or arrival date? "));
468 if (scan()==IHREAL) {
470 if (ttime > game.state.date) ttime -= game.state.date; // Actually a star date
471 if (ttime <= 1e-10 ||
472 (twarp=(floor(sqrt((10.0*game.dist)/ttime)*10.0)+1.0)/10.0) > 10) {
473 prout(_("We'll never make it, sir."));
477 if (twarp < 1.0) twarp = 1.0;
481 proutn(_("Warp factor? "));
482 if (scan()== IHREAL) {
485 if (twarp<1.0 || twarp > 10.0) {
491 prout(_("Captain, certainly you can give me one of these."));
495 ttime = (10.0*game.dist)/square(twarp);
496 tpower = game.dist*twarp*twarp*twarp*(game.shldup+1);
497 if (tpower >= game.energy) {
498 prout(_("Insufficient energy, sir."));
499 if (!game.shldup || tpower > game.energy*2.0) {
501 proutn(_("New warp factor to try? "));
502 if (scan() == IHREAL) {
505 if (twarp<1.0 || twarp > 10.0) {
517 prout(_("But if you lower your shields,"));
518 proutn(_("remaining"));
522 proutn(_("Remaining"));
523 prout(_(" energy will be %.2f."), game.energy-tpower);
525 prout(_("And we will arrive at stardate %.2f."),
526 game.state.date+ttime);
529 prout(_("Any warp speed is adequate."));
531 prout(_("Minimum warp needed is %.2f,"), twarp);
532 prout(_("and we will arrive at stardate %.2f."),
533 game.state.date+ttime);
535 if (game.state.remtime < ttime)
536 prout(_("Unfortunately, the Federation will be destroyed by then."));
538 prout(_("You'll be taking risks at that speed, Captain"));
539 if ((game.isatb==1 && same(game.state.kscmdr, w1) &&
540 scheduled(FSCDBAS)< ttime+game.state.date)||
541 (scheduled(FCDBAS)<ttime+game.state.date && same(game.battle, w1)))
542 prout(_("The starbase there will be destroyed by then."));
543 proutn(_("New warp factor to try? "));
544 if (scan() == IHREAL) {
547 if (twarp<1.0 || twarp > 10.0) {
563 * A visual scan is made in a particular direction of three sectors
564 * in the general direction specified. This takes time, and
565 * Klingons can attack you, so it should be done only when sensors
566 * are out. Code swiped from BSD-Trek. Not presently used, as we
567 * automatically display all adjacent sectors on the short-range
568 * scan even when short-range sensors are out.
571 /* This struct[] has the delta x, delta y for particular directions */
592 if (scan() != IHREAL) {
594 proutn(_("Direction? "));
595 if (scan()!=IHREAL) {
600 if (aaitem < 0.0 || aaitem > 360.0)
602 co = (aaitem + 22) / 45;
604 ix = game.sector.x + v->x;
605 iy = game.sector.y + v->y;
606 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
609 co = game.quad[ix][iy];
610 printf("%d,%d %c ", ix, iy, co);
612 ix = game.sector.x + v->x;
613 iy = game.sector.y + v->y;
614 if (ix < 0 || ix >= QUADSIZE || iy < 0 || iy >= QUADSIZE)
617 co = game.quad[ix][iy];
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("%c %d,%d\n", co, ix, iy);