Commit | Line | Data |
---|---|---|
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 | ||
03f9e9f6 | 7 | #ifndef lint |
b6f0a7e4 | 8 | static char sccsid[] = "@(#)autover.c 5.1 (Berkeley) %G%"; |
03f9e9f6 KM |
9 | #endif not lint |
10 | ||
11 | # include "trek.h" | |
12 | ||
13 | /* | |
14 | ** Automatic Override | |
15 | ** | |
16 | ** If we should be so unlucky as to be caught in a quadrant | |
17 | ** with a supernova in it, this routine is called. It is | |
18 | ** called from checkcond(). | |
19 | ** | |
20 | ** It sets you to a random warp (guaranteed to be over 6.0) | |
21 | ** and starts sending you off "somewhere" (whereever that is). | |
22 | ** | |
23 | ** Please note that it is VERY important that you reset your | |
24 | ** warp speed after the automatic override is called. The new | |
25 | ** warp factor does not stay in effect for just this routine. | |
26 | ** | |
27 | ** This routine will never try to send you more than sqrt(2) | |
28 | ** quadrants, since that is all that is needed. | |
29 | */ | |
30 | ||
31 | autover() | |
32 | { | |
06d69904 | 33 | double dist; |
03f9e9f6 KM |
34 | register int course; |
35 | ||
36 | printf("\aRED ALERT: The %s is in a supernova quadrant\n", Ship.shipname); | |
37 | printf("*** Emergency override attempts to hurl %s to safety\n", Ship.shipname); | |
38 | /* let's get our ass out of here */ | |
39 | Ship.warp = 6.0 + 2.0 * franf(); | |
40 | Ship.warp2 = Ship.warp * Ship.warp; | |
41 | Ship.warp3 = Ship.warp2 * Ship.warp; | |
42 | dist = 0.75 * Ship.energy / (Ship.warp3 * (Ship.shldup + 1)); | |
43 | if (dist > 1.4142) | |
44 | dist = 1.4142; | |
45 | course = ranf(360); | |
46 | Etc.nkling = -1; | |
47 | Ship.cond = RED; | |
48 | warp(-1, course, dist); | |
49 | attack(0); | |
50 | } |