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