Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ucbvax.ARPA Path: utzoo!watmath!clyde!burl!ulysses!ucbvax!okamoto From: okamoto@ucbvax.ARPA (Doctor Who) Newsgroups: net.sources.games Subject: Trek73 (part 4 of 4) Message-ID: <10402@ucbvax.ARPA> Date: Mon, 16-Sep-85 11:16:05 EDT Article-I.D.: ucbvax.10402 Posted: Mon Sep 16 11:16:05 1985 Date-Received: Wed, 18-Sep-85 02:59:03 EDT Organization: University of California at Berkeley Lines: 1954 # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. -----cut here-----cut here-----cut here-----cut here----- #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # main.c # misc.c # mission.c # moveships.c # options.h # parseopts.c # parsit.c # strat1.c # structs.h # This archive created: Mon Sep 9 12:07:23 1985 echo shar: extracting main.c '(7038 characters)' sed 's/^XX//' << \SHAR_EOF > main.c XX/* XX * TREK73: main.c XX * XX * Originally written (in HP-2000 BASIC) by XX * William K. Char, Perry Lee, and Dan Gee XX * XX * Rewritten in C by XX * Dave Pare (sdcsvax!sdamos!mr-frog) XX * and XX * Christopher Williams (ucbvax!ucbmerlin!williams) XX * XX * Corrected, Completed, and Enhanced by XX * Jeff Okamoto (ucbvax!okamoto) XX * Peter Yee (ucbvax!yee) XX * Matt Dillon (ucbvax!dillon) XX * Dave Sharnoff (ucbvax!ucbcory!muir) XX * and XX * Joel Duisman (ucbvax!duisman) XX * XX * Main Loop XX * XX * main, alarmtrap XX * XX */ XX XX#include "defines.h" XX#include "structs.h" XX#include XX#include XX#include XX#include XX XXint timeout; XXjmp_buf jumpbuf; XXextern char shutup[]; XX XX XXmain() XX{ XX extern char **environ; XX extern struct list *newitem(); XX extern char captain[]; XX extern char title[]; XX extern char foename[]; XX extern char *foeraces[]; XX extern char *foecaps[]; XX extern char *foeshiptype[]; XX extern char foerace[]; XX extern char foestype[]; XX extern int terse; XX extern int silly; XX extern char *feds[]; XX extern char *baddies[MAXFOERACES][MAXBADS]; XX extern struct cmd cmds[]; XX extern struct ship *shiplist[]; XX extern int shipnum; XX extern char shipname[]; XX extern char slots[]; XX struct cmd *scancmd(); XX int alarmtrap(); XX register int i; XX register int j; XX register struct ship *sp; XX register struct list *lp; XX char buf1[30]; XX struct cmd *cp; XX int range; XX float bearing; XX int loop; XX int len; XX int enemynum; XX extern char slots[]; XX char *tmp; XX int swap1; XX int swap2; XX int offset; XX extern int (*strategies[])(); XX extern char *options; XX extern char *getenv(); XX extern char sex[]; XX extern char shipbuf[]; XX extern char science[]; XX extern char engineer[]; XX extern char com[]; XX extern char nav[]; XX extern char helmsman[]; XX extern char racename[]; XX extern int init_p_turn[]; XX extern int init_t_turn[]; XX extern char *foeempire[]; XX extern char empire[]; XX XX signal(SIGALRM, alarmtrap); XX signal(SIGINT, SIG_IGN); XX srandom(time(0)); XX options = getenv("TREK73OPTS"); XX if (options != NULL) { XX parse_opts(options); XX } XX if (strlen(science) == 0) XX strcpy(science, "Spock"); XX if (strlen(engineer) == 0) XX strcpy(engineer, "Scott"); XX if (strlen(com) == 0) XX strcpy(com, "Uhura"); XX if (strlen(nav) == 0) XX strcpy(nav, "Chekov"); XX if (strlen(helmsman) == 0) XX strcpy(helmsman, "Sulu"); XX if (strlen(captain) == 0) { XX printf("\n\nCaptain: my last name is "); XX if (gets(buf1) == NULL || *buf1 == NULL) XX exit(1); XX strcpy (captain, buf1); XX } XX if (*captain == '*') { XX terse = 1; XX len = strlen(captain) + 1; XX for (loop = 1; loop < len; loop++) XX captain[loop-1] = captain[loop]; XX } XX if (strlen(sex) != 0) XX strcpy(buf1,sex); XX else { XX printf("%s: My sex is: ",captain); XX if (gets(buf1) == NULL || *buf1 == NULL) XX exit(1); XX } XX if ((*buf1 <= 'z') && (*buf1 >= 'a')) XX *buf1 = *buf1 - 'a' + 'A'; XX switch(*buf1) { XX case 'M': XX strcpy(title, "Sir"); XX break; XX case 'F': XX strcpy(title, "Ma'am"); XX break; XX default : XX switch (random() % 6) { XX case 0: XX strcpy(title, "Fag"); XX break; XX case 1: XX strcpy(title, "Fairy"); XX break; XX case 2: XX strcpy(title, "Fruit"); XX break; XX case 3: XX strcpy(title, "Weirdo"); XX break; XX case 4: XX strcpy(title, "Gumby"); XX break; XX case 5: XX strcpy(title, "Freak"); XX break; XX } XX } XX if (strlen(shipbuf) != 0) { XX strcpy(buf1,shipbuf); XX } else { XX getships: XX printf(" I'm expecting [1-9] enemy vessels "); XX if (gets(buf1) == NULL || *buf1 == NULL) XX exit(1); XX } XX i = atoi(buf1); XX if (i < 1 || i > 9) { XX printf("%s: %s, Starfleet Command reports that it can only\n", com, title); XX printf(" be from 1 to 9. Try again.\n"); XX printf("%s: Correct, Lieutenant -- just testing your attention..\n", captain); XX goto getships; XX } XX shipnum = i; XX for (loop = 0; loop < shipnum; loop++); XX slots[loop] = 'X'; XX if (strlen(racename) == 0) { XX if (silly == 0) XX offset = 1; XX else XX offset = 0; XX enemynum = randm(MAXFOERACES - offset) - 1; XX } else { XX for (loop=0; loopdata.sp = MKNODE(struct ship, *, 1); XX sp = shiplist[i] = lp->data.sp; XX if (i) XX strcpy(sp->name, baddies[enemynum][i-1]); XX sp->warp = sp->newwarp = 1.0; XX sp->course = sp->newcourse = randm(360); XX sp->eff = .75; XX sp->regen = 10.0; XX sp->energy = 150; XX sp->pods = 200; XX sp->id = i; XX for (j=0; j<4; j++) { XX sp->phasers[j].target = NULL; XX sp->phasers[j].bearing = init_p_turn[j]; XX sp->phasers[j].load = 10; XX sp->phasers[j].drain = 10; XX sp->phasers[j].status = P_NORMAL; XX } XX for (j=0; j<4; j++) { XX sp->shields[j].eff = 1.0; XX sp->shields[j].drain = 0.0; XX sp->shields[j].attemp_drain = 1.0; XX } XX sp->p_spread = 10; XX for (j=0; j<6; j++) { XX sp->tubes[j].target = NULL; XX sp->tubes[j].bearing = init_t_turn[j]; XX sp->tubes[j].load = 0; XX sp->tubes[j].status = T_NORMAL; XX } XX sp->t_lspeed = 12; XX sp->t_prox = 200; XX sp->t_delay = 10; XX sp->p_percent = 100; XX sp->status = S_NORMAL; /* all is well */ XX sp->target = NULL; XX sp->eluding = 0; XX sp->delay = 10000; XX range = 4100 + randm(300) - i * 200; XX bearing = toradians(randm(360)); XX sp->x = range * cos(bearing); XX sp->y = range * sin(bearing); XX sp->crew = 350; XX sp->strategy = strategies[0]; XX } XX /* XX * federation exceptions XX */ XX sp = shiplist[0]; XX sp->course = sp->newcourse = 0; XX sp->eff = 1.0; XX sp->x = sp->y = 0; XX sp->crew = 450; XX if (strlen(shipname) == 0) { XX i = randm(MAXFEDS) - 1; XX strcpy(sp->name, feds[i]); XX } else { XX strcpy(sp->name, shipname); XX } XX for(loop=shipnum+1; loop<300; loop++) XX slots[loop] = ' '; XX mission(); XX warning(); XX setjmp(jumpbuf); XX timeout = 0; XX signal(SIGALRM, alarmtrap); XX alarm(0); XX for (;;) { XX sp = shiplist[0]; XX if (!(sp->status & S_DEAD)) { XX alarm(20); XX for (loop = 0; loop < HIGHSHUTUP; loop++) XX shutup[loop] = 0; XX printf("\n%s: Code [1-30] ", captain); XX if (gets(buf1) != NULL) { XX cp = scancmd(buf1); XX if (cp != NULL) { XX (*cp->routine)(sp); XX if (!cp->turns) XX continue; XX } else XX printf("\n%s: What??\n", science); XX } XX } XX alarm(0); XX alarmtrap(0); XX } XX} XX XXalarmtrap(sig) XXint sig; XX{ XX extern int timeout; XX extern jmp_buf jumpbuf; XX XX if (sig) { XX printf("\n** TIME **\n"); XX stdin->_cnt = 0; XX } XX if (!(shiplist[0]->status & S_DEAD)) XX printf("\n"); XX shiplist[1]->strategy(); XX move_ships(); XX if (sig) { XX timeout = 1; XX longjmp(jumpbuf, 1); XX } XX} SHAR_EOF if test 7038 -ne "`wc -c main.c`" then echo shar: error transmitting main.c '(should have been 7038 characters)' fi echo shar: extracting misc.c '(5106 characters)' sed 's/^XX//' << \SHAR_EOF > misc.c XX/* XX * TREK73: misc.c XX * XX * Miscellaneous Routines XX * XX * help, scancmd, new_slot, return_slot, betw, vowelstr, plural, XX * check_p_damage, check_t_damage, check_p_turn, check_t_turn XX * XX */ XX XX#include "defines.h" XX#include "structs.h" XX#include XX XXint help(dummy) XXstruct ship *dummy; XX{ XX extern struct cmd cmds[]; XX struct cmd *cp; XX int column = 0; XX XX printf("\nTrek84 Commands: \n"); XX printf("Code Command\n\n"); XX for (cp = &cmds[0]; cp->routine != NULL; cp++) { XX printf("%3s: ", cp->word1); XX if (cp->turns == 0) XX printf (" *"); XX else XX printf (" "); XX printf(" %-31s", cp->word2); XX if (column++ & 1) XX puts(""); XX } XX printf("\n\n\n * does not use a turn\n"); XX dummy = dummy; /* LINT */ XX} XX XXstruct cmd *scancmd(buf) XXchar *buf; XX{ XX extern struct cmd cmds[]; XX struct cmd *cp; XX extern char **argp; XX int argnum; XX int first; XX XX argnum = parsit(buf, &argp); XX first = strlen(argp[0]); XX if (argnum && first) { XX for (cp = &cmds[0]; cp->routine != NULL; cp++) { XX if (strncmp(argp[0], cp->word1, first) == 0) XX return (cp); XX } XX } XX return (NULL); XX} XX XX/* XX * This routine handles getting unique identifier numbers for XX * all objects. XX */ XXnew_slot() XX{ XX extern char slots[]; XX extern int shipnum; XX /* XX * This is to make it appear that in a 2-ship duel, for XX * instance, the first object to appear will be numbered XX * as 3. XX */ XX int i = shipnum + 2; XX XX while (slots[i] == 'X') XX i++; XX slots[i] = 'X'; XX return i; XX} XX XX/* XX * This routine handles returning identifiers XX */ XXreturn_slot(i) XXint i; XX{ XX extern char slots[]; XX XX if (slots[i] != 'X') XX printf("FATAL ERROR - Slot already empty!"); XX slots[i] = ' '; XX} XX XXbetw(i, j, k) XXint i, j, k; XX{ XX if ((i > j) && (i < k)) XX return(1); XX else XX return(0); XX} XX XXchar *vowelstr(str) XXchar *str; XX{ XX switch(*str) { XX case 'a': case 'A': XX case 'e': case 'E': XX case 'i': case 'I': XX case 'o': case 'O': XX case 'u': case 'U': XX return "n"; XX default: XX return ""; XX } XX} XX XXchar *plural(i) XXint i; XX{ XX if (i != 1) XX return("s"); XX else XX return(""); XX} XX XX/* XX * This routine takes an array generated from commands 1, 3, and 5 XX * to print out a list of those phasers damaged and unable to XX * either fire, lock, or turn. XX */ XXcheck_p_damage(array, sp, string) XXint array[]; XXstruct ship *sp; XXchar *string; XX{ XX int i, j = 0; XX XX for (i=0; i<4; i++) { XX if ((array[i] != 0) && (sp->phasers[i].status & P_DAMAGED)) { XX if (!j) XX printf("Computer: Phaser(s) %d", i+1); XX else XX printf(", %d", i+1); XX j++; XX } XX } XX if (j) XX printf(" damaged and unable to %s.\n", string); XX} XX XX/* XX * This routine takes an array generated from commands 2, 4, and 6 XX * to print out a list of those tubes damaged and unable to either XX * fire, lock, or turn. XX */ XXcheck_t_damage(array, sp, string) XXint array[]; XXstruct ship *sp; XXchar *string; XX{ XX int i, j = 0; XX XX for (i=0; i<6; i++) { XX if ((array[i] != 0) && (sp->tubes[i].status & P_DAMAGED)) { XX if (!j) XX printf("Computer: Tube(s) %d", i+1); XX else XX printf(", %d", i+1); XX j++; XX } XX } XX if (j) XX printf(" damaged and unable to %s.\n", string); XX} XX XX/* XX * This routine checks to see if a phaser is pointing into our XX * blind side XX */ XXcheck_p_turn(array, sp, flag) XXint array[]; XXstruct ship *sp; XXint flag; /* If 1, came from fire_phasers */ XX{ XX register int i; XX register int j = 0; XX register int k; XX register int bear; XX struct ship *target; XX XX for (i=0; i<4; i++) { XX if (array[i] == 0) XX continue; XX if ((flag) && (!(sp->phasers[i].status & P_FIRING))) XX continue; XX target = sp->phasers[i].target; XX /* XX * This hack is here since when the phaser is locked, XX * the bearing points at the target, whereas when XX * not locked, the bearing is relative to the ship. XX */ XX if (target == NULL) { XX bear = sp->phasers[i].bearing + sp->course; XX k = sp->phasers[i].bearing; XX } else { XX bear = bearing(sp->x, target->x, sp->y, target->y); XX k = bear - sp->course; XX } XX k = rectify(k); XX if ((k > 125) && (k < 235) && (!(sp->status & S_ENG))) { XX if (!j) XX printf("Computer: Phaser(s) %d", i + 1); XX else XX printf(", %d", i + 1); XX j++; XX } XX } XX if (j) XX printf(" are pointing into our blind side.\n"); XX} XX XX/* XX * This routine checks to see if a tube is turned into XX * our blind side. XX */ XXcheck_t_turn(array, sp, flag) XXint array[]; XXstruct ship *sp; XXint flag; /* If 1, came from fire_tubes */ XX{ XX register int i; XX register int j = 0; XX register int k; XX register int bear; XX struct ship *target; XX XX for (i=0; i<6; i++) { XX if (array[i] == 0) XX continue; XX if (flag && (!(sp->tubes[i].status & T_FIRING))) XX continue; XX target = sp->tubes[i].target; XX /* XX * This hack is here since when the tube is locked, XX * the bearing points at the target, whereas when XX * not locked, the bearing is relative to the ship. XX */ XX if (target == NULL) { XX bear = sp->tubes[i].bearing + sp->course; XX k = sp->tubes[i].bearing; XX } else { XX bear = bearing(sp->x, target->x, sp->y, target->y); XX k = bear - sp->course; XX } XX k = rectify(k); XX if ((k > 135) && (k < 225) && (!(sp->status & S_ENG))) { XX if (!j) XX printf("Computer: Tubes(s) %d", i + 1); XX else XX printf(", %d", i + 1); XX j++; XX } XX } XX if (j) XX printf(" are pointing into our blind side.\n"); XX} SHAR_EOF if test 5106 -ne "`wc -c misc.c`" then echo shar: error transmitting misc.c '(should have been 5106 characters)' fi echo shar: extracting mission.c '(4017 characters)' sed 's/^XX//' << \SHAR_EOF > mission.c XX/* XX * TREK73: mission.c XX * XX * Mission Assignment XX * XX */ XX XX#include "structs.h" XX#include "defines.h" XX XXextern int terse; XXextern char title[]; XXextern char foerace[]; XXextern char foename[]; XXextern char foestype[]; XXextern char captain[]; XXextern char science[]; XXextern char com[]; XXextern char helmsman[]; XXextern struct ship *shiplist[]; XXextern int shipnum; XX XXmission() XX{ XX int onef; XX extern char *plural(), *vowelstr(); XX XX if (terse) XX return; XX onef = (shipnum == 1); XX printf("\n\n\nSpace, the final frontier.\n"); XX printf("These are the voyages of the starship %s.\n", shiplist[0]->name); XX printf("Its five year mission: to explore strange new worlds,\n"); XX printf("to seek our new life and new civilizations,\n"); XX printf("to boldly go where no man has gone before!\n"); XX printf("\n"); XX printf(" S T A R T R E K\n"); XX printf("\n"); XX missionlog(); XX printf("%s: %s, I'm picking up %d vessel%s on interception\n", helmsman, title, shipnum, plural(shipnum)); XX printf(" course with the %s.\n", shiplist[0]->name); XX printf("%s: Sensors identify %s as ", science, onef ? "it" : "them"); XX if (onef) XX printf("a%s ", vowelstr(foerace)); XX printf("%s %s%s,\n", foerace, foestype, plural); XX printf(" probably under the command of Captain %s.\n", foename); XX printf("%s: Sound general quarters, Lieutenant!\n", captain); XX printf("%s: Aye, %s!\n", com, title); XX} XX XXwarning() XX{ XX register int i; XX XX printf("Computer: The %ss are attacking the %s with the ", foerace, shiplist[0]->name); XX if (shipnum == 1) { XX printf("%s", shiplist[1]->name); XX } else { XX for (i = 1; i <= shipnum; i++) { XX if (i == shipnum) XX printf("and the "); XX printf("%s", shiplist[i]->name); XX if (i == shipnum) XX break; XX printf(", "); XX /* XX if ((shipnum == 2 && i == 1) || i == 2 || i == 7) XX */ XX if (i == 1 || i == 7) XX printf("\n "); XX } XX } XX printf(".\n"); XX} XX XXmissionlog() XX{ XX static char *missiontab[] = { XX " We are acting in response to a Priority 1 distress call from", XX "space station K7.", XX " We are orbiting Gamma 2 to make a routine check of automatic", XX "communications and astrogation stations.", XX " We are on course for Epsilon Canares 3 to treat Commissioner", XX "Headford for Sukaro's disease.", XX " We have been assigned to transport ambassadors to a diplomatic", XX "conference on the planet code named Babel.", XX " Our mission is to investigate a find of tritanium on Beta 7.", XX 0, XX " We are orbiting Rigel 4 for therapeutic shore leave.", XX 0, XX " We are orbiting Sigma Iota 2 to study the effects of", XX "contamination upon a devoloping culture.", XX " We have altered course for a resue mission on the Gamma 7A", XX "system.", XX " We are presently on course for Altair 6 to attend inauguration", XX "cermonies on the planet.", XX " We are on a cartographic mission to Polex 9.", XX 0, XX " We are headed for Malurian in response to a distress call", XX "from that system.", XX " We are to negotiate a treaty to mine dilithium crystals from", XX "the Halkans.", XX " We are to investigate strange sensor readings reported by a", XX "scoutship investigating Gamma Triangula 6.", XX " We are headed for planets L370 and L374 to investigate the", XX "disappearance of the starship Constellation in that vincinity.", XX " We are ordered, with a skeleton crew, to proceed to Space", XX "Station K2 to test Dr. Richard Daystrom's computer M5.", XX " We have encountered debris from the SS Beagle and are", XX "proceeding to investigate.", XX " We are on course for Ekos to locate John Gill.", XX 0, XX " We are to divert an asteroid from destroying an inhabited", XX "planet.", XX " We are responding to a distresss call form the scientific", XX "expedition on Triacus.", XX " We have been assigned to transport the Medusan Ambassador to", XX "to his home planet." XX }; XX int t1, t2; XX XX t2 = randm(100) - 1; XX t1 = randm(100) - 1; XX printf("%s: Captain's log, stardate %d.%d.\n", captain, t1, t2); XX t1 = (randm(20) - 1) * 2; XX printf("%s\n", missiontab[t1]); XX t1++; XX if (!missiontab[t1]) XX return; XX printf(" %s\n", missiontab[t1]); XX} SHAR_EOF if test 4017 -ne "`wc -c mission.c`" then echo shar: error transmitting mission.c '(should have been 4017 characters)' fi echo shar: extracting moveships.c '(7887 characters)' sed 's/^XX//' << \SHAR_EOF > moveships.c XX/* XX * TREK73: moveships.c XX * XX * Actual command execution XX * XX * move_ships XX * XX */ XX XX#include "defines.h" XX#include "structs.h" XX XXextern int defenseless; XXextern int corbomite; XXextern int surrender; XXextern int surrenderp; XXextern char shutup[]; XXextern int global; XXextern int reengaged; XX XX XXmove_ships() { XX extern double sin(); XX extern double cos(); XX extern double sqrt(); XX extern float fabs(); XX extern struct list head; XX extern struct list *tail; XX extern int shipnum; XX extern struct ship *shiplist[]; XX register int i; XX register int j; XX register int k; XX register struct list *lp; XX register struct ship *sp; XX struct torpedo *tp; XX struct ship *fed; XX struct list *lp1; XX struct ship *sp1; XX int iterations; XX float tmpf; XX int course, newcourse, energy; XX float warp, newwarp; XX int x, y; XX struct ship *target; XX int kills, others, fedstatus; XX struct ship *ep; XX double d0; XX extern float segment; XX extern float timeperturn; XX float Mpersegment; XX XX /* XX * The value 100 is the number of Megameters per second XX * per warp-factor XX */ XX Mpersegment = segment * 100.0; XX iterations = timeperturn/segment; XX for (i=0; i<=shipnum; i++) XX distribute(shiplist[i]); XX fed = shiplist[0]; XX for (i=0; ifwd) { XX if (lp == tail) XX break; XX if (lp->type == 0) XX continue; XX sp = NULL; XX tp = NULL; XX if (lp->type == I_SHIP) XX sp = lp->data.sp; XX else XX tp = lp->data.tp; XX if (sp && sp->status & S_DEAD) XX continue; XX if (sp) { XX phaser_firing(sp); XX torpedo_firing(sp); XX } XX /* XX * time fuses XX */ XX if (tp) { XX tp->timedelay--; XX if (tp->timedelay <= 0) { XX torp_detonate(tp, lp); XX continue; XX } XX } else { XX sp->delay--; XX if (sp->delay <= 0) { XX ship_detonate(sp, lp); XX continue; XX } XX } XX /* XX * proximity fuse XX */ XX if (tp && tp->prox != 0) { XX for (lp1 = &head; lp1 != tail; lp1 = lp1->fwd) { XX if (lp1->type != I_SHIP) XX continue; XX sp1 = lp1->data.sp; XX if (sp1 == tp->from) XX continue; XX j=rangefind(tp->x,sp1->x,tp->y,sp1->y); XX if (j > tp->prox) XX continue; XX torp_detonate(tp, lp); XX tp = 0; XX break; XX } XX if (!tp) XX continue; XX } XX /* XX * movement simulation XX */ XX if (sp && sp->status & S_DEAD) XX continue; XX if (sp) { XX x = sp->x; XX y = sp->y; XX warp = sp->warp; XX newwarp = sp->newwarp; XX course = sp->course; XX newcourse = sp->newcourse; XX target = sp->target; XX energy = sp->energy; XX /* XX * fuel consumption XX */ XX if (fabs((double) warp) >= 1) XX j = (int) (warp * sp->eff * segment); XX else XX j = 0; XX if (j < 0) XX j *= -1; XX if (j > energy) { XX if (!shutup[BURNOUT + sp->id] && !(sp->status & S_WARP)) { XX printf("%s's warp drive burning out.\n", XX sp->name); XX shutup[BURNOUT + sp->id]++; XX } XX newwarp = warp < 0 ? -.99 : .99; XX energy = 0; XX } else XX energy -= j; XX } else { XX x = tp->x; XX y = tp->y; XX warp = tp->speed; XX newwarp = tp->newspeed; XX course = tp->course; XX newcourse = course; XX target = tp->target; XX } XX /* XX * destroyed warp drive XX */ XX if (sp && (sp->status & S_WARP)) XX if (fabs((double)warp) > 1.0) XX newwarp = warp < 0.0 ? -.99 : .99; XX /* XX * automatic pilot XX */ XX if (target != NULL) { XX if (sp && (target->status & S_DEAD)) { XX if ((sp == fed) && (!shutup[DISENGAGE]) && !(sp->status & S_DEAD)) XX printf("%s's autopilot disengaging.\n", XX sp->name); XX newcourse = course; XX shutup[DISENGAGE]++; XX target = NULL; XX sp->eluding = 0; XX } else { XX j = bearing(x, target->x, y, target->y); XX if (sp && sp->eluding) XX j = rectify(j + 180); XX newcourse = (float) j; XX /*if ((sp) && (sp != fed)) { XX sp->newwarp = 1.0; XX newwarp = 1.0; XX }*/ XX if (tp) XX course = newcourse; XX } XX } XX /* XX * turn rate XX */ XX if (course != newcourse) { XX j = rectify(newcourse - course); XX if (j > 180) XX j -= 360; XX /* XX * maximum degrees turned in one turn XX */ XX k = (int) ((12.0 - warp) * 4.0 * segment); XX if (sp->status & S_WARP) XX k /= 2; XX k = (int) course + (j < 0 ? -1 : 1) * XX min(abs(j), k); XX course = (float) rectify(k); XX } XX /* XX * acceleration XX */ XX tmpf = newwarp - warp; XX if (tmpf < 0.0) XX d0 = (double) (tmpf * -1.0); XX else XX d0 = (double) tmpf; XX if (tmpf != 0.0) XX warp += (tmpf < 0 ? -1 : 1) * sqrt(d0) XX * segment; XX d0 = (double) toradians(course); XX x += (int) (warp * cos(d0) * Mpersegment); XX y += (int) (warp * sin(d0) * Mpersegment); XX if ((warp > -0.1) && (warp < 0.1)){ XX warp = 0.0; XX } XX /* XX * reset all the vars XX */ XX if (sp) { XX sp->x = x; XX sp->y = y; XX sp->warp = warp; XX sp->newwarp = newwarp; XX sp->course = course % 360; XX sp->newcourse = newcourse % 360; XX sp->energy = energy; XX sp->target = target; XX } else { XX tp->x = x; XX tp->y = y; XX tp->speed = warp; XX tp->course = course % 360; XX tp->target = target; XX } XX } XX } XX for (i=0; i <= shipnum; i++) { /* Check targets */ XX sp = shiplist[i]; XX if (sp->status & S_DEAD) XX continue; XX for (j=0; j<4; j++) { XX target = sp->phasers[j].target; XX if (target && (target->status & S_DEAD)) { XX if ((sp == fed) && (!shutup[PHASERS+j])&& !(sp->status & S_DEAD)) XX printf(" phaser %d disengaging\n",j+1); XX sp->phasers[j].target = NULL; XX shutup[PHASERS+j]++; XX } XX } XX for (j=0; j<6; j++) { XX target = sp->tubes[j].target; XX if (target && (target->status & S_DEAD)) { XX if ((sp == fed) && (!shutup[TUBES+j]) && !(sp->status & S_DEAD)) XX printf(" tube %d disengaging\n", j+1); XX sp->tubes[j].target = NULL; XX shutup[TUBES+j]++; XX } XX } XX } XX /* XX * self-destruct warning XX */ XX if ((fed->delay < 1000) && (fed->delay > 8)) { XX printf("Computer: %d seconds to self destruct.\n",fed->delay/9); XX } XX /* XX * Ruses, bluffs, surrenders XX */ XX if (defenseless) XX defenseless++; XX if (corbomite) XX corbomite++; XX if (surrender) XX surrender++; XX if (surrenderp) XX surrenderp++; XX /* XX * Federation dispostion XX */ XX sp = fed; XX kills = others = fedstatus = 0; XX if ((sp->crew <= 0) || (sp->status & S_DEAD)) { XX fedstatus = 1; XX sp->status |= S_DEAD; XX } else XX for (j=0; j<1; j++) { XX for (i=0; i<4; i++) XX if (~sp->phasers[i].status | ~P_DAMAGED) XX break; XX if (i != 4) XX continue; XX for (i=0; i<6; i++) XX if (~sp->tubes[i].status | ~T_DAMAGED) XX break; XX if (i != 6) XX continue; XX fedstatus = 1; XX } XX /* XX * enemy disposition XX */ XX for (k=1; k <= shipnum; k++) { XX ep = shiplist[k]; XX if (ep->status & S_DEAD) { XX kills++; XX continue; XX } XX if (ep->crew <= 0) { XX ep->status |= S_DEAD; XX kills++; XX continue; XX } XX if (fedstatus) XX continue; XX j = rangefind(sp->x, ep->x, sp->y, ep->y); XX if ((j>3500 && (ep->status & S_WARP)) || XX (j>4500 && ep->delay<100)) { XX others++; XX continue; XX } XX /* Check if we are within range to turn off the flag */ XX if ((j <= 3500) && (reengaged)) XX reengaged = 0; XX if (ep->energy > 10) XX continue; XX for (i=0; i<4; i++) XX if (~ep->phasers[i].status | ~P_DAMAGED) XX break; XX if (i != 4) XX continue; XX for (i=0; i<6; i++) XX if (~ep->tubes[i].status | ~T_DAMAGED) XX break; XX if (i != 6) XX continue; XX kills++; XX } XX if (fedstatus == 0 && (global & E_SURRENDER)) { XX if (leftovers()) XX warn(4); XX else { XX final(4); XX } XX } XX if ((fed->status & S_SURRENDER) && (kills + others < shipnum)) { XX if (leftovers()) XX warn(3); XX else { XX final(3); XX } XX } XX if (fedstatus == 0 && kills+others < shipnum) XX return 0; XX if (fedstatus == 1 && kills+others < shipnum) { XX if (leftovers()) XX warn(0); XX else XX final(0); XX } XX if (fedstatus == 0 && kills == shipnum) { XX if (leftovers()) XX warn(1); XX else XX final(1); XX } XX if (fedstatus == 0 && kills+others == shipnum) { XX if (leftovers()) XX warn(2); XX else XX final(2); XX } XX if (fedstatus == 1 && kills == shipnum) { XX final(5); XX } XX return 0; XX} SHAR_EOF if test 7887 -ne "`wc -c moveships.c`" then echo shar: error transmitting moveships.c '(should have been 7887 characters)' fi echo shar: extracting options.h '(92 characters)' sed 's/^XX//' << \SHAR_EOF > options.h XX/* XX * TREK73: options.h XX * XX * Parse_opts defines XX * XX */ XX XX#define BOOLEAN 0 XX#define STRING 1 SHAR_EOF if test 92 -ne "`wc -c options.h`" then echo shar: error transmitting options.h '(should have been 92 characters)' fi echo shar: extracting parseopts.c '(3053 characters)' sed 's/^XX//' << \SHAR_EOF > parseopts.c XX/* XX * TREK73: parse_opt.c XX * XX * Parse the environment variable TREK73OPTS XX * XX * parse_opts XX */ XX XX#include XX#include "structs.h" XX#include "options.h" XX XX#define EQSTR(a, b, c) (strncmp(a, b, c) == 0) XX XX#define NUM_OPTS (sizeof optlist / sizeof (OPTION)) XX XX/* XX * description of an option and what to do with it XX */ XXstruct optstruct { XX char *o_name; /* option name */ XX int *o_opt; /* pointer to thing to set */ XX int o_type /* Boolean or string */ XX}; XX XXtypedef struct optstruct OPTION; XX XXextern int terse; XXextern char captain[]; XXextern char sex[]; XXextern char shipbuf[]; XXextern char science[]; XXextern char engineer[]; XXextern char com[]; XXextern char nav[]; XXextern char helmsman[]; XXextern char shipname[]; XXextern char foename[]; XXextern char racename[]; XXextern int silly; XX XX XXOPTION optlist[] = { XX {"terse", (int *)&terse, BOOLEAN}, XX {"name", (int *)captain, STRING}, XX {"sex", (int *)sex, STRING}, XX {"ships", (int *)shipbuf, STRING}, XX {"science", (int *)science, STRING}, XX {"engineer", (int *)engineer, STRING}, XX {"com", (int *)com, STRING}, XX {"nav", (int *)nav, STRING}, XX {"helmsman", (int *)helmsman, STRING}, XX {"shipname", (int *)shipname, STRING}, XX {"enemy", (int *)racename, STRING}, XX {"foename", (int *)foename, STRING}, XX {"silly", (int *)&silly, BOOLEAN}, XX}; XX XX/* XX * parse_opts: XX * Parse options from string, usually taken from the environment. XX * The string is a series of comma seperated values, with booleans XX * being stated as "name" (true) or "noname" (false), and strings XX * being "name=....", with the string being defined up to a comma XX * or the end of the entire option string. XX */ XXparse_opts(str) XXregister char *str; XX{ XX register char *sp; XX register OPTION *op; XX register int len; XX XX while (*str) XX { XX /* XX * Get option name XX */ XX for (sp = str; isalpha(*sp); sp++) XX continue; XX len = sp - str; XX /* XX * Look it up and deal with it XX */ XX for (op = optlist; op < &optlist[NUM_OPTS]; op++) XX if (EQSTR(str, op->o_name, len)) XX { XX if (op->o_type == BOOLEAN) /* if option is a boolean */ XX *op->o_opt = 1; XX else /* string option */ XX { XX register char *start; XX /* XX * Skip to start of string value XX */ XX for (str = sp + 1; *str == '='; str++) XX continue; XX start = (char *) op->o_opt; XX /* XX * Skip to end of string value XX */ XX for (sp = str + 1; *sp && *sp != ','; sp++) XX continue; XX strucpy(start, str, sp - str); XX } XX break; XX } XX /* XX * check for "noname" for booleans XX */ XX else if (op->o_type == BOOLEAN XX && EQSTR(str, "no", 2) && EQSTR(str + 2, op->o_name, len - 2)) XX { XX *op->o_opt = 0; XX break; XX } XX XX /* XX * skip to start of next option name XX */ XX while (*sp && !isalpha(*sp)) XX sp++; XX str = sp; XX } XX} XX XX/* XX * strucpy: XX * Copy string using unctrl for things XX */ XXstrucpy(s1, s2, len) XXregister char *s1, *s2; XXregister int len; XX{ XX if (len > 100) XX len = 100; XX while (len--) XX { XX if (isprint(*s2) || *s2 == ' ') XX *s1++ = *s2; XX s2++; XX } XX *s1 = '\0'; XX} XX SHAR_EOF if test 3053 -ne "`wc -c parseopts.c`" then echo shar: error transmitting parseopts.c '(should have been 3053 characters)' fi echo shar: extracting parsit.c '(2631 characters)' sed 's/^XX//' << \SHAR_EOF > parsit.c XX/* XX * TREK73: parsit.c XX * XX * Parse and get input XX * XX * Gets, parsit (courtesy, P. Lapsley) XX * XX */ XX#include XXstatic int gindex; XXstatic char **argv; XXchar * XXGets(buf) XXchar *buf; XX{ XX extern char *gets(); XX XX if (argv[gindex] == NULL) XX return (gets (buf)); XX ++gindex; XX if (argv[gindex] == NULL) XX return (gets (buf)); XX strcpy (buf, argv[gindex]); XX puts (buf); XX return (buf); XX} XX XX/* XX** parsit.c 23 September 1984 P. Lapsley (phil@Berkeley.ARPA) XX** XX** Parse a string of words separated by spaces into an XX** array of pointers to characters, just like good ol' argv[] XX** and argc. XX** XX** Usage: XX** XX** char line[132]; XX** char **argv; XX** int argc; XX** XX** argv = (char **) NULL; XX** argc = parsit(line, &argv); XX** XX** returns the number of words parsed in argc. argv[argc] will XX** be (char *) NULL to indicate end of list, if you're not XX** happy with just knowing how many words you have. XX** XX** Note that setting argv = (char **) NULL is only done the first XX** time the routine is called with a new "argv" -- it tells XX** parsit that "argv" is a new array, and parsit shouldn't free XX** up the elements (as it would do if it were an old array). XX*/ XX XX XXparsit(line, array) XXchar *line; XXchar ***array; XX{ XX char *malloc(); XX char word[132]; XX char *linecp; XX int i, j, num_words; XX XX gindex = 0; XX argv = *array; XX if (argv != (char **) NULL) { /* Check to see if we should */ XX i = 0; /* free up the old array */ XX do { XX free(argv[i]); /* If so, free each member */ XX } while (argv[i++] != (char *) NULL); XX free(argv); /* and then free the ptr itself */ XX } XX XX linecp = line; XX num_words = 0; XX while (1) { /* count words in input */ XX for (; *linecp == ' ' || *linecp == '\t'; ++linecp) XX ; XX if (*linecp == '\0') XX break; XX XX for (; *linecp != ' ' && *linecp != '\t' && *linecp != '\0'; ++linecp) XX ; XX ++num_words; XX if (*linecp == '\0') XX break; XX } XX XX /* Then malloc enough for that many words plus 1 (for null) */ XX XX if ((argv = (char **) malloc((num_words + 1) * sizeof(char *))) == XX (char **) NULL) { XX fprintf(stderr, "parsit: malloc out of space!\n"); XX return(0); XX } XX XX j = i = 0; XX while (1) { /* Now build the list of words */ XX for (; *line == ' ' || *line == '\t'; ++line) XX ; XX if (*line == '\0') XX break; XX XX i = 0; XX for (; *line != ' ' && *line != '\t' && *line != '\0'; ++line) XX word[i++] = *line; XX word[i] = '\0'; XX argv[j] = malloc(strlen(word) + 1); XX if (argv[j] == (char *) NULL) { XX fprintf(stderr, "parsit: malloc out of space!\n"); XX return(0); XX } XX XX strcpy(argv[j], word); XX ++j; XX if (*line == '\0') XX break; XX } XX argv[j] = (char *) NULL; /* remember null at end of list */ XX *array = argv; XX return(j); XX} XX XX SHAR_EOF if test 2631 -ne "`wc -c parsit.c`" then echo shar: error transmitting parsit.c '(should have been 2631 characters)' fi echo shar: extracting strat1.c '(8821 characters)' sed 's/^XX//' << \SHAR_EOF > strat1.c XX/* XX * TREK73: strat1.c XX * XX * Standard Enemy Strategy XX * XX * standard_strategy XX * XX */ XX XX#include "defines.h" XX#include "structs.h" XX XX XXstandard_strategy() XX{ XX extern float fabs(); XX extern struct ship *shiplist[]; XX extern int shipnum; XX extern int defenseless; XX extern int corbomite; XX extern int surrender; XX extern int surrenderp; XX extern char captain[]; XX extern char science[]; XX extern char nav[]; XX extern char com[]; XX extern char helmsman[]; XX extern char title[]; XX extern char foename[]; XX extern char foerace[]; XX extern int global; XX extern char empire[]; XX int i; XX register struct ship *sp; XX register struct ship *fed; XX int bear; XX int range; XX float tmpf; XX int loop, loop2; XX int probability; XX XX fed = shiplist[0]; XX for (i=1; i <= shipnum; i++) { XX sp = shiplist[i]; XX if (sp->status & S_DEAD) XX continue; XX range = rangefind(sp->x, fed->x, sp->y, fed->y); XX bear = bearing(sp->x, fed->x, sp->y, fed->y); XX bear = rectify(sp->course - bear); XX /* XX * Take care of special commands like defenseless ruses, XX * corbomite bluffs, surrenders (both sides) XX */ XX /* XX * Play dead effects XX */ XX switch (defenseless) { XX case 1: { XX if (randm(10) > 2) { XX defenseless = 2; XX dstrat: XX if (randm(2) == 1) { XX sp->target = NULL; XX sp->newwarp = 0.0; XX } else { XX sp->newwarp = 1.0; XX } XX printf("%s: The %s is ",helmsman, sp->name); XX if (sp->target != NULL) { XX printf("cautiously advancing.\n"); XX } else { XX printf("turning away.\n"); XX } XX astrat: XX if ((fabs(sp->target->warp) > 1.0) XX || (range < 200)) { XX defenseless = 6; XX } else { XX for (loop = 0; loop < 4; loop++) { XX if (sp->target->shields[loop].drain) { XX defenseless = 6; XX } XX } XX } XX } else { XX printf("%s: No apparent change in the enemy's actions.\n", helmsman); XX defenseless = 6; XX } XX } XX break; XX case 2: goto dstrat; XX case 4: goto astrat; XX case 5: goto astrat; XX } XX /* XX * Corbomite bluff effects. XX */ XX switch (corbomite) { XX case 1: { XX probability = 30; XX if (!strcmp(foerace, "Romulan")) { XX probability = 50; XX } XX if (randm(100) < probability) { XX printf("%s: %ss giving ground, Captain. Obviously, they\n", science, foerace); XX printf(" tapped in as you expected them to.\n"); XX printf("%s: A logical assumption, Mr. %s. Are they still\n", captain, science); XX printf(" retreating?\n"); XX printf("%s: Yes, %s\n",science, title); XX printf("%s: Good. All hands, stand by.\n",captain); XX corbomite = 2; XX cstrat: XX sp->target = NULL; XX sp->newwarp = 3.0 + randm(7); XX } else { XX printf("%s: Message coming in from the %ss.\n",com, foerace); XX printf("%s: Put it on audio.\n",captain); XX if (randm(2) == 1) { XX printf ("%s: Ha, ha, ha, %s. You lose.\n", foename, captain); XX } else { XX printf("%s: I fell for that the last time we met, idiot!\n", foename); XX } XX corbomite = 6; XX } XX } XX break; XX case 2: goto cstrat; XX case 3: if (fabs(sp->target->warp) > 2.0) { XX corbomite = 6; XX } XX break; XX case 4: if (fabs(sp->target->warp) > 2.0) { XX corbomite = 6; XX } XX break; XX case 5: if (fabs(sp->target->warp) > 2.0) { XX corbomite = 6; XX } XX break; XX } XX /* XX * Will the enemy accept your surrender? XX */ XX XX if (surrender) XX switch (surrender) { XX case 1: { XX probability=49; XX if (!strcmp(foerace, "Romulan")) { XX probability = 4; XX printf("%s: The %ss do not take prisoners.\n", nav, foerace); XX } XX if (randm(100) < probability) { XX if (randm(2) == 1) { XX printf("%s: Prepare to die, Chicken %s!\n", foename, captain); XX } else { XX printf("%s: No reply from the %ss.\n",com, foerace); XX } XX surrender = 6; XX } else { XX printf("%s: Message coming in from the %s.\n", com, sp->name); XX printf("%s: On behalf of the %s %s, I accept your surrender.\n", foename, foerace, empire); XX printf(" You have five seconds to drop your shields, cut\n"); XX printf(" warp, and prepare to be boarded.\n"); XX surrender = 2; XX global |= F_SURRENDER; XX sstrat: XX sp->target = fed; XX sp->newwarp = 2.0; XX } XX break; XX } XX case 2: XX case 3: { XX warn(3); XX goto sstrat; XX } XX case 4: XX case 5: { XX for (loop = 0; loop < 4; loop++) { XX if (sp->target->shields[loop].attemp_drain) XX goto breakout; XX } XX if (range <= 1400) XX sp->newwarp = 1.0; XX if ((range > 1000) || (fabs(sp->target->warp) > 1.0)) { XX if (surrender == 5) { XX printf("%s: Captain %s, you have not fulfilled our terms.\n", foename, captain); XX printf(" We are resuming our attack.\n"); XX } XX goto breakout; XX } else { XX fed->status |= S_SURRENDER; XX final(3); XX } XX } XX default: global &= ~F_SURRENDER; XX break; XX breakout: XX break; XX } XX /* XX * Enemy surrenders? XX */ XX switch (surrenderp) { XX case 1: XX for (loop = 1; loop < shipnum; loop++) XX if (!(sp->status & S_ENG) && (sp->crew > 100)) { XX printf("%s: You must be joking, Captain %s. Why don't you\n", foename, captain); XX printf(" surrender?\n"); XX surrenderp = 6; XX break; XX } XX if (loop = shipnum) { XX probability = 49; XX if (!strcmp (foerace, "Romulan")) XX probability = 4; XX if (randm(100) < probability) { XX printf("%s: As much as I hate to, Captain %s, we will surrender.\n", foename, captain); XX printf(" We are dropping shields. You may board us.\n"); XX surrenderp = 2; XX dropshields: XX for (loop = 0; loop < 3; loop++) XX sp->shields[0].drain = 0; XX sp->newwarp = 0.0; XX for (loop = 1; loop < shipnum; loop++) XX shiplist[loop]->status |= S_SURRENDER; XX global |= E_SURRENDER; XX } else { XX printf("%s: You must be joking, Captain %s. Why don't you\n", foename, captain); XX printf(" surrender?\n"); XX surrenderp = 6; XX } XX } XX break; XX case 2: XX case 3: XX warn(4); XX goto dropshields; XX } XX /* XX * Unsportsmanlike firing XX */ XX if (betw(defenseless, 0, 6) || betw(corbomite, 0, 6) XX || betw(surrender, 0, 6) || betw(surrenderp, 0, 6)) { XX for (loop = 0; loop < 4; loop++) XX if (fed->phasers[i].status & P_FIRING) XX break; XX for (loop2 = 0; loop2 < 6; loop2++) XX if (fed->tubes[i].status & T_FIRING) XX break; XX /* Has he fired? */ XX if ((loop != 4) || (loop2 != 6)) { XX /* Yes, be angry and disbelieve everything from now on */ XX printf("%s: How dare you fire on us! We are\n", foename); XX printf(" resuming our attack!\n"); XX global = NORMAL; XX if (betw(defenseless,0,6)) XX defenseless = 6; XX if (betw(corbomite,0,6)) XX corbomite = 6; XX if (betw(surrender,0,6)) XX surrender = 6; XX if (betw(surrenderp,0,6)) XX surrenderp = 6; XX for (loop = 0; loop < shipnum; loop++) XX shiplist[loop]->status &= ~S_SURRENDER; XX } XX } XX if ((global & F_SURRENDER) || (global & E_SURRENDER)) XX continue; XX /* XX * short range? XX * 1). fire phasers XX * 2). lock phasers XX * 3). evade probes XX * 4). enemy to the rear - turn around XX * 5). launch a probe? XX * 6). self destruct? XX * 7). set course. XX */ XX if (range < 1050) { XX if (e_closetorps(sp, fed)) XX continue; XX if (e_lockphasers(sp, fed)) XX continue; XX if (e_phasers(sp, fed)) XX continue; XX if (e_checkprobe(sp)) XX continue; XX if (bear > 90 && bear < 270) { XX e_pursue(sp, fed, 1); XX continue; XX } XX if (bear > 90 && bear < 270 && e_launchprobe(sp, fed)) XX continue; XX if (sp->pods<20 && sp->regen < 4.0 && e_destruct(sp)) XX continue; XX /* XX * set course? XX */ XX tmpf = fabs(fed->warp); XX if (sp->target != fed || sp->warp + tmpf > 2.0) { XX e_pursue(sp, fed, (int)tmpf); XX continue; XX } XX } XX if (range < 3800) { XX /* XX * either medium range, or we can't figure out what XX * to do at short range XX */ XX if (e_torpedo(sp)) XX continue; XX if (e_locktubes(sp, fed)) XX continue; XX /* XX * should we run away; can we? XX */ XX if (e_checkarms(sp) < randm(3)) { XX e_runaway(sp, fed); XX continue; XX } XX /* XX * pursued from behind, low power: jettison engineering! XX */ XX if (sp->energy<10 && sp->regen < 4.0 && e_jettison(sp)) XX continue; XX /* XX * put in other junk later XX */ XX } XX /* XX * either distant range, or we can't figure out XX * what to do at medium range XX */ XX if (fed->delay < 15*10 && (sp->status & S_WARP)) { XX e_runaway(sp, fed); XX continue; XX } XX /* XX * enemy behind us? make a quick turn. XX */ XX if (bear > 135 && bear < 225) { XX e_pursue(sp, fed, 1); XX continue; XX } XX /* XX * attack? XX */ XX if (sp->pods > 40 && e_attack(sp, fed)) XX continue; XX if (sp->energy > 30 && sp->pods > 40) XX if (e_loadtubes(sp)) XX continue; XX if (e_locktubes(sp, fed)) XX continue; XX if (e_lockphasers(sp, fed)) XX continue; XX /* XX * gee, there's nothing that we want to do! XX */ XX printf("%s: We're being scanned by the %s\n", science, sp->name); XX } XX} SHAR_EOF if test 8821 -ne "`wc -c strat1.c`" then echo shar: error transmitting strat1.c '(should have been 8821 characters)' fi echo shar: extracting structs.h '(2965 characters)' sed 's/^XX//' << \SHAR_EOF > structs.h XX/* XX * TREK73: structs.h XX * XX * Struct Defs for TREK73 XX * XX */ XX XX XXstruct phaser { XX struct ship *target; /* who we're aimed at */ XX int bearing; /* direction aimed (if no target) */ XX char load; /* energy in phasers */ XX char status; /* Damaged, etc. */ XX int drain; /* Drain from engines (to if negative) */ XX} ; XX XXstruct tube { XX struct ship *target; /* who we're aimed at */ XX int bearing; /* direction aimed (if no target) */ XX char load; /* energy in tubes */ XX char status; /* Damaged, etc */ XX} ; XX XXstruct shield { XX float eff; /* efficiency from 0-1 */ XX float drain; /* Actual drain from engines */ XX float attemp_drain; /* Attempted drain from engines */ XX} ; XX XXstruct ship { XX char name[30]; /* name of ship */ XX char nat; /* nationality */ XX int x, y; /* location */ XX float warp; /* warp speed */ XX float newwarp; /* for speed changes */ XX int course; /* 0-360 */ XX int newcourse; /* for course changes */ XX struct ship *target; /* who we're pursuing */ XX int eluding; /* Flag for eluding */ XX struct phaser phasers[4]; /* phaser banks */ XX int p_spread; /* phaser spread */ XX int p_percent; /* phaser firing percentage */ XX struct tube tubes[6]; /* torpedo tubes */ XX int t_prox; /* proximity delay */ XX int t_delay; /* time delay */ XX int t_lspeed; /* launch speed */ XX struct shield shields[4]; /* shields */ XX float eff; /* efficiency */ XX float regen; /* regeneration (energy per turn) */ XX int energy; /* amount of effective energy */ XX int pods; /* max energy level */ XX int crew; /* crew left alive */ XX int status; /* computer, probe l, warp, sensors, eng */ XX int delay; /* how long 'till we blow up? */ XX int id; /* Unique identifier */ XX int (*strategy)(); /* Which strategy to use */ XX} ; XX XX/* XX * note that probes act like torpedos XX * but have targets; torps only have XX * courses XX */ XXstruct torpedo { XX struct ship *from; /* pointer to ship they're from */ XX int x, y; /* coords of object */ XX int course; /* where it's going */ XX float speed; /* how fast we're moving */ XX float newspeed; /* what our target speed is */ XX struct ship *target; /* who we're aimed at */ XX int fuel; /* how many antimatter pods it has */ XX int timedelay; /* time clicks left before detonation */ XX int prox; /* proximity fuse */ XX int id; /* Unique identifier */ XX} ; XX XX/* XX * the list of what's in space -- depending on the type, we use XX * differing parts of the union (data) structure. it's a linked XX * list of all the stuff in space. XX */ XXstruct list { XX int type; XX struct list *back, *fwd; XX union { XX struct torpedo *tp; XX struct ship *sp; XX } data; XX} ; XX XXstruct cmd { XX int (*routine)(); XX char *word1; XX char *word2; XX int turns; XX} ; XX XX/* XX * for the phaser and anti-matter damage lists XX */ XX XXstruct dam { XX int roll; XX char *mesg; XX}; XX XXstruct damage { XX float eff; XX float fuel; XX float regen; XX float shield; XX float crew; XX float weapon; XX struct dam stats[4]; XX}; XX XXstruct score { XX int score; XX int ships; XX char captain[30]; XX char username[10]; XX}; XX XXstruct rates { XX char *rate; XX int points; XX}; SHAR_EOF if test 2965 -ne "`wc -c structs.h`" then echo shar: error transmitting structs.h '(should have been 2965 characters)' fi # End of shell archive exit 0