C TROLLP-	TROLL FUNCTION
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
	LOGICAL FUNCTION TROLLP(ARG)
	IMPLICIT INTEGER (A-Z)
	LOGICAL QHERE,PROB
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 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 TROLLP, PAGE 2
C
	TROLLP=.TRUE.				!ASSUME WINS.
	IF(PRSA.NE.FIGHTW) GO TO 1100		!FIGHT?
	IF(OCAN(AXE).EQ.TROLL) GO TO 10		!GOT AXE?  NOTHING.
	I=433					!ASSUME CANT GET.
	IF(.NOT.QHERE(AXE,HERE)) GO TO 1050	!HERE?
	I=434					!YES, RECOVER.
	CALL NEWSTA(AXE,0,0,TROLL,0)
1050	IF(QHERE(TROLL,HERE)) CALL RSPEAK(I)	!IF PLAYER HERE.
	RETURN
C
1100	IF(PRSA.NE.DEADXW) GO TO 1200		!DEAD?
	TROLLF=.TRUE.				!PERMIT EXITS.
	RETURN
C
1200	IF(PRSA.NE.OUTXW) GO TO 1300		!OUT?
	TROLLF=.TRUE.				!PERMIT EXITS.
	OFLAG1(AXE)=OFLAG1(AXE).AND. .NOT.VISIBT
	ODESC1(TROLL)=435			!TROLL OUT.
	RETURN
C
1300	IF(PRSA.NE.INXW) GO TO 1400		!WAKE UP?
	TROLLF=.FALSE.				!FORBID EXITS.
	OFLAG1(AXE)=OFLAG1(AXE).OR.VISIBT
	ODESC1(TROLL)=436			!TROLL IN.
	IF(QHERE(TROLL,HERE)) CALL RSPEAK(437)
	RETURN
C
1400	IF(PRSA.NE.FRSTQW) GO TO 1500		!FIRST ENCOUNTER?
	TROLLP=PROB(33,66)		!33% TRUE UNLESS BADLK.
	RETURN
C
1500	IF((PRSA.NE.MOVEW).AND.(PRSA.NE.TAKEW).AND.(PRSA.NE.MUNGW)
	1	.AND.(PRSA.NE.THROWW).AND.(PRSA.NE.GIVEW)) GO TO 2000
	IF(OCAPAC(TROLL).GE.0) GO TO 1550	!TROLL OUT?
	OCAPAC(TROLL)=-OCAPAC(TROLL)		!YES, WAKE HIM.
	OFLAG1(AXE)=OFLAG1(AXE).OR.VISIBT
	TROLLF=.FALSE.
	ODESC1(TROLL)=436
	CALL RSPEAK(437)
C
1550	IF((PRSA.NE.TAKEW).AND.(PRSA.NE.MOVEW)) GO TO 1600
	CALL RSPEAK(438)			!JOKE.
	RETURN
C
1600	IF(PRSA.NE.MUNGW) GO TO 1700		!MUNG?
	CALL RSPEAK(439)			!JOKE.
	RETURN
C
1700	IF(PRSO.EQ.0) GO TO 10			!NO OBJECT?
	I=440					!ASSUME THROW.
	IF(PRSA.EQ.GIVEW) I=441			!GIVE?
	CALL RSPSUB(I,ODESC2(PRSO))		!TROLL TAKES.
	IF(PRSO.EQ.KNIFE) GO TO 1900		!OBJ KNIFE?
	CALL NEWSTA(PRSO,442,0,0,0)		!NO, EATS IT.
	RETURN
C
1900	CALL RSPEAK(443)			!KNIFE, THROWS IT BACK
	OFLAG2(TROLL)=OFLAG2(TROLL).OR.FITEBT	!AND GETS MAD.
	RETURN
C
2000	IF(.NOT.TROLLF.OR.(PRSA.NE.HELLOW)) GO TO 10
	CALL RSPEAK(366)			!TROLL OUT.
	RETURN
C
10	TROLLP=.FALSE.				!COULDNT HANDLE IT.
	RETURN
	END
C CYCLOP-	CYCLOPS FUNCTION
C
C DECLARATIONS
C
	LOGICAL FUNCTION CYCLOP(ARG)
	IMPLICIT INTEGER (A-Z)
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 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 CYCLOP, PAGE 2
C
	CYCLOP=.TRUE.				!ASSUME WINS.
	IF(.NOT.CYCLOF) GO TO 100		!ASLEEP?
	IF((PRSA.NE.ALARMW).AND.(PRSA.NE.MUNGW).AND.(PRSA.NE.HELLOW).AND.
	1	(PRSA.NE.BURNW).AND.(PRSA.NE.KILLW).AND.(PRSA.NE.ATTACW))
	2	 GO TO 10
	CYCLOF=.FALSE.			!WAKE CYCLOPS.
	CALL RSPEAK(187)			!DESCRIBE.
	RVCYC=IABS(RVCYC)
	OFLAG2(CYCLO)=(OFLAG2(CYCLO).OR.FITEBT).AND..NOT.SLEPBT
	RETURN
C
100	IF((PRSA.EQ.FIGHTW).OR.(PRSA.EQ.FRSTQW)) GO TO 10
	IF(IABS(RVCYC).LE.5) GO TO 200		!ANNOYED TOO MUCH?
	RVCYC=0					!RESTART COUNT.
	CALL JIGSUP(188)			!YES, EATS PLAYER.
	RETURN
C
200	IF(PRSA.NE.GIVEW) GO TO 500		!GIVE?
	IF((PRSO.NE.FOOD).OR.(RVCYC.LT.0)) GO TO 300 !FOOD WHEN HUNGRY?
	CALL NEWSTA(FOOD,189,0,0,0)		!EATS PEPPERS.
	RVCYC=MIN0(-1,-RVCYC)			!GETS THIRSTY.
	RETURN
C
300	IF(PRSO.NE.WATER) GO TO 400		!DRINK WHEN THIRSTY?
	IF(RVCYC.GE.0) GO TO 350
	CALL NEWSTA(PRSO,190,0,0,0)		!DRINKS AND
	CYCLOF=.TRUE.				!FALLS ASLEEP.
	OFLAG2(CYCLO)=(OFLAG2(CYCLO).OR.SLEPBT).AND..NOT.FITEBT
	RETURN
C
350	CALL RSPEAK(191)			!NOT THIRSTY.
10	CYCLOP=.FALSE.				!FAILS.
	RETURN
C
400	I=192					!ASSUME INEDIBLE.
	IF(PRSO.EQ.GARLI) I=193			!GARLIC IS JOKE.
450	CALL RSPEAK(I)				!DISDAIN IT.
	IF(RVCYC.LT.0) RVCYC=RVCYC-1
	IF(RVCYC.GE.0) RVCYC=RVCYC+1
	IF(.NOT.CYCLOF) CALL RSPEAK(193+IABS(RVCYC))
	RETURN
C
500	I=0					!ASSUME NOT HANDLED.
	IF(PRSA.EQ.HELLOW) GO TO 450		!HELLO IS NO GO.
	IF((PRSA.EQ.THROWW).OR.(PRSA.EQ.MUNGW)) I=200+RND(2)
	IF(PRSA.EQ.TAKEW) I=202
	IF(PRSA.EQ.TIEW) I=203
	IF(I) 10,10,450			!SEE IF HANDLED.
C
	END
C THIEFP-	THIEF FUNCTION
C
C DECLARATIONS
C
	LOGICAL FUNCTION THIEFP(ARG)
	IMPLICIT INTEGER (A-Z)
	LOGICAL QHERE,PROB
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 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 /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 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 VILLAINS AND DEMONS
C
	LOGICAL THFFLG,SWDACT,THFACT
	COMMON /HACK/ THFPOS,THFFLG,THFACT,SWDACT
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 THIEFP, PAGE 2
C
	THIEFP=.TRUE.				!ASSUME WINS.
	IF(PRSA.NE.FIGHTW) GO TO 100		!FIGHT?
	IF(OCAN(STILL).EQ.THIEF) GO TO 10	!GOT STILLETTO?  F.
	IF(QHERE(STILL,THFPOS)) GO TO 50	!CAN HE RECOVER IT?
	CALL NEWSTA(THIEF,0,0,0,0)		!NO, VANISH.
	IF(QHERE(THIEF,HERE)) CALL RSPEAK(498)	!IF HERO, TELL.
	RETURN
C
50	CALL NEWSTA(STILL,0,0,THIEF,0)		!YES, RECOVER.
	IF(QHERE(THIEF,HERE)) CALL RSPEAK(499)	!IF HERO, TELL.
	RETURN
C
100	IF(PRSA.NE.DEADXW) GO TO 200		!DEAD?
	THFACT=.FALSE.				!DISABLE DEMON.
	OFLAG1(CHALI)=OFLAG1(CHALI).OR.TAKEBT
	J=0
	DO 125 I=1,OLNT				!CARRYING ANYTHING?
125	  IF(OADV(I).EQ.-THIEF) J=500
	CALL RSPEAK(J)				!TELL IF BOOTY REAPPEARS.
C
	J=501
	DO 150 I=1,OLNT			!LOOP.
	  IF((I.EQ.CHALI).OR.(I.EQ.THIEF).OR.(HERE.NE.TREAS)
	1	.OR. .NOT.QHERE(I,HERE)) GO TO 135
	  OFLAG1(I)=OFLAG1(I).OR.VISIBT		!REMATERIALIZE OBJECTS.
	  CALL RSPSUB(J,ODESC2(I))		!DESCRIBE.
	  J=502
	  GO TO 150
C
135	  IF(OADV(I).EQ.-THIEF) CALL NEWSTA(I,0,HERE,0,0)
150	CONTINUE
	RETURN
C
200	IF(PRSA.NE.FRSTQW) GO TO 250		!FIRST ENCOUNTER?
	THIEFP=PROB(20,75)
	RETURN
C
250	IF((PRSA.NE.HELLOW).OR.(ODESC1(THIEF).NE.504))
	1	GO TO 300			!HELLO TO OUT THIEF?
	CALL RSPEAK(626)
	RETURN
C
300	IF(PRSA.NE.OUTXW) GO TO 400		!OUT?
	THFACT=.FALSE.				!DISABLE DEMON.
	ODESC1(THIEF)=504			!CHANGE DESCRIPTION.
	OFLAG1(STILL)=OFLAG1(STILL).AND..NOT.VISIBT
	OFLAG1(CHALI)=OFLAG1(CHALI).OR.TAKEBT
	RETURN
C
400	IF(PRSA.NE.INXW) GO TO 500		!IN?
	IF(QHERE(THIEF,HERE)) CALL RSPEAK(505)	!CAN HERO SEE?
	THFACT=.TRUE.				!ENABLE DEMON.
	ODESC1(THIEF)=503			!CHANGE DESCRIPTION.
	OFLAG1(STILL)=OFLAG1(STILL).OR.VISIBT
	IF((HERE.EQ.TREAS).AND.QHERE(CHALI,HERE))
	1	OFLAG1(CHALI)=OFLAG1(CHALI).AND..NOT.TAKEBT
	RETURN
C
500	IF(PRSA.NE.TAKEW) GO TO 600		!TAKE?
	CALL RSPEAK(506)			!JOKE.
	RETURN
C
600	IF((PRSA.NE.THROWW).OR.(PRSO.NE.KNIFE).OR.
	1	((OFLAG2(THIEF).AND.FITEBT).NE.0)) GO TO 700
	IF(PROB(10)) GO TO 650			!THREW KNIFE, 10%?
	CALL RSPEAK(507)			!NO, JUST MAKES
	OFLAG2(THIEF)=OFLAG2(THIEF).OR.FITEBT	!THIEF MAD.
	RETURN
C
650	J=508					!THIEF DROPS STUFF.
	DO 675 I=1,OLNT
	  IF(OADV(I).NE.-THIEF) GO TO 675	!THIEF CARRYING?
	  J=509
	  CALL NEWSTA(I,0,HERE,0,0)
675	CONTINUE
	CALL NEWSTA(THIEF,J,0,0,0)		!THIEF VANISHES.
	RETURN
C
700	IF(((PRSA.NE.THROWW).AND.(PRSA.NE.GIVEW)).OR.(PRSO.EQ.0).OR.
	1	(PRSO.EQ.THIEF)) GO TO 10	!THRO/GIVE TO THIEF?
	IF(OCAPAC(THIEF).GE.0) GO TO 750	!WAKE HIM UP.
	OCAPAC(THIEF)=-OCAPAC(THIEF)
	THFACT=.TRUE.
	OFLAG1(STILL)=OFLAG1(STILL).OR.VISIBT
	ODESC1(THIEF)=503
	CALL RSPEAK(510)
C
750	IF((PRSO.NE.BRICK).OR.(OCAN(FUSE).NE.BRICK).OR.
	1	(CTICK(CEVFUS).EQ.0)) GO TO 800
	CALL RSPEAK(511)			!THIEF REFUSES BOMB.
	RETURN
C
800	CALL NEWSTA(PRSO,0,0,0,-THIEF)		!THIEF TAKES GIFT.
	IF(OTVAL(PRSO).GT.0) GO TO 900		!A TREASURE?
	CALL RSPSUB(512,ODESC2(PRSO))
	RETURN
C
900	CALL RSPSUB(627,ODESC2(PRSO))		!THIEF ENGROSSED.
	THFENF=.TRUE.
	RETURN
C
10	THIEFP=.FALSE.
	RETURN
	END
