1 #include "sst.h"\r
2 \r
3 static int height;\r
4 \r
5 static char *classes[] = {"M","N","O"};\r
6 \r
7 static int consumeTime(void) {\r
8 /* I think most of this avoidance was caused by overlay scheme.\r
9    Let's see what happens if all events can occur here */\r
10 \r
11 //      double asave;\r
12         ididit = 1;\r
13 #if 0\r
14         /* Don't wory about this */\r
15         if (future[FTBEAM] <= game.state.date+Time && game.state.remcom != 0 && condit != IHDOCKED) {\r
16                 /* We are about to be tractor beamed -- operation fails */\r
17                 return 1;\r
18         }\r
19 #endif\r
20 //      asave = future[FSNOVA];\r
21 //      future[FSNOVA] = 1e30; /* defer supernovas */\r
22         events();       /* Used to avoid if future[FSCMOVE] within time */\r
23 //      future[FSNOVA] = asave;\r
24         /*fails if game over, quadrant super-novas or we've moved to new quadrant*/\r
25         if (alldone || game.state.galaxy[quadx][quady] == 1000 || justin != 0) return 1;\r
26         return 0;\r
27 }\r
28 \r
29 void preport(void) {\r
30         int iknow = 0, i;\r
31         skip(1);\r
32         chew();\r
33         prout("Spock-  \"Planet report follows, Captain.\"");\r
34         skip(1);\r
35         for (i = 0; i < inplan; i++) {\r
36                 if (game.state.plnets[i].known != unknown\r
37 #ifdef DEBUG\r
38                         || ( idebug && game.state.plnets[i].x !=0)\r
39 #endif\r
40                         ) {\r
41                         iknow = 1;\r
42 #ifdef DEBUG\r
43                         if (idebug && game.state.plnets[i].known==unknown) proutn("(Unknown) ");\r
44 #endif\r
46                         proutn("   class ");\r
47                         proutn(classes[game.state.plnets[i].pclass]);\r
48                         proutn("   ");\r
49                         if (game.state.plnets[i].crystals == 0) proutn("no ");\r
50                         prout("dilithium crystals present.");\r
51                         if (game.state.plnets[i].known==shuttle_down) \r
52                                 prout("    Shuttle Craft Galileo on surface.");\r
53                 }\r
54         }\r
55         if (iknow==0) prout("No information available.");\r
56 }\r
57 \r
58 void orbit(void) {\r
59         double asave;\r
60 \r
61         skip(1);\r
62         chew();\r
63         ididit=0;\r
64         if (inorbit!=0) {\r
66                 return;\r
67         }\r
68         if (game.damage[DWARPEN] != 0 && game.damage[DIMPULS] != 0) {\r
69                 prout("Both warp and impulse engines damaged.");\r
70                 return;\r
71         }\r
72         if (plnetx == 0 || abs(sectx-plnetx) > 1 || abs(secty-plnety) > 1) {\r
73                 crmshp();\r
74                 prout(" not adjacient to planet.\n");\r
75                 return;\r
76         }\r
77         Time = 0.02+0.03*Rand();\r
78         prout("Helmsman Sulu-  \"Entering standard orbit, Sir.\"");\r
79         newcnd();\r
80         if (consumeTime()) return;\r
81         height = (1400.+7200.*Rand());\r
82         prout("Sulu-  \"Entered orbit at altitude %.2f kilometers.\"", height);\r
83         inorbit = 1;\r
84         return;\r
85 }\r
86 \r
87 void sensor(void) {\r
88         skip(1);\r
89         chew();\r
90         if (game.damage[DSRSENS] != 0.0) {\r
91                 prout("Short range sensors damaged.");\r
92                 return;\r
93         }\r
94         if (plnetx == 0) {\r
95                 prout("No planet in this quadrant.");\r
96                 return;\r
97         }\r
99         skip(1);\r
100         prout("         Planet at %s is of class %s.", \r
101                cramlc(sector, plnetx, plnety),\r
102                classes[game.state.plnets[iplnet].pclass]);\r
103         if (game.state.plnets[iplnet].known==shuttle_down) \r
104                 prout("         Sensors show Galileo still on surface.");\r
106         if (game.state.plnets[iplnet].crystals == 0) proutn(" no");\r
107         prout(" dilithium crystals present.\"");\r
108         if (game.state.plnets[iplnet].known == unknown) game.state.plnets[iplnet].known = known;\r
109         return;\r
110 }\r
111 \r
112 void beam(void) {\r
113         chew();\r
114         skip(1);\r
115         if (game.damage[DTRANSP] != 0) {\r
116                 prout("Transporter damaged.");\r
117                 if (game.damage[DSHUTTL]==0 && (game.state.plnets[iplnet].known==shuttle_down || iscraft == 1)) {\r
118                         skip(1);\r
119                         prout("Spock-  \"May I suggest the shuttle craft, Sir?\" ");\r
120                         if (ja() != 0) shuttle();\r
121                 }\r
122                 return;\r
123         }\r
124         if (inorbit==0) {\r
125                 crmshp();\r
126                 prout(" not in standard orbit.");\r
127                 return;\r
128         }\r
129         if (shldup!=0) {\r
130                 prout("Impossible to transport through shields.");\r
131                 return;\r
132         }\r
133         if (game.state.plnets[iplnet].known==unknown) {\r
134                 prout("Spock-  \"Captain, we have no information on this planet");\r
135                 prout("  and Starfleet Regulations clearly state that in this situation");\r
136                 prout("  you may not go down.\"");\r
137                 return;\r
138         }\r
139         if (landed==1) {\r
140                 /* Coming from planet */\r
141                 if (game.state.plnets[iplnet].known==shuttle_down) {\r
142                         proutn("Spock-  \"Wouldn't you rather take the Galileo?\" ");\r
143                         if (ja() != 0) {\r
144                                 chew();\r
145                                 return;\r
146                         }\r
147                         prout("Your crew hides the Galileo to prevent capture by aliens.");\r
148                 }\r
149                 prout("Landing party assembled, ready to beam up.");\r
150                 skip(1);\r
151                 prout("Kirk whips out communicator...");\r
152                 prouts("BEEP  BEEP  BEEP");\r
153                 skip(2);\r
154                 prout("\"Kirk to enterprise-  Lock on coordinates...energize.\"");\r
155         }\r
156         else {\r
157                 /* Going to planet */\r
158                 if (game.state.plnets[iplnet].crystals==0) {\r
159                         prout("Spock-  \"Captain, I fail to see the logic in");\r
160                         prout("  exploring a planet with no dilithium crystals.");\r
161                         proutn("  Are you sure this is wise?\" ");\r
162                         if (ja()==0) {\r
163                                 chew();\r
164                                 return;\r
165                         }\r
166                 }\r
167                 prout("Scotty-  \"Transporter room ready, Sir.\"");\r
168                 skip(1);\r
169                 prout("Kirk, and landing party prepare to beam down to planet surface.");\r
170                 skip(1);\r
171                 prout("Kirk-  \"Energize.\"");\r
172         }\r
173         skip(1);\r
174         prouts("WWHOOOIIIIIRRRRREEEE.E.E.  .  .  .  .   .    .");\r
175         skip(2);\r
176         if (Rand() > 0.98) {\r
177                 prouts("BOOOIIIOOOIIOOOOIIIOIING . . .");\r
178                 skip(2);\r
179                 prout("Scotty-  \"Oh my God!  I've lost them.\"");\r
180                 finish(FLOST);\r
181                 return;\r
182         }\r
183         prouts(".    .   .  .  .  .  .E.E.EEEERRRRRIIIIIOOOHWW");\r
184         skip(2);\r
185         prout("Transport complete.");\r
186         landed = -landed;\r
187         if (landed==1 && game.state.plnets[iplnet].known==shuttle_down) {\r
188                 prout("The shuttle craft Galileo is here!");\r
189         }\r
190         if (landed!=1 && imine==1) {\r
191                 icrystl = 1;\r
192                 cryprob = 0.05;\r
193         }\r
194         imine = 0;\r
195         return;\r
196 }\r
197 \r
198 void mine(void) {\r
199 \r
200         ididit = 0;\r
201         skip(1);\r
202         chew();\r
203         if (landed!= 1) {\r
204                 prout("Mining party not on planet.");\r
205                 return;\r
206         }\r
207         if (game.state.plnets[iplnet].crystals == 0) {\r
208                 prout("No dilithium crystals on this planet.");\r
209                 return;\r
210         }\r
211         if (imine == 1) {\r
212                 prout("You've already mined enough crystals for this trip.");\r
213                 return;\r
214         }\r
215         if (icrystl == 1 && cryprob == 0.05) {\r
216                 proutn("With all those fresh crystals aboard the ");\r
217                 crmshp();\r
218                 skip(1);\r
219                 prout("there's no reason to mine more at this time.");\r
220                 return;\r
221         }\r
222         Time = (0.1+0.2*Rand())*game.state.plnets[iplnet].pclass;\r
223         if (consumeTime()) return;\r
224         prout("Mining operation complete.");\r
225         imine = 1;\r
226         return;\r
227 }\r
228 \r
229 void usecrystals(void) {\r
230 \r
231         skip(1);\r
232         chew();\r
233         if (icrystl!=1) {\r
234                 prout("No dilithium crystals available.");\r
235                 return;\r
236         }\r
237         if (energy >= 1000) {\r
238                 prout("Spock-  \"Captain, Starfleet Regulations prohibit such an operation");\r
239                 prout("  except when condition Yellow exists.");\r
240                 return;\r
241         }\r
243         prout("  raw dilithium crystals into the ship's power");\r
244         prout("  system may risk a severe explosion.");\r
245         proutn("  Are you sure this is wise?\" ");\r
246         if (ja()==0) {\r
247                 chew();\r
248                 return;\r
249         }\r
250         skip(1);\r
251         prout("Engineering Officer Scott-  \"(GULP) Aye Sir.");\r
252         prout("  Mr. Spock and I will try it.\"");\r
253         skip(1);\r
254         prout("Spock-  \"Crystals in place, Sir.");\r
255         prout("  Ready to activate circuit.\"");\r
256         skip(1);\r
257         prouts("Scotty-  \"Keep your fingers crossed, Sir!\"");\r
258         skip(1);\r
259         if (Rand() <= cryprob) {\r
260                 prouts("  \"Activating now! - - No good!  It's***");\r
261                 skip(2);\r
263                 skip(1);\r
264                 stars();\r
265                 prouts("******************   KA-BOOM!!!!   *******************");\r
266                 skip(1);\r
267                 kaboom();\r
268                 return;\r
269         }\r
270         energy += 5000.0*(1.0 + 0.9*Rand());\r
271         prouts("  \"Activating now! - - ");\r
272         prout("The instruments");\r
273         prout("   are going crazy, but I think it's");\r
274         prout("   going to work!!  Congratulations, Sir!\"");\r
275         cryprob *= 2.0;\r
276         return;\r
277 }\r
278 \r
279 void shuttle(void) {\r
280 \r
281         chew();\r
282         skip(1);\r
283         ididit = 0;\r
284         if(game.damage[DSHUTTL] != 0.0) {\r
285                 if (game.damage[DSHUTTL] == -1.0) {\r
286                         if (inorbit && game.state.plnets[iplnet].known == shuttle_down)\r
287                                 prout("Ye Faerie Queene has no shuttle craft bay to dock it at.");\r
288                         else\r
289                                 prout("Ye Faerie Queene had no shuttle craft.");\r
290                 }\r
291                 else if (game.damage[DSHUTTL] > 0)\r
292                         prout("The Galileo is damaged.");\r
293                 else prout("Shuttle craft is now serving Big Macs.");\r
294                 return;\r
295         }\r
296         if (inorbit==0) {\r
297                 crmshp();\r
298                 prout(" not in standard orbit.");\r
299                 return;\r
300         }\r
301         if ((game.state.plnets[iplnet].known != shuttle_down) && iscraft != 1) {\r
302                 prout("Shuttle craft not currently available.");\r
303                 return;\r
304         }\r
305         if (landed==-1 && game.state.plnets[iplnet].known==shuttle_down) {\r
306                 prout("You will have to beam down to retrieve the shuttle craft.");\r
307                 return;\r
308         }\r
309         if (shldup!=0 || condit == IHDOCKED) {\r
310                 prout("Shuttle craft cannot pass through shields.");\r
311                 return;\r
312         }\r
313         if (game.state.plnets[iplnet].known==unknown) {\r
314                 prout("Spock-  \"Captain, we have no information on this planet");\r
315                 prout("  and Starfleet Regulations clearly state that in this situation");\r
316                 prout("  you may not fly down.\"");\r
317                 return;\r
318         }\r
319         Time = 3.0e-5*height;\r
320         if (Time >= 0.8*game.state.remtime) {\r
321                 prout("First Officer Spock-  \"Captain, I compute that such");\r
322                 proutn("  a maneuver would require approximately 2d%% of our",\r
323                       (int)(100*Time/game.state.remtime));\r
324                 prout("remaining time.");\r
325                 prout("Are you sure this is wise?\" ");\r
326                 if (ja()==0) {\r
327                         Time = 0.0;\r
328                         return;\r
329                 }\r
330         }\r
331         if (landed == 1) {\r
332                 /* Kirk on planet */\r
333                 if (iscraft==1) {\r
334                         /* Galileo on ship! */\r
335                         if (game.damage[DTRANSP]==0) {\r
336                                 proutn("Spock-  \"Would you rather use the transporter?\" ");\r
337                                 if (ja() != 0) {\r
338                                         beam();\r
339                                         return;\r
340                                 }\r
341                                 proutn("Shuttle crew");\r
342                         }\r
343                         else\r
344                                 proutn("Rescue party");\r
345                         prout(" boards Galileo and swoops toward planet surface.");\r
346                         iscraft = 0;\r
347                         skip(1);\r
348                         if (consumeTime()) return;\r
349                         game.state.plnets[iplnet].known=shuttle_down;\r
350                         prout("Trip complete.");\r
351                         return;\r
352                 }\r
353                 else {\r
354                         /* Ready to go back to ship */\r
355                         prout("You and your mining party board the");\r
356                         prout("shuttle craft for the trip back to the Enterprise.");\r
357                         skip(1);\r
358                         prout("The short hop begins . . .");\r
359                         game.state.plnets[iplnet].known=known;\r
360                         icraft = 1;\r
361                         skip(1);\r
362                         landed = -1;\r
363                         if (consumeTime()) return;\r
364                         iscraft = 1;\r
365                         icraft = 0;\r
366                         if (imine!=0) {\r
367                                 icrystl = 1;\r
368                                 cryprob = 0.05;\r
369                         }\r
370                         imine = 0;\r
371                         prout("Trip complete.");\r
372                         return;\r
373                 }\r
374         }\r
375         else {\r
376                 /* Kirk on ship */\r
377                 /* and so is Galileo */\r
378                 prout("Mining party assembles in the hangar deck,");\r
379                 prout("ready to board the shuttle craft \"Galileo\".");\r
380                 skip(1);\r
381                 prouts("The hangar doors open; the trip begins.");\r
382                 skip(1);\r
383                 icraft = 1;\r
384                 iscraft = 0;\r
385                 if (consumeTime()) return;\r
386                 game.state.plnets[iplnet].known = shuttle_down;\r
387                 landed = 1;\r
388                 icraft = 0;\r
389                 prout("Trip complete");\r
390                 return;\r
391         }\r
392 }\r
393                 \r
394 \r
395 void deathray(void) {\r
396         double r = Rand();\r
397         \r
398         ididit = 0;\r
399         skip(1);\r
400         chew();\r
401         if (ship != IHE) {\r
402                 prout("Ye Faerie Queene has no death ray.");\r
403                 return;\r
404         }\r
405         if (nenhere==0) {\r
406                 prout("Sulu-  \"But Sir, there are no enemies in this quadrant.\"");\r
407                 return;\r
408         }\r
409         if (game.damage[DDRAY] > 0.0) {\r
410                 prout("Death Ray is damaged.");\r
411                 return;\r
412         }\r
413         prout("Spock-  \"Captain, the 'Experimental Death Ray'");\r
414         prout("  is highly unpredictible.  Considering the alternatives,");\r
415         prout("  are you sure this is wise?\" ");\r
416         if (ja()==0) return;\r
417         prout("Spock-  \"Acknowledged.\"");\r
418         skip(1);\r
419         ididit=1;\r
420         prouts("WHOOEE ... WHOOEE ... WHOOEE ... WHOOEE");\r
421         skip(1);\r
422         prout("Crew scrambles in emergency preparation.");\r
423         prout("Spock and Scotty ready the death ray and");\r
424         prout("prepare to channel all ship's power to the device.");\r
425         skip(1);\r
426         prout("Spock-  \"Preparations complete, sir.\"");\r
427         prout("Kirk-  \"Engage!\"");\r
428         skip(1);\r
429         prouts("WHIRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR");\r
430         skip(1);\r
431         if (r > .30) {\r
432                 prouts("Sulu- \"Captain!  It's working!\"");\r
433                 skip(2);\r
434                 while (nenhere > 0)\r
436                 prout("Ensign Chekov-  \"Congratulations, Captain!\"");\r
437                 if (game.state.remkl == 0) finish(FWON);\r
438                 prout("Spock-  \"Captain, I believe the `Experimental Death Ray'");\r
439                 if (Rand() <= 0.05) {\r
440                         prout("   is still operational.\"");\r
441                 }\r
442                 else {\r
443                         prout("   has been rendered nonfunctional.\"");\r
444                         game.damage[DDRAY] = 39.95;\r
445                 }\r
446                 return;\r
447         }\r
448         r = Rand();     // Pick failure method \r
449         if (r <= .30) {\r
450                 prouts("Sulu- \"Captain!  It's working!\"");\r
451                 skip(1);\r
453                 skip(1);\r
454                 prout("***MATTER-ANTIMATTER IMPLOSION IMMINENT!");\r
455                 skip(1);\r
457                 skip(1);\r
458                 stars();\r
459                 prouts("******************   KA-BOOM!!!!   *******************");\r
460                 skip(1);\r
461                 kaboom();\r
462                 return;\r
463         }\r
464         if (r <= .55) {\r
465                 prouts("Sulu- \"Captain!  Yagabandaghangrapl, brachriigringlanbla!\"");\r
466                 skip(1);\r
467                 prout("Lt. Uhura-  \"Graaeek!  Graaeek!\"");\r
468                 skip(1);\r
469                 prout("Spock-  \"Facinating!  . . . All humans aboard");\r
470                 prout("  have apparently been transformed into strange mutations.");\r
471                 prout("  Vulcans do not seem to be affected.");\r
472                 skip(1);\r
473                 prout("Kirk-  \"Raauch!  Raauch!\"");\r
474                 finish(FDRAY);\r
475                 return;\r
476         }\r
477         if (r <= 0.75) {\r
478                 int i,j;\r
479                 prouts("Sulu- \"Captain!  It's   --WHAT?!?!\"");\r
480                 skip(2);\r
481                 proutn("Spock-  \"I believe the word is");\r
482                 prouts(" *ASTONISHING*");\r
483                 prout(" Mr. Sulu.");\r
484                 for (i=1; i<=10; i++)\r
485                         for (j=1; j<=10; j++)\r