      SUBROUTINE WAIT 
C*BEGIN COMMON 
      COMMON SNAP,SNAPSHT(247), 
     +   DATE,REMKL,REMCOM,REMBASE,REMRES,REMTIME,STARKL,BASEKL,
     +   KILLK,KILLC,GALAXY(8,8),CX(10),CY(10),BASEQX(5),BASEQY(5), 
     +   NEWSTUF(8,8),PLNETS(10,5),ISX,ISY,NSCREM,NROMKL,NROMREM,
     +   NSCKILL,NPLANKL,ISATB,BATX,BATY,THINGX,THINGY,
     +   QUAD(10,10),KX(20),KY(20),KPOWER(20),KDIST(20),KSTUF(20),  
     +   FUTURE(10),MESSAGE(5,10),
     +   INKLING,INBASE,INRESOR,INCOM,INTIME,INSTAR,INENRG,INSHLD,
     +   INTORPS,INLSR,INDATE,ENERGY,SHLD,SHLDUP,CONDIT,TORPS,SHIP, 
     +   QUADX,QUADY,SECTX,SECTY,WARPFAC,WFACSQ,LSUPRES,DAMAGE(20), 
     +   LENGTH,SKILL,PASSWD,DIST,DIREC,TIME,BASEX,BASEY,DOCKFAC, 
     +   KLHERE,COMHERE,CASUAL,NHELP,NKINKS,STARCH(8,8),
     +   DEVICE(2,14),IDIDIT,GAMEWON,ALIVE,JUSTIN,RESTING,ALLDONE,
     +   DAMFAC,SHLDCHG,NDEVICE,PLNETX,PLNETY,INORBIT,LANDED,IPLANET,
     +   IMINE,ICRYSTL,INPLAN,NENHERE,ISHERE,NEUTZ,IRHERE,ICRAFT,
     +   IENTESC,ISCRAFT,ISCATE,CRYPROB,ICITE,IPHWHO,
     +   CRACKS(12) 
      INTEGER SHLDUP,CONDIT,QUADX,QUADY,SECTX,SECTY,TORPS,
     +   REMKL,REMBASE,SKILL,REMCOM,GALAXY,STARCH,CX,CY, 
     +   SHIP,ALLDONE,BASEQX,BASEQY,BASEX,BASEY,GAMEWON, 
     +   ALIVE,STARKL,BASEKL,CASUAL,COMHERE,RESTING,SNAP,SHLDCHG, 
     +   THINGX,THINGY,BATX,BATY,PLNETX,PLNETY,PLNETS
      REAL KDIST,KPOWER,LSUPRES,INTIME,INRESOR,INDATE,INSHLD,   
     +   INENRG,INLSR 
	BYTE QUAD
	REAL*8 DEVICE,PASSWD
C*END COMMON 
	LOGICAL*1 IHS,IHR,IHC,IHK,IHE,IHF,IHBLANK,IHDOT,IHP,IHB
	1 ,IHSTAR,IHT,IHQUEST,IHNUM
      COMMON/HOLLER/IHEOL,IHREAL,IHALPHA,IHS,IHR,IHC,IHK,IHGREEN,IHRED, 
     +IHYELLO,IHDOCKD,IHE,IHF,IHBLANK,IHDOT,IHQUEST,IHP,IHSTAR,IHB
     +,IHT,IHNUM  
	REAL*8 AITEM
	COMMON/SCANBF/KEY,AITEM
	EQUIVALENCE(AITEM,FNUM)
C--------DO COMMAND SCANNING
      IDIDIT=0
 10   CALL SCAN
	ANUM=FNUM		!SAVE SCAN BUFFER
      IF(KEY .NE. IHEOL) GO TO 20 
      CALL PROMPT(10HHOW LONG? ,10) 
      GO TO 10
20	IF(KEY .NE. IHREAL) GO TO 60
      IF(ANUM .LE. 0.) RETURN 
	IF (NENHERE.EQ.0) GO TO 25
	IF(CONDIT .NE. IHDOCKD) GO TO 23
	DESTIM = 1E38
	IF(BATX.EQ.QUADX .AND. BATY.EQ.QUADY) DESTIM = FUTURE(5)-DATE
	IF(ISX.EQ.QUADX .AND. ISY.EQ.QUADY .AND. ISATB.EQ.1)
	+   DESTIM = FUTURE(7)-DATE
	IF(ANUM .LT. DESTIM) GO TO 25
	CALL PROUT(
	+54HMR. SPOCK:   "CAPTAIN, THIS STARBASE WILL BE DESTROYED,54)
	CALL CRAM(6H   IN )
	CALL CRAMF(DESTIM,0,1)
	CALL CRAMDMP(28H STARDATES IF WE DO NOTHING.)
	GO TO 28
23	CALL PROUT(47HMR. SPOCK:   "CAPTAIN, WE ARE UNDER ENEMY FIRE.,47)
	GO TO 28
25	IF (ANUM .LT. 0.80*REMTIME) GO TO 30
	CALL PROUT(
	+56HMR. SPOCK:   "CAPTAIN, I COMPUTE THAT SUCH A REST PERIOD,56)
	CALL CRAM(17H   WOULD CONSUME )
	CALL CRAMF(100.0*ANUM/REMTIME,0,2)
	CALL CRAMDMP(24H% OF OUR REMAINING TIME.)
28	CALL PROMPT(33H   ARE YOU SURE THIS IS WISE?"   ,33)
      IF(JA(DUMMY) .EQ. 0) RETURN 
C--------ALTERNATE REST PERIODS (EVENTS) WITH ATTACKS 
 30   RESTING=1 
      AITEM2=ANUM
 40   IF(ANUM .LE. 0.) RESTING=0
      IF(RESTING .EQ. 0) GO TO 50 
	TEMP=ANUM
      IF(NENHERE.NE. 0) TEMP=AMIN1(ANUM,1.0+RANF(0))
	TIME=TEMP
      IF(TIME .LT. ANUM) CALL ATTACK 
      IF(NENHERE.EQ.0) CALL MOVETHO   
      IF(ALLDONE.NE.0 .OR. GALAXY(QUADX,QUADY).EQ.1000) RETURN 
      CALL EVENTS 
      IDIDIT=1
      IF(ALLDONE.NE.0) RETURN 
      ANUM=ANUM-TEMP
      IF(GALAXY(QUADX,QUADY) .NE. 1000) GO TO 40
	RESTING=0
	TIME=0
      GOTO 55     
 50   CALL CRAMF(REMTIME,0,2) 
      CALL CRAMDMP(16H STARDATES LEFT.) 
55    IF(CONDIT.NE.IHDOCKD) RETURN    
      IF((AITEM2-ANUM).GE.9.99) DAMAGE(14)=0   
C*--------HANDLE SPECIAL CASE OF DEATHRAY REPAIRS. 
      RETURN
 60   CALL BEGPARD
      RETURN
      END 
