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