don't overwrite scoreboard if it exists
[unix-history] / usr / src / games / trek / abandon.c
CommitLineData
b6f0a7e4
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
47060859 7#ifndef lint
b6f0a7e4 8static char sccsid[] = "@(#)abandon.c 5.1 (Berkeley) %G%";
47060859
KM
9#endif not lint
10
11# include "trek.h"
12
13/*
14** Abandon Ship
15**
16** The ship is abandoned. If your current ship is the Faire
17** Queene, or if your shuttlecraft is dead, you're out of
18** luck. You need the shuttlecraft in order for the captain
19** (that's you!!) to escape.
20**
21** Your crew can beam to an inhabited starsystem in the
22** quadrant, if there is one and if the transporter is working.
23** If there is no inhabited starsystem, or if the transporter
24** is out, they are left to die in outer space.
25**
26** These currently just count as regular deaths, but they
27** should count very heavily against you.
28**
29** If there are no starbases left, you are captured by the
30** Klingons, who torture you mercilessly. However, if there
31** is at least one starbase, you are returned to the
32** Federation in a prisoner of war exchange. Of course, this
33** can't happen unless you have taken some prisoners.
34**
35** Uses trace flag 40
36*/
37
38abandon()
39{
40 register struct quad *q;
41 register int i;
42 int j;
43 register struct event *e;
44
45 if (Ship.ship == QUEENE)
46 return (printf("You may not abandon ye Faire Queene\n"));
47 if (Ship.cond != DOCKED)
48 {
49 if (damaged(SHUTTLE))
50 return (out(SHUTTLE));
51 printf("Officers escape in shuttlecraft\n");
52 /* decide on fate of crew */
53 q = &Quad[Ship.quadx][Ship.quady];
06d69904 54 if (q->qsystemname == 0 || damaged(XPORTER))
47060859
KM
55 {
56 printf("Entire crew of %d left to die in outer space\n",
57 Ship.crew);
35b95499 58 Game.deaths += Ship.crew;
47060859
KM
59 }
60 else
61 {
62 printf("Crew beams down to planet %s\n", systemname(q));
63 }
64 }
65 /* see if you can be exchanged */
66 if (Now.bases == 0 || Game.captives < 20 * Game.skill)
67 lose(L_CAPTURED);
68 /* re-outfit new ship */
69 printf("You are hereby put in charge of an antiquated but still\n");
70 printf(" functional ship, the Fairie Queene.\n");
71 Ship.ship = QUEENE;
72 Ship.shipname = "Fairie Queene";
73 Param.energy = Ship.energy = 3000;
74 Param.torped = Ship.torped = 6;
75 Param.shield = Ship.shield = 1250;
76 Ship.shldup = 0;
77 Ship.cloaked = 0;
78 Ship.warp = 5.0;
79 Ship.warp2 = 25.0;
80 Ship.warp3 = 125.0;
81 Ship.cond = GREEN;
82 /* clear out damages on old ship */
83 for (i = 0; i < MAXEVENTS; i++)
84 {
85 e = &Event[i];
86 if (e->evcode != E_FIXDV)
87 continue;
88 unschedule(e);
89 }
90 /* get rid of some devices and redistribute probabilities */
91 i = Param.damprob[SHUTTLE] + Param.damprob[CLOAK];
92 Param.damprob[SHUTTLE] = Param.damprob[CLOAK] = 0;
93 while (i > 0)
94 for (j = 0; j < NDEV; j++)
95 {
96 if (Param.damprob[j] != 0)
97 {
35b95499 98 Param.damprob[j] += 1;
06d69904 99 i--;
47060859
KM
100 if (i <= 0)
101 break;
102 }
103 }
104 /* pick a starbase to restart at */
105 i = ranf(Now.bases);
106 Ship.quadx = Now.base[i].x;
107 Ship.quady = Now.base[i].y;
108 /* setup that quadrant */
109 while (1)
110 {
111 initquad(1);
112 Sect[Ship.sectx][Ship.secty] = EMPTY;
113 for (i = 0; i < 5; i++)
114 {
115 Ship.sectx = Etc.starbase.x + ranf(3) - 1;
116 if (Ship.sectx < 0 || Ship.sectx >= NSECTS)
117 continue;
118 Ship.secty = Etc.starbase.y + ranf(3) - 1;
119 if (Ship.secty < 0 || Ship.secty >= NSECTS)
120 continue;
121 if (Sect[Ship.sectx][Ship.secty] == EMPTY)
122 {
123 Sect[Ship.sectx][Ship.secty] = QUEENE;
124 dock();
125 compkldist(0);
126 return;
127 }
128 }
129 }
130}