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 2 of 4) Message-ID: <10400@ucbvax.ARPA> Date: Mon, 16-Sep-85 11:14:07 EDT Article-I.D.: ucbvax.10400 Posted: Mon Sep 16 11:14:07 1985 Date-Received: Wed, 18-Sep-85 02:53:46 EDT Organization: University of California at Berkeley Lines: 1714 # 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: # cmds1.c # cmds2.c # cmds3.c # cmds4.c # defines.h # dist.c # This archive created: Mon Sep 9 12:06:17 1985 echo shar: extracting cmds1.c '(9815 characters)' sed 's/^XX//' << \SHAR_EOF > cmds1.c XX/* XX * TREK73: cmds1.c XX * XX * User Commands XX * XX * fire_phasers, fire_tubes, lock_phasers, lock_tubes XX * turn_phasers, turn_tubes, load_tubes, launch_probe, XX * probe_control XX * XX */ XX XX#include "defines.h" XX#include "structs.h" XX XXextern char title[]; XXextern char science[]; XXextern char engineer[]; XXextern char nav[]; XXextern char helmsman[]; XX XXfire_phasers(sp) XXstruct ship *sp; XX{ XX char buf1[20]; XX char buf2[20]; XX char c; XX int typed[4]; XX register int i; XX register int k; XX XX for (i=0; i<4; i++) XX typed[i] = 0; XX printf(" fire phasers [1-4] "); XX if (Gets(buf1) == NULL) XX return 0; XX printf(" spread [10-45] "); XX if (Gets(buf2) == NULL) XX return 0; XX i = atoi(buf2); XX if (i < 10 || i > 45) XX return 0; XX sp->p_spread = i; XX for (i=0; c = buf1[i]; i++) { XX k = c - '1'; XX if (k < 0 || k > 3) XX continue; XX typed[k]++; XX if ((sp->phasers[k].status & P_DAMAGED) || XX (sp->phasers[k].status) & P_FIRING) XX continue; XX sp->phasers[k].status |= P_FIRING; XX } XX check_p_damage(typed, sp, "fire"); /* Type out if damaged */ XX check_p_turn(typed, sp, 1); XX return 1; XX} XX XX XXfire_tubes(sp) XXstruct ship *sp; XX{ XX char buf1[20]; XX char c; XX int typed[6]; XX register int i; XX register int j; XX register int k; XX XX for (i=0; i<6; i++) XX typed[i] = 0; XX printf(" fire tubes [1-6] "); XX if (Gets(buf1) == NULL) XX return 0; XX j = strlen(buf1); XX for (i=0; c = buf1[i]; i++) { XX k = c - '1'; XX if (k < 0 || k > 5) XX continue; XX typed[k]++; XX if ((sp->tubes[k].status & T_DAMAGED) || XX (sp->tubes[k].status & T_FIRING)) XX continue; XX sp->tubes[k].status |= T_FIRING; XX } XX check_t_damage(typed, sp, "fire"); /* Type if damaged */ XX check_t_turn(typed, sp, 1); XX j = 0; XX for (i=0; i<6; i++) { XX if ((typed[i] == 0) || (!(sp->tubes[i].status & T_FIRING))) XX continue; XX if (sp->tubes[i].load == 0) { 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(" have no charge in them.\n"); XX return 0; XX} XX XX XXlock_phasers(sp) XXstruct ship *sp; XX{ XX extern struct ship *ship_name(); XX char buf1[20]; XX char buf2[20]; XX int typed[4]; XX char c; XX struct ship *ep; XX register int i; XX register int k; XX XX for (i=0; i<4; i++) XX typed[i] = 0; XX if (sp->status & S_COMP) { XX printf("%s: Impossible %s, our computer is dead.\n", science, title); XX return 0; XX } XX printf(" lock phasers [1-4] "); XX if (Gets(buf1) == NULL) XX return 0; XX printf(" onto whom "); XX if (Gets(buf2) == NULL) XX return 0; XX ep = ship_name(buf2,ENEMYONLY); XX if (ep == NULL) XX return 0; XX for (i=0; c = buf1[i]; i++) { XX k = c - '1'; XX if (k < 0 || k > 3) XX continue; XX typed[k]++; XX if (sp->phasers[k].status & P_DAMAGED) XX continue; XX sp->phasers[k].target = ep; XX } XX check_p_damage(typed, sp, "lock"); XX check_p_turn(typed, sp, 0); XX return 1; XX} XX XX XXlock_tubes(sp) XXstruct ship *sp; XX{ XX extern struct ship *ship_name(); XX char buf1[20]; XX char buf2[20]; XX int typed[6]; XX char c; XX struct ship *ep; XX register int i; XX register int k; XX XX for (i=0; i<6; i++) XX typed[i] = 0; XX if (sp->status & S_COMP) { XX printf("%s: Impossible %s, our computer is dead.\n", science, title); XX return 0; XX } XX printf(" lock tubes [1-6] "); XX if (Gets(buf1) == NULL) XX return 0; XX printf(" onto whom "); XX if (Gets(buf2) == NULL) XX return 0; XX ep = ship_name(buf2,ENEMYONLY); XX if (ep == NULL) XX return 0; XX for (i=0; c = buf1[i]; i++) { XX k = c - '1'; XX if (k < 0 || k > 5) XX continue; XX typed[k]++; XX if (sp->tubes[k].status & T_DAMAGED) XX continue; XX sp->tubes[k].target = ep; XX } XX check_t_damage(typed, sp, "lock"); XX check_t_turn(typed, sp, 0); XX return 1; XX} XX XX XXturn_phasers(sp) XXstruct ship *sp; XX{ XX char buf1[20]; XX char buf2[20]; XX char c; XX int typed[4]; XX register int i; XX register int j; XX register int k; XX XX for (i=0; i<4; i++) XX typed[i] = 0; XX printf(" turn phasers [1-4] "); XX if (Gets(buf1) == NULL) XX return 0; XX printf(" to [0-360] "); XX if (Gets(buf2) == NULL) XX return 0; XX j = atoi(buf2); XX if (j < 0 || j > 360) XX return 0; XX for (i=0; c = buf1[i]; i++) { XX k = c - '1'; XX if (k < 0 || k > 3) XX continue; XX typed[k]++; XX if (sp->phasers[k].status & P_DAMAGED) XX continue; XX sp->phasers[k].target = NULL; XX sp->phasers[k].bearing = j; XX } XX check_p_damage(typed, sp, "turn"); XX check_p_turn(typed, sp, 0); XX return 1; XX} XX XX XXturn_tubes(sp) XXstruct ship *sp; XX{ XX char buf1[20]; XX char buf2[20]; XX char c; XX int typed[6]; XX register int i; XX register int j; XX register int k; XX XX for (i=0; i<6; i++) XX typed[i] = 0; XX printf(" turn tubes [1-6] "); XX if (Gets(buf1) == NULL) XX return 0; XX printf(" to [0-360] "); XX if (Gets(buf2) == NULL) XX return 0; XX j = atoi(buf2); XX if (j < 0 || j > 360) XX return 0; XX for (i=0; c = buf1[i]; i++) { XX k = c - '1'; XX if (k < 0 || k > 5) XX continue; XX typed[k]++; XX if (sp->tubes[k].status & T_DAMAGED) XX continue; XX sp->tubes[k].target = NULL; XX sp->tubes[k].bearing = j; XX } XX check_t_damage(typed, sp, "turn"); XX check_t_turn(typed, sp, 0); XX return 1; XX} XX XX XXload_tubes(sp) XXstruct ship *sp; XX{ XX char buf1[20]; XX char buf2[20]; XX char c; XX int load; XX struct tube *tp; XX register int i; XX register int j; XX register int k; XX XX load = 0; XX printf(" [load or unload] "); XX if (Gets(buf1) == NULL) XX return 0; XX if (*buf1 == 'l' || *buf1 == 'L') XX load++; XX else if (*buf1 != 'u' && *buf1 != 'U') XX return 0; XX printf(" tubes [1-6] "); XX if (Gets(buf2) == NULL) XX return 0; XX for (i=0; c = buf2[i]; i++) { XX if (sp->energy <= 0) XX break; XX k = c - '1'; XX if (k < 0 || k > 5) XX continue; XX tp = &sp->tubes[k]; XX if (tp->status & T_DAMAGED) XX continue; XX if (load) { XX j = min(sp->energy, 10-tp->load); XX if (j == 0) XX continue; XX sp->energy -= j; XX sp->pods -= j; XX tp->load += j; XX } else { XX j = tp->load; XX if (j == 0) XX continue; XX sp->energy += j; XX sp->pods += j; XX tp->load = 0; XX } XX } XX printf("%s: tubes now ", engineer); XX for (i=0; i<6; i++) { XX if (sp->tubes[i].status & T_DAMAGED) XX printf(" -- "); XX else XX printf(" %-2d ", sp->tubes[i].load); XX } XX printf(" pods at %d\n", sp->pods); XX return 1; XX} XX XX XXlaunch_probe(sp) XXstruct ship *sp; XX{ XX extern char captain[]; XX extern struct list *newitem(); XX char buf1[20]; XX int pods, delay, prox, course; XX struct ship *target; XX struct list *lp; XX struct torpedo *pp; XX XX pods = delay = prox = course = 0; XX target = NULL; XX if (sp->status & S_PROBE) { XX printf("%s: probe launcher destroyed!\n", engineer); XX return 0; XX } XX if (sp->energy < 10) { XX printf("%s: we've not enough power, Captain.\n", engineer); XX return 0; XX } XX printf("%s: %d pods available.\n", engineer, sp->energy); XX printf("%s: number to launch [10+] is ", captain); XX if (Gets(buf1) == NULL) XX return 0; XX pods = atoi(buf1); XX if (pods < 10 || pods > sp->energy) XX return 0; XX printf(" set time delay to [0-15] "); XX if (Gets(buf1) == NULL) XX return 0; XX delay = atoi(buf1); XX if (delay < 0 || delay > 15) XX return 0; XX printf(" set proximity delay to [50+] "); XX if (Gets(buf1) == NULL) XX return 0; XX prox = atoi(buf1); XX if (prox < 50) XX return 0; XX printf(" launch towards [whom, if anyone] "); XX Gets(buf1); XX /* XX * This must be fixed in the near future... XX */ XX if (*buf1) { XX target = ship_name(buf1,ENEMYONLY); XX if (target == NULL) XX return 0; XX } else { XX printf(" course [0-360] "); XX if (gets(buf1) == NULL) XX return 0; XX course = atoi(buf1); XX if (course < 0 || course > 360) XX return 0; XX target = NULL; XX } XX /* XX * add a new item to the list of items in space XX */ XX lp = newitem(I_PROBE); XX lp->data.tp = MKNODE(struct torpedo, *, 1); XX pp = lp->data.tp; XX pp->from = sp; XX pp->fuel = pods; XX pp->timedelay = delay * 10; XX pp->speed = sp->warp; XX pp->newspeed = 2.0; XX pp->prox = prox; XX pp->target = target; XX pp->course = course; XX pp->x = sp->x; XX pp->y = sp->y; XX pp->id = new_slot(); XX /* XX * subtract the pods used XX */ XX sp->pods -= pods; XX sp->energy -= pods; XX printf("%s: probe %d away\n",engineer, pp->id); XX return 1; XX} XX XX XXprobe_control(sp) XXstruct ship *sp; XX{ XX extern int rangefind(); XX extern int bearing(); XX extern struct list head; XX extern struct list *tail; XX register struct list *lp; XX register int i; XX register int j; XX register struct torpedo *pp; XX struct torpedo *probes[10]; XX int probenum; XX struct ship *ep; XX int pnum; XX int bear; XX int range; XX char buf1[20]; XX char *bp; XX XX pnum = 0; XX for (lp = &head; lp != tail; lp = lp->fwd) { XX if (lp->type != I_PROBE) XX continue; XX pp = lp->data.tp; XX if (pp->from != sp) XX continue; XX if (!pnum) XX printf("\nprobe bearng range course time prox units target\n"); XX probes[pnum] = pp; XX pnum++; XX range = rangefind(sp->x, pp->x, sp->y, pp->y); XX bear = bearing(sp->x, pp->x, sp->y, pp->y); XX if (pp->target == NULL) XX bp = "NONE"; XX else XX bp = pp->target->name; XX printf(" %2d %3d %5d %3d %2d %5d %3d %s\n", XX pp->id, bear, range, pp->course, pp->timedelay, XX pp->prox, pp->fuel, bp); XX } XX if (!pnum) { XX printf("%s: what probes?\n", nav); XX return 0; XX } XX printf("%s: detonate all probes?\n", nav); XX printf("%s: [yes or no] ", captain); XX if (Gets(buf1) != NULL && (*buf1 == 'Y' || *buf1 == 'y')) { XX printf("%s: aye, %s\n",nav, title); XX for (i=0; itimedelay = 0; XX return 1; XX } XX printf(" control probe [#] "); XX if (Gets(buf1) == NULL) XX return 0; XX probenum = atoi(buf1); XX for (i=0; iid == probenum) XX break; XX if (i == pnum) XX return 0; XX probenum = i; XX printf("%s: detonate it?\n", nav); XX printf("%s: [yes or no] ", captain); XX if (Gets(buf1) != NULL && (*buf1 == 'y' || *buf1 == 'Y')) { XX probes[probenum]->timedelay = 0; XX return 0; XX } XX printf(" lock it onto [whom] "); XX if (Gets(buf1) != NULL && *buf1 != NULL) { XX ep = ship_name(buf1,ENEMYONLY); XX if (ep != NULL) { XX probes[probenum]->target = ep; XX printf("%s: locking.\n", nav); XX return 1; XX } XX } XX printf(" set it to course [0-360] "); XX if (Gets(buf1) == NULL || *buf1 == NULL) XX return 0; XX j = atoi(buf1); XX if (j < 0 || j > 360) XX return 0; XX probes[probenum]->course = j; XX probes[probenum]->target = NULL; XX printf("%s: setting in new course.\n", nav); XX return 1; XX} SHAR_EOF if test 9815 -ne "`wc -c cmds1.c`" then echo shar: error transmitting cmds1.c '(should have been 9815 characters)' fi echo shar: extracting cmds2.c '(9808 characters)' sed 's/^XX//' << \SHAR_EOF > cmds2.c XX/* XX * TREK73: cmds2.c XX * XX * User Commands XX * XX * pos_report, pos_display, pursue, helm, self_scan, scan XX * XX * (print_damages) XX * XX */ XX XX#include "defines.h" XX#include "structs.h" XX#include XX#include XX XXextern char title[]; XXextern char science[]; XXextern char engineer[]; XXextern char helmsman[]; XXextern char nav[]; XX XX XXpos_report(sp) XXstruct ship *sp; XX{ XX extern int rangefind(); XX extern int bearing(); XX extern struct ship *shiplist[]; XX extern struct list head, *tail; XX struct ship *sp1; XX struct torpedo *tp; XX struct list *lp; XX int x, y; XX int range; XX int bear; XX float speed; XX int course; XX int maxlen = 0; XX char whitespace[5], who[80]; XX XX /* XX * Go through tht list of objects and find out the longest XX * name of any of them. This is to insure that no matter XX * what the names of the ship, the position report will XX * come out formatted. XX */ XX for (lp = &head; lp != tail; lp = lp->fwd) { XX if (lp->type == 0) XX continue; XX if (lp->type == I_SHIP) { XX sp1 = lp->data.sp; XX strcpy(who, sp1->name); XX maxlen = max(maxlen, strlen(who)); XX } else { XX tp = lp->data.tp; XX strcpy(who, tp->from->name); XX switch (lp->type) { XX case I_SHIP: XX case I_TORPEDO: XX continue; XX case I_PROBE: XX maxlen = max(maxlen, strlen(who) + 9); XX case I_ENG: XX maxlen = max(maxlen, strlen(who) + 12); XX break; XX default: XX break; XX } XX } XX } XX /* XX * Construct a string %ns where n is the length of the XX * longest name. XX */ XX sprintf(whitespace, "%%%ds", maxlen); XX /* XX * And print out the position report XX */ XX printf(whitespace, " "); XX printf(" warp course bearing range\n"); XX for (lp = &head; lp != tail; lp = lp->fwd) { XX if (lp->type == 0) XX continue; XX sp1 = NULL; XX tp = NULL; XX if (lp->type == I_SHIP) { XX sp1 = lp->data.sp; XX if (sp1->status & S_DEAD) XX continue; XX x = sp1->x; XX y = sp1->y; XX speed = sp1->warp; XX course = sp1->course; XX strcpy(who, sp1->name); XX } else { XX tp = lp->data.tp; XX if (lp->type == I_TORPEDO) XX continue; XX x = tp->x; XX y = tp->y; XX speed = tp->speed; XX course = tp->course; XX strcpy(who, tp->from->name); XX switch(lp->type) { XX case I_PROBE: XX sprintf(who, "%s probe %d", who, tp->id); XX break; XX case I_ENG: XX strcat(who, " engineering"); XX break; XX default: XX break; XX } XX } XX bear = bearing(sp->x, x, sp->y, y); XX range = rangefind(sp->x, x, sp->y, y); XX printf(whitespace, who); XX printf(" %4.1f %3d ", speed, course); XX if ((sp1 != NULL) && (sp1 == shiplist[0])) { XX if (shiplist[0]->target != NULL) XX if (shiplist[0]->eluding) XX printf("eluding %s\n", shiplist[0]->target->name); XX else XX printf("pursuing %s\n", shiplist[0]->target->name); XX else XX printf(" \n"); XX } else XX printf("%3d %5d\n", bear, range); XX } XX} XX XX XXpos_display(sp) XXstruct ship *sp; XX{ XX extern struct list head, *tail; XX register int i; XX register int j; XX int range; XX char buf1[20]; XX int x, y; XX float xf, yf; XX int h, v; XX struct list *lp; XX struct ship *sp1; XX struct torpedo *tp; XX char map[13][23]; XX char c; XX XX if (sp->status & S_SENSOR) { XX printf("%s: sensors are damaged.\n", science); XX return 0; XX } XX printf(" display to [100+] "); XX if (Gets(buf1) == NULL) XX return 0; XX range = atoi(buf1); XX if (range < 100 || range > 10000) XX return 0; XX /* XX * Compensation for aspect ratio of the output device XX */ XX x = range/10; XX y = range/6; XX for (i=0; i<13; i++) { XX if (i == 0 || i == 12) XX strcpy(map[i], "---------------------"); XX else XX strcpy(map[i], " "); XX } XX map[6][10] = '+'; XX for (lp = &head; lp != tail; lp = lp->fwd) { XX if (lp->data.sp == sp) XX continue; XX if (lp->type == I_SHIP) { XX sp1 = lp->data.sp; XX xf = sp1->x - sp->x; XX yf = sp1->y - sp->y; XX } else { XX tp = lp->data.tp; XX xf = tp->x - sp->x; XX yf = tp->y - sp->y; XX } XX v = yf/y + 6.5; XX h = xf/x + 10.5; XX if (v < 0 || v > 12) XX continue; XX if (h < 0 || h > 20) XX continue; XX switch (lp->type) { XX case I_SHIP: XX c = lp->data.sp->name[0]; XX break; XX case I_TORPEDO: XX c = ':'; XX break; XX case I_ENG: XX c = '#'; XX break; XX case I_PROBE: XX c = '*'; XX break; XX default: XX c = '?'; XX break; XX } XX map[12 - v][h] = c; XX } XX for (i=0; i<13; i++) { XX for (j=0; j<21; j++) XX if (map[i][j] != ' ') XX break; XX if (j != 21) XX printf("%s", map[i]); XX printf("\n"); XX } XX return 0; XX} XX XX XXpursue(sp) XXstruct ship *sp; XX{ XX extern struct ship *ship_name(); XX extern double atof(); XX register int i; XX char buf1[20]; XX struct ship *ep; XX float warp; XX XX if (sp->status & S_COMP) { XX printf("%s: Impossible, %s, our computer is dead\n",science ,title); XX return 0; XX } XX printf(" Mr. %s, pursue [who] ", nav); XX if (Gets(buf1) == NULL) XX return 0; XX ep = ship_name(buf1,ENEMYONLY); XX if (ep == NULL) XX return 0; XX printf(" Mr. %s, warp factor [-9 to 9] ", helmsman); XX if (Gets(buf1) == NULL) XX return 0; XX warp = (float) atof(buf1); XX if (warp > 9.0 || warp < -9.0) { XX printf("%s: %s, the engines canna go that fast!\n",engineer, title); XX return 0; XX } XX if ((warp > 1.0 || warp < -1.0) && (sp->status & S_WARP)) { XX printf("%s: Warp drive is dead, Captain.\n", science); XX warp = warp < 0.0 ? -1.0 : 1.0; XX } XX sp->newwarp = warp; XX sp->target = ep; XX /* Set eluding flag to 0, which means pursue */ XX sp->eluding = 0; XX i = bearing(sp->x, ep->x, sp->y, ep->y); XX printf("%s: Aye, %s, coming to course %d.\n", nav, title, i); XX sp->newcourse = i; XX return 1; XX} XX XX XXelude(sp) XXstruct ship *sp; XX{ XX extern struct ship *ship_name(); XX extern double atof(); XX register int i; XX char buf1[20]; XX struct ship *ep; XX float warp; XX XX if (sp->status & S_COMP) { XX printf("%s: impossible, %s, our computer is dead\n",science, title); XX return 0; XX } XX printf(" Mr. %s, elude [who] ", nav); XX if ((Gets(buf1) == NULL) || (buf1 == NULL)) XX return 0; XX ep = ship_name(buf1,ENEMYONLY); XX if (ep == NULL) XX return 0; XX printf(" Mr. %s, warp factor [-9 to 9] ", helmsman); XX if (Gets(buf1) == NULL) XX return 0; XX warp = (float) atof(buf1); XX if (warp > 9.0 || warp < -9.0) { XX printf("%s: %s, the engines canna go that fast!\n",engineer, title); XX return 0; XX } XX if ((warp > 1.0 || warp < -1.0) && (sp->status & S_WARP)) { XX printf("%s: Warp drive is dead, Captain.\n", science); XX warp = warp < 0.0 ? -1.0 : 1.0; XX } XX sp->newwarp = warp; XX sp->target = ep; XX /* Set eluding flag to 1, which means elude */ XX sp->eluding = 1; XX i = bearing(sp->x, ep->x, sp->y, ep->y); XX i = rectify(i + 180); XX printf("%s: Aye, %s, coming to course %d.\n", nav, title, i); XX sp->newcourse = i; XX return 1; XX} XX XXhelm(sp) XXstruct ship *sp; XX{ XX extern double atof(); XX char buf1[20]; XX register int course; XX float warp; XX XX printf(" Mr. %s, come to course [0-359] ", nav); XX if (Gets(buf1) == NULL) XX return 0; XX course = atoi(buf1); XX if (course < 0 || course > 360) XX return 0; XX printf(" Mr. %s, warp factor [-9 to 9] ", helmsman); XX if (Gets(buf1) == NULL) XX return 0; XX warp = (float) atof(buf1); XX if (warp > 9.0 || warp < -9.0) { XX printf("%s: %s, the engines canna go that fast!\n",engineer, title); XX return 0; XX } XX if ((warp > 1.0 || warp < -1.0) && (sp->status & S_WARP)) { XX printf("%s: Warp drive is dead, Captain.\n", science); XX warp = warp < 0.0 ? -1.0 : 1.0; XX } XX sp->newwarp = warp; XX sp->newcourse = course; XX sp->target = NULL; XX sp->eluding = 0; XX printf("%s: aye, %s.\n", nav, title); XX return 1; XX} XX XXself_scan(sp) XXstruct ship *sp; XX{ XX struct ship *ep; XX extern struct ship *shiplist[]; XX XX ep = shiplist[0]; /* Scanning ourself */ XX print_damage(ep); XX sp = sp; /* LINT */ XX return 1; XX} XX XXscan(sp) XXstruct ship *sp; XX{ XX struct ship *ep; XX char buf1[20]; XX XX printf(" %s, scan [who] ", science); XX if (Gets(buf1) == NULL) XX return 0; XX ep = ship_name(buf1,ENEMYONLY); XX if (ep == NULL) XX return 0; XX if (sp != ep && (sp->status & S_SENSOR)) { XX printf ("%s: The sensors are damaged, Captain.\n", science); XX return 0; XX } XX if (sp == ep) { XX printf ("%s: Captain, don't you mean 'Damage Report'?\n", science); XX return 0; XX } XX print_damage(ep); XX return 1; XX} XX XXprint_damage(ep) XXstruct ship *ep; XX{ XX extern char *statmsg[]; XX register int i; XX register int j; XX register float k; XX XX printf("\n\nDamages to the %s\n", ep->name); XX for (i=0; i<5; i++) { XX if (ep->status & 1<crew); XX printf("\nPhasers Control"); XX for (i=0; i<4; i++) { XX if (ep->phasers[i].status & P_DAMAGED) XX printf("\tdamaged"); XX else if (ep->phasers[i].target == NULL) XX printf("\tmanual"); XX else XX printf("\t%.7s", ep->phasers[i].target->name); XX } XX printf("\n\t turned"); XX for (i=0; i<4; i++) XX if (ep->phasers[i].status & P_DAMAGED) XX printf("\t"); XX else if (ep->phasers[i].target == NULL) XX printf("\t%d", ep->phasers[i].bearing); XX else XX printf("\tLOCKED"); XX printf("\n\t level"); XX for (i=0; i<4; i++) XX if (ep->phasers[i].status & P_DAMAGED) XX printf("\t"); XX else XX printf("\t%-2d", ep->phasers[i].load); XX printf("\n"); XX printf("\nTubes\tcontrol"); XX for (i=0; i<6; i++) { XX if (ep->tubes[i].status & T_DAMAGED) XX printf("\tdamaged"); XX else if (ep->tubes[i].target == NULL) XX printf("\tmanual"); XX else XX printf("\t%.7s", ep->tubes[i].target->name); XX } XX printf("\n\t turned"); XX for (i=0; i<6; i++) XX if (ep->tubes[i].status & T_DAMAGED) XX printf("\t"); XX else if (ep->tubes[i].target == NULL) XX printf("\t%d", ep->tubes[i].bearing); XX else XX printf("\tLOCKED"); XX printf("\n\t level"); XX for (i=0; i<6; i++) XX if (ep->tubes[i].status & T_DAMAGED) XX printf("\t"); XX else XX printf("\t%-2d", ep->tubes[i].load); XX printf("\n"); XX printf("\nShields\t levels"); XX for (i=0; i<4; i++) { XX j = 100 * ep->shields[i].eff * ep->shields[i].drain; XX printf("\t%-2d", j); XX } XX printf("\n\t drains"); XX for (i=0; i<4; i++) { XX k = ep->shields[i].attemp_drain; XX printf("\t%-4.2f", k); XX } XX printf("\n\nefficiency: %3.1f\t\tfuel remaining: %d\n", XX ep->eff, ep->energy); XX printf("regeneration: %4.1f\tfuel capacity: %d\n", XX ep->regen, ep->pods); XX return 1; XX} SHAR_EOF if test 9808 -ne "`wc -c cmds2.c`" then echo shar: error transmitting cmds2.c '(should have been 9808 characters)' fi echo shar: extracting cmds3.c '(5051 characters)' sed 's/^XX//' << \SHAR_EOF > cmds3.c XX/* XX * TREK73: cmds3.c XX * XX * User Commands XX * XX * jettison_engineering, detonate_engineering, phaser_status, tube_status, XX * survivors, alter_power XX * XX * (do_jettison) XX * XX */ XX XX#include "defines.h" XX#include "structs.h" XX#include XX#include XX XXextern char title[]; XXextern char engineer[]; XX XXjettison_engineering(sp) XXstruct ship *sp; XX{ XX XX printf(" Mr. %s, jettison our engineering section!\n", engineer); XX if (sp->status & S_ENG) { XX printf("%s: But Captain, it's already jettisonned.\n", engineer); XX return 0; XX } XX do_jettison(sp); XX printf("%s: Jettisoning engineering.\n", engineer); XX return 1; XX} XX XXdo_jettison(sp) XXstruct ship *sp; XX{ XX extern struct list *newitem(); XX register struct list *lp; XX register struct torpedo *tp; XX XX lp = newitem(I_ENG); XX tp = lp->data.tp = MKNODE(struct torpedo, *, 1); XX tp->target = NULL; XX tp->speed = sp->warp; XX tp->newspeed = 0.0; XX tp->x = sp->x; XX tp->y = sp->y; XX tp->course = sp->course; XX tp->fuel = sp->pods; XX tp->timedelay = 10 * 10; XX tp->prox = 0; XX tp->from = sp; XX tp->id = new_slot(); XX sp->energy = sp->pods = 0; XX sp->newwarp = .99 * (sp->warp < 0.0 ? -1.0 : 1.0); XX sp->regen = 0.0; XX sp->status |= S_ENG; XX sp->status |= S_WARP; XX} XX XXdetonate_engineering(sp) XXstruct ship *sp; XX{ XX extern struct list head; XX extern struct list *tail; XX register struct list *lp; XX register struct torpedo *tp; XX register int found; XX char buf[10]; XX XX found = 0; XX printf(" %s, detonate engineering!\n", engineer); XX if (!(sp->status & S_ENG)) { XX printf("%s: But %s, it's still attached.\n",engineer,title); XX printf(" Detonate anyway? "); XX if ((Gets(buf) == NULL) || (buf == NULL)) XX return 0; XX if (buf[0] != 'y') XX return 0; XX else XX do_jettison(sp); XX } XX for (lp = &head; lp != tail; lp = lp->fwd) { XX if (lp->type != I_ENG) XX continue; XX tp = lp->data.tp; XX if (tp->from != sp) XX continue; XX found++; XX tp->timedelay = 1; XX break; XX } XX if (found) XX printf("%s: Aye, %s.\n",engineer, title); XX else XX printf("%s: Ours has already detonated.\n", engineer); XX return 1; XX} XX XX XXphaser_status(sp) XXstruct ship *sp; XX{ XX register int i; XX XX printf("Phasers\n\n"); XX printf("Control: "); XX for (i=0; i<4; i++) { XX if (sp->phasers[i].status & P_DAMAGED) XX printf("\tdamaged"); XX else if (sp->phasers[i].target == NULL) XX printf("\tmanual"); XX else XX printf("\t%.7s", sp->phasers[i].target->name); XX } XX printf("\n Turned: "); XX for (i=0; i<4; i++) XX if (sp->phasers[i].status & P_DAMAGED) XX printf("\t"); XX else if (sp->phasers[i].target == NULL) XX printf("\t%d", sp->phasers[i].bearing); XX else XX printf("\tLOCKED"); XX printf("\n Level: "); XX for (i=0; i<4; i++) { XX if (sp->phasers[i].status & P_DAMAGED) XX printf("\t"); XX else XX printf("\t%d", sp->phasers[i].load); XX } XX printf("\n Drain: "); XX for (i=0; i<4; i++) { XX if (sp->phasers[i].status & P_DAMAGED) XX printf("\t"); XX else XX printf("\t%d", sp->phasers[i].drain); XX } XX printf("\n\nFiring percentage: %d\n",sp->p_percent); XX return 1; XX} XX XXtube_status(sp) XXstruct ship *sp; XX{ XX register int i; XX XX printf("Torpedos\n\n"); XX printf("Control: "); XX for (i=0; i<6; i++) { XX if (sp->tubes[i].status & T_DAMAGED) XX printf("\tdamaged"); XX else if (sp->tubes[i].target == NULL) XX printf("\tmanual"); XX else XX printf("\t%.7s", sp->tubes[i].target->name); XX } XX printf("\n Turned: "); XX for (i=0; i<6; i++) XX if (sp->tubes[i].status & T_DAMAGED) XX printf("\t"); XX else if (sp->tubes[i].target == NULL) XX printf("\t%d", sp->tubes[i].bearing); XX else XX printf("\tLOCKED"); XX printf("\n Level: "); XX for (i=0; i<6; i++) { XX if (sp->tubes[i].status & T_DAMAGED) XX printf("\t"); XX else XX printf("\t%d", sp->tubes[i].load); XX } XX printf("\n\nLaunch speed: %d\n", sp->t_lspeed); XX printf(" time delay: %d\n", sp->t_delay); XX printf(" prox delay: %d\n", sp->t_prox); XX return 1; XX} XX XXsurvivors(sp) XXstruct ship *sp; XX{ XX extern struct ship *shiplist[]; XX extern int shipnum; XX struct ship *ep; XX register int i; XX XX printf("\nSurvivors reported:\n"); XX for (i=0; i<=shipnum; i++) { XX ep = shiplist[i]; XX printf(" %s -- %d\n", ep->name, ep->crew); XX } XX sp = sp; /* LINT */ XX} XX XXalter_power() XX{ XX extern char **argp; XX extern struct ship *shiplist[]; XX extern char captain[]; XX extern double atof(); XX register int i; XX float j; XX char buf1[20]; XX XX printf("\n%s: Regeneration rate is %5.2f.\n",engineer, shiplist[0]->regen); XX for (i=0; i<4; i++) { XX printf("%s: Shield %d drain is ", captain, i + 1); XX Gets(buf1); XX j = (float) atof(buf1); XX if (buf1[strlen(buf1) - 1] == '*') { XX for (; i<4; i++) XX shiplist[0]->shields[i].attemp_drain =j; XX break; XX } else if ((j < 0.0) || (j > 1.0)) XX goto badparam; XX else XX shiplist[0]->shields[i].attemp_drain = j; XX } XX printf("\n"); XX for (i=0; i<4; i++) { XX printf("%s: Phaser %d drain is ", captain, i + 1); XX Gets(buf1); XX j = (float) atof(buf1); XX if (buf1[strlen(buf1) - 1] == '*') { XX for (; i<4; i++) XX shiplist[0]->phasers[i].drain = (int) j; XX break; XX } else if ((j < -10.0) || (j > 10.0)) XX goto badparam; XX else XX shiplist[0]->phasers[i].drain = (int) j; XX } XX return 1; XXbadparam: XX printf("%s: Bad parameters, %s.\n", engineer, title); XX return 0; XX} SHAR_EOF if test 5051 -ne "`wc -c cmds3.c`" then echo shar: error transmitting cmds3.c '(should have been 5051 characters)' fi echo shar: extracting cmds4.c '(8534 characters)' sed 's/^XX//' << \SHAR_EOF > cmds4.c XX/* XX * TREK73: cmds4.c XX * XX * User Commands XX * XX * alterpntparams, play_dead, corbomite_bluff, surrender_ship, XX * request_surrender, self_destruct, abort_self_destruct XX * XX */ XX XX#include "defines.h" XX#include "structs.h" XX#include XX XXextern int defenseless; XXextern char captain[]; XXextern char title[]; XXextern char science[]; XXextern char com[]; XXextern char nav[]; XXextern char helmsman[]; XXextern char engineer[]; XXextern char foerace[]; XXextern int corbomite; XXextern int surrender; XXextern int surrenderp; XX XXalterpntparams(sp) XXstruct ship *sp; XX{ XX int temp; XX char buf1[30]; XX XX printf("\n%s: Reset tubes, %s?\n",nav,title); XX printf("%s: [yes or no] ",captain); XX if (Gets(buf1) == NULL) XX return 0; XX if ((buf1 != NULL) && (buf1[0] != 'n')) { XX printf(" Set launch speed to [0-12] "); XX if (Gets(buf1) == NULL) XX return 0; XX if (buf1 != NULL) { XX temp = atoi(buf1); XX if ((temp > -1) && (temp < 13)) XX sp->t_lspeed = temp; XX } XX printf(" ...time delay to [0-10] "); XX if (Gets(buf1) == NULL) XX return 0; XX if (buf1 != NULL) { XX temp = atoi(buf1); XX if ((temp > -1) && (temp < 11)) XX sp->t_delay = temp; XX } XX printf(" ...proximity delay to [0-500] "); XX if (Gets(buf1) == NULL) XX return 0; XX if (buf1 != NULL) { XX temp = atoi(buf1); XX if ((temp > -1) && (temp < 501)) XX sp->t_prox = temp; XX } XX } XX printf("%s: Reset phasers, %s?\n",nav ,title); XX printf("%s: [yes or no] ",captain); XX if (Gets(buf1) == NULL) XX return 0; XX if ((buf1 != NULL) && (buf1[0] != 'n')) { XX printf(" Reset firing percentage to [0-100] "); XX if (Gets(buf1) == NULL) XX return 0; XX if (buf1 != NULL) { XX temp = atoi(buf1); XX if ((temp > -1) && (temp < 101)) XX sp->p_percent = temp; XX } XX } XX return 0; XX} XX XXplay_dead(sp) XXstruct ship *sp; XX{ XX XX char buf1[30]; XX int phaser_charge; XX register int i; XX XX printf("%s: Weapons officer, drop shields ...\n",captain); XX if (defenseless) { XX printf("%s: %s, the %ss are not that stupid.",science, title,foerace); XX return 0; XX } XX printf(" Transfer power to [engines or phasers]: "); XX if (Gets(buf1) == NULL || *buf1 == NULL) { XX printf("%s: What?\n", nav); XX return 0; XX } XX phaser_charge = -10.; XX if (buf1[0] != 'e') { XX phaser_charge = 10.; XX if (buf1[0] != 'p') { XX printf("%s: What?\n", nav); XX return 0; XX } XX } XX for (i=0;i<4;i++) XX sp->shields[i].attemp_drain = 0.; XX for (i=0;i<4;i++) XX sp->phasers[i].drain = phaser_charge; XX defenseless = 1; XX return 0; XX} XX XXcorbomite_bluff(sp) XXstruct ship *sp; XX{ XX XX if (randm(2) == 1) { XX printf("%s: Open a hailing frequency, ship-to-ship.\n",captain); XX printf("%s: Hailing frequency open, %s.\n", com, title); XX printf("%s: This is the Captain of the %s. Our respect for\n",captain, sp->name); XX printf(" other life forms requires that we give you this warning--\n"); XX printf(" one critical item of information which has never been\n"); XX printf(" incorporated into the memory banks of any Earth ship.\n"); XX printf(" Since the early years of space exploration, Earth vessels\n"); XX printf(" have had incorporated into them a substance know as corbomite.\n"); XX if (!corbomite) { XX printf(" It is a material and a device which prevents attack on\n"); XX printf(" us. If any destructive energy touchs our vessel, a re-\n"); XX printf(" verse reaction of equal strength is created, destroying\n"); XX printf(" the attacker. It may interest you to know that, since\n"); XX printf(" the initial use of corbomite for more than two of our\n"); XX printf(" centuries ago, no attacking vessel has survived the attempt.\n"); XX printf(" Death has little meaning to us. If it has none to you,\n"); XX printf(" then attack us now. We grow annoyed with your foolishness.\n"); XX } XX } else { XX printf("%s: Open a special channel to Starfleet Command.\n",captain); XX printf("%s: Aye, %s.\n",com, title); XX printf("%s: Use Code 2.\n",captain); XX printf("%s: but, Captain, according to our last Starfleet\n", com); XX printf(" Bulletin, the %ss have broken code 2.\n",foerace); XX printf("%s: That's an order, Lieutenant. Code 2!\n",captain); XX printf("%s: Yes, Captain. Code 2.\n", com); XX printf("%s: Message from %s to Starfleet Command, this sector.\n",captain,sp->name); XX printf(" have inadvertantly encroached upon %s neutral zone,\n",foerace); XX printf(" surrounded and under heavy %s attack. Escape\n",foerace); XX printf(" impossible. Shields failing. Will implement destruct\n"); XX printf(" order using corbomite device recently installed.\n"); XX if (!corbomite) { XX printf(" This will result in the destruction of the %s and\n",sp->name); XX printf(" all matter within a 200 megameter diameter and\n"); XX printf(" establish corresponding dead zone, all federation\n"); XX printf(" vessels will aviod this area for the next four solar\n"); XX printf(" years. Explosion will take place in one minute. %s,\n",captain); XX printf(" commanding %s, out.\n",sp->name); XX } XX } XX if (!corbomite) { XX printf(" Mr. %s. Stand by.\n", helmsman); XX printf("%s: Standing by.\n", helmsman); XX corbomite = 1; XX } else { XX printf("\n%s: I don't believe that they will fall for tha maneuver\n", science); XX printf(" again, %s.\n",title); XX } XX return 0; XX} XX XXsurrender_ship(sp) XXstruct ship *sp; XX{ XX printf("%s: Lieutenant, open a channel to the %ss.\n", captain, foerace); XX printf("%s: Aye, %s.\n", com, title); XX printf("%s: This is Captain %s of the U. S. S. %s. Will\n",captain,captain,sp->name); XX printf(" you accept my unconditional surrender?\n"); XX if (surrender) { XX printf("%s: The %ss have already refused.\n",science, foerace); XX } else { XX if (foerace == "Romulan") { XX printf("%s: The %ss have not been know to have taken\n",science, foerace); XX printf(" prisoners.\n"); XX } XX surrender = 1; XX } XX return 0; XX} XX XXrequest_surrender(sp) XXstruct ship *sp; XX{ XX printf("%s: Lieutenant, open a hailing frequency to the %ss.\n",captain,foerace); XX printf("%s: Aye, %s.\n", com, title); XX printf("%s: This is Captain %s of the U. S. S. %s. I give you\n",captain, captain, sp->name); XX printf(" one last chance to surrender before we resume our attack.\n"); XX if (surrenderp) { XX printf("%s: %s, our offer has already been refused.\n",science, title); XX } else { XX surrenderp = 1; XX } XX return 0; XX} XX XXself_destruct(sp) XXstruct ship *sp; XX{ XX printf("%s: Lieutenant %s, tie in the bridge to the master\n",captain, com); XX printf(" computer.\n"); XX if (sp->status & S_COMP) { XX printf("%s: Our computer is down.\n", science); XX return 0; XX } XX printf("%s: Aye, %s.\n",com, title); XX printf("%s: Computer. Destruct sequence. Are you ready to copy?\n",captain); XX printf("Computer: Working.\n"); XX printf("%s: Computer, this is Captain %s of the U. S. S. %s.\n",captain,captain,sp->name); XX printf(" destruct sequence one, code 1-1a.\n"); XX printf("Computer: Voice and code verified and correct.\n"); XX printf(" Sequence one complete.\n"); XX printf("%s: This is Commander %s, Science Officer. Destruct\n", science, science); XX printf(" sequence two, code 1-1a-2b.\n"); XX printf("Computer: Voice and code verified and correct. Sequence\n"); XX printf(" two complete.\n"); XX printf("%s: This is Lieutenant Commander %s, Chief Engineering\n", engineer, engineer); XX printf(" Officer of the U. S. S. %s. Destruct sequence\n",sp->name); XX printf(" number three, code 1-b2-b3.\n"); XX printf("Computer: Voice and code verified and correct.\n"); XX printf(" Destruct sequence complete and engaged. Awaiting final\n"); XX printf(" code for twenty second countdown.\n"); XX printf("%s: Computer, this is Captain %s of the U. S. S. %s.\n",captain, captain, sp->name); XX printf(" begin countdown, code 0-0-0, destruct 0.\n"); XX printf("Computer: 20 seconds to self-detruct.\n"); XX sp->delay = 9 * 20; XXreturn 0; XX} XX XXabort_self_destruct(sp) XXstruct ship *sp; XX{ XX printf("%s: Computer, this is Captain %s of the U. S. S. %s.\n",captain,captain,sp->name); XX printf(" Code 1-2-3 continuity abort destruct order, repeat:\n"); XX printf(" Code 1-2-3 continuity abort destruct order!\n"); XX if (sp->status & S_COMP) { XX printf("%s: Our computer is down.\n", science); XX return 0; XX } XX if (sp->delay > 1000) { XX printf("Computer: Self-destruct sequence has not been\n"); XX printf(" initiated.\n"); XX return 0; XX } XX printf("Computer: Self-destruct order ..."); XX fflush(stdout); XX sleep(4); XX if (sp->delay > 4 * 9) { XX printf("aborted. Destruct order aborted.\n"); XX sp->delay = 10000; XX return 0; XX } else { XX printf("\n%s: Too late, captain ...\n", science); XX return 0; XX } XX} SHAR_EOF if test 8534 -ne "`wc -c cmds4.c`" then echo shar: error transmitting cmds4.c '(should have been 8534 characters)' fi echo shar: extracting defines.h '(1508 characters)' sed 's/^XX//' << \SHAR_EOF > defines.h XX/* XX * TREK73: defines.h XX * XX * Defines for TREK73 XX * XX */ XX XX/* Globals externals */ XXextern char *malloc(), *strcpy(), *gets(); XXextern long random(); XX XX#define toradians(x) ((float)(x)*.0174533) XX#define todegrees(x) ((float)(x)*57.2958) XX#define randm(x) (((int)random() % (x)) + 1) XX XX#define min(x, y) ((x) < (y) ? (x) : (y)) XX#define max(x, y) ((x) > (y) ? (x) : (y)) XX XX#ifndef NULL XX#define NULL 0 XX#endif XX XX/* XX * for the item linked list XX */ XX#define I_UNDEFINED 0 XX#define I_SHIP 1 XX#define I_TORPEDO 2 XX#define I_PROBE 3 XX#define I_ENG 4 XX XX/* XX * for the ship status word XX */ XX#define S_NORMAL 000 XX#define S_COMP 001 XX#define S_SENSOR 002 XX#define S_PROBE 004 XX#define S_WARP 010 XX#define S_ENG 020 XX#define S_DEAD 040 XX#define S_SURRENDER 0100 XX XX/* XX * for the status message turn off array XX */ XX#define DISENGAGE 1 XX#define SHIELDSF 2 XX#define PHASERS 3 XX#define TUBES 7 XX#define SURRENDER 13 XX#define SURRENDERP 14 XX#define PLAYDEAD 15 XX#define CORBOMITE 16 XX#define BURNOUT 17 XX#define HIGHSHUTUP 27 XX XX/* XX * Defines for the play status word XX */ XX#define NORMAL 000 XX#define F_SURRENDER 001 XX#define E_SURRENDER 002 XX XX/* XX * Phaser statuses XX */ XX#define P_NORMAL 000 XX#define P_DAMAGED 001 XX#define P_FIRING 002 XX XX/* XX * Tube statuses XX */ XX#define T_NORMAL 000 XX#define T_DAMAGED 001 XX#define T_FIRING 002 XX XX/* XX * Ship search routine directives XX */ XX#define ALL 0 XX#define ENEMYONLY 1 XX XX#define MKNODE(cast, star, number) (cast star)malloc(sizeof(cast) * number) XX XX#define MAXBADS 9 XX#define MAXFEDS 9 XX#define MAXENCOMM 9 XX#define MAXFOERACES 9 SHAR_EOF if test 1508 -ne "`wc -c defines.h`" then echo shar: error transmitting defines.h '(should have been 1508 characters)' fi echo shar: extracting dist.c '(2568 characters)' sed 's/^XX//' << \SHAR_EOF > dist.c XX/* XX * TREK73: dist.c XX * XX * Power distribution routines XX * XX * distribute XX * XX */ XX XX#include "defines.h" XX#include "structs.h" XX#include XX XXextern char engineer[]; XX XXdistribute(sp) XXstruct ship *sp; XX{ XX extern char title[]; XX register int i; XX register int fuel; XX register int load; XX register int effload; XX register int drain; XX float shield; XX extern char shutup[]; XX extern struct ship *shiplist[]; XX XX fuel = sp->energy + (int)(sp->regen * 2); XX /* XX * Calculate negative phaser drains XX */ XX for (i=0; i<4; i++) { XX load = sp->phasers[i].load; XX drain = sp->phasers[i].drain; XX if ((sp->phasers[i].status & P_DAMAGED) || (drain >= 0) XX || (sp->phasers[i].load <= 0)) XX continue; XX /* XX * Drain the lesser of either the current load if the XX * load is less than the drain, or the drain value XX */ XX if (drain < 0) { XX effload = max(load + drain, 0); XX fuel += load - effload; XX sp->phasers[i].load = effload; XX } XX } XX /* XX * Calculate shield drains XX */ XX shield = 0.0; XX for (i=0; i<4; i++) XX shield += sp->shields[i].attemp_drain; XX drain = ceil((double) shield); XX /* XX * If all attempted drains are zero, or we have no XX * fuel, our shields are down! XX */ XX if (((shield == 0) || (fuel == 0)) && !shutup[SHIELDSF] && sp == shiplist[0]) { XX printf("%s: %s, our shields are down!\n",engineer, title); XX shutup[SHIELDSF]++; XX } XX /* XX * If there's not enough fuel to sustain the drains, then XX * ration it out in proportion to the attempted drains and XX * say that shields are fluctuating. XX */ XX if (drain <= fuel) { XX fuel -= drain; XX for (i=0; i<4; i++) XX sp->shields[i].drain = sp->shields[i].attemp_drain; XX } else { XX if (!shutup[SHIELDSF] && sp == shiplist[0]) { XX printf("%s: %s, our shields are fluctuating!\n", engineer, title); XX shutup[SHIELDSF]++; XX } XX for (i=0; i<4; i++) XX if (!sp->shields[i].attemp_drain) XX sp->shields[i].drain = sp->shields[i].attemp_drain * (float) fuel / drain; XX else XX sp->shields[i].drain = 0; XX fuel = 0; XX } XX /* XX * Calculate positive phaser drains XX */ XX for (i=0; i<4 && fuel > 0; i++) { XX if (fuel <=0) XX break; XX load = sp->phasers[i].load; XX drain = sp->phasers[i].drain; XX if ((sp->phasers[i].status & P_DAMAGED) || load >= 10 || drain <= 0) XX continue; XX /* XX * Load phasers either enough to top them off, or XX * the full drain XX */ XX if (drain > 0) { XX effload = min(10, load + min(drain, fuel)); XX fuel -= effload - load; XX sp->phasers[i].load = effload; XX } XX } XX /* XX * Now balance the level of energy with the numer of pods XX */ XX if (fuel > sp->pods) XX sp->energy = sp->pods; XX else XX sp->energy = fuel; XX} SHAR_EOF if test 2568 -ne "`wc -c dist.c`" then echo shar: error transmitting dist.c '(should have been 2568 characters)' fi # End of shell archive exit 0