C TAKE-- BASIC TAKE SEQUENCE
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 TAKE AN OBJECT (FOR VERBS TAKE, PUT, DROP, READ, ETC.)
C
	LOGICAL FUNCTION TAKE(FLG)
C
C DECLARATIONS
C
	IMPLICIT INTEGER (A-Z)
	LOGICAL FLG,OBJACT,OAPPLI,QOPEN,QHERE
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
	COMMON /STATE/ MOVES,DEATHS,RWSCOR,MXSCOR,MXLOAD,
	1	LTSHFT,BLOC,MUNGRM,HS,EGSCOR,EGMXSC
	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 ADVENTURERS
C
	COMMON /ADVS/ ALNT,AROOM(4),ASCORE(4),AVEHIC(4),
	1	AOBJ(4),AACTIO(4),ASTREN(4),AFLAG(4)
C
	COMMON /AINDEX/ PLAYER,AROBOT,AMASTR
C
C FUNCTIONS AND DATA
C
	QOPEN(O)=(OFLAG2(O).AND.OPENBT).NE.0
C TAKE, PAGE 2
C
	TAKE=.FALSE.				!ASSUME LOSES.
	OA=OACTIO(PRSO)				!GET OBJECT ACTION.
	IF(PRSO.LE.STRBIT) GO TO 100	!STAR?
	TAKE=OBJACT(X)			!YES, LET IT HANDLE.
	RETURN
C
100	X=OCAN(PRSO)				!INSIDE?
	IF(PRSO.NE.AVEHIC(WINNER)) GO TO 400	!HIS VEHICLE?
	CALL RSPEAK(672)			!DUMMY.
	RETURN
C
400	IF((OFLAG1(PRSO).AND.TAKEBT).NE.0) GO TO 500 !TAKEABLE?
	IF(.NOT.OAPPLI(OA,0)) CALL RSPEAK(552+RND(5))
	RETURN
C
C OBJECT IS TAKEABLE AND IN POSITION TO BE TAKEN.
C
500	IF((X.NE.0).OR. QHERE(PRSO,HERE)) GO TO 600
	IF(OADV(PRSO).EQ.WINNER) CALL RSPEAK(557)	!ALREADY GOT IT?
	RETURN
C
600	IF(((X.NE.0).AND.(OADV(X).EQ.WINNER)).OR.
	1	((WEIGHT(0,PRSO,WINNER)+OSIZE(PRSO)).LE.MXLOAD))
	2	GO TO 700
	CALL RSPEAK(558)			!TOO MUCH WEIGHT.
	RETURN
C
700	TAKE=.TRUE.				!AT LAST.
	IF(OAPPLI(OA,0)) RETURN			!DID IT HANDLE?
	CALL NEWSTA(PRSO,0,0,0,WINNER)		!TAKE OBJECT FOR WINNER.
	OFLAG2(PRSO)=OFLAG2(PRSO).OR.TCHBT	!HAS BEEN TOUCHED.
	CALL SCRUPD(OFVAL(PRSO))		!UPDATE SCORE.
	OFVAL(PRSO)=0				!CANT BE SCORED AGAIN.
	IF(FLG) CALL RSPEAK(559)		!TELL TAKEN.
	RETURN
C
	END
C DROP- DROP VERB PROCESSOR
C
C DECLARATIONS
C
	LOGICAL FUNCTION DROP(Z)
	IMPLICIT INTEGER (A-Z)
	LOGICAL F,PUT,OBJACT
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
C
C ADVENTURERS
C
	COMMON /ADVS/ ALNT,AROOM(4),ASCORE(4),AVEHIC(4),
	1	AOBJ(4),AACTIO(4),ASTREN(4),AFLAG(4)
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 DROP, PAGE 2
C
	DROP=.TRUE.				!ASSUME WINS.
	X=OCAN(PRSO)				!GET CONTAINER.
	IF(X.EQ.0) GO TO 200			!IS IT INSIDE?
	IF(OADV(X).NE.WINNER) GO TO 1000	!IS HE CARRYING CON?
	IF((OFLAG2(X).AND.OPENBT).NE.0) GO TO 300 !IS IT OPEN?
	CALL RSPSUB(525,ODESC2(X))		!CANT REACH.
	RETURN
C
200	IF(OADV(PRSO).NE.WINNER) GO TO 1000	!IS HE CARRYING OBJ?
300	IF(AVEHIC(WINNER).EQ.0) GO TO 400	!IS HE IN VEHICLE?
	PRSI=AVEHIC(WINNER)			!YES,
	F=PUT(.TRUE.)				!DROP INTO VEHICLE.
	PRSI=0					!DISARM PARSER.
	RETURN					!DONE.
C
400	CALL NEWSTA(PRSO,0,HERE,0,0)		!DROP INTO ROOM.
	IF(HERE.EQ.MTREE) CALL NEWSTA(PRSO,0,FORE3,0,0)
	CALL SCRUPD(OFVAL(PRSO))		!SCORE OBJECT.
	OFVAL(PRSO)=0				!CANT BE SCORED AGAIN.
	OFLAG2(PRSO)=OFLAG2(PRSO).OR.TCHBT	!HAS BEEN TOUCHED.
C
	IF(OBJACT(X)) RETURN			!DID IT HANDLE?
	I=0					!ASSUME NOTHING TO SAY.
	IF(PRSA.EQ.DROPW) I=528
	IF(PRSA.EQ.THROWW) I=529
	IF((I.NE.0).AND.(HERE.EQ.MTREE)) I=659
	CALL RSPSUB(I,ODESC2(PRSO))
	RETURN
C
1000	CALL RSPEAK(527)			!DONT HAVE IT.
	RETURN
C
	END
C PUT- PUT VERB PROCESSOR
C
C DECLARATIONS
C
	LOGICAL FUNCTION PUT(FLG)
	IMPLICIT INTEGER (A-Z)
	LOGICAL QOPEN,QHERE,OBJACT,FLG
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 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 ADVENTURERS
C
	COMMON /ADVS/ ALNT,AROOM(4),ASCORE(4),AVEHIC(4),
	1	AOBJ(4),AACTIO(4),ASTREN(4),AFLAG(4)
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 FUNCTIONS AND DATA
C
	QOPEN(R)=(OFLAG2(R).AND.OPENBT).NE.0
C PUT, PAGE 2
C
	PUT=.FALSE.
	IF((PRSO.LE.STRBIT).AND.(PRSI.LE.STRBIT)) GO TO 200
	IF(.NOT.OBJACT(X)) CALL RSPEAK(560)		!STAR
	PUT=.TRUE.
	RETURN
C
200	IF(QOPEN(PRSI).OR.((OFLAG1(PRSI).AND.(DOORBT+CONTBT)).NE.0)
	1	.OR.((OFLAG2(PRSI).AND.VEHBT).NE.0)) GO TO 300
	CALL RSPEAK(561)			!CANT PUT IN THAT.
	RETURN
C
300	IF(QOPEN(PRSI)) GO TO 400		!IS IT OPEN?
	CALL RSPEAK(562)			!NO, JOKE
	RETURN
C
400	IF(PRSO.NE.PRSI) GO TO 500		!INTO ITSELF?
	CALL RSPEAK(563)			!YES, JOKE.
	RETURN
C
500	IF(OCAN(PRSO).NE.PRSI) GO TO 600	!ALREADY INSIDE.
	CALL RSPSB2(564,ODESC2(PRSO),ODESC2(PRSI))
	PUT=.TRUE.
	RETURN
C
600	IF((WEIGHT(0,PRSO,0)+WEIGHT(0,PRSI,0)+OSIZE(PRSO))
	1	.LE.OCAPAC(PRSI)) GO TO 700	!NOT TOO FULL?
	CALL RSPEAK(565)			!THEN CANT DO IT.
	RETURN
C
C NOW SEE IF OBJECT (OR ITS CONTAINER) IS IN ROOM
C
700	J=PRSO					!START SEARCH.
725	IF(QHERE(J,HERE)) GO TO 750		!IS IT HERE?
	J=OCAN(J)
	IF(J.NE.0) GO TO 725			!MORE TO DO?
	GO TO 800				!NO, SCH FAILS.
C
750	SVO=PRSO				!SAVE PARSER.
	SVI=PRSI
	PRSA=TAKEW
	PRSI=0
	IF(.NOT.TAKE(.FALSE.)) RETURN		!TAKE OBJECT.
	PRSA=PUTW
	PRSO=SVO
	PRSI=SVI
	GO TO 1000
C
C NOW SEE IF OBJECT IS ON PERSON.
C
800	IF(OCAN(PRSO).EQ.0) GO TO 1000		!INSIDE?
	IF(QOPEN(OCAN(PRSO))) GO TO 900		!OPEN?
	CALL RSPSUB(566,ODESC2(PRSO))		!LOSE.
	RETURN
C
900	CALL SCRUPD(OFVAL(PRSO))		!SCORE OBJECT.
	OFVAL(PRSO)=0
	OFLAG2(PRSO)=OFLAG2(PRSO).OR.TCHBT	!HAS BEEN TOUCHED.
	CALL NEWSTA(PRSO,0,0,0,WINNER)		!TEMPORARILY ON WINNER.
C
1000	IF(OBJACT(X)) RETURN			!NO, GIVE OBJECT A SHOT.
	CALL NEWSTA(PRSO,2,0,PRSI,0)		!CONTAINED INSIDE.
	PUT=.TRUE.
	RETURN
C
	END
C VALUAC- HANDLES VALUABLES/EVERYTHING
C
C DECLARATIONS
C
	SUBROUTINE VALUAC(V)
	IMPLICIT INTEGER (A-Z)
	LOGICAL LIT,F,F1,TAKE,PUT,DROP,NOTVAL,QHERE
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
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 FUNCTIONS AND DATA
C
	NOTVAL(R)=(SAVEP.EQ.V).AND.(OTVAL(R).LE.0)
C VALUAC, PAGE 2
C
	F=.TRUE.				!ASSUME NO ACTIONS.
	I=579					!ASSUME NOT LIT.
	IF(.NOT.LIT(HERE)) GO TO 4000		!IF NOT LIT, PUNT.
	I=677					!ASSUME WRONG VERB.
	SAVEP=PRSO				!SAVE PRSO.
	SAVEH=HERE				!SAVE HERE.
C
100	IF(PRSA.NE.TAKEW) GO TO 1000		!TAKE EVERY/VALUA?
	DO 500 PRSO=1,OLNT			!LOOP THRU OBJECTS.
	  IF(.NOT.QHERE(PRSO,HERE).OR.
	1	((OFLAG1(PRSO).AND.VISIBT).EQ.0).OR.
	2	((OFLAG2(PRSO).AND.ACTRBT).NE.0).OR.
	3	NOTVAL(PRSO)) GO TO 500
	  IF(((OFLAG1(PRSO).AND.TAKEBT).EQ.0).AND.
	1	((OFLAG2(PRSO).AND.TRYBT).EQ.0)) GO TO 500
	  F=.FALSE.
	  CALL RSPSUB(580,ODESC2(PRSO))
	  F1=TAKE(.TRUE.)
	  IF(SAVEH.NE.HERE) RETURN
500	CONTINUE
	GO TO 3000
C
1000	IF(PRSA.NE.DROPW) GO TO 2000		!DROP EVERY/VALUA?
	DO 1500 PRSO=1,OLNT
	  IF((OADV(PRSO).NE.WINNER).OR.NOTVAL(PRSO))
	1	GO TO 1500
	  F=.FALSE.
	  CALL RSPSUB(580,ODESC2(PRSO))
	  F1=DROP(.TRUE.)
	  IF(SAVEH.NE.HERE) RETURN
1500	CONTINUE
	GO TO 3000
C
2000	IF(PRSA.NE.PUTW) GO TO 3000		!PUT EVERY/VALUA?
	DO 2500 PRSO=1,OLNT			!LOOP THRU OBJECTS.
	  IF((OADV(PRSO).NE.WINNER)
	1	.OR.(PRSO.EQ.PRSI).OR.NOTVAL(PRSO).OR.
	2	((OFLAG1(PRSO).AND.VISIBT).EQ.0)) GO TO 2500
	  F=.FALSE.
	  CALL RSPSUB(580,ODESC2(PRSO))
	  F1=PUT(.TRUE.)
	  IF(SAVEH.NE.HERE) RETURN
2500	CONTINUE
C
3000	I=581
	IF(SAVEP.EQ.V) I=582			!CHOOSE MESSAGE.
4000	IF(F) CALL RSPEAK(I)			!IF NOTHING, REPORT.
	RETURN
	END
