121274Sdist /*
2*60857Sbostic * Copyright (c) 1980, 1993
3*60857Sbostic * The Regents of the University of California. All rights reserved.
434205Sbostic *
542605Sbostic * %sccs.include.redist.c%
621274Sdist */
721274Sdist
811667Smckusick #ifndef lint
9*60857Sbostic static char sccsid[] = "@(#)destruct.c 8.1 (Berkeley) 05/31/93";
1034205Sbostic #endif /* not lint */
1111667Smckusick
1211667Smckusick # include "trek.h"
1311667Smckusick
1411667Smckusick /*
1511667Smckusick ** Self Destruct Sequence
1611667Smckusick **
1711667Smckusick ** The computer starts up the self destruct sequence. Obviously,
1811667Smckusick ** if the computer is out nothing can happen. You get a countdown
1911667Smckusick ** and a request for password. This must match the password that
2011667Smckusick ** you entered at the start of the game.
2111667Smckusick **
2211667Smckusick ** You get to destroy things when you blow up; hence, it is
2311667Smckusick ** possible to win the game by destructing if you take the last
2411667Smckusick ** Klingon with you.
2511667Smckusick **
2611667Smckusick ** By the way, the \032 in the message is a ^Z, which is because
2711667Smckusick ** the terminal in my office is an ADM-3, which uses that char-
2811667Smckusick ** acter to clear the screen. I also stick in a \014 (form feed)
2911667Smckusick ** because that clears some other screens.
3011667Smckusick **
3111667Smckusick ** Uses trace flag 41
3211667Smckusick */
3311667Smckusick
destruct()3411667Smckusick destruct()
3511667Smckusick {
3611667Smckusick char checkpass[15];
3711667Smckusick register int i, j;
3812737Slayer double zap;
3911667Smckusick
4011667Smckusick if (damaged(COMPUTER))
4111667Smckusick return (out(COMPUTER));
4234713Sbostic printf("\n\07 --- WORKING ---\07\n");
4311667Smckusick sleep(3);
4411667Smckusick /* output the count 10 9 8 7 6 */
4511667Smckusick for (i = 10; i > 5; i--)
4611667Smckusick {
4711667Smckusick for (j = 10; j > i; j--)
4811667Smckusick printf(" ");
4911667Smckusick printf("%d\n", i);
5011667Smckusick sleep(1);
5111667Smckusick }
5211667Smckusick /* check for password on new line only */
5311667Smckusick skiptonl(0);
5411667Smckusick getstrpar("Enter password verification", checkpass, 14, 0);
5511667Smckusick sleep(2);
5611667Smckusick if (!sequal(checkpass, Game.passwd))
5711667Smckusick return (printf("Self destruct sequence aborted\n"));
5811667Smckusick printf("Password verified; self destruct sequence continues:\n");
5911667Smckusick sleep(2);
6011667Smckusick /* output count 5 4 3 2 1 0 */
6111667Smckusick for (i = 5; i >= 0; i--)
6211667Smckusick {
6311667Smckusick sleep(1);
6411667Smckusick for (j = 5; j > i; j--)
6511667Smckusick printf(" ");
6611667Smckusick printf("%d\n", i);
6711667Smckusick }
6811667Smckusick sleep(2);
6911667Smckusick printf("\032\014***** %s destroyed *****\n", Ship.shipname);
7011667Smckusick Game.killed = 1;
7111667Smckusick /* let's see what we can blow up!!!! */
7211667Smckusick zap = 20.0 * Ship.energy;
7312344Slayer Game.deaths += Ship.crew;
7411667Smckusick for (i = 0; i < Etc.nkling; )
7511667Smckusick {
7611667Smckusick if (Etc.klingon[i].power * Etc.klingon[i].dist <= zap)
7711667Smckusick killk(Etc.klingon[i].x, Etc.klingon[i].y);
7811667Smckusick else
7912344Slayer i++;
8011667Smckusick }
8111667Smckusick /* if we didn't kill the last Klingon (detected by killk), */
8211667Smckusick /* then we lose.... */
8311667Smckusick lose(L_DSTRCT);
8411667Smckusick }
85