      SUBROUTINE DAMAGE(NX,SUM)                                         0846

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

C     ...NX=1 FOR P OR T HIT                                            0869
C     ...NX=0 FOR COLLISIN                                              0870
      IF(NX)5,5,100                                                     0871
C     ...MINIMUM SET AT 1000.                                           0872
5     IF(SUM.LT.ZMIN)SUM=ZMIN                                           0873
C     ...TWO ITEMS DAMAGED IN COLLISION                                 0874
      DO 10    I=1,2                                                    0875
      IF(NX.GE.0)GO TO 15                                               0876
      J=I+5                                                             0877
      GO TO 30                                                          0878
15    X=RAN(IZZ)                                                        0879
      DO 20    J=1,10                                                   0880
      IF(X.LE.J/10.)GO TO 30                                            0881
20    CONTINUE                                                          0882
30    SDAYS=RAN(IZZ)*SUM/DIV1                                           0883
      WRITE(6,1)NAMD(J)                                                 0884
1     FORMAT(1X,A10,' DAMAGED')                                         0885
      IF(J.EQ.10)GO TO 32                                               0886
      IF(J.NE.1)GO TO 35                                                0887
      IHWARP=IHWARP+1                                                   0888
C     ...END OF GAME IF MORE THAN 2 HITS ON W DRIVE BEFORE REPAIRED.    0889
      IF(IHWARP.GT.2)CALL RATING(6)                                     0890
32    I   F(NDRA.EQ.0)GO TO 35                                          0891
      NDRA=0                                                            0892
      WRITE(6,4)                                                        0893
4     FORMAT(' ENERGY FORMS DISTROYED DURING DAMAGE')                   0894
35    IDMG(J)=IDMG(J)+SDAYS*100.                                        0895
10    CONTINUE                                                          0896
      KLED=(RAN(IZZ)*SUM/DIV1)*MULTK1                                   0897
      DSP=0.                                                            0898
      PSP=0.                                                            0899
      SUM=0.                                                            0900
      DEFL=0.                                                           0901
      DDEG=PDEG                                                         0902
C     ...DISTRIBUTE KLED AMONGST CREW+TROOPS RANDOMLY.                  0903
45    KKLED=RAN(IZZ)*KLED                                               0904
      LKLED=MIN0(KLED-KKLED,MEN)                                        0905
      KKLED=MIN0(KLED-LKLED,ITRMEN(1))                                  0906
      KLED=LKLED+KKLED                                                  0907
      MEN=MEN-LKLED                                                     0908
      ITRMEN(1)=ITRMEN(1)-KKLED                                         0909
      IF(ITRMEN(1).LT.0)ITRMEN(1)=0                                     0910
      IF(MEN.GT.6)GO TO 50                                              0911
      CALL RATING(5)                                                    0912
50    WRITE(6,2)KLED,MEN, ITRMEN(1)                                     0913
2     FORMAT(' MEN KILLED: ',I4,' CREW LEFT: ',I4,' TROOPS LEFT: ',I4)  0914
      RETURN                                                            0915
C     ...P OR T HIT WITH SHIELDS DOWN.                                  0916
100   X=RAN(IZZ)                                                        0917
      DO 110    J=1,10                                                  0918
      IF(X.LE.J/10.)GO TO 130                                           0919
110   CONTINUE                                                          0920
130   SDAYS=RAN(IZZ)*SUM/DIV2                                           0921
      WRITE(6,1)NAMD(J)                                                 0922
      IF(J.EQ.10)GO TO 42                                               0923
      IF(J.NE.1)GO TO 44                                                0924
      IHWARP=IHWARP+1                                                   0925
      IF(IHWARP.GT.2)CALL RATING(6)                                     0926
42    I   F(NDRA.EQ.0)GO TO 44                                          0927
      NDRA=0                                                            0928
      WRITE(6,4)                                                        0929
44    IDMG(J)=IDMG(J)+SDAYS*100.                                        0930
      KLED=RAN(IZZ)*SUM/DIV2*MULTK2                                     0931
      GO TO 45                                                          0932
      END                                                               0933

      KLNGNS=0                                