1000 REM *****************************************************
1005 REM *                                                   *
1010 REM * WIZARD'S CASTLE GAME FROM JULY/AUGUST 1980        *
1015 REM * ISSUE OF RECREATIONAL COMPUTING MAGAZINE          *
1020 REM * WRITTEN FOR EXIDY SORCERER BY JOSEPH R. POWER     *
1025 REM * MODIFIED FOR HEATH MICROSOFT BASIC BY J.F.STETSON *
1030 REM *                                                   *
1035 REM *****************************************************
1040 DEFINT A-Z
1045 DIM C$(34),I$(34),R$(4),W$(8),E$(8)
1050 DIM L(512),C(3,4),T(8),O(3),R(3)
1055 DEF FNA(Q)=1+INT(RND(1)*Q)
1060 DEF FNB(Q)=Q+8*((Q=9)-(Q=0))
1065 DEF FNC(Q)=-Q*(Q<19)-18*(Q>18)
1070 DEF FND(Q)=64*(Q-1)+8*(X-1)+Y
1075 DEF FNE(Q)=Q+100*(Q>99)
1080 Y$="** PLEASE ANSWER YES OR NO"
1085 NG=0
1090 REM
1095 REM   INITIALIZE ARRAYS
1100 REM
1105 NG=NG+1
1110 Q=RND(1)
1115 RESTORE
1120 FOR Q=1 TO 34
1125 READ C$(Q),I$(Q)
1130 NEXT Q
1135 FOR Q=1 TO 512
1140 L(Q)=101
1145 NEXT Q
1150 FOR Q=1 TO 8
1155 READ W$(Q),E$(Q)
1160 NEXT Q
1165 FOR Q=1 TO 4
1170 READ R$(Q)
1175 NEXT Q
1180 IF NG > 1 GOTO 1250
1185 PRINT CHR$(27);"E"
1190 GOSUB 5375
1195 PRINT TAB(16);"* * * THE WIZARD'S CASTLE * * *"
1200 PRINT
1205 GOSUB 5375
1210 PRINT "MANY CYCLES AGO, IN THE KINGDOM OF N'DIC, THE GNOMIC"
1215 PRINT "WIZARD ZOT FORGED HIS GREAT *ORB OF POWER*. HE SOON"
1220 PRINT "VANISHED, LEAVING BEHIND HIS VAST SUBTERRANEAN CASTLE"
1225 PRINT "FILLED WITH ESURIENT MONSTERS, FABULOUS TREASURES, AND"
1230 PRINT "THE INCREDIBLE *ORB OF ZOT*. FROM THAT TIME HENCE, MANY"
1235 PRINT "A BOLD YOUTH HAS VENTURED INTO THE WIZARD'S CASTLE. AS"
1240 PRINT "OF NOW, *NONE* HAS EVER EMERGED VICTORIOUSLY! BEWARE!!"
1245 PRINT
1250 X=1 : Y=4
1255 L(FND(1))=2
1260 FOR Z=1 TO 7
1265 FOR Q1=1 TO 2
1270 Q=104
1275 GOSUB 5285
1280 L(FND(Z+1))=103
1285 NEXT Q1
1290 NEXT Z
1295 FOR Z=1 TO 8
1300 FOR Q=113 TO 124
1305 GOSUB 5285
1310 NEXT Q
1315 FOR Q1=1 TO 3
1320 FOR Q=105 TO 112
1325 GOSUB 5285
1330 NEXT Q
1335 Q=125
1340 GOSUB 5285
1345 NEXT Q1
1350 NEXT Z
1355 FOR Q=126 TO 133
1360 Z=FNA(8)
1365 GOSUB 5285
1370 NEXT Q
1375 Q=101
1380 FOR A=1 TO 3
1385 Z=FNA(8)
1390 GOSUB 5285
1395 C(A,1)=X
1400 C(A,2)=Y
1405 C(A,3)=Z
1410 C(A,4)=0
1415 NEXT A
1420 RC=0
1425 ST=2
1430 DX=14
1435 R$(3)="MAN"
1440 Q=112+FNA(12)
1445 Z=FNA(8)
1450 GOSUB 5285
1455 R(1)=X
1460 R(2)=Y
1465 R(3)=Z
1470 Q=109
1475 Z=FNA(8)
1480 GOSUB 5285
1485 O(1)=X
1490 O(2)=Y
1495 O(3)=Z
1500 BF=0 : OT=8 : AV=0 : HT=0 : T=1 : VF=0 : LF=0
1505 TC=0 : GP=60 : RF=0 : OF=0 : BL=0 : IQ=8 : SX=0
1510 FOR Q=1 TO 8
1515 T(Q)=0
1520 NEXT Q
1525 PRINT CHR$(7);
1530 PRINT "ALL RIGHT, BOLD ONE."
1535 PRINT "YOU MAY BE AN ELF, DWARF, MAN, OR HOBBIT."
1540 GOSUB 5405
1545 FOR Q=1 TO 4
1550 IF LEFT$(R$(Q),1)=O$ THEN RC=Q : ST=ST+2*Q : DX=DX-2*Q
1555 NEXT Q
1560 PRINT
1565 OT=OT+4*(RC=1)
1570 IF RC > 0 THEN R$(3)="HUMAN" : GOTO 1585
1575 PRINT "** THAT WAS INCORRECT. PLEASE TYPE E, D, M, OR H."
1580 GOTO 1535
1585 PRINT "WHICH SEX TO YOU PREFER";
1590 GOSUB 5415
1595 IF O$="M" THEN SX=1 : GOTO 1615
1600 IF O$="F" GOTO 1615
1605 PRINT "** CUTE ";R$(RC);", REAL CUTE. TRY M OR F."
1610 GOTO 1585
1615 PRINT
1620 PRINT "OK, ";R$(RC);", YOU HAVE THE FOLLOWING ATTRIBUTES :"
1625 PRINT "STRENGTH =";ST;" INTELLIGENCE =";IQ;" DEXTERITY =";DX
1630 PRINT "AND";OT;"OTHER POINTS TO ALLOCATE AS YOU WISH."
1635 PRINT
1640 Z$="STRENGTH"
1645 GOSUB 5430
1650 ST=ST+Q
1655 IF OT=0 GOTO 1695
1660 Z$="INTELLIGENCE"
1665 GOSUB 5430
1670 IQ=IQ+Q
1675 IF OT=0 GOTO 1695
1680 Z$="DEXTERITY"
1685 GOSUB 5430
1690 DX=DX+Q
1695 PRINT "OK, ";R$(RC);", YOU HAVE 60 GOLD PIECES (GP'S)."
1700 Z$="ARMOR"
1705 GOSUB 5555
1710 AV=0 : WV=0 : FL=0 : WC=0
1715 PRINT "PLATE<30> CHAINMAIL<20> LEATHER<10> NOTHING<0>"
1720 GOSUB 5405
1725 IF O$="N" GOTO 1755
1730 AV=-3*(O$="P")-2*(O$="C")-(O$="L")
1735 IF AV > 0 GOTO 1755
1740 PRINT
1745 PRINT "** ARE YOU A ";R$(RC);" OR ";C$(FNA(12)+12);"?"
1750 GOTO 1700
1755 AH=AV*7 : GP=GP-AV*10
1760 PRINT
1765 PRINT "OK, BOLD ";R$(RC);", YOU HAVE";GP;"GP'S LEFT."
1770 Z$="WEAPONS"
1775 GOSUB 5555
1780 PRINT "SWORD<30> MACE<20> DAGGER<10> NOTHING<0>"
1785 GOSUB 5405
1790 IF O$="N" GOTO 1820
1795 WV=-3*(O$="S")-2*(O$="M")-(O$="D")
1800 IF WV > 0 GOTO 1820
1805 PRINT 
1810 PRINT "** IS YOUR IQ REALLY";IQ;"?"
1815 GOTO 1770
1820 GP=GP-WV*10
1825 IF GP < 20 GOTO 1855
1830 PRINT
1835 PRINT "DO YOU WANT TO BUY A LAMP FOR 20 GP'S";
1840 GOSUB 5415
1845 IF O$="Y" THEN LF=1 : GP=GP-20 : GOTO 1855
1850 IF O$ <> "N" THEN PRINT : PRINT Y$ : PRINT : GOTO 1835
1855 PRINT
1860 IF GP < 1 THEN Q=0 : GOTO 1915
1865 PRINT "OK, ";R$(RC);", YOU HAVE";GP;"GOLD PIECES LEFT."
1870 PRINT
1875 INPUT "FLARES COST 1 GP EACH. HOW MANY DO YOU WANT";O$
1880 Q=VAL(O$)
1885 PRINT
1890 IF Q > 0 OR ASC(O$)=48 GOTO 1910
1895 PRINT "** IF YOU DON'T WANT ANY, JUST TYPE 0 (ZERO)."
1900 PRINT
1905 GOTO 1875
1910 IF Q > GP THEN PRINT "** YOU CAN ONLY AFFORD";GP;"." : PRINT : GOTO 1875
1915 FL=FL+Q : GP=GP-Q
1920 X=1 : Y=4 : Z=1
1925 PRINT "OK, ";R$(RC);", YOU ARE NOW ENTERING THE CASTLE!"
1930 GOTO 3450
1935 REM
1940 REM   MAIN PROCESSING LOOP
1945 REM
1950 T=T+1
1955 IF RF+OF > 0 GOTO 2020
1960 IF C(1,4) > T(1) THEN T=T+1
1965 IF C(2,4) > T(3) THEN GP=GP-FNA(5)
1970 IF GP < 0 THEN GP=0
1975 IF C(3,4) <= T(5) GOTO 2020
1980 A=X : B=Y : C=Z
1985 X=FNA(8) : Y=FNA(8) : Z=FNA(8)
1990 L(FND(Z))=FNE(L(FND(Z)))+100
1995 X=A : Y=B : Z=C
2000 IF L(FND(Z)) <> 1 GOTO 2020
2005 FOR Q=1 TO 3
2010 C(Q,4)=-(C(Q,1)=X)*(C(Q,2)=Y)*(C(Q,3)=Z)
2015 NEXT Q
2020 IF FNA(5) > 1 GOTO 2165
2025 PRINT
2030 PRINT "YOU ";
2035 Q=FNA(7)+BL
2040 IF Q > 7 THEN Q=4
2045 ON Q GOSUB 2125,2065,2115,2055,2135,2145,2155
2050 GOTO 2165
2055 PRINT "STEPPED ON A FROG!"
2060 RETURN
2065 PRINT "HEAR ";
2070 ON FNA(4) GOTO 2075,2085,2095,2105
2075 PRINT "A SCREAM!"
2080 RETURN
2085 PRINT "FOOTSTEPS!"
2090 RETURN
2095 PRINT "A WUMPUS!"
2100 RETURN
2105 PRINT "THUNDER!"
2110 RETURN
2115 PRINT "SNEEZED!"
2120 RETURN
2125 PRINT "SEE A BAT FLY BY!"
2130 RETURN
2135 PRINT "SMELL ";C$(12+FNA(13));" FRYING!"
2140 RETURN
2145 PRINT "FEEL LIKE YOU'RE BEING WATCHED!"
2150 RETURN
2155 PRINT "HEAR FAINT RUSTLING NOISES!"
2160 RETURN
2165 IF BL+T(4) <> 2 GOTO 2185
2170 PRINT
2175 PRINT C$(29);" CURES YOUR BLINDNESS!"
2180 BL=0
2185 IF BF+T(6) <> 2 GOTO 2205
2190 PRINT
2195 PRINT C$(31);" DISSOLVES THE BOOK!"
2200 BF=0
2205 PRINT
2210 LINE INPUT "ENTER YOUR COMMAND : ";O$
2215 IF LEFT$(O$,2)="DR" GOTO 2870
2220 O$=LEFT$(O$,1)
2225 IF O$="N" GOTO 2435
2230 IF (O$="S") OR (O$="W") OR (O$="E") GOTO 2440
2235 IF O$="U" GOTO 2465
2240 IF O$="D" GOTO 2480
2245 IF O$="M" GOTO 2505
2250 IF O$="F" THEN ON BL+1 GOTO 2620,2505
2255 IF O$="L" THEN ON BL+1 GOTO 2750,2505
2260 IF O$="O" GOTO 2965
2265 IF O$="G" THEN ON BL+1 GOTO 3185,2505
2270 IF O$="T" THEN PRINT : ON RF+1 GOTO 3315,3335
2275 IF O$="Q" GOTO 3390
2280 IF O$<>"H" GOTO 2420
2285 PRINT CHR$(27);"E"
2290 PRINT "*** WIZARD'S CASTLE COMMAND AND INFORMATION SUMMARY ***"
2295 PRINT
2300 PRINT "THE FOLLOWING COMMANDS ARE AVAILABLE :"
2305 PRINT 
2310 PRINT "H/ELP     N/ORTH    S/OUTH    E/AST     W/EST     U/P"
2315 PRINT "D/OWN     DR/INK    M/AP      F/LARE    L/AMP     O/PEN"
2320 PRINT "G/AZE     T/ELEPORT Q/UIT"
2325 PRINT
2330 PRINT "THE CONTENTS OF ROOMS ARE AS FOLLOWS :"
2335 PRINT
2340 PRINT ". = EMPTY ROOM      B = BOOK            C = CHEST"
2345 PRINT "D = STAIRS DOWN     E = ENTRANCE/EXIT   F = FLARES"
2350 PRINT "G = GOLD PIECES     M = MONSTER         O = CRYSTAL ORB"
2355 PRINT "P = MAGIC POOL      S = SINKHOLE        T = TREASURE"
2360 PRINT "U = STAIRS UP       V = VENDOR          W = WARP/ORB"
2365 PRINT
2370 PRINT "THE BENEFITS OF HAVING TREASURES ARE :"
2375 PRINT
2380 PRINT "RUBY RED - AVOID LETHARGY     PALE PEARL - AVOID LEECH"
2385 PRINT "GREEN GEM - AVOID FORGETTING  OPAL EYE - CURES BLINDNESS"
2390 PRINT "BLUE FLAME - DISSOLVES BOOKS  NORN STONE - NO BENEFIT"
2395 PRINT "PALANTIR - NO BENEFIT         SILMARIL - NO BENEFIT"
2400 PRINT
2405 PRINT "PRESS RETURN WHEN READY TO RESUME, ";R$(RC);".";
2410 LINE INPUT "";O$
2415 GOTO 1950
2420 PRINT
2425 PRINT "** SILLY ";R$(RC);", THAT WASN'T A VALID COMMAND!"
2430 GOTO 1950
2435 IF L(FND(Z))=2 GOTO 4970
2440 X=X+(O$="N")-(O$="S")
2445 Y=Y+(O$="W")-(O$="E")
2450 X=FNB(X)
2455 Y=FNB(Y)
2460 GOTO 3450
2465 IF L(FND(Z))=3 THEN Z=Z-1 : GOTO 3450
2470 Z$="UP"
2475 GOTO 2490
2480 Z$="DOWN"
2485 IF L(FND(Z))=4 THEN Z=Z+1 : GOTO 3450
2490 PRINT
2495 PRINT "** THERE ARE NO STAIRS GOING ";Z$;" FROM HERE!"
2500 GOTO 1950
2505 IF BL <> 1 GOTO 2540
2510 PRINT
2515 PRINT "** YOU CAN'T SEE ANYTHING, YOU DUMB ";R$(RC);"!"
2520 GOTO 1950
2525 REM
2530 REM   DISPLAY MAP OF CURRENT CASTLE LEVEL
2535 REM
2540 PRINT
2545 A=X : B=Y
2550 FOR X=1 TO 8
2555 FOR Y=1 TO 8
2560 Q=L(FND(Z))
2565 IF Q>99 THEN Q=34 ' LET Q=Q-100 TO SHOW ROOMS
2570 IF X=A AND Y=B THEN PRINT "<";I$(Q);">  "; : GOTO 2580
2575 PRINT " ";I$(Q);"   ";
2580 NEXT Y
2585 PRINT
2590 PRINT
2595 NEXT X
2600 X=A : Y=B
2605 GOTO 2725
2610 PRINT ") LEVEL";Z
2615 GOTO 1950
2620 IF FL <> 0 GOTO 2650
2625 PRINT "** HEY, BRIGHT ONE, YOU'RE OUT OF FLARES!"
2630 GOTO 1950
2635 REM
2640 REM   DISPLAY ADJACENT ROOM CONTENTS WITH FLARE
2645 REM
2650 PRINT
2655 FL=FL-1
2660 A=X : B=Y
2665 FOR Q1=A-1 TO A+1
2670 X=FNB(Q1)
2675 FOR Q2=B-1 TO B+1
2680 Y=FNB(Q2)
2685 Q=FNE(L(FND(Z)))
2690 L(FND(Z))=Q
2695 PRINT " ";I$(Q);"   ";
2700 NEXT Q2
2705 PRINT
2710 PRINT
2715 NEXT Q1
2720 X=A : Y=B
2725 GOSUB 5570
2730 GOTO 1950
2735 REM
2740 REM   DISPLAY CONTENTS OF ADJACENT ROOM WITH LAMP
2745 REM
2750 IF LF <> 0 GOTO 2770
2755 PRINT
2760 PRINT "** YOU DON'T HAVE A LAMP, ";R$(RC);"!"
2765 GOTO 1950
2770 PRINT
2775 PRINT "WHERE DO YOU WANT TO SHINE THE LAMP (N,S,E,W)";
2780 GOSUB 5415
2785 A=X : B=Y
2790 X=FNB(X+(O$="N")-(O$="S"))
2795 Y=FNB(Y+(O$="W")-(O$="E"))
2800 IF A-X+B-Y <> 0 GOTO 2820
2805 PRINT
2810 PRINT "** THAT'S NOT A DIRECTION, ";R$(RC);"!"
2815 GOTO 1950
2820 PRINT
2825 PRINT "THE LAMP SHINES INTO (";X;",";Y;") LEVEL";Z;"."
2830 PRINT
2835 L(FND(Z))=FNE(L(FND(Z)))
2840 PRINT "THERE YOU WILL FIND ";C$(L(FND(Z)));"."
2845 X=A : Y=B
2850 GOTO 1950
2855 REM
2860 REM   TAKE A DRINK FROM A POOL
2865 REM
2870 IF L(FND(Z))=5 GOTO 2890
2875 PRINT
2880 PRINT "** IF YOU WANT A DRINK, FIND A POOL!"
2885 GOTO 1950
2890 Q=FNA(8)
2895 PRINT
2900 PRINT "YOU TAKE A DRINK AND ";
2905 IF Q < 7 THEN PRINT "FEEL ";
2910 ON Q GOTO 2915,2920,2925,2930,2935,2940,2945,2955
2915 ST=FNC(ST+FNA(3)) : PRINT "STRONGER." : GOTO 1950
2920 ST=ST-FNA(3) : PRINT "WEAKER." : ON (1-(ST<1)) GOTO 1950,4910
2925 IQ=FNC(IQ+FNA(3)) : PRINT "SMARTER." : GOTO 1950
2930 IQ=IQ-FNA(3) : PRINT "DUMBER." : ON (1-(IQ<1)) GOTO 1950,4910
2935 DX=FNC(DX+FNA(3)) : PRINT "NIMBLER." : GOTO 1950
2940 DX=DX-FNA(3) : PRINT "CLUMSIER." : ON (1-(DX<1)) GOTO 1950,4910
2945 Q=FNA(4) : IF Q=RC GOTO 2945
2950 RC=Q : PRINT "BECOME A ";R$(RC);"." : GOTO 1950
2955 SX=1-SX : PRINT "TURN INTO A "; : IF SX=0 THEN PRINT "FE";
2960 PRINT "MALE ";R$(RC);"!" : GOTO 1950
2965 IF L(FND(Z)) <> 6 GOTO 2985
2970 PRINT
2975 PRINT "YOU OPEN THE CHEST AND"
2980 GOTO 3115
2985 IF L(FND(Z)) <> 12 GOTO 3005
2990 PRINT
2995 PRINT "YOU OPEN THE BOOK AND"
3000 GOTO 3020
3005 PRINT
3010 PRINT "** THE ONLY THING OPENED WAS YOUR BIG MOUTH!"
3015 GOTO 1950
3020 ON FNA(6) GOTO 3025,3040,3050,3060,3075,3090
3025 PRINT "FLASH! OH NO! YOU ARE NOW A BLIND ";R$(RC);"!"
3030 BL=1
3035 GOTO 3105
3040 PRINT "IT'S ANOTHER VOLUME OF ZOT'S POETRY! - YECH!!"
3045 GOTO 3105
3050 PRINT "IT'S AN OLD COPY OF PLAY";R$(FNA(4));"!"
3055 GOTO 3105
3060 PRINT "IT'S A MANUAL OF DEXTERITY!"
3065 DX=18
3070 GOTO 3105
3075 PRINT "IT'S A MANUAL OF STRENGTH!"
3080 ST=18
3085 GOTO 3105
3090 PRINT "THE BOOK STICKS TO YOUR HANDS -"
3095 PRINT "NOW YOU ARE UNABLE TO DRAW YOUR WEAPON!"
3100 BF=1
3105 L(FND(Z))=1
3110 GOTO 1950
3115 ON FNA(4) GOTO 3120,3140,3160,3140
3120 PRINT "KABOOM! IT EXPLODES!!"
3125 Q=FNA(6)
3130 GOSUB 4860
3135 ON (1-(ST<1)) GOTO 3105,4910
3140 Q=FNA(1000)
3145 PRINT "FIND";Q;"GOLD PIECES!"
3150 GP=GP+Q
3155 GOTO 3105
3160 PRINT "GAS!! YOU STAGGER FROM THE ROOM!"
3165 L(FND(Z))=1
3170 T=T+20
3175 O$=MID$("NSEW",FNA(4),1)
3180 GOTO 2440
3185 IF L(FND(Z))=11 GOTO 3205
3190 PRINT
3195 PRINT "** IT'S HARD TO GAZE WITHOUT AN ORB!"
3200 GOTO 1950
3205 PRINT
3210 PRINT "YOU SEE ";
3215 ON FNA(6) GOTO 3220,3230,3240,3250,3285,3305
3220 PRINT "YOURSELF IN A BLOODY HEAP!"
3225 ST=ST-FNA(2) : ON (1-(ST<1)) GOTO 1950,4910
3230 PRINT "YOURSELF DRINKING FROM A POOL AND BECOMING ";C$(12+FNA(13));"!"
3235 GOTO 1950
3240 PRINT C$(12+FNA(13));" GAZING BACK AT YOU!"
3245 GOTO 1950
3250 A=X : B=Y : C=Z
3255 X=FNA(8) : Y=FNA(8) : Z=FNA(8)
3260 Q=FNE(L(FND(Z)))
3265 L(FND(Z))=Q
3270 PRINT C$(Q);" AT (";X;",";Y;") LEVEL";Z;"."
3275 X=A : Y=B : Z=C
3280 GOTO 1950
3285 A=FNA(8) : B=FNA(8) : C=FNA(8)
3290 IF FNA(8) < 4 THEN A=O(1) : B=O(2) : C=O(3)
3295 PRINT "***THE ORB OF ZOT*** AT (";A;",";B;") LEVEL";C;"!"
3300 GOTO 1950
3305 PRINT "A SOAP OPERA RERUN!"
3310 GOTO 1950
3315 IF RF <> 0 GOTO 3335
3320 PRINT
3325 PRINT "** YOU CAN'T TELEPORT WITHOUT THE RUNESTAFF!"
3330 GOTO 1950
3335 Z$="X-COORDINATE"
3340 GOSUB 5485
3345 X=Q
3350 Z$="Y-COORDINATE"
3355 GOSUB 5485
3360 Y=Q
3365 Z$="Z-COORDINATE"
3370 GOSUB 5485
3375 Z=Q
3380 O$="T"
3385 GOTO 3450
3390 PRINT
3395 PRINT "DO YOU REALLY WANT TO QUIT NOW";
3400 GOSUB 5415
3405 PRINT
3410 IF O$="Y" GOTO 3425
3415 PRINT "** THEN DON'T SAY THAT YOU DO!"
3420 GOTO 1950
3425 PRINT
3430 GOTO 5030
3435 REM
3440 REM   DISPLAY STATUS INFORMATION
3445 REM
3450 PRINT
3455 IF BL=0 THEN GOSUB 5570 : PRINT
3460 PRINT "STRENGTH =";ST;" INTELLIGENCE =";IQ;" DEXTERITY =";DX
3465 PRINT "TREASURES =";TC;" FLARES =";FL;" GOLD PIECES =";GP
3470 PRINT "WEAPON = ";W$(WV+1);"  ARMOR = ";W$(AV+5);
3475 IF LF=1 THEN PRINT "  AND A LAMP";
3480 PRINT
3485 WC=0
3490 Q=FNE(L(FND(Z)))
3495 L(FND(Z))=Q
3500 Z$="YOU NOW HAVE"
3505 PRINT
3510 PRINT "HERE YOU FIND ";C$(Q);"."
3515 IF (Q<7) OR (Q=11) OR (Q=12) GOTO 1950
3520 IF Q=7 THEN GP=GP+FNA(10) : PRINT Z$;GP;"." : GOTO 3105
3525 IF Q=8 THEN FL=FL+FNA(5) : PRINT Z$;FL;"." : GOTO 3105
3530 IF Q > 9 GOTO 3545
3535 IF (O(1)=X) AND (O(2)=Y) AND (O(3)=Z) THEN ON (1-(O$="T")) GOTO 2440,5175
3540 X=FNA(8) : Y=FNA(8) : Z=FNA(8) : GOTO 3450
3545 IF Q=10 THEN Z=FNB(Z+1) : GOTO 3450
3550 IF Q <= 25 OR Q >= 34 GOTO 3580
3555 PRINT
3560 PRINT "IT'S NOW YOURS!"
3565 T(Q-25)=1
3570 TC=TC+1
3575 GOTO 3105
3580 A=L(FND(Z))-12
3585 WC=0
3590 IF (A<13) OR (VF=1) GOTO 4185
3595 PRINT
3600 PRINT "YOU MAY TRADE WITH, ATTACK, OR IGNORE THE VENDOR."
3605 GOSUB 5405
3610 IF O$="I" GOTO 1950
3615 IF O$ <> "A" GOTO 3640
3620 VF=1
3625 PRINT
3630 PRINT "YOU'LL BE SORRY THAT YOU DID THAT!"
3635 GOTO 4185
3640 IF O$="T" GOTO 3660
3645 PRINT
3650 PRINT "** NICE SHOT, ";R$(RC);"!"
3655 GOTO 3595
3660 FOR Q=1 TO 8
3665 A=FNA(Q*1500)
3670 IF T(Q)=0 GOTO 3700
3675 PRINT
3680 PRINT "DO YOU WANT TO SELL ";C$(Q+25);" FOR";A;"GP'S";
3685 GOSUB 5415
3690 IF O$="Y" THEN TC=TC-1 : T(Q)=0 : GP=GP+A : GOTO 3700
3695 IF O$ <> "N" THEN PRINT Y$ : GOTO 3675
3700 NEXT Q
3705 IF GP >= 1000 GOTO 3725
3710 PRINT
3715 PRINT "YOU'RE TOO POOR TO TRADE, ";R$(RC);"."
3720 GOTO 1950
3725 IF GP < 1250 GOTO 3975
3730 PRINT
3735 PRINT "OK, ";R$(RC);", YOU HAVE";GP;"GP'S AND ";W$(AV+5);" ARMOR."
3740 PRINT
3745 Z$="ARMOR"
3750 GOSUB 5555
3755 PRINT "NOTHING<0> LEATHER<1250> ";
3760 IF GP > 1499 THEN PRINT "CHAINMAIL<1500> ";
3765 IF GP > 1999 THEN PRINT "PLATE<2000>";
3770 PRINT
3775 GOSUB 5405
3780 PRINT
3785 IF O$="N" GOTO 3850
3790 IF O$="L" THEN GP=GP-1250 : AV=1 : AH=7 : GOTO 3850
3795 IF O$ <> "C" OR GP >= 1500 GOTO 3810
3800 PRINT "** YOU HAVEN'T GOT THAT MUCH CASH ON HAND!"
3805 GOTO 3740
3810 IF O$="C" THEN GP=GP-1500 : AV=2 : AH=14 : GOTO 3850
3815 IF O$ <> "P" OR GP >= 2000 GOTO 3830
3820 PRINT "** YOU CAN'T AFFORD PLATE ARMOR!"
3825 GOTO 3740
3830 IF O$="P" THEN GP=GP-2000 : AV=3 : AH=21 : GOTO 3850
3835 PRINT
3840 PRINT "** DON'T BE SILLY. CHOOSE A SELECTION."
3845 GOTO 3770
3850 IF GP < 1250 GOTO 3975
3855 PRINT
3860 PRINT "YOU HAVE";GP;"GP'S LEFT WITH ";W$(WV+1);" IN HAND."
3865 PRINT
3870 Z$="WEAPON"
3875 GOSUB 5555
3880 PRINT "NOTHING<0> DAGGER<1250> ";
3885 IF GP > 1499 THEN PRINT "MACE<1500> ";
3890 IF GP > 1999 THEN PRINT "SWORD<2000>";
3895 PRINT
3900 GOSUB 5405
3905 PRINT
3910 IF O$="N" GOTO 3975
3915 IF O$="D" THEN GP=GP-1250 : WV=1 : GOTO 3975
3920 IF O$ <> "M" OR GP >= 1500 GOTO 3935
3925 PRINT "** SORRY SIR, I'M AFRAID I DON'T GIVE CREDIT!"
3930 GOTO 3865
3935 IF O$="M" THEN GP=GP-1500 : WV=2 : GOTO 3975
3940 IF O$ <> "S" OR GP >= 2000 GOTO 3960
3945 PRINT "** YOUR DUNGEON EXPRESS CARD - ";
3950 PRINT "YOU LEFT HOME WITHOUT IT!"
3955 GOTO 3865
3960 IF O$="S" THEN GP=GP-2000 : WV=3 : GOTO 3975
3965 PRINT "** TRY CHOOSING A SELECTION!"
3970 GOTO 3895
3975 IF GP < 1000 GOTO 1950
3980 Z$="STRENGTH"
3985 GOSUB 5525
3990 IF O$ <> "Y" GOTO 4020
3995 GP=GP-1000
4000 ST=FNC(ST+FNA(6))
4005 Q=ST
4010 GOSUB 5540
4015 GOTO 3975
4020 IF O$ <> "N" THEN PRINT Y$ : GOTO 3980
4025 IF GP < 1000 GOTO 1950
4030 Z$="INTELLIGENCE"
4035 GOSUB 5525
4040 IF O$ <> "Y" GOTO 4070
4045 GP=GP-1000
4050 IQ=FNC(IQ+FNA(6))
4055 Q=IQ
4060 GOSUB 5540
4065 GOTO 4025
4070 IF O$ <> "N" THEN PRINT Y$ : GOTO 4030
4075 IF GP < 1000 GOTO 1950
4080 Z$="DEXTERITY"
4085 GOSUB 5525
4090 IF O$ <> "Y" GOTO 4120
4095 GP=GP-1000
4100 DX=FNC(DX+FNA(6))
4105 Q=DX
4110 GOSUB 5540
4115 GOTO 4075
4120 IF O$ <> "N" THEN PRINT Y$ : GOTO 4080
4125 IF (GP<1000) OR (LF=1) GOTO 1950
4130 PRINT
4135 PRINT "DO YOU WANT TO BUY A LAMP FOR 1000 GP'S";
4140 GOSUB 5415
4145 IF O$ <> "Y" GOTO 4175
4150 GP=GP-1000
4155 LF=1
4160 PRINT
4165 PRINT "IT'S GUARANTEED TO OUTLIVE YOU!"
4170 GOTO 1950
4175 IF O$ <> "N" THEN PRINT Y$ : GOTO 4130
4180 GOTO 1950
4185 Q1=1+INT(A/2) : Q2=A+2 : Q3=1
4190 IF (C(1,4)>T(1)) OR (BL=1) OR (DX<FNA(9)+FNA(9)) GOTO 4700
4195 PRINT
4200 PRINT "YOU'RE FACING ";C$(A+12);"!"
4205 PRINT
4210 PRINT "YOU MAY ATTACK OR RETREAT."
4215 IF Q3=1 THEN PRINT "YOU CAN ALSO ATTEMPT A BRIBE."
4220 IF IQ > 14 THEN PRINT "YOU CAN ALSO CAST A SPELL."
4225 PRINT
4230 PRINT "YOUR STRENGTH IS";ST;"AND YOUR DEXTERITY IS";DX;"."
4235 GOSUB 5405
4240 IF O$ <> "A" GOTO 4445
4245 IF WV <> 0 GOTO 4265
4250 PRINT
4255 PRINT "** POUNDING ON ";C$(A+12);" WON'T HURT IT!"
4260 GOTO 4700
4265 IF BF <> 1 GOTO 4285
4270 PRINT
4275 PRINT "** YOU CAN'T BEAT IT TO DEATH WITH A BOOK!"
4280 GOTO 4700
4285 IF DX >= FNA(20)+(3*BL) GOTO 4305
4290 PRINT
4295 PRINT "YOU MISSED, TOO BAD!"
4300 GOTO 4700
4305 Z$=RIGHT$(C$(A+12),LEN(C$(A+12))-2)
4310 IF LEFT$(Z$,1)=" " THEN Z$=MID$(Z$,2)
4315 PRINT
4320 PRINT "YOU HIT THE EVIL ";Z$;"!"
4325 Q2=Q2-WV
4330 IF (A <> 9 AND A <> 12) GOTO 4355
4335 IF FNA(8) <> 1 GOTO 4355
4340 PRINT
4345 PRINT "OH NO! YOUR ";W$(WV+1);" BROKE!"
4350 WV=0
4355 IF Q2 > 0 GOTO 4700
4360 PRINT
4365 MC=MC-1
4370 PRINT C$(A+12);" LIES DEAD AT YOUR FEET!"
4375 IF H > T-60 GOTO 4395
4380 PRINT
4385 PRINT "YOU SPEND AN HOUR EATING ";C$(A+12);E$(FNA(8));"."
4390 H=T
4395 IF X <> R(1) OR Y <> R(2) OR Z <> R(3) THEN ON (1-(A=13)) GOTO 4420,5305
4400 PRINT
4405 PRINT "GREAT ZOT! YOU'VE FOUND THE RUNESTAFF!";CHR$(7)
4410 R(1)=0
4415 RF=1
4420 Q=FNA(1000)
4425 PRINT
4430 PRINT "YOU NOW GET HIS HOARD OF";Q;"GP'S!"
4435 GP=GP+Q
4440 GOTO 3105
4445 IF O$="R" GOTO 4700
4450 IF O$ <> "C" GOTO 4595
4455 IF IQ >= 15 OR Q3 <= 1 GOTO 4475
4460 PRINT
4465 PRINT "** YOU CAN'T CAST A SPELL NOW!"
4470 GOTO 4195
4475 PRINT
4480 PRINT "WHICH SPELL (WEB, FIREBALL, DEATHSPELL)";
4485 GOSUB 5415
4490 PRINT
4495 IF O$ <> "W" GOTO 4515
4500 ST=ST-1
4505 WC=FNA(8)+1
4510 ON (1-(ST<1)) GOTO 4700,4910
4515 IF O$ <> "F" GOTO 4560
4520 Q=FNA(7)+FNA(7)
4525 ST=ST-1
4530 IQ=IQ-1
4535 IF (IQ < 1) OR (ST < 1) GOTO 4910
4540 PRINT "IT DOES";Q;"POINTS WORTH OF DAMAGE."
4545 PRINT
4550 Q2=Q2-Q
4555 GOTO 4355
4560 IF O$="D" GOTO 4580
4565 PRINT
4570 PRINT "** TRY ONE OF THE OPTIONS GIVEN."
4575 GOTO 4195
4580 PRINT "DEATH . . . ";
4585 IF IQ < FNA(4)+15 THEN PRINT "YOURS!" : IQ=0 : GOTO 4910
4590 PRINT "HIS!" : Q2=0 : GOTO 4360
4595 IF O$="B" AND Q3 <= 1 GOTO 4615
4600 PRINT
4605 PRINT "** CHOOSE ONE OF THE OPTIONS LISTED."
4610 GOTO 4195
4615 IF TC <> 0 GOTO 4635
4620 PRINT
4625 PRINT "ALL I WANT IS YOUR LIFE!"
4630 GOTO 4700
4635 Q=FNA(8)
4640 IF T(Q)=0 GOTO 4635
4645 PRINT
4650 PRINT "I WANT ";C$(Q+25);". WILL YOU GIVE IT TO ME";
4655 GOSUB 5415
4660 IF O$="N" GOTO 4700
4665 IF O$ <> "Y" THEN PRINT Y$ : GOTO 4645
4670 T(Q)=0
4675 TC=TC-1
4680 PRINT
4685 PRINT "OK, JUST DON'T TELL ANYONE ELSE."
4690 VF=VF+(L(FND(Z))=25)
4695 GOTO 1950
4700 Q3=2
4705 IF WC <= 0 GOTO 4720
4710 WC=WC-1
4715 IF WC=0 THEN PRINT : PRINT "THE WEB JUST BROKE!"
4720 Z$=RIGHT$(C$(A+12),LEN(C$(A+12))-2)
4725 IF LEFT$(Z$,1)=" " THEN Z$=MID$(Z$,2)
4730 IF WC <= 0 GOTO 4750
4735 PRINT
4740 PRINT "THE ";Z$;" IS STUCK AND CAN'T ATTACK NOW!"
4745 GOTO 4805
4750 PRINT
4755 PRINT "THE ";Z$;" ATTACKS!"
4760 IF DX < FNA(7)+FNA(7)+FNA(7)+3*BL GOTO 4780
4765 PRINT
4770 PRINT "WHAT LUCK, HE MISSED YOU!"
4775 GOTO 4805
4780 PRINT
4785 PRINT "OUCH! HE HIT YOU!"
4790 Q=Q1
4795 GOSUB 4860
4800 IF ST < 1 GOTO 4910
4805 IF O$ <> "R" GOTO 4195
4810 PRINT
4815 PRINT "YOU HAVE ESCAPED!"
4820 PRINT
4825 PRINT "DO YOU WANT TO GO NORTH, SOUTH, EAST, OR WEST";
4830 GOSUB 5415
4835 IF O$="N" OR O$="S" OR O$="E" OR O$="W" GOTO 2440
4840 PRINT
4845 PRINT "** DON'T PRESS YOUR LUCK, ";R$(RC);"!"
4850 PRINT
4855 GOTO 4825
4860 IF AV=0 GOTO 4900
4865 Q=Q-AV
4870 AH=AH-AV
4875 IF Q < 0 THEN AH=AH-Q : Q=0
4880 IF AH >= 0 GOTO 4900
4885 AH=0 : AV=0
4890 PRINT
4895 PRINT "YOUR ARMOR HAS BEEN DESTROYED . . . GOOD LUCK!"
4900 ST=ST-Q
4905 RETURN
4910 PRINT CHR$(7)
4915 GOSUB 5375
4920 PRINT "A NOBLE EFFORT, OH FORMERLY LIVING ";R$(RC);"!"
4925 PRINT
4930 PRINT "YOU DIED DUE TO LACK OF ";
4935 IF ST < 1 THEN PRINT "STRENGTH."
4940 IF IQ < 1 THEN PRINT "INTELLIGENCE."
4945 IF DX < 1 THEN PRINT "DEXTERITY."
4950 PRINT
4955 Q3=1
4960 PRINT "AT THE TIME YOU DIED, YOU HAD :"
4965 GOTO 5055
4970 Q3=0
4975 PRINT
4980 PRINT "YOU LEFT THE CASTLE WITH";
4985 IF OF=0 THEN PRINT "OUT";
4990 PRINT " THE ORB OF ZOT."
4995 PRINT
5000 IF OF=0 GOTO 5030
5005 PRINT
5010 PRINT "AN INCREDIBLY GLORIOUS VICTORY!!"
5015 PRINT
5020 PRINT "IN ADDITION, YOU GOT OUT WITH THE FOLLOWING :"
5025 GOTO 5050
5030 PRINT
5035 PRINT "A LESS THAN AWE-INSPIRING DEFEAT."
5040 PRINT
5045 PRINT "WHEN YOU LEFT THE CASTLE, YOU HAD :"
5050 IF Q3=0 THEN PRINT "YOUR MISERABLE LIFE!"
5055 FOR Q=1 TO 8
5060 IF T(Q)=1 THEN PRINT C$(Q+25)
5065 NEXT Q
5070 PRINT W$(WV+1);" AND ";W$(AV+5);
5075 IF LF=1 THEN PRINT " AND A LAMP";
5080 PRINT
5085 PRINT "YOU ALSO HAD";FL;"FLARES AND";GP;"GOLD PIECES"
5090 IF RF=1 THEN PRINT "AND THE RUNESTAFF"
5095 PRINT
5100 PRINT "AND IT TOOK YOU";T;"TURNS!"
5105 PRINT
5110 PRINT "ARE YOU FOOLISH ENOUGH TO WANT TO PLAY AGAIN";
5115 GOSUB 5415
5120 PRINT
5125 IF O$ <> "Y" GOTO 5155
5130 PRINT "SOME ";R$(RC);"S NEVER LEARN!"
5135 PRINT
5140 PRINT "PLEASE BE PATIENT WHILE THE CASTLE IS RESTOCKED."
5145 PRINT
5150 GOTO 1105
5155 IF O$ <> "N" THEN PRINT Y$ : GOTO 5110
5160 PRINT "MAYBE DUMB ";R$(RC);" IS NOT SO DUMB AFTER ALL!"
5165 PRINT
5170 GOTO 5580
5175 PRINT
5180 PRINT "GREAT UNMITIGATED ZOT!"
5185 PRINT
5190 PRINT "YOU JUST FOUND ***THE ORB OF ZOT***!"
5195 PRINT
5200 PRINT "THE RUNESTAFF HAS DISAPPEARED!"
5205 RF=0
5210 OF=1
5215 O(1)=0
5220 GOTO 3105
5225 DATA AN EMPTY ROOM,.,THE ENTRANCE,E,STAIRS GOING UP,U
5230 DATA STAIRS GOING DOWN,D,A POOL,P,A CHEST,C,GOLD PIECES,G
5235 DATA FLARES,F,A WARP,W,A SINKHOLE,S,A CRYSTAL ORB,O
5240 DATA A BOOK,B,A KOBOLD,M,AN ORC,M,A WOLF,M,A GOBLIN,M,AN OGRE,M
5245 DATA A TROLL,M,A BEAR,M,A MINOTAUR,M,A GARGOYLE,M,A CHIMERA,M
5250 DATA A BALROG,M,A DRAGON,M,A VENDOR,V,THE RUBY RED,T
5255 DATA THE NORN STONE,T,THE PALE PEARL,T,THE OPAL EYE,T
5260 DATA THE GREEN GEM,T,THE BLUE FLAME,T,THE PALANTIR,T,THE SILMARIL,T
5265 DATA X,"?",NO WEAPON," SANDWICH"
5270 DATA DAGGER," STEW",MACE," SOUP",SWORD," BURGER",NO ARMOR," ROAST"
5275 DATA LEATHER," FILET",CHAINMAIL," TACO",PLATE," PIE"
5280 DATA HOBBIT,ELF,MAN,DWARF
5285 X=FNA(8) : Y=FNA(8)
5290 IF L(FND(Z)) <> 101 GOTO 5285
5295 L(FND(Z))=Q
5300 RETURN
5305 PRINT
5310 PRINT "YOU GET ALL HIS WARES :"
5315 PRINT "PLATE ARMOR"
5320 AV=3 : AH=21
5325 PRINT "A SWORD"
5330 WV=3
5335 PRINT "A STRENGTH POTION"
5340 ST=FNC(ST+FNA(6))
5345 PRINT "AN INTELLIGENCE POTION"
5350 IQ=FNC(IQ+FNA(6))
5355 PRINT "A DEXTERITY POTION"
5360 DX=FNC(DX+FNA(6))
5365 IF LF=0 THEN PRINT "A LAMP" : LF=1
5370 GOTO 4420
5375 FOR Q=1 TO 64
5380 PRINT "*";
5385 NEXT Q
5390 PRINT
5395 PRINT
5400 RETURN
5405 PRINT
5410 PRINT "YOUR CHOICE";
5415 INPUT O$
5420 O$=LEFT$(O$,1)
5425 RETURN
5430 PRINT "HOW MANY POINTS DO YOU WISH TO ADD TO YOUR ";Z$;
5435 INPUT O$
5440 PRINT
5445 Q=VAL(O$)
5450 IF Q=0 AND ASC(O$) <> 48 THEN Q=-1
5455 IF Q<0 OR Q>OT OR Q<>INT(Q) THEN PRINT "** "; : GOTO 5430
5460 OT=OT-Q
5465 RETURN
5470 INPUT O$
5475 Q=INT(VAL(O$))
5480 RETURN
5485 PRINT
5490 PRINT Z$;
5495 INPUT O$
5500 Q=INT(VAL(O$))
5505 IF Q > 0 AND Q < 9 THEN RETURN
5510 PRINT
5515 PRINT "** TRY A NUMBER FROM 1 TO 8."
5520 GOTO 5485
5525 PRINT
5530 PRINT "DO YOU WANT TO BUY A POTION OF ";Z$;" FOR 1000 GP'S";
5535 GOTO 5415
5540 PRINT
5545 PRINT "YOUR ";Z$;" IS NOW";Q;"."
5550 RETURN
5555 PRINT
5560 PRINT "THESE ARE THE TYPES OF ";Z$;" YOU CAN BUY :"
5565 RETURN
5570 PRINT "YOU ARE AT (";X;",";Y;") LEVEL";Z;"."
5575 RETURN
5580 END