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 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. 11 */ 12 13 #ifndef lint 14 static char sccsid[] = "@(#)destruct.c 5.3 (Berkeley) 06/12/88"; 15 #endif /* not lint */ 16 17 # include "trek.h" 18 19 /* 20 ** Self Destruct Sequence 21 ** 22 ** The computer starts up the self destruct sequence. Obviously, 23 ** if the computer is out nothing can happen. You get a countdown 24 ** and a request for password. This must match the password that 25 ** you entered at the start of the game. 26 ** 27 ** You get to destroy things when you blow up; hence, it is 28 ** possible to win the game by destructing if you take the last 29 ** Klingon with you. 30 ** 31 ** By the way, the \032 in the message is a ^Z, which is because 32 ** the terminal in my office is an ADM-3, which uses that char- 33 ** acter to clear the screen. I also stick in a \014 (form feed) 34 ** because that clears some other screens. 35 ** 36 ** Uses trace flag 41 37 */ 38 39 destruct() 40 { 41 char checkpass[15]; 42 register int i, j; 43 double zap; 44 45 if (damaged(COMPUTER)) 46 return (out(COMPUTER)); 47 printf("\n\07 --- WORKING ---\07\n"); 48 sleep(3); 49 /* output the count 10 9 8 7 6 */ 50 for (i = 10; i > 5; i--) 51 { 52 for (j = 10; j > i; j--) 53 printf(" "); 54 printf("%d\n", i); 55 sleep(1); 56 } 57 /* check for password on new line only */ 58 skiptonl(0); 59 getstrpar("Enter password verification", checkpass, 14, 0); 60 sleep(2); 61 if (!sequal(checkpass, Game.passwd)) 62 return (printf("Self destruct sequence aborted\n")); 63 printf("Password verified; self destruct sequence continues:\n"); 64 sleep(2); 65 /* output count 5 4 3 2 1 0 */ 66 for (i = 5; i >= 0; i--) 67 { 68 sleep(1); 69 for (j = 5; j > i; j--) 70 printf(" "); 71 printf("%d\n", i); 72 } 73 sleep(2); 74 printf("\032\014***** %s destroyed *****\n", Ship.shipname); 75 Game.killed = 1; 76 /* let's see what we can blow up!!!! */ 77 zap = 20.0 * Ship.energy; 78 Game.deaths += Ship.crew; 79 for (i = 0; i < Etc.nkling; ) 80 { 81 if (Etc.klingon[i].power * Etc.klingon[i].dist <= zap) 82 killk(Etc.klingon[i].x, Etc.klingon[i].y); 83 else 84 i++; 85 } 86 /* if we didn't kill the last Klingon (detected by killk), */ 87 /* then we lose.... */ 88 lose(L_DSTRCT); 89 } 90