|
|
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 provided ! 6: * that: (1) source distributions retain this entire copyright notice and ! 7: * comment, and (2) distributions including binaries display the following ! 8: * acknowledgement: ``This product includes software developed by the ! 9: * University of California, Berkeley and its contributors'' in the ! 10: * documentation or other materials provided with the distribution and in ! 11: * all advertising materials mentioning features or use of this software. ! 12: * Neither the name of the University nor the names of its contributors may ! 13: * be used to endorse or promote products derived from this software without ! 14: * specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 16: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 17: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #ifndef lint ! 21: static char sccsid[] = "@(#)destruct.c 5.5 (Berkeley) 6/1/90"; ! 22: #endif /* not lint */ ! 23: ! 24: # include "trek.h" ! 25: ! 26: /* ! 27: ** Self Destruct Sequence ! 28: ** ! 29: ** The computer starts up the self destruct sequence. Obviously, ! 30: ** if the computer is out nothing can happen. You get a countdown ! 31: ** and a request for password. This must match the password that ! 32: ** you entered at the start of the game. ! 33: ** ! 34: ** You get to destroy things when you blow up; hence, it is ! 35: ** possible to win the game by destructing if you take the last ! 36: ** Klingon with you. ! 37: ** ! 38: ** By the way, the \032 in the message is a ^Z, which is because ! 39: ** the terminal in my office is an ADM-3, which uses that char- ! 40: ** acter to clear the screen. I also stick in a \014 (form feed) ! 41: ** because that clears some other screens. ! 42: ** ! 43: ** Uses trace flag 41 ! 44: */ ! 45: ! 46: destruct() ! 47: { ! 48: char checkpass[15]; ! 49: register int i, j; ! 50: double zap; ! 51: ! 52: if (damaged(COMPUTER)) ! 53: return (out(COMPUTER)); ! 54: printf("\n\07 --- WORKING ---\07\n"); ! 55: sleep(3); ! 56: /* output the count 10 9 8 7 6 */ ! 57: for (i = 10; i > 5; i--) ! 58: { ! 59: for (j = 10; j > i; j--) ! 60: printf(" "); ! 61: printf("%d\n", i); ! 62: sleep(1); ! 63: } ! 64: /* check for password on new line only */ ! 65: skiptonl(0); ! 66: getstrpar("Enter password verification", checkpass, 14, 0); ! 67: sleep(2); ! 68: if (!sequal(checkpass, Game.passwd)) ! 69: return (printf("Self destruct sequence aborted\n")); ! 70: printf("Password verified; self destruct sequence continues:\n"); ! 71: sleep(2); ! 72: /* output count 5 4 3 2 1 0 */ ! 73: for (i = 5; i >= 0; i--) ! 74: { ! 75: sleep(1); ! 76: for (j = 5; j > i; j--) ! 77: printf(" "); ! 78: printf("%d\n", i); ! 79: } ! 80: sleep(2); ! 81: printf("\032\014***** %s destroyed *****\n", Ship.shipname); ! 82: Game.killed = 1; ! 83: /* let's see what we can blow up!!!! */ ! 84: zap = 20.0 * Ship.energy; ! 85: Game.deaths += Ship.crew; ! 86: for (i = 0; i < Etc.nkling; ) ! 87: { ! 88: if (Etc.klingon[i].power * Etc.klingon[i].dist <= zap) ! 89: killk(Etc.klingon[i].x, Etc.klingon[i].y); ! 90: else ! 91: i++; ! 92: } ! 93: /* if we didn't kill the last Klingon (detected by killk), */ ! 94: /* then we lose.... */ ! 95: lose(L_DSTRCT); ! 96: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.