|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1980 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted provided ! 6: * that: (1) source distributions retain this entire copyright notice and ! 7: * comment, and (2) distributions including binaries display the following ! 8: * acknowledgement: ``This product includes software developed by the ! 9: * University of California, Berkeley and its contributors'' in the ! 10: * documentation or other materials provided with the distribution and in ! 11: * all advertising materials mentioning features or use of this software. ! 12: * Neither the name of the University nor the names of its contributors may ! 13: * be used to endorse or promote products derived from this software without ! 14: * specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 16: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 17: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #ifndef lint ! 21: static char sccsid[] = "@(#)impulse.c 5.4 (Berkeley) 6/1/90"; ! 22: #endif /* not lint */ ! 23: ! 24: # include "trek.h" ! 25: ! 26: /** ! 27: ** move under impulse power ! 28: **/ ! 29: ! 30: impulse() ! 31: { ! 32: int course; ! 33: register int power; ! 34: double dist, time; ! 35: register int percent; ! 36: extern double move(); ! 37: ! 38: if (Ship.cond == DOCKED) ! 39: return (printf("Scotty: Sorry captain, but we are still docked.\n")); ! 40: if (damaged(IMPULSE)) ! 41: return (out(IMPULSE)); ! 42: if (getcodi(&course, &dist)) ! 43: return; ! 44: power = 20 + 100 * dist; ! 45: percent = 100 * power / Ship.energy + 0.5; ! 46: if (percent >= 85) ! 47: { ! 48: printf("Scotty: That would consume %d%% of our remaining energy.\n", ! 49: percent); ! 50: if (!getynpar("Are you sure that is wise")) ! 51: return; ! 52: printf("Aye aye, sir\n"); ! 53: } ! 54: time = dist / 0.095; ! 55: percent = 100 * time / Now.time + 0.5; ! 56: if (percent >= 85) ! 57: { ! 58: printf("Spock: That would take %d%% of our remaining time.\n", ! 59: percent); ! 60: if (!getynpar("Are you sure that is wise")) ! 61: return; ! 62: printf("(He's finally gone mad)\n"); ! 63: } ! 64: Move.time = move(0, course, time, 0.095); ! 65: Ship.energy -= 20 + 100 * Move.time * 0.095; ! 66: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.