1 /*
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)abandon.c 8.1 (Berkeley) 05/31/93";
10 #endif /* not lint */
11
12 # include "trek.h"
13
14 /*
15 ** Abandon Ship
16 **
17 ** The ship is abandoned. If your current ship is the Faire
18 ** Queene, or if your shuttlecraft is dead, you're out of
19 ** luck. You need the shuttlecraft in order for the captain
20 ** (that's you!!) to escape.
21 **
22 ** Your crew can beam to an inhabited starsystem in the
23 ** quadrant, if there is one and if the transporter is working.
24 ** If there is no inhabited starsystem, or if the transporter
25 ** is out, they are left to die in outer space.
26 **
27 ** These currently just count as regular deaths, but they
28 ** should count very heavily against you.
29 **
30 ** If there are no starbases left, you are captured by the
31 ** Klingons, who torture you mercilessly. However, if there
32 ** is at least one starbase, you are returned to the
33 ** Federation in a prisoner of war exchange. Of course, this
34 ** can't happen unless you have taken some prisoners.
35 **
36 ** Uses trace flag 40
37 */
38
abandon()39 abandon()
40 {
41 register struct quad *q;
42 register int i;
43 int j;
44 register struct event *e;
45
46 if (Ship.ship == QUEENE)
47 return (printf("You may not abandon ye Faire Queene\n"));
48 if (Ship.cond != DOCKED)
49 {
50 if (damaged(SHUTTLE))
51 return (out(SHUTTLE));
52 printf("Officers escape in shuttlecraft\n");
53 /* decide on fate of crew */
54 q = &Quad[Ship.quadx][Ship.quady];
55 if (q->qsystemname == 0 || damaged(XPORTER))
56 {
57 printf("Entire crew of %d left to die in outer space\n",
58 Ship.crew);
59 Game.deaths += Ship.crew;
60 }
61 else
62 {
63 printf("Crew beams down to planet %s\n", systemname(q));
64 }
65 }
66 /* see if you can be exchanged */
67 if (Now.bases == 0 || Game.captives < 20 * Game.skill)
68 lose(L_CAPTURED);
69 /* re-outfit new ship */
70 printf("You are hereby put in charge of an antiquated but still\n");
71 printf(" functional ship, the Fairie Queene.\n");
72 Ship.ship = QUEENE;
73 Ship.shipname = "Fairie Queene";
74 Param.energy = Ship.energy = 3000;
75 Param.torped = Ship.torped = 6;
76 Param.shield = Ship.shield = 1250;
77 Ship.shldup = 0;
78 Ship.cloaked = 0;
79 Ship.warp = 5.0;
80 Ship.warp2 = 25.0;
81 Ship.warp3 = 125.0;
82 Ship.cond = GREEN;
83 /* clear out damages on old ship */
84 for (i = 0; i < MAXEVENTS; i++)
85 {
86 e = &Event[i];
87 if (e->evcode != E_FIXDV)
88 continue;
89 unschedule(e);
90 }
91 /* get rid of some devices and redistribute probabilities */
92 i = Param.damprob[SHUTTLE] + Param.damprob[CLOAK];
93 Param.damprob[SHUTTLE] = Param.damprob[CLOAK] = 0;
94 while (i > 0)
95 for (j = 0; j < NDEV; j++)
96 {
97 if (Param.damprob[j] != 0)
98 {
99 Param.damprob[j] += 1;
100 i--;
101 if (i <= 0)
102 break;
103 }
104 }
105 /* pick a starbase to restart at */
106 i = ranf(Now.bases);
107 Ship.quadx = Now.base[i].x;
108 Ship.quady = Now.base[i].y;
109 /* setup that quadrant */
110 while (1)
111 {
112 initquad(1);
113 Sect[Ship.sectx][Ship.secty] = EMPTY;
114 for (i = 0; i < 5; i++)
115 {
116 Ship.sectx = Etc.starbase.x + ranf(3) - 1;
117 if (Ship.sectx < 0 || Ship.sectx >= NSECTS)
118 continue;
119 Ship.secty = Etc.starbase.y + ranf(3) - 1;
120 if (Ship.secty < 0 || Ship.secty >= NSECTS)
121 continue;
122 if (Sect[Ship.sectx][Ship.secty] == EMPTY)
123 {
124 Sect[Ship.sectx][Ship.secty] = QUEENE;
125 dock();
126 compkldist(0);
127 return;
128 }
129 }
130 }
131 }
132