xref: /csrg-svn/games/trek/impulse.c (revision 60857)
121282Sdist /*
2*60857Sbostic  * Copyright (c) 1980, 1993
3*60857Sbostic  *	The Regents of the University of California.  All rights reserved.
434205Sbostic  *
542606Sbostic  * %sccs.include.redist.c%
621282Sdist  */
721282Sdist 
811677Smckusick #ifndef lint
9*60857Sbostic static char sccsid[] = "@(#)impulse.c	8.1 (Berkeley) 05/31/93";
1034205Sbostic #endif /* not lint */
1111677Smckusick 
1211677Smckusick # include	"trek.h"
1311677Smckusick 
1411677Smckusick /**
1511677Smckusick  **	move under impulse power
1611677Smckusick  **/
1711677Smckusick 
impulse()1811677Smckusick impulse()
1911677Smckusick {
2011677Smckusick 	int			course;
2111677Smckusick 	register int		power;
2212738Slayer 	double			dist, time;
2311677Smckusick 	register int		percent;
2412738Slayer 	extern double		move();
2511677Smckusick 
2611677Smckusick 	if (Ship.cond == DOCKED)
2711677Smckusick 		return (printf("Scotty: Sorry captain, but we are still docked.\n"));
2811677Smckusick 	if (damaged(IMPULSE))
2911677Smckusick 		return (out(IMPULSE));
3011677Smckusick 	if (getcodi(&course, &dist))
3111677Smckusick 		return;
3211677Smckusick 	power = 20 + 100 * dist;
3311677Smckusick 	percent = 100 * power / Ship.energy + 0.5;
3411677Smckusick 	if (percent >= 85)
3511677Smckusick 	{
3611677Smckusick 		printf("Scotty: That would consume %d%% of our remaining energy.\n",
3711677Smckusick 			percent);
3811677Smckusick 		if (!getynpar("Are you sure that is wise"))
3911677Smckusick 			return;
4011677Smckusick 		printf("Aye aye, sir\n");
4111677Smckusick 	}
4211677Smckusick 	time = dist / 0.095;
4311677Smckusick 	percent = 100 * time / Now.time + 0.5;
4411677Smckusick 	if (percent >= 85)
4511677Smckusick 	{
4611677Smckusick 		printf("Spock: That would take %d%% of our remaining time.\n",
4711677Smckusick 			percent);
4811677Smckusick 		if (!getynpar("Are you sure that is wise"))
4911677Smckusick 			return;
5011677Smckusick 		printf("(He's finally gone mad)\n");
5111677Smckusick 	}
5211677Smckusick 	Move.time = move(0, course, time, 0.095);
5312344Slayer 	Ship.energy -= 20 + 100 * Move.time * 0.095;
5411677Smckusick }
55