DECLARE SUB Main ()
' Eamon Adventure #1  -> The Beginners Cave <-
' By Donald Brown (bless his soul)
' Converted to MBASIC by Jon Walker,139 S. Central Ave
' Marshfield, WI, 54449 (no Lithuanian currency please!)
'
' (Fixed to run under QBASIC by Frank Black, 2/97)
'
RANDOMIZE VAL(RIGHT$(TIME$, 2))
DEF FND$ (x$) = MID$(x$, INSTR(x$, ".") + 1) + CHR$(10) + CHR$(13)
CLS : LOCATE 10
PRINT "         Please wait a short while (Waking up the Monsters)"
'
'  /// Initialize the program!!!
'
DIM SHARED na, nm, nr, hd, ag, ch, ea, ac, ae, nc, c, spd, die
DIM SHARED wa(5), sex$, gold, bank, wn$(20), wt(20), wo(20), wd(20), ws(20)
DIM SHARED cname, sa(4), s2(4), fd(3), td(3), r1$, r2$, r3$

22010 OPEN "I", #1, "EAMON.ART"
22011 INPUT #1, na
22012 DIM SHARED a$(na + 4), a(na + 4, 8)
22013 FOR a = 1 TO na: INPUT #1, a$(a)
22014 FOR a2 = 1 TO 4: INPUT #1, a(a, a2)
22015 NEXT a2: IF a(a, 2) > 1 THEN FOR a2 = 5 TO 8: INPUT #1, a(a, a2): NEXT a2
22016 NEXT: CLOSE #1
'
22020 OPEN "I", #1, "EAMON.MON"
22021 INPUT #1, nm: DIM SHARED m$(nm), m(nm, 15)
22022 FOR a = 1 TO nm: INPUT #1, m$(a)
22023 FOR a2 = 1 TO 12: INPUT #1, m(a, a2)
22024 NEXT: NEXT
22025 CLOSE #1
'
22028 ON ERROR GOTO 24000
22029 a$ = "FRESHMEA.T"
22030 OPEN "I", #1, a$
22031 a$ = "": INPUT #1, rec
22035 LINE INPUT #1, b$: GOSUB 30000
22036 CLOSE #1
ON ERROR GOTO 0
22037 m$(0) = cname$: m(0, 1) = hd: m(0, 2) = ag
'
22040 OPEN "R", #1, "EAMON.ROM", 64
22041 FIELD 1, 64 AS R5$
22045 GET #1, 1: nr = VAL(R5$)
22050 DIM SHARED map(nr, 6), room
22051 FOR room = 1 TO nr
22052 GOSUB 25000
22053 NEXT
22054 CLOSE #1
'
22060 OPEN "R", #2, "ROOM.NAM", 32
22061 FIELD 2, 32 AS r2$
22062 OPEN "R", #1, "EAMON.DES", 255
22063 FIELD 1, 255 AS r1$
22064 OPEN "R", #3, "EAMON.EFF", 255
22065 FIELD 3, 255 AS r3$
'
22070 CLS
PRINT "You have no trouble finding a horse that you, well, borrowed to take you"
PRINT "on your first adventure.  You follow several signs to take you to"
PRINT "the beginners cave."
PRINT
22073 GET #2, 1: PRINT : PRINT r1$: PRINT
PRINT "As you stand there, you see the local Knight Marshal come out to"
PRINT "inspect you before you may enter the Beginners Cave."
PRINT
22090 IF wn$(1) = "NONE" THEN PRINT "He shakes his head and says, 'You must have at least one weapon to adventure": PRINT "here!  Go back to the Main Hall.'": GOTO 23010
'22100 IF ae <> 0 OR wa(1) <> 5 OR wa(3) <> 20 OR wa(5) <> 0 THEN PRINT "He shakes his head and says, 'You are not a beginner! You cannot adventure": PRINT "here!  Go back to the Main Hall.'": GOTO 23010
'22110 IF wn$(2) = "NONE" THEN w2 = 1: GOTO 22160
'22120 PRINT "He tells you, 'You may only take one weapon into the cave. Which shall": PRINT "it be?'"
'22121 PRINT : FOR w = 1 TO 4: IF wn$(w) <> "NONE" THEN PRINT w; "   "; wn$(w): NEXT w
'22130 PRINT : PRINT "(Hit 1 -"; w; ")   ";
'22140 a$ = INKEY$: IF a$ = "" THEN 22140 ELSE w2 = VAL(a$): IF w2 < 1 OR w2 > w - 1 THEN 22140
'22150 PRINT a$: PRINT
'
w2 = 0
FOR w = 1 TO 4
   IF wn$(w) <> "NONE" THEN
     na = na + 1: a$(na) = wn$(w): a(na, 2) = 2: a(na, 3) = 2
     a(na, 4) = -1: a(na, 5) = wo(w): a(na, 6) = wt(w)
     a(na, 7) = wd(w): a(na, 8) = ws(w)
     IF w2 = 0 THEN w2 = w: w3 = na
   END IF
NEXT
22170 ea = 0: m(0, 8) = 0: a2 = INT(ac / 2): IF a2 * 2 <> ac THEN m(0, 8) = 1: ea = -5
22180 IF a2 <> 0 THEN m(0, 8) = m(0, 8) + a2: ea = ea - a2 * 10: IF a2 = 3 THEN m(0, 8) = m(0, 8) + 2: ea = ea - 30
22190 m(0, 10) = (ea + ae) * ABS(-ea > ae) + wo(w2) + wa(wt(w2)) + 2 * m(0, 2): m(0, 7) = 0: m(0, 9) = w3: m(0, 11) = wd(w2): m(0, 12) = ws(w2)
22200 TP = TP + a(a, 1)
22210 READ nc: DIM SHARED c$(nc): FOR c = 1 TO nc: READ c$(c): NEXT c
22220 FOR S = 1 TO 4: s2(S) = sa(S): NEXT S
22230 DIM SHARED V(26): room = 1
22235 FOR a = 1 TO na - 1: IF a$(na) = a$(a) THEN a$(a) = a$(a) + "#": GOTO 22235
22236 NEXT a
22240 PRINT : PRINT "Eventually the Knight Marshal says, 'You may now proceed'"
22241 PRINT "and he walkes away.": PRINT : PRINT "(Hit any key to continue)  ";
22242 a$ = INKEY$: IF a$ = "" THEN 22242
22243 PRINT : PRINT : CALL Main: GOTO 23010
22250 DATA 36
DATA GET,PICK,DROP,ATTACK,LOOK,EXAMINE,UP,U,DOWN,D,NORTH,N,EAST,E
DATA WEST,W,SOUTH,S,POWER,HEAL,BLAST,SPEED,SMILE,WAVE,SAY,DRINK,READ
DATA READY,ESCAPE,RETREAT,FLEE,INVENTORY,I,ENTER,TROLLSFIRE,OPEN
'---------------------------------------------------------------------------
' End of game
'
23010 PRINT : PRINT "(Hit any key to continue)  ";
23011 a$ = INKEY$: IF a$ = "" THEN 23011 ELSE PRINT
23020 CLOSE #1: CLOSE #2: CLOSE #3
23030 a(10, 8) = 10
23040 IF spd THEN m(0, 2) = m(0, 2) / 2
23050 IF die THEN 23240
23060 FOR f = 2 TO 4
         IF wn$(f) = "NONE" THEN w = f
      NEXT
23070 w2 = 1
FOR w3 = 1 TO na
   IF a(w3, 2) > 1 AND a(w3, 4) = -1 THEN
     wn$(w2) = a$(w3): WP(w2) = w3: w2 = w2 + 1: a(w3, 4) = 0
   END IF
NEXT: IF w2 < 6 THEN 23160
23090 CLS : PRINT : PRINT : PRINT : PRINT : PRINT "As you try to leave, the Knight Marshall reappears and": PRINT "tells you, 'You have too many weapons-- 4 is the leagal limit.'": PRINT : PRINT "Your weapons are---"
23100 FOR W4 = 1 TO w2 - 1: PRINT "    "; W4; "--"; wn$(W4): NEXT W4: PRINT : PRINT "Hit the number key for one to throw away. ( 1 -"; w2 - 1; ")  ";
23110 a$ = INKEY$: IF a$ = "" THEN 23110 ELSE W5 = VAL(a$): IF W5 < 1 OR W5 > w2 - 1 THEN 23110
23120 IF WP(W5) <> 0 THEN a(WP(W5), 4) = -1
23130 wn$(W5) = wn$(w2 - 1): WP(W5) = WP(w2 - 1): w2 = w2 - 1: IF w2 > 5 THEN 23090
23140 FOR W4 = 2 TO w2 - 1: FOR W5 = 1 TO W4 - 1: IF wn$(W4) = wn$(W5) THEN wn$(W4) = wn$(W4) + "#": GOTO 23140
23150 NEXT W5: NEXT W4
23160 FOR w = 1 TO 4: IF WP(w) <> 0 THEN wt(w) = a(WP(w), 6): wo(w) = a(WP(w), 5): wd(w) = a(WP(w), 7): ws(w) = a(WP(w), 8)
23170 NEXT w: CLS : PRINT : PRINT : PRINT : PRINT : PRINT "As you deliver your treasures to Sam Slicker, the local buyer of such things,": PRINT "he examines your goods and pays you ";
23180 TP = 0: FOR a = 1 TO na - 1: IF a(a, 4) <> -1 THEN 23210
23190 IF a(a, 2) <> 0 THEN a(a, 1) = a(a, 1) * ch / 10
23200 TP = INT(TP + a(a, 1))
23210 NEXT a: PRINT TP; "gold pieces.": PRINT : IF m(9, 5) = 1 THEN PRINT : PRINT "Additionaly, you receive "; 10 * ch; " gold pieces as reward for the": PRINT "safe return of Cynthia.": TP = TP + 10 * ch
23220 gold = gold + TP
23230 PRINT : PRINT : PRINT "(Hit any key to continue)  ";
23231 a$ = INKEY$: IF a$ = "" THEN 23231 ELSE PRINT
23240 REM KILL "FRESHMEAT"
23241 a$ = INKEY$: PRINT : CLS : PRINT : PRINT : PRINT : PRINT : PRINT "(Insert EAMON MASTER diskette, then hit any key"; : IF die THEN PRINT ")  ";  ELSE PRINT " to goto Main Hall)  ";
23242 a$ = INKEY$: IF a$ = "" THEN 23242
23250 ON ERROR GOTO 24000
23251 IF die THEN KILL "ADVENTUR.ER": CHDIR "..":CHDIR "..":RUN "MUSEUM"
23260 OPEN "R", #1, "CHARACTE.RS", 255
23261 GOSUB 30600
23262 FIELD 1, 255 AS r1$
23263 LSET r1$ = a$
23264 PUT #1, rec + 1
23270 CLOSE #1
23290 OPEN "O", #1, "ADVENTUR.ER"
23291 PRINT #1, m$(0): PRINT #1, rec
23292 CLOSE #1
23300 RUN "MAINHALL"
23310 STOP

24000 IF ERR = 53 THEN 24100
24005 PRINT "Error #"; ERR
24010 PRINT "At line"; ERL
24020 PRINT : PRINT "Hit any key to continue"
24030 a$ = INKEY$: IF a$ = "" THEN 24030
24040 RESUME NEXT
24050 STOP
24100 CLS
24110 IF a$ <> "FRESHMEAT" THEN 24005
24120 CLS
24130 PRINT "You must enter this program through the EAMON program and main hall."
24140 PRINT : PRINT : STOP
'
25000 REM /// get room move info
25010 GET #1, room + 1
25020 R$ = R5$
25030 FOR I = 1 TO 6
25040 ML = INSTR(R$, ",")
25045 IF ML = 0 THEN map(room, I) = VAL(R$): R$ = "": GOTO 25070
25050 map(room, I) = VAL(LEFT$(R$, ML - 1))
25060 R$ = MID$(R$, ML + 1)
25070 NEXT
25080 RETURN

'
30000 REM
30010 REM  Break up record into its needed parts
30020 REM  and damned be he the first to screw up this ordered set!!!
30030 REM
30031 REM HINT: a string of 37 commas will clear all fields!
30040 REM
30050 R$ = b$
30060 w = 1: x = 1: Y = 1: IF LEN(R$) = 0 THEN R$ = ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"
30070 FOR I = 1 TO 38
30075 A1$ = ""
30080 IF R$ = "" THEN 30555
30090 J = INSTR(R$, ",")
30095 IF J <> 0 THEN A1$ = LEFT$(R$, J - 1): R$ = MID$(R$, J + 1) ELSE IF R$ <> "" THEN A1$ = R$: R$ = ""
30100 REM
30110 REM
30120 ON I GOTO 30170, 30180, 30190, 30200, 30210, 30210, 30210, 30210, 30250, 30250
30130 ON I - 10 GOTO 30250, 30250, 30250, 30300, 30310, 30320, 30330, 30340, 30350, 30360
30140 ON I - 20 GOTO 30370, 30380, 30390, 30350, 30360, 30370, 30380, 30390, 30350, 30360
30150 ON I - 30 GOTO 30370, 30380, 30390, 30350, 30360, 30370, 30380, 30390
30160 STOP
30170 cname$ = A1$: GOTO 30550
30180 hd = VAL(A1$): GOTO 30550
30190 ag = VAL(A1$): GOTO 30550
30200 ch = VAL(A1$): GOTO 30550
30210 sa(x) = VAL(A1$): x = x + 1: GOTO 30550
30250 wa(Y) = VAL(A1$): Y = Y + 1: GOTO 30550
30300 ae = VAL(A1$): GOTO 30550
30310 sex$ = A1$: GOTO 30550
30320 gold = VAL(A1$): GOTO 30550
30330 bank = VAL(A1$): GOTO 30550
30340 ac = VAL(A1$): GOTO 30550
30350 wn$(w) = A1$: GOTO 30550
30360 wt(w) = VAL(A1$): GOTO 30550
30370 wo(w) = VAL(A1$): GOTO 30550
30380 wd(w) = VAL(A1$): GOTO 30550
30390 ws(w) = VAL(A1$): w = w + 1: GOTO 30550
30550 REM
30555 NEXT I
30560 RETURN
30570 REM
30580 REM   pack the array with commas
30590 REM
30600 a$ = cname$ + "," + STR$(hd) + "," + STR$(ag) + "," + STR$(ch) + ","
30610 FOR I = 1 TO 4: a$ = a$ + STR$(sa(I)) + ",": NEXT I
30620 FOR I = 1 TO 5: a$ = a$ + STR$(wa(I)) + ",": NEXT I
30630 a$ = a$ + STR$(ae) + "," + sex$ + "," + STR$(gold) + "," + STR$(bank) + "," + STR$(ac)
30640 FOR I = 1 TO 4: a$ = a$ + "," + wn$(I) + ","
30650 a$ = a$ + STR$(wt(I)) + "," + STR$(wo(I)) + ","
30660 a$ = a$ + STR$(wd(I)) + "," + STR$(ws(I))
30670 NEXT I
30680 RETURN

SUB Main
100 REM /// give room description if never here, then get command
110 PRINT
115 IF spd > 0 THEN spd = spd - 1: IF spd = 0 THEN m(0, 2) = m(0, 2) / 2: m(0, 10) = m(0, 10) - 2 * m(0, 2)
120 IF V(room) THEN GET #2, room: PRINT "You are standing in "; r2$
125 IF NOT V(room) THEN GET #1, room: PRINT FND$(r1$)
130 FOR m = 1 TO nm: IF m(m, 5) = room AND m(m, 15) <> 0 THEN PRINT m$(m); " is here."
135 IF m(m, 5) = room AND m(m, 15) = 0 THEN GET #3, m + 30: PRINT FND$(r3$): m(m, 15) = 1: IF m = 10 THEN GET #3, 26: PRINT FND$(r3$)
140 NEXT m: FOR a = 1 TO na - 1: IF a(a, 4) = room AND (a < na) AND NOT V(room) THEN GET #3, a: PRINT FND$(r3$)
145 IF a(a, 4) = room AND (a < na) AND V(room) THEN PRINT "You see "; a$(a)
150 NEXT a: IF a(na, 4) = room THEN PRINT "Your "; a$(a); " is here."
155 V(room) = -1
'
160 PRINT
LINE INPUT "   Your command? "; a$: a$ = LTRIM$(RTRIM$(UCASE$(a$)))
163 REM
IF a$ = "" THEN a$ = CZ$: LOCATE CSRLIN - 1, 18: PRINT a$
'
175 PRINT : CZ$ = a$: a = INSTR(2, a$, " ")
180 IF a <> 0 THEN V$ = LEFT$(a$, a - 1): S$ = MID$(a$, a + 1) ELSE V$ = a$: S$ = ""
185 IF LEFT$(S$, 1) = " " THEN S$ = MID$(S$, 2): GOTO 185
190 c = 0
FOR f = 1 TO nc
 IF c$(f) = V$ OR c$(f) = S$ THEN c = f: f = nc
NEXT: IF c > 0 THEN GOTO 195
191 PRINT "Huh? I only understand these commands--"
192 FOR c = 1 TO nc: PRINT c$(c); SPACE$(30 - LEN(c$(c)));
193 IF c / 2 = INT(c / 2) THEN PRINT
194 NEXT c: PRINT : PRINT : GOTO 160
195 IF c$(c) = S$ THEN S$ = V$: V$ = c$(c)
200 ON c GOTO 1000, 1000, 2000, 3000, 4000, 4000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 6000, 7000, 8000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 17000, 17000, 18000, 18000, 19000, 20000, 21000, 28000
'---------------------------------------------------------------------------
' /// Commands return here
'
300 REM ///
310 IF nbtl = 0 THEN 440
320 FOR m = 1 TO nm
      IF m(m, 5) <> room THEN 430
330 MR = fd(m(m, 14)) / td(m(m, 14)) - fd(ABS(m(m, 14) = 0)) / td(ABS(m(m, 14) = 0)) / 5 + INT(41 * RND(1) - 20)
340 IF m(m, 4) < MR THEN PRINT : PRINT m$(m); " flees out an exit.": PRINT : GOSUB 17500: m(m, 5) = r2: td(m(m, 14)) = td(m(m, 14)) - m(m, 1): fd(m(m, 14)) = fd(m(m, 14)) - m(m, 13): GOTO 430
350 IF m(m, 14) <> 0 THEN 390
360 OF = m: IF td(1) = m(0, 1) THEN DF = 0: GOSUB 3500: GOTO 430
370 SKIP = 0: FOR M2 = 1 TO nm: IF m(M2, 5) = room AND (m(M2, 14) <> 0) AND RND(1) < .25 THEN DF = M2: GOSUB 3500: M2 = 200: SKIP = -1
380 NEXT M2: IF SKIP THEN 430 ELSE DF = 0: GOSUB 3500: GOTO 430
390 OF = m
400 SKIP = 0: FOR M2 = 1 TO nm: IF m(M2, 5) = room AND m(M2, 14) = 0 THEN DF = M2: GOSUB 3500: M2 = 200: SKIP = -1
410 NEXT M2: IF SKIP THEN 430 ELSE 400
420 REM
430 nbtl = (fd(0) < td(0)): IF nbtl = 0 THEN m = nm
435 NEXT m
440 REM
450 GOTO 100
460 REM
470 REM
'---------------------------------------------------------------------------
1000 REM /// The GET command
1010 GOSUB 1950
1020 IF S$ = "TORCH" THEN PRINT : PRINT "All torches are bolted to the wall and cannot be removed.": PRINT : GOTO 300
1030 IF S$ = "ALL" THEN 1120
1040 IF S$ <> "RAT" THEN 1070
1050 FOR a = 14 TO 16: IF a(a, 4) = room THEN S$ = a$(a)
1060 NEXT
1070 IF S$ = "GOLD" OR S$ = "COINS" THEN S$ = a$(6)
GOSUB Asearch: IF f = 0 THEN PRINT : PRINT "I see no "; S$; " here!": PRINT : GOTO 100
1090 IF wt + a(a, 3) > 10 * m(0, 1) THEN PRINT : PRINT "It is too heavy for you.": PRINT : GOTO 100
1100 PRINT : PRINT "Got it.": a(a, 4) = -1: wt = wt + a(a, 3): PRINT : IF a(a, 2) < 2 OR m(0, 9) <> -1 THEN 300
1110 GOTO 16000
1120 FOR a = 1 TO na: IF a(a, 4) <> room THEN 1150
1130 IF wt + a(a, 3) > 10 * m(0, 1) THEN PRINT a$(a); " is too heavy.": GOTO 1150
1140 PRINT a$(a); " taken.": a(a, 4) = -1: wt = wt + a(a, 3)
1150 NEXT a: PRINT : GOTO 300
'---------------------------------------------------------------------------
' Check Player input
'
1950 IF S$ = "" THEN PRINT : PRINT c$(c); " what "; : A3$ = a$: INPUT a$: a$ = LTRIM$(RTRIM$(UCASE$(a$))): S$ = a$: a$ = A3$: GOTO 1950
1960 RETURN
'---------------------------------------------------------------------------
2000 REM /// DROP command
2010 GOSUB 1950
2020 IF nbtl THEN PRINT : PRINT "You can't do that with unfrienlies about!": PRINT : GOTO 100
2030 IF S$ = "ALL" THEN 2060
2040 wh = -1: GOSUB Asearch1: IF f = 0 THEN PRINT "You aren't carrying a "; S$; ".": GOTO 100
2050 wt = wt - a(a, 3): PRINT : PRINT "Dropped.": a(a, 4) = room: PRINT : GOTO 300
2060 FOR a = 1 TO na: IF a(a, 4) <> -1 THEN 2080
2070 wt = wt - a(a, 3): a(a, 4) = room: PRINT a$(a); " dropped."
2080 NEXT a: GOTO 300
'---------------------------------------------------------------------------
3000 REM /// ATTACK command
'
3010 GOSUB 1950
3020 IF S$ <> "RAT" THEN 3050
3030 FOR m = 1 TO 3: IF m(m, 5) = room THEN S$ = m$(m)
3040 NEXT m
3050 GOSUB Msearch: IF f = 0 THEN PRINT : PRINT "Attack who?": PRINT : GOTO 100
3060 IF m(0, 9) = -1 THEN PRINT : PRINT "You have no weapon ready!": PRINT : GOTO 100
3070 OF = 0: DF = m: GOSUB 3500: IF NOT HIT THEN 3130
3080 IF INC <> 0 THEN w2 = a(m(0, 9), 6): wa(w2) = wa(w2) + 2
3090 IF -ea <= ae THEN 300
3100 IF INT(100 * RND(1) + 1) <= m(0, 10) THEN 3130
3110 a = 2: IF ea + ae = 1 THEN a = 1
3120 ae = ae + a: m(0, 10) = m(0, 10) + a
3130 IF m(DF, 14) = 0 OR DF = 0 THEN 300
3140 m(DF, 3) = m(DF, 3) / 2: IF nbtl THEN m(DF, 14) = 0: td(0) = td(0) + m(DF, 1): td(1) = td(1) - m(DF, 1): fd(0) = fd(0) + m(DF, 13): fd(1) = fd(1) - m(DF, 13): GOTO 300
3150 r2 = room: m(DF, 14) = 0: GOTO 5100
3500 HIT = 0: IF m(OF, 9) = -1 THEN RETURN
3505 PRINT m$(OF); " attacks "; m$(DF): PRINT " -- ";
3510 RL = INT(100 * RND(1) + 1): HIT = 0: IF RL < 5 OR RL < m(OF, 10) THEN HIT = -1
3515 IF HIT THEN 3600
3520 IF RL < 97 THEN PRINT "a miss.": RETURN
3525 PRINT "a fumble!": FR = INT(100 * RND(1) + 1): IF FR <= 35 + 40 * ABS(m(OF, 9) = 0) THEN PRINT " fumble recovered.": PRINT : RETURN
3530 IF FR < 76 THEN PRINT " weapon dropped!": a(m(OF, 9), 4) = room: m(OF, 9) = -1: PRINT : RETURN
3535 IF FR > 95 THEN 3550
3540 PRINT " weapon broken!": a(m(OF, 9), 4) = 0: m(OF, 9) = -1: IF RND(1) > .9 THEN PRINT : RETURN
3545 PRINT " Broken weapon hurts user!"
3550 IF FR = 100 THEN 3560
3555 d = m(OF, 11): S = m(OF, 12): DF = OF: a = 1: GOTO 3650
3560 d = m(OF, 11) * 2: S = m(OF, 12): DF = OF: a = 0: GOTO 3650
3600 INC = INT(100 * RND(1) + 1) > m(OF, 10): m(OF, 10) = m(OF, 10) + 2 * (-INC)
3605 d = m(OF, 11): S = m(OF, 12): a = 1: IF RL > 5 THEN PRINT "a hit!": GOTO 3650
3610 PRINT "a critical hit!": r2 = INT(100 * RND(1) + 1): IF r2 < 51 THEN a = 0: GOTO 3650
3615 IF r2 < 86 THEN S = 1.5 * S: GOTO 3650
3620 IF r2 < 96 THEN d = 2 * d: GOTO 3650
3625 IF r2 < 100 THEN d = 3 * d: GOTO 3650
3630 GOTO 3700
3650 D2 = 0: FOR D3 = 1 TO d: D2 = D2 + INT(S * RND(1) + 1): NEXT D3: D2 = D2 - a * m(DF, 8): IF D2 < 1 THEN PRINT " blow bounces off armour": PRINT : RETURN
3655 m(DF, 13) = m(DF, 13) + D2: IF m(DF, 13) >= m(DF, 1) THEN 3700
3660 a = m(DF, 14): fd(a) = fd(a) + D2
3665 ON INT(m(DF, 13) * 5 / m(DF, 1) + 1) GOTO 3670, 3675, 3680, 3685, 3690
3670 PRINT : PRINT m$(DF); " takes damage but is still in good shape.": RETURN
3675 PRINT : PRINT m$(DF); " is hurting.": RETURN
3680 PRINT : PRINT m$(DF); " is in pain.": RETURN
3685 PRINT : PRINT m$(DF); " is very badly injured.": RETURN
3690 PRINT : PRINT m$(DF); "is at death's door, knocking loudly.": RETURN
3700 PRINT m$(DF); " is dead!": PRINT
a = m(DF, 14): fd(a) = fd(a) + m(DF, 1) - m(DF, 13) + D2
m(DF, 5) = 0: a2 = 24 - nm + DF: a(a2, 4) = room
IF m(DF, 9) > 0 THEN a(m(DF, 9), 4) = room
3710 IF fd(0) > td(0) THEN nbtl = 0
3720 IF DF = 0 THEN die = -1: GOTO 23000
3730 IF m$(DF) = "PIRATE" THEN GET #3, 27: PRINT FND$(r3$): PRINT : a(11, 8) = 6: V(room) = 0: RETURN
3740 IF m$(DF) = "MIMIC" THEN PRINT : PRINT "As the mimic dies, it rolls over and you find a ring underneath it.": a(7, 4) = room
3750 PRINT : RETURN
3760 REM
4000 REM /// look command
4010 IF nbtl THEN 2020
4020 IF S$ = "LABEL" OR S$ = "BOTTLE" THEN 15000
4030 LK = 0
4040 FOR a = 1 TO na - 1: IF a$(a) = S$ AND (a(a, 4) = room OR a(a, 4) = -1) THEN GET #3, a: PRINT FND$(r3$): LK = -1
4050 NEXT a: IF LK THEN 300
4060 IF room <> 15 THEN V(room) = 0: GOTO 300
4070 PRINT "You found a hidden tunnel going off to the east!": PRINT : GOTO 300
4080 REM
'---------------------------------------------------------------------------
' What Monster?
'
Msearch:
wh = room
Msearch1:
f = 0
FOR m = 1 TO nm
   IF m(m, 5) = wh THEN
     IF S$ = UCASE$(m$(m)) THEN f = m
   END IF
NEXT: m = f: RETURN
'---------------------------------------------------------------------------
' What Artifact?
'
Asearch:
wh = room
Asearch1:
f = 0
FOR a = 1 TO na
   IF a(a, 4) = wh THEN
     IF S$ = UCASE$(a$(a)) THEN f = a
   END IF
NEXT: a = f: RETURN
'---------------------------------------------------------------------------
5000 REM /// movement command
5010 IF nbtl THEN 2020
5020 d = 0
FOR f = 1 TO 6
   IF LEFT$(V$, 1) = MID$("NSEWUD", f, 1) THEN d = f
NEXT
5030 r2 = map(room, d)
5040 IF r2 <> 0 THEN 5100
5050 IF room = 1 AND d = 1 THEN PRINT : PRINT "You successfully ride off into the sunset.": GOTO 23000
5060 PRINT : PRINT "You can't go that way!": V(room) = 0: GOTO 100
5100 r3 = room: room = r2: td(0) = 0: td(1) = m(0, 1): fd(0) = 0: fd(1) = m(0, 13)
5110 FOR m = 1 TO nm: IF m(m, 5) = r3 THEN IF m(m, 14) <> 0 OR 200 * RND(1) < m(m, 4) THEN m(m, 5) = room: GOTO 5150
5120 IF m(m, 5) <> room THEN 5160
5130 FR = m(m, 3): IF FR <> 0 AND FR <> 100 THEN FR = FR + INT((ch - 10) / 2)
5140 m(m, 14) = ABS(FR > 100 * RND(1)): IF m(m, 14) = 0 THEN nbtl = 1
5150 a = m(m, 14): fd(a) = fd(a) + m(m, 13): td(a) = td(a) + m(m, 1)
5160 NEXT m: nbtl = (td(0) > 0)
5170 GOTO 100
6000 REM /// power spell
6010 S = 4: GOSUB 7500: IF NOT SUC THEN 300
6020 RAISE = 0: FOR m = 1 TO nm: M2 = 13 + m: IF a(M2, 4) = room OR a(M2, 4) = -1 THEN RAISE = -1: PRINT m$(m); " come alive!": a(M2, 4) = 0: m(m, 5) = room: m(m, 13) = 0: IF m(m, 9) > 0 THEN a(m(m, 9), 4) = 0: IF m(m, 9) = m(0, 9) THEN m(0, 9) = 0
6030 NEXT m: IF RAISE THEN nbtl = 0: r2 = room: GOTO 5100
6040 FOR a = 1 TO na: IF a(a, 4) = room THEN RAISE = -1: PRINT a$(a); " vanishes!": a(a, 4) = 0
6050 NEXT a: IF RAISE THEN PRINT : GOTO 300
6060 RR = INT(100 * RND(1) + 1): IF RR < 11 THEN PRINT : PRINT "The section of tunnel you are in collapses and you die.": die = 1: GOTO 23000
6070 IF RR < 31 THEN PRINT : PRINT "You are teleported somewhere in the dungeon": PRINT : r2 = INT(26 * RND(1) + 1): nbtl = 0: GOTO 5100
6080 IF RR < 86 THEN PRINT : PRINT "You hear a very loud sonic boom that echoes through the tunnels.": PRINT : GOTO 300
6090 IF RR > 95 THEN PRINT : PRINT "All of your hits are healed.": PRINT : m(0, 13) = 0: GOTO 300
6100 GOTO 10020
7000 REM /// heal spell
7010 S = 2: GOSUB 7500: IF NOT SUC THEN 300
7020 PRINT : IF m(0, 13) <> 0 THEN PRINT "Some of your wounds seem to clear up.": PRINT
7030 m(0, 13) = m(0, 13) - INT(10 * RND(1) + 1): IF m(0, 13) < 0 THEN m(0, 13) = 0
7040 IF m(0, 13) = 0 THEN H2 = 100 ELSE H2 = hd / m(0, 13)
7050 IF H2 > 95 THEN PRINT "You feel great!.": PRINT : GOTO 7100
7060 IF H2 > 66 THEN PRINT "You feel better.": PRINT : GOTO 7100
7070 IF H2 > 33 THEN PRINT "Though you feel better, you are still very,very sick!": PRINT : GOTO 7100
7080 PRINT "Though you feel better, you are still at death's door knocking loudly!": PRINT : GOTO 7100
7090 REM
7100 GOTO 300
7495 REM
7496 REM try out success on spell
7497 REM
7500 SUC = 0: IF sa(S) <> 0 THEN RL = INT(100 * RND(1) + 1): SUC = (((RL <= s2(S)) OR (RL < 5)) AND (RL < 95))
7510 IF NOT SUC THEN PRINT : PRINT "Nothing happened.": RETURN
7520 RL = INT(100 * RND(1) + 1): IF RL > s2(S) THEN s2(S) = s2(S) + 2: sa(S) = sa(S) + 2
7530 s2(S) = s2(S) / 2
7540 RETURN
'---------------------------------------------------------------------------
' /// BLAST spell (alright!!!)
'
8000 REM
8010 GOSUB 1950
8020 GOSUB Msearch: IF f = 0 THEN PRINT : PRINT "You can't blast "; S$; "!": PRINT : GOTO 300
8030 S = 1: GOSUB 7500: IF NOT SUC THEN 300
8040 PRINT : PRINT "Direct hit!": PRINT : S = 5: d = 1: DF = m: m(m, 14) = 0: GOSUB 3650: PRINT : GOTO 300
'---------------------------------------------------------------------------
' /// speed spell
'
10000 REM
10010 S = 3: GOSUB 7500: IF NOT SUC THEN 300
10020 IF spd = 0 THEN m(0, 10) = m(0, 10) + 2 * m(0, 2): m(0, 2) = 2 * m(0, 2)
10030 spd = INT(25 * RND(1) + 1): PRINT : PRINT "You can feel the new agility flowing through you!": PRINT : GOTO 300
'---------------------------------------------------------------------------
' /// smile command
'
11000 REM
11010 PRINT : IF nbtl THEN PRINT "As you smile, the enemy attacks you.": PRINT : GOTO 300
11020 PRINT "Nothing happens.": PRINT : GOTO 300
'---------------------------------------------------------------------------
' /// wave command
'
12000 REM
12010 PRINT : IF nbtl THEN PRINT "As you wave, the enemy attacks you.": PRINT : GOTO 300
12020 PRINT "Nothing happens.": PRINT : GOTO 300
'---------------------------------------------------------------------------
' /// say command
'
13000 REM
13010 GOSUB 1950
13020 IF S$ = "TROLLSFIRE" THEN 20000
13030 IF S$ = "POWER" THEN 6000
13040 IF S$ = "HEAL" THEN 7000
13050 IF S$ = "BLAST" THEN 8000
13060 IF S$ = "SPEED" THEN 10000
13070 PRINT : PRINT "Okay, '"; S$; "'": PRINT : GOTO 300
14000 REM /// drink command
14010 GOSUB 1950
14020 IF nbtl THEN 2020
14030 IF RIGHT$(S$, 6) <> "POTION" AND RIGHT$(S$, 6) <> "BOTTLE" THEN 14500
14040 IF a(4, 4) <> -1 AND a(4, 4) <> room THEN 14500
14050 PRINT : IF m(0, 13) THEN PRINT "Some of your wounds seem to clear up.": PRINT
14060 m(0, 13) = m(0, 13) - INT(10 * RND(1) + 1): IF m(0, 13) < 0 THEN m(0, 13) = 0
14070 IF m(0, 13) = 0 THEN H2 = 100 ELSE H2 = hd / m(0, 13)
14080 IF H2 > 95 THEN PRINT "You feel great!.": PRINT : GOTO 14110
14090 IF H2 > 66 THEN PRINT "You feel better.": PRINT : GOTO 14110
14100 IF H2 > 33 THEN PRINT "Though you feel better, you are still very,very sick!": PRINT : GOTO 14110
14105 PRINT "Though you feel better, you are still at deaths door knocking loudly."
14110 a(4, 4) = 0: a(14, 4) = -1
14130 GOTO 300
14500 IF S$ <> "WATER" OR RIGHT$(S$, 3) <> "SEA" THEN PRINT : PRINT "A job similiar to getting blood from a turnip.": PRINT : GOTO 300
14510 PRINT : PRINT "The water tasted salty, but it doesn't seem to be poisonous.": PRINT : GOTO 300
14520 REM
15000 REM ///read command
15010 GOSUB 1950
15020 IF nbtl THEN 2020
15030 IF S$ = "LABEL" OR S$ = "BOTTLE" THEN IF a(4, 4) = room OR a(14, 4) = room OR a(4, 4) = -1 OR a(14, 4) = -1 THEN PRINT "The bottle says, 'HEALING POTION'": PRINT : GOTO 300
15035 IF S$ = "SIGN" AND room = 1 THEN PRINT "It says:  'Don't forget, Eamon Dungeon Designer diskette will let you make your own dungeons.  Order yours today!'": GOTO 100
15045 IF S$ = "TROLLSFIRE" AND (a(11, 4) = room OR a(11, 4) = -1) THEN PRINT "Among the scroll work is the word 'TROLLSFIRE": PRINT : GOTO 300
15050 IF S$ <> "BOOK" THEN PRINT : PRINT "There are no markings to read!": PRINT : GOTO 300
15060 IF a(10, 4) <> -1 AND a(10, 4) <> room THEN PRINT "What book?": PRINT : GOTO 300
15070 PRINT "As you read the book, you feel a weird sensation overtaking you."
15071 PRINT "You suddenly realize that you are turning into a small fish.": PRINT
15080 IF room = 26 THEN PRINT "You fall into the sea and are promptly eaten by a big fish.": PRINT
15090 IF room < 26 THEN PRINT "You flop three times and die.": PRINT
15100 die = -1: GOTO 23000
15110 REM
'---------------------------------------------------------------------------
' ///ready a weapon
'
16000 REM
16010 GOSUB 1950
16020 wh = -1: GOSUB Asearch1: IF f = 0 THEN PRINT : PRINT "You aren't carrying it!": PRINT : GOTO 100
16030 IF a(a, 2) < 2 THEN PRINT : PRINT "That isn't a weapon!": PRINT : GOTO 100
16040 m(0, 10) = (ea + ae) * ABS(-ea > ae) + a(a, 4) + wa(a(a, 6)) + 2 * m(0, 2): m(0, 9) = a: m(0, 11) = a(a, 7): m(0, 12) = a(a, 8)
16050 IF S$ <> "TROLLSFIRE" THEN PRINT " readied.": PRINT : GOTO 300
16060 TR = 0: m(0, 12) = 10: GOTO 20000
16070 REM
'---------------------------------------------------------------------------
' ///flee command
'
17000 REM
17010 IF NOT nbtl THEN PRINT : PRINT "What are you fleeing from?": PRINT : GOTO 100
17020 IF m(7, 5) = room THEN PRINT : PRINT "You are held fast by the Mimic and connot "; V$: PRINT : GOTO 300
17030 m = 0: GOSUB 17500
17040 nbtl = 0: GOTO 5100
17500 ' map is in memory now
17510 r2 = map(room, INT(6 * RND(1) + 1)): IF r2 < 1 THEN 17510
17520 RETURN
'---------------------------------------------------------------------------
'  /// INVENTORY command
'
18000 REM
PRINT : PRINT m$(0); " is carrying the following --"
FOR a = 1 TO na
   IF a(a, 4) = -1 THEN
     PRINT "  "; a$(a); "   "; : IF a = m(0, 9) THEN PRINT "(Ready Weapon)";
     PRINT
END IF
NEXT
PRINT : PRINT LTRIM$(STR$(gold)); " gold pieces"
GOTO 300
'---------------------------------------------------------------------------
' /// Enter command
'
19000 REM
19005 IF nbtl THEN 2020
19010 GOSUB 1950
19020 IF S$ <> "WATER" AND S$ <> "SEA" THEN 19040
19030 PRINT : PRINT "Sorry, but I'm afraid to go into the water without my life preserver!": PRINT : GOTO 300
19040 IF S$ = "CAVE" AND room = 1 THEN V$ = "S": GOTO 5000
19050 PRINT : PRINT "I'm not sure what you mean by that.": PRINT "Try giving a direction to move.": PRINT : GOTO 100
19060 REM
20000 REM /// trollsfire activation
20010 IF a(11, 4) <> -1 THEN PRINT : PRINT "Nothing happens.": PRINT : GOTO 300
20020 IF NOT TR THEN 20500
20030 GET #3, 30: PRINT FND$(r3$): TR = 0: a(11, 8) = 6: IF m(0, 9) = 10 THEN m(0, 12) = 6
20040 GOTO 300
20500 GET #3, 28: PRINT FND$(r3$): IF m(0, 9) <> 11 THEN GET #3, 29: PRINT FND$(r3$): S = 5: d = 1: DF = 0: a = 0: GOSUB 3650: GOTO 300
20510 TR = -1: m(0, 12) = 10: a(10, 8) = 10: GOTO 300
21000 REM ///open command
21010 IF nbtl THEN 2020
21020 IF S$ <> "CHEST" OR room <> a(13, 4) THEN 21050
21030 GET #3, 25: PRINT FND$(r3$): PRINT : a(13, 4) = 0: m(7, 5) = room
21040 r2 = room: GOTO 5100
21050 IF S$ = "DOOR" THEN PRINT : PRINT "The door will open when you move through it.": PRINT : GOTO 100
21060 PRINT : PRINT "Would you have any bloody ideas how?": GOTO 100
23000 EXIT SUB
'
28000 T1 = VAL(S$)
28010 IF T1 > nr OR T1 < 1 THEN 300
28020 r2 = T1: GOTO 5100
END SUB

