      SUBROUTINE GHACTV

      real ysav(6)

c	include 'tcommon.for'
	%include tcommon.for


C     ...GHOSTSHIP ACTIVITIES.
      I3=3
      I4=4
C     ...MOVEMENT.    USES ENERGY.
      J1=0
      J2=0
      IF(GHOST(5).NE.GHOST(7))J2=1
      IF(GHOST(4).EQ.0..AND.GHOST(6).EQ.0.)GO TO 100
      IF(GHOST(4).NE.GHOST(6))J1=1
      VSX=GHOST(4)-AMIN1(ABS(GHOST(6)-GHOST(4)),DSPGH)/2.
      VSX=VSX*VSX
      VSY=COSD(AMIN1(ABS(GHOST(7)-GHOST(5)),DGGH))
      GHOST(11)=GHOST(11)-(VSX*(2.-2.*VSY)+(AMIN1(ABS(GHOST(6)-GHOST(4))1889
     1,DSPGH)**2))*GHACCE
      IF(GHOST(11).LE.0.)GO TO 900
100   CALL OMOVE(GHOST(1),GHOST(2),GHOST(4),GHOST(5),GHOST(6),GHOST(7), 1892
     1     DSPGH,DGGH)
      IF(J1.EQ.1.AND.GHOST(4).EQ.GHOST(6))WRITE(6,1)GHOST(4)
1     FORMAT(' G DESIRED SPEED OF ',F5.3,' ATTAINED')
      IF(J2.EQ.1.AND.GHOST(5).EQ.GHOST(7))WRITE(6,2)GHOST(5)
2     FORMAT(' G DESIRED BEARING OF ',F4.0,' ATTAINED')
C     ...CHECK IF LEAVING QUAD.
      IF(GHOST(1).LT..5.OR.GHOST(1).GE.10.5)GO TO 900
      IF(GHOST(2).LT..5.OR.GHOST(2).GE.10.5)GO TO 900
C     ...IF UNDER E CONTROL, DO OTHER ACTIVITIES.
      IF(GHOST(8).EQ.0..OR.GHOST(8).GT.NTSTPS)GO TO 500
C     ...FIRES T.
      IF(GHOST(12).LE.0.)GO TO 500
      IF(RTBRG(1).LT.0.)GO TO 500
      IF(NTORPS.NE.0)GO TO 200
      K=1
      NTORPS=30
      GO TO 275
200   DO 250 K=1,NTORPS
      IF(TORPS(K,1).EQ.0.)GO TO 275
250   CONTINUE
      GO TO 500
275   NT=K
      GHOST(12)=GHOST(12)-1.
      VPX=COSD(GHOST(5))*GHOST(4)+COSD(RTBRG(1))*.4
      VPY=SIND(GHOST(5))*GHOST(4)+SIND(RTBRG(1))*.4
      TORPS(NT,3)=SQRT(VPX*VPX+VPY*VPY)
      TORPS(NT,1)=GHOST(1)+VPX
      TORPS(NT,2)=GHOST(2)+VPY
      RTBRG(1)=-1.
      VSX=0.
      VSY=0.
      CALL GETBRG(DELTA,VSX,VPX,VSY,VPY,X,Y)
C     ...RESET TORP BEARING TO 360-720 RANGE.
      TORPS(NT,4)=DELTA+360.
      GHOST(8)=0.
      IF(RTBRG(2).LT.0.)GO TO 271
      GHOST(8)=NTSTPS+1+FLOAT(MIN0(MXCRGH,ITRMEN(20)))/FLOAT(ITRMEN(20))1929
      DO 270 K=1,4
270   RTBRG(K)=RTBRG(K+1)
      RTBRG(5)=-1.
271   WRITE(6,3)
3     FORMAT(' G TORPEDO LAUNCHED')
C     ...FIRES PHASERS.
500   IF(GHOST(10).EQ.0..OR.GHOST(10).GT.NTSTPS)GO TO 1000
      IF(GHOST(11).LE.0.)GO TO 2350
C     ...USES EPHIT, SO MUST MAY G LOOK LIKE E TO IT.
      WRITE(6,4)
4     FORMAT(' G FIRING PHASERS')
      ysav(1)=XQE
      ysav(2)=YQE
      ysav(3)=PDEG
      ysav(4)=EFP(3)
      ysav(5)=EFP(2)
      ysav(6)=DISTPE
      XQE=GHOST(1)
      YQE=GHOST(2)
      PDEG=GHOST(5)
      EFP(3)=AMIN1(GHPHEN,GHOST(11))
      GHOST(11)=GHOST(11)-EFP(3)
      EFP(2)=1.
      DISTPE=TNRGY
      IF(KLNGNS.EQ.0)GO TO 2320
      DO 2310 J=1,KLNGNS
      IF(XKL(J,1).EQ.0.)GO TO 2310
      IF(ICNTL(J+1).EQ.1)GO TO 2310
      CALL EPHIT(XKL(J,1),XKL(J,2),XKL(J,7),XKLHIT,I3,J)
2310  CONTINUE
2320  IF(NROM.EQ.0)GO TO 2340
C     ...HIT ON ROMULANS
      DO 2330 J=1,NROM
      IF(XROM(J,1).EQ.0.)GO TO 2330
      IF(ICNTL(J+10).EQ.1)GO TO 2330
      CALL EPHIT(XROM(J,1),XROM(J,2),XROM(J,3),XRMHIT,I4,J)
2330  CONTINUE
C     ...RESTORE VALUES.
2340  XQE=ysav(1)
      YQE=ysav(2)
      PDEG=ysav(3)
      EFP(3)=ysav(4)
      EFP(2)=ysav(5)
      DISTPE=ysav(6)
      GHOST(10)=0.
2350  N GHTFP=NGHTFP-1
      IF(NGHTFP.EQ.0)GO TO 1000
      GHOST(10)=NTSTPS+1+FLOAT(MIN0(MXCRGH,ITRMEN(20)))/      FLOAT(ITRM1977
     1EN(20))
      GO TO 1000
C     ...G OUT OF QUAD.
900   CALL DLETE(5,1)
1000  RETURN
      END
                       2130
      VPX=XK-XROM(K,1)               