'
'                  Eamon Adventure # 8
'                The Abductor's Quarters
'
'                   By Jim Jacobson
'
' ----------------------------------------------------------------------
'
    DEFINT A-Z
    DECLARE SUB PGPRT (SP, LIT$)
REM $$INCL:'\EAMON\COPY\CHARDEF.BAS'
	' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	'
	'   Module:  CHARDEF.BAS
	'   Eamon Version:  Eamon-QB (or Eamon-PC)
	' ------------------------------------------------------------
	'  Character Definition for Eamon QB/PC
	'        Basic version:  QuickBASIC 4.0, GW-BASIC, QBasic *
	'                        or BASIC 7.0 PDS
	'       uses Field statements for record description
	'       This module will work for QBasic, but QBasic cannot
REM $$INCL:statements, so module must be copied
	'       into programs manually or merged using a utility
	' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	'
TYPE WeaponRec
	Nam             AS STRING * 20
	Wpntyp          AS INTEGER
	Odds            AS INTEGER
	Dice            AS INTEGER
	Sides           AS INTEGER
END TYPE

TYPE CharacterRecord
	Nam             AS STRING * 30
	Hd              AS INTEGER
	Ag              AS INTEGER
	Ch              AS INTEGER
	SA1             AS INTEGER
	SA2             AS INTEGER
	SA3             AS INTEGER
	SA4             AS INTEGER
	WA1             AS INTEGER
	WA2             AS INTEGER
	WA3             AS INTEGER
	WA4             AS INTEGER
	WA5             AS INTEGER
	Sex             AS STRING * 1
	Gold            AS LONG
	Bank            AS LONG
	AE              AS INTEGER
	ArmNam          AS STRING * 20
	ArmHit          AS INTEGER
	Armadj          AS INTEGER
	ShdNam          AS STRING * 20
	ShdHit          AS INTEGER
	ShdAdj          AS INTEGER
	Wpn1Nam         AS STRING * 20
	Wpn1typ         AS INTEGER
	Wpn1Wpntyp      AS INTEGER
	Wpn1odds        AS INTEGER
	Wpn1Dice        AS INTEGER
	Wpn1Sides       AS INTEGER
	Wpn2Nam         AS STRING * 20
	Wpn2typ         AS INTEGER
	Wpn2Wpntyp      AS INTEGER
	Wpn2odds        AS INTEGER
	Wpn2Dice        AS INTEGER
	Wpn2Sides       AS INTEGER
	Wpn3Nam         AS STRING * 20
	Wpn3typ         AS INTEGER
	Wpn3Wpntyp      AS INTEGER
	Wpn3odds        AS INTEGER
	Wpn3Dice        AS INTEGER
	Wpn3Sides       AS INTEGER
	Wpn4Nam         AS STRING * 20
	Wpn4typ         AS INTEGER
	Wpn4Wpntyp      AS INTEGER
	Wpn4odds        AS INTEGER
	Wpn4Dice        AS INTEGER
	Wpn4Sides       AS INTEGER
	Filler          AS STRING * 23
END TYPE
DIM Char AS CharacterRecord
TYPE CharControl
	NbrChar         AS INTEGER
	Filler          AS STRING * 254
END TYPE
DIM CharCtl AS CharControl

    '------- (end of include file) -------    
 ' 
    DIM FRIEND as CharacterRecord
REM $$INCL:'\EAMON\COPY\COLORRTN.BAS'
     ON ERROR GOTO NoColors
     OPEN "EAMCOLOR" FOR INPUT AS #1
     INPUT #1, fgc%
     INPUT #1, bgc%
     INPUT #1, hfg%
     INPUT #1, hbg%
     CLOSE
In.BW:
     ON ERROR GOTO 0
     COLOR fgc%, bgc%
     GOTO Colorset
NoColors:
      fgc% = 7
      bgc% = 0
      hfg% = 0
      hbg% = 7
      RESUME In.BW
Colorset:

    '------- (end of include file) -------    
 ' 
    CLS
    DEF FNR (X) = INT(RND(1) * X) + 1
REM $$INCL:'\EAMON\COPY\READCTL.BAS'
     CLOSE 1
     OPEN "DESC.R0" FOR INPUT AS #1
     INPUT #1, NR
     INPUT #1, NZ
     INPUT #1, NE
     INPUT #1, NM
     INPUT #1, ND
     INPUT #1, MAX.RM
     INPUT #1, MAX.ART
     INPUT #1, MAX.EFF
     INPUT #1, Max.Mon
     INPUT #1, Rm.Len
     INPUT #1, Rmn.Len
     INPUT #1, Mon.Len
     INPUT #1, Art.Len
     INPUT #1, Desc.Len
     INPUT #1, Mon.Flds
     INPUT #1, Art.Flds
     INPUT #1, RM.Flds
     INPUT #1, MN.Len
     INPUT #1, AN.Len
     CLOSE 1
     NA = NZ
     ART.ADJ = MAX.RM
     EFF.ADJ = MAX.RM + MAX.ART
     MON.ADJ = MAX.RM + MAX.ART + MAX.EFF
     EMB.ADJ = MAX.RM + MAX.ART
     INS.ADJ = MAX.RM
     HID.ADJ = MAX.RM * 2 + MAX.ART
     BURY.ADJ = MAX.RM * 3 + MAX.ART

    '------- (end of include file) -------    
 ' 
    DIM V%(NR), RD%(10), FD%(3), TD%(3), SA%(4), S2%(4), WA%(5), RF.DIR$(10)
    DIM AN$(NA + 6), AD%(NA + 6, 9)
    DIM MN$(NM), MD%(NM, 16)
    GOSUB READ.ARTIFACTS ' LOAD ARTIFACT TABLE
    GOSUB READ.MONSTERS ' LOAD MONSTER TABLE
    NW = NW + 4
    DIM WN$(NW), WR%(NW), WT%(NW), WC%(NW), WD%(NW), WP%(NW), WS%(NW)
    READ NC
    DIM C$(NC)
    FOR C = 1 TO NC
    READ C$(C)
    NEXT
    R2 = 1
    CONST KM.HARD = 1
    CONST KM.AGIL = 2
    CONST KM.FRIEND = 3
    CONST KM.COURAGE = 4
    CONST KM.ROOM = 5
    CONST KM.WT = 6
    CONST KM.D.ODDS = 7
    CONST KM.ARMOR = 8
    CONST KM.WEAPON = 9
    CONST KM.O.ODDS = 10
    CONST KM.DICE = 11
    CONST KM.SIDES = 12
    CONST KM.DAMAGE = 13
    CONST KM.REACTION = 14
    CONST KM.STATUS = 15
    CONST KA.VALUE = 1
    CONST KA.TYPE = 2
    CONST KA.WEIGHT = 3
    CONST KA.ROOM = 4
    CONST GOLD.ART = 0
    CONST TREASURE.ART = 1
    CONST WEAPON.ART = 2
    CONST MAG.WEAPON = 3
    CONST CONTAIN.ART = 4
    CONST LIGHT.ART = 5
    CONST HEAL.ART = 6
    CONST READ.ART = 7
    CONST DOOR.ART = 8
    CONST KEY.ART = 9
    CONST BOUND.MON.ART = 10
    CONST ARMOR.ART = 11
    CONST FOOD.ART = 12
    CONST DRINK.ART = 13            ' DRINKABLE ARTIFACT --- PUT IN YOUR OWN EFFECTS
    CONST KT.MONSTER.DISGUISED = 14
    CONST KT.TRAP = 15
    GOTO INITIALIZE
DONT.UNDERSTAND:
    PGPRT 2, "I don't understand."
' ---------------------------------------------------------------------------
MAIN.LOOP:
    IF SPD THEN
	SPD = SPD - 1
	IF SPD = 0 THEN
	    MD%(0, KM.AGIL) = MD%(0, KM.AGIL) / 2:
	    MD%(0, KM.O.ODDS) = MD%(0, KM.O.ODDS) - 2 * MD%(0, KM.AGIL)
	    PGPRT 2, "Your Speed Spell has just expired!"
	END IF
    END IF
SHOW.ROOM:      ' SHOW.ROOM
    IF (Room > 45 AND Room < 61) AND LT = 0 THEN PGPRT 2, "It's too dark to see anything.": GOTO GET.COMMAND
    IF V%(Room) <> 0 THEN GET #3, Room: A$ = RTRIM$(RN$): PGPRT 2, "You are " + A$
    IF V%(Room) = 0 THEN GOSUB SPECIAL.ROOM.CHK
    IF FNR(100) > 98 THEN GOSUB GUARD.ENTERS: GOTO MON.LOOP
    IF NBTL AND FNR(100) > 80 THEN GOSUB GUARD.ENTERS
    IF GOLD& > 0 AND FNR(100) > 96 AND MD%(13, 5) THEN GOSUB THIEF.RTN
MON.LOOP:
    FOR M = 1 TO NM
    IF MD%(M, KM.ROOM) = Room THEN
	IF MD%(M, KM.STATUS) = 1 THEN PGPRT 2, MN$(M) + " is here."
	IF MD%(M, KM.STATUS) = 0 THEN
	    GET #2, M + MON.ADJ
	    A$ = RTRIM$(Desc$)
	    PGPRT 2, A$
	    MD%(M, KM.STATUS) = 1
	END IF
    END IF
    NEXT
    FOR A = 1 TO NZ
    IF AD%(A, KA.ROOM) <> Room THEN GOTO NEXT.ART
    IF AD%(A, 9) THEN
	PGPRT 2, "You see " + AN$(A) + "."
    ELSE
	GET #2, A + ART.ADJ
	A$ = RTRIM$(Desc$)
	PGPRT 2, A$
	AD%(A, 9) = 1
    END IF
NEXT.ART:      ' NEXT.ART
    NEXT
    FOR A = A TO NA
    IF AD%(A, KA.ROOM) = Room THEN
	PGPRT 2, "Your " + AN$(A) + " is here."
    END IF
    NEXT
    PRINT
GET.COMMAND:      ' GET.COMMAND
    PGPRT 0, ""
    PRINT
    COLOR HFG%, HBG%
    PRINT "  Your Command ";
    COLOR FGC%, BGC%
    LINE INPUT " ", A$
    A$ = LTRIM$(RTRIM$(UCASE$(A$)))
    IF A$ = "" THEN A$ = CZ$: LOCATE CSRLIN - 1, 17: PRINT A$
    IF A$ = "" THEN GOTO LIST.COMMANDS
    IF A$ = "EXIT NOW" THEN GOTO Game.Over
    CZ$ = A$
    A = INSTR(A$, " ")
    IF A = 0 THEN A = LEN(A$) + 1
    V$ = LEFT$(A$, A - 1)
    S$ = MID$(A$, A + 1)
    S$ = LTRIM$(S$)
REM $$INCL:'\EAMON\COPY\EXTCMDS.BAS'
    '    Abductor's Quarters Test commands
    ' ------------------------------------------
    IF V$ = "DIE" THEN DIE = -1: GOTO GAME.OVER
    IF V$ = "LEAVE" AND S$ = "WITH FRIEND" THEN DIE = 0: MD%(6, KM.ROOM) = 1: ROOM = 1: GOTO GAME.OVER
    IF V$ = "LEAVE" THEN DIE = 0: ROOM = 1: GOTO GAME.OVER
    IF V$ = "KILL" THEN
        IF S$ = "ALL" THEN
            FOR DF = 1 TO NM
                IF MD%(DF, 5) = ROOM AND MD%(DF, 14) = 1 THEN
                    D2 = MD%(DF, 1)
                    A = 0
                    GOSUB APPLY.DAMAGE
                END IF
            NEXT
            NBTL = (FD%(1) < TD%(1))
            GOTO MAIN.LOOP
        END IF
        GOSUB MONSTER.SEARCH
        IF FOUND THEN
            DF = M
            D2 = MD%(M, 1)
            A = 0
            OF = 0
            GOSUB APPLY.DAMAGE
            NBTL = (FD%(1) < TD%(1))
            GOTO MAIN.LOOP
        END IF
    END IF
    '------- (end of include file) -------    
 ' 
    C = 0
    FOR A = 1 TO ND
    IF LEFT$(UCASE$(C$(A)), LEN(V$)) = V$ THEN C = A: A = ND
    NEXT
    IF C <> 0 THEN GOTO BRANCH.RTN
    F = 0
    FOR A = ND + 1 + 4 * ABS(ND = 6) TO NC
    IF UCASE$(C$(A)) = V$ THEN C = A: A = NC
    IF LEFT$(UCASE$(C$(A)), LEN(V$)) = V$ THEN
	F = F + 1
	C = A
	IF F > 1 THEN C = 0: A = NC
    END IF
    NEXT
    IF C = 0 THEN GOTO LIST.COMMANDS
    GOTO BRANCH.RTN
LIST.COMMANDS:      ' LIST.COMMANDS
    PRINT
    PRINT "Huh? I only understand these commands ... "
    FOR C = 1 TO NC
    IF ND = 6 AND C > 6 AND C < 11 THEN C = 10 ELSE PRINT C$(C); SPC(20 - LEN(C$(C)));
    NEXT
    PRINT
    PRINT
    GOTO GET.COMMAND
    IF UCASE$(C$(C)) = S$ THEN S$ = V$: V$ = C$(C)
BRANCH.RTN:      ' BRANCH.RTN
    ON C GOTO MOVE.RTN, MOVE.RTN, MOVE.RTN, MOVE.RTN, MOVE.RTN
    ON C - 5 GOTO MOVE.RTN, MOVE.RTN, MOVE.RTN, MOVE.RTN, MOVE.RTN
    ON C - 10 GOTO GET.RTN, GET.RTN, DROP.RTN, LOOK.RTN
    ON C - 14 GOTO LOOK.RTN, ATTACK.RTN, FLEE.RTN, GIVE.RTN, INVENTORY.RTN
    ON C - 19 GOTO BLAST.SPELL, HEAL.SPELL, POWER.SPELL, SPEED.SPELL, SMILE.RTN
    ON C - 24 GOTO SMILE.RTN, SAY.SOMETHING, READY.WEAPON
    ON C - 27 GOTO LIGHT.RTN, DRINK.RTN
    ON C - 29 GOTO SAVE.GAME, RESTORE.GAME, QUIT.RTN
GET.BACK:      ' GET.BACK
REM $$INCL:'\EAMON\COPY\NEWBATL.BAS'
    IF TT > 0 THEN TT = TT - 1: GOTO End.Battle
    IF NBTL = 0 THEN GOTO End.Battle
    FOR M = 1 TO NM
        IF MD%(M, 5) = ROOM AND TT = 0 THEN
            MR = FD%(MD%(M, 14)) / TD%(MD%(M, 14)) - FD%(4 - MD%(M, 14)) / TD%(4 - MD%(M, 14)) / 5 + INT(41 * RND(1) - 20)
            IF MD%(M, 4) < MR THEN
                GOSUB Find.Exit
                IF R2 > 0 THEN
                    PGPRT 2, MN$(M) + " flees!"
                    GOSUB MONSTER.LEAVES
                    EXIT FOR
                END IF
            END IF
            IF MD%(M, 14) = 3 THEN
                GOSUB GoodGuys.Attack
            ELSE
                GOSUB BadGuys.Attack
            END IF
        END IF
        NBTL = (FD%(1) < TD%(1))
        IF NBTL = 0 THEN EXIT FOR
    NEXT M
End.Battle:
    IF TT > 0 THEN TT = TT - 1
    GOTO End.Loop
BadGuys.Attack:
    OF = M
    IF TD%(1) = MD%(0, 1) THEN DF = 0: GOSUB Take.a.Swing: RETURN
    DF = -1
    FOR M2 = 1 TO NM
        IF MD%(M2, 5) = ROOM AND MD%(M2, 14) = 3 AND RND(1) < .25 THEN
            DF = M2
            GOSUB Take.a.Swing
            EXIT FOR
        END IF
    NEXT M2
    IF DF < 0 THEN DF = 0: GOSUB Take.a.Swing
    RETURN
GoodGuys.Attack:
    OF = M
    DF = -1
    FOR M2 = 1 TO NM
        IF MD%(M2, 5) = ROOM AND MD%(M2, 14) = 1 THEN
            DF = M2
            GOSUB Take.a.Swing
            EXIT FOR
        END IF
    NEXT M2
    RETURN
End.Loop:

    '------- (end of include file) -------    
 ' 
    GOTO MAIN.LOOP
REM $$INCL:'\EAMON\COPY\MONLEAVE.BAS'
MONSTER.LEAVES:
    MD%(M, 5) = R2
    M2 = MD%(M, 14)
    TD%(M2) = TD%(M2) - MD%(M, 1)
    FD%(M2) = FD%(M2) - MD%(M, 13)
    NBTL = (FD%(1) < TD%(1))
    RETURN

    '------- (end of include file) -------    
 ' 
' ---------------------------------------------------------------------------
INITIALIZE:
REM $$INCL:'\Eamon\COPY\READMEAT.BAS'
    OPEN "MEAT" FOR INPUT AS #2
    INPUT #2, Nbr.Party
    INPUT #2, REC
    INPUT #2, MN$(0)
    INPUT #2, MD%(0, 1)
    INPUT #2, MD%(0, 2)
    INPUT #2, MD%(0, 3)
    CH = MD%(0, 3)
    FOR X = 1 TO 4
    INPUT #2, SA%(X)
    S2%(X) = SA%(X)
    NEXT
    FOR X = 1 TO 5
    INPUT #2, WA%(X)
    NEXT
    INPUT #2, SEX$
    INPUT #2, GOLD&
    INPUT #2, BANK&
    INPUT #2, AE
    INPUT #2, ArmNam$
    INPUT #2, ArmHit
    INPUT #2, ArmAdj
    INPUT #2, ShdNam$
    INPUT #2, ShdHit
    INPUT #2, ShdAdj
    FOR X = 1 TO 4
      INPUT #2, A$
      IF RTRIM$(A$) = "" THEN A$ = "NONE"
      WN$(X) = A$
      INPUT #2, WT%(X)
      INPUT #2, WC%(X)
      INPUT #2, WD%(X)
      INPUT #2, WS%(X)
      IF A$ <> "NONE" THEN
          NA = NA + 1
          AN$(NA) = WN$(X)
          AD%(NA, 2) = 2
          AD%(NA, 3) = 2
          AD%(NA, 4) = -1
          AD%(NA, 5) = WC%(X)
          AD%(NA, 6) = WT%(X)
          AD%(NA, 7) = WD%(X)
          AD%(NA, 8) = WS%(X)
      END IF
    NEXT
    IF ArmHit <> 0 THEN
          WN$(5) = ArmNam$ + " Armor"
          WT%(5) = 1
          WD%(5) = ArmHit
          WC%(5) = ArmAdj
          NA = NA + 1
          MD%(0, 8) = ArmHit
          Armptr = NA
          AN$(NA) = WN$(5)
          AD%(NA, 1) = ArmHit * 15
          AD%(NA, 2) = 11
          AD%(NA, 3) = ArmHit * 2
          AD%(NA, 4) = -1
          AD%(NA, 5) = WC%(X)
          AD%(NA, 6) = WT%(X)
          AD%(NA, 7) = WD%(X)
          AD%(NA, 8) = WS%(X)
    END IF
    IF ShdHit <> 0 THEN
          WN$(6) = ShdNam$ + " Shield"
          WT%(6) = 2
          WD%(6) = ShdHit
          WC%(6) = ShdAdj
          NA = NA + 1
          MD%(0, 8) = MD%(0, 8) + ShdHit
          Shdptr = NA
          AN$(NA) = WN$(6)
          AD%(NA, 1) = ArmHit * 15
          AD%(NA, 2) = 11
          AD%(NA, 3) = ArmHit * 2
          AD%(NA, 4) = -1
          AD%(NA, 5) = WC%(X)
          AD%(NA, 6) = WT%(X)
          AD%(NA, 7) = WD%(X)
          AD%(NA, 8) = WS%(X)
    END IF
    INPUT #2, MastPath$
    CLOSE 2
    EA = -(ArmAdj + ShdAdj)
    MD%(0, 8) = ArmHit + ShdHit
    IF NA > NZ THEN
        MD%(0, 10) = MD%(0, 2) * 2 + WC%(1) + WA%(WT%(1)) + (EA + AE) * ABS(-EA > AE)
        MD%(0, 7) = 0
        MD%(0, 9) = NZ + 1
        MD%(0, 11) = WD%(1)
        MD%(0, 12) = WS%(1)
        MD%(0, 14) = 3
    END IF

    '------- (end of include file) -------    
 ' 
'   *  GET OLD CHARACTER *
    OPEN PATH$ + "LASTCHAR.TXT" FOR INPUT AS #1
    INPUT #1, MN$(6)
    CLOSE 1
    GOSUB OPEN.DESC
    GOSUB OPEN.RMNAMES
    GOSUB OPEN.ROOMS
    Room = 1
    GOTO MOVE.IT
    DATA 32
    DATA North,South,East,West,Up,Down
    DATA NE,NW,SE,SW
    DATA Get,Take,Drop,Look,Examine
    DATA Attack,Flee,Give,Inventory
    DATA Blast,Heal,Power,Speed,Smile
    DATA Wave,Say,Ready
    DATA Light,Drink
    DATA Save,Restore,Quit
' ---------------------------------------------------------------------------
Game.Over:      ' GAME.OVER
    PRINT
    PRINT "(Press any key to continue) ";
    A$ = INPUT$(1)
    PRINT
    CLOSE
    IF SPD THEN MD%(0, KM.AGIL) = MD%(0, KM.AGIL) / 2
    IF DIE <> 0 AND SAVED <> 0 THEN
	PRINT "Do you want to restart (Y/N)  ";
	YN$ = INPUT$(1)
	IF UCASE$(YN$) = "Y" THEN CLEAR : RUN
    END IF
    IF DIE <> 0 THEN
	GOSUB IMPRISON.PLAYER
	GOTO GET.MASTER
    END IF
    GOSUB CHK.SUCCESS
    FOR W = 1 TO 4
    WN$(W) = "NONE"
    NEXT
    W2 = 1
    FOR A = 1 TO NA
    IF AD%(A, KA.TYPE) > 1 AND AD%(A, KA.TYPE) < 4 AND AD%(A, KA.ROOM) = -1 THEN WN$(W2) = AN$(A): WP%(W2) = A: W2 = W2 + 1: AD%(A, KA.ROOM) = 0
    NEXT A
    IF W2 < 6 THEN GOTO SELL.TREASURE
PLAYER.RETURNS:
    CLS
    LOCATE 5, 1
    PRINT "As you start to enter the Main Hall, Lord William Misslefire appears and"
    PRINT "tells you, 'You have too many weapons to keep them all--4 is the legal limit."
    PRINT
    PRINT "Your weapons are--"
    FOR W = 1 TO W2 - 1
    PRINT SPC(4); W; "--"; WN$(W)
    NEXT
    PRINT
    PRINT "Enter the number of the weapon to sell  (1-"; W2 - 1; ") "
SELL.WEAPON:
    LOCATE CSRLIN - 1, 53
    INPUT A$
    W5 = VAL(A$)
    IF W5 < 1 OR W5 > W2 - 1 OR W5 <> INT(W5) THEN GOTO SELL.WEAPON
    AD%(WP%(W5), KA.ROOM) = -1
    WN$(W5) = WN$(W2 - 1)
    WP%(W5) = WP%(W2 - 1)
    W2 = W2 - 1
    IF W2 > 5 THEN GOTO PLAYER.RETURNS
SELL.TREASURE:
    IF MD%(0, KM.ARMOR) > AC THEN MD%(0, KM.ARMOR) = AC
    FOR W = 1 TO 4
    IF WP%(W) THEN WT%(W) = AD%(WP%(W), 6): WC%(W) = AD%(WP%(W), 5): WD%(W) = AD%(WP%(W), 7): WS%(W) = AD%(WP%(W), 8)
    NEXT W
    CLS
    LOCATE 5, 1
    PRINT "As you deliver your treasures to Sam Slicker, the local buyer for such"
    PRINT "things, he examines your goods and pays you ";
    TP = 0
    FOR A = 1 TO NA
    IF A = ArmPtr OR A = ShdPtr THEN GOTO NEXT.TREASURE 
    IF AD%(A, KA.ROOM) <> -1 THEN GOTO NEXT.TREASURE
    IF AD%(A, KA.TYPE) <> 0 THEN AD%(A, KA.VALUE) = AD%(A, KA.VALUE) * CH / 10
    TP = TP + AD%(A, KA.VALUE)
NEXT.TREASURE:
    NEXT A
    PRINT TP; " gold pieces."
    PRINT
    GOLD& = GOLD& + TP
    IF GOLD& < 0 THEN GOLD& = 0
    PRINT
    PRINT "(Press any key to continue)  ";
    A$ = INPUT$(1)
    PRINT
GET.MASTER:
    CLS
    LOCATE 5, 1
 '  PRINT "  Insert Eamon Master Diskette, and press <RETURN>  OR     "
 '  PRINT
 '  PRINT "  Enter Path of Master ===> ";
 '  INPUT "", MastPath$
    IF INSTR(MastPath$, ":") = 2 THEN DR$ = LEFT$(MastPath$, 2): MastPath$ = MID$(MastPath$, 3): SHELL DR$
    IF MastPath$ <> "" THEN CHDIR MastPath$
    ON ERROR GOTO Invalid.Path
    IF DIE THEN
	OPEN PATH$ + "ADVENT" FOR OUTPUT AS #1
	WRITE #1, "BYE"
	CLOSE
	KILL PATH$ + "ADVENT"
	CLEAR
	RUN PATH$ + "WORLD"
    END IF
    CLOSE
    GOSUB OPEN.CHARACTERS
    GOSUB FIND.RECNBR
    Nam$ = MN$(0)
    HD = MD%(0, KM.HARD)
    AG = MD%(0, KM.AGIL)
    REC = R + 1
    GOSUB WRITE.CHARACTER
    GOSUB WRITE.FRIEND
    CLOSE
    OPEN PATH$ + "ADVENT" FOR OUTPUT AS #1
    PRINT #1, MN$(0)
    PRINT #1, REC
    CLOSE
    CLEAR
    RUN PATH$ + "HALL"
Invalid.Path:
    PRINT
    PRINT "Invalid Path, or Master Not Found. Please re-try ..."
    PRINT " (press any key to continue)";
    A$ = INPUT$(1)
    RESUME GET.MASTER
READ.FRIEND:
    IF MN$(6) = "Kathryn" THEN RETURN
    OPEN PATH$ + "LASTCHAR.TXT" FOR INPUT AS #2
    DIM X$(18)
    FOR J = 1 TO 18: INPUT #2, X$(J): NEXT J
    CLOSE 2
    KILL PATH$ + "LASTCHAR.TXT"
    OPEN PATH$ + "LASTCHAR.TXT" FOR OUTPUT AS #2
    WRITE #2, "Kathryn"
    CLOSE 2
    RETURN
WRITE.FRIEND:
    R = 0
    FOR K = 1 TO NC
    GET #1, K + 1
    IF FLNAM$ = MN$(6) THEN R = K + 1: K = NC
    NEXT K
    IF R > 0 THEN GOTO WRITE.FR.REC
    FOR K = 1 TO NC
     GET #1, K + 1
     A$ = FLNAM$
     IF LEFT$(A$, 5) = "*DEAD" THEN R = K + 1: K = NC
    NEXT
    IF R = 0 THEN NC = NC + 1: R = NC + 1: GOSUB WRITE.NBR.CHARS
WRITE.FR.REC:
	Friend.Nam = X$(1)
	Friend.Hd = VAL(X$(2))
	Friend.Ag = VAL(X$(3))
	Friend.Ch = VAL(X$(4))
	Friend.SA1 = VAL(X$(5))
	Friend.SA2 = VAL(X$(6))
	Friend.SA3 = VAL(X$(7))
	Friend.SA4 = VAL(X$(8))
	Friend.WA1 = VAL(X$(9))
	Friend.WA2 = VAL(X$(10))
	Friend.WA3 = VAL(X$(11))
	Friend.WA4 = VAL(X$(12))
	Friend.WA5 = VAL(X$(13))
	Friend.SEX = X$(14)
	Friend.GOLD = VAL(X$(15))
	Friend.BANK = VAL(X$(16))
	Friend.AE = VAL(X$(17))
	Friend.ArmNam$ = X$(18)
	Friend.ArmHit = VAL(X$(19))
	Friend.ArmAdj = VAL(X$(20))
	Friend.ShdNam$ = X$(21)
	Friend.ShdHit = VAL(X$(22))
	Friend.ShdAdj = VAL(X$(23))
	IF MD%(6, 9) > 0 THEN
	    A = MD%(6, 9)
	    Friend.Wpn1Nam = AN$(MD%(6, 9))
	    Friend.Wpn1Typ = WR%(1)
	    Friend.Wpn1WpnTyp = AD%(A, 6)
	    Friend.Wpn1Odds = AD%(A, 5)
	    Friend.Wpn1Dice = AD%(A, 7)
	    Friend.Wpn1Sides = AD%(A, 8)
	END IF
	Friend.Wpn2Nam = "NONE"
	Friend.Wpn2Typ = 0
	Friend.Wpn2WpnTyp = 0
	Friend.Wpn2Odds = 0
	Friend.Wpn2Dice = 0
	Friend.Wpn2Sides = 0
	Friend.Wpn3Nam = "NONE"
	Friend.Wpn3Typ = 0
	Friend.Wpn3WpnTyp = 0
	Friend.Wpn3Odds = 0
	Friend.Wpn3Dice = 0
	Friend.Wpn3Sides = 0
	Friend.Wpn4Nam = "NONE"
	Friend.Wpn4Typ = 0
	Friend.Wpn4WpnTyp = 0
	Friend.Wpn4Odds = 0
	Friend.Wpn4Dice = 0
	Friend.Wpn4Sides = 0
	PUT #1, R, Friend
    'LSET FLNAM$ = X$(1)
    'RSET FHD$ = MKI$(VAL(X$(2)))
    'RSET FAG$ = MKI$(VAL(X$(3)))
    'RSET FCH$ = MKI$(VAL(X$(4)))
    'FOR X = 1 TO 4
    'RSET FSA$(X) = MKI$(VAL(X$(X + 4)))
    'NEXT
    'FOR X = 1 TO 5
    'RSET FWA$(X) = MKI$(VAL(X$(X + 8)))
    'NEXT
    'LSET FSEX$ = X$(14)
    'RSET FGOLD$ = MKL$(VAL(X$(15)))
    'RSET FBANK$ = MKL$(VAL(X$(16)))
    'RSET FAE$ = MKI$(VAL(X$(17)))
    'RSET FAC$ = MKI$(VAL(X$(18)))
    'S = 1
    'IF MD%(6, 9) > 0 THEN
'	A = MD%(6, 9)
'	LSET FWN$(1) = AN$(MD%(6, 9))
'	RSET FWT$(1) = MKI$(AD%(A, 6))
'	RSET FWC$(1) = MKI$(AD%(A, 5))
'	RSET FWD$(1) = MKI$(AD%(A, 7))
'	RSET FWS$(1) = MKI$(AD%(A, 8))
'	S = 2
 '   END IF
  '  FOR K = S TO 4
'	LSET FWN$(S) = "NONE"
'	RSET FWT$(S) = MKI$(0)
'	RSET FWC$(S) = MKI$(0)
'	RSET FWD$(S) = MKI$(0)
'	RSET FWS$(S) = MKI$(0)
'   NEXT K
'    PUT #1, R
    RETURN
QUIT.RTN:
    PRINT "Do you want to Quit this game? (Y/N) ";
    A$ = INPUT$(1)
    IF UCASE$(A$) = "N" THEN GOTO GET.COMMAND
    CLOSE
    END
CHK.SUCCESS:
    IF MD%(6, KM.ROOM) = Room THEN
	PGPRT 2, "You were able to save your friend!"
	GOSUB READ.FRIEND
    END IF
    RETURN
' --------------------------------------------------------------------------
MOVE.RTN:
    IF IV = 0 THEN
	IF NBTL AND S$ <> "FLEE" THEN
	    IF TT = 0 THEN
		PGPRT 2, "You can't do that with unfriendlies about!"
		GOTO MAIN.LOOP
	    END IF
	END IF
    END IF
    D = C
    R2 = RD%(D)
    IF Room = 11 AND RND(1) > MD%(0, 2) / 25 THEN PGPRT 2, "OOPS! You just fell in the hole!": S = 4: D = 1: DF = 0: A = 0: GOSUB DO.DAMAGE: R2 = 45: GOTO MOVE.IT
    GOSUB DecodeRoom
    IF Rmcd = 1 THEN GOTO PASSAGE.BLOCKED
CHK.SPECIAL.MOVES:
    IF R2 > 0 AND R2 <= NR THEN GOTO MOVE.IT
    IF R2 = -99 THEN PGPRT 2, "You successfully ride off into the sunset.": GOTO Game.Over
    IF R2 = 0 THEN GOTO CANT.GO
    GOTO CANT.GO
PASSAGE.BLOCKED:
    GATE = ACT.ROOM
    IF AD%(GATE, KA.ROOM) <> Room THEN R2 = AD%(GATE, 5): GOTO CHK.SPECIAL.MOVES
    PGPRT 2, "The " + AN$(GATE) + " blocks the way!"
    GOTO MAIN.LOOP
CANT.GO:
    PGPRT 2, "You can't go that way!"
    V%(Room) = 0
    GOTO MAIN.LOOP
MOVE.IT:
    IF Room = 37 AND R2 = 36 AND AD%(11, 4) = Room THEN PGPRT 2, "The doorway is bricked up.": GOTO MAIN.LOOP
    R3 = Room
    Room = R2
    GOSUB CHK.REACTIONS
    GET #1, Room
    NX = 0
    FOR X = 1 TO ND
    RD%(X) = CVI(RF.DIR$(X))
    IF RD%(X) < 0 AND RD%(X) > -NR AND V%(Room) > 1 THEN RD%(X) = ABS(RD%(X))
COUNT.EXITS:      ' COUNT.EXITS
    IF RD%(X) > 0 AND RD%(X) <= NR THEN NX = NX + 1
    NEXT
    GOTO END.LOOP
CHK.REACTIONS:
    TD%(1) = 0
    TD%(3) = MD%(0, KM.HARD)
    FD%(1) = 0
    FD%(3) = MD%(0, KM.DAMAGE)
    IF IV THEN NBTL = 0: RETURN
    FOR M.1 = 1 TO NM
    IF MD%(M.1, KM.STATUS) = 2 AND MD%(M.1, KM.ROOM) = Room THEN GOTO MONSTER.NOT.HERE
    IF MD%(M.1, KM.ROOM) = R3 THEN
	IF MD%(M.1, KM.REACTION) = 3 OR (MD%(M.1, KM.REACTION) = 1 AND 200 * RND(1) < MD%(M.1, KM.COURAGE)) THEN MD%(M.1, KM.ROOM) = Room: GOTO ADD.SIDES
    END IF
MONSTER.REACTS:
    IF MD%(M.1, KM.ROOM) <> Room THEN GOTO MONSTER.NOT.HERE
    IF MD%(M.1, KM.REACTION) > 0 THEN GOTO ADD.SIDES
    FR = MD%(M.1, KM.FRIEND)
    IF FR > 0 AND FR <> 100 THEN FR = FR + INT((CH - 10) * 2)
    MD%(M.1, KM.REACTION) = 1
    IF FR > (100 * RND(1)) THEN MD%(M.1, KM.REACTION) = 2: IF FR > (100 * RND(1)) THEN MD%(M.1, KM.REACTION) = 3
ADD.SIDES:
    A = MD%(M.1, KM.REACTION)
    FD%(A) = FD%(A) + MD%(M.1, KM.DAMAGE)
    TD%(A) = TD%(A) + MD%(M.1, KM.HARD)
MONSTER.NOT.HERE:
    NEXT
    GOTO SET.NBTL
SET.NBTL:
    NBTL = (TD%(1) > 0)
    RETURN
BRING.IN.BEASTS:
    MD%(M, KM.ROOM) = Room
    MD%(M, KM.DAMAGE) = 0
    R3 = Room
    GOSUB CHK.REACTIONS
    RETURN
DecodeRoom:
    Select Case R2
        Case 1 To Max.Rm
            Rmcd = 0
            R = R2
        Case Ins.Adj + 1 To Ins.Adj + Max.Art
            Rmcd = 1
            R = R2 - Ins.Adj
        Case Emb.Adj + 1 To Emb.Adj + Max.Rm
            Rmcd = 2
            R = R2 - Emb.Adj
        Case Hid.Adj + 1 To Hid.Adj + Max.Rm
            Rmcd = 3
            R = R2 - Hid.Adj
        Case Bury.Adj + 1 To Bury.Adj + Max.Rm
            Rmcd = 4
            R = R2 - Bury.Adj
        Case Is < 0
            Rmcd = -1
            R = Abs(R2) - 1
        Case Else
    End Select
    RETURN
' --------------------------------------------------------------------------
GET.RTN:
    GOSUB GET.SUBJ
    IF LT = 0 AND (Room > 45 AND Room < 61) THEN PGPRT 2, "You can't find anything.": GOTO MAIN.LOOP
    IF S$ = "ALL" THEN GOTO GET.ALL
    EMB = Room + EMB.ADJ
    WH = Room
    HA = Room
    GOSUB LOCATE.ARTIFACT
    IF FOUND = 0 THEN PGPRT 2, "I see no " + LCASE$(S$) + " here!": GOTO MAIN.LOOP
    MON.APP = 0
    GOSUB GET.SURPRISE
    IF SUC = 0 THEN GOTO MAIN.LOOP
    IF WT + AD%(A, KA.WEIGHT) > 10 * MD%(0, KM.HARD) THEN PGPRT 2, "You can't budge it!": GOTO MAIN.LOOP
    PGPRT 2, "Got it."
    AD%(A, KA.ROOM) = -1
    WT = WT + AD%(A, KA.WEIGHT)
    IF (AD%(A, KA.TYPE) = 2 OR AD%(A, KA.TYPE) = 3) AND MD%(0, KM.WEAPON) = -1 THEN GOTO CALCULATE.ODDS
    GOTO GET.BACK
GET.ALL:
    MON.APP = 0
    FOR A = 1 TO NA
    IF AD%(A, KA.ROOM) <> Room OR AD%(A, KA.TYPE) = 10 THEN GOTO GET.NEXT
    GOSUB GET.SURPRISE
    IF SUC = 0 THEN GOTO GET.NEXT
    IF WT + AD%(A, 3) > 10 * MD%(0, KM.HARD) THEN PGPRT 2, AN$(A) + " can't be moved.": GOTO GET.NEXT
    PGPRT 1, AN$(A) + " taken."
    AD%(A, KA.ROOM) = -1
    WT = WT + AD%(A, 3)
GET.NEXT:      ' GET.NEXT
    NEXT
    GOTO GET.BACK
GET.SURPRISE:      ' GET.SURPRISE
'    /// INSERT HERE SPECIAL EFFECTS OF PICKING SOMETHING UP
    IF AD%(A, 2) = 11 AND AD%(A, 6) = 1 AND ArmPtr = 0 THEN 
    	ArmPtr = A
    	GOSUB Ready.Armor
    END IF	
    IF AD%(A, 2) = 11 AND AD%(A, 6) = 2 AND ShdPtr = 0 THEN 
    	ShdPtr = A
    	GOSUB Ready.Armor
    END IF	
    SUC = -1
    IF AD%(A, KA.TYPE) = KT.MONSTER.DISGUISED THEN
	M = AD%(A, 5)
	R = AD%(A, 6)
	GOSUB PRINT.EFFECT
	AD%(A, KA.ROOM) = 0
	GOSUB FIND.MONSTER
	SUC = 0
    END IF
    IF AD%(A, KA.TYPE) = KT.TRAP THEN
	R = AD%(A, 6)
	GOSUB PRINT.EFFECT
	IF FNR(100) > AD%(A, 5) THEN
	    D = AD%(A, 7)
	    S = AD%(A, 8)
	    GOSUB DO.DAMAGE
	END IF
	AD%(A, KA.ROOM) = 0
	SUC = 0
    END IF
    IF A = KH.GOLDEN.SWORD THEN
	PGPRT 2, "As you touch the sword, your hand feels warm. You are forced to drop any"
	PGPRT 1, "ready weapon you have and use the Goldensword!"
	GOTO READY.GOLDEN
    END IF
    IF A = 21 AND GOLD& = 0 THEN GOLD& = AD%(21, 1): AD%(21, 1) = 0: RETURN
    IF IV THEN GOSUB RATTLE.MONSTER
    RETURN
RATTLE.MONSTER:      ' RATTLE.MONSTER
    FOR M = 1 TO NM
    IF MD%(M, KM.ROOM) = Room THEN
	PGPRT 1, MN$(M) + " is slightly unnerved!"
	MD%(M, KM.COURAGE) = MD%(M, KM.COURAGE) - 10
    END IF
    NEXT
    RETURN
READY.GOLDEN:
    AD%(A, 4) = -1
    MD%(0, 10) = (EA + AE) * (-EA > AE) + AD%(A, 5) + WA%(AD%(A, 6)) + 2 * MD%(0, 2)
    MD%(0, 9) = A
    MD%(0, 11) = AD%(A, 7)
    MD%(0, 12) = AD%(A, 8)
    PGPRT 2, "Readied."
    PGPRT 2, "You suddenly realize you can't let go of this sword!!!"
    RETURN
SPECIAL.ROOM.CHK:
    GET #2, Room
    A$ = RTRIM$(Desc$)
    PGPRT 2, A$
    V%(Room) = V%(Room) + 1
    RETURN
' ---------------------------------------------------------------------------
MONSTER.SEARCH:
    WH = Room
    HA = -1
    EMB = Room
LOCATE.MONSTER:
    FOUND = 0
    SL = LEN(S$)
    FOR X = 1 TO NM
    IF (LEFT$(UCASE$(MN$(X)), SL) = S$ OR RIGHT$(UCASE$(MN$(X)), SL) = S$) AND (MD%(X, KM.ROOM) = WH OR MD%(X, KM.ROOM) = HA OR MD%(X, KM.ROOM) = EMB) THEN FOUND = FOUND + 1: M = X: IF S$ = MN$(X) THEN X = 9999
    NEXT
    RETURN
' ---------------------------------------------------------------------------
ARTIFACT.SEARCH:
    WH = Room
    HA = -1
    EMB = Room
LOCATE.ARTIFACT:
    FOUND = 0
    SL = LEN(S$)
    FOR X = 1 TO NA
    IF (LEFT$(UCASE$(AN$(X)), SL) = S$ OR RIGHT$(UCASE$(AN$(X)), SL) = S$) AND (AD%(X, KA.ROOM) = WH OR AD%(X, KA.ROOM) = HA OR AD%(X, KA.ROOM) = EMB) THEN FOUND = FOUND + 1: A = X: IF S$ = AN$(X) THEN X = 9999
    NEXT
    RETURN
' --------------------------------------------------------------------------
GET.SUBJ:
    WHILE S$ = ""
      PRINT
      PRINT C$(C); " What";
      INPUT S$
      PGPRT 2, ""
    WEND
    S$ = UCASE$(S$)
    RETURN
' --------------------------------------------------------------------------
DROP.RTN:
    GOSUB GET.SUBJ
    IF S$ = "ALL" THEN GOTO DROP.ALL
    WH = -1
    HA = -1
    EMB = -1
    GOSUB LOCATE.ARTIFACT
    IF FOUND = 0 THEN PGPRT 2, "You aren't carrying a " + LCASE$(S$) + "!": GOTO MAIN.LOOP
    WT = WT - AD%(A, 3)
    AD%(A, KA.ROOM) = Room
    PGPRT 2, AN$(A) + " dropped."
    GOSUB DROP.SPECIAL
CHK.WGHT:      ' CHK.WGHT
    IF WT > 10 * MD%(0, KM.HARD) THEN PGPRT 2, "You suddenly find you cannot carry all of the items you are carrying, and they all fall to the ground.": GOTO DROP.ALL
CHK.DROP.WEAPON:
    IF MD%(0, KM.WEAPON) > 0 THEN IF AD%(MD%(0, KM.WEAPON), KA.ROOM) <> -1 THEN MD%(0, KM.WEAPON) = -1
    GOTO GET.BACK
DROP.ALL:       ' DROP.ALL
    SR = Room
    FOR A = 1 TO NA
    IF AD%(A, KA.ROOM) = -1 AND A <> ArmPtr THEN
	GOSUB DROP.SPECIAL
	IF SUC THEN
	    PGPRT 2, AN$(A) + " dropped."
	    AD%(A, KA.ROOM) = Room
	END IF
    END IF
    NEXT
    WT = 0
    GOTO CHK.DROP.WEAPON
DROP.SPECIAL:
    IF A = ARMPTR OR A = SHDPTR THEN GOSUB DROP.ARMOR
    IF A = KH.GOLDEN.SWORD THEN PGPRT 2, "You can't drop it.": SUC = 0: RETURN
    IF A = 20 THEN PGPRT 2, "You can't drop " + AN$(A) + ".": SUC = 0: RETURN
    IF IV THEN GOSUB RATTLE.MONSTER
    SUC = -1
    RETURN
Drop.Armor:
    IF A = ArmPtr THEN ArmPtr = 0
    IF A = ShdPtr THEN ShdPtr = 0
    MD%(0, 8) = MD%(0, 8) - AD%(A, 7)
    EA = EA + AD%(A, 5)
    W = MD%(0, 9)
    MD%(0, 10) = MD%(0, 2) * 2 + WA%(AD%(W, 6)) + AD%(W, 5) - ((EA + AE) * ABS(-EA > AE))
    RETURN
Ready.Armor:
    MD%(0, 8) = MD%(0, 8) + AD%(A, 7)
    EA = EA - AD%(A, 5)
    W = MD%(0, 9)
    MD%(0, 10) = MD%(0, 2) * 2 + WA%(AD%(W, 6)) + AD%(W, 5) - ((EA + AE) * ABS(-EA > AE))
    RETURN
' ---------------------------------------------------------------------------
LOOK.RTN:
    IF LT = 0 AND (Room > 45 AND Room < 61) THEN PGPRT 2, "You see nothing.": GOTO MAIN.LOOP
    LK = 0
    IF S$ = "" THEN GOTO GENERAL.LOOK
    GOSUB EXAMINE.NONART
    IF LK THEN GOTO GET.BACK
    WH = Room
    HA = -1
    EMB = Room + EMB.ADJ
    GOSUB LOCATE.ARTIFACT
    IF FOUND THEN IF AD%(A, KA.ROOM) = EMB THEN AD%(A, KA.ROOM) = Room
    IF FOUND THEN GOSUB EXAMINE.ARTIFACT: GOTO GET.BACK
    WH = Room
    HA = -1
    EMB = Room + EMB.ADJ
    GOSUB LOCATE.MONSTER
    IF FOUND THEN IF MD%(M, KM.ROOM) = EMB THEN MD%(M, KM.ROOM) = Room: GOSUB CHK.REACTIONS
    IF FOUND THEN GOSUB EXAMINE.MONSTER
GENERAL.LOOK:      ' GENERAL.LOOK
    IF S$ <> "" THEN GOTO NOTHIN.TA.SEE
    FOR A = 1 TO NA
    IF AD%(A, KA.ROOM) = HID.ADJ + Room THEN LK = -1: GOSUB FIND.ARTIFACT
    NEXT
    FOR M = 1 TO NM
	IF MD%(M, KM.ROOM) = HID.ADJ + Room THEN LK = -1: GOSUB FIND.MONSTER
    NEXT
    IF LK THEN PGPRT 2, "You found something.": GOTO GET.BACK
    FOR X = 1 TO ND
    IF RD%(X) < 0 AND RD%(X) >= -NR THEN GOSUB SECRET.PASSAGE
    NEXT
NOTHIN.TA.SEE:      ' NOTHIN.TA.SEE
    V%(Room) = 0
    GOTO GET.BACK
EXAMINE.MONSTER:      ' EXAMINE.MONSTER
    R = M + MAX.EFF
    GOSUB PRINT.EFFECT
    RETURN
EXAMINE.NONART:      ' EXAMINE.NONART (S$)
    RETURN
SECRET.PASSAGE:
    RD%(X) = ABS(RD%(X))
    V%(Room) = 2
    IF LK = 0 THEN PGPRT 2, "You found a secret passage " + C$(X) + "!": NX = NX + 1
    RETURN
EXAMINE.ARTIFACT:
'     === EXAM ART A
    IF AD%(A, KA.TYPE) = KT.MONSTER.DISGUISED THEN
	M = AD%(A, 5)
	R = AD%(A, 6)
	GOSUB PRINT.EFFECT
	GOSUB FIND.MONSTER
    END IF
    IF A > NZ THEN PGPRT 2, "This is your " + AN$(A) + "."
    IF A > NZ - NM THEN PGPRT 2, "Yes, he's dead!": RETURN
    GET #2, A + ART.ADJ
    A$ = RTRIM$(Desc$)
    PGPRT 2, A$
    LK = -1
    AD%(A, 9) = 1
    RETURN
FIND.ARTIFACT:      ' FIND.ARTIFACT
'      == DISCOVER ARTIFACT A HIDDEN IN ROOM!
'    --- INSERT HERE ANY SPECIAL DISCOVERY MESSAGES ---
'        SUCH AS "YOU FOUND SOMETHING UNDER THE BED"
    LK = -1
    AD%(A, KA.ROOM) = Room
    RETURN
FIND.MONSTER:
    LK = -1
    MD%(M, KM.ROOM) = Room
    FR = MD%(M, KM.FRIEND)
    IF FR > 0 AND FR <> 100 THEN FR = FR + INT((CH - 10) * 2)
    MD%(M, KM.REACTION) = 1
    IF FR > (100 * RND(1)) THEN MD%(M, KM.REACTION) = 2: IF FR > (100 * RND(1)) THEN MD%(M, KM.REACTION) = 3
    REAC = MD%(M, KM.REACTION)
    FD%(REAC) = FD%(REAC) + MD%(M, KM.DAMAGE)
    TD%(REAC) = TD%(REAC) + MD%(M, KM.HARD)
    NBTL = (TD%(1) > 0)
    RETURN
' ---------------------------------------------------------------------------
ATTACK.RTN:
    GOSUB GET.SUBJ
    IF LT = 0 AND (Room > 45 AND Room < 61) THEN PGPRT 2, "You swing wild --- nothing hit.": GOTO GET.BACK
    GOSUB MONSTER.SEARCH
    IF FOUND THEN GOTO ATTACK.MONSTER
    PGPRT 2, "Attack who?"
    GOTO MAIN.LOOP
ATTACK.MONSTER:
    IF MD%(0, KM.WEAPON) = -1 THEN PGPRT 2, "You have no weapon ready!": GOTO MAIN.LOOP
    OF = 0
    DF = M
    GOSUB TAKE.A.SWING
    IF HIT = 0 THEN GOTO MISSED
    IF INC THEN W2 = AD%(MD%(0, KM.WEAPON), 6): WA%(W2) = WA%(W2) + 2
    IF -EA <= AE THEN GOTO GET.BACK
    IF INT(100 * RND(1) + 1) <= MD%(0, KM.O.ODDS) THEN GOTO MISSED
    A = 2
    IF EA + AE = -1 THEN A = 1
    AE = AE + A
    MD%(0, KM.O.ODDS) = MD%(0, KM.O.ODDS) + A
MISSED:
    IF MD%(DF, KM.REACTION) = 1 OR DF = 0 THEN GOTO GET.BACK
    MD%(DF, KM.FRIEND) = MD%(DF, KM.FRIEND) / 2
    FOR M = 1 TO NM
    IF MD%(M, KM.ROOM) = Room AND MD%(M, KM.REACTION) > 1 THEN MD%(M, KM.REACTION) = 0
    NEXT
    R3 = Room
    GOSUB CHK.REACTIONS
    GOTO GET.BACK
MON.GET.GUN:      ' MON.GET.GUN
'    -- MONSTER PICK-UP WEAPON
    IF MD%(OF, KM.O.ODDS) = 0 THEN RETURN
    A = 0
    FOR X = 1 TO NA
    IF AD%(X, KA.ROOM) = Room AND (AD%(X, KA.TYPE) = 2 OR AD%(X, KA.TYPE) = 3) THEN A = X: X = NA
    NEXT
    IF A = 0 THEN RETURN
    PGPRT 2, MN$(OF) + " picks up " + AN$(A) + "."
    AD%(A, KA.ROOM) = 0
    MD%(OF, KM.WEAPON) = A
    MD%(OF, KM.O.ODDS) = MD%(OF, KM.O.ODDS) + AD%(A, 5)
    MD%(OF, KM.COURAGE) = MD%(OF, KM.COURAGE) * 2
    RETURN
TAKE.A.SWING:
    HIT = 0
    IF MD%(OF, KM.WEAPON) = -1 THEN GOTO MON.GET.GUN
    IF DF = 0 AND IV THEN RETURN
    PGPRT 2, MN$(OF) + " attacks " + MN$(DF)
    PRINT " --";
    RL = INT(100 * RND(1) + 1)
    HIT = 0
    IF (RL < 5 OR RL < MD%(OF, KM.O.ODDS) - MD%(DF, KM.D.ODDS)) AND RL < 96 THEN HIT = 1
    IF HIT = 0 AND MD%(DF, KM.D.ODDS) > MD%(OF, KM.O.ODDS) / 2 THEN PGPRT 1, MN$(DF) + " dodges out of the way!"
    IF HIT THEN GOTO A.HIT
    IF RL < 97 THEN PGPRT 1, " A miss!": RETURN
    PGPRT 1, "A fumble!"
    FR = INT(100 * RND(1) + 1)
    IF FR <= 35 + 40 * ABS(MD%(OF, KM.WEAPON) = 0) THEN PGPRT 1, "   fumble recovered.": RETURN
    IF FR < 76 THEN
	PGPRT 1, "  weapon dropped!"
	AD%(MD%(OF, KM.WEAPON), KA.ROOM) = Room
	MD%(OF, KM.O.ODDS) = MD%(OF, KM.O.ODDS) - AD%(MD%(OF, KM.WEAPON), 5)
	MD%(OF, KM.WEAPON) = -1
	MD%(OF, KM.COURAGE) = MD%(OF, KM.COURAGE) / 2
	RETURN
    END IF
    IF MD%(OF, KM.WEAPON) > 0 THEN W = MD%(OF, KM.WEAPON): IF AD%(W, KA.TYPE) = 3 THEN PGPRT 1, "Sparks fly from " + AN$(W) + "!": RETURN
    IF FR > 95 THEN GOTO SELF.OUCH
    PGPRT 1, "  weapon breaks!"
    AD%(MD%(OF, KM.WEAPON), KA.ROOM) = 0
    MD%(OF, KM.O.ODDS) = MD%(OF, KM.O.ODDS) - AD%(MD%(OF, KM.WEAPON), 5)
    MD%(OF, KM.WEAPON) = -1
    MD%(OF, KM.COURAGE) = MD%(OF, KM.COURAGE) / 2
    IF RND(1) > .5 THEN RETURN
    PGPRT 1, "  broken weapon hurts user!"
SELF.OUCH:
    IF FR = 100 THEN GOTO SELF.YEOW
    D = MD%(OF, KM.DICE)
    S = MD%(OF, KM.SIDES)
    DF = OF
    A = 1
    GOTO DO.DAMAGE
SELF.YEOW:
    D = MD%(OF, KM.DICE) * 2
    S = MD%(OF, KM.SIDES)
    DF = OF
    A = 0
    GOTO DO.DAMAGE
A.HIT:
    INC = ABS(INT(100 * RND(1) + 1) > MD%(OF, KM.O.ODDS))
    MD%(OF, KM.O.ODDS) = MD%(OF, KM.O.ODDS) + 2 * INC
    D = MD%(OF, KM.DICE)
    S = MD%(OF, KM.SIDES)
    A = 1
    IF RL > 5 THEN PGPRT 1, "a Hit!": GOTO DO.DAMAGE
    PGPRT 1, "A critical hit!"
    R2 = INT(100 * RND(1) + 1)
    IF R2 < 51 THEN A = 0: GOTO DO.DAMAGE
    IF R2 < 86 THEN S = 1.5 * S: GOTO DO.DAMAGE
    IF R2 < 96 THEN D = 2 * D: GOTO DO.DAMAGE
    IF R2 < 100 THEN D = 3 * D: GOTO DO.DAMAGE
    GOTO IS.DEAD
DO.DAMAGE:      ' DO.DAMAGE
    D2 = 0
    FOR D3 = 1 TO D
    D2 = D2 + INT(S * RND(1) + 1)
    NEXT
    D2 = D2 - A * MD%(DF, KM.ARMOR)
    IF D2 < 1 THEN PGPRT 1, "   blow bounces off armour.": RETURN
APPLY.DAMAGE:      ' APPLY.DAMAGE
    MD%(DF, KM.DAMAGE) = MD%(DF, KM.DAMAGE) + D2
    IF MD%(DF, KM.DAMAGE) >= MD%(DF, KM.HARD) THEN GOTO DEAD.RTN
    A = MD%(DF, KM.REACTION)
    FD%(A) = FD%(A) + D2
SHOW.CONDITION:
    A$ = MN$(DF)
    ON INT(MD%(DF, KM.DAMAGE) * 5 / MD%(DF, KM.HARD) + 1) GOTO GOOD.SHAPE, HURTING, IN.PAIN, BADLY.INJURED, DEATHS.DOOR
GOOD.SHAPE:      ' GOOD.SHAPE
    PGPRT 2, A$ + " is still in good shape."
    RETURN
HURTING:      ' HURTING
    PGPRT 2, A$ + " is hurting."
    RETURN
IN.PAIN:      ' IN.PAIN
    PGPRT 2, A$ + " is in pain."
    RETURN
BADLY.INJURED:      ' BADLY.INJURED
    PGPRT 2, A$ + " is very badly injured."
    RETURN
DEATHS.DOOR:      ' DEATHS.DOOR
    PGPRT 2, A$ + " is at death's door, knocking loudly."
    RETURN
DEAD.RTN:
    IF DF = 0 THEN PGPRT 2, "You are dead!": DIE = -1: GOTO Game.Over
IS.DEAD:      ' IS.DEAD
'    /// MONSTER DIES
    PGPRT 2, MN$(DF) + " is dead!"
    A = MD%(DF, KM.REACTION)
    FD%(A) = FD%(A) + MD%(DF, KM.HARD) - MD%(DF, KM.DAMAGE) + D2
    MD%(DF, KM.ROOM) = 0
    IF DF = 17 THEN RETURN
    FOR AJ = 1 TO NA
    IF AD%(AJ, 4) = -DF - 1 THEN AD%(AJ, 4) = Room
    NEXT
    IF MD%(DF, KM.WEAPON) > 0 THEN AD%(MD%(DF, KM.WEAPON), KA.ROOM) = Room: MD%(DF, KM.O.ODDS) = MD%(DF, KM.O.ODDS) - AD%(MD%(DF, KM.WEAPON), 5): MD%(DF, KM.WEAPON) = -1: MD%(DF, KM.COURAGE) = MD%(DF, KM.COURAGE) / 2
GET.BODY:
    IF DF = 0 THEN DIE = 1: GOTO Game.Over
    A2 = DF + NZ - NM
    AD%(A2, KA.ROOM) = Room
    RETURN
FLEE.RTN:
    IF RND(1) > MD%(0, 2) / 25 THEN COLOR HFG%, HBG%: PGPRT 2, "Your exit was blocked!!!": COLOR FGC%, BGC%: GOTO GET.BACK
    IF NBTL = 0 THEN PGPRT 2, "There's nothing to flee from!": GOTO MAIN.LOOP
    IF NX = 0 THEN PGPRT 2, "There's no place to go!": GOTO MAIN.LOOP
    IF LM THEN PGPRT 2, "By running away, you blew out your lamp!": LT = NL: LS = 0: LM = 0
    IF S$ <> "" THEN
	C = 0
	FOR D = 1 TO ND
	    IF S$ = LEFT$(UCASE$(C$(D)), LEN(S$)) THEN C = D: Exit For
	NEXT
	IF C > 0 THEN V$ = S$: S$ = "FLEE": GOTO MOVE.RTN
    END IF
    GOSUB FIND.EXIT
    GOTO MOVE.IT
FIND.EXIT:
    IF NX = 0 THEN R2 = Room: PGPRT 1, " ... but can't find an exit!": RETURN
    R2 = RD%(ND * RND(1) + 1)
    IF R2 < 1 OR R2 > NR THEN GOTO FIND.EXIT
    RETURN
' ---------------------------------------------------------------------------
GIVE.RTN:
    IF S$ = "" THEN GOSUB GET.SUBJ
    A = 0
    M = 0
    M$ = ""
    A$ = ""
    SEP = INSTR(S$, " TO ")
    IF SEP > 0 THEN
	A$ = LEFT$(S$, SEP - 1)
	M$ = MID$(S$, SEP + 4)
	GOTO READY.SEARCH.GIVE
    END IF
    SEP = INSTR(S$, " ")
    IF SEP > 0 THEN
	NBR.SP = 0
	SP = SEP + 1
	DO UNTIL SP = 0
	  SAVE.S$ = S$
	  S$ = LEFT$(S$, SP - 2)
	  GOSUB MONSTER.SEARCH
	  IF FOUND THEN
	      M$ = S$
	      A$ = MID$(SAVE.S$, SP)
	      GOTO READY.SEARCH.GIVE
	  END IF
	  NBR.SP = NBR.SP + 1
	  SP = INSTR(SP + 1, S$, " ")
	LOOP
	IF NBR.SP = 1 THEN
	    A$ = MID$(S$, SEP + 1)
	    M$ = LEFT$(S$, SEP - 1)
	ELSE
	    GOSUB GIVE.WHO
	    GOSUB GIVE.WHAT
	END IF
    ELSE
	GOSUB ARTIFACT.SEARCH
	IF FOUND THEN
	    A$ = AN$(A)
	ELSE
	    GOSUB MONSTER.SEARCH
	    IF FOUND THEN
		M$ = MN$(M)
		GOSUB GIVE.WHAT
	    END IF
	END IF
    END IF
READY.SEARCH.GIVE:
    GOSUB GIVE.WHO
    GOSUB GIVE.WHAT
    IF M = 0 THEN
	S$ = M$
	GOSUB MONSTER.SEARCH
    END IF
    IF A = 0 THEN
	IF A$ = MID$(STR$(VAL(A$)), 2) THEN GG = -1 ELSE GG = 0
	IF GG = 0 THEN
	    S$ = A$
	    GOSUB ARTIFACT.SEARCH
	END IF
    END IF
    IF M > 0 AND GG <> 0 THEN GOTO GIVE.GOLD
    IF M > 0 AND A > 0 THEN GOTO RESOLVE.GIVE
    PGPRT 2, "I don't know what you mean."
    GOTO MAIN.LOOP
RESOLVE.GIVE:      ' RESOLVE.GIVE
    PGPRT 2, "Okay."
    POP = 0
    GOSUB GIVE.ART.MON
    IF POP <> 0 THEN GOTO MAIN.LOOP
    IF A = MD%(0, 9) THEN MD%(0, 9) = -1
    AD%(A, 4) = -M - 1
    MD%(M, 14) = 0
    IF MD%(M, 3) < 100 THEN MD%(M, 3) = MD%(M, 3) * (1 + AD%(A, 1) / 100)
    IF MD%(M, 10) <> 0 AND MD%(M, 9) = -1 THEN MD%(M, 9) = A: MD%(M, 10) = MD%(M, 9) + AD%(A, 5): MD%(M, 4) = 2 * MD%(M, 4)
COMPLETE.GIVE:
    R3 = Room
    GOSUB CHK.REACTIONS
    GOTO CHK.WGHT
GIVE.ART.MON:
 ' PUT SPECIAL CODE HERE FOR GIVING ITEM (A) TO MONSTER (M)
 ' IF MONSTER REFUSES OR SOME SPECIAL ACTION WHERE ITEM DOESN'T CHANGE
 ' HANDS OCCURS, THEN SET POP = -1 AND RETURN FROM THIS ROUTINE.
    IF A = ARMPTR OR A = SHDPTR THEN GOSUB DROP.ARMOR
    IF A = KH.GOLDEN.SWORD THEN PRINT 2, "You can't let go of it!.": SUC = 0: GOTO GET.BACK
    RETURN
GIVE.GOLD:
    IF VAL(A$) > GOLD& THEN PGPRT 2, "You aren't carrying that much gold!": GOTO GET.BACK
    GOLD& = INT(GOLD& - VAL(A$))
    MD%(M, 0) = MD%(M, 0) + INT(VAL(A$))
    MD%(M, 14) = 0
    IF MD%(M, 3) < 100 THEN MD%(M, 3) = MD%(M, 3) * (1 + VAL(A$) / 100)
    GOTO COMPLETE.GIVE
GIVE.WHO:
    IF M$ = "" THEN INPUT "Who to give to? ", M$: M$ = UCASE$(M$): GOTO GIVE.WHO
    RETURN
GIVE.WHAT:
    IF A$ = "" THEN INPUT "What to give? ", A$: A$ = UCASE$(A$): GOTO GIVE.WHAT
    RETURN
' ---------------------------------------------------------------------------
INVENTORY.RTN:
    IF IV THEN PGPRT 2, "You see nothing.": GOTO MAIN.LOOP
    PGPRT 2, "You are carrying the following--"
    FOR A = 1 TO NA
    IF AD%(A, 4) = -1 THEN
	PRINT " " + AN$(A);
	IF A = MD%(0, 9) THEN PRINT " (Ready weapon)";
	IF A = ArmPtr THEN PRINT " (Worn armor)";
	IF A = ShdPtr THEN PRINT " (Your shield)";
	PGPRT 1, " "
    END IF
    NEXT
    PGPRT 1, STR$(GOLD&) + " gold pieces."
    GOTO GET.BACK
' --------------------------------------------------------------------------
BLAST.SPELL:
    GOSUB GET.SUBJ
    GOSUB MONSTER.SEARCH
    IF FOUND = 0 THEN GOTO BLASTED.DOOR
BLAST.MONSTER:
    S = 1
    GOSUB CAST.SPELL
    IF SUC = 0 THEN GOTO GET.BACK
    PGPRT 2, "Direct Hit!"
    S = 5
    D = 2
    DF = M
    A = 0
    GOSUB DO.DAMAGE
    GOTO GET.BACK
BLASTED.DOOR:
'    /// BLAST DOOR/GATE OR CONTAINER?
    TA = 1
    GOTO ASSAULT.ARTIFACT
' ---------------------------------------------------------------------------
CAST.SPELL:
    SUC = 0
    IF SA%(S) THEN RL = INT(100 * RND(1) + 1): SUC = (((RL < S2%(S)) OR (RL < 5)) AND (RL < 95)): IF RL = 100 THEN SUC = 0
    IF SUC = 0 THEN PGPRT 2, "Nothing happened.": RETURN
    RL = INT(100 * RND(1) + 1)
    IF RL > S2%(S) THEN S2%(S) = S2%(S) + 2: SA%(S) = SA%(S) + 2
    S2%(S) = S2%(S) * .8
    RETURN
' ---------------------------------------------------------------------------
HEAL.SPELL:
    S = 2
    GOSUB CAST.SPELL
    IF SUC = 0 THEN GOTO GET.BACK
HEAL.WOUNDS:
    M = 0
    IF S$ <> "" THEN GOSUB MONSTER.SEARCH
    IF M = 0 THEN S$ = "your" ELSE S$ = MN$(M) + "'s"
    IF MD%(M, KM.DAMAGE) THEN
	PGPRT 2, "Some of " + S$ + " wounds seem to clear up."
	MD%(M, KM.DAMAGE) = MD%(M, KM.DAMAGE) - INT(10 * RND(1) + 1)
    END IF
    IF MD%(M, KM.DAMAGE) < 0 THEN MD%(M, KM.DAMAGE) = 0
    DF = M
    GOSUB SHOW.CONDITION
    GOTO GET.BACK
' --------------------------------------------------------------------------
POWER.SPELL:
    S = 4
    GOSUB CAST.SPELL
    IF SUC = 0 THEN GOTO GET.BACK
    RR = INT(RND(1) * 100 + 1)
GEN.EFFECT:
    X = FNR(8)
    ON X GOTO POWER.1, RESTORE.SPELLS, ARMOR.GONE, TELEPORT.RTN, UPGRADE.WEAPON, UPGRADE.ARMEXP, POWER.HEAL, POWER.FLAME
POWER.1:  ' //BACK ALIVE
    RAISE = 0
    FOR M = 1 TO NM
	GOSUB RAISE.DEAD
    NEXT M
    IF RAISE THEN GOTO GET.BACK
    GOTO GEN.EFFECT
RESTORE.SPELLS:  ' ///RESTORE SPELLS
    FOR J = 1 TO 3
      S2%(J) = SA%(J)
    NEXT
    PGPRT 2, "Your spells are back at their original level!!"
    GOTO GET.BACK
ARMOR.GONE:  ' ///ARMOUR GONE
    IF FNR(100) > 50 THEN PGPRT 2, "Poof! Your armour just disappeared!!!": MD%(0, 8) = 0: AC = 0: GOTO GET.BACK
    PGPRT 2, "You felt a twitch, then realized that you have forgotten your armour expertise": AE = 0
    A = MD%(0, 9)
    GOTO CALCULATE.ODDS
TELEPORT.RTN:  ' ///TELEPORT
    PGPRT 2, "You feel very strange and suddenly find ... "
    R2 = INT(RND(1) * 10 + 10)
    GOTO MOVE.IT
UPGRADE.WEAPON: ' ///UP WEAPON STATS
    UP = 0
    FOR A = 1 TO NA
      IF AD%(A, 2) > 1 AND RND(1) > .8 AND AD%(A, 4) = -1 THEN GOSUB UPGRADE.WEAP
    NEXT
    IF UP = 0 THEN GOTO GEN.EFFECT
    GOTO GET.BACK
UPGRADE.WEAP:
    D = AD%(A, 7)
    S = AD%(A, 8)
    CP = AD%(A, 5)
    IF D > 1 THEN
	CP = CP + INT(RND(1) * 5 + 2)
	PGPRT 2, "complexity on " + AN$(A) + " went up."
	GOTO WEAP.MOD.DONE
    END IF
    IF S > 5 THEN
	S = S + INT(RND(1) * S / 2 + 1)
	GOTO WEAP.MOD.DONE
    ELSE
	D = D + 1
    END IF
    PGPRT 2, "Damage points on " + AN$(A) + " went up!"
WEAP.MOD.DONE:
    UP = 1
    AD%(A, 7) = D
    AD%(A, 8) = S
    AD%(A, 5) = CP
    RETURN
UPGRADE.ARMEXP:  ' ///UP AE
       IF FNR(65) > AE THEN PGPRT 2, "Your armour expertise went up!": AE = AE + INT(RND(1) * 5 + 5): GOTO GET.BACK
       A$ = "You hear a rush of wind."
       IF LT THEN
	   A$ = A$ + "The wind blows out your lantern."
	   LT = 0
       ELSE
	   A$ = A$ + " nothing happens, however."
       END IF
       PGPRT 2, A$
       GOTO GET.BACK
POWER.FLAME:  ' ///FLAME
    PGPRT 2, "A flame erupts from the floor, engulfing you and burning you."
    IF AD%(26, 4) = -1 THEN
	PGPRT 2, "The chemical you were carrying just exploded!! You were hurt by the explosion."
	S = 10
	D = 1
	A = 0
	DF = 0
	GOSUB DO.DAMAGE
	GOTO GET.BACK
    END IF
    PGPRT 2, "You were burned by the flame."
    S = 10
    D = 1
    A = 0
    DF = 0
    GOSUB DO.DAMAGE
    GOTO GET.BACK
POWER.HEAL:
    PGPRT 2, "Some of your wounds seem to clear up."
    MD%(0, 13) = MD%(0, 13) - INT(RND(1) * 6 + 1)
    IF MD%(0, 13) < 0 THEN MD%(0, 13) = 0
    DF = 0
    GOSUB SHOW.CONDITION
    GOTO GET.BACK
RAISE.DEAD:
    M2 = NZ - NM + M
    IF AD%(M2, KA.ROOM) = Room OR AD%(M2, KA.ROOM) = -1 THEN
	PGPRT 2, MN$(M) + " comes to life!!"
	RAISE = -1
	MD%(M, KM.DAMAGE) = 0
	MD%(M, KM.ROOM) = Room
	IF AD%(M2, KA.ROOM) = -1 THEN WT = WT - AD%(M2, KA.WEIGHT)
	AD%(M2, KA.ROOM) = 0
     END IF
     RETURN
' --------------------------------------------------------------------------
SPEED.SPELL:
    S = 3
    GOSUB CAST.SPELL
    IF SUC = 0 THEN GOTO GET.BACK
    IF SPD <> 0 THEN PGPRT 2, "Nothing Happens.": GOTO MAIN.LOOP
DO.SPEED:
    MD%(0, KM.O.ODDS) = MD%(0, KM.O.ODDS) + 2 * MD%(0, KM.AGIL)
    MD%(0, KM.AGIL) = 2 * MD%(0, KM.AGIL)
    SPD = SPD + INT(25 * RND(1) + 10)
    PGPRT 2, "You can feel the new agility flowing through you!"
    GOTO GET.BACK
' --------------------------------------------------------------------------
SMILE.RTN:
    IF IV THEN GOTO GET.BACK
    PGPRT 1, " "
    FOR M = 1 TO NM
      IF MD%(M, KM.ROOM) = Room AND MD%(M, KM.STATUS) <= 1 THEN
	  ON MD%(M, KM.REACTION) GOSUB GROWLS, IGNORES, SMILES
      END IF
    NEXT
    PGPRT 1, " "
    GOTO GET.BACK
GROWLS:
    PGPRT 1, MN$(M) + " growls at you!"
    RETURN
IGNORES:
    PGPRT 1, MN$(M) + " ignores you."
    RETURN
SMILES:
    PGPRT 1, MN$(M) + " " + LCASE$(C$(C)) + "s back."
    RETURN
' --------------------------------------------------------------------------
SAY.SOMETHING:
    GOSUB GET.SUBJ
    IF S$ = "BLAST" THEN V$ = S$: S$ = "": GOTO BLAST.SPELL
    IF S$ = "HEAL" THEN GOTO HEAL.SPELL
    IF S$ = "POWER" THEN GOTO POWER.SPELL
    IF S$ = "SPEED" THEN GOTO SPEED.SPELL
    IF S$ = "ANDERHAUF" AND AD%(17, 4) = -1 THEN PGPRT 2, "As you say the word, you feel the sword vibrate and ...": PGPRT 2, "POOF!": AD%(17, 4) = INT(RND(1) * 77 + 1): GOTO GET.BACK
    IF S$ = "GILGAMESH" AND AD%(20, 4) = -1 THEN PGPRT 2, "The sword leaves your hand and transforms itself into a huge demon!": MD%(15, 5) = Room: AD%(20, 4) = 0: MD%(0, 9) = -1: R3 = Room: GOSUB CHK.REACTIONS: GOTO GET.BACK
    IF S$ = "EAMON" AND Room = 52 THEN PGPRT 2, "You hear a rumbling noise, and find...": R2 = INT(RND(1) * 7) + 10: GOTO MOVE.IT
    IF S$ = "INVINCIBLE" THEN MD%(0, 1) = 999: GOSUB CHK.REACTIONS: PGPRT 2, "You feel your strength multiply!!": GOTO GET.BACK
    PGPRT 2, "Okay, " + CHR$(34) + S$ + CHR$(34)
    IF IV THEN GOSUB RATTLE.MONSTER
    GOTO GET.BACK
' --------------------------------------------------------------------------
READY.WEAPON:
    GOSUB GET.SUBJ
    WH = -1
    HA = WH
    EMB = HA
    GOSUB LOCATE.ARTIFACT
    IF FOUND = 0 THEN PGPRT 2, "You aren't carrying it!": GOTO MAIN.LOOP
    IF A = KH.GOLDEN.SWORD THEN PGPRT 2, "You can't drop it.": GOTO GET.BACK
    IF AD%(A, KA.TYPE) < WEAPON.ART OR AD%(A, KA.TYPE) > 3 THEN PGPRT 2, "That isn't a weapon!": GOTO MAIN.LOOP
CALCULATE.ODDS:
    MD%(0, KM.O.ODDS) = (EA + AE) * ABS(-EA > AE) + AD%(A, 5) + WA%(AD%(A, 6)) + 2 * MD%(0, 2)
    MD%(0, KM.WEAPON) = A
    MD%(0, KM.DICE) = AD%(A, 7)
    MD%(0, KM.SIDES) = AD%(A, 8)
    PGPRT 2, "Readied."
    GOTO GET.BACK
' --------------------------------------------------------------------------
ASSAULT.ARTIFACT:
    WH = Room
    HA = Room
    EMB = Room + EMB.ADJ
    GOSUB LOCATE.ARTIFACT
    IF FOUND = 0 THEN
	IF TA = 0 THEN PGPRT 2, "Attack who?": GOTO MAIN.LOOP
	PGPRT 2, "You can't blast " + LCASE$(S$) + "!"
	GOTO MAIN.LOOP
    END IF
    IF AD%(A, KA.TYPE) = KT.MONSTER.DISGUISED THEN
	M = AD%(A, 5)
	GOSUB BRING.IN.BEASTS
	ON TA + 1 GOTO ATTACK.MONSTER, BLAST.MONSTER
    END IF
    IF AD%(A, KA.TYPE) <> DOOR.ART AND AD%(A, KA.TYPE) <> CONTAIN.ART THEN
	PGPRT 2, "Why would you want to attack that?!"
	GOTO MAIN.LOOP
    END IF
    IF MD%(0, KM.WEAPON) = -1 THEN PGPRT 2, "You have no weapon ready!": GOTO MAIN.LOOP
    D = MD%(0, KM.DICE)
    S = MD%(0, KM.SIDES)
    IF TA = 1 THEN D = 2: S = 5
    SX = 7: K = 6: IF AD%(A, KM.TYPE) = CONTAIN.ART THEN SX = 6: K = 5
    D2 = 0: FOR X = 1 TO D: D2 = D2 + FNR(S): NEXT
    AD%(A, SX) = AD%(A, SX) - D2
    IF AD%(A, SX) <= 0 THEN AD%(A, SX) = 0: AD%(A, K) = 0: PGPRT 2, "The " + AN$(A) + " shatters!": GOTO GET.BACK
    PGPRT 2, "WHAM!! You " + MID$("hitblast", TA * 3 + 1, 3 + TA * 2) + " the " + AN$(A) + "!"
    GOTO GET.BACK
CHK.OPEN.SPECIAL:
    RETURN
' --------------------------------------------------------------------------
PRINT.EFFECT:
    GET #2, R + EFF.ADJ
    A$ = RTRIM$(Desc$)
    PGPRT 2, A$
    RETURN
' --------------------------------------------------------------------------
LIGHT.RTN:
       GOSUB GET.SUBJ
       GOSUB ARTIFACT.SEARCH
     IF FOUND = 0 THEN PGPRT 2, "Light what??": GOTO GET.BACK
     IF AD%(8, 4) <> -1 AND AD%(9, 4) <> -1 THEN PGPRT 2, "You have nothing to light it with.": GOTO GET.BACK
     IF LT = 0 AND (Room > 45 AND Room < 61) THEN PGPRT 2, "You can't light it now.": GOTO GET.BACK
     IF A = 9 THEN GOTO LANTERN.RTN
     IF A = 10 THEN GOTO LIGHT.POWDER
     PGPRT 2, "I don't understand."
     GOTO GET.BACK
LIGHT.POWDER:
     PGPRT 1, " "
     COLOR HFG%, HBG%
     PGPRT 1, " ----- KABOOM! -----"
     COLOR FGC%, BGC%
     IF AD%(10, 4) = -1 THEN PGPRT 2, "You lit the powder while it was in your hands (Ooh, THAT HURT!)": S = 10: D = 1: DF = 0: A = 0: GOSUB DO.DAMAGE: GOTO POWDER.GONE
     IF Room <> 37 THEN GOTO BLOW.CEILING
     PGPRT 2, "The explosion blew a hole in the doorway that was bricked up.": AD%(11, 4) = 0: AD%(12, 4) = Room: GOTO POWDER.GONE
BLOW.CEILING:
     IF Room > 30 AND RND(1) > .5 THEN PGPRT 2, "You knocked a chunk of the ceiling loose which hits you on the head!": S = 6: D = 1: A = 0: DF = 0: GOSUB DO.DAMAGE: GOTO POWDER.GONE
     PGPRT 2, "Apparently, nothing happened."
POWDER.GONE:
    AD%(10, 4) = 0
    GOTO GET.BACK
LANTERN.RTN:
    IF LT THEN PGPRT 2, "The lantern is already lit.": GOTO GET.BACK
    PGPRT 2, "OK."
    LT = 1
    GOTO GET.BACK
DRINK.RTN:
    GOSUB GET.SUBJ
    GOSUB ARTIFACT.SEARCH
    IF FOUND = 0 THEN PGPRT 2, "I don't know what you're talking about.": GOTO MAIN.LOOP
    IF A = 18 THEN GOTO DRINK.HEALING
    IF A = 10 THEN PGPRT 2, "As you raise the bottle to your lips, it suddenly vanishes!": AD%(10, 4) = 0: GOTO GET.BACK
    PGPRT 2, "You can't drink that!": GOTO GET.BACK
DRINK.HEALING:
    IF AD%(18, 4) <> -1 THEN PGPRT 2, "You aren't carrying it!": GOTO GET.BACK
    AD%(18, 4) = 0
    AD%(19, 4) = -1
    PGPRT 2, "UGH! The potion was poison!!!"
    S = 6
    D = 1
    A = 0
    DF = 0
    GOSUB DO.DAMAGE
    GOTO GET.BACK
GUARD.ENTERS:  '  GUARD WALKS IN?
    IF Room < 8 THEN RETURN
    FOR J = 16 TO 18: IF MD%(J, 5) <> Room AND MD%(J, 5) AND RND(1) > .85 THEN PGPRT 2, MN$(J) + " just walked in!": MD%(J, 5) = Room: R3 = Room: GOSUB CHK.REACTIONS
    NEXT J
    FOR J = 2 TO 4: IF MD%(J, 5) <> Room AND MD%(J, 5) AND RND(1) > .9 THEN PGPRT 2, MN$(J) + " just walked in!": MD%(J, 5) = Room: R3 = Room: GOSUB CHK.REACTIONS
    NEXT J
    IF MD%(1, 5) <> 0 OR RND(1) < .93 THEN RETURN
    IF AD%(1 + NZ - NM, 4) = -1 THEN RETURN
    COLOR HFG%, HBG%
    PGPRT 2, "The Abductor just teleported into the room!!!"
    COLOR FGC%, BGC%
    MD%(1, 5) = Room
    R3 = Room
    GOSUB CHK.REACTIONS
    MD%(1, 9) = 24
    A2 = 1 + NZ - NM
    AD%(A2, 4) = 0
    RETURN
IMPRISON.PLAYER:  ' ///STASH DEAD CHARACTER
       IF DIE = 0 THEN RETURN
       CLS
       PGPRT 0, " "
       PGPRT 2, "Suddenly, you find yourself jolted back to life by a power spell. You are now "
       PGPRT 2, "chained to a wall in the dungeon of the nasty Abductor. Hopefully, someone will"
       PGPRT 2, "come along and rescue you."
       IF MN$(6) <> "Kathryn" THEN
	   PGPRT 2, "As you look on, you see the head of your friend roll from the headsman's axe."
	   PGPRT 2, " "
       END IF
       PGPRT 99, ""
       KILL PATH$ + "LASTCHAR.TXT"
       OPEN PATH$ + "LASTCHAR.TXT" FOR OUTPUT AS #2
       WRITE #2, MN$(0)
       WRITE #2, MD%(0, 1)
       WRITE #2, MD%(0, 2)
       WRITE #2, CH
       FOR A = 1 TO 4: WRITE #2, SA%(A): NEXT
       FOR A = 1 TO 5: WRITE #2, WA%(A): NEXT
       WRITE #2, AE
       WRITE #2, SEX$
       WRITE #2, GOLD&
       WRITE #2, BANK&
       IF ArmPtr <> 0 THEN 
       	    WRITE #2, AN$(ArmPtr)
       	    WRITE #2, AD%(ArmPtr, 7)
       	    WRITE #2, AD%(ArmPtr, 5)
       ELSE
           WRITE #2, "NONE"
           WRITE #2, 0
           WRITE #2, 0
       END IF	    
       IF ShdPtr <> 0 THEN 
       	    WRITE #2, AN$(ShdPtr)
       	    WRITE #2, AD%(ShdPtr, 7)
       	    WRITE #2, AD%(ShdPtr, 5)
       ELSE
           WRITE #2, "NONE"
           WRITE #2, 0
           WRITE #2, 0
       END IF	    
       CLOSE 2
       RETURN
FIND.RECNBR:
       GOSUB READ.NBR.CHARS
       R = 0
       FOR J = 1 TO NC
       GET #1, J + 1
       IF UCASE$(FLNAM$) = UCASE$(MN$(0)) THEN R = J: J = NC
       NEXT
       IF R > 0 THEN RETURN
       FOR J = 1 TO NC
	 GET #1, J + 1
	 A$ = FLNAM$
	 IF LEFT$(A$, 5) = "*DEAD" THEN R = J: J = NC + 1
       NEXT
       IF R = 0 THEN
	   NC = NC + 1
	   R = NC
	   GOSUB WRITE.NBR.CHARS
       END IF
       RETURN
THIEF.RTN:
       PGPRT 2, "You feel someone brush against you and say 'Excuse me, sir'. As you turn around"
       PGPRT 1, "you see a figure vanish into the shadows. You also notice your gold sack has"
       PGPRT 1, "cut from your belt!"
       GD = GOLD&
       GOLD& = 0
       IF GD > 32760 THEN GD = 32760
       AD%(21, 1) = GD
       AD%(21, 4) = 32
       RETURN
' --------------------------------------------------------------------------
DIG.RTN:
    FOR X = 1 TO NA
	IF AD%(X, KA.ROOM) = Room + BURY.ADJ THEN FOUND = -1: AD%(X, KA.ROOM) = Room
    NEXT
    FOR M = 1 TO NM
	IF MD%(M, KM.ROOM) = Room + BURY.ADJ THEN FOUND = -1: MD%(M, KM.ROOM) = Room: FOUND = -2: GOSUB BRING.IN.BEASTS
    NEXT
    IF FOUND THEN PGPRT 2, "You found something!"
    GOTO GET.BACK
' ---------------------------------------------------------------------------
SAVE.GAME:
    INPUT "Do you want to save this game? (Y/N) ", SAVE.GM$
    IF UCASE$(LEFT$(SAVE.GM$, 1)) = "Y" THEN GOTO SAVE.IT
    GOTO MAIN.LOOP
SAVE.IT:
    GOSUB GET.GAME.ID
    CLOSE 1
REM $$INCL:'\EAMON\COPY\SAVEGAME.BAS'
'        Eamon Save Game Routine
'
'          by John Nelson
'
        OPEN GAME.ID$ FOR OUTPUT AS #1
        PRINT #1, LT
        PRINT #1, LM
        PRINT #1, LC
        PRINT #1, LS
        PRINT #1, ROOM
        PRINT #1, SPD
        PRINT #1, TT
        PRINT #1, ArmNam$
        PRINT #1, ArmHit
        PRINT #1, ArmAdj
        PRINT #1, ShdNam$
        PRINT #1, ShdHit
        PRINT #1, ShdAdj
        PRINT #1, AE
        FOR X = 1 TO 4
        PRINT #1, SA%(4)
        NEXT
        FOR X = 1 TO 4
        PRINT #1, S2%(4)
        NEXT
        FOR X = 1 TO 5
        PRINT #1, WA%(X)
        NEXT
        FOR M = 0 TO NM
        FOR D = 0 TO 15
        PRINT #1, MD%(M, D)
        NEXT D
        NEXT M
        FOR A = 0 TO NA
        FOR D = 0 TO 9
        PRINT #1, AD%(A, D)
        NEXT D
        NEXT A
        FOR V = 1 TO NR
        PRINT #1, V%(V)
        NEXT V
        PRINT #1, GOLD&
        PRINT #1, BANK&

    '------- (end of include file) -------    
 ' 
    PRINT #1, VC
    PRINT #1, IC
    PRINT #1, IV
    PRINT "Game is saved. To restore it, use restore command."
    SAVED = -1
    CLOSE 1
    GOSUB OPEN.ROOMS
    GOTO MAIN.LOOP
RESTORE.GAME:
    INPUT "Do you want to Restore a game? (Y/N) ", SAVE.GM$
    IF UCASE$(LEFT$(SAVE.GM$, 1)) = "Y" THEN GOTO RESTORE.IT
    GOTO MAIN.LOOP
RESTORE.IT:
    GOSUB GET.GAME.ID
    CLOSE 1
REM $$INCL:'\EAMON\COPY\RESTGAME.BAS'
'        Eamon Restore Game Routine
'
'          by John Nelson
'
        OPEN GAME.ID$ FOR INPUT AS #1
        INPUT #1, LT
        INPUT #1, LM
        INPUT #1, LC
        INPUT #1, LS
        INPUT #1, ROOM
        INPUT #1, SPD
        INPUT #1, TT
        INPUT #1, ArmNam$
        INPUT #1, ArmHit
        INPUT #1, ArmAdj
        INPUT #1, ShdNam$
        INPUT #1, ShdHit
        INPUT #1, ShdAdj
        INPUT #1, AE
        FOR X = 1 TO 4
        INPUT #1, SA%(X)
        NEXT
        FOR X = 1 TO 4
        INPUT #1, S2%(X)
        NEXT
        FOR X = 1 TO 5
        INPUT #1, WA%(X)
        NEXT
        FOR M = 0 TO NM
        FOR D = 0 TO 15
        INPUT #1, MD%(M, D)
        NEXT D
        NEXT M
        FOR A = 0 TO NA
        FOR D = 0 TO 9
        INPUT #1, AD%(A, D)
        NEXT D
        NEXT A
        FOR V = 1 TO NR
        INPUT #1, V%(V)
        NEXT V
        INPUT #1, GOLD&
        INPUT #1, BANK&
    CLOSE 1

    '------- (end of include file) -------    
 ' 
    INPUT #1, VC
    INPUT #1, IC
    INPUT #1, IV
    CLOSE 1
    R2 = Room
    GOSUB OPEN.ROOMS
    GOTO MOVE.IT
GET.GAME.ID:
    PRINT
    INPUT "File Name: ", GAME.ID$
    IF LEN(GAME.ID$) > 8 THEN GOTO GET.GAME.ID
    GAME.ID$ = UCASE$(GAME.ID$)
    IF LEFT$(GAME.ID$, 1) < "A" OR LEFT$(GAME.ID$, 1) > "Z" THEN GOTO GET.GAME.ID
    GAME.ID$ = GAME.ID$ + ".GAM"
    RETURN
REM $$INCL:'\EAMON\COPY\CHARIO.BAS'
        ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        '
        '   Module:  CHARIO.BAS
        '   Eamon Version:  Eamon-QB (or Eamon-PC)
        ' ------------------------------------------------------------
        '  Character File I/O Routines for Eamon QB/PC
        '        Basic version:  QuickBASIC 4.0, GW-BASIC, QBasic *
        '                        or BASIC 7.0 PDS
        '       uses User defined types for record definition
        '       This module will work for QBasic, but QBasic cannot
REM $$INCL:statements, so module must be built
        '       manually or merged using a utility
        ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        '
OPEN.CHARACTERS:
      OPEN "CHARACT.DAT" FOR RANDOM AS #1 LEN = LEN(Char)
      RETURN
READ.NBR.CHARS:
      GET #1, 1, CharCtl
      NC = CharCtl.NbrChar
      IF NC > LOF(1) \ LEN(Char) THEN NC = LOF(1) \ LEN(Char) - 1
      RETURN
READ.CHARACTER:
      GET #1, REC, Char
      Nam$ = RTRIM$(Char.Nam$)
      HD = Char.Hd
      AG = Char.Ag
      CH = Char.Ch
      SA%(1) = Char.SA1
      SA%(2) = Char.SA2
      SA%(3) = Char.SA3
      SA%(4) = Char.SA4
      WA%(1) = Char.WA1
      WA%(2) = Char.WA2
      WA%(3) = Char.WA3
      WA%(4) = Char.WA4
      WA%(5) = Char.WA5
      SEX$ = Char.SEX
      GOLD& = Char.GOLD
      BANK& = Char.BANK
      AE = Char.AE
      ArmNam$ = RTRIM$(Char.ArmNam)
      ArmHit = Char.ArmHit
      ArmAdj = Char.ArmAdj
      ShdNam$ = RTRIM$(Char.ShdNam)
      ShdHit = Char.ShdHit
      ShdAdj = Char.ShdAdj
      WN$(1) = RTRIM$(Char.Wpn1Nam)
      WR%(1) = Char.Wpn1Typ
      WT%(1) = Char.Wpn1WpnTyp
      WC%(1) = Char.Wpn1Odds
      WD%(1) = Char.Wpn1Dice
      WS%(1) = Char.Wpn1Sides
      WN$(2) = RTRIM$(Char.Wpn2Nam)
      WR%(2) = Char.Wpn2Typ
      WT%(2) = Char.Wpn2WpnTyp
      WC%(2) = Char.Wpn2Odds
      WD%(2) = Char.Wpn2Dice
      WS%(2) = Char.Wpn2Sides
      WN$(3) = RTRIM$(Char.Wpn3Nam)
      WR%(3) = Char.Wpn3Typ
      WT%(3) = Char.Wpn3WpnTyp
      WC%(3) = Char.Wpn3Odds
      WD%(3) = Char.Wpn3Dice
      WS%(3) = Char.Wpn3Sides
      WN$(4) = RTRIM$(Char.Wpn4Nam)
      WR%(4) = Char.Wpn4Typ
      WT%(4) = Char.Wpn4WpnTyp
      WC%(4) = Char.Wpn4Odds
      WD%(4) = Char.Wpn4Dice
      WS%(4) = Char.Wpn4Sides
      RETURN
WRITE.CHARACTER:
      Char.Nam = Nam$
      Char.Hd = HD
      Char.Ag = AG
      Char.Ch = CH
      Char.SA1 = SA%(1)
      Char.SA2 = SA%(2)
      Char.SA3 = SA%(3)
      Char.SA4 = SA%(4)
      Char.WA1 = WA%(1)
      Char.WA2 = WA%(2)
      Char.WA3 = WA%(3)
      Char.WA4 = WA%(4)
      Char.WA5 = WA%(5)
      Char.SEX = SEX$
      Char.GOLD = GOLD&
      Char.BANK = BANK&
      Char.AE = AE
      Char.ArmNam = ArmNam$
      Char.ArmHit = ArmHit
      Char.ArmAdj = ArmAdj
      Char.ShdNam = ShdNam$
      Char.ShdHit = ShdHit
      Char.ShdAdj = ShdAdj
      Char.Wpn1Nam = WN$(1)
      Char.Wpn1Typ = WR%(1)
      Char.Wpn1WpnTyp = WT%(1)
      Char.Wpn1Odds = WC%(1)
      Char.Wpn1Dice = WD%(1)
      Char.Wpn1Sides = WS%(1)
      Char.Wpn2Nam = WN$(2)
      Char.Wpn2Typ = WR%(2)
      Char.Wpn2WpnTyp = WT%(2)
      Char.Wpn2Odds = WC%(2)
      Char.Wpn2Dice = WD%(2)
      Char.Wpn2Sides = WS%(2)
      Char.Wpn3Nam = WN$(3)
      Char.Wpn3Typ = WR%(3)
      Char.Wpn3WpnTyp = WT%(3)
      Char.Wpn3Odds = WC%(3)
      Char.Wpn3Dice = WD%(3)
      Char.Wpn3Sides = WS%(3)
      Char.Wpn4Nam = WN$(4)
      Char.Wpn4Typ = WR%(4)
      Char.Wpn4WpnTyp = WT%(4)
      Char.Wpn4Odds = WC%(4)
      Char.Wpn4Dice = WD%(4)
      Char.Wpn4Sides = WS%(4)
      PUT #1, REC, Char
      RETURN
WRITE.NBR.CHARS:
      CharCtl.NbrChar = NC
      PUT #1, 1, CharCtl
      RETURN

    '------- (end of include file) -------    
 ' 
REM $$INCL:'\EAMON\COPY\ADVENIO.OLD'
        ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        '
        '   Module:  ADVENIO.BAS
        '   Eamon Version:  Eamon-QB (or Eamon-PC)
        ' ------------------------------------------------------------
        '  Adventure I/O Routines for Eamon Base Adventure Program
        '        Basic version:  QuickBASIC 4.0, GW-BASIC, QBasic *
        '                        BASIC 7.0 PDS
        '       uses Field statements for record description
        '       This module will work for QBasic, but QBasic cannot
REM $$INCL:statements, so module must be built
        '       manually or merged using a utility
        ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        '
READ.ARTIFACTS:    ' ----- READ ARTIFACTS ---------------------
       IF Art.Len = 0 THEN Art.Len = 128
       IF Art.Flds = 0 THEN Art.Flds = 8
       IF AN.Len = 0 THEN AN.Len = 20
       OPEN "ARTIF.TXT" FOR RANDOM AS #3 LEN = Art.Len
       FIELD 3, AN.Len AS AF.NAME$
       DIM AF.DATA$(Art.Flds)
       FOR A2 = 1 TO Art.Flds
       FIELD 3, AN.Len AS X$, (A2 - 1) * 2 AS X$, 2 AS AF.DATA$(A2)
       NEXT
       FOR A = 1 TO NA
           GET #3, A
           AN$(A) = RTRIM$(AF.NAME$)
           FOR A2 = 1 TO Art.Flds
               AD%(A, A2) = CVI(AF.DATA$(A2))
           NEXT A2
           IF AD%(A, 2) > 1 AND AD%(A, 2) < 4 THEN NW = NW + 1
       NEXT
       CLOSE 3
       RETURN
READ.MONSTERS:  ' ------------- READ MONSTERS    ---------------------
       IF MON.LEN = 0 THEN MON.LEN = 128
       IF Mon.Flds = 0 THEN Mon.Flds = 12
       IF MN.Len = 0 THEN MN.Len = 20
       OPEN "MONST.TXT" FOR RANDOM AS #3 LEN = MON.LEN
       FIELD 3, MN.Len AS MF.NAME$
       DIM MF.DATA$(Mon.Flds)
       FOR A2 = 1 TO Mon.Flds
           FIELD 3, MN.Len AS X$, (A2 - 1) * 2 AS X$, 2 AS MF.DATA$(A2)
       NEXT
       FOR A = 1 TO NM
           GET #3, A
           MN$(A) = RTRIM$(MF.NAME$)
           FOR A2 = 1 TO Mon.Flds
               MD%(A, A2) = CVI(MF.DATA$(A2))
           NEXT A2
           IF MD%(A, 3) < 0 THEN               ' Force nuetral if < 0
              MD%(A, 3) = ABS(MD%(A, 3)) - 1
              MD%(A, 14) = 2
           END IF
       NEXT
       CLOSE 3
       RETURN
OPEN.DESC:       ' ----------------- OPEN DESC FILE -------------------
       IF Desc.Len = 0 THEN Desc.Len = 256
       OPEN "DESC.TXT" FOR RANDOM AS #2 LEN = Desc.Len
       FIELD 2, Desc.Len - 1 AS Desc$
       RETURN
OPEN.RMNAMES:    ' ---------------- OPEN ROOM NAMES -------------------
       IF RMN.Len = 0 THEN RMN.Len = 64
       OPEN "RMNAMES.TXT" FOR RANDOM AS #3 LEN = RMN.Len
       FIELD 3, RMN.Len AS RN$
       RETURN
OPEN.ROOMS:      ' ---------------- OPEN ROOMS FILE -------------------
       IF RM.LEN = 0 THEN RM.LEN = 64
       OPEN "ROOMS.TXT" FOR RANDOM AS #1 LEN = RM.LEN
       FOR D = 1 TO 10
           FIELD 1, (D - 1) * 2 AS X$, 2 AS RF.DIR$(D)
       NEXT
       FIELD 1, 20 AS X$, 1 AS RF.LT$
       RETURN
Read.Room:
       GET #1, Room
       IF ND = 0 THEN ND = 6
       NX = 0
       FOR X = 1 TO ND
           RD%(X) = CVI(RF.DIR$(X))
           IF RD%(X) > 0 AND RD%(X) <= NR THEN NX = NX + 1
       NEXT
       NL = VAL(RF.LT$)
       GET #3, Room
       RETURN
    '------- (end of include file) -------

    '------- (end of include file) -------    
 ' 

SUB PGPRT (SP, LIT$)

STATIC PG.CNT
    IF SP = 0 THEN PG.CNT = 0: EXIT SUB
    IF SP = 99 THEN
	GOSUB PAGE.BRK
	EXIT SUB
    END IF
    IF LIT$ = "" THEN PG.CNT = PG.CNT + SP: EXIT SUB
    IF PG.CNT > 18 THEN
	GOSUB PAGE.BRK
    END IF
    IF SP > 1 THEN
	FOR X = 1 TO SP - 1
	PRINT
	PG.CNT = PG.CNT + 1
	NEXT
    END IF
    PRINT LIT$
    PG.CNT = PG.CNT + INT(LEN(LIT$) / 80) + 1
    EXIT SUB
PAGE.BRK:
    LOCATE 24, 1
    PRINT STRING$(25, "-"); " Press Any Key to Continue "; STRING$(25, "-");
    A$ = INPUT$(1)
    PG.CNT = 0
    LOCATE CSRLIN, 1
    PRINT SPC(79);
    RETURN
END SUB

