BSD 1 development
[unix-history] / trek / impulse.c
CommitLineData
520d5775
EA
1# include "trek.h"
2
3/**
4 ** move under impulse power
5 **/
6
7impulse()
8{
9 int course;
10 register int power;
11 float dist, time;
12 register int percent;
13 extern float move();
14
15 if (Ship.cond == DOCKED)
16 return (printf("Scotty: Sorry captain, but we are still docked.\n"));
17 if (damaged(IMPULSE))
18 return (out(IMPULSE));
19 if (getcodi(&course, &dist))
20 return;
21 power = 20 + 100 * dist;
22 percent = 100 * power / Ship.energy + 0.5;
23 if (percent >= 85)
24 {
25 printf("Scotty: That would consume %d%% of our remaining energy.\n",
26 percent);
27 if (!getynpar("Are you sure that is wise"))
28 return;
29 printf("Aye aye, sir\n");
30 }
31 time = dist / 0.095;
32 percent = 100 * time / Now.time + 0.5;
33 if (percent >= 85)
34 {
35 printf("Spock: That would take %d%% of our remaining time.\n",
36 percent);
37 if (!getynpar("Are you sure that is wise"))
38 return;
39 printf("(He's finally gone mad)\n");
40 }
41 Move.time = move(0, course, time, 0.095);
42 Ship.energy =- 20 + 100 * Move.time * 0.095;
43}