Article View: net.sources.games
Article #8Trek73 (part 3 of 4)
From: Doctor Who
Date: Mon, 16 Sep 1985 15:15
Date: Mon, 16 Sep 1985 15:15
1115 lines
29708 bytes
29708 bytes
# 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:
# endgame.c
# enemycom.c
# firing.c
# globals.c
# This archive created: Mon Sep 9 12:06:55 1985
echo shar: extracting endgame.c '(4612 characters)'
sed 's/^XX//' << \SHAR_EOF > endgame.c
XX/*
XX * TREK73: endgame.c
XX *
XX * prints end-of-game messages and warnings
XX *
XX * leftovers, final, warn
XX *
XX */
XX
XX#include <sys/file.h>
XX#include "defines.h"
XX#include "structs.h"
XX
XXextern char captain[];
XXextern char title[];
XXextern char science[];
XXextern char com[];
XXextern char helmsman[];
XXextern char foerace[];
XXextern char foename[];
XXextern char foestype[];
XXextern char empire[];
XXextern int reengaged;
XX
XXleftovers()
XX{
XX extern struct list head;
XX extern struct list *tail;
XX register struct list *lp;
XX
XX for (lp = &head; lp != tail; lp = lp->fwd) {
XX if (lp->type == 0)
XX continue;
XX if (lp->type != I_SHIP)
XX return 1;
XX }
XX return 0;
XX}
XX
XX
XXfinal(mesg)
XXint mesg;
XX{
XX extern struct ship *shiplist[];
XX extern int shipnum;
XX register int i;
XX register int j;
XX struct ship *sp;
XX struct ship *ep;
XX char buf[80];
XX extern char *plural();
XX
XX
XX sp = shiplist[0];
XX /* If we're getting that message again, ignore it. */
XX if ((mesg == 2) && (reengaged))
XX return;
XX switch (mesg) {
XX case 0:
XX starfleet();
XX printf("We have recieved confirmation that the USS %s,\n",
XX sp->name);
XX printf(" captained by %s, was destroyed by %s%s\n",captain, shipnum==1 ?"a ":"", foerace);
XX printf(" %s%s. May future Federation officers\n", foestype, plural(shipnum));
XX printf(" perform better in their duties.\n\n");
XX break;
XX case 1:
XX starfleet();
XX printf("We commend Captain %s and his crew on their\n",captain);
XX printf(" fine performance against the %ss. May he\n",foerace);
XX printf(" be an inspiration to future starship captains.\n");
XX break;
XX case 2:
XX /*
XX * Give him a chance to re-engage if he wants to. If he does,
XX * he has to get within a range of 3500 before he can again
XX * try to dis-engage
XX */
XX if (!reengaged) {
XX printf("%s: %s, we are in a position to either disengage from the\n", science, title);
XX printf(" %ss, or re-engage them in combat.\n", foerace);
XX printf(" Do you wish to re-engage?\n");
XX printf("%s: [y or n] ", captain);
XX gets(buf);
XX if ((*buf == NULL) || (*buf == 'y') || (*buf == 'Y')) {
XX reengaged = 1;
XX return;
XX }
XX }
XX starfleet();
XX printf("Captain %s of the starship %s has\n",captain,sp->name);
XX printf(" out-maneuvered %s aggressors. We commend\n",foerace);
XX printf(" his tactical ability.\n");
XX break;
XX case 3:
XX starfleet();
XX printf("Captain %s of the starship %s has\n",captain,sp->name);
XX printf(" surrendered his vessel to the %ss. May\n",foerace);
XX printf(" Captain Donsell be remembered.\n");
XX break;
XX case 4:
XX starfleet();
XX printf("We have recieved word from the %s that the\n",sp->name);
XX printf(" %ss have surrendered.\n",foerace);
XX break;
XX case 5:
XX starfleet();
XX printf("One of our vessels has encountered the wreckage of\n");
XX printf(" the %s and %d other %s vessel%s.\n", sp->name,
XX shipnum, foerace, plural(shipnum));
XX break;
XX default:
XX printf("how did we get here?\n");
XX break;
XX }
XX printf("\n\n");
XX j = 0;
XX for (i=0; i<=shipnum; i++) {
XX ep = shiplist[i];
XX if (ep->status & S_DEAD)
XX continue;
XX if (!j)
XX printf("Survivors Reported:\n");
XX j++;
XX }
XX if (j) {
XX for (i=0; i<=shipnum; i++) {
XX ep = shiplist[i];
XX if ((ep->status & S_DEAD) || (ep->crew == 0)){
XX printf(" %s -- destroyed.\n",ep->name);
XX }
XX else
XX printf(" %s -- %d\n", ep->name, ep->crew);
XX }
XX } else
XX printf("*** No survivors reported ***\n");
XX exit (1);
XX}
XX
XX
XX
XXwarn(mesg)
XXint mesg;
XX{
XX extern struct ship *shiplist[];
XX static int beenhere[5] = {0, 0, 0, 0, 0};
XX struct ship *sp;
XX
XX if ((reengaged) && (mesg == 2)) {
XX return 0;
XX }
XX if (beenhere[mesg])
XX return 0;
XX sp = shiplist[0];
XX switch (mesg) {
XX case 0:
XX printf("Message to the Federation: This is Commander\n");
XX printf(" %s of the %s %s. We have defeated\n", foename, foerace, empire);
XX printf(" the %s and are departing the quadrant.\n", sp->name);
XX break;
XX case 1:
XX printf("%s: All %s vessels have been either\n", science, foerace);
XX printf(" destroyed or crippled. We still, however, have\n");
XX printf(" antimatter devices to avoid.\n");
XX break;
XX case 2:
XX printf("%s: The %ss are falling behind and seem to\n", helmsman, foerace);
XX printf(" be breaking off their attack.\n");
XX break;
XX case 3:
XX printf("%s: I'm informing Starfleet Command of our \n", com);
XX printf(" disposition.\n");
XX break;
XX case 4:
XX printf("%s: Although the %ss have surrendered,\n",science, foerace);
XX printf(" there are still antimatter devices floating\n");
XX printf(" around us.\n");
XX break;
XX default:
XX printf("how did we get here?\n");
XX break;
XX }
XX beenhere[mesg]++;
XX return 0;
XX}
XX
XXstarfleet()
XX{
XX printf("\n\nStarfleet Command: \n");
XX sleep(3);
XX printf("\n");
XX}
SHAR_EOF
if test 4612 -ne "`wc -c endgame.c`"
then
echo shar: error transmitting endgame.c '(should have been 4612 characters)'
fi
echo shar: extracting enemycom.c '(8299 characters)'
sed 's/^XX//' << \SHAR_EOF > enemycom.c
XX/*
XX * TREK73: enemycom.c
XX *
XX * Enemy strategy sub-routines
XX *
XX * e_phasers, e_lockphasers, e_locktubes, e_checkprobe, e_evade,
XX * e_pursue, e_launchprobe, e_destruct, e_torpedo, e_jettison,
XX * e_checkarms, e_runaway, e_attack, e_loadtubes, e_closetorp
XX *
XX */
XX
XX#include "defines.h"
XX#include "structs.h"
XX
XXextern float fabs();
XXextern char science[];
XXextern char helmsman[];
XX
XX/*
XX * returns the number of banks we're going to fire
XX * it also sets them up.
XX */
XXint e_phasers(sp, fed)
XXstruct ship *sp;
XXstruct ship *fed;
XX{
XX register int i;
XX register int banks;
XX register int hit;
XX register int howmany;
XX int bear;
XX
XX banks = 0;
XX howmany = randm(2) + 2;
XX sp->p_spread = 10 + randm(12);
XX for (i=0; i<4; i++) {
XX if (sp->phasers[i].status & P_DAMAGED)
XX continue;
XX if (fed != NULL) {
XX if (sp->phasers[i].target == NULL)
XX continue;
XX bear = bearing(sp->x, fed->x, sp->y, fed->y);
XX hit = phaser_hit(sp, fed->x, fed->y, &sp->phasers[i], bear);
XX if (hit <= 0)
XX continue;
XX }
XX banks++;
XX sp->phasers[i].status |= P_FIRING;
XX if (banks > howmany)
XX break;
XX }
XX return banks;
XX}
XX
XX/*
XX * returns positive if we had to lock phasers
XX */
XXint e_lockphasers(sp, fed)
XXstruct ship *sp;
XXstruct ship *fed;
XX{
XX register int i;
XX register int banks;
XX
XX banks = 0;
XX for (i=0; i<4; i++) {
XX if (sp->phasers[i].status & P_DAMAGED)
XX continue;
XX if (sp->phasers[i].target != NULL)
XX continue;
XX sp->phasers[i].target = fed;
XX banks++;
XX }
XX return banks;
XX}
XX
XX/*
XX * returns positive if we had to lock tubes
XX */
XXint e_locktubes(sp, fed)
XXstruct ship *sp;
XXstruct ship *fed;
XX{
XX register int i;
XX register int tubes;
XX
XX tubes = 0;
XX for (i=0; i<4; i++) {
XX if (sp->tubes[i].status & T_DAMAGED)
XX continue;
XX if (sp->tubes[i].target != NULL)
XX continue;
XX sp->tubes[i].target = fed;
XX tubes++;
XX }
XX return tubes;
XX}
XX
XX/*
XX * returns 1 if evasive action being taken (to avoid probe)
XX */
XXe_checkprobe(sp)
XXstruct ship *sp;
XX{
XX extern struct list head;
XX extern struct list *tail;
XX register struct list *lp;
XX register int range;
XX register struct torpedo *tp;
XX
XX for (lp = &head; lp != tail; lp = lp->fwd) {
XX if (lp->type != I_PROBE)
XX continue;
XX tp = lp->data.tp;
XX range = rangefind(sp->x, tp->x, sp->y, tp->y);
XX if (range < 1000) {
XX e_evade(sp, tp->x, tp->y, I_PROBE);
XX return 1;
XX }
XX }
XX return 0;
XX}
XX
XX
XX/*
XX * advance to the rear!
XX */
XXe_evade(sp, x, y, type)
XXstruct ship *sp;
XXint x;
XXint y;
XXint type; /* Currently unused */
XX{
XX register int i;
XX register int newcourse;
XX int bear;
XX
XX bear = bearing(sp->x, x, sp->y, y);
XX printf("%s taking evasive action!\n", sp->name);
XX i = randm(3);
XX switch (i) {
XX case 1:
XX newcourse = rectify(bear - 90);
XX break;
XX case 2:
XX newcourse = rectify(bear + 90);
XX break;
XX case 3:
XX newcourse = rectify(bear + 180);
XX break;
XX default:
XX printf("error in evade()\n");
XX break;
XX }
XX sp->target = NULL;
XX sp->newcourse = newcourse;
XX sp->newwarp = 2 + randm(8);
XX if (sp->status & S_WARP)
XX sp->newwarp = 1.0;
XX type = type; /* LINT */
XX return 1;
XX}
XX
XX
XXe_pursue(sp, fed, speed)
XXstruct ship *sp;
XXstruct ship *fed;
XXint speed;
XX{
XX int bear;
XX int coursediff;
XX
XX bear = bearing(sp->x, fed->x, sp->y, fed->y);
XX /*
XX * do a quick turn if our speed is > warp 10 and
XX * (thus) we are never going to bear on the fed ship
XX * speed = 7 is a magic cookie. feel free to change.
XX */
XX coursediff = abs(sp->course - bear);
XX if (speed >= 9 && coursediff > 10)
XX speed = 5;
XX sp->target = fed;
XX sp->newcourse = bear;
XX sp->newwarp = speed;
XX if (speed > 1 && (sp->status & S_WARP))
XX sp->newwarp = 0.99;
XX return 1;
XX}
XX
XX
XXint e_launchprobe(sp, fed)
XXstruct ship *sp;
XXstruct ship *fed;
XX{
XX extern struct list *newitem();
XX register int i;
XX register struct list *lp;
XX register struct torpedo *tp;
XX
XX if ((sp->status & S_PROBE) || sp->energy <= 10)
XX return 0;
XX /*
XX * fed ship has to be going slow before we'll launch
XX * a probe at it.
XX */
XX if (fabs(fed->warp) > 1.0)
XX return 0;
XX lp = newitem(I_PROBE);
XX tp = lp->data.tp = MKNODE(struct torpedo, *, 1);
XX printf("%s launching probe\n", sp->name);
XX tp->speed = sp->warp;
XX tp->newspeed = 3.0;
XX tp->target = fed;
XX tp->course = bearing(sp->x, fed->x, sp->y, fed->y);
XX tp->x = sp->x;
XX tp->y = sp->y;
XX tp->prox = 200 + randm(200);
XX tp->timedelay = 15 * 10;
XX i = min(randm(15) + 10, sp->energy);
XX tp->fuel = i;
XX sp->energy -= i;
XX sp->pods -= i;
XX return 1;
XX}
XX
XX
XX/*
XX * goodbye, cruel world
XX */
XXint e_destruct(sp)
XXstruct ship *sp;
XX{
XX if (sp->delay < 5 * 9)
XX return 0;
XX sp->delay = 5 * 9;
XX printf("%s: The %s is overloading what remains of it's\n",science, sp->name);
XX printf(" antimatter pods -- obviously a suicidal gesture.\n");
XX printf(" Detonation in five seconds\n");
XX return 1;
XX}
XX
XX
XXint e_torpedo(sp)
XXstruct ship *sp;
XX{
XX extern struct ship *shiplist[];
XX extern int shipnum;
XX register int i;
XX register int tubes;
XX register int howmany;
XX register struct ship *sp1;
XX register int range;
XX
XX /*
XX * don't shoot if someone might be in the way
XX * (i.e. proximity fuse will go off right as the
XX * torps leave the tubes!)
XX */
XX for (i=1; i <= shipnum; i++) {
XX sp1 = shiplist[i];
XX if ((sp1->status & S_DEAD) || sp1 == sp)
XX continue;
XX range = rangefind(sp->x, sp1->x, sp->y, sp1->y);
XX if (range <= 400)
XX return 0;
XX }
XX tubes = 0;
XX howmany = randm(2) + 1;
XX for (i=0; i<4; i++) {
XX if ((sp->tubes[i].status & T_DAMAGED)
XX || (sp->tubes[i].load == 0))
XX continue;
XX if (sp->tubes[i].target == NULL)
XX continue;
XX tubes++;
XX sp->tubes[i].status |= T_FIRING;
XX if (tubes > howmany)
XX break;
XX }
XX return tubes;
XX}
XX
XX
XXint e_jettison(sp)
XXstruct ship *sp;
XX{
XX extern struct list *newitem();
XX register struct list *lp;
XX register struct torpedo *tp;
XX
XX if (sp->status & S_ENG)
XX return 0;
XX if (!(shiplist[0]->status & S_SENSOR)) {
XX printf("%s: Sensors indicate debris being left by\n", science);
XX printf(" the %s. Insufficient mass?\n", sp->name);
XX }
XX lp = newitem(I_ENG);
XX tp = lp->data.tp = MKNODE(struct torpedo, *, 1);
XX tp->id = new_slot();
XX /*
XX * ship slows to warp 1.0 when jettisonning engineering
XX */
XX tp->newspeed = 0.0;
XX tp->speed = sp->warp;
XX tp->target = NULL;
XX tp->course = sp->course;
XX tp->x = sp->x;
XX tp->y = sp->y;
XX tp->prox = 0;
XX tp->timedelay = 15 * 9;
XX tp->fuel = sp->pods;
XX sp->energy = sp->pods = 0;
XX sp->regen = 0.0;
XX tp->from = sp;
XX if (sp->newwarp < -1.0)
XX sp->newwarp = -0.99;
XX if (sp->newwarp > 1.0)
XX sp->newwarp = 0.99;
XX sp->status |= S_ENG;
XX sp->status |= S_WARP;
XX return 1;
XX}
XX
XXint e_checkarms(sp)
XXstruct ship *sp;
XX{
XX register int i;
XX register int arms;
XX
XX arms = 0;
XX for (i=0; i<4; i++)
XX if (sp->phasers[i].load >= 0)
XX arms++;
XX for (i=0; i<6; i++)
XX if (sp->tubes[i].load >= 0)
XX arms++;
XX return arms;
XX}
XX
XXint e_runaway(sp, fed)
XXstruct ship *sp;
XXstruct ship *fed;
XX{
XX register int speed;
XX
XX speed = randm(4) + 2;
XX speed = -speed;
XX e_pursue(sp, fed, speed);
XX printf("%s: The %s is retreating.\n", helmsman, sp->name);
XX return 1;
XX}
XX
XXint e_attack(sp, fed)
XXstruct ship *sp;
XXstruct ship *fed;
XX{
XX int speed;
XX float tmpf;
XX
XX tmpf = fabs(fed->warp);
XX if (sp->warp >= tmpf + 2.0 || (sp->status & S_WARP))
XX return 0;
XX speed = min(11, tmpf + randm(2) + 2.0);
XX e_pursue(sp, fed, speed);
XX printf("%s: %s attacking.\n", helmsman, sp->name);
XX return 1;
XX}
XX
XXint e_loadtubes(sp)
XXstruct ship *sp;
XX{
XX register int i;
XX register int j;
XX register int loaded;
XX register int below;
XX
XX below = 10;
XX loaded = 0;
XX for (i=0; i<6; i++) {
XX if (sp->energy <= below)
XX break;
XX if (sp->tubes[i].status & T_DAMAGED)
XX continue;
XX j = min(sp->energy, 10-sp->tubes[i].load);
XX if (j == 0)
XX continue;
XX sp->energy -= j;
XX sp->pods -= j;
XX sp->tubes[i].load += j;
XX loaded++;
XX }
XX return loaded;
XX}
XX
XXe_closetorps(sp, fed)
XXstruct ship *sp;
XXstruct ship *fed;
XX{
XX extern struct list head;
XX extern struct list *tail;
XX register struct list *lp;
XX register int range;
XX register struct torpedo *tp;
XX struct torpedo *bad;
XX
XX bad = NULL;
XX for (lp = &head; lp != tail; lp = lp->fwd) {
XX if (lp->type != I_TORPEDO)
XX continue;
XX tp = lp->data.tp;
XX if (tp->from != fed)
XX continue;
XX range = rangefind(sp->x, tp->x, sp->y, tp->y);
XX if (range < 1200) {
XX bad = tp;
XX /*
XX * fire phasers - hope they're pointing in
XX * the right direction!
XX */
XX if (e_phasers(sp, (struct ship *) NULL))
XX return 1;
XX return 1;
XX }
XX }
XX /*
XX * we can't get a phaser shot off.
XX * try and evade (although hopeless)
XX */
XX if (bad != NULL) {
XX e_evade(sp, tp->x, tp->y, I_TORPEDO);
XX return 1;
XX }
XX return 0;
XX}
SHAR_EOF
if test 8299 -ne "`wc -c enemycom.c`"
then
echo shar: error transmitting enemycom.c '(should have been 8299 characters)'
fi
echo shar: extracting firing.c '(5253 characters)'
sed 's/^XX//' << \SHAR_EOF > firing.c
XX/*
XX * TREK73: firing.c
XX *
XX * Take care of firing phasers and torpedos for both enemy
XX * and fed ships.
XX *
XX * phaser_firing, torpedo_firing, ship_detonate, torp_detonate
XX *
XX */
XX
XX#include "defines.h"
XX#include "structs.h"
XX
XXextern struct ship *shiplist[];
XXextern char shutup[];
XX
XXphaser_firing(sp)
XXstruct ship *sp;
XX{
XX extern struct list head;
XX extern struct list *tail;
XX extern struct damage p_damage;
XX register int i;
XX register int j;
XX int hit;
XX struct ship *ep;
XX struct torpedo *tp;
XX int s;
XX int x, y;
XX struct ship *target;
XX struct list *lp;
XX int bear;
XX struct ship *fed;
XX
XX
XX fed = shiplist[0];
XX for (i=0; i<4; i++) {
XX if (sp->phasers[i].status & P_FIRING)
XX break;
XX }
XX if (i == 4)
XX return 0;
XX sp->phasers[i].status &= ~P_FIRING;
XX target = sp->phasers[i].target;
XX /*
XX * Put in j the exact bearing of the phasers relative to
XX * the ship
XX */
XX if (target == NULL) {
XX bear = sp->phasers[i].bearing + sp->course;
XX j = sp->phasers[i].bearing;
XX } else {
XX bear = bearing(sp->x, target->x, sp->y, target->y);
XX j = bear - sp->course;
XX }
XX j = rectify(j);
XX if (j > 125 && j < 235 && !(sp->status & S_ENG))
XX return 0;
XX if (target != NULL && (target->status & S_DEAD)) {
XX if ((sp = fed) && (!shutup[PHASERS+j])&& !(sp->status & S_DEAD))
XX printf("%s phaser %d disengaging\n", sp->name, i+1);
XX sp->phasers[i].target = NULL;
XX shutup[PHASERS+j]++;
XX return 0;
XX }
XX if (target != NULL)
XX sp->phasers[i].bearing = j;
XX printf(" <%s frng phasers>\n", sp->name);
XX for (lp = &head; lp != tail; lp = lp->fwd) {
XX if (lp->type == 0)
XX continue;
XX ep = NULL;
XX tp = NULL;
XX if (lp->type == I_SHIP) {
XX ep = lp->data.sp;
XX if (ep == sp)
XX continue;
XX x = ep->x;
XX y = ep->y;
XX } else {
XX tp = lp->data.tp;
XX x = tp->x;
XX y = tp->y;
XX }
XX hit = phaser_hit(sp, x, y, &sp->phasers[i], bear);
XX if (hit == 0)
XX continue;
XX if (tp) {
XX if (tp->timedelay > 2) {
XX switch (lp->type) {
XX default:
XX case I_SHIP:
XX printf("oops...\n");
XX break;
XX case I_TORPEDO:
XX printf("hit on torpedo %d\n",
XX tp->id);
XX break;
XX case I_ENG:
XX printf("%s's engineering hit.\n",
XX tp->from->name);
XX break;
XX case I_PROBE:
XX printf("hit on probe %d\n",
XX tp->id);
XX break;
XX }
XX tp->timedelay = 2;
XX }
XX tp->fuel -= hit/2;
XX if (tp->fuel < 0)
XX tp->fuel = 0;
XX continue;
XX }
XX /*
XX * Determine which shield was hit
XX */
XX j = rectify(bearing(x, sp->x, y, sp->y) - ep->course);
XX if (j > 315 || j < 45)
XX s = 1;
XX else if (j < 135)
XX s = 2;
XX else if (j < 225)
XX s = 3;
XX else
XX s = 4;
XX damage(hit, ep, s, &p_damage);
XX }
XX /*
XX * Reduce the load by the firing percentage
XX */
XX sp->phasers[i].load = sp->phasers[i].load
XX - sp->phasers[i].load * sp->p_percent / 100;
XX return 0;
XX}
XX
XXtorpedo_firing(sp)
XXstruct ship *sp;
XX{
XX extern struct damage a_damage;
XX extern struct list *newitem();
XX register int i;
XX register int j;
XX register int th;
XX struct torpedo *tp;
XX struct ship *target;
XX struct list *lp;
XX int bear;
XX struct ship *fed;
XX
XX
XX fed = shiplist[0];
XX for (i=0; i<6; i++) {
XX if (sp->tubes[i].status & T_FIRING)
XX break;
XX }
XX if (i == 6)
XX return 0;
XX sp->tubes[i].status &= ~T_FIRING;
XX th = sp->tubes[i].load;
XX if (th == 0)
XX return 0;
XX target = sp->tubes[i].target;
XX /*
XX * Put in j the relative bearing of the tube
XX */
XX if (target == NULL) {
XX bear = sp->tubes[i].bearing + sp->course;
XX j = sp->tubes[i].bearing;
XX } else {
XX bear = bearing(sp->x, target->x, sp->y, target->y);
XX j = bear - sp->course;
XX }
XX j = rectify(j);
XX if (j > 125 && j < 235 && !(sp->status & S_ENG))
XX return 0;
XX if (target != NULL && (target->status & S_DEAD)) {
XX if ((sp = fed) && (!shutup[TUBES+j])&&!(sp->status & S_DEAD))
XX printf(" tube %d disengaging\n", i+1);
XX sp->tubes[i].target = NULL;
XX shutup[TUBES+j]++;
XX return 0;
XX }
XX if (target != NULL)
XX sp->tubes[i].bearing = j;
XX sp->tubes[i].load = 0;
XX lp = newitem(I_TORPEDO);
XX lp->type = I_TORPEDO;
XX lp->data.tp = MKNODE(struct torpedo, *, 1);
XX tp = lp->data.tp;
XX tp->from = sp;
XX tp->x = sp->x;
XX tp->y = sp->y;
XX tp->target = NULL;
XX tp->course = rectify(bear);
XX tp->fuel = th;
XX tp->speed = sp->t_lspeed + sp->warp;
XX tp->newspeed = tp->speed;
XX tp->timedelay = sp->t_delay * 10;
XX tp->prox = sp->t_prox;
XX tp->id = new_slot();
XX printf(" <<%s frng torpedo %d>>\n", sp->name, tp->id);
XX return 1;
XX}
XX
XXint ship_detonate(sp, lp)
XXstruct ship *sp;
XXstruct list *lp;
XX{
XX register int fuel;
XX register int i;
XX
XX fuel = 0;
XX printf("++%s++ destruct.\n", sp->name);
XX for (i=0; i<4; i++)
XX if (sp->phasers[i].status & ~P_DAMAGED)
XX fuel += min(sp->phasers[i].load, 10);
XX for (i=0; i<6; i++)
XX if (sp->tubes[i].status & ~T_DAMAGED)
XX fuel += min(sp->tubes[i].load, 10);
XX fuel += sp->pods;
XX antimatter_hit((char *) sp, sp->x, sp->y, fuel);
XX lp->type = 0;
XX sp->status |= S_DEAD;
XX}
XX
XX
XXint torp_detonate(tp, lp)
XXstruct torpedo *tp;
XXstruct list *lp;
XX{
XX
XX switch (lp->type) {
XX case I_SHIP:
XX printf("we aren't supposed to be here \n");
XX break;
XX case I_TORPEDO:
XX printf(":: torp %d ::\n", tp->id);
XX break;
XX case I_PROBE:
XX printf("** probe %d **\n", tp->id);
XX break;
XX case I_ENG:
XX printf("## %s engineering ##\n", tp->from->name);
XX break;
XX default:
XX printf("what the heck is this\n");
XX break;
XX }
XX antimatter_hit((char *) tp, tp->x, tp->y, tp->fuel);
XX return_slot(tp->id);
XX delitem(lp);
XX}
SHAR_EOF
if test 5253 -ne "`wc -c firing.c`"
then
echo shar: error transmitting firing.c '(should have been 5253 characters)'
fi
echo shar: extracting globals.c '(6478 characters)'
sed 's/^XX//' << \SHAR_EOF > globals.c
XX/*
XX *
XX * TREK73: globals.c
XX *
XX * Global variable declarations
XX *
XX */
XX#include "defines.h"
XX#include "structs.h"
XX
XXextern int fire_phasers(), fire_tubes(), lock_phasers(), lock_tubes(),
XX turn_phasers(), turn_tubes(), load_tubes(), phaser_status(),
XX tube_status(), launch_probe(), probe_control(), pos_report(),
XX pos_display(), pursue(), elude(), helm(), self_scan(), scan(),
XX alter_power(), jettison_engineering(), detonate_engineering(),
XX alterpntparams(), play_dead(), corbomite_bluff(), surrender_ship(),
XX request_surrender(), self_destruct(), abort_self_destruct(),
XX survivors(), help();
XX
XXextern int
XX standard_strategy();
XX
XX
XXchar *statmsg[] = {
XX "computer inoperable",
XX "sensors annihilated",
XX "probe launcher shot off",
XX "warp drive disabled",
XX "engineering jettisoned",
XX} ;
XX
XXstruct damage p_damage = {
XX 50, 2, 20, 3, 10, 3,
XX 1000, "Computer destroyed.",
XX 500, "Sensors demolished.",
XX 100, "Probe launcher crushed.",
XX 50, "Warp drive destroyed.",
XX} ;
XX
XXstruct damage a_damage = {
XX 100, 3, 10, 2, 7, 6,
XX 1500, "Computer banks pierced.",
XX 750, "Sensors smashed.",
XX 150, "Probe launcher shot off.",
XX 75, "Warp drive disabled.",
XX} ;
XX
XX
XXchar *baddies[MAXFOERACES][MAXBADS] = {
XX /* Klingons*/
XX "Annihilation", "Crusher", "Devastator", "Merciless", "Nemesis",
XX "Pitiliess", "Ruthless", "Savage", "Vengeance",
XX /* Romulan */
XX "Avenger", "Defiance", "Fearless", "Harrower", "Intrepid",
XX "Relentless", "Seeker", "Torch", "Vigilant",
XX /* Kzinti */
XX "Black Hole", "Comet", "Ecliptic", "Galaxy", "Meteor",
XX "Nova", "Pulsar", "Quasar", "Satellite",
XX /* Gorn */
XX "Chimericon", "Dragonicon", "Ornithocon", "Predatoricon", "Reptilicon",
XX "Serpenticon", "Tyranicon", "Vipericon", "Wyvericon",
XX /* Orion */
XX "Arrogant", "Boisterous", "Daring", "Flamboyant", "Heavensent",
XX "Jolly Tar", "Magnificent", "Resplendent", "Stupendous",
XX /* Hydran */
XX "Baron", "Chancellor", "Dictator", "Emperor", "Lord",
XX "Monarch", "President", "Shogun", "Viscount",
XX /* Lyran */
XX "Bandit", "Claw", "Dangerous", "Fury", "Mysterious",
XX "Sleek", "Tiger", "Vicious", "Wildcat",
XX /* Tholian */
XX "Bismark", "Centaur", "Draddock", "Forbin", "Kreiger",
XX "Shlurg", "Trakka", "Varnor", "Warrior",
XX /* Monty Python */
XX "Blancmange", "Spam", "R.J. Gumby", "Lumberjack", "Dennis Moore",
XX "Ministry of Silly Walks", "Argument Clinic", "Piranha Brothers",
XX "Upper Class Twit of the Year",
XX} ;
XX
XXchar *feds[] = {
XX "Constitution", "Enterprise", "Hornet", "Lexington", "Potempkin",
XX "Hood", "Kongo", "Republic", "Yorktown",
XX} ;
XX
XXchar *foeraces[] = {
XX "Klingon", "Romulan", "Kzinti", "Gorn", "Orion", "Hydran",
XX "Lyran", "Tholian", "Monty Python",
XX} ;
XX
XXchar *foeempire[] = {
XX "Empire", "Star Empire", "Hegemony", "Confederation", "Pirates",
XX "Monarchy", "Something", "Holdfast", "Flying Circus",
XX};
XX
XXchar *foeshiptype[] = {
XX "D-7 Battle Cruiser", "Sparrowhawk", "Strike Cruiser",
XX "Heavy Cruiser", "Raider Cruiser", "Ranger-class Cruiser",
XX "Tiger-class Cruiser", "Patrol Cruiser", "Thingee",
XX};
XX
XXchar *foecaps[] = {
XX "Bolak", "Kang", "Koloth", "Kor", "Korax", "Krulix", "Quarlo",
XX "Tal", "Troblak"
XX};
XX
XXint init_p_turn[] = {
XX -90, 0, 0, 90
XX};
XX
XXint init_t_turn[] = {
XX -120, -60, 0, 0, 60, 120
XX};
XX
XX/*
XX * for the linked list of items in space
XX */
XXstruct list head;
XXstruct list *tail;
XX
XX/*
XX * Global definitions
XX */
XXfloat segment = 0.2; /* Segment time */
XXfloat timeperturn = 2.0; /* Seconds per turn */
XX
XXstruct ship *shiplist[10]; /* All the ships in the battle */
XX
XXchar captain[30]; /* captain's name */
XXchar science[30]; /* science officer's name */
XXchar engineer[30]; /* engineer's name */
XXchar com[30]; /* communications officer's name */
XXchar nav[30]; /* navigation officer's name */
XXchar helmsman[30]; /* helmsman's name */
XXchar title[9]; /* captain's title */
XXchar foerace[11]; /* enemy's race */
XXchar foename[9]; /* enemy's captain's name */
XXchar foestype[30]; /* enemy's ship type */
XXchar empire[30]; /* What the enemy's empire is called */
XXint shipnum; /* number of ships this time out */
XXint terse = 0; /* print out initial description? */
XXint silly = 0; /* Use the Monty Python's Flying Curcus? */
XXint defenseless = 0; /* defensless ruse status */
XXint corbomite = 0; /* corbomite bluff status */
XXint surrender = 0; /* surrender offered by federation? */
XXint surrenderp = 0; /* Did we request that the enemy surrenders? */
XXchar shutup[HIGHSHUTUP]; /* Turn off messages after first printing */
XXchar slots[300]; /* Id slots */
XXint global = NORMAL; /* Situation status */
XXchar **argp = NULL; /* Argument list for parsit() routine */
XXchar options[100]; /* Environment variable */
XXchar sex[20]; /* From environment */
XXchar shipbuf[10]; /* From environment */
XXchar shipname[20]; /* From environment */
XXchar racename[20]; /* From environment */
XXint reengaged = 0; /* Re-engaging far-off ships? */
XX
XXstruct cmd cmds[] = {
XX { fire_phasers, "1", "Fire phasers", 1 },
XX { fire_tubes, "2", "Fire photon torpedoes", 1 },
XX { lock_phasers, "3", "Lock phasers onto target", 1 },
XX { lock_tubes, "4", "Lock tubes onto target", 1 },
XX { turn_phasers, "5", "Manually rotate phasers", 1 },
XX { turn_tubes, "6", "Manually rotate tubes", 1 },
XX { phaser_status, "7", "Phaser status", 1 },
XX { tube_status, "8", "Tube status", 1 },
XX { load_tubes, "9", "Load/unload torpedo tubes", 1 },
XX { launch_probe, "10", "Launch antimatter probe", 1 },
XX { probe_control, "11", "Probe control", 1 },
XX { pos_report, "12", "Position report", 0 },
XX { pos_display, "13", "Position display", 0 },
XX { pursue, "14", "Pursue an enemy vessel", 1 },
XX { elude, "15", "Elude an enemy vessel", 1 },
XX { helm, "16", "Manually change course and speed", 1 },
XX { self_scan, "17", "Damage report", 1 },
XX { scan, "18", "Scan enemy (enemy Damage report)", 1 },
XX { alter_power, "19", "Alter power distribution", 1 },
XX { jettison_engineering, "20", "Jettison engineering", 1 },
XX { detonate_engineering, "21", "Detonate engineering", 1 },
XX { alterpntparams, "22", "Alter firing parameters", 1},
XX { play_dead, "23", "Attempt defenseless ruse", 1 },
XX { corbomite_bluff, "24", "Attempt corbomite bluff(s)", 1 },
XX { surrender_ship, "25", "Surrender", 1 },
XX { request_surrender, "26", "Ask enemy to surrender", 1 },
XX { self_destruct, "27", "Initiate self-destruct sequence", 1 },
XX { abort_self_destruct, "28", "Abort self-destruct", 1 },
XX { survivors, "29", "Survivors report", 0 },
XX { help, "30", "Reprints above list", 0 },
XX { NULL, NULL, NULL, 1 },
XX} ;
XX
XX/* Strategy table */
XXint (*strategies[])() = {
XX standard_strategy
XX};
SHAR_EOF
if test 6478 -ne "`wc -c globals.c`"
then
echo shar: error transmitting globals.c '(should have been 6478 characters)'
fi
# End of shell archive
exit 0
Technical Details
Message-ID:
<10401@ucbvax.ARPA>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!ucbvax!okamotoShow Full Headers
Complete Article Headers
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: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!ucbvax!okamoto From: okamoto@ucbvax.ARPA (Doctor Who) Newsgroups: net.sources.games Subject: Trek73 (part 3 of 4) Message-ID: <10401@ucbvax.ARPA> Date: Mon, 16-Sep-85 11:15:07 EDT Article-I.D.: ucbvax.10401 Posted: Mon Sep 16 11:15:07 1985 Date-Received: Wed, 18-Sep-85 02:58:03 EDT Organization: University of California at Berkeley Lines: 1115