|
|
1.1 root 1: #ifndef lint
2: static char sccsid[] = "@(#)warp.c 4.2 (Berkeley) 5/27/83";
3: #endif not lint
4:
5: # include "trek.h"
6:
7: /*
8: ** MOVE UNDER WARP POWER
9: **
10: ** This is both the "move" and the "ram" commands, differing
11: ** only in the flag 'fl'. It is also used for automatic
12: ** emergency override mode, when 'fl' is < 0 and 'c' and 'd'
13: ** are the course and distance to be moved. If 'fl' >= 0,
14: ** the course and distance are asked of the captain.
15: **
16: ** The guts of this routine are in the routine move(), which
17: ** is shared with impulse(). Also, the working part of this
18: ** routine is very small; the rest is to handle the slight chance
19: ** that you may be moving at some riduculous speed. In that
20: ** case, there is code to handle time warps, etc.
21: */
22:
23: warp(fl, c, d)
24: int fl, c;
25: double d;
26: {
27: int course;
28: double power;
29: double dist;
30: double time;
31: double speed;
32: double frac;
33: register int percent;
34: register int i;
35: extern double move();
36:
37: if (Ship.cond == DOCKED)
38: return (printf("%s is docked\n", Ship.shipname));
39: if (damaged(WARP))
40: {
41: return (out(WARP));
42: }
43: if (fl < 0)
44: {
45: course = c;
46: dist = d;
47: }
48: else
49: if (getcodi(&course, &dist))
50: return;
51:
52: /* check to see that we are not using an absurd amount of power */
53: power = (dist + 0.05) * Ship.warp3;
54: percent = 100 * power / Ship.energy + 0.5;
55: if (percent >= 85)
56: {
57: printf("Scotty: That would consume %d%% of our remaining energy.\n",
58: percent);
59: if (!getynpar("Are you sure that is wise"))
60: return;
61: }
62:
63: /* compute the speed we will move at, and the time it will take */
64: speed = Ship.warp2 / Param.warptime;
65: time = dist / speed;
66:
67: /* check to see that that value is not ridiculous */
68: percent = 100 * time / Now.time + 0.5;
69: if (percent >= 85)
70: {
71: printf("Spock: That would take %d%% of our remaining time.\n",
72: percent);
73: if (!getynpar("Are you sure that is wise"))
74: return;
75: }
76:
77: /* compute how far we will go if we get damages */
78: if (Ship.warp > 6.0 && ranf(100) < 20 + 15 * (Ship.warp - 6.0))
79: {
80: frac = franf();
81: dist *= frac;
82: time *= frac;
83: damage(WARP, (frac + 1.0) * Ship.warp * (franf() + 0.25) * 0.20);
84: }
85:
86: /* do the move */
87: Move.time = move(fl, course, time, speed);
88:
89: /* see how far we actually went, and decrement energy appropriately */
90: dist = Move.time * speed;
91: Ship.energy -= dist * Ship.warp3 * (Ship.shldup + 1);
92:
93: /* test for bizarre events */
94: if (Ship.warp <= 9.0)
95: return;
96: printf("\n\n ___ Speed exceeding warp nine ___\n\n");
97: sleep(2);
98: printf("Ship's safety systems malfunction\n");
99: sleep(2);
100: printf("Crew experiencing extreme sensory distortion\n");
101: sleep(4);
102: if (ranf(100) >= 100 * dist)
103: {
104: return (printf("Equilibrium restored -- all systems normal\n"));
105: }
106:
107: /* select a bizzare thing to happen to us */
108: percent = ranf(100);
109: if (percent < 70)
110: {
111: /* time warp */
112: if (percent < 35 || !Game.snap)
113: {
114: /* positive time warp */
115: time = (Ship.warp - 8.0) * dist * (franf() + 1.0);
116: Now.date += time;
117: printf("Positive time portal entered -- it is now Stardate %.2f\n",
118: Now.date);
119: for (i = 0; i < MAXEVENTS; i++)
120: {
121: percent = Event[i].evcode;
122: if (percent == E_FIXDV || percent == E_LRTB)
123: Event[i].date += time;
124: }
125: return;
126: }
127:
128: /* s/he got lucky: a negative time portal */
129: time = Now.date;
130: i = (int) Etc.snapshot;
131: bmove(i, Quad, sizeof Quad);
132: bmove(i += sizeof Quad, Event, sizeof Event);
133: bmove(i += sizeof Event, &Now, sizeof Now);
134: printf("Negative time portal entered -- it is now Stardate %.2f\n",
135: Now.date);
136: for (i = 0; i < MAXEVENTS; i++)
137: if (Event[i].evcode == E_FIXDV)
138: reschedule(&Event[i], Event[i].date - time);
139: return;
140: }
141:
142: /* test for just a lot of damage */
143: if (percent < 80)
144: lose(L_TOOFAST);
145: printf("Equilibrium restored -- extreme damage occured to ship systems\n");
146: for (i = 0; i < NDEV; i++)
147: damage(i, (3.0 * (franf() + franf()) + 1.0) * Param.damfac[i]);
148: Ship.shldup = 0;
149: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.