10 REM 		DEVILS DUNGEON from "STIMULATING SIMULATIONS by C.W.Engel
20 REM 		as modified by A.E.McLaughlin Jr. ----4/4/81
30 E$=CHR$(27):E1$=E$+"E":P$=E$+"p":J$=E$+"j":X1$=E$+"x":Y$=E$+"Y":Q$=E$+"q"
40 K$=E$+"k":K1$=E$+"K":Y1$=E$+"Y":Z$=E$+"z":PRINT E1$
50 PRINT,,"Welcome to the DEVILS DUNGEON"
60 PRINT,"----When you wish to quit, enter `99' in room #1 on any level."
70 PRINT,"-You gain experience by moving (1 x level #), fighting monsters"
80 PRINT,"and finding gold (1 pt. for each piece of gold)."
90 PRINT,"-Enter `0' in any room #1 to trade experience for speed or"
100 PRINT,"strength. If you run out of strength or speed, you die ---so"
110 PRINT,"on each level, try to find room #1 as quick as possible."
120 PRINT,"-Enter the room number to goto any adjacent room in the list."
130 PRINT,"-Enter `0' in any room but #1 to fight the monster if you are"
140 PRINT,"strong enough. I'll print his speed & strength for comparison."
150 PRINT,"-If stuck, enter `99' in any room except #1 to use your magic"
160 PRINT,"wand. This will create a DROPOFF (if it works!). It has been"
170 PRINT,"known to malfunction once in a while and cost you speed and"
180 PRINT,"strength. DROPOFFs take you to the next level down if you enter "
190 PRINT,"`.1' but you can't go back up. Slides are also one way! Some"
200 PRINT,"corridors might be enchanted allowing one way only also!"
210 PRINT,"-The deeper you go, the more gold is available to find but the"
220 PRINT,"monsters become stronger and faster also! Your speed and strength"
230 PRINT,"go down each move by an amount equal to the level you're on.":PRINT
240 PRINT,"I'll print a command reminder at the bottom when you are ready to"
250 PRINT,"play so you don't have to memorize these instructions. Please,
260 PRINT,"press ENTER when ready for more instructions.";:INPUT"---READY";ZZ$:PRINT E1$
270 PRINT,"-Drawing a map of each level is recommended but not necessary"
280 PRINT,"as you can enter `88' at any time to get a list of rooms you"
290 PRINT,"have visited and the numbers of rooms they connect to."
300 PRINT,"In case of a `tremor', things will change so better check!":PRINT
310 PRINT,"     Let's see----did I forget anything----?";:FOR I=1 TO 2000:NEXT
320 PRINT:PRINT,"-Oh yes, the GOLD. You have to take it out of the room to get to"
330 PRINT,"keep it and any monster there wont let you take it while it's"
340 PRINT,"alive so it's either fight or run and leave the gold behind!"
350 PRINT,"-Also, you may run into Demons and poison gas down here!"
360 PRINT,"Demons might curse you (take half your speed) or steal your gold."
370 PRINT,"If gassed, you'll lose half your strength.":PRINT
380 PRINT,"-------When you are ready to play, press ENTER.":PRINT:PRINT,;:INPUT"READY";ZZ$
385 GOSUB 390
386 GOTO 420
390 PRINT:PRINT P$;J$;X1$;Y$;:REM reverse video,save cursor,enable 25,pos. cursor
400 PRINT"  `0'=fight or trade `99'=use wand or quit `88'=review rooms `.1'=decend   "
410 PRINT Q$;K$;Y1$:REM reset rvs video,restore cursor,turnoff 25
415 RETURN
420 PRINT E1$:PRINT,"Hang on while I draw my maps!":PRINT
430 REM SET ROOMS
440 DIM R(16),L(65),F(16),X(19),B(16)
450 L=1: G=0: E=0:X=16:D=1:YS=101:YD=101
460 PRINT:IF C=0 THEN C=1:GOTO 510
470 IF C=1 THEN C=2:PRINT,"OK, let me get the map.":GOTO 510
480 IF C=2 THEN C=3:PRINT,"Elevator going down!":GOTO 510
490 IF C=3 THEN C=4:PRINT,"AGAIN!--- Where did I put those maps!":GOTO 510
500 IF C=4 THEN C=1:PRINT,"You sure are keeping me busy!"
510 FOR I=0 TO 65:L(I)=0:NEXT
520 FOR I=1 TO X:N=INT(3*RND(1)+1)
530 IF I=1 THEN N=3
540 FOR J=1 TO N
550 R=INT(64*RND(1)+1)
560 IF L(R)<>0 THEN 550
570 L(R)=I:NEXT J
580 R(I)=INT(524287!*RND(1)):B(I)=0
590 NEXT I:B(L)=1
600 R(1)=24576:FOR I=1 TO 19:X(I)=0:NEXT
610 REM HAZARDS
620 IF RND(1)<.01 THEN PRINT "TREMOR":FOR I=1 TO 20:L(I)=INT(X*RND(1)+1):NEXT
630 IF RND(1)<.01 THEN PRINT "TREMOR":FOR I=1 TO 20:L(I)=0:NEXT
640 IF X(1)*X(12)=1 AND RND(1)<.4 THEN PRINT "CURSED BY DEMON!":YD=INT(.5*YD)
650 IF X(9)*X(11)=1 AND RND(1)<.4 THEN PRINT "GASSED!":YS=INT(.5*YS)
660 YD=YD-D:YS=YS-D:IF YD>0 AND YS>0 THEN 860:REM     DECREMENT AND TEST
670 IF YD<=0 THEN PRINT:PRINT,"You just ran out of speed and died!":GOTO 690
680 IF YS<=0 THEN PRINT:PRINT,"You just exhausted your strength and died!"
690 PRINT:PRINT, "It might be possible for me to bring you back to life!"
700 PRINT,"Would you like to try again? 1=YES 2=NO <NO>";:INPUT B 
710 IF B=1 THEN B=0:GOTO 740
720 PRINT E1$:PRINT,"OK, so long-----QUITTER!"
730 FOR I=1 TO 999:NEXT:PRINT:PRINT P$;J$;X1$;Y$;K1$;Y1$;K$:FOR C=1 TO 800:NEXT:PRINT E1$:END
740 PRINT:PRINT,"Would you like to start from the beginning? Enter (0)-"
750 PRINT,"or continue from where you are? Enter (1)-";:INPUT B
760 IF B=0 THEN RUN 
770 A=A+1:IF A=3 THEN 830 ELSE YD=101:YS=101
772 PRINT E1$:PRINT Y$"#&";:PRINT"CUT--CUT--PULL--TWIST--PUSH--SEW--SEW"
774 FOR I=1 TO 800:NEXT:PRINT:PRINT,,"THERE!!!":PRINT:PRINT
780 PRINT:PRINT,"The operation was a success! You have been returned"
790 PRINT,"to the land of the living and for my modest fee,"
800 IF G-250>0 THEN 820 ELSE G=0
810 PRINT,"I extracted the small amount of gold you had!":GOTO 860
820 G=G-250:PRINT,"I took only 250 pieces of gold.":GOTO 860
830 PRINT E1$:PRINT Y$"(-";:PRINT "----POOF----":PRINT Y$"--";
840 PRINT"Oh-Oh! It didn't work!":PRINT
850 PRINT,"Oh well, no one is perfect! Two out of three isn't bad!":GOTO 730
860 PRINT:PRINT,"GOLD";G;"    ";"EXP.";E;"DEPTH";D:REM	OUTPUT STATUS
870 PRINT,"SPEED:";YD;,"STRENGTH:";YS:GOSUB 880:GOTO 940
880 FOR I=1 TO X:F(I)=0:NEXT:REM		ADJACENT ROOMS
890 FOR I=1 TO 64
900 IF L<>L(I) THEN 930
910 IF L(I+1)<>0 AND L(I+1)<>L THEN F(L(I+1))=1
920 IF L(I-1)<>0 AND L(I-1)<>1 THEN F(L(I-1))=1
930 NEXT:RETURN
940 N=R(L):REM					CONVERT
950 FOR I=1 TO 19:Q=INT(N/2):X(I)=2*(N/2-Q):N=Q:NEXT
960 IF X(2)=0 THEN MS=0:GOTO 1010:REM		MONSTERS,DEMONS,GAS
970 IF F=1 THEN 1000
980 MS=D*(X(3)+2*X(4)+4*X(5)+L)
990 MD=D*(X(6)+2*X(7)+4*X(8)+L)
1000 PRINT"MONSTER","SPEED:";MD;,"STRENGTH:";MS
1010 IF X(1)*X(12)=1 THEN PRINT "DEMONS"
1020 IF X(9)*X(11)=1 THEN PRINT"POISONOUS GAS"
1030 IF X(10)<>1 THEN T=0:GOTO 1060:REM		TREASURE
1040 T=X(11)+2*X(12)+4*X(13)+1
1050 PRINT,"MAXIMUM GOLD:";T*L*D+1
1060 S=X(15)+2*X(16)+4*X(17)+8*X(18)+1:REM	SLIDES AND DROPOFFS
1070 IF S>X THEN S=1
1080 IF S=0 THEN S=1
1090 IF X(14)=0 OR S=L THEN 1110
1100 PRINT,"SLIDE TO:";S
1110 IF X(19)*X(13)=1 THEN PRINT,"DROPOFF"
1120 PRINT,"MOVE FROM ROOM #";L;"TO ROOM #";:REM INPUT MOVE
1130 FOR I=1 TO X
1140 IF F(I)=1 AND I<>L THEN PRINT I;
1150 NEXT I
1155 GOSUB 390
1160 INPUT M:IF M=88 THEN 1540
1170 IF M<>99 AND M>16 THEN 1530
1180 IF M<1 AND M<>0 AND X(19)*X(13)=1 THEN D=D+1:F=0:GOTO 460
1190 IF M<1 AND M<>0 THEN PRINT"NO DROPOFF":GOTO 620
1200 IF M<>99 THEN 1250
1210 IF M=99 AND L=1 THEN PRINT E1$:PRINT,"YOU FOUND";G;"PIECES OF GOLD!":GOTO 730
1220 REM MAGIC WAND
1230 IF RND(1)<.4 THEN PRINT"BACKFIRE":YS=INT(.5*YS):YD=INT(.5*YD):GOTO 620
1240 PRINT,"WAND WORKS!":R(L)=266240!:GOTO 860
1250 IF MS>0 THEN 1340:REM			MOVE OR TRADE
1260 IF M=0 AND L<>1 THEN PRINT,"No monster to fight! Enter room #";:GOTO 1160
1270 IF M<>0 OR L<>1 THEN 1460
1280 PRINT,"EXPERIENCE:";E;"SPEED:";YD;"STRENGTH:";YS:PRINT,"ADD SPEED";:INPUT N
1290 IF E-N<0 THEN PRINT,"NEED MORE EXPERIENCE":GOTO 1280
1300 E=E-N:YD=YD+N:PRINT,"EXPERIENCE LEFT:";E
1310 PRINT,"ADD STRENGTH";:INPUT N
1320 IF E-N<0 THEN PRINT,,"NEED MORE EXPERIENCE":GOTO 1310
1330 E=E-N:YS=YS+N:GOTO 860
1340 F=1:IF M>0 THEN 1440:REM			FIGHT
1350 IF M>0 THEN 1440
1360 YH=INT(RND(1)*YS):MH=INT(RND(1)*MS)
1370 IF YH>MS THEN YH=MS
1380 IF MH>YS THEN MH=YS
1390 IF RND(1)*YD>RND(1)*MD THEN 1410
1400 PRINT,"Monster attacks!":YS=YS-MH:MS=MS-INT(.5*YH):GOTO 1420
1410 PRINT,"You attack!":MS=MS-YH:YS=YS-INT(.5*MH):E=E+2*YH
1420 IF MS<=0 THEN PRINT,"Monster Killed!":R(L)=R(L)-2:GOTO 620
1430 PRINT:PRINT,"Monster still alive!":GOTO 620
1440 PRINT:IF RND(1)*YD>RND(1)*MD THEN PRINT,"ESCAPED":GOTO 1520:REM   RUN
1450 PRINT,"Monster HIT you!":YS=YS-INT(.2*MS):GOTO 1520
1460 IF T=0 THEN 1520:REM TREASURE
1470 G1=INT(RND(1)*T*L*D)+1:PRINT
1480 IF X(1)*X(12)=1 AND RND(1)<.4 THEN PRINT,"Demon got gold!":G1=0:GOTO 1500
1490 PRINT,"You found";G1;"pieces of gold.":G=G+G1
1500 E=E+G1:R(L)=R(L)-512
1510 REM 					MOVE
1520 IF F(M)=1 OR M=S THEN L=M:F=0:E=E+D:B(L)=1:GOTO 620
1530 PRINT:PRINT,"Not adjacent! Try a different room! Room #";:GOTO 1160
1540 L1=L:FOR K=1 TO X:REM			PRINT ROOMS
1550 IF B(K)<>1 THEN 1610
1560 PRINT,K; "--";
1570 L=K:GOSUB 880
1580 FOR J=1 TO X
1590 IF F(J)=1 AND J<>K THEN PRINT J;
1600 NEXT J:PRINT
1610 NEXT K
1620 L=L1:GOTO 860
