C FIGHTD- INTERMOVE FIGHT DEMON
C
C COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142
C ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED
C WRITTEN BY R. M. SUPNIK
C
C DECLARATIONS
C
	SUBROUTINE FIGHTD
	IMPLICIT INTEGER (A-Z)
	LOGICAL PROB,OAPPLI
C
C PARSER OUTPUT
C
	LOGICAL PRSWON
	COMMON /PRSVEC/ PRSA,PRSI,PRSO,PRSWON,PRSCON
C
C GAME STATE
C
	LOGICAL TELFLG
	COMMON /PLAY/ WINNER,HERE,TELFLG
C
C OBJECTS
C
	COMMON /OBJCTS/ OLNT,ODESC1(220),ODESC2(220),ODESCO(220),
	1	OACTIO(220),OFLAG1(220),OFLAG2(220),OFVAL(220),
	2	OTVAL(220),OSIZE(220),OCAPAC(220),OROOM(220),
	3	OADV(220),OCAN(220),OREAD(220)
C
	COMMON /OFLAGS/ VISIBT,READBT,TAKEBT,DOORBT,TRANBT,FOODBT,
	1	NDSCBT,DRNKBT,CONTBT,LITEBT,VICTBT,BURNBT,FLAMBT,
	2	TOOLBT,TURNBT,ONBT
	COMMON /OFLAGS/ FINDBT,SLEPBT,SCRDBT,TIEBT,CLMBBT,ACTRBT,
	1	WEAPBT,FITEBT,VILLBT,STAGBT,TRYBT,NOCHBT,OPENBT,
	2	TCHBT,VEHBT,SCHBT
C
	COMMON /OINDEX/ GARLI,FOOD,GUNK,COAL,MACHI,DIAMO,TCASE,BOTTL
	COMMON /OINDEX/ WATER,ROPE,KNIFE,SWORD,LAMP,BLAMP,RUG
	COMMON /OINDEX/	LEAVE,TROLL,AXE
	COMMON /OINDEX/ RKNIF,KEYS,ICE,BAR
	COMMON /OINDEX/ COFFI,TORCH,TBASK,FBASK,IRBOX
	COMMON /OINDEX/ GHOST,TRUNK,BELL,BOOK,CANDL
	COMMON /OINDEX/ MATCH,TUBE,PUTTY,WRENC,SCREW,CYCLO,CHALI
	COMMON /OINDEX/ THIEF,STILL,WINDO,GRATE,DOOR
	COMMON /OINDEX/ HPOLE,LEAK,RBUTT,RAILI
	COMMON /OINDEX/ POT,STATU,IBOAT,DBOAT,PUMP,RBOAT
	COMMON /OINDEX/ STICK,BUOY,SHOVE,BALLO,RECEP,GUANO
	COMMON /OINDEX/ BROPE,HOOK1,HOOK2,SAFE,SSLOT,BRICK,FUSE
	COMMON /OINDEX/ GNOME,BLABE,DBALL,TOMB
	COMMON /OINDEX/ LCASE,CAGE,RCAGE,SPHER,SQBUT
	COMMON /OINDEX/ FLASK,POOL,SAFFR,BUCKE,ECAKE,ORICE,RDICE,BLICE
	COMMON /OINDEX/ ROBOT,FTREE,BILLS,PORTR,SCOL,ZGNOM
	COMMON /OINDEX/ EGG,BEGG,BAUBL,CANAR,BCANA
	COMMON /OINDEX/ YLWAL,RDWAL,PINDR,RBEAM
	COMMON /OINDEX/ ODOOR,QDOOR,CDOOR,NUM1,NUM8
	COMMON /OINDEX/ WARNI,CSLIT,GCARD,STLDR
	COMMON /OINDEX/ HANDS,WALL,LUNGS,SAILO,AVIAT,TEETH
	COMMON /OINDEX/ ITOBJ,EVERY,VALUA,OPLAY,WNORT,GWATE,MASTER
C
C VILLAINS AND DEMONS
C
	COMMON /VILL/ VLNT,VILLNS(4),VPROB(4),VOPPS(4),VBEST(4),VMELEE(4)
C
C ADVENTURERS
C
	COMMON /ADVS/ ALNT,AROOM(4),ASCORE(4),AVEHIC(4),
	1	AOBJ(4),AACTIO(4),ASTREN(4),AFLAG(4)
C
	COMMON /AFLAGS/ ASTAG
C
	COMMON /AINDEX/ PLAYER,AROBOT,AMASTR
C
C VERBS
C
	COMMON /VINDEX/ CINTW,DEADXW,FRSTQW,INXW,OUTXW
	COMMON /VINDEX/ WALKIW,FIGHTW,FOOW
	COMMON /VINDEX/ MELTW,READW,INFLAW,DEFLAW,ALARMW,EXORCW
	COMMON /VINDEX/ PLUGW,KICKW,WAVEW,RAISEW,LOWERW,RUBW
	COMMON /VINDEX/ PUSHW,UNTIEW,TIEW,TIEUPW,TURNW,BREATW
	COMMON /VINDEX/ KNOCKW,LOOKW,EXAMIW,SHAKEW,MOVEW,TRNONW,TRNOFW
	COMMON /VINDEX/ OPENW,CLOSEW,FINDW,WAITW,SPINW,BOARDW,UNBOAW,TAKEW
	COMMON /VINDEX/ INVENW,FILLW,EATW,DRINKW,BURNW
	COMMON /VINDEX/ MUNGW,KILLW,ATTACW,SWINGW
	COMMON /VINDEX/ WALKW,TELLW,PUTW,DROPW,GIVEW,POURW,THROWW
	COMMON /VINDEX/ DIGW,LEAPW,STAYW,FOLLOW
	COMMON /VINDEX/ HELLOW,LOOKIW,LOOKUW,PUMPW,WINDW
	COMMON /VINDEX/ CLMBW,CLMBUW,CLMBDW,TRNTOW
C
C FLAGS
C
	LOGICAL*1 TROLLF,CAGESF,BUCKTF,CAROFF,CAROZF,LWTIDF
	LOGICAL*1 DOMEF,GLACRF,ECHOF,RIDDLF,LLDF,CYCLOF
	LOGICAL*1 MAGICF,LITLDF,SAFEF,GNOMEF,GNODRF,MIRRMF
	LOGICAL*1 EGYPTF,ONPOLF,BLABF,BRIEFF,SUPERF,BUOYF
	LOGICAL*1 GRUNLF,GATEF,RAINBF,CAGETF,EMPTHF,DEFLAF
	LOGICAL*1 GLACMF,FROBZF,ENDGMF,BADLKF,THFENF,SINGSF
	LOGICAL*1 MRPSHF,MROPNF,WDOPNF,MR1F,MR2F,INQSTF
	LOGICAL*1 FOLLWF,SPELLF,CPOUTF,CPUSHF
	COMMON /FINDEX/ TROLLF,CAGESF,BUCKTF,CAROFF,CAROZF,LWTIDF,
	1	DOMEF,GLACRF,ECHOF,RIDDLF,LLDF,CYCLOF,
	2	MAGICF,LITLDF,SAFEF,GNOMEF,GNODRF,MIRRMF,
	3	EGYPTF,ONPOLF,BLABF,BRIEFF,SUPERF,BUOYF,
	4	GRUNLF,GATEF,RAINBF,CAGETF,EMPTHF,DEFLAF,
	5	GLACMF,FROBZF,ENDGMF,BADLKF,THFENF,SINGSF,
	6	MRPSHF,MROPNF,WDOPNF,MR1F,MR2F,INQSTF,
	7	FOLLWF,SPELLF,CPOUTF,CPUSHF
	COMMON /FINDEX/ BTIEF,BINFF
	COMMON /FINDEX/ RVMNT,RVCLR,RVCYC,RVSND,RVGUA
	COMMON /FINDEX/ ORRUG,ORCAND,ORMTCH,ORLAMP
	COMMON /FINDEX/ MDIR,MLOC,POLEUF
	COMMON /FINDEX/ QUESNO,NQATT,CORRCT
	COMMON /FINDEX/ LCELL,PNUMB,ACELL,DCELL,CPHERE
C
C FUNCTIONS AND DATA
C
	DATA ROUT/1/
C FIGHTD, PAGE 2
C
	DO 2400 I=1,VLNT			!LOOP THRU VILLAINS.
	  VOPPS(I)=0				!CLEAR OPPONENT SLOT.
	  OBJ=VILLNS(I)				!GET OBJECT NO.
	  RA=OACTIO(OBJ)			!GET HIS ACTION.
	  IF(HERE.NE.OROOM(OBJ)) GO TO 2200	!ADVENTURER STILL HERE?
	  IF((OBJ.EQ.THIEF).AND.THFENF) GO TO 2400 !THIEF ENGROSSED?
	  IF(OCAPAC(OBJ).GE.0) GO TO 2050	!YES, VILL AWAKE?
	  IF((VPROB(I).EQ.0).OR..NOT.PROB(VPROB(I),VPROB(I)))
	1	GO TO 2025			!NO, SEE IF WAKES UP.
	  OCAPAC(OBJ)=IABS(OCAPAC(OBJ))
	  VPROB(I)=0
	  IF(RA.EQ.0) GO TO 2400		!ANYTHING TO DO?
	  PRSA=INXW				!YES, WAKE HIM UP.
	  F=OAPPLI(RA,0)
	  GO TO 2400				!NOTHING ELSE HAPPENS.
C
2025	  VPROB(I)=VPROB(I)+10			!INCREASE WAKEUP PROB.
	  GO TO 2400				!NOTHING ELSE.
C
2050	  IF((OFLAG2(OBJ).AND.FITEBT).EQ.0) GO TO 2100
	  VOPPS(I)=OBJ				!FIGHTING, SET UP OPP.
	  GO TO 2400
C
2100	  IF(RA.EQ.0) GO TO 2400		!NOT FIGHTING,
	  PRSA=FRSTQW				!SET UP PROBABILITY
	  IF(.NOT.OAPPLI(RA,0)) GO TO 2400	!OF FIGHTING.
	  OFLAG2(OBJ)=OFLAG2(OBJ).OR.FITEBT
	  VOPPS(I)=OBJ				!SET UP OPP.
	  GO TO 2400
C
2200	  IF(((OFLAG2(OBJ).AND.FITEBT).EQ.0).OR.(RA.EQ.0))
	1	GO TO 2300			!NOTHING TO DO.
	  PRSA=FIGHTW				!HAVE A FIGHT.
	  F=OAPPLI(RA,0)
2300	  IF(OBJ.EQ.THIEF) THFENF=.FALSE.	!TURN OFF ENGROSSED.
	  AFLAG(PLAYER)=AFLAG(PLAYER).AND. .NOT.ASTAG
	  OFLAG2(OBJ)=OFLAG2(OBJ).AND. .NOT.(STAGBT+FITEBT)
	  IF((OCAPAC(OBJ).GE.0).OR.(RA.EQ.0))
	1	GO TO 2400
	  PRSA=INXW				!WAKE HIM UP.
	  F=OAPPLI(RA,0)
	  OCAPAC(OBJ)=IABS(OCAPAC(OBJ))
2400	CONTINUE
C FIGHTD, PAGE 3
C
C NOW DO ACTUAL COUNTERBLOWS.
C
	OUT=0					!ASSUME HERO OK.
2600	DO 2700 I=1,VLNT			!LOOP THRU OPPS.
	  J=VOPPS(I)
	  IF(J.EQ.0) GO TO 2700			!SLOT EMPTY?
	  PRSCON=1				!STOP CMD STREAM.
	  RA=OACTIO(J)
	  IF(RA.EQ.0) GO TO 2650		!VILLAIN ACTION?
	  PRSA=FIGHTW				!SEE IF
	  IF(OAPPLI(RA,0)) GO TO 2700		!SPECIAL ACTION.
2650	  RES=BLOW(PLAYER,J,VMELEE(I),.FALSE.,OUT) !STRIKE BLOW.
	  IF(RES.LT.0) RETURN			!IF HERO DEAD, EXIT.
	  IF(RES.EQ.ROUT) OUT=2+RND(3)		!IF HERO OUT, SET FLG.
2700	CONTINUE
	OUT=OUT-1				!DECREMENT OUT COUNT.
	IF(OUT.GT.0) GO TO 2600			!IF STILL OUT, GO AGAIN.
	RETURN
C
	END
C BLOW- STRIKE BLOW
C
C DECLARATIONS
C
	INTEGER FUNCTION BLOW(H,V,RMK,HFLG,OUT)
	IMPLICIT INTEGER (A-Z)
	LOGICAL HFLG,OAPPLI,PROB
	INTEGER DEF1R(3),DEF2R(4),DEF3R(5)
	INTEGER RVECTR(66),RSTATE(45)
C
C GAME STATE
C
	LOGICAL TELFLG
	COMMON /PLAY/ WINNER,HERE,TELFLG
C
C PARSE VECTOR
C
	LOGICAL PRSWON
	COMMON /PRSVEC/ PRSA,PRSI,PRSO,PRSWON,PRSCON
C
C MISCELLANEOUS VARIABLES
C
	COMMON /STAR/ MBASE,STRBIT
C
C OBJECTS
C
	COMMON /OBJCTS/ OLNT,ODESC1(220),ODESC2(220),ODESCO(220),
	1	OACTIO(220),OFLAG1(220),OFLAG2(220),OFVAL(220),
	2	OTVAL(220),OSIZE(220),OCAPAC(220),OROOM(220),
	3	OADV(220),OCAN(220),OREAD(220)
C
	COMMON /OFLAGS/ VISIBT,READBT,TAKEBT,DOORBT,TRANBT,FOODBT,
	1	NDSCBT,DRNKBT,CONTBT,LITEBT,VICTBT,BURNBT,FLAMBT,
	2	TOOLBT,TURNBT,ONBT
	COMMON /OFLAGS/ FINDBT,SLEPBT,SCRDBT,TIEBT,CLMBBT,ACTRBT,
	1	WEAPBT,FITEBT,VILLBT,STAGBT,TRYBT,NOCHBT,OPENBT,
	2	TCHBT,VEHBT,SCHBT
C
C
C CLOCK INTERRUPTS
C
	LOGICAL*1 CFLAG
	COMMON /CEVENT/ CLNT,CTICK(25),CACTIO(25),CFLAG(25)
C
	COMMON /CINDEX/ CEVCUR,CEVMNT,CEVLNT,CEVMAT,CEVCND,
	1	CEVBAL,CEVBRN,CEVFUS,CEVLED,CEVSAF,CEVVLG,
	2	CEVGNO,CEVBUC,CEVSPH,CEVEGH,
	3	CEVFOR,CEVSCL,CEVZGI,CEVZGO,CEVSTE,
	5	CEVMRS,CEVPIN,CEVINQ,CEVFOL

C
C ADVENTURERS
C
	COMMON /ADVS/ ALNT,AROOM(4),ASCORE(4),AVEHIC(4),
	1	AOBJ(4),AACTIO(4),ASTREN(4),AFLAG(4)
C
	COMMON /AFLAGS/ ASTAG
C
	COMMON /AINDEX/ PLAYER,AROBOT,AMASTR
C
C VERBS
C
	COMMON /VINDEX/ CINTW,DEADXW,FRSTQW,INXW,OUTXW
	COMMON /VINDEX/ WALKIW,FIGHTW,FOOW
C
C FUNCTIONS AND DATA
C
	DATA RMISS/0/,ROUT/1/,RKILL/2/,RLIGHT/3/
	DATA RSER/4/,RSTAG/5/,RLOSE/6/,RHES/7/,RSIT/8/
	DATA DEF1R/1,2,3/
	DATA DEF2R/13,23,24,25/
	DATA DEF3R/35,36,46,47,57/
C
	DATA RVECTR/0,0,0,0,5,5,1,1,2,2,2,2,
	1	0,0,0,0,0,5,5,3,3,1,
	2	0,0,0,5,5,3,3,3,1,2,2,2,
	3	0,0,0,0,0,5,5,3,3,4,4,
	4	0,0,0,5,5,3,3,3,4,4,4,
	5	0,5,5,3,3,3,3,4,4,4/
	DATA RSTATE/5000,3005,3008,4011,3015,3018,1021,0,0,
	1	5022,3027,3030,4033,3037,3040,1043,0,0,
	2	4044,2048,4050,4054,5058,4063,4067,3071,1074,
	3	4075,1079,4080,4084,4088,4092,4096,4100,1104,
	4	4105,2109,4111,4115,4119,4123,4127,3131,3134/
C BLOW, PAGE 3
C
	RA=OACTIO(V)				!GET VILLAIN ACTION,
	DV=ODESC2(V)				!DESCRIPTION.
	BLOW=RMISS				!ASSUME NO RESULT.
D	TYPE 10,H,V,RMK,HFLG,OUT
D10	FORMAT(' BLOW 10-- ',3I7,L7,I7)
	IF(.NOT.HFLG) GO TO 1000		!HERO STRIKING BLOW?
C
C HERO IS ATTACKER, VILLAIN IS DEFENDER.
C
	PBLOSE=10				!BAD LK PROB.
	OFLAG2(V)=OFLAG2(V).OR.FITEBT		!YES, VILLAIN GETS MAD.
	IF((AFLAG(H).AND.ASTAG).EQ.0) GO TO 100	!HERO STAG?
	CALL RSPEAK(591)			!YES, CANT FIGHT.
	AFLAG(H)=AFLAG(H).AND. .NOT.ASTAG
	RETURN
C
100	ATT=FIGHTS(H,.TRUE.)			!GET HIS STRENGTH.
	OA=ATT
	DEF=VILSTR(V)				!GET VILL STRENGTH.
	OD=DEF
	DWEAP=0					!ASSUME NO WEAPON.
	DO 200 I=1,OLNT				!SEARCH VILLAIN.
	  IF((OCAN(I).EQ.V).AND.((OFLAG2(I).AND.WEAPBT).NE.0))
	1	DWEAP=I
200	CONTINUE
	IF(V.EQ.AOBJ(PLAYER)) GO TO 300		!KILLING SELF?
	IF(DEF.NE.0) GO TO 2000			!DEFENDER ALIVE?
	CALL RSPSUB(592,DV)			!VILLAIN DEAD.
	RETURN
C
300	CALL JIGSUP(593)			!KILLING SELF.
	RETURN
C
C VILLAIN IS ATTACKER, HERO IS DEFENDER.
C
1000	PBLOSE=50				!BAD LK PROB.
	AFLAG(H)=AFLAG(H).AND..NOT.ASTAG	!VILL STRIKING.
	IF((OFLAG2(V).AND.STAGBT).EQ.0) GO TO 1200 !VILL STAGGERED?
	OFLAG2(V)=OFLAG2(V).AND. .NOT.STAGBT	!MAKE HIM OK.
	CALL RSPSUB(594,DV)			!DESCRIBE.
	RETURN
C
1200	ATT=VILSTR(V)				!SET UP ATT, DEF.
	OA=ATT
	DEF=FIGHTS(H,.TRUE.)
	IF(DEF.LE.0) RETURN			!DONT ALLOW DEAD DEF.
	OD=FIGHTS(H,.FALSE.)
	DWEAP=IABS(FWIM(0,WEAPBT,0,0,H,.TRUE.))	!FIND A WEAPON.
C BLOW, PAGE 4
C
C PARTIES ARE NOW EQUIPPED.  DEF CANNOT BE ZERO.
C ATT MUST BE > 0.
C
2000	CONTINUE
D	TYPE 2050,ATT,OA,DEF,OD,DWEAP
D2050	FORMAT(' BLOW 2050-- ',5I7)
	IF(DEF.GT.0) GO TO 2100			!DEF ALIVE?
	RES=RKILL
	IF(HFLG) CALL RSPSUB(595,DV)		!DEADER.
	GO TO 3000
C
2100	IF(DEF-2) 2200,2300,2400		!DEF <2,=2,>2
2200	ATT=MIN0(ATT,3)				!SCALE ATT.
	TBL=DEF1R(ATT)				!CHOOSE TABLE.
	GO TO 2500
C
2300	ATT=MIN0(ATT,4)				!SCALE ATT.
	TBL=DEF2R(ATT)				!CHOOSE TABLE.
	GO TO 2500
C
2400	ATT=ATT-DEF				!SCALE ATT.
	ATT=MIN0(2,MAX0(-2,ATT))+3
	TBL=DEF3R(ATT)
C
2500	RES=RVECTR(TBL+RND(10))			!GET RESULT.
	IF(OUT.EQ.0) GO TO 2600			!WAS HE OUT?
	IF(RES.EQ.RSTAG) GO TO 2550		!YES, STAG--> HES.
	RES=RSIT				!OTHERWISE, SITTING.
	GO TO 2600
2550	RES=RHES
2600	IF((RES.EQ.RSTAG).AND.(DWEAP.NE.0).AND.PROB(25,PBLOSE))
	1	RES=RLOSE			!LOSE WEAPON.
C
	MI=RSTATE(((RMK-1)*9)+RES+1)		!CHOOSE TABLE ENTRY.
	IF(MI.EQ.0) GO TO 3000
	I=(MOD(MI,1000)+RND(MI/1000))+MBASE+1
	J=DV
	IF(.NOT.HFLG .AND.(DWEAP.NE.0)) J=ODESC2(DWEAP)
D	TYPE 2650,RES,MI,I,J,MBASE
D2650	FORMAT(' BLOW 2650-- ',5I7)
	CALL RSPSUB(I,J)			!PRESENT RESULT.
C BLOW, PAGE 5
C
C NOW APPLY RESULT
C
3000	GO TO (4000,3100,3200,3300,3400,3500,3600,4000,3200),RES+1
C
3100	IF(HFLG) DEF=-DEF			!UNCONSCIOUS.
	GO TO 4000
C
3200	DEF=0					!KILLED OR SITTING DUCK.
	GO TO 4000
C
3300	DEF=MAX0(0,DEF-1)			!LIGHT WOUND.
	GO TO 4000
C
3400	DEF=MAX0(0,DEF-2)			!SERIOUS WOUND.
	GO TO 4000
C
3500	IF(HFLG) GO TO 3550			!STAGGERED.
	AFLAG(H)=AFLAG(H).OR.ASTAG
	GO TO 4000
C
3550	OFLAG2(V)=OFLAG2(V).OR.STAGBT
	GO TO 4000
C
3600	CALL NEWSTA(DWEAP,0,HERE,0,0)		!LOSE WEAPON.
	DWEAP=0
	IF(HFLG) GO TO 4000			!IF HERO, DONE.
	DWEAP=IABS(FWIM(0,WEAPBT,0,0,H,.TRUE.)) !GET NEW.
	IF(DWEAP.NE.0) CALL RSPSUB(605,ODESC2(DWEAP))
C BLOW, PAGE 6
C
4000	BLOW=RES				!RETURN RESULT.
	IF(.NOT.HFLG) GO TO 4500		!HERO?
	OCAPAC(V)=DEF				!STORE NEW CAPACITY.
	IF(DEF.NE.0) GO TO 4100			!DEAD?
	OFLAG2(V)=OFLAG2(V).AND. .NOT.FITEBT	!YES, NOT FIGHTING.
	CALL RSPSUB(572,DV)			!HE DIES.
	CALL NEWSTA(V,0,0,0,0)			!MAKE HIM DISAPPEAR.
	IF(RA.EQ.0) RETURN			!IF NX TO DO, EXIT.
	PRSA=DEADXW				!LET HIM KNOW.
	F=OAPPLI(RA,0)
	RETURN
C
4100	IF((RES.NE.ROUT).OR.(RA.EQ.0)) RETURN
	PRSA=OUTXW				!LET HIM BE OUT.
	F=OAPPLI(RA,0)
	RETURN
C
4500	ASTREN(H)=-10000			!ASSUME DEAD.
	IF(DEF.NE.0) ASTREN(H)=DEF-OD
	IF(DEF.GE.OD) GO TO 4600
	CTICK(CEVCUR)=30
	CFLAG(CEVCUR)=.TRUE.
4600	IF(FIGHTS(H,.TRUE.).GT.0) RETURN
	ASTREN(H)=1-FIGHTS(H,.FALSE.)		!HE'S DEAD.
	CALL JIGSUP(596)
	BLOW=-1
	RETURN
C
	END
C SWORDD- SWORD INTERMOVE DEMON
C
C DECLARATIONS
C
	SUBROUTINE SWORDD
	IMPLICIT INTEGER(A-Z)
	LOGICAL INFEST,FINDXT
C
C GAME STATE
C
	LOGICAL TELFLG
	COMMON /PLAY/ WINNER,HERE,TELFLG
C
C EXITS
C
	COMMON /CURXT/ XTYPE,XROOM1,XSTRNG,XACTIO,XOBJ
	EQUIVALENCE (XFLAG,XOBJ)
C
	COMMON /XSRCH/ XMIN,XMAX,XDOWN,XUP,
	1	XNORTH,XSOUTH,XENTER,XEXIT,XEAST,XWEST
C
C OBJECTS
C
	COMMON /OBJCTS/ OLNT,ODESC1(220),ODESC2(220),ODESCO(220),
	1	OACTIO(220),OFLAG1(220),OFLAG2(220),OFVAL(220),
	2	OTVAL(220),OSIZE(220),OCAPAC(220),OROOM(220),
	3	OADV(220),OCAN(220),OREAD(220)
C
	COMMON /OINDEX/ GARLI,FOOD,GUNK,COAL,MACHI,DIAMO,TCASE,BOTTL
	COMMON /OINDEX/ WATER,ROPE,KNIFE,SWORD,LAMP,BLAMP,RUG
	COMMON /OINDEX/	LEAVE,TROLL,AXE
	COMMON /OINDEX/ RKNIF,KEYS,ICE,BAR
	COMMON /OINDEX/ COFFI,TORCH,TBASK,FBASK,IRBOX
	COMMON /OINDEX/ GHOST,TRUNK,BELL,BOOK,CANDL
	COMMON /OINDEX/ MATCH,TUBE,PUTTY,WRENC,SCREW,CYCLO,CHALI
	COMMON /OINDEX/ THIEF,STILL,WINDO,GRATE,DOOR
	COMMON /OINDEX/ HPOLE,LEAK,RBUTT,RAILI
	COMMON /OINDEX/ POT,STATU,IBOAT,DBOAT,PUMP,RBOAT
	COMMON /OINDEX/ STICK,BUOY,SHOVE,BALLO,RECEP,GUANO
	COMMON /OINDEX/ BROPE,HOOK1,HOOK2,SAFE,SSLOT,BRICK,FUSE
	COMMON /OINDEX/ GNOME,BLABE,DBALL,TOMB
	COMMON /OINDEX/ LCASE,CAGE,RCAGE,SPHER,SQBUT
	COMMON /OINDEX/ FLASK,POOL,SAFFR,BUCKE,ECAKE,ORICE,RDICE,BLICE
	COMMON /OINDEX/ ROBOT,FTREE,BILLS,PORTR,SCOL,ZGNOM
	COMMON /OINDEX/ EGG,BEGG,BAUBL,CANAR,BCANA
	COMMON /OINDEX/ YLWAL,RDWAL,PINDR,RBEAM
	COMMON /OINDEX/ ODOOR,QDOOR,CDOOR,NUM1,NUM8
	COMMON /OINDEX/ WARNI,CSLIT,GCARD,STLDR
	COMMON /OINDEX/ HANDS,WALL,LUNGS,SAILO,AVIAT,TEETH
	COMMON /OINDEX/ ITOBJ,EVERY,VALUA,OPLAY,WNORT,GWATE,MASTER
C
C VILLAINS AND DEMONS
C
	LOGICAL THFFLG,SWDACT,THFACT
	COMMON /HACK/ THFPOS,THFFLG,THFACT,SWDACT,SWDSTA
C
C ADVENTURERS
C
	COMMON /AINDEX/ PLAYER,AROBOT,AMASTR
C SWORDD, PAGE 2
C
	IF(OADV(SWORD).NE.PLAYER) GO TO 500	!HOLDING SWORD?
	NG=2					!ASSUME VILL CLOSE.
	IF(INFEST(HERE)) GO TO 300		!VILL HERE?
	NG=1
	DO 200 I=XMIN,XMAX,XMIN			!NO, SEARCH ROOMS.
	  IF(.NOT.FINDXT(I,HERE)) GO TO 200	!ROOM THAT WAY?
	  GO TO (50,200,50,50),XTYPE		!SEE IF ROOM AT ALL.
50	  IF(INFEST(XROOM1)) GO TO 300		!CHECK ROOM.
200	CONTINUE
	NG=0					!NO GLOW.
C
300	IF(NG.EQ.SWDSTA) RETURN			!ANY STATE CHANGE?
	CALL RSPEAK(NG+495)			!YES, TELL NEW STATE.
	SWDSTA=NG
	RETURN
C
500	SWDACT=.FALSE.				!DROPPED SWORD,
	RETURN					!DISABLE DEMON.
	END
C INFEST-	SUBROUTINE TO TEST FOR INFESTED ROOM
C
C DECLARATIONS
C
	LOGICAL FUNCTION INFEST(R)
	IMPLICIT INTEGER(A-Z)
C
C ROOMS
C
	COMMON /RINDEX/ WHOUS,LROOM,CELLA
	COMMON /RINDEX/ MTROL,MAZE1	
	COMMON /RINDEX/ MGRAT,MAZ15	
	COMMON /RINDEX/ FORE1,FORE3,CLEAR,RESER
	COMMON /RINDEX/ STREA,EGYPT,ECHOR
	COMMON /RINDEX/ TSHAF	
	COMMON /RINDEX/ BSHAF,MMACH,DOME,MTORC
	COMMON /RINDEX/ CAROU	
	COMMON /RINDEX/ RIDDL,LLD2,TEMP1,TEMP2,MAINT
	COMMON /RINDEX/ BLROO,TREAS,RIVR1,RIVR2,RIVR3,MCYCL
	COMMON /RINDEX/ RIVR4,RIVR5,FCHMP,FALLS,MBARR
	COMMON /RINDEX/ MRAIN,POG,VLBOT,VAIR1,VAIR2,VAIR3,VAIR4
	COMMON /RINDEX/ LEDG2,LEDG3,LEDG4,MSAFE,CAGER
	COMMON /RINDEX/ CAGED,TWELL,BWELL,ALICE,ALISM,ALITR
	COMMON /RINDEX/ MTREE,BKENT,BKVW,BKTWI,BKVAU,BKBOX
	COMMON /RINDEX/ CRYPT,TSTRS,MRANT,MREYE
	COMMON /RINDEX/ MRA,MRB,MRC,MRG,MRD,FDOOR
	COMMON /RINDEX/ MRAE,MRCE,MRCW,MRGE,MRGW,MRDW,INMIR
	COMMON /RINDEX/ SCORR,NCORR,PARAP,CELL,PCELL,NCELL
	COMMON /RINDEX/ CPANT,CPOUT,CPUZZ
C
C OBJECTS
C
	COMMON /OBJCTS/ OLNT,ODESC1(220),ODESC2(220),ODESCO(220),
	1	OACTIO(220),OFLAG1(220),OFLAG2(220),OFVAL(220),
	2	OTVAL(220),OSIZE(220),OCAPAC(220),OROOM(220),
	3	OADV(220),OCAN(220),OREAD(220)
C
	COMMON /OINDEX/ GARLI,FOOD,GUNK,COAL,MACHI,DIAMO,TCASE,BOTTL
	COMMON /OINDEX/ WATER,ROPE,KNIFE,SWORD,LAMP,BLAMP,RUG
	COMMON /OINDEX/	LEAVE,TROLL,AXE
	COMMON /OINDEX/ RKNIF,KEYS,ICE,BAR
	COMMON /OINDEX/ COFFI,TORCH,TBASK,FBASK,IRBOX
	COMMON /OINDEX/ GHOST,TRUNK,BELL,BOOK,CANDL
	COMMON /OINDEX/ MATCH,TUBE,PUTTY,WRENC,SCREW,CYCLO,CHALI
	COMMON /OINDEX/ THIEF,STILL,WINDO,GRATE,DOOR
	COMMON /OINDEX/ HPOLE,LEAK,RBUTT,RAILI
	COMMON /OINDEX/ POT,STATU,IBOAT,DBOAT,PUMP,RBOAT
	COMMON /OINDEX/ STICK,BUOY,SHOVE,BALLO,RECEP,GUANO
	COMMON /OINDEX/ BROPE,HOOK1,HOOK2,SAFE,SSLOT,BRICK,FUSE
	COMMON /OINDEX/ GNOME,BLABE,DBALL,TOMB
	COMMON /OINDEX/ LCASE,CAGE,RCAGE,SPHER,SQBUT
	COMMON /OINDEX/ FLASK,POOL,SAFFR,BUCKE,ECAKE,ORICE,RDICE,BLICE
	COMMON /OINDEX/ ROBOT,FTREE,BILLS,PORTR,SCOL,ZGNOM
	COMMON /OINDEX/ EGG,BEGG,BAUBL,CANAR,BCANA
	COMMON /OINDEX/ YLWAL,RDWAL,PINDR,RBEAM
	COMMON /OINDEX/ ODOOR,QDOOR,CDOOR,NUM1,NUM8
	COMMON /OINDEX/ WARNI,CSLIT,GCARD,STLDR
	COMMON /OINDEX/ HANDS,WALL,LUNGS,SAILO,AVIAT,TEETH
	COMMON /OINDEX/ ITOBJ,EVERY,VALUA,OPLAY,WNORT,GWATE,MASTER
C
C VILLAINS AND DEMONS
C
	LOGICAL THFFLG,SWDACT,THFACT
	COMMON /HACK/ THFPOS,THFFLG,THFACT,SWDACT,SWDSTA
C
C FLAGS
C
	LOGICAL*1 TROLLF,CAGESF,BUCKTF,CAROFF,CAROZF,LWTIDF
	LOGICAL*1 DOMEF,GLACRF,ECHOF,RIDDLF,LLDF,CYCLOF
	LOGICAL*1 MAGICF,LITLDF,SAFEF,GNOMEF,GNODRF,MIRRMF
	LOGICAL*1 EGYPTF,ONPOLF,BLABF,BRIEFF,SUPERF,BUOYF
	LOGICAL*1 GRUNLF,GATEF,RAINBF,CAGETF,EMPTHF,DEFLAF
	LOGICAL*1 GLACMF,FROBZF,ENDGMF,BADLKF,THFENF,SINGSF
	LOGICAL*1 MRPSHF,MROPNF,WDOPNF,MR1F,MR2F,INQSTF
	LOGICAL*1 FOLLWF,SPELLF,CPOUTF,CPUSHF
	COMMON /FINDEX/ TROLLF,CAGESF,BUCKTF,CAROFF,CAROZF,LWTIDF,
	1	DOMEF,GLACRF,ECHOF,RIDDLF,LLDF,CYCLOF,
	2	MAGICF,LITLDF,SAFEF,GNOMEF,GNODRF,MIRRMF,
	3	EGYPTF,ONPOLF,BLABF,BRIEFF,SUPERF,BUOYF,
	4	GRUNLF,GATEF,RAINBF,CAGETF,EMPTHF,DEFLAF,
	5	GLACMF,FROBZF,ENDGMF,BADLKF,THFENF,SINGSF,
	6	MRPSHF,MROPNF,WDOPNF,MR1F,MR2F,INQSTF,
	7	FOLLWF,SPELLF,CPOUTF,CPUSHF
	COMMON /FINDEX/ BTIEF,BINFF
	COMMON /FINDEX/ RVMNT,RVCLR,RVCYC,RVSND,RVGUA
	COMMON /FINDEX/ ORRUG,ORCAND,ORMTCH,ORLAMP
	COMMON /FINDEX/ MDIR,MLOC,POLEUF
	COMMON /FINDEX/ QUESNO,NQATT,CORRCT
	COMMON /FINDEX/ LCELL,PNUMB,ACELL,DCELL,CPHERE
C
	IF(.NOT.ENDGMF) INFEST=(OROOM(CYCLO).EQ.R).OR.
	1	(OROOM(TROLL).EQ.R).OR.
	2	((OROOM(THIEF).EQ.R).AND.THFACT)
	IF(ENDGMF) INFEST=(R.EQ.MRG).OR.(R.EQ.MRGE).OR.
	1	(R.EQ.MRGW).OR.
	2	((R.EQ.INMIR).AND.(MLOC.EQ.MRG))
	RETURN
	END
