1 /* @(#)warp.c 8.1 (Berkeley) 5/31/93 */
2 /* $NetBSD: warp.c,v 1.11 2009/05/24 22:55:03 dholland Exp $ */
5 * Copyright (c) 1980, 1993
6 * The Regents of the University of California. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 ** MOVE UNDER WARP POWER
43 ** This is both the "move" and the "ram" commands, differing
44 ** only in the flag 'fl'. It is also used for automatic
45 ** emergency override mode, when 'fl' is < 0 and 'c' and 'd'
46 ** are the course and distance to be moved. If 'fl' >= 0,
47 ** the course and distance are asked of the captain.
49 ** The guts of this routine are in the routine move(), which
50 ** is shared with impulse(). Also, the working part of this
51 ** routine is very small; the rest is to handle the slight chance
52 ** that you may be moving at some riduculous speed. In that
53 ** case, there is code to handle time warps, etc.
68 warp(int fl, int c, double d)
81 if (Ship.cond == DOCKED) {
82 printf("%s is docked\n", Ship.shipname);
93 /* check to see that we are not using an absurd amount of power */
94 power = (dist + 0.05) * Ship.warp3;
95 percent = 100 * power / Ship.energy + 0.5;
97 printf("Scotty: That would consume %d%% of our remaining "
100 if (!getynpar("Are you sure that is wise"))
104 /* compute the speed we will move at, and the time it will take */
105 speed = Ship.warp2 / Param.warptime;
108 /* check to see that that value is not ridiculous */
109 percent = 100 * time / Now.time + 0.5;
111 printf("Spock: That would take %d%% of our remaining time.\n",
113 if (!getynpar("Are you sure that is wise"))
117 /* compute how far we will go if we get damages */
118 if (Ship.warp > 6.0 && ranf(100) < 20 + 15 * (Ship.warp - 6.0)) {
122 repairs = (frac + 1.0) * Ship.warp * (franf() + 0.25) * 0.20;
123 damage(WARP, repairs);
127 Move.time = move(fl, course, time, speed);
129 /* see how far we actually went, and decrement energy appropriately */
130 dist = Move.time * speed;
131 Ship.energy -= dist * Ship.warp3 * (Ship.shldup + 1);
133 /* test for bizarre events */
134 if (Ship.warp <= 9.0)
136 printf("\n\n ___ Speed exceeding warp nine ___\n\n");
138 printf("Ship's safety systems malfunction\n");
140 printf("Crew experiencing extreme sensory distortion\n");
142 if (ranf(100) >= 100 * dist) {
143 printf("Equilibrium restored -- all systems normal\n");
147 /* select a bizzare thing to happen to us */
151 if (percent < 35 || !Game.snap) {
152 /* positive time warp */
153 time = (Ship.warp - 8.0) * dist * (franf() + 1.0);
155 printf("Positive time portal entered -- "
156 "it is now Stardate %.2f\n",
158 for (i = 0; i < MAXEVENTS; i++) {
159 percent = Event[i].evcode;
160 if (percent == E_FIXDV || percent == E_LRTB)
161 Event[i].date += time;
166 /* s/he got lucky: a negative time portal */
168 p = (char *) Etc.snapshot;
169 memcpy(p, Quad, sizeof Quad);
171 memcpy(p, Event, sizeof Event);
173 memcpy(p, &Now, sizeof Now);
174 printf("Negative time portal entered -- "
175 "it is now Stardate %.2f\n",
177 for (i = 0; i < MAXEVENTS; i++)
178 if (Event[i].evcode == E_FIXDV)
179 reschedule(&Event[i], Event[i].date - time);
183 /* test for just a lot of damage */
186 printf("Equilibrium restored -- "
187 "extreme damage occurred to ship systems\n");
188 for (i = 0; i < NDEV; i++)
189 damage(i, (3.0 * (franf() + franf()) + 1.0) * Param.damfac[i]);