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