games-request@tekred.TEK.COM (12/18/87)
Submitted by: Jeff Okamoto <okamoto%hpccc@hplabs.HP.COM> Comp.sources.games: Volume 3, Issue 24 Archive-name: trek73/Part03 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 3 (of 6)." # Contents: man/00.t man/02.t man/bpv.6 src/damage.c src/grammar.y # src/init.c src/special.c src/structs.h # Wrapped by billr@tekred on Thu Dec 17 11:43:34 1987 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f man/00.t -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"man/00.t\" else echo shar: Extracting \"man/00.t\" \(3697 characters\) sed "s/^X//" >man/00.t <<'END_OF_man/00.t' X.ND X.ds CF - % - X.ds LH STAR X.ds CH X.ds RH TREK X.nr PO 0.5i X.nr LL 6.5i X.nr PD 0 X.na X.LP X.FS (R) XStar Trek is a registered trademark of Paramount Pictures. X.FE X.FS (TM) XStar Fleet Battles is a trademark held jointly by Task Force Games Xand Amarillo Design Bureau. X.FE X.ce 3 XT R E K 7 3 X.sp XVersion 4.0 X.sp XA Star Trek Battle Simulation X.sp X.PP XTrek73 is a computer-simulated battle based on the famous XStar Trek television series and Xthe board game Star Fleet Battles. XVia computer terminal, you can clash with enemy Xbattle cruisers, such as Klingon D-7's and Romulan Sparrowhawks, Xand use the same strategies Xthat Captain Kirk has used. XLike Kirk, you control a Federation vessel similar to the XEnterprise; a computer program directs the enemy. XVictory can fall into several categories: X.sp X.PP XDecisive Victory -- You completely destroy or cripple the Xattacking force. X.sp X.PP XTactical Victory -- You out-maneuver the enemy using Xhigh-speed escapes, corbomite bluffs, `play dead' tactics; Xor the enemy surrenders. X.sp X.PP XMoral Victory -- You surrender or self-destruct and destroy Xeach other. X.sp X.PP XAll distances are measured in megameters, one million meters X(abbreviated `M'). XSpeed is expressed in `Warp Factors'. XEach warp factor equals 100M per second.\** X.FS XAlthough technically incorrect, it does save the player from Xhaving to compute cube roots. X.FE XAll angles are expressed in common degrees from zero to X360, measured counter-clockwise from the x-axis, similar to Xreading a protractor. XOnly two dimensions are used.\** X.FS XThis saves the player from having to work out problems in Xspherical trigonometry. X.FE X.sp X.PP XPlay is as follows: X.sp X.PP X1. You issue one of a number of commands (fire phasers, change Xcourse, launch antimatter pods, surrender, etc.) by typing Xthe appropriate code number into the keyboard; X.sp X.PP X2. The enemy, under programmed instructions, issues a Xsimilar command; X.sp X.PP X3. Both your commands are executed (phasers are fired, Xprobes are launched, damages are assessed, courses changed, Xetc.) while the vessels move through space; X.sp X.PP X4. Unless certain end-game conditions are met (you destroy Xthe enemy, the enemy destroys you, your out-maneuver the Xenemy, you both destroy each other, or one party surrenders) Xthe above steps are repeated. X.sp X.PP XAppendix 1 depicts the Enterprise's power circuits. X.sp X.PP XAppendix 2 displays certain weapon and shield angles. X.sp X.PP XAppendix 3 lists certain weapon and vessel specifications. X.sp X.PP XAppendix 4 lists initial deployment of resources. X.sp X.PP XAppendix 5 contains the designer's notes. X.sp 2 X.LP X.in 1i X.ta .5i X.nf XCODE COMMAND X==== ======= X.sp X1 Fire Phasers X2 Fire Photon Torpedos X3 Lock Phasers Onto Target X4 Lock Tubes Onto Target X5 Manually Rotate Phasers X6 Manually Rotate Tubes X7 *Phaser Status X8 *Tube Status X9 Load/Unload Torpedo Tubes X10 Launch Antimatter Probe X.sp X11 Probe Control (Detonate, Redirect, Lock) X12 *Position Report X13 *Position Display X14 Pursue An Enemy Vessel X15 Run From An Enemy Vessel X16 Manually Change Course And Speed X17 *Damage Report X18 Scan Enemy (Damage Report Of Enemy) X19 Alter Power Distribution X20 Jettison Engineering X.sp X21 Detonate Engineering X22 Alter Torpedo And Phaser Firing Parameters X23 Attempt Defenseless Ruse X24 Attempt Corbomite Bluff(s) X25 Surrender X26 Ask Enemy to Surrender X27 Initiate Self-Destruct Sequence X28 Abort Self-Destruct X29 *Survivors Report X30 *Print Version Number X.sp X31 *Save Game X32 *Reprints Above List X.sp X*Does Not Use A Turn X.in 0 X.fi X.bp END_OF_man/00.t if test 3697 -ne `wc -c <man/00.t`; then echo shar: \"man/00.t\" unpacked with wrong size! fi # end of overwriting check fi if test -f man/02.t -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"man/02.t\" else echo shar: Extracting \"man/02.t\" \(8375 characters\) sed "s/^X//" >man/02.t <<'END_OF_man/02.t' X.sp X.LP X11. Probe Control. X.PP X[y | [n [Probe] [y | [n [Target | [<CR> Course]]]]]] X.PP XProbe control allows you to detonate or redirect probes Xwhich may have missed. X.sp X.LP X12. Position Report. X.PP XPosition reports are vital since valuable information on Xcourses, bearings and ranges are given to aid the formation Xof good strategy. X.PP XEach ship is listed along with its current speed, course, Xand bearing. XAlso listed is your relative bearing to that ship. XA relative bearing of 0 means you are pointed directly at Xthe ship, whereas a relative bearing of 180 means you are Xpointed directly away from the ship. XNext is the reverse relative bearing, which gives the relative Xbearing of you with respect to the ship listed. X.PP XCloaked ships show up with an asterisk (*) before the name, Xand the information displayed is the last available information Xon those ships. XIf no position report has been performed prior to the enemy ship Xengages a cloaking device, no information will be available on Xthat ship. XThis command does not use a turn. X.sp X.LP X13. Position Display. X.PP X[Radius of scan] X.PP XPosition displays, similar to radar scans, show objects Xwhich surround your vessel. XThe Enterprise is indicated by a `+', jettisoned engineering Xsections by a `#', probes by a `*', torpedos by a `:', and Xenemy vessels by the first letter of their names. XEnemy vessels that are cloaked appear as lower case letters. XThis command does not use a turn. X.sp X.LP X14. Pursue An Enemy Vessel. X.PP X[Target Name] [Warp Factor] X.PP XThis order instructs the ship's navigation to face an enemy Xvessel whenever possible. XObviously it is impossible to pursue a cloaked vessel. X.sp X.LP X15. Run From An Enemy Vessel. X.PP X[Target Name] [Warp Factor] X.PP XThis order, just the opposite of order #14, instructs the Xnavigation to keep the stern of the Enterprise towards an Xenemy vessel whenever possible. XRunning from a cloaked vessel is not very useful. X.sp X.LP X16. Manually Change Course and Speed. X.PP X[Course] [Warp Factor] X.PP XThis order instructs navigation to maintain a fixed course Xand speed. XThe following information applies to the above three orders: X.sp X.PP XYour maximum rotation rate when turning is: X.ce Xdegrees per sec = 5 * (11 - current warp speed) X.sp X.PP XAccordingly, you can turn 55 degrees at warp one, 50 at Xwarp two, and so on down to 10 degrees at warp nine. XIn other words, the faster you travel, the less Xmaneuverable you are. XYou are also less maneuverable if your warp drive is damaged Xor destroyed. XYour maximum speed is warp nine, Xthe enemy's is warp eleven. X.sp X.LP X17. Damage Report. X.PP XThis report informs you of the status of your ship. XA destroyed computer make commands 3 (lock Xphasers), 4 (lock torpedos), 14 (pursue), 15 (run), 27 X(initiate self-destruct), and 28 (abort self-destruct) Ximpossible to execute. XYou will be required to manually rotate phasers and Xtorpedos, and manually change course and speed. XDestroyed sensors makes commands 13 (position display) and X18 (scan) impossible. XA destroyed probe launcher prevents you from Xlaunching probes (command 10). XA destroyed warp drive slows your maximum speed to warp 0.99 and Xseverely limits your maneuverability. XSee order 20 about jettisoned engineering section. XWhen your crew of 450 dies, your vessel is as good as dead. XThere are 350 men aboard each enemy vessel. X.sp X.PP XAll of the above systems can be partially damaged. XA damaged warp drive (common) lowers your maximum speed Xand maneuverability. XA damaged probe launcher (sometimes) may refuse to launch. XDamaged sensors (rare) may not be able to return position Xdisplays or be able to scan an enemy. XA damaged computer (very rare) will sometimes refuse to lock onto Xtargets, and in addition, when damaged, may lose some of the Xlocks held by the weapons or by the helm. X.sp X.PP XShield percentage is calculated by its energy drain times Xits operating efficiency. XEfficiency starts at 100 and declines with each hit. XNo damages of any kind are incurred when a shield absorbs Xits first hit, no matter how great the hit. XShield one is 1.5 times as strong as the other three shields. X.sp X.PP X`Efficiency' indicates the number of energy units being Xburned per warp factor per second. XThis number is initially one (.75 for enemy) and increases Xper hit. X.sp X.PP X`Regeneration' indicates the number of energy units being Xgained per second. XInitially set at 10, this number decreases per hit. X.sp X.PP X`Fuel capacity' indicates the number of matter-antimatter Xpods a vessel has aboard. XThis number rapidly decreases with each torpedo or probe Xfired. X.sp X.PP X`Fuel' indicates the number of matter-antimatter pods which Xare filled with energy. XThis number rapidly decreases when maintaining high warp Xspeeds or firing phasers. X.sp X.LP X18. Scan Enemy (Damage Report of Enemy). X.PP X[Ship Name | Probe id | #Ship Name] X.PP XThis command gives a damage report of an enemy ship in Xthe same format as command 17. XYou cannot scan an enemy who is cloaked. X.PP XBy giving the id number of a probe, information about it can Xbe gathered. XThe same information can be gathered about a ship's jettisoned Xengineering by prepending a '#' before the ship's name. X.sp X.LP X19. Alter Power Distribution. X.PP X[Shld 1 drain [* | ... Sh 4]] [Phsr 1 drain [* | ... Ph 4]] X.PP XThe synopsis of this command can be confusing. XThe first set of numbers gives the drains for each shield. XAll four shield drains can be specified, but Xif a star is used immediately after a shield drain X(eg, 19 0.5 1*), Xthen the remaining shields will all be given a drain equal to the Xnumber preceding the '*'. X(Thus, in the above example, shield 1's drain is 0.5, whereas Xshields 2, 3, and 4 have a drain of 1). XThe same applies to the phaser drains. X.sp X.PP XThe power circuits of all vessels are illustrated in XAppendix 2. XDilithium crystals produce energy much like generators. XThis power is then used to maintain warp speeds, recharge Xantimatter pods in the engine reserve, recharge phaser Xbanks, or maintain shield power. XYour initial regeneration is ten, however, the shields normally Xdrain four units and the engines require one unit per each Xwarp-second. X.sp X.PP XShields can be thought of as electromagnets. XThe more energy put into them, the stronger their force field Xbecomes. XTherefore, a shield's overall percentage is calculated by Xthe following formula: X.sp X.ce Xshield percentage = (energy in)(effective %) X.sp X.PP XNotice that dropping power to a shield has the same effect Xas having it hit. XNotice also that if your regeneration drops below four, Xyou may have to discharge your phaser banks if you wish to maintain Xfull shield power. X.sp X.PP XPhaser banks, similar to batteries, not only discharge (when Xfiring), but also recharge. XInitially, they are set to recharge fully in one second X(+10) so that you can continually use them. XHowever, they can discharge fully (-10) in one second to Xprovide extra power to shields, warp engines, or engine Xreserve. X.sp X.PP XUnder most conditions, you need not concern yourself with Xpower distribution unless some special need arises. XDistribution, for the most part, is automatic. XRegeneration is calculated first; that power is placed in Xreserve, along with any discharged phaser units. XShield drain is calculated next, then the cloaking device, Xthen phaser and engine drains. X.sp X.PP XBe concerned with wasting power by indiscriminately firing Xphasers and torpedos, maintaining speeds over warp three, or Xdumping scores of units onto antimatter probes. XHuge power losses cannot be made up in battle. X.sp X.LP X20. Jettison Engineering. X.PP XAlthough this order was never executed in the television Xseries, it is quite possible. XJettisoning engineering has serious consequences, but it may Xbe your only course of action. X.sp X.PP XOne would jettison engineering if being pursed by vessels, Xprobes or torpedos, or as a suicidal gesture. X.sp X.PP XThe following things happen when engineering is jettisoned: XYou lose all your fuel and reserve capacity; Xyou lose your regeneration; Xyou lose your warp drive; Xyour lose your probe launcher; Xyou lose your shields until you designate phasers to discharge; Xthe engineering section itself decelerates to a stop; Xa ten second time delay on it is set (hopefully, Xwhen it does explode, you are far from its effects); Xyou lose your cloaking device; Xyour phasers and torpedos are now free to fire in any direction. END_OF_man/02.t if test 8375 -ne `wc -c <man/02.t`; then echo shar: \"man/02.t\" unpacked with wrong size! fi # end of overwriting check fi if test -f man/bpv.6 -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"man/bpv.6\" else echo shar: Extracting \"man/bpv.6\" \(638 characters\) sed "s/^X//" >man/bpv.6 <<'END_OF_man/bpv.6' X.TH BPV 6 "17 Oct 1986" X.UC 4 X.SH NAME Xbpv - tool for trek73 X.SH SYNOPSIS Xbpv X.SH DESCRIPTION X.PP X.I Bpv Xis a program used in conjunction with X.I shipyard X(6) to construct ships that can be used in the game X.I trek73 X(6). X.PP X.I XBpv Xprints out a list of the basic point values (BPV) Xof the four standard ship classes X(DN, CA, CL, and DD). X.PP XThis allows a person using X.I shipyard X(6) Xto compare their ships with the standard ship classes. X.SH SEE ALSO Xtrek73(6) X.br XJeff Okamoto, X.I "The Star Trek Battle Manual" X.SH AUTHOR XJeff Okamoto X.SH BUGS XHopefully none. XBug reports should be sent to: ..!hplabs!hpccc!okamoto and ..!ucbvax!yee. END_OF_man/bpv.6 if test 638 -ne `wc -c <man/bpv.6`; then echo shar: \"man/bpv.6\" unpacked with wrong size! fi # end of overwriting check fi if test -f src/damage.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"src/damage.c\" else echo shar: Extracting \"src/damage.c\" \(7025 characters\) sed "s/^X//" >src/damage.c <<'END_OF_src/damage.c' X#ident "@(#) TREK73 $Header: damage.c,v 1.1 87/10/09 11:03:30 okamoto Exp $" X/* X * $Source: /ccc/okamoto/src/trek/src/RCS/damage.c,v $ X * X * $Header: damage.c,v 1.1 87/10/09 11:03:30 okamoto Exp $ X * X * $Log: damage.c,v $ X * Revision 1.1 87/10/09 11:03:30 11:03:30 okamoto (Jeff Okamoto) X * Initial revision X * X */ X/* X * TREK73: damage.c X * X * Damage routines X * X * damage, check_locks X * X */ X X#include "externs.h" X X Xdamage(hit, ep, s, dam, flag) Xint hit; Xstruct ship *ep; Xint s; Xstruct damage *dam; Xint flag; X{ X register int i; X register int j; X register int k; X float f1; /* Damage factor except for shields */ X float f2; /* Shield damage factor */ X int percent; X struct ship *fed; X X fed = shiplist[0]; X printf("hit %d on %s's shield %d\n", hit, ep->name, s); X s--; X /* X * Note that if the shield is at 100% efficiency, no X * damage at all will be taken (except to the shield itself) X */ X f1 = hit * (1.0 - ep->shields[s].eff * ep->shields[s].drain); X if (f1 < 0) X return 0; X /* Calculate shield damage */ X if (flag == D_ANTIMATTER) X f2 = ep->tu_damage * 100; X else if (flag == D_PHASER) X f2 = ep->ph_damage * 100; X if (s == 0) X f2 *= SHIELD1; X ep->shields[s].eff -= max(hit/f2, 0); X if (ep->shields[s].eff < 0.0) X ep->shields[s].eff = 0.0; X /* Calculate loss of fuel, regeneration, etc. */ X ep->eff += f1/dam->eff; X ep->pods -= f1/dam->fuel; X ep->energy -= f1/dam->fuel; X ep->regen -= f1/dam->regen; X if (ep->regen < 0.0) X ep->regen = 0.0; X if (ep->pods < 0.0) X ep->pods = 0.0; X if (ep->energy < 0.0) X ep->energy = 0.0; X if (ep->pods < ep->energy) X ep->energy = ep->pods; X /* Kill some crew */ X if (ep->complement > 0) { X j = f1 * dam->crew; X if (j > 0) X ep->complement -= randm(j); X if (ep->complement < 0) X ep->complement = 0; X } X /* Damage some weapons */ X j = f1/dam->weapon; X for(i=0; i<j; i++) { X k = randm(ep->num_phasers + ep->num_tubes) - 1; X if (k < ep->num_phasers) { X if (ep->phasers[k].status & P_DAMAGED) X continue; X ep->phasers[k].status |= P_DAMAGED; X ep->phasers[k].target = NULL; X /* X * Reroute the energy X * back to the engines X */ X ep->energy = min(ep->pods, ep->energy X + ep->phasers[k].load); X ep->phasers[k].load = 0; X ep->phasers[k].drain = 0; X k++; X if (ep == fed) X printf(" phaser %d damaged\n", k); X } else { X k -= ep->num_phasers; X if (ep->tubes[k].status & T_DAMAGED) X continue; X /* X * If tubes are damaged, reroute the pods X * back to the engines X */ X ep->pods += ep->tubes[k].load; X ep->energy += ep->tubes[k].load; X ep->tubes[k].load = 0; X ep->tubes[k].status |= T_DAMAGED; X ep->tubes[k].target = NULL; X k++; X if (ep == fed) X printf(" tube %d damaged\n", k); X } X } X /* Damage the different systems */ X for (i=0; i<S_NUMSYSTEMS; i++) { X if (is_dead(ep, i)) /* Don't damage a dead system */ X continue; X percent = 0; X if (randm(dam->stats[i].roll) < f1) { X /* A better method should be found */ X percent = (int) randm((int) f1); X/* X * The expected value for the percent damage to each system is roughly X * equal to: X * f1 * f1 / (2 * dam->stats[i].roll) X * Only these damages are proportional to hit squared. All others are X * linearly proportional. This includes shield damage, ship's fuel X * supply, consumption and regeneration rates, casualties, and weapons. X * (When weapons are damaged, they are 100% damaged - the number of X * weapons damaged is proportional to hit). I think the old way X * decided whether or not to completely damage a system based on the X * comparison "randm(dam->stats[i].roll) < f1". This is almost like X * the weapons are still handled. Another possibility is to always X * damage each system by: X * 100 * randm((int)f1) / dam->stats[i].roll X * percent. This adds some randomness and makes the approx. expected X * value of the damage to each system: X * 100 * f1 / (2 * dam->stats[i].roll) X * percent. Perhaps this isn't such a good idea after all; this is X * 100/f1 times the current expected value, often > 2. And it is X * actually somewhat less random since each system gets damaged each X * time. I had thought that the damage should be directly proportional X * to f1, not to its square. But perhaps it makes sense that a hit X * twice as big has an expected value of damage four times as big as X * that from a smaller hit. The actual damage any given time is still X * proportional to the hit, but the probability that any damage will be X * done at all is also directly proportional to the hit. This is a X * pretty good system after all. [RJN] X */ X ep->status[i] += percent; X if (ep->status[i] > 100) X ep->status[i] = 100; X if (ep == fed) { X if (is_dead(ep, i)) X printf(" %s\n", X dam->stats[i].mesg); X else X printf(" %s damaged.\n", X sysname[i]); X } X /* Now check for the effects of the damage */ X /* Do the effects of a totally destroyed system */ X if (is_dead(ep, i)) { X switch(i) { X case S_SENSOR: X case S_PROBE: X /* No bookkeeping needed */ X break; X case S_WARP: X /* Reduce max speed */ X ep->max_speed = 1.0; X break; X case S_COMP: X check_locks(ep, 100, fed); X break; X default: X printf("How'd we get here?\n"); X } X } else { X /* Now check partially damaged systems */ X switch(i) { X case S_SENSOR: X case S_PROBE: X /* No bookkeeping needed */ X break; X case S_WARP: X f2 = percent * ep->orig_max / 100; X ep->max_speed -= f2; X if (ep->max_speed < 1.0) { X ep->max_speed = 1.0; X ep->status[S_WARP] = 100; X } X break; X case S_COMP: X check_locks(ep, percent, fed); X break; X default: X printf("Oh, oh....\n"); X } X } X } X } X#ifdef HISTORICAL X /* X * Historically, if more than 43 points of damage were done X * to the ship, it would destroy itself. This led to much X * abuse of probes and thus has been enclosed inside of X * an #ifdef X */ X if (f1 > 43) X ep->delay = 1.; X#endif X return 0; X} X Xcheck_locks(ep, percent, fed) Xstruct ship *ep; Xint percent; Xstruct ship *fed; X{ X register int i, j = 0; X X for (i=0; i<ep->num_phasers; i++) { X if ((ep->phasers[i].target != NULL) X && (randm(100) <= percent)) { X ep->phasers[i].target = NULL; X if (ep != fed) X continue; X if (!j) X printf("Computer: Phaser(s) %d", i+1); X else X printf(", %d", i+1); X j++; X } X } X if (j > 1) X puts(" have lost their target locks."); X else if (j == 1) X puts(" has lost its target lock."); X j = 0; X for (i=0; i<ep->num_tubes; i++) { X if ((ep->tubes[i].target != NULL) X && (randm(100) <= percent)) { X ep->tubes[i].target = NULL; X if (ep != fed) X continue; X if (!j) X printf("Computer: Tube(s) %d", i+1); X else X printf(", %d", i+1); X j++; X } X } X if (j > 1) X puts(" have lost their target locks."); X else if (j == 1) X puts(" has lost its target lock."); X if ((ep->target != NULL) && (randm(100) <= percent)) { X ep->target = NULL; X ep->relbear = 0; X if (ep == fed) X printf("Computer: %s has lost helm lock\n", X shipname); X } X} END_OF_src/damage.c if test 7025 -ne `wc -c <src/damage.c`; then echo shar: \"src/damage.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f src/grammar.y -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"src/grammar.y\" else echo shar: Extracting \"src/grammar.y\" \(7008 characters\) sed "s/^X//" >src/grammar.y <<'END_OF_src/grammar.y' X%token <dval> NUMBER X%token <sval> NAME X X%token ABORT X%token ALL X%token CONTROL X%token CORB X%token COURSE X%token DAMAGE X%token DEAD X%token DELAY X%token DEMAND X%token DESTR X%token DET X%token DISPLAY X%token ELUDE X%token ENG X%token FIRE X%token HELP X%token JETT X%token LAUNCH X%token LOAD X%token LOCK X%token PARAM X%token PHASER X%token POWER X%token PROBE X%token PROXIMITY X%token PURSUE X%token ROTATE X%token SAVE X%token SCAN X%token SPREAD X%token STATUS X%token SURREND X%token SURV X%token TACTIC X%token TOWARD X%token TUBE X%token UNLOAD X%token VERSION X%token WARP X X%type <dval> number1 X%type <dval> number2 X%type <dval> number3 X%type <dval> number4 X%type <sval> name X X%{ X#ident "@(#) TREK73 $Header: grammar.y,v 1.2 87/10/09 12:24:34 okamoto Exp $" X/* X * $Source: /ccc/okamoto/src/trek/src/RCS/grammar.y,v $ X * X * $Header: grammar.y,v 1.2 87/10/09 12:24:34 okamoto Exp $ X * X * $Log: grammar.y,v $ X * Revision 1.2 87/10/09 12:24:34 12:24:34 okamoto (Jeff Okamoto) X * Added many extra stuff X * X * Revision 1.1 87/10/09 12:22:55 12:22:55 okamoto (Jeff Okamoto) X * Initial revision X * X */ X#include "union.h" X extern char parsed[]; X char string[80]; X double num1; X double num2; X double num3; X double num4; X%} X X%% X Xorders : X | '\n' X | error X { yyclearin; } X | phfire X | tufire X | phlock X | tulock X | phrot X | turot X | phstat X | tustat X | tuload X | probe X | control X | tactical X | display X | pursue X | elude X | course X | damage X | scan X | power X | jettison X | detonate X | dead X | param X | corb X | surr X | esurr X | selfd X | abort X | surv X | version X | save X | help X ; X Xnumber1 : NUMBER X { num1 = yylval.dval; } X ; X Xnumber2 : NUMBER X { num2 = yylval.dval; } X ; Xnumber3 : NUMBER X { num3 = yylval.dval; } X ; Xnumber4 : NUMBER X { num4 = yylval.dval; } X ; X Xname : NAME X { strcpy(string, yylval.sval); } X ; X Xphfire : FIRE PHASER number1 SPREAD number2 X { sprintf(parsed, "1 %.0f %.0f", num1, num2);} X | FIRE PHASER number1 X { sprintf(parsed, "1 %.0f", num1); } X | FIRE ALL PHASER SPREAD number1 X { sprintf(parsed, "1 all %.0f", num1); } X | FIRE ALL PHASER X { strcpy(parsed, "1 all"); } X | FIRE PHASER X { strcpy(parsed, "1"); } X ; X Xtufire : FIRE TUBE number1 X { sprintf(parsed, "2 %.0f", num1); } X | FIRE ALL TUBE X { sprintf(parsed, "2 all"); } X | FIRE TUBE X { strcpy(parsed, "2"); } X ; X Xphlock : LOCK PHASER number1 name X { sprintf(parsed, "3 %.0f %s", num1, string);} X | LOCK PHASER number1 X { sprintf(parsed, "3 %.0f", num1); } X | LOCK ALL PHASER name X { (void)sprintf(parsed, "3 all %s", string); } X | LOCK ALL PHASER X { strcpy(parsed, "3 all"); } X | LOCK PHASER X { strcpy(parsed, "3"); } X ; X Xtulock : LOCK TUBE number1 name X { sprintf(parsed, "4 %.0f %s", num1, string);} X | LOCK TUBE number1 X { sprintf(parsed, "4 %.0f", num1); } X | LOCK ALL TUBE name X { (void)sprintf(parsed, "4 all %s", string); } X | LOCK ALL TUBE X { strcpy(parsed, "4 all"); } X | LOCK TUBE X { strcpy(parsed, "4"); } X ; X Xphrot : ROTATE ALL PHASER number1 X { sprintf(parsed, "5 all %.0f", num1); } X | ROTATE ALL PHASER X { strcpy(parsed, "5 all"); } X | ROTATE PHASER number1 number2 X { sprintf(parsed,"5 %.0f %.0f", num1, num2); } X | ROTATE PHASER number1 X { sprintf(parsed,"5 %.0f", num1); } X ; X Xturot : ROTATE ALL TUBE number1 X { sprintf(parsed, "6 all %.0f", num1); } X | ROTATE ALL TUBE X { strcpy(parsed, "6 all"); } X | ROTATE TUBE number1 number2 X { sprintf(parsed,"6 %.0f %.0f", num1, num2); } X | ROTATE TUBE number1 X { sprintf(parsed,"6 %.0f", num1); } X ; X Xphstat : PHASER STATUS X { strcpy(parsed, "7"); } X ; X Xtustat : TUBE STATUS X { strcpy(parsed, "8"); } X ; X Xtuload : LOAD ALL TUBE X { strcpy(parsed, "9 l all"); } X | UNLOAD ALL TUBE X { strcpy(parsed, "9 u all"); } X | LOAD TUBE number1 X { sprintf(parsed, "9 l %.0f", num1); } X | UNLOAD TUBE number1 X { sprintf(parsed, "9 u %.0f", num1); } X | LOAD TUBE X { strcpy(parsed, "9 l"); } X | UNLOAD TUBE X { strcpy(parsed, "9 u"); } X ; X Xprobe : LAUNCH PROBE X { strcpy(parsed, "10"); } X | LAUNCH PROBE number1 X { sprintf(parsed, "10 %.0f", num1); } X | LAUNCH PROBE number1 DELAY number2 X {sprintf(parsed, "10 %.0f %.0f", num1, num2); } X | LAUNCH PROBE number1 DELAY number2 PROXIMITY number3 X { sprintf(parsed, "10 %.0f %.0f %.0f", num1, num2, num3); } X | LAUNCH PROBE number1 DELAY number2 PROXIMITY number3 TOWARD name X { sprintf(parsed, "10 %.0f %.0f %.0f %s", num1, num2, num3, string); } X | LAUNCH PROBE number1 DELAY number2 PROXIMITY number3 COURSE number4 X { sprintf(parsed, "10 %.0f %.0f %.0f\n\r %.0f", num1, num2, num3, num4); } X ; X Xcontrol : CONTROL PROBE number1 X { sprintf(parsed, "11 %.0f", num1); } X | CONTROL PROBE X { strcpy(parsed, "11"); } X | PROBE CONTROL number1 X { sprintf(parsed, "11 %.0f", num1); } X | PROBE CONTROL X { strcpy(parsed, "11"); } X ; X Xtactical: TACTIC X { strcpy(parsed, "12"); } X ; X Xdisplay : DISPLAY number1 X { sprintf(parsed, "13 %.0f", num1); } X | DISPLAY X { strcpy(parsed, "13"); } X ; X Xpursue : PURSUE name WARP number1 X { sprintf(parsed, "14 %s %f", string, num1);} X | PURSUE name number1 X { sprintf(parsed, "14 %s %f", string, num1);} X | PURSUE name X { sprintf(parsed, "14 %s", string); } X | PURSUE X { strcpy(parsed, "14"); } X ; X Xelude : ELUDE name WARP number1 X { sprintf(parsed, "15 %s %f", string, num1);} X | ELUDE name number1 X { sprintf(parsed, "15 %s %f", string, num1);} X | ELUDE name X { sprintf(parsed, "15 %s", string); } X | ELUDE X { strcpy(parsed, "15"); } X ; X Xcourse : COURSE number1 WARP number2 X { sprintf(parsed, "16 %.0f %0f", num1, num2);} X | COURSE number1 number2 X { sprintf(parsed, "16 %.0f %0f", num1, num2);} X | COURSE number1 X { sprintf(parsed, "16 %.0f", num1);} X | COURSE COURSE number1 WARP number2 X { sprintf(parsed, "16 %.0f %0f", num1, num2);} X | COURSE COURSE number1 number2 X { sprintf(parsed, "16 %.0f %0f", num1, num2);} X | COURSE COURSE number1 X { sprintf(parsed, "16 %.0f", num1);} X ; X Xdamage : DAMAGE X { strcpy(parsed, "17"); } X ; X Xscan : SCAN name X { sprintf(parsed, "18 %s", string); } X | SCAN number1 X { sprintf(parsed, "18 %.0f", num1); } X | SCAN X { strcpy(parsed, "18"); } X ; X Xpower : POWER X { strcpy(parsed, "19"); } X ; X Xjettison: JETT ENG X { strcpy(parsed, "20"); } X ; X Xdetonate: DET ENG name X { sprintf(parsed, "21 %s", string); } X | DET ENG X { strcpy(parsed, "21"); } X ; X Xparam : PARAM X { strcpy(parsed, "22"); } X ; X Xdead : DEAD name X { sprintf(parsed, "23 %s", string); } X | DEAD X { strcpy(parsed, "23"); } X ; X Xcorb : CORB X { strcpy(parsed, "24"); } X ; X Xsurr : SURREND X { strcpy(parsed, "25"); } X ; X Xesurr : DEMAND SURREND X { strcpy(parsed, "26"); } X ; X Xselfd : DESTR X { strcpy(parsed, "27"); } X ; X Xabort : ABORT DESTR X { strcpy(parsed, "28"); } X ; X Xsurv : SURV X { strcpy(parsed, "29"); } X ; X Xversion : VERSION X { strcpy(parsed, "30"); } X ; X Xsave : SAVE X { strcpy(parsed, "31"); } X ; X Xhelp : HELP X { strcpy(parsed, "32"); } X ; X X%% X X#include "lex.yy.c" X Xyywrap() { return(1); } X Xyyerror(s) char *s; { fprintf(stderr, "%s", s); } END_OF_src/grammar.y if test 7008 -ne `wc -c <src/grammar.y`; then echo shar: \"src/grammar.y\" unpacked with wrong size! fi # end of overwriting check fi if test -f src/init.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"src/init.c\" else echo shar: Extracting \"src/init.c\" \(9697 characters\) sed "s/^X//" >src/init.c <<'END_OF_src/init.c' X#ident "@(#) TREK73 $Header: init.c,v 1.1 87/10/09 11:07:33 okamoto Exp $" X/* X * $Source: /ccc/okamoto/src/trek/src/RCS/init.c,v $ X * X * $Header: init.c,v 1.1 87/10/09 11:07:33 okamoto Exp $ X * X * $Log: init.c,v $ X * Revision 1.1 87/10/09 11:07:33 11:07:33 okamoto (Jeff Okamoto) X * Initial revision X * X */ X/* X * TREK73: init.c X * X * Game initialization routines X * X * name_crew, init_ships X * X */ X X#include "externs.h" X#include <fcntl.h> X Xname_crew() X{ X char buf1[30]; X int loop; X int len; X X if (com_delay[0] != 0) X time_delay = atoi(com_delay); X if (science[0] == '\0') X (void) strcpy(science, "Spock"); X if (engineer[0] == '\0') X (void) strcpy(engineer, "Scott"); X if (com[0] == '\0') X (void) strcpy(com, "Uhura"); X if (nav[0] == '\0') X (void) strcpy(nav, "Chekov"); X if (helmsman[0] == '\0') X (void) strcpy(helmsman, "Sulu"); X if (captain[0] == '\0') { X printf("\n\nCaptain: my last name is "); X (void) Gets(buf1, sizeof(buf1)); X if (buf1[0] == '\0') X exit(1); X (void) strncpy (captain, buf1, sizeof captain); X captain[sizeof captain - 1] = '\0'; X } X if (captain[0] == '*') { X terse = 1; X len = strlen(captain) + 1; X for (loop = 1; loop <= len; loop++) X captain[loop-1] = captain[loop]; X } X if (sex[0] != '\0') { X (void) strncpy(buf1, sex, sizeof sex); X sex[sizeof sex - 1] = '\0'; X } else { X printf("%s: My sex is: ",captain); X (void) Gets(buf1, sizeof(buf1)); X if (buf1[0] == '\0') X exit(1); X } X switch(*buf1) { X case 'M': X case 'm': X (void) strcpy(title, "Sir"); X break; X case 'F': X case 'f': X (void) strcpy(title, "Ma'am"); X break; X default : X switch ((int)(random() % 6)) { X case 0: X (void) strcpy(title, "Fag"); X break; X case 1: X (void) strcpy(title, "Fairy"); X break; X case 2: X (void) strcpy(title, "Fruit"); X break; X case 3: X (void) strcpy(title, "Weirdo"); X break; X case 4: X (void) strcpy(title, "Gumby"); X break; X case 5: X (void) strcpy(title, "Freak"); X break; X } X } X} X X Xinit_ships() X{ X struct ship_stat *my_class, *his_class, *ship_class(), *read_class(); X int hisread; /* Did we read from file? */ X register int i; X register int j; X register struct ship *sp; X register struct list *lp; X int range; X float bear; X char *tmp; X int swap1, swap2; X int offset; X int loop; X char buf1[30]; X Xgetships: X printf(" I'm expecting [1-9] enemy vessels "); X (void) Gets(buf1, sizeof(buf1)); X if (buf1[0] == NULL) { X printf("%s: %s, Starfleet Command reports that you have been\n", X com, title); X puts(" relieved of command for dereliction of duty."); X exit(1); X } X if (buf1[0] != '\0') { X i = atoi(buf1); X if (i < 1 || i > MAXESHIPS) { X printf("%s: %s, Starfleet Command reports that it can only\n", X com, title); X printf(" be from 1 to 9. Try again.\n"); X printf("%s: Correct, Lieutenant -- just testing your attention..\n", X captain); X goto getships; X } X shipnum = i; X } else X shipnum = randm(MAXESHIPS); X for (loop = 0; loop < shipnum; loop++); X slots[loop] = 'X'; X offset = !silly; X if (racename[0] == '\0') { X enemynum = randm(MAXFOERACES - offset) - 1; X } else { X for (loop=0; loop<MAXFOERACES; loop++) X if (!strncmp(racename, aliens[loop].race_name, strlen(racename))) { X enemynum = loop; X break; X } X if (loop == MAXFOERACES) { X printf("Cannot find race %s.\n", racename); X enemynum = randm(MAXFOERACES - offset) - 1; X } X } X if (class[0] == '\0') X (void) strcpy(class, "CA"); X if (foeclass[0] == '\0') X (void) strcpy(foeclass, "CA"); X hisread = 0; X if ((my_class = ship_class(class)) == NULL) X if ((my_class = read_class(class, 0)) == NULL) X my_class = ship_class("CA"); X if ((his_class = ship_class(foeclass)) == NULL) X if ((his_class = read_class(foeclass, 1)) == NULL) X his_class = ship_class("CA"); X else { X hisread = 1; X enemynum = randm(MAXFOERACES-1); X } X if (!hisread) { X (void) strncpy(foerace, aliens[enemynum].race_name, X sizeof foerace); X (void) strncpy(foestype, X aliens[enemynum].ship_types[his_class->class_num], X sizeof foestype); X (void) strncpy(empire, aliens[enemynum].empire_name, X sizeof empire); X } X while (foename[0] == '\0') X (void) strncpy(foename, X aliens[enemynum].captains[randm(MAXECAPS) - 1], X sizeof foename); X foerace[sizeof foerace - 1] = '\0'; X foestype[sizeof foestype - 1] = '\0'; X empire[sizeof empire - 1] = '\0'; X foename[sizeof foename - 1] = '\0'; X /* X * Randomize the enemy ships X */ X for (loop = 0; loop < 20; loop++) { X swap1 = randm(MAXESHIPS) - 1; X swap2 = randm(MAXESHIPS) - 1; X tmp = aliens[enemynum].ship_names[swap1]; X aliens[enemynum].ship_names[swap1] = aliens[enemynum].ship_names[swap2]; X aliens[enemynum].ship_names[swap2] = tmp; X } X /* X * Everybody is centered on the Federation ship X * (for now, anyways) X */ X for (i=0; i<=shipnum; i++) { X lp = newitem(I_SHIP); X lp->data.sp = MKNODE(struct ship, *, 1); X sp = shiplist[i] = lp->data.sp; X if (sp == (struct ship *)NULL) { X fprintf(stderr, "init_ships: malloc failed\n"); X exit(2); X } X if (i) X (void) strncpy(sp->name, X aliens[enemynum].ship_names[i-1], X sizeof sp->name); X (void) strncpy(sp->class, his_class->abbr, X sizeof sp->class); X sp->warp = sp->newwarp = 1.0; X sp->course = sp->newcourse = (float)randm(360); X sp->eff = his_class->e_eff; X sp->regen = his_class->regen; X sp->energy = his_class->energy; X sp->pods = his_class->pods; X sp->id = i; X sp->p_spread = INIT_P_SPREAD; X sp->num_phasers = his_class->num_phaser; X sp->num_tubes = his_class->num_torp; X sp->max_speed = his_class->e_warpmax; X sp->orig_max = his_class->e_warpmax; X sp->deg_turn = his_class->turn_rate; X sp->ph_damage = his_class->ph_shield; X sp->tu_damage = his_class->tp_shield; X sp->p_blind_left = his_class->p_blind_left; X sp->p_blind_right = his_class->p_blind_right; X sp->t_blind_left = his_class->t_blind_left; X sp->t_blind_right = his_class->t_blind_right; X for (j=0; j<SHIELDS; j++) { X sp->shields[j].eff = 1.0; X sp->shields[j].drain = 1.0; X sp->shields[j].attemp_drain = 1.0; X } X for (j=0; j<sp->num_phasers; j++) { X sp->phasers[j].target = NULL; X sp->phasers[j].bearing = init_p_turn[sp->num_phasers][j]; X sp->phasers[j].load = INIT_P_LOAD; X sp->phasers[j].drain = INIT_P_DRAIN; X sp->phasers[j].status = P_NORMAL; X } X for (j=0; j<sp->num_tubes; j++) { X sp->tubes[j].target = NULL; X sp->tubes[j].bearing = init_t_turn[sp->num_tubes][j]; X sp->tubes[j].load = INIT_T_LOAD; X sp->tubes[j].status = T_NORMAL; X } X sp->t_lspeed = INIT_T_SPEED; X sp->t_prox = INIT_T_PROX; X sp->t_delay = INIT_T_TIME; X sp->p_percent = INIT_P_PERCENT; X for (j=0; j<MAXSYSTEMS; j++) /* Everything is OK */ X sp->status[j] = 0; X sp->target = NULL; X sp->relbear = 0.0; X sp->delay = 10000.; X range = 4100 + randm(300) - i * 200; X bear = toradians(randm(360)); X sp->x = range * cos(bear); X sp->y = range * sin(bear); X sp->complement = his_class->e_crew; X sp->strategy = strategies[0]; X if (!strcmp(foerace, "Romulan") || can_cloak) X sp->cloaking = C_OFF; X else X sp->cloaking = C_NONE; X sp->cloak_energy = his_class->cloaking_energy; X sp->cloak_delay = CLOAK_DELAY; X sp->position.x = 0; X sp->position.y = 0; X sp->position.warp = 0.0; X sp->position.range = 0; X sp->position.bearing = 0.0; X sp->position.course = 0.0; X sp->p_firing_delay = his_class->p_firing_delay; X sp->t_firing_delay = his_class->t_firing_delay; X } X /* X * federation exceptions X */ X sp = shiplist[0]; X (void) strcpy(sp->class, my_class->abbr); X sp->course = sp->newcourse = 0.0; X sp->x = sp->y = 0; X sp->eff = my_class->o_eff; X sp->regen = my_class->regen; X sp->energy = my_class->energy; X sp->pods = my_class->pods; X sp->complement = my_class->o_crew; X sp->num_phasers = my_class->num_phaser; X sp->num_tubes = my_class->num_torp; X sp->max_speed = my_class->o_warpmax; X sp->orig_max = my_class->o_warpmax; X sp->deg_turn = my_class->turn_rate; X sp->ph_damage = my_class->ph_shield; X sp->tu_damage = my_class->tp_shield; X sp->cloaking = C_NONE; X for (j=0; j<sp->num_phasers; j++) { X sp->phasers[j].target = NULL; X sp->phasers[j].bearing = init_p_turn[sp->num_phasers][j]; X sp->phasers[j].load = INIT_P_LOAD; X sp->phasers[j].drain = INIT_P_DRAIN; X sp->phasers[j].status = P_NORMAL; X } X for (j=0; j<sp->num_tubes; j++) { X sp->tubes[j].target = NULL; X sp->tubes[j].bearing = init_t_turn[sp->num_tubes][j]; X sp->tubes[j].load = INIT_T_LOAD; X sp->tubes[j].status = T_NORMAL; X } X sp->p_firing_delay = my_class->p_firing_delay; X sp->t_firing_delay = my_class->t_firing_delay; X if (strlen(shipname) == 0) { X i = randm(MAXFEDS) - 1; X (void) strcpy(sp->name, feds[i]); X (void) strcpy(shipname, sp->name); X } else { X (void) strcpy(sp->name, shipname); X } X for(loop=shipnum + 1; loop < HIGHSLOT; loop++) X slots[loop] = ' '; X} X Xstruct ship_stat * Xread_class(str, flag) Xchar *str; Xint flag; X{ X int fd, bytes; X char path[BUFSIZ]; X X sprintf(path, "%s.trek%s", home, str); X if ((fd = open(path, O_RDONLY, 0)) < 0) { X printf("Could not find file %s\n", path); X return(NULL); X } X switch (flag) { X case 0: X if ((bytes = read(fd, &us, sizeof(us))) != sizeof(us)) { X puts("Bad format in file"); X return(NULL); X } X return(&us); X break; X case 1: X if ((bytes = read(fd, &them, sizeof(them))) X != sizeof(them)) { X puts("Bad format in file"); X return(NULL); X } X if ((bytes = read(fd, foestype, 30)) < 0) X return(NULL); X if ((bytes = read(fd, foerace, 30)) < 0) X return(NULL); X if ((bytes = read(fd, empire, 30)) < 0) X return(NULL); X if ((bytes = read(fd, &can_cloak, 1)) < 0) X return(NULL); X if ((bytes = read(fd, (char *)&e_bpv, sizeof(int))) < 0) X return(NULL); X X return(&them); X break; X X } X bytes = bytes; /* LINT */ X /*NOTREACHED*/ X} END_OF_src/init.c if test 9697 -ne `wc -c <src/init.c`; then echo shar: \"src/init.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f src/special.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"src/special.c\" else echo shar: Extracting \"src/special.c\" \(7138 characters\) sed "s/^X//" >src/special.c <<'END_OF_src/special.c' X#ident "@(#) TREK73 $Header: special.c,v 1.1 87/10/09 11:11:39 okamoto Exp $" X/* X * $Source: /ccc/okamoto/src/trek/src/RCS/special.c,v $ X * X * $Header: special.c,v 1.1 87/10/09 11:11:39 okamoto Exp $ X * X * $Log: special.c,v $ X * Revision 1.1 87/10/09 11:11:39 11:11:39 okamoto (Jeff Okamoto) X * Initial revision X * X */ X/* X * TREK73: special.c X * X * special: Take care of special commands like defenseless ruses, X * corbomite bluffs, surrenders (both sides) X * X */ X X#include "externs.h" X X Xspecial(sp, range, fed) Xstruct ship *sp; Xint range; Xstruct ship *fed; X{ X int loop, loop2, loop3; X X /* X * Play dead effects X */ X switch (defenseless) { X case 1: X /* Monty Pythons? */ X if (aliens[enemynum].defenseless == -1) X aliens[enemynum].defenseless = randm(100); X if (randm(100) > aliens[enemynum].defenseless) { X /* Didn't work. Too bad. */ X if (cansee(sp)) { X printf("%s: No apparent change in the enemy's actions.\n", X helmsman); X } X defenseless = 6; X break; X } X defenseless = 2; X case 2: X case 3: X /* Okay, he's fallen for it. Choose his action */ X if (randm(2) == 1) { X sp->target = NULL; X sp->newwarp = 0.0; X } else { X sp->newwarp = 1.0; X } X if (cansee(sp)) { X printf("%s: The %s is ", helmsman, sp->name); X if (sp->target != NULL) { X puts("cautiously advancing."); X } else { X puts("turning away."); X } X } X case 4: X case 5: X /* X * Now he might get suspicious. If he's moving too X * fast or if we're close enough, or if his shields X * are up, we'll spot him. X */ X if ((fabs(sp->target->warp) > 1.0) || (range < 200)) X defenseless = 6; X else X for (loop = 0; loop < SHIELDS; loop++) X if (sp->target->shields[loop].drain) X defenseless = 6; X } X X /* X * Corbomite bluff effects. X */ X switch (corbomite) { X case 1: X /* Monty Pythons? */ X if (aliens[enemynum].corbomite == -1) X aliens[enemynum].corbomite = randm(100); X if (randm(100) > aliens[enemynum].corbomite) { X /* He didn't fall for it */ X printf("%s: Message coming in from the %ss.\n", X com, foerace); X printf("%s: Put it on audio.\n", captain); X if (randm(2) == 1) X printf ("%s: Ha, ha, ha, %s. You lose.\n", X foename, captain); X else X printf("%s: I fell for that the last time we met, idiot!\n", X foename); X corbomite = 6; X break; X } X if (cansee(sp)) { X printf("%s: %ss giving ground, Captain. Obviously they\n", X science, foerace); X puts(" tapped in as you expected them to."); X printf("%s: A logical assumption, Mr. %s. Are they still\n", X captain, science); X puts(" retreating?"); X printf("%s: Yes, %s\n", science, title); X printf("%s: Good. All hands, stand by.\n", captain); X } X corbomite = 2; X case 2: X /* He fell for it, retrograde out of here! */ X sp->target = NULL; X sp->newwarp = -(3.0 + randm(7)); X break; X case 3: X case 4: X case 5: X /* Begin to get suspicious */ X if (fabs(sp->target->warp) > 2.0) X corbomite = 6; X break; X } X X /* X * Will the enemy accept your surrender? X */ X switch (surrender) { X case 1: X /* Monty Python */ X if (aliens[enemynum].surrender == -1) X aliens[enemynum].surrender = randm(100); X /* Just a little reminder */ X if (aliens[enemynum].surrender <= 10) X printf("%s: The %ss do not take prisoners.\n", X nav, foerace); X if (randm(100) > aliens[enemynum].surrender) { X /* Tough luck */ X if (randm(2) == 1) { X printf("%s: Message coming in from the %ss.\n", X com, foerace); X printf("%s: Put it on audio.\n", captain); X printf("%s: Prepare to die, Chicken %s!\n", X foename, captain); X } else X printf("%s: No reply from the %ss", X com, foerace); X surrender = 6; X break; X } X /* He took it! */ X printf("%s: Message coming in from the %ss.\n", X com, foerace); X printf("%s: Put it on audio.\n", captain); X printf("%s: On behalf of the %s %s, I accept your surrender.\n", X foename, foerace, empire); X puts(" You have five seconds to drop your shields, cut"); X puts(" warp, and prepare to be boarded."); X global |= F_SURRENDER; X case 2: X case 3: X if (surrender == 1) X surrender = 2; X else X (void) warn(FIN_F_SURRENDER); X sp->target = fed; X sp->newwarp = sp->max_speed; X (void) e_cloak_off(sp, fed); X break; X case 4: X case 5: X /* Begin checking surrender conditions */ X for (loop = 0; loop < SHIELDS; loop++) X if (sp->target->shields[loop].drain) X break; X if (loop < SHIELDS) X break; X if (range <= 1400) X sp->newwarp = 1.0; X if ((range <= 1000) && (fabs(sp->target->warp) <= 1.0)) { X fed->status[S_SURRENDER] = 100; X final(FIN_F_SURRENDER); X } X if (surrender == 4) X break; X if (!shutup[SURRENDER]) X printf("%s: Captain %s, you have not fulfilled our terms.\n", X foename, captain); X printf(" We are resuming our attack.\n"); X surrender = 6; X shutup[SURRENDER]++; X default: X global &= ~F_SURRENDER; X break; X } X X /* X * Enemy surrenders? X */ X switch (surrenderp) { X case 1: X for (loop = 1; loop <= shipnum; loop++) X if (!is_dead(shiplist[loop], S_ENG) X && (sp->complement > 100)) { X printf("%s: Message coming in from the %ss.\n", X com, foerace); X printf("%s: Put it on audio.\n", captain); X printf("%s: You must be joking, Captain %s.\n", X foename, captain); X puts(" Why don't you surrender?"); X surrenderp = 6; X break; X } X if (loop <= shipnum) X break; X /* Monty Python */ X if (aliens[enemynum].surrenderp == -1) X aliens[enemynum].surrenderp = randm(100); X if (randm(100) > aliens[enemynum].surrenderp) { X printf("%s: I'll never surrender to you, %s\n", X foename, captain); X surrenderp = 6; X break; X } X printf("%s: As much as I hate to, Captain %s, we will surrender.\n", X foename, captain); X puts(" We are dropping shields. You may board us."); X case 2: X case 3: X if (surrenderp == 1) X surrenderp = 2; X else X (void) warn(FIN_E_SURRENDER); X for (loop = 0; loop < SHIELDS; loop++) X sp->shields[loop].attemp_drain = 0.0; X sp->newwarp = 0.0; X for (loop = 1; loop <= shipnum; loop++) X shiplist[loop]->status[S_SURRENDER] = 100; X global |= E_SURRENDER; X break; X } X X /* X * Unsportsmanlike firing X */ X if (betw(defenseless, 0, 6) || betw(corbomite, 0, 6) X || betw(surrender, 0, 6) || betw(surrenderp, 0, 6)) { X for (loop = 0; loop < fed->num_phasers; loop++) X if (fed->phasers[loop].status & P_FIRING) X break; X for (loop2 = 0; loop2 < fed->num_tubes; loop2++) X if (fed->tubes[loop].status & T_FIRING) X break; X loop3 = (fed->probe_status != PR_NORMAL); X /* Has he fired? */ X if ((loop != fed->num_phasers) || X (loop2 != fed->num_tubes) || X (loop3 == 1)) { X /* Yes, be angry and disbelieve everything from now on */ X printf("%s: How dare you fire on us! We are resuming our attack!\n", X foename); X global = NORMAL; X if (betw(defenseless,0,6)) X defenseless = 6; X if (betw(corbomite,0,6)) X corbomite = 6; X if (betw(surrender,0,6)) X surrender = 6; X if (betw(surrenderp,0,6)) X surrenderp = 6; X for (loop = 0; loop <= shipnum; loop++) X shiplist[loop]->status[S_SURRENDER] = 0; X } X } X} END_OF_src/special.c if test 7138 -ne `wc -c <src/special.c`; then echo shar: \"src/special.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f src/structs.h -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"src/structs.h\" else echo shar: Extracting \"src/structs.h\" \(7178 characters\) sed "s/^X//" >src/structs.h <<'END_OF_src/structs.h' X#ident "@(#) TREK73 $Header: structs.h,v 1.1 87/10/09 11:12:49 okamoto Exp $" X/* X * $Source: /ccc/okamoto/src/trek/src/RCS/structs.h,v $ X * X * $Header: structs.h,v 1.1 87/10/09 11:12:49 okamoto Exp $ X * X * $Log: structs.h,v $ X * Revision 1.1 87/10/09 11:12:49 11:12:49 okamoto (Jeff Okamoto) X * Initial revision X * X */ X/* X * TREK73: structs.h X * X * Struct Defs for TREK73 X * X */ X X#include "defines.h" X Xstruct phaser { X struct ship *target; /* who we're aimed at */ X float bearing; /* direction aimed (if no target) */ X int drain; /* Drain from engines (to if negative) */ X short load; /* energy in phasers */ X char status; /* Damaged, etc. */ X} ; X Xstruct tube { X struct ship *target; /* who we're aimed at */ X float bearing; /* direction aimed (if no target) */ X int load; /* energy in tubes */ X char status; /* Damaged, etc */ X} ; X Xstruct shield { X float eff; /* efficiency from 0-1 */ X float drain; /* Actual drain from engines */ X float attemp_drain; /* Attempted drain from engines */ X} ; X X#define MAXWEAPONS 11 X#define SHIELDS 4 X Xstruct ship { X char name[30]; /* name of ship */ X char class[3]; /* Type of ship */ X int x, y; /* location */ X float warp; /* warp speed */ X float newwarp; /* for speed changes */ X float course; /* 0-360 */ X float newcourse; /* for course changes */ X struct ship *target; /* who we're pursuing */ X float relbear; /* Relative bearing to keep */ X struct phaser phasers[MAXWEAPONS]; /* phaser banks */ X int p_spread; /* phaser spread */ X int p_percent; /* phaser firing percentage */ X int p_blind_left; /* phaser blind angle, left side */ X int p_blind_right; /* phaser blind angle, right side */ X struct tube tubes[MAXWEAPONS]; /* torpedo tubes */ X int t_prox; /* proximity delay */ X int t_delay; /* time delay to detonation */ X int t_lspeed; /* launch speed */ X int t_blind_left; /* tube blind angle, left side */ X int t_blind_right; /* tube blind angle, right side */ X struct shield shields[SHIELDS]; /* shields */ X int probe_status; /* Probe launcher status */ X float eff; /* efficiency */ X float regen; /* regeneration (energy per turn) */ X float energy; /* amount of effective energy */ X float pods; /* max energy level */ X int complement; /* crew left alive */ X int status[MAXSYSTEMS]; /* damage percentage of these systems */ X float delay; /* how long 'till we blow up? */ X int id; /* Unique identifier */ X int num_phasers; /* Number of phasers */ X int num_tubes; /* Number of tubes */ X float orig_max; /* Maximum original warp */ X float max_speed; /* Maximum warp */ X float deg_turn; /* Degrees per warp turn */ X float ph_damage; /* Damage divisor from phasers */ X float tu_damage; /* Damage divisor from tubes */ X int cloaking; /* Cloaking device status */ X int cloak_energy; /* Energy needed to run cloak */ X int cloak_delay; /* Time until you can recloak */ X int (*strategy)(); /* Which strategy to use */ X struct pos { /* Last known position (before cloak) */ X int x,y; /* Coordinates */ X float warp; /* Warp speed */ X int range; /* Distance to ship */ X float bearing; /* Bearing */ X float course; /* Course */ X } position ; X int p_firing_delay; /* Delay in segments to fire phasers */ X int t_firing_delay; /* Delay in segments to fire torpedos */ X} ; X X/* X * note that probes act like torpedos X * but have targets; torps only have X * courses X */ Xstruct torpedo { X struct ship *from; /* pointer to ship they're from */ X int x, y; /* coords of object */ X float course; /* where it's going */ X float speed; /* how fast we're moving */ X float newspeed; /* what our target speed is */ X struct ship *target; /* who we're aimed at */ X int fuel; /* how many antimatter pods it has */ X float timedelay; /* seconds until detonation */ X int prox; /* proximity fuse */ X int id; /* Unique identifier */ X int type; /* torpedo, probe, or engineering */ X} ; X X/* X * the list of what's in space -- depending on the type, we use X * differing parts of the union (data) structure. it's a linked X * list of all the stuff in space. X */ Xstruct list { X int type; /* Type of pointer kept */ X struct list *back, *fwd; /* Pointers fore and aft */ X union { X struct torpedo *tp; /* Hold a ptr to a torpedo */ X struct ship *sp; /* ...or to a ship */ X } data; X} ; X Xstruct cmd { X int (*routine)(); /* Routine to call */ X char *code_num; /* Code number of command */ X char *explanation; /* Explanation of command */ X int turns; /* Does it take a turn? */ X} ; X X/* X * for the phaser and anti-matter damage lists X */ X X/* X * When you are hit, for each system, you roll a roll-sided die. X * If this number is less than the actual hit you took, then the X * system has been damaged. Historically, this system would be X * completely damaged, but here we simply add more damage to that X * system. See damage.c for more details X */ Xstruct dam { X int roll; /* How many sides on the die */ X char *mesg; /* Message to print out */ X}; X X/* X * How to allocate damage. X * For all but crew, the amount of a hit that gets through is divided X * by the field and that amount is added or subtracted from the X * relevant stat. The number for weapon is the number of weapons that X * have been damaged. X */ Xstruct damage { X float eff; /* Damage to efficiency */ X float fuel; /* Loss of fuel capacity */ X float regen; /* Loss of regeneration */ X float crew; /* Crew casualties */ X float weapon; /* Chance of weapons damage */ X struct dam stats[S_NUMSYSTEMS]; /* For each system */ X}; X Xstruct ship_stat { X char abbr[4]; /* Abbreviation */ X int class_num; /* Index into array */ X int num_phaser; /* Number of phasers */ X int num_torp; /* Number of tubes */ X int o_warpmax; /* Own max speed */ X int e_warpmax; /* Enemy max speed */ X float o_eff; /* Own efficiency */ X float e_eff; /* Enemy efficiency */ X float regen; /* Regeneration */ X float energy; /* Starting fuel */ X float pods; /* Max pods */ X int o_crew; /* Own crew */ X int e_crew; /* Enemy crew */ X float ph_shield; /* Divisor for phaser damage */ X float tp_shield; /* Divisor for torp damage */ X int turn_rate; /* Degrees per warp-second */ X int cloaking_energy; /* Energy to run cloaking device */ X int t_blind_left; /* Start of tube blind area left */ X int t_blind_right; /* Start of tube blind area right */ X int p_blind_left; /* Start of phaser blind area left */ X int p_blind_right; /* Start of phaser blind area right */ X /* Must change to absolute time */ X int p_firing_delay; /* Delay in segments to fire phasers */ X int t_firing_delay; /* Delay in segments to fire torpedos */ X}; X Xstruct race_info { X char race_name[30]; /* Name of the race */ X char empire_name[30]; /* What they call themselves */ X int id; /* Identifier number */ X int surrender; /* Chance they will accept a surrender */ X int surrenderp; /* Chance they will surrender to you */ X int corbomite; /* Chance they fall for a corbomite bluff */ X int defenseless; /* Chance they fall for a defenseless ruse */ X int attitude; /* Attitude factor for strategies */ X char *ship_names[MAXESHIPS]; /* Ship names */ X char *ship_types[MAXSHIPCLASS]; /* Ship types */ X char *captains[MAXECAPS]; /* Some exemplary captains */ X}; END_OF_src/structs.h if test 7178 -ne `wc -c <src/structs.h`; then echo shar: \"src/structs.h\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of archive 3 \(of 6\). cp /dev/null ark3isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0