Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

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