1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 static char sccsid[] = "@(#)autover.c 5.4 (Berkeley) 06/18/88"; 20 #endif /* not lint */ 21 22 # include "trek.h" 23 24 /* 25 ** Automatic Override 26 ** 27 ** If we should be so unlucky as to be caught in a quadrant 28 ** with a supernova in it, this routine is called. It is 29 ** called from checkcond(). 30 ** 31 ** It sets you to a random warp (guaranteed to be over 6.0) 32 ** and starts sending you off "somewhere" (whereever that is). 33 ** 34 ** Please note that it is VERY important that you reset your 35 ** warp speed after the automatic override is called. The new 36 ** warp factor does not stay in effect for just this routine. 37 ** 38 ** This routine will never try to send you more than sqrt(2) 39 ** quadrants, since that is all that is needed. 40 */ 41 42 autover() 43 { 44 double dist; 45 register int course; 46 47 printf("\07RED ALERT: The %s is in a supernova quadrant\n", Ship.shipname); 48 printf("*** Emergency override attempts to hurl %s to safety\n", Ship.shipname); 49 /* let's get our ass out of here */ 50 Ship.warp = 6.0 + 2.0 * franf(); 51 Ship.warp2 = Ship.warp * Ship.warp; 52 Ship.warp3 = Ship.warp2 * Ship.warp; 53 dist = 0.75 * Ship.energy / (Ship.warp3 * (Ship.shldup + 1)); 54 if (dist > 1.4142) 55 dist = 1.4142; 56 course = ranf(360); 57 Etc.nkling = -1; 58 Ship.cond = RED; 59 warp(-1, course, dist); 60 attack(0); 61 } 62