9 int c_printf (char *format, ... )
11 char buffer[BUFSIZ]; /* Well, BUFSIZ is from ncurses... */
13 va_start(argp,format);
14 vsprintf(buffer,format,argp);
16 return waddstr(conio_scr,buffer);
19 #define c_printf proutn
22 void attakreport(int l) {
24 if (game.future[FCDBAS] < 1e30) {
25 prout("Starbase in %s is currently under Commander attack.",
26 cramlc(quadrant, batx, baty));
27 prout("It can hold out until Stardate %d.",
28 (int)game.future[FCDBAS]);
31 prout("Starbase in %s is under Super-commander attack.",
32 cramlc(quadrant, game.state.isx, game.state.isy));
33 prout("It can hold out until Stardate %d.",
34 (int)game.future[FSCDBAS]);
37 if (game.future[FCDBAS] < 1e30)
38 proutn("Base in %i - %i attacked by C. Alive until %.1f", batx, baty, game.future[FCDBAS]);
40 proutn("Base in %i - %i attacked by S. Alive until %.1f", game.state.isx, game.state.isy, game.future[FSCDBAS]);
52 s1 = (thawed?"thawed ":"");
54 case 1: s2="short"; break;
55 case 2: s2="medium"; break;
56 case 4: s2="long"; break;
57 default: s2="unknown length"; break;
60 case 1: s3="novice"; break;
61 case 2: s3="fair"; break;
62 case 3: s3="good"; break;
63 case 4: s3="expert"; break;
64 case 5: s3="emeritus"; break;
65 default: s3="skilled"; break;
68 prout("You %s playing a %s%s %s game.",
69 alldone? "were": "are now", s1, s2, s3);
70 if (skill>3 && thawed && !alldone) prout("No plaque is allowed.");
71 if (tourn) prout("This is tournament game %d.", tourn);
72 prout("Your secret password is \"%s\"",game.passwd);
73 proutn("%d of %d Klingons have been killed",
74 game.state.killk+game.state.killc+game.state.nsckill, inkling);
75 if (game.state.killc) prout(", including %d Commander%s.", game.state.killc, game.state.killc==1?"":"s");
76 else if (game.state.killk+game.state.nsckill > 0) prout(", but no Commanders.");
78 if (skill > 2) prout("The Super Commander has %sbeen destroyed.",
79 game.state.nscrem?"not ":"");
80 if (game.state.rembase != inbase) {
82 if (inbase-game.state.rembase==1) proutn("has been 1 base");
84 proutn("have been %d bases", inbase-game.state.rembase);
86 prout(" destroyed, %d remaining.", game.state.rembase);
88 else prout("There are %d bases.", inbase);
89 if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED || iseenit) {
90 /* Don't report this if not seen and
91 either the radio is dead or not at base! */
95 if (casual) prout("%d casualt%s suffered so far.",
96 casual, casual==1? "y" : "ies");
97 if (nhelp) prout("There were %d call%s for help.",
98 nhelp, nhelp==1 ? "" : "s");
101 if (nprobes) proutn("%d", nprobes);
103 proutn(" deep space probe");
104 if (nprobes!=1) proutn("s");
107 if ((game.damage[DRADIO] == 0.0 || condit == IHDOCKED)&&
108 game.future[FDSPROB] != 1e30) {
110 proutn("An armed deep space probe is in");
112 proutn("A deep space probe is in");
113 proutn(cramlc(quadrant, probecx, probecy));
118 prout("Dilithium crystals aboard ship... not yet used.");
122 while (cryprob > ai) {
126 prout("Dilithium crystals have been used %d time%s.",
136 if (game.damage[DLRSENS] != 0.0) {
137 /* Now allow base's sensors if docked */
138 if (condit != IHDOCKED) {
139 prout("LONG-RANGE SENSORS DAMAGED.");
142 proutn("Starbase's long-range scan");
145 prout("Long-range scan");
147 for (x = quadx-1; x <= quadx+1; x++) {
149 for (y = quady-1; y <= quady+1; y++) {
150 if (x == 0 || x > 8 || y == 0 || y > 8)
153 if (game.state.galaxy[x][y]<1000) proutn(" %3d", game.state.galaxy[x][y]);
155 game.starch[x][y] = game.damage[DRADIO] > 0 ? game.state.galaxy[x][y]+1000 : 1;
166 for (i = 1; i <= NDEVICES; i++) {
167 if (game.damage[i] > 0.0) {
169 prout("DEVICE -REPAIR TIMES-");
170 prout(" IN FLIGHT DOCKED");
173 prout(" %16s %8.2f %8.2f",
176 docfac*game.damage[i]+0.005);
179 if (!jdam) prout("All devices functional.");
186 if (stdamtim != 1e30 && stdamtim != game.state.date && condit == IHDOCKED) {
187 c_printf("Spock- \"I revised the Star Chart from the starbase's records.\"\n\r");
189 if (nn == 0) c_printf(" STAR CHART FOR THE KNOWN GALAXY\n\r");
190 if (stdamtim != 1e30) {
191 if (condit == IHDOCKED) {
192 /* We are docked, so restore chart from base information */
193 stdamtim = game.state.date;
194 for (i=1; i <= 8 ; i++)
195 for (j=1; j <= 8; j++)
196 if (game.starch[i][j] == 1) game.starch[i][j] = game.state.galaxy[i][j]+1000;
199 proutn("(Last surveillance update %d stardates ago.",
200 (int)(game.state.date-stdamtim));
204 prout(" 1 2 3 4 5 6 7 8");
205 for (i = 1; i <= 8; i++) {
207 for (j = 1; j <= 8; j++) {
210 if (game.starch[i][j] < 0)
212 else if (game.starch[i][j] == 0)
214 else if (game.starch[i][j] > 999)
215 if ((i==quadx)&&(j==quady)){
217 gotoxy(wherex()-1,wherey());
219 if (game.starch[i][i]<2000)
220 sprintf(buf, "%03d", game.starch[i][j]-1000);
225 if (game.starch[i][j]<2000)
226 sprintf(buf, "%03d", game.starch[i][j]-1000);
229 else if ((i==quadx)&&(j==quady)){
231 gotoxy(wherex()-1,wherey());
233 sprintf(buf, "%03d", game.state.galaxy[i][j]);
235 else if (game.state.galaxy[i][j]>=1000)
238 sprintf(buf, "%03d", game.state.galaxy[i][j]);
239 for (cp = buf; cp < buf + sizeof(buf); cp++)
245 if (i<8) c_printf("\n\r");
248 proutn(""); /* flush output */
257 int leftside=TRUE, rightside=TRUE, i, j, jj, k=0, nn=FALSE, t, dam=0;
261 if (game.damage[DSRSENS] != 0) {
262 /* Allow base's sensors if docked */
263 if (condit != IHDOCKED) {
264 prout(" S.R. SENSORS DAMAGED!");
268 prout(" [Using Base's sensors]");
270 else c_printf(" Short-range scan\n\r");
271 if (goodScan) game.starch[quadx][quady] = game.damage[DRADIO]>0.0 ? game.state.galaxy[quadx][quady]+1000:1;
273 if (isit("chart")) nn = TRUE;
276 c_printf(" 1 2 3 4 5 6 7 8 9 10\n\r");
286 if (condit != IHDOCKED) newcnd();
287 for (i = 1; i <= 10; i++) {
291 for (j = 1; j <= 10; j++) {
292 if (goodScan || (abs(i-sectx)<= 1 && abs(j-secty) <= 1)){
293 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)){
295 case IHRED: textcolor(RED); break;
296 case IHGREEN: textcolor(GREEN); break;
297 case IHYELLOW: textcolor(YELLOW); break;
298 case IHDOCKED: textcolor(LIGHTGRAY); break;
299 case IHDEAD: textcolor(WHITE);
302 if (game.quad[i][j]!=ship) highvideo();
306 if (game.quad[i][j] & 128) highvideo();
308 c_printf("%c ",game.quad[i][j] & 127);
309 textcolor(LIGHTGRAY);
318 proutn("Stardate %.1f, Time Left %.2f", game.state.date, game.state.remtime);
321 if (condit != IHDOCKED) newcnd();
323 case IHRED: cp = "RED"; break;
324 case IHGREEN: cp = "GREEN"; break;
325 case IHYELLOW: cp = "YELLOW"; break;
326 case IHDOCKED: cp = "DOCKED"; break;
327 case IHDEAD: cp="DEAD"; break;
329 for (t=0;t<=NDEVICES;t++)
330 if (game.damage[t]>0) dam++;
331 proutn("Condition %s, %i DAMAGES", cp, dam);
334 proutn("Position %d - %d , %d - %d",
335 quadx, quady, sectx, secty);
338 proutn("Life Support ");
339 if (game.damage[DLIFSUP] != 0.0) {
340 if (condit == IHDOCKED)
341 proutn("DAMAGED, Base provides");
343 proutn("DAMAGED, reserves=%4.2f", lsupres);
349 proutn("Warp Factor %.1f", warpfac);
352 proutn("Energy %.2f", energy);
355 proutn("Torpedoes %d", torps);
359 if (game.damage[DSHIELD] != 0)
365 proutn(" %d%% %.1f units",
366 (int)((100.0*shield)/inshld + 0.5), shield);
369 proutn("Klingons Left %d", game.state.remkl);
376 if (i<10) c_printf("\n\r");
377 if (k!=0) return(goodScan);
390 int ix1, ix2, iy1, iy2, prompt=FALSE;
392 double ttime, twarp, tpower;
393 if (game.damage[DCOMPTR] != 0.0) {
394 prout("COMPUTER DAMAGED, USE A POCKET CALCULATOR.");
398 if (scan() != IHREAL) {
401 proutn("Destination quadrant and/or sector? ");
402 if (scan()!=IHREAL) {
408 if (scan() != IHREAL) {
413 if (scan() == IHREAL) {
415 if (scan() != IHREAL) {
422 if (quady>ix1) ix2 = 1;
424 if (quadx>iy1) iy2 = 1;
428 if (ix1 > 8 || ix1 < 1 || iy1 > 8 || iy1 < 1 ||
429 ix2 > 10 || ix2 < 1 || iy2 > 10 || iy2 < 1) {
433 dist = sqrt(square(iy1-quadx+0.1*(iy2-sectx))+
434 square(ix1-quady+0.1*(ix2-secty)));
437 if (prompt) prout("Answer \"no\" if you don't know the value:");
440 proutn("Time or arrival date? ");
441 if (scan()==IHREAL) {
443 if (ttime > game.state.date) ttime -= game.state.date; // Actually a star date
444 if (ttime <= 1e-10 ||
445 (twarp=(floor(sqrt((10.0*dist)/ttime)*10.0)+1.0)/10.0) > 10) {
446 prout("We'll never make it, sir.");
450 if (twarp < 1.0) twarp = 1.0;
454 proutn("Warp factor? ");
455 if (scan()== IHREAL) {
458 if (twarp<1.0 || twarp > 10.0) {
464 prout("Captain, certainly you can give me one of these.");
468 ttime = (10.0*dist)/square(twarp);
469 tpower = dist*twarp*twarp*twarp*(shldup+1);
470 if (tpower >= energy) {
471 prout("Insufficient energy, sir.");
472 if (shldup==0 || tpower > energy*2.0) {
474 proutn("New warp factor to try? ");
475 if (scan() == IHREAL) {
478 if (twarp<1.0 || twarp > 10.0) {
490 prout("But if you lower your shields,");
496 prout(" energy will be %.2f.", energy-tpower);
498 prout("And we will arrive at stardate %.2f.",
499 game.state.date+ttime);
502 prout("Any warp speed is adequate.");
504 prout("Minimum warp needed is %.2f,", twarp);
505 prout("and we will arrive at stardate %.2f.",
506 game.state.date+ttime);
508 if (game.state.remtime < ttime)
509 prout("Unfortunately, the Federation will be destroyed by then.");
511 prout("You'll be taking risks at that speed, Captain");
512 if ((isatb==1 && game.state.isy == ix1 && game.state.isx == iy1 &&
513 game.future[FSCDBAS]< ttime+game.state.date)||
514 (game.future[FCDBAS]<ttime+game.state.date && baty==ix1 && batx == iy1))
515 prout("The starbase there will be destroyed by then.");
516 proutn("New warp factor to try? ");
517 if (scan() == IHREAL) {
520 if (twarp<1.0 || twarp > 10.0) {