xref: /original-bsd/games/trek/impulse.c (revision 89a39cb6)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)impulse.c	5.4 (Berkeley) 06/01/90";
10 #endif /* not lint */
11 
12 # include	"trek.h"
13 
14 /**
15  **	move under impulse power
16  **/
17 
18 impulse()
19 {
20 	int			course;
21 	register int		power;
22 	double			dist, time;
23 	register int		percent;
24 	extern double		move();
25 
26 	if (Ship.cond == DOCKED)
27 		return (printf("Scotty: Sorry captain, but we are still docked.\n"));
28 	if (damaged(IMPULSE))
29 		return (out(IMPULSE));
30 	if (getcodi(&course, &dist))
31 		return;
32 	power = 20 + 100 * dist;
33 	percent = 100 * power / Ship.energy + 0.5;
34 	if (percent >= 85)
35 	{
36 		printf("Scotty: That would consume %d%% of our remaining energy.\n",
37 			percent);
38 		if (!getynpar("Are you sure that is wise"))
39 			return;
40 		printf("Aye aye, sir\n");
41 	}
42 	time = dist / 0.095;
43 	percent = 100 * time / Now.time + 0.5;
44 	if (percent >= 85)
45 	{
46 		printf("Spock: That would take %d%% of our remaining time.\n",
47 			percent);
48 		if (!getynpar("Are you sure that is wise"))
49 			return;
50 		printf("(He's finally gone mad)\n");
51 	}
52 	Move.time = move(0, course, time, 0.095);
53 	Ship.energy -= 20 + 100 * Move.time * 0.095;
54 }
55