Commit | Line | Data |
---|---|---|
b6f0a7e4 DF |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
e9fb6bea KB |
3 | * All rights reserved. |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
6 | * provided that this notice is preserved and that due credit is given | |
7 | * to the University of California at Berkeley. The name of the University | |
8 | * may not be used to endorse or promote products derived from this | |
9 | * software without specific prior written permission. This software | |
10 | * is provided ``as is'' without express or implied warranty. | |
b6f0a7e4 DF |
11 | */ |
12 | ||
03f9e9f6 | 13 | #ifndef lint |
5b8cd1f5 | 14 | static char sccsid[] = "@(#)autover.c 5.3 (Berkeley) %G%"; |
e9fb6bea | 15 | #endif /* not lint */ |
03f9e9f6 KM |
16 | |
17 | # include "trek.h" | |
18 | ||
19 | /* | |
20 | ** Automatic Override | |
21 | ** | |
22 | ** If we should be so unlucky as to be caught in a quadrant | |
23 | ** with a supernova in it, this routine is called. It is | |
24 | ** called from checkcond(). | |
25 | ** | |
26 | ** It sets you to a random warp (guaranteed to be over 6.0) | |
27 | ** and starts sending you off "somewhere" (whereever that is). | |
28 | ** | |
29 | ** Please note that it is VERY important that you reset your | |
30 | ** warp speed after the automatic override is called. The new | |
31 | ** warp factor does not stay in effect for just this routine. | |
32 | ** | |
33 | ** This routine will never try to send you more than sqrt(2) | |
34 | ** quadrants, since that is all that is needed. | |
35 | */ | |
36 | ||
37 | autover() | |
38 | { | |
06d69904 | 39 | double dist; |
03f9e9f6 KM |
40 | register int course; |
41 | ||
5b8cd1f5 | 42 | printf("\07RED ALERT: The %s is in a supernova quadrant\n", Ship.shipname); |
03f9e9f6 KM |
43 | printf("*** Emergency override attempts to hurl %s to safety\n", Ship.shipname); |
44 | /* let's get our ass out of here */ | |
45 | Ship.warp = 6.0 + 2.0 * franf(); | |
46 | Ship.warp2 = Ship.warp * Ship.warp; | |
47 | Ship.warp3 = Ship.warp2 * Ship.warp; | |
48 | dist = 0.75 * Ship.energy / (Ship.warp3 * (Ship.shldup + 1)); | |
49 | if (dist > 1.4142) | |
50 | dist = 1.4142; | |
51 | course = ranf(360); | |
52 | Etc.nkling = -1; | |
53 | Ship.cond = RED; | |
54 | warp(-1, course, dist); | |
55 | attack(0); | |
56 | } |