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