1 /* $NetBSD: abandon.c,v 1.5 1999/09/08 21:45:32 jsm 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 #include <sys/cdefs.h> 37 #ifndef lint 38 #if 0 39 static char sccsid[] = "@(#)abandon.c 8.1 (Berkeley) 5/31/93"; 40 #else 41 __RCSID("$NetBSD: abandon.c,v 1.5 1999/09/08 21:45:32 jsm Exp $"); 42 #endif 43 #endif /* not lint */ 44 45 #include <stdio.h> 46 #include "trek.h" 47 48 /* 49 ** Abandon Ship 50 ** 51 ** The ship is abandoned. If your current ship is the Faire 52 ** Queene, or if your shuttlecraft is dead, you're out of 53 ** luck. You need the shuttlecraft in order for the captain 54 ** (that's you!!) to escape. 55 ** 56 ** Your crew can beam to an inhabited starsystem in the 57 ** quadrant, if there is one and if the transporter is working. 58 ** If there is no inhabited starsystem, or if the transporter 59 ** is out, they are left to die in outer space. 60 ** 61 ** These currently just count as regular deaths, but they 62 ** should count very heavily against you. 63 ** 64 ** If there are no starbases left, you are captured by the 65 ** Klingons, who torture you mercilessly. However, if there 66 ** is at least one starbase, you are returned to the 67 ** Federation in a prisoner of war exchange. Of course, this 68 ** can't happen unless you have taken some prisoners. 69 ** 70 ** Uses trace flag 40 71 */ 72 73 /*ARGSUSED*/ 74 void 75 abandon(v) 76 int v __attribute__((__unused__)); 77 { 78 struct quad *q; 79 int i; 80 int j; 81 struct event *e; 82 83 if (Ship.ship == QUEENE) { 84 printf("You may not abandon ye Faire Queene\n"); 85 return; 86 } 87 if (Ship.cond != DOCKED) 88 { 89 if (damaged(SHUTTLE)) { 90 out(SHUTTLE); 91 return; 92 } 93 printf("Officers escape in shuttlecraft\n"); 94 /* decide on fate of crew */ 95 q = &Quad[Ship.quadx][Ship.quady]; 96 if (q->qsystemname == 0 || damaged(XPORTER)) 97 { 98 printf("Entire crew of %d left to die in outer space\n", 99 Ship.crew); 100 Game.deaths += Ship.crew; 101 } 102 else 103 { 104 printf("Crew beams down to planet %s\n", systemname(q)); 105 } 106 } 107 /* see if you can be exchanged */ 108 if (Now.bases == 0 || Game.captives < 20 * Game.skill) 109 lose(L_CAPTURED); 110 /* re-outfit new ship */ 111 printf("You are hereby put in charge of an antiquated but still\n"); 112 printf(" functional ship, the Fairie Queene.\n"); 113 Ship.ship = QUEENE; 114 Ship.shipname = "Fairie Queene"; 115 Param.energy = Ship.energy = 3000; 116 Param.torped = Ship.torped = 6; 117 Param.shield = Ship.shield = 1250; 118 Ship.shldup = 0; 119 Ship.cloaked = 0; 120 Ship.warp = 5.0; 121 Ship.warp2 = 25.0; 122 Ship.warp3 = 125.0; 123 Ship.cond = GREEN; 124 /* clear out damages on old ship */ 125 for (i = 0; i < MAXEVENTS; i++) 126 { 127 e = &Event[i]; 128 if (e->evcode != E_FIXDV) 129 continue; 130 unschedule(e); 131 } 132 /* get rid of some devices and redistribute probabilities */ 133 i = Param.damprob[SHUTTLE] + Param.damprob[CLOAK]; 134 Param.damprob[SHUTTLE] = Param.damprob[CLOAK] = 0; 135 while (i > 0) 136 for (j = 0; j < NDEV; j++) 137 { 138 if (Param.damprob[j] != 0) 139 { 140 Param.damprob[j] += 1; 141 i--; 142 if (i <= 0) 143 break; 144 } 145 } 146 /* pick a starbase to restart at */ 147 i = ranf(Now.bases); 148 Ship.quadx = Now.base[i].x; 149 Ship.quady = Now.base[i].y; 150 /* setup that quadrant */ 151 while (1) 152 { 153 initquad(1); 154 Sect[Ship.sectx][Ship.secty] = EMPTY; 155 for (i = 0; i < 5; i++) 156 { 157 Ship.sectx = Etc.starbase.x + ranf(3) - 1; 158 if (Ship.sectx < 0 || Ship.sectx >= NSECTS) 159 continue; 160 Ship.secty = Etc.starbase.y + ranf(3) - 1; 161 if (Ship.secty < 0 || Ship.secty >= NSECTS) 162 continue; 163 if (Sect[Ship.sectx][Ship.secty] == EMPTY) 164 { 165 Sect[Ship.sectx][Ship.secty] = QUEENE; 166 dock(0); 167 compkldist(0); 168 return; 169 } 170 } 171 } 172 } 173