abandon.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /* $NetBSD: abandon.c,v 1.6 2003/08/07 09:37:49 agc Exp $ */
  2. /*
  3. * Copyright (c) 1980, 1993
  4. * The Regents of the University of California. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the University nor the names of its contributors
  15. * may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  22. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. */
  30. #include <sys/cdefs.h>
  31. #ifndef lint
  32. #if 0
  33. static char sccsid[] = "@(#)abandon.c 8.1 (Berkeley) 5/31/93";
  34. #else
  35. __RCSID("$NetBSD: abandon.c,v 1.6 2003/08/07 09:37:49 agc Exp $");
  36. #endif
  37. #endif /* not lint */
  38. #include <stdio.h>
  39. #include "trek.h"
  40. /*
  41. ** Abandon Ship
  42. **
  43. ** The ship is abandoned. If your current ship is the Faire
  44. ** Queene, or if your shuttlecraft is dead, you're out of
  45. ** luck. You need the shuttlecraft in order for the captain
  46. ** (that's you!!) to escape.
  47. **
  48. ** Your crew can beam to an inhabited starsystem in the
  49. ** quadrant, if there is one and if the transporter is working.
  50. ** If there is no inhabited starsystem, or if the transporter
  51. ** is out, they are left to die in outer space.
  52. **
  53. ** These currently just count as regular deaths, but they
  54. ** should count very heavily against you.
  55. **
  56. ** If there are no starbases left, you are captured by the
  57. ** Klingons, who torture you mercilessly. However, if there
  58. ** is at least one starbase, you are returned to the
  59. ** Federation in a prisoner of war exchange. Of course, this
  60. ** can't happen unless you have taken some prisoners.
  61. **
  62. ** Uses trace flag 40
  63. */
  64. /*ARGSUSED*/
  65. void
  66. abandon(v)
  67. int v __attribute__((__unused__));
  68. {
  69. struct quad *q;
  70. int i;
  71. int j;
  72. struct event *e;
  73. if (Ship.ship == QUEENE) {
  74. printf("You may not abandon ye Faire Queene\n");
  75. return;
  76. }
  77. if (Ship.cond != DOCKED)
  78. {
  79. if (damaged(SHUTTLE)) {
  80. out(SHUTTLE);
  81. return;
  82. }
  83. printf("Officers escape in shuttlecraft\n");
  84. /* decide on fate of crew */
  85. q = &Quad[Ship.quadx][Ship.quady];
  86. if (q->qsystemname == 0 || damaged(XPORTER))
  87. {
  88. printf("Entire crew of %d left to die in outer space\n",
  89. Ship.crew);
  90. Game.deaths += Ship.crew;
  91. }
  92. else
  93. {
  94. printf("Crew beams down to planet %s\n", systemname(q));
  95. }
  96. }
  97. /* see if you can be exchanged */
  98. if (Now.bases == 0 || Game.captives < 20 * Game.skill)
  99. lose(L_CAPTURED);
  100. /* re-outfit new ship */
  101. printf("You are hereby put in charge of an antiquated but still\n");
  102. printf(" functional ship, the Fairie Queene.\n");
  103. Ship.ship = QUEENE;
  104. Ship.shipname = "Fairie Queene";
  105. Param.energy = Ship.energy = 3000;
  106. Param.torped = Ship.torped = 6;
  107. Param.shield = Ship.shield = 1250;
  108. Ship.shldup = 0;
  109. Ship.cloaked = 0;
  110. Ship.warp = 5.0;
  111. Ship.warp2 = 25.0;
  112. Ship.warp3 = 125.0;
  113. Ship.cond = GREEN;
  114. /* clear out damages on old ship */
  115. for (i = 0; i < MAXEVENTS; i++)
  116. {
  117. e = &Event[i];
  118. if (e->evcode != E_FIXDV)
  119. continue;
  120. unschedule(e);
  121. }
  122. /* get rid of some devices and redistribute probabilities */
  123. i = Param.damprob[SHUTTLE] + Param.damprob[CLOAK];
  124. Param.damprob[SHUTTLE] = Param.damprob[CLOAK] = 0;
  125. while (i > 0)
  126. for (j = 0; j < NDEV; j++)
  127. {
  128. if (Param.damprob[j] != 0)
  129. {
  130. Param.damprob[j] += 1;
  131. i--;
  132. if (i <= 0)
  133. break;
  134. }
  135. }
  136. /* pick a starbase to restart at */
  137. i = ranf(Now.bases);
  138. Ship.quadx = Now.base[i].x;
  139. Ship.quady = Now.base[i].y;
  140. /* setup that quadrant */
  141. while (1)
  142. {
  143. initquad(1);
  144. Sect[Ship.sectx][Ship.secty] = EMPTY;
  145. for (i = 0; i < 5; i++)
  146. {
  147. Ship.sectx = Etc.starbase.x + ranf(3) - 1;
  148. if (Ship.sectx < 0 || Ship.sectx >= NSECTS)
  149. continue;
  150. Ship.secty = Etc.starbase.y + ranf(3) - 1;
  151. if (Ship.secty < 0 || Ship.secty >= NSECTS)
  152. continue;
  153. if (Sect[Ship.sectx][Ship.secty] == EMPTY)
  154. {
  155. Sect[Ship.sectx][Ship.secty] = QUEENE;
  156. dock(0);
  157. compkldist(0);
  158. return;
  159. }
  160. }
  161. }
  162. }