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