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