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