gettextize and some rough translations
[super-star-trek.git] / src / planets.c
1 #include "sst.h"
2
3 static char *classes[] = {"M","N","O"};
4
5 static int consumeTime(void) 
6 {
7 /* I think most of this avoidance was caused by overlay scheme.
8    Let's see what happens if all events can occur here */
9
10 //  double asave;
11     game.ididit = 1;
12 #if 0
13     /* Don't worry about this */
14     if (future[FTBEAM] <= game.state.date+game.optime && game.state.remcom != 0 && game.condit != IHDOCKED) {
15         /* We are about to be tractor beamed -- operation fails */
16         return 1;
17     }
18 #endif
19 //      asave = future[FSNOVA];
20 //      future[FSNOVA] = FOREVER; /* defer supernovas */
21     events();   /* Used to avoid if future[FSCMOVE] within time */
22 //      future[FSNOVA] = asave;
23     /*fails if game over, quadrant super-novas or we've moved to new quadrant*/
24     if (game.alldone || game.state.galaxy[game.quadx][game.quady].supernova || game.justin != 0) return 1;
25     return 0;
26 }
27
28 void preport(void) 
29 {
30     int iknow = 0, i;
31     skip(1);
32     chew();
33     prout("Spock-  \"Planet report follows, Captain.\"");
34     skip(1);
35     for (i = 0; i < game.inplan; i++) {
36         if ((game.state.plnets[i].known != unknown
37             && game.state.plnets[i].crystals != 0)
38 #ifdef DEBUG
39             || ( game.idebug && game.state.plnets[i].x !=0)
40 #endif
41             ) {
42             iknow = 1;
43 #ifdef DEBUG
44             if (game.idebug && game.state.plnets[i].known==unknown) proutn("(Unknown) ");
45 #endif
46             proutn(cramlc(quadrant, game.state.plnets[i].x, game.state.plnets[i].y));
47             proutn("   class ");
48             proutn(classes[game.state.plnets[i].pclass]);
49             proutn("   ");
50             if (game.state.plnets[i].crystals <= 0) proutn("no ");
51             prout("dilithium crystals present.");
52             if (game.state.plnets[i].known==shuttle_down) 
53                 prout("    Shuttle Craft Galileo on surface.");
54         }
55     }
56     if (iknow==0) prout("No information available.");
57 }
58
59 void orbit(void) 
60 {
61     skip(1);
62     chew();
63     if (game.inorbit!=0) {
64         prout("Already in standard orbit.");
65         return;
66     }
67     if (game.damage[DWARPEN] != 0 && game.damage[DIMPULS] != 0) {
68         prout("Both warp and impulse engines damaged.");
69         return;
70     }
71     if (game.plnetx == 0 || abs(game.sectx-game.plnetx) > 1 || abs(game.secty-game.plnety) > 1) {
72         crmshp();
73         prout(" not adjacent to planet.");
74         skip(1);
75         return;
76     }
77     game.optime = 0.02+0.03*Rand();
78     prout("Helmsman Sulu-  \"Entering standard orbit, Sir.\"");
79     newcnd();
80     if (consumeTime()) return;
81     game.height = (1400.0+7200.0*Rand());
82     prout("Sulu-  \"Entered orbit at altitude %.2f kilometers.\"", game.height);
83     game.inorbit = 1;
84     game.ididit=1;
85 }
86
87 void sensor(void) 
88 {
89     skip(1);
90     chew();
91     if (game.damage[DSRSENS] != 0.0) {
92         prout("Short range sensors damaged.");
93         return;
94     }
95     if (!game.plnetx && (game.options & OPTION_TTY)) {
96         prout("Spock- \"No planet in this quadrant, Captain.\"");
97         return;
98     }
99     if ((game.plnetx != 0)&& (game.state.plnets[game.iplnet].known == unknown)) {
100         prout("Spock-  \"Sensor scan for %s-", cramlc(quadrant, game.quadx, game.quady));
101         skip(1);
102         prout("         Planet at %s is of class %s.", 
103               cramlc(sector, game.plnetx, game.plnety),
104               classes[game.state.plnets[game.iplnet].pclass]);
105         if (game.state.plnets[game.iplnet].known==shuttle_down) 
106             prout("         Sensors show Galileo still on surface.");
107         proutn("         Readings indicate");
108         if (game.state.plnets[game.iplnet].crystals == 0) proutn(" no");
109         prout(" dilithium crystals present.\"");
110         if (game.state.plnets[game.iplnet].known == unknown) game.state.plnets[game.iplnet].known = known;
111     }
112 }
113
114 void beam(void) 
115 {
116     chew();
117     skip(1);
118     if (game.damage[DTRANSP] != 0) {
119         prout("Transporter damaged.");
120         if (game.damage[DSHUTTL]==0 && (game.state.plnets[game.iplnet].known==shuttle_down || game.iscraft == 1)) {
121             skip(1);
122             proutn("Spock-  \"May I suggest the shuttle craft, Sir?\" ");
123             if (ja() != 0) shuttle();
124         }
125         return;
126     }
127     if (game.inorbit==0) {
128         crmshp();
129         prout(" not in standard orbit.");
130         return;
131     }
132     if (game.shldup!=0) {
133         prout("Impossible to transport through shields.");
134         return;
135     }
136     if (game.state.plnets[game.iplnet].known==unknown) {
137         prout("Spock-  \"Captain, we have no information on this planet");
138         prout("  and Starfleet Regulations clearly state that in this situation");
139         prout("  you may not go down.\"");
140         return;
141     }
142     if (game.landed==1) {
143         /* Coming from planet */
144         if (game.state.plnets[game.iplnet].known==shuttle_down) {
145             proutn("Spock-  \"Wouldn't you rather take the Galileo?\" ");
146             if (ja() != 0) {
147                 chew();
148                 return;
149             }
150             prout("Your crew hides the Galileo to prevent capture by aliens.");
151         }
152         prout("Landing party assembled, ready to beam up.");
153         skip(1);
154         prout("Kirk whips out communicator...");
155         prouts("BEEP  BEEP  BEEP");
156         skip(2);
157         prout("\"Kirk to enterprise-  Lock on coordinates...energize.\"");
158     }
159     else {
160         /* Going to planet */
161         if (game.state.plnets[game.iplnet].crystals==0) {
162             prout("Spock-  \"Captain, I fail to see the logic in");
163             prout("  exploring a planet with no dilithium crystals.");
164             proutn("  Are you sure this is wise?\" ");
165             if (ja()==0) {
166                 chew();
167                 return;
168             }
169         }
170         prout("Scotty-  \"Transporter room ready, Sir.\"");
171         skip(1);
172         prout("Kirk, and landing party prepare to beam down to planet surface.");
173         skip(1);
174         prout("Kirk-  \"Energize.\"");
175     }
176     game.ididit=1;
177     skip(1);
178     prouts("WWHOOOIIIIIRRRRREEEE.E.E.  .  .  .  .   .    .");
179     skip(2);
180     if (Rand() > 0.98) {
181         prouts("BOOOIIIOOOIIOOOOIIIOIING . . .");
182         skip(2);
183         prout("Scotty-  \"Oh my God!  I've lost them.\"");
184         finish(FLOST);
185         return;
186     }
187     prouts(".    .   .  .  .  .  .E.E.EEEERRRRRIIIIIOOOHWW");
188     skip(2);
189     prout("Transport complete.");
190     game.landed = -game.landed;
191     if (game.landed==1 && game.state.plnets[game.iplnet].known==shuttle_down) {
192         prout("The shuttle craft Galileo is here!");
193     }
194     if (game.landed!=1 && game.imine==1) {
195         game.icrystl = 1;
196         game.cryprob = 0.05;
197     }
198     game.imine = 0;
199     return;
200 }
201
202 void mine(void) 
203 {
204     skip(1);
205     chew();
206     if (game.landed!= 1) {
207         prout("Mining party not on planet.");
208         return;
209     }
210     if (game.state.plnets[game.iplnet].crystals == MINED) {
211         prout("This planet has already been strip-mined for dilithium.");
212         return;
213     }
214     else if (game.state.plnets[game.iplnet].crystals == 0) {
215         prout("No dilithium crystals on this planet.");
216         return;
217     }
218     if (game.imine == 1) {
219         prout("You've already mined enough crystals for this trip.");
220         return;
221     }
222     if (game.icrystl == 1 && game.cryprob == 0.05) {
223         proutn("With all those fresh crystals aboard the ");
224         crmshp();
225         skip(1);
226         prout("there's no reason to mine more at this time.");
227         return;
228     }
229     game.optime = (0.1+0.2*Rand())*game.state.plnets[game.iplnet].pclass;
230     if (consumeTime()) return;
231     prout("Mining operation complete.");
232     game.state.plnets[game.iplnet].crystals = MINED;
233     game.imine = 1;
234     game.ididit=1;
235 }
236
237 void usecrystals(void) 
238 {
239     game.ididit=0;
240     skip(1);
241     chew();
242     if (game.icrystl!=1) {
243         prout("No dilithium crystals available.");
244         return;
245     }
246     if (game.energy >= 1000) {
247         prout("Spock-  \"Captain, Starfleet Regulations prohibit such an operation");
248         prout("  except when game.condition Yellow exists.");
249         return;
250     }
251     prout("Spock- \"Captain, I must warn you that loading");
252     prout("  raw dilithium crystals into the ship's power");
253     prout("  system may risk a severe explosion.");
254     proutn("  Are you sure this is wise?\" ");
255     if (ja()==0) {
256         chew();
257         return;
258     }
259     skip(1);
260     prout("Engineering Officer Scott-  \"(GULP) Aye Sir.");
261     prout("  Mr. Spock and I will try it.\"");
262     skip(1);
263     prout("Spock-  \"Crystals in place, Sir.");
264     prout("  Ready to activate circuit.\"");
265     skip(1);
266     prouts("Scotty-  \"Keep your fingers crossed, Sir!\"");
267     skip(1);
268     if (Rand() <= game.cryprob) {
269         prouts("  \"Activating now! - - No good!  It's***");
270         skip(2);
271         prouts("***RED ALERT!  RED A*L********************************");
272         skip(1);
273         stars();
274         prouts("******************   KA-BOOM!!!!   *******************");
275         skip(1);
276         kaboom();
277         return;
278     }
279     game.energy += 5000.0*(1.0 + 0.9*Rand());
280     prouts("  \"Activating now! - - ");
281     prout("The instruments");
282     prout("   are going crazy, but I think it's");
283     prout("   going to work!!  Congratulations, Sir!\"");
284     game.cryprob *= 2.0;
285     game.ididit=1;
286 }
287
288 void shuttle(void) 
289 {
290     chew();
291     skip(1);
292     if(game.damage[DSHUTTL] != 0.0) {
293         if (game.damage[DSHUTTL] == -1.0) {
294             if (game.inorbit && game.state.plnets[game.iplnet].known == shuttle_down)
295                 prout("Ye Faerie Queene has no shuttle craft bay to dock it at.");
296             else
297                 prout("Ye Faerie Queene had no shuttle craft.");
298         }
299         else if (game.damage[DSHUTTL] > 0)
300             prout("The Galileo is damaged.");
301         else prout("Shuttle craft is now serving Big Macs.");
302         return;
303     }
304     if (game.inorbit==0) {
305         crmshp();
306         prout(" not in standard orbit.");
307         return;
308     }
309     if ((game.state.plnets[game.iplnet].known != shuttle_down) && game.iscraft != 1) {
310         prout("Shuttle craft not currently available.");
311         return;
312     }
313     if (game.landed==-1 && game.state.plnets[game.iplnet].known==shuttle_down) {
314         prout("You will have to beam down to retrieve the shuttle craft.");
315         return;
316     }
317     if (game.shldup!=0 || game.condit == IHDOCKED) {
318         prout("Shuttle craft cannot pass through shields.");
319         return;
320     }
321     if (game.state.plnets[game.iplnet].known==unknown) {
322         prout("Spock-  \"Captain, we have no information on this planet");
323         prout("  and Starfleet Regulations clearly state that in this situation");
324         prout("  you may not fly down.\"");
325         return;
326     }
327     game.optime = 3.0e-5*game.height;
328     if (game.optime >= 0.8*game.state.remtime) {
329         prout("First Officer Spock-  \"Captain, I compute that such");
330         proutn("  a maneuver would require approximately 2d%% of our",
331                (int)(100*game.optime/game.state.remtime));
332         prout("remaining time.");
333         proutn("Are you sure this is wise?\" ");
334         if (ja()==0) {
335             game.optime = 0.0;
336             return;
337         }
338     }
339     if (game.landed == 1) {
340         /* Kirk on planet */
341         if (game.iscraft==1) {
342             /* Galileo on ship! */
343             if (game.damage[DTRANSP]==0) {
344                 proutn("Spock-  \"Would you rather use the transporter?\" ");
345                 if (ja() != 0) {
346                     beam();
347                     return;
348                 }
349                 proutn("Shuttle crew");
350             }
351             else
352                 proutn("Rescue party");
353             prout(" boards Galileo and swoops toward planet surface.");
354             game.iscraft = 0;
355             skip(1);
356             if (consumeTime()) return;
357             game.state.plnets[game.iplnet].known=shuttle_down;
358             prout("Trip complete.");
359             return;
360         }
361         else {
362             /* Ready to go back to ship */
363             prout("You and your mining party board the");
364             prout("shuttle craft for the trip back to the Enterprise.");
365             skip(1);
366             prout("The short hop begins . . .");
367             game.state.plnets[game.iplnet].known=known;
368             game.icraft = 1;
369             skip(1);
370             game.landed = -1;
371             if (consumeTime()) return;
372             game.iscraft = 1;
373             game.icraft = 0;
374             if (game.imine!=0) {
375                 game.icrystl = 1;
376                 game.cryprob = 0.05;
377             }
378             game.imine = 0;
379             prout("Trip complete.");
380             return;
381         }
382     }
383     else {
384         /* Kirk on ship */
385         /* and so is Galileo */
386         prout("Mining party assembles in the hangar deck,");
387         prout("ready to board the shuttle craft \"Galileo\".");
388         skip(1);
389         prouts("The hangar doors open; the trip begins.");
390         skip(1);
391         game.icraft = 1;
392         game.iscraft = 0;
393         if (consumeTime()) return;
394         game.state.plnets[game.iplnet].known = shuttle_down;
395         game.landed = 1;
396         game.icraft = 0;
397         prout("Trip complete");
398         return;
399     }
400 }
401
402 void deathray(void) 
403 {
404     double dprob, r = Rand();
405         
406     game.ididit = 0;
407     skip(1);
408     chew();
409     if (game.ship != IHE) {
410         prout("Ye Faerie Queene has no death ray.");
411         return;
412     }
413     if (game.nenhere==0) {
414         prout("Sulu-  \"But Sir, there are no enemies in this quadrant.\"");
415         return;
416     }
417     if (game.damage[DDRAY] > 0.0) {
418         prout("Death Ray is damaged.");
419         return;
420     }
421     prout("Spock-  \"Captain, the 'Experimental Death Ray'");
422     prout("  is highly unpredictible.  Considering the alternatives,");
423     proutn("  are you sure this is wise?\" ");
424     if (ja()==0) return;
425     prout("Spock-  \"Acknowledged.\"");
426     skip(1);
427     game.ididit=1;
428     prouts("WHOOEE ... WHOOEE ... WHOOEE ... WHOOEE");
429     skip(1);
430     prout("Crew scrambles in emergency preparation.");
431     prout("Spock and Scotty ready the death ray and");
432     prout("prepare to channel all ship's power to the device.");
433     skip(1);
434     prout("Spock-  \"Preparations complete, sir.\"");
435     prout("Kirk-  \"Engage!\"");
436     skip(1);
437     prouts("WHIRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR");
438     skip(1);
439     dprob = .30;
440     if (game.options & OPTION_PLAIN)
441         dprob = .5;
442     if (r > dprob) {
443         prouts("Sulu- \"Captain!  It's working!\"");
444         skip(2);
445         while (game.nenhere > 0)
446             deadkl(game.kx[1],game.ky[1],game.quad[game.kx[1]][game.ky[1]],game.kx[1],game.ky[1]);
447         prout("Ensign Chekov-  \"Congratulations, Captain!\"");
448         if (KLINGREM == 0) finish(FWON);
449         if ((game.options & OPTION_PLAIN) == 0) {
450             prout("Spock-  \"Captain, I believe the `Experimental Death Ray'");
451             if (Rand() <= 0.05) {
452                 prout("   is still operational.\"");
453             }
454             else {
455                 prout("   has been rendered nonfunctional.\"");
456                 game.damage[DDRAY] = 39.95;
457             }
458         }
459         return;
460     }
461     r = Rand(); // Pick failure method 
462     if (r <= .30) {
463         prouts("Sulu- \"Captain!  It's working!\"");
464         skip(1);
465         prouts("***RED ALERT!  RED ALERT!");
466         skip(1);
467         prout("***MATTER-ANTIMATTER IMPLOSION IMMINENT!");
468         skip(1);
469         prouts("***RED ALERT!  RED A*L********************************");
470         skip(1);
471         stars();
472         prouts("******************   KA-BOOM!!!!   *******************");
473         skip(1);
474         kaboom();
475         return;
476     }
477     if (r <= .55) {
478         prouts("Sulu- \"Captain!  Yagabandaghangrapl, brachriigringlanbla!\"");
479         skip(1);
480         prout("Lt. Uhura-  \"Graaeek!  Graaeek!\"");
481         skip(1);
482         prout("Spock-  \"Fascinating!  . . . All humans aboard");
483         prout("  have apparently been transformed into strange mutations.");
484         prout("  Vulcans do not seem to be affected.");
485         skip(1);
486         prout("Kirk-  \"Raauch!  Raauch!\"");
487         finish(FDRAY);
488         return;
489     }
490     if (r <= 0.75) {
491         int i,j;
492         prouts("Sulu- \"Captain!  It's   --WHAT?!?!\"");
493         skip(2);
494         proutn("Spock-  \"I believe the word is");
495         prouts(" *ASTONISHING*");
496         prout(" Mr. Sulu.");
497         for_sectors(i)
498             for_sectors(j)
499                 if (game.quad[i][j] == IHDOT) game.quad[i][j] = IHQUEST;
500         prout("  Captain, our quadrant is now infested with");
501         prouts(" - - - - - -  *THINGS*.");
502         skip(1);
503         prout("  I have no logical explanation.\"");
504         return;
505     }
506     prouts("Sulu- \"Captain!  The Death Ray is creating tribbles!\"");
507     skip(1);
508     prout("Scotty-  \"There are so many tribbles down here");
509     prout("  in Engineering, we can't move for 'em, Captain.\"");
510     finish(FTRIBBLE);
511     return;
512 }
513
514 char *systemname(planet *planet)
515 {
516     static char *names[NINHAB] =
517     {
518         /*
519          * This started out life as the BSD Trek inhabited-planets list,
520          * but I used <http://www.memory-alpha.org> to weed out planets
521          * with no references in ST:TOS and to fill it out again to the
522          * required length from "The Worlds of The Federation" list,
523          * <http://memory-alpha.org/en/wiki/The_Worlds_of_the_Federation>.
524          * Some misspellings have been silently corrected.  (To be
525          * fair, there was no Web when Eric Allman did his list.)
526          *
527          * Some planets marked Class G and P here will be displayed as class M
528          * because of the way planets are generated. This is a known bug.
529          */
530         "ERROR",
531         // Added Federation Worlds
532         "Deneva",               /* TOS: "Operation -- Annihilate!" */
533         "Eminiar VII",          /* TOS: "A Taste of Armageddon" */
534         "Hansen's Planet",      /* TOS: "The Galileo Seven" */
535         "Taurus IV",            /* TOS: "The Galileo Seven" (class G) */
536         "Aldebaran III",        /* TOS: "The Deadly Years" */
537         "Vulcan (T'Khasi)",     /* many episodes */
538         "Tellar Prime (Miracht)",       /* TOS: "Journey to Babel" */
539         "Andoria (Fesoan)",     /* several episodes */
540         "Antos IV (Doraphane)", /* TOS: "Whom Gods Destroy", "Who Mourns for Adonais?" */
541         "Catulla (Cendo-Prae)", /* TOS: "The Way to Eden" */
542         "Izar",                 /* TOS: "Whom Gods Destroy" */
543         "Tiburon",              /* TOS: "The Way to Eden" */
544         "Merak II",             /* TOS: "The Cloud Minders" */
545         "Argelius II (Nelphia)",        /* TOS: "Wolf in the Fold" ("IV" in BSD) */
546         "Daran V",              /* TOS: "For the World is Hollow and I Have Touched the Sky" */
547         "Medusa",               /* TOS: "Is There in Truth No Beauty?" */
548         "Coridan (Desotriana)", /* TOS: "Journey to Babel" */
549         "Berengaria IV",        /* TOS: "This Side of Paradise" */
550         "Capella IV (Kohath)",  /* TOS: "Friday's Child" (Class G) */
551         "Gideon",               /* TOS: "The Mark of Gideon" */
552         "Iotia",                /* TOS: "A Piece of the Action" */
553         /* Worlds from BSD Trek */
554         //"Talos IV",           /* TOS: "The Cage" (interdicted world) */
555         "Rigel II",             /* TOS: "Shore Leave" ("III" in BSD) */
556         "Deneb II",             /* TOS: "Wolf in the Fold" ("IV" in BSD) */
557         //"Canopus V",          /* noncanonical */
558         //"Icarus I",           /* noncanonical */
559         //"Prometheus II",      /* noncanonical */
560         //"Omega VII",          /* noncanonical */
561         //"Elysium I",          /* noncanonical */
562         "Scalos IV",            /* TOS: "Wink of an Eye" */
563         //"Procyon IV",         /* noncanonical */
564         //"Arachnid I",         /* noncanonical */
565         //"Argo VIII",          /* noncanonical */
566         //"Triad III",          /* noncanonical */
567         //"Echo IV",            /* noncanonical */
568         //"Nimrod III",         /* noncanonical */
569         //"Nemisis IV",         /* noncanonical */
570         //"Centarurus I",       /* noncanonical */
571         //"Kronos III",         /* noncanonical */
572         //"Spectros V",         /* noncanonical */
573         "Beta III",             /* TOS: "The Return of the Archons" */
574         "Gamma Tranguli VI (Vaalel)",   /* TOS: "The Apple" */
575         "Pyris VII",            /* TOS: "Catspaw" ("III" in BSD) */
576         "Triacus",              /* TOS: "And the Children Shall Lead", */
577         "Marcos XII",           /* TOS: "And the Children Shall Lead", */
578         //"Kaland",             /* noncanonical */
579         "Ardana",               /* TOS: "The Cloud Minders" */
580         //"Stratos",            /* noncanonical */
581         //"Eden",               /* TOS: "The Way to Eden" (in Romulan space) */
582         //"Arrikis",            /* noncanonical */
583         //"Epsilon Eridani IV", /* noncanonical */
584         "Exo III",              /* TOS: "What Are Little Girls Made Of?" (Class P) */
585     };
586
587     return names[planet->inhabited];
588 }