	SUBROUTINE FIRE(ID,BNS)
C	ROUTINE TO ALLOW FIRING OF MISSILES AT RANGE IR
C----------------------standard common block----------------------------
C 
	COMMON ICR(8,12),IPARM(10),IS1,IS2,NT,ICU(10,10,10,2),CLEAR(8)
	COMMON MARKER(4,3,3)
	LOGICAL*1 ICU,CLEAR
C 
C-----------------------------------------------------------------------
	LOGICAL*1 C,BNS
	IE=ICR(ID,9)
	LUN=ICR(ID,8)
	IF(ICR(ID,1).NE.1) GOTO 25   ! NOT A PLAYER CRAWLER IN CUBE
20	WRITE(LUN,21)
21	FORMAT(' range: ',$)
	READ(LUN,22,ERR=20) IR
22	FORMAT(I2)
	IF(IR.GT.0) GOTO 25
	WRITE(LUN,23)
23	FORMAT(' fire aborted')
	GOTO 16   ! RETURN
25	IF(IE.GE.IR) GOTO 2
	IR=IE
	WRITE(LUN,1) IR
1	FORMAT(' <WARNING> -- not enough energy'/
     C'          -- range reduced to ',I1)
	CALL DELAY(1.,LUN,C)
2	ICR(ID,9)=IE-IR  !  EXPEND ENERGY
	IR0=IR  ! STORE ORIGINAL RANGE FOR DFIRE
	IF(IR.EQ.0) GOTO 18
	IE=ICR(ID,2)  ! FORWARD DIRECTION
	I=0
	J=0
	K=0
	IF(IE.EQ.1) I=1
	IF(IE.EQ.2) J=1
	IF(IE.EQ.3) I=-1
	IF(IE.EQ.4) J=-1
	IF(IE.EQ.5) K=1
	IF(IE.EQ.6) K=-1
	I0=ICR(ID,10)
	J0=ICR(ID,11)
	K0=ICR(ID,12)
C	WRITE(LUN,600) I0,J0,K0,I,J,K
C600	FORMAT(' firing from',3I3,', moving',3I3)
	IR=0
	DO 3 N=1,IR0
	IR=N
	I0=I0+I
	J0=J0+J
	K0=K0+K
C	WRITE(LUN,601) I0,J0,K0
C601	FORMAT(' missile entering',3I3)
	IF(I0.GT.10.OR.I0.LT.1) GOTO 10 ! HIT WALL....
	IF(J0.GT.10.OR.J0.LT.1) GOTO 10
	IF(K0.GT.10.OR.K0.LT.1) GOTO 10
C 
C 
	C=ICU(I0,J0,K0,1)
C 
C	WRITE(LUN,602) C
C602	FORMAT('       ---- area contains (',A1,')')
	IF(C.NE.' ') GOTO 5 ! HIT SOMETHING ELSE.
3	CONTINUE
	IF(BNS.NE.'X') CALL DFIRE(ID,IR0,IR,C)
	WRITE(LUN,31) IR
31	FORMAT(' you have destroyed an empty space at range',I3)
	GOTO 15
C 
C	SHOT INTERRUPTED:
5	IF(C.GT.'8'.AND.C.LT.'C') C=C-10  ! CRAWLER BLOCKING DOOR
	IF(C.GT.'0'.AND.C.LT.'9') GOTO 32 ! HIT OTHER CRAWLER
	IF(C.EQ.'[') GOTO 34 ! HIT DOORWAY
	IF(C.NE.'*') GOTO 36 ! HIT "UFO"
C	MUST HAVE HIT DESTROYED AREA:
	IR=IR-1
	IF(BNS.NE.'X') CALL DFIRE(ID,IR0,IR,C)
	WRITE(LUN,38) IR
38	FORMAT(' missile crashed into a destroyed area causing'/
     C' the destruction of empty area at range',I3)
	GOTO 11
10	IR=IR-1
11	I0=I0-I
	J0=J0-J
	K0=K0-K
	IF(BNS.NE.'X') CALL DFIRE(ID,IR0,IR,C)
	IF(C.NE.'*') WRITE(LUN,39) IR
39	FORMAT(' missile range too large -- detonated on wall'/
     C' destroying empty area at range',I3)
15	ICU(I0,J0,K0,1)='*' ! DESTROY AREA
	IF(I0.NE.ICR(ID,10).OR.J0.NE.ICR(ID,11).OR.K0.NE.ICR(ID,12))
     CGOTO 16
19	WRITE(LUN,17)
17	FORMAT(' you ninny !!!  you`ve destroyed yourself !')
	ICR(ID,1)=0
16	RETURN
C 
C	FIRE AT RANGE OF 0:
18	C=ID+48
	IF(BNS.NE.'X') CALL DFIRE(ID,IR0,IR,C)
	GOTO 19
C	HIT OTHER CRAWLER:
32	IF(NT.LT.4) GOTO 832
	IF(BNS.NE.'X') CALL DFIRE(ID,IR0,IR,C)
	IS=C-"60  ! CONVERT CHARACTER 3 TO INTEGER 3, ETC.
	WRITE(LUN,33) IS,IR
33	FORMAT(' good shooting......crawler',I2,' has been destroyed'/
     C' at range',I3)
	ICR(IS,1)=0
	WRITE(ICR(IS,8),133) IS,ID
133	FORMAT(' .......tsk, tsk, tsk.  crawler',I2,', you have been'/
     C' killed until death by crawler',I2//' r.i.p.')
	GOTO 15
C 
C	HIT OTHER CRAWLER BUT WITHIN FIRST 3 TURNS:
832	I0=I0-I
	J0=J0-J
	K0=K0-K
	IF(BNS.NE.'X') CALL DFIRE(ID,IR0,IR,C)
	IR=IR-1
	WRITE(LUN,833) C,C
833	FORMAT(' your missile would have hit crawler ',A1/
     C' but unfortunately all crawlers are protected by'/
     C' force sheilds until the fourth turn.  Your missile'/
     C' has destroyed an empty area in front of crawler ',A1)
	GOTO 15
C 
C	DOORWAY:
34	IF(BNS.NE.'X') CALL DFIRE(ID,IR0,IR,C)
	WRITE(LUN,35) IR
35	FORMAT(' .....your missile has blasted into tiny pieces an'/
     C' access door area at range',I2,', making the area impassible')
	GOTO 15
C	UFO:
36	IF(BNS.NE.'X') CALL DFIRE(ID,IR0,IR,C)
	WRITE(LUN,37) C
37	FORMAT(' an unidentified object has been hit by your missile.'/
     C' it had the number ',O3,' inscribed on its side')
	GOTO 15
	END
