home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / DNDOOR45.ZIP / DNDS4.BAS < prev    next >
BASIC Source File  |  2000-04-28  |  117KB  |  2,587 lines

  1.  Rem * Filename: dnds4.bas Version: v4.5 r1.0
  2.  Rem * This subprogram contains room edit routines, user list routines,
  3.  Rem * shopkeeper routines, and some main commands.
  4.  
  5.  Rem $Include: 'dnddoor.inc'
  6.  
  7.  Rem * routine to toggle player sort flag.
  8.  
  9. Sub Sort.Inventory
  10.  On Local Error Resume Next ' local error resume
  11.  Select Case Sorting ' toggle sort method
  12.  Case -1 ' now sort by charges
  13.     Sorting=0 ' change to no sort
  14.     UserRecord.Sort=0 ' store in user record
  15.     Outpt="Inventory sorting off."
  16.  Case 0 ' now not sorting
  17.     Sorting=1 ' change to sorting by plus
  18.     UserRecord.Sort=1 ' store in user record
  19.     Outpt="Inventory plus sorting on."
  20.  Case 1 ' now sort by plus
  21.     Sorting=-1 ' change to sorting by charges
  22.     UserRecord.Sort=-1 ' store in user record
  23.     Outpt="Inventory charges sorting on."
  24.  Case Else ' not within range
  25.     Sorting=0 ' default sorting off
  26.     UserRecord.Sort=0 ' store in user record
  27.     Outpt="Inventory sorting off."
  28.  End Select ' end toggle sort flag
  29.  Call IO.O ' send display message
  30. End Sub ' end routine to toggle sort flag
  31.  
  32.  Rem * routine to sort player inventory.
  33.  Rem * input variables:
  34.  Rem *   Sorting - flag for sort toggle.
  35.  
  36. Sub Sorter
  37.  On Local Error Resume Next ' local error resume
  38.  If Sorting=False Then ' check sorting on
  39.     Exit Sub ' exit routine
  40.  Endif ' end check sorting on
  41.  ' perform a simple 'bubble sort' while swapping indexes of weapons variables
  42.  For Sort1=1 To 20 ' loop through top bubble of player inventory
  43.     For Sort2=Sort1+1 To 20 ' loop through bottom bubble of player inventory
  44.        If Sorting=-1 Then ' sort by charges
  45.           '  make the comparison of charges left of two inventory items
  46.           If UserRecord.Charges(Sort1)<UserRecord.Charges(Sort2) Then
  47.              ' swap the two items if the second one is greater
  48.              Swap UserRecord.Inv(Sort1),UserRecord.Inv(Sort2)
  49.              Swap UserRecord.Charges(Sort1),UserRecord.Charges(Sort2)
  50.              Gosub Swap.Weapons ' check weapons being held
  51.           Endif ' end compare value of two items
  52.        Else
  53.           If Sorting=1 Then ' sort by plus
  54.              Inventory1=UserRecord.Inv(Sort1) ' get treasure index
  55.              Inventory2=UserRecord.Inv(Sort2) ' get treasure index
  56.              If Inventory1>0 And Inventory2>0 Then ' compare index values
  57.                 Call Read.Record(TreasureFile,Inventory1) ' get record
  58.                 Inventory.Plus1=TreasureRecord.Plus ' store treasure plus
  59.                 Call Read.Record(TreasureFile,Inventory2) ' get record
  60.                 Inventory.Plus2=TreasureRecord.Plus ' store treasure plus
  61.                 If Inventory.Plus1<Inventory.Plus2 Then ' compare inventory pluses
  62.                    ' swap the two items if the second one is greater
  63.                    Swap UserRecord.Inv(Sort1),UserRecord.Inv(Sort2)
  64.                    Swap UserRecord.Charges(Sort1),UserRecord.Charges(Sort2)
  65.                    Gosub Swap.Weapons ' check weapons being held
  66.                 Endif
  67.              Endif
  68.           Endif
  69.        Endif
  70.     Next ' end loop through bubble sort
  71.  Next ' end loop through bubble sort
  72.  Exit Sub ' exit sort routine
  73. Swap.Weapons:
  74.  ' check if any of the weapons/armor/shield/rings held/worn are
  75.  ' equal to one of the two items being swapped so their indexes
  76.  ' still point to the correct player inventory array elements
  77.  Select Case Weapon4 ' select an index (armor)
  78.  Case Sort1 ' swap 1
  79.     Weapon4=Sort2 ' switch index
  80.  Case Sort2 ' swap 2
  81.     Weapon4=Sort1 ' switch index
  82.  End Select ' end index selection
  83.  Select Case Weapon5 ' select an index (shield)
  84.  Case Sort1 ' swap 1
  85.     Weapon5=Sort2 ' switch index
  86.  Case Sort2 ' swap 2
  87.     Weapon5=Sort1 ' switch index
  88.  End Select ' end index selection
  89.  Select Case Weapon6 ' select an index (weapon)
  90.  Case Sort1 ' swap 1
  91.     Weapon6=Sort2 ' switch index
  92.  Case Sort2 ' swap 2
  93.     Weapon6=Sort1 ' switch index
  94.  End Select ' end index selection
  95.  Select Case Weapon7 ' select an index (ring)
  96.  Case Sort1 ' swap 1
  97.     Weapon7=Sort2 ' switch index
  98.  Case Sort2 ' swap 2
  99.     Weapon7=Sort1 ' switch index
  100.  End Select ' end index selection
  101. Return
  102. End Sub ' end routine to sort player inventory
  103.  
  104.  Rem * routine to page sysop at console by beeping.
  105.  Rem * processing variables:
  106.  Rem *   Chat - contains chat mode toggle.
  107.  
  108. Sub Page.Sysop
  109.  On Local Error Resume Next ' local error resume
  110.  If Normal.User Then ' check non DM
  111.     If UserRecord.Level<=1 Then ' check player level
  112.        Outpt="The Sysop is not answering pages now." ' make message
  113.        Call IO.O ' send message
  114.        Exit Sub ' exit routine
  115.     Endif ' end check player level
  116.  Endif ' end check normal user
  117.  Beep.Count=False ' reset beep counter
  118.  Graphics.Off=True ' reset color
  119.  Outpt="Hit <control-k> to return to prompt." ' make message
  120.  Call IO.O ' send message
  121.  Outpt="Sysop press <escape> to enter chat.." ' make message
  122.  Call IO.O ' send message
  123.  Outpt="Paging Sysop:" ' make paging message
  124.  Carriage.Return=True ' disable cr/lf
  125.  Call IO.O ' send paging message
  126.  Chat=True ' store chat flag toggle off
  127.  Allow.Break=True ' enable control-k checking
  128.  Break=False ' reset control-k flag
  129.  Beep.Time!=Timer ' store current time
  130.  Do While Chat ' loop until chat entered, 10 beeps, or control-k break entered
  131.     If Break Then ' check control-k entered
  132.        Exit Do ' exit chat loop
  133.     Endif ' end check control-k entered
  134.     ' routine to compute time elapsed
  135.     Call Second.Timer(Time.Elapsed,Beep.Time!,2!)
  136.     If Time.Elapsed Then ' check two seconds elapsed
  137.        Outpt=Chr$(7)+Mask$ ' make remote beep plus character
  138.        Carriage.Return=True ' disable cr/lf
  139.        Call IO.O ' send page message
  140.        Beep.Time!=Timer ' store current time
  141.        Beep.Count=Beep.Count+1 ' increment beep counter
  142.        If Beep.Count=10 Then ' check 10 beeps
  143.           Exit Do ' exit chat loop
  144.        Endif ' end check beep exit
  145.     Endif ' end check time elapsed
  146.  Loop ' end chat loop
  147.  Allow.Break=False ' reset control-k checking off
  148.  If Break Then ' check control-k flag
  149.     Break=False ' reset control-k flag
  150.     Outpt=Nul ' set output to null
  151.     Call IO.O ' send empty return
  152.  Endif ' end check control-k flag
  153.  If Chat=False Then ' compare chat flag on
  154.     Chat=True ' reset chat flag
  155.     Call Enter.Chat ' routine to chat with player
  156.  Endif ' end compare chat flag
  157.  Chat=False ' clear chat flag
  158.  Call IO.O ' send empty cr/lf
  159. End Sub
  160.  
  161.  Rem * routine to chat with remote player.
  162.  Rem * input variables:
  163.  Rem *   Chat - is true, false to quit.
  164.  Rem * processing variables:
  165.  Rem *   Logged.On! - time player logged on (seconds from midnight).
  166.  Rem *   Chat.Start! - time chat started (seconds from midnight).
  167.  Rem *   Time.Remaining! - time player had remaining before chat in seconds.
  168.  
  169. Sub Enter.Chat
  170.  On Local Error Resume Next ' local error resume
  171.  Graphics.Off=True ' reset graphics
  172.  Logged.On!=Timeon ' store timeon
  173.  Chat.Start!=Timer ' store time now
  174.  Time.Remaining!=Time.Left ' store time left
  175.  Timeon=Timer ' reset time on to now
  176.  Time.Left=60! ' reset time left to 60 seconds
  177.  Allow.Break=False ' disable control-k checking
  178.  Break=False ' reset control-k flag
  179.  Outpt=Nul ' format empty string
  180.  Call IO.O ' send empty cr/lf
  181.  Outpt="Chat Mode.." ' make chat mode message
  182.  Call IO.O ' send chat mode message
  183.  User.Word.Wrap=User.Wordwrap ' store word wrap
  184.  User.Wordwrap=False ' reset word wrap
  185.  Word.Wrap=True ' enable 80 column word wrap
  186.  Do While Chat ' chat in an input loop
  187.     Timeon=Timer ' reset time on (disables timeout messages)
  188.     Time.Left=600! ' reset time left (disables timeout messages)
  189.     Call IO.I ' continually process input (from keyboard and modem)
  190.  Loop ' loop until chat toggla flag is reset
  191.  ' end chat, restore time variables
  192.  Timeon=Logged.On!+Fix(Timer-Chat.Start!) ' recalculate time on
  193.  If Timeon>86400! Then ' check chatted past midnight
  194.     Timeon=Timeon-86400! ' decrement midnight
  195.  Endif ' end check midnight
  196.  Time.Left=Time.Remaining! ' restore time left
  197.  Allow.Break=False ' disable control-k checking
  198.  Break=False ' reset control-k flag
  199.  Buffer=Nul ' clear buffer
  200.  Func.Buffer=Nul ' clear buffer
  201.  Outpt=Nul ' clear buffer
  202.  Word.Wrap=False ' disable word wrap
  203.  User.Wordwrap=User.Word.Wrap ' restore word wrap
  204.  If Len(Inpt) Then ' check last input
  205.     Call IO.O ' output last input
  206.  Endif ' end check last input
  207.  Inpt=Nul ' reset input buffer
  208. End Sub ' end routine to chat with remote player
  209.  
  210.  Rem * routine to display help text for DMs.
  211.  Rem * input variables:
  212.  Rem *   Stored.Parsed.Command1 - command to look up help text for.
  213.  
  214. Sub DM.Help
  215.  On Local Error Resume Next ' local error resume
  216.  Help.Command$=Stored.Parsed.Command1 ' get command parameter
  217.  ' compare first character to DM command prefix
  218.  If Left$(Help.Command$,1)<>"!" Then
  219.     Outpt="Enter DM command, form: !Help !<command>" ' make error message
  220.     Call IO.O ' send error message
  221.     Exit Sub ' exit routine
  222.  Endif ' end compare DM command prefix
  223.  ' store next part of parameter for command lookup
  224.  Help.Command$=Mid$(Help.Command$,2)
  225.  Stored.Parsed.Command1=Help.Command$ ' store into parsed command variable
  226.  Call Read.Help(True) ' routine to read help text
  227. End Sub ' end routine for DM help text
  228.  
  229.  Rem * routine displays help text for a command.
  230.  Rem * input variables:
  231.  Rem *   Help.Type is 1=!edit help, 0=normal command, -1=DM command lookup.
  232.  
  233. Sub Read.Help(Help.Type)
  234.  On Local Error Resume Next ' local error resume
  235.  Help.Command$=Stored.Parsed.Command1 ' store parameter of command to lookup
  236.  Help.Command$=Rtrim$(Help.Command$) ' trim command
  237.  Help.Command$=Ucase$(Help.Command$) ' uppercase command
  238.  Close #HelpFile ' close work file
  239.  Select Case Help.Type ' selection of help file
  240.  Case True ' check DM command
  241.     FileName="dmhelp.dat" ' store DM help filename
  242.     Help.Command$=Left$(Help.Command$,8) ' truncate command
  243.  Case False ' check normal command
  244.     FileName="help.dat" ' store normal command help filename
  245.     Help.Command$=Left$(Help.Command$,8) ' truncate command
  246.  Case 1 ' check !edit help command
  247.     FileName="edithelp.dat" ' store !edit help filename
  248.  End Select ' end check command type
  249.  Open FileName For Random Shared As #HelpFile Len=Len(HelpRecord) ' open file
  250. Start.Display:
  251.  Allow.Break=True ' enable control-k checking
  252.  Break=False ' reset control-k flag
  253.  Continue=False ' reset continuous flag
  254.  Graphics.Off=True ' reset color
  255.  Help.Displayed=False ' reset help text displayed flag
  256.  Page.Length=False ' reset page length counter
  257.  For Record.Count=2 To Lof(HelpFile)/Len(HelpRecord) ' loop through help records
  258.     Call Read.Record(HelpFile,Record.Count) ' get next help record
  259.     Command.Name$=HelpRecord.CName ' store command name of help record
  260.     Command.Name$=Rtrim$(Command.Name$) ' trim command
  261.     Command.Name$=Ucase$(Command.Name$) ' uppercase command
  262.     If Help.Type<=False Then ' check help file type
  263.        Command.Name$=Left$(Command.Name$,8) ' truncate command
  264.     Endif ' end check command
  265.     If Help.Displayed=True Then ' check help topic found already
  266.        If Help.Command$<>Command.Name$ Then ' compare against topic selected
  267.           Exit For ' exit help file display loop
  268.        Endif ' end compare topic
  269.     Endif ' end check help topic displayed
  270.     If Help.Command$=Command.Name$ Then ' compare help record command
  271.        If Help.Type=1 Then ' check displaying !edit help
  272.           If Help.Displayed=False Then ' verify topic already being displayed
  273.              If Help.Command$<>"CONTENTS" Then ' compare help type
  274.                 Count.Store=Record.Count ' save help file record counter
  275.                 Topic.Name$=Rtrim$(HelpRecord.CName) ' get command being displayed
  276.                 For Topic.Count=2 To Lof(HelpFile)/Len(HelpRecord) ' loop through help records
  277.                    Call Read.Record(HelpFile,Topic.Count) ' get next help record
  278.                    Topic.Number$=HelpRecord.Text ' store command name of help record
  279.                    Topic.Number$=Rtrim$(Topic.Number$) ' trim command
  280.                    Topic.Space=Instr(Topic.Number$," ") ' store imbdded topic number
  281.                    If Topic.Space Then ' remove topic sequence from topic
  282.                       Topic.Number$=Left$(Topic.Number$,Topic.Space-1) ' remove topic
  283.                    Endif ' end check for topic sequence
  284.                    If Topic.Number$=Topic.Name$ Then ' compare to topic
  285.                       Page.Length=Page.Length+1 ' increment text displayed
  286.                       Outpt=Rtrim$(HelpRecord.Text) ' store topic number/name
  287.                       Call IO.O ' send command name message
  288.                       Exit For ' exit loop search
  289.                    Endif ' end compare topic
  290.                 Next ' end loop search
  291.                 Record.Count=Count.Store ' restore help file record counter
  292.              Endif ' end compare help type
  293.           Endif ' end verify topic displayed
  294.        Endif ' end check displaying
  295.        Call Read.Record(HelpFile,Record.Count) ' get help record
  296.        Outpt=HelpRecord.Text ' get command help text
  297.        Outpt=Rtrim$(Outpt) ' trim help text
  298.        Outpt=Ltrim$(Outpt) ' trim help text
  299.        Call IO.O ' display help text
  300.        Help.Displayed=True ' set text displayed flag
  301.        If Break Then ' check control-k break flag
  302.           Goto End.Display ' exit loop through help file
  303.        Endif ' end check control-k break
  304.        Page.Length=Page.Length+1 ' increment page length counter
  305.        If Page.Length=User.Pagelength Then ' compare page length
  306.           Page.Length=False ' reset page length counter
  307.           If Continue=False Then ' check continuous flag
  308.              Call More.Prompt ' routine to pause for more
  309.              If No Then ' check no more entered
  310.                 Goto End.Display ' exit loop through help file
  311.              Endif ' end check no  entered
  312.           Endif ' end check continuous flag
  313.        Endif ' end check page length
  314.     Endif ' end compare help commands
  315.  Next ' end loop through all help file records
  316.  If Help.Type=1 Then ' check if !edit help topics are being displayed
  317.     If Record.Count<Lof(HelpFile)/Len(HelpRecord) Then ' verify eof
  318.        Graphics.Off=False ' reset color
  319.        Outpt="Continue search(y/n)? " ' prompt to continue to next topic
  320.        No.Input.Out="y" ' default input
  321.        Call IO.I ' get user input
  322.        If Yes Then ' verify to continue display
  323.           Help.Command$=Command.Name$ ' store last help topic
  324.           Goto Start.Display ' go redisplay
  325.        Endif ' end verify to continue
  326.     Endif ' end verify file end
  327.  Endif ' end check help display type
  328. End.Display:
  329.  Graphics.Off=False ' reset color
  330.  Allow.Break=False ' clear control-k flag
  331.  If Break Then ' check control-k flag
  332.     Break=False ' reset control-k flag
  333.     Outpt=Nul ' set output to null
  334.     Call IO.O ' send empty return
  335.  Endif ' end check control-k flag
  336.  If Page.Length Then ' check page length
  337.     Call More.Prompt ' routine for more
  338.  Endif ' end check page length
  339.  If Help.Displayed=False Then ' check help text displayed flag
  340.     Outpt="No help found on '"+Lcase$(Help.Command$)+"'." ' make error message
  341.     Call IO.O ' send error message
  342.  Endif ' end check help text flag
  343.  Close #HelpFile ' close work file
  344. End Sub ' end routine to display help text
  345.  
  346.  Rem * routine trains player for next level.
  347.  
  348. Sub Train.Stats
  349.  On Local Error Resume Next ' local error resume
  350.  If UserRecord.Level<False Then ' check negative player level
  351.     UserRecord.Level=False ' set player level
  352.  Endif ' end check negative level
  353.  If UserRecord.Level>=MaxInt Then ' check player level to maximum integer
  354.     Outpt="Nothing happens.." ' make error message
  355.     Call IO.O ' send message
  356.     Exit Sub ' exit routine
  357.  Endif ' end check maximum integer
  358.  If UserRecord.Level>False Then ' check player level again
  359.     Call Gold(Required.Gold#) ' get gold required to train for next level
  360.     UserRecord.Gold=UserRecord.Gold-Required.Gold# ' subtract gold from player
  361.  Endif ' end check player level
  362.  Stat=Int(Rnd*7+1) ' get random statistic to increment
  363.  ' verify statistic below maximum statistic or player is DM type
  364.  If UserRecord.Stats(Stat)<MaxStat Or Normal.User=False Then ' verify
  365.     UserRecord.Stats(Stat)=UserRecord.Stats(Stat)+1 ' increment statistic
  366.  Endif ' end verify player type
  367.  If UserRecord.Level<=10 Then ' compare player level
  368.     If UserRecord.Stats(6)<MaxStat Then ' check statistic below maximum stat
  369.        UserRecord.Stats(6)=UserRecord.Stats(6)+1 ' increment piety
  370.     Endif ' end check statistic
  371.  Endif ' end compare level
  372.  UserRecord.Level=UserRecord.Level+1 ' increment the player level
  373.  Call New.Stats ' routine to update statistics based on level
  374.  Outpt="After many hours of training and meditation..." ' make train message
  375.  Call IO.O ' send train message
  376.  Call Display.Health ' routine to display player statistics
  377.  Call Display.Experience ' routine to display player requirements
  378. End Sub ' end routine to train player for next level
  379.  
  380.  Rem * routine recalculates player statistics based on player level.
  381.  
  382. Sub New.Stats
  383.  On Local Error Resume Next ' local error resume
  384.  If UserRecord.Level<False Then ' check player level
  385.     UserRecord.Level=False ' reset player level
  386.  Endif ' end check player level
  387.  ' compute player maximum fatigue points
  388.  New.Stat#=Cdbl(Training.Stats(UserRecord.ClassType,1))*Cdbl(UserRecord.Level)
  389.  If New.Stat#<0 Then ' compare fatigue points
  390.     New.Stat#=0 ' reset fatigue points
  391.  Endif ' end compare points
  392.  If New.Stat#>MaxInt Then ' compare fatigue points
  393.     New.Stat#=MaxInt ' reset fatigue points
  394.  Endif ' end compare points
  395.  ' store new maximum fatigue points in player record
  396.  UserRecord.FatigueMax=Cint(New.Stat#) ' convert points to integer
  397.  ' compute player maximum vitality points
  398.  New.Stat#=Cdbl(Training.Stats(UserRecord.ClassType,2))*Cdbl(UserRecord.Level)
  399.  If New.Stat#<0 Then ' compare vitality points
  400.     New.Stat#=0 ' reset vitality points
  401.  Endif ' end compare points
  402.  If New.Stat#>MaxInt Then ' compare vitality points
  403.     New.Stat#=MaxInt ' reset vitality points
  404.  Endif ' end compare points
  405.  ' store new maximum vitality points in player record
  406.  UserRecord.VitalityMax=Cint(New.Stat#) ' convert points to integer
  407.  ' compute player maximum magic points
  408.  New.Stat#=Cdbl(Training.Stats(UserRecord.ClassType,3))*Cdbl(UserRecord.Level)
  409.  If New.Stat#<0 Then ' compare magic points
  410.     New.Stat#=0 ' reset magic points
  411.  Endif ' end compare points
  412.  If New.Stat#>MaxInt Then ' compare magic points
  413.     New.Stat#=MaxInt ' reset magic points
  414.  Endif ' end compare points
  415.  ' store new maximum magic points in player record
  416.  UserRecord.MagicMax=Cint(New.Stat#) ' convert points to integer
  417.  ' compute player maximum psionic points
  418.  New.Stat#=Cdbl(Training.Stats(UserRecord.ClassType,4))*Cdbl(UserRecord.Level)
  419.  If New.Stat#<0 Then ' compare psionic points
  420.     New.Stat#=0 ' reset psionic points
  421.  Endif ' end compare points
  422.  If New.Stat#>MaxInt Then ' compare psionic points
  423.     New.Stat#=MaxInt ' reset psionic points
  424.  Endif ' end compare points
  425.  ' store new maximum psionic points in player record
  426.  UserRecord.PsionicMax=Cint(New.Stat#) ' convert points to integer
  427.  Stat=UserRecord.Fatigue ' store player fatigue points
  428.  Stat.Max=UserRecord.FatigueMax ' store player maximum fatigue points
  429.  If Stat<0 Or Stat>Stat.Max Then ' compare fatigue points range
  430.     Stat=Stat.Max ' reset fatigue to maximum fatigue points
  431.  Endif ' end compare points
  432.  UserRecord.Fatigue=Stat ' store new fatigue points
  433.  Stat=UserRecord.Vitality ' store player vitality points
  434.  Stat.Max=UserRecord.VitalityMax ' store player maximum vitality points
  435.  If Stat<0 Or Stat>Stat.Max Then ' compare vitality points range
  436.     Stat=Stat.Max ' reset vitality to maximum vitality points
  437.  Endif ' end compare points
  438.  UserRecord.Vitality=Stat ' store new vitality points
  439.  Stat=UserRecord.Magic ' store player magic points
  440.  Stat.Max=UserRecord.MagicMax ' store player maximum magic points
  441.  If Stat<0 Or Stat>Stat.Max Then ' compare magic points range
  442.     Stat=Stat.Max ' reset magic points to maximum magic points
  443.  Endif ' end compare points
  444.  UserRecord.Magic=Stat ' store new magic points
  445.  Stat=UserRecord.Psionic ' store player psionic points
  446.  Stat.Max=UserRecord.PsionicMax ' store player maximum psionic points
  447.  If Stat<0 Or Stat>Stat.Max Then ' compare spionic points range
  448.     Stat=Stat.Max ' reset psionic points to maximum psionic points
  449.  Endif ' end compare points
  450.  UserRecord.Psionic=Stat ' store new psionic points
  451.  ' routine for maximum statistic comparison
  452.  If Normal.User Then ' check non DM
  453.     For Stats=1 To 7 ' loop through all player statistic points
  454.        If UserRecord.Stats(Stats)>MaxStat Then ' compare statistic to maximum
  455.           UserRecord.Stats(Stats)=MaxStat ' reset statistic to maximum
  456.        Endif ' end compare points
  457.     Next ' end loop through statistics
  458.  Endif
  459.  ' routine for zero stats
  460.  If Normal.User Then
  461.     Low.Stats=False ' reset low stats flag
  462.     For Stats1=1 To 7 ' loop through statistics again
  463.        If UserRecord.Stats(Stats1)<=False Then ' check low statistic
  464.           UserRecord.Stats(Stats1)=1 ' reset low statistic
  465.           ' loop through statistics again to prevent death loop
  466.           For Stats2=1 To 7
  467.              If UserRecord.Stats(Stats2)<=False Then ' check low statistic
  468.                 UserRecord.Stats(Stats2)=1 ' reset statistic
  469.              Endif ' end check low stat
  470.           Next ' end loop through stats
  471.           Low.Stats=True ' set low stats flag
  472.           Exit For ' exit loop so low stats don't death loop
  473.        Endif ' end check low stat
  474.     Next ' end loop through stats
  475.     If Low.Stats Then ' check low stats flag
  476.        ' make death message
  477.        Outpts=Lcase$(Rtrim$(Stat(Stats1)))
  478.        Message1="Your "+Outpts+" is zero! You have died!"
  479.        Call Player.Died ' routine for dead player
  480.        Exit Sub ' exit low stats loop
  481.     Endif ' end check low stats flag
  482.  Endif ' end check normal player
  483.  ' routine to assign upper class name to player
  484.  If UserRecord.Level>=10 Then ' check player level
  485.     Class.Number=UserRecord.ClassType ' get player class type
  486.     If Class.Number<=0 Or Class.Number>10 Then ' verify bounds of class type
  487.        Class.Number=1 ' reset class type to fighter
  488.        UserRecord.ClassType=1 ' reset class type to fighter
  489.     Endif ' end verify class type bounds
  490.     Inpt=High.Class.Name(Class.Number) ' get player level 10 class name
  491.     Call Valid(Inpt,20) ' validate name
  492.     If Len(Inpt) Then ' compare name length
  493.        Call Encrypt(Inpt,True) ' encrypt name
  494.        UserRecord.ClassName=Inpt ' assign class name to player record
  495.     Endif ' end compare name length
  496.  Endif ' end check player level
  497.  Call Get.User.Stats ' routine to assign more player stats
  498. End Sub ' end routine to recalculate player stats
  499.  
  500.  Rem * routine adds and edits new room.
  501.  Rem * input variables:
  502.  Rem *   Next.Room - number of new room number to add.
  503.  Rem *   Last.Direction - last direction entered.
  504.  Rem * output variables:
  505.  Rem *   Room.Added - true for a new room added, false if not.
  506.  
  507. Sub Add.Room(Last.Direction,Room.Added)
  508.  On Local Error Resume Next ' local error resume
  509.  Graphics.Off=True ' reset color
  510.  Outpt="Add new room(y/n)? " ' make input prompt
  511.  No.Input.Out="N" ' default input
  512.  Call IO.I ' get input
  513.  Room.Added=False ' set return variable
  514.  If No Then ' check response
  515.     Exit Sub ' exit routine
  516.  Endif ' end check response
  517.  Room.Added=True ' set return variable
  518.  Next.Room=Lof(RoomFile)/Len(RoomRecord)+1 ' store last room record
  519.  Call Clear.Room(Next.Room) ' routine to clear room record
  520.  ' routine to edit room description and monster class
  521.  Call Change.Room(Next.Room)
  522.  Outpt="Add room link(y/n)? " ' input prompt
  523.  No.Input.Out="Y" ' default input
  524.  Call IO.I ' get input
  525.  If Yes Then ' check response
  526.     If Last.Direction Then ' check direction entered
  527.        Graphics.Off=True ' reset color
  528.        Outpt="Press <enter> for entry link:" ' make message
  529.        Call IO.O ' send message
  530.     Endif ' end check direction entered
  531.     ' routine to add link to room
  532.     Call Add.Link(Room,Next.Room,Last.Direction)
  533.  Endif ' end check response
  534.  Graphics.Off=False ' reset color
  535.  Outpt="New room"+Str$(Next.Room)+" added." ' make display message
  536.  Call IO.O ' send display message
  537.  Room=Next.Room ' update current room number to added room number
  538. End Sub ' end routine to add new room
  539.  
  540.  Rem * routine clears room record variables.
  541.  Rem * input variables:
  542.  Rem *   Room.Number! - room number.
  543.  
  544. Sub Clear.Room(Room.Number!)
  545.  On Local Error Resume Next ' local error resume
  546.  RoomRecord.ShortDesc=Nul ' set short description
  547.  For Array.Index=1 To 4 ' loop through long description
  548.     RoomRecord.LongDesc(Array.Index)=Nul ' set long description
  549.  Next ' end loop through long description
  550.  RoomRecord.Action=False ' clear variable
  551.  RoomRecord.MonsterClass=False ' clear variable
  552.  For Array.Index=1 To 12 ' loop through room directions
  553.     RoomRecord.Direct(Array.Index)=False ' clear variable
  554.  Next ' end loop through directions
  555.  For Array.Index=1 To 20 ' loop through room objects and treasure
  556.     RoomRecord.Object(Array.Index)=False ' clear variable
  557.     RoomRecord.ObjCharges(Array.Index)=False ' clear variable
  558.     RoomRecord.Treasure(Array.Index)=False ' clear variable
  559.     RoomRecord.TreCharges(Array.Index)=False ' clear variable
  560.     RoomRecord.Flags(Array.Index)=False ' clear variable
  561.  Next ' end loop through room objects and treasure
  562.  Call Clear.Container(0,True) ' routine to clear container record
  563.  RoomRecord.Container=ContainerRec ' clear variable
  564.  Call Share.Room.Record(Room.Number!) ' write room record number
  565. End Sub ' end routine to clear room record
  566.  
  567.  Rem * routine to add, delete, and list room links.
  568.  
  569. Sub Link.Room
  570.  On Local Error Resume Next ' local error resume
  571.  Do ' input entry loop
  572.     Graphics.Off=False ' reset color
  573.     Outpt="Room link edit:" ' make option message
  574.     Call IO.O ' send option message
  575.     Graphics.Off=True ' reset color
  576.     Outpt="[A]dd" ' make message
  577.     Call IO.O ' send message
  578.     Outpt="[D]elete" ' make message
  579.     Call IO.O ' send message
  580.     Outpt="[L]ist" ' make message
  581.     Call IO.O ' send message
  582.     Graphics.Off=False ' reset color
  583.     Outpt="Enter room link option(q to quit)? " ' make input prompt
  584.     No.Input.Out="Q" ' default input
  585.     Call IO.I ' get input
  586.     Graphics.Off=True ' reset color
  587.     Select Case Ucase$(Inpt) ' make selection of input
  588.     Case "A" ' add link
  589.        Outpt="Enter room number" ' make range prompt
  590.        Max.Rooms!=Lof(RoomFile)/Len(RoomRecord) ' make range number
  591.        ' routine to get number from range
  592.        Call Get.Room.Range2(0!,Max.Rooms!,Room.From!)
  593.        If Room.From! Then ' check range
  594.           Outpt="Enter link room number" ' make range prompt
  595.           ' routine to get number from range
  596.           Call Get.Room.Range2(0!,Max.Rooms!,Room.To!)
  597.           If Room.To! Then ' check range
  598.              ' routine to link two room numbers
  599.              Call Add.Link(Room.From!,Room.To!,False)
  600.           Endif ' end check range
  601.        Endif ' end check range
  602.     Case "D" ' delete link
  603.        Outpts="Link not deleted." ' make default response
  604.        Outpt="Enter room number" ' make range prompt
  605.        Max.Rooms!=Lof(RoomFile)/Len(RoomRecord) ' make range number
  606.        ' routine to get number from range
  607.        Call Get.Room.Range2(0!,Max.Rooms!,Room.Delete!)
  608.        If Room.Delete! Then ' check range
  609.           Outpt="Enter direction(N/E/S/W/NE/SE/SW/NW/U/D/I/O)? "
  610.           Call IO.I ' get input
  611.           ' routine to get room link number
  612.           Call Find.Link(Inpt,Room.Link,False)
  613.           If Room.Link>=1 And Room.Link<=12 Then ' check link number
  614.              Call Read.Room.Record(Room.Delete!) ' get room record
  615.              RoomRecord.Direct(Room.Link)=False ' clear room link number
  616.              Call Share.Room.Record(Room.Delete!) ' write room record
  617.              Outpts="Room"+Str$(Room.Delete!)+", "+ _
  618.              Rtrim$(Direction(Room.Link))+" link removed."
  619.           Endif ' end check link number
  620.        Endif ' end check range
  621.        Outpt=Outpts ' store response
  622.        Call IO.O ' send message
  623.     Case "L" ' list links
  624.        Graphics.Off=False ' reset color
  625.        Outpt="Enter range of room numbers:" ' make display message
  626.        Call IO.O ' send message
  627.        Graphics.Off=True ' reset color
  628.        Max.Rooms!=Lof(RoomFile)/Len(RoomRecord) ' store length of room file
  629.        ' get range of rooms to list
  630.        Call Get.Room.Range(Max.Rooms!,Room.List1!,Room.List2!)
  631.        Allow.Break=True ' set allow break flag
  632.        Break=False ' reset control-k flag
  633.        Continue=False ' set continuous flag
  634.        Page.Length=False ' reset page length counter
  635.        For Room.Number!=Room.List1! To Room.List2! ' loop through rooms to list
  636.           If Page.Length+4>=User.Pagelength Then ' compare page length
  637.              Page.Length=False ' clear page length
  638.              If Continue=False Then ' check continuous flag
  639.                 Call More.Prompt ' routine to pause
  640.                 If No Then ' check more promtp response
  641.                    Exit For ' exit room link display loop
  642.                 Endif ' end check response
  643.              Endif ' end check continuouu flag
  644.           Endif ' end compare page length
  645.           Call Read.Room.Record(Room.Number!) ' get next room record
  646.           Call Display.Room.Links(Room.Number!) ' display room links
  647.           If Break Or No Then ' check break flag
  648.              Exit For ' exit display loop
  649.           Endif ' end check break flag
  650.           Page.Length=Page.Length+4 ' increment page length counter
  651.        Next ' end loop through rooms
  652.        Allow.Break=False ' reset allow break flag
  653.        If Break Then ' check control-k flag
  654.           Break=False ' reset control-k flag
  655.           Outpt=Nul ' set output to null
  656.           Call IO.O ' send empty return
  657.        Endif ' end check control-k flag
  658.        If Page.Length Then ' check page length counter
  659.           Call More.Prompt ' pause prompt
  660.        Endif ' end check page length
  661.     Case "Q" ' quit
  662.        Exit Do ' exit input loop
  663.     End Select ' end selection of input
  664.  Loop ' end input loop
  665.  Call Read.Room.Record(Room) ' get current room record
  666. End Sub ' end DM link routine
  667.  
  668.  Rem * routine adds links between two room numbers.
  669.  Rem * input variables:
  670.  Rem *   Room.Number1! - room to link.
  671.  Rem *   Room.Number2! - room to link.
  672.  Rem *   Entry.Link - default entry link.
  673.  
  674. Sub Add.Link(Room.Number1!,Room.Number2!,Entry.Link)
  675.  On Local Error Resume Next ' local error resume
  676.  ' make direction link prompt
  677.  Outpt="Enter direction(N/E/S/W/NE/SE/SW/NW/U/D/I/O)? "
  678.  Call IO.I ' get input
  679.  ' routine converts direction to link number
  680.  Call Find.Link(Inpt,Direction.Number,Entry.Link)
  681.  If Direction.Number=False Or Direction.Number=13 Then ' check link number
  682.     Outpt="Link not added." ' make error message
  683.     Call IO.O ' send message
  684.     Exit Sub ' exit routine
  685.  Endif ' end check link number
  686.  Call Read.Room.Record(Room.Number1!) ' get room number one to link
  687.  RoomRecord.Direct(Direction.Number)=Room.Number2! ' add link to room
  688.  Call Share.Room.Record(Room.Number1!) ' write room record
  689.  ' make link message
  690.  Outpt="Room"+Str$(Room.Number1!)+" link added to room"+ _
  691.  Str$(Room.Number2!)+"."
  692.  Call IO.O ' send message
  693.  ' make link back prompt
  694.  Outpt="Link room"+Str$(Room.Number2!)+ _
  695.  " back to room"+Str$(Room.Number1!)+"(y/n)? "
  696.  Call IO.I ' get input
  697.  If Yes Then ' check response
  698.     Call Find.Back.Link(Direction.Number,Return.Link) ' get return link
  699.     If Return.Link Then ' check return link
  700.        Call Read.Room.Record(Room.Number2!) ' get room record
  701.        ' add return link to first room
  702.        RoomRecord.Direct(Return.Link)=Room.Number1!
  703.        Call Share.Room.Record(Room.Number2!) ' write room record
  704.        ' make return link message
  705.        Outpt="Room"+Str$(Room.Number2!)+ _
  706.        " link added back to room"+Str$(Room.Number1!)+"."
  707.        Call IO.O ' send message
  708.     Endif ' end check return link
  709.  Endif ' end check response
  710. End Sub ' end routine to link two rooms
  711.  
  712.  Rem * routine converts direction string to number.
  713.  Rem * input variables:
  714.  Rem *   Direction.Name$ - string of direction name.
  715.  Rem *   Entry.Link - default entry link number.
  716.  Rem * output variables:
  717.  Rem *   Direction.Number - direction number.
  718.  
  719. Sub Find.Link(Direction.Name$,Direction.Number,Entry.Link)
  720.  On Local Error Resume Next ' local error resume
  721.  Select Case Ucase$(Direction.Name$) ' select direction string
  722.  Case "N" ' north
  723.     Direction.Number=1 ' direction number
  724.  Case "E" ' east
  725.     Direction.Number=2 ' direction number
  726.  Case "S" ' south
  727.     Direction.Number=3 ' direction number
  728.  Case "W" ' west
  729.     Direction.Number=4 ' direction number
  730.  Case "NE" ' northeast
  731.     Direction.Number=5 ' direction number
  732.  Case "SE" ' southeast
  733.     Direction.Number=6 ' direction number
  734.  Case "SW" ' southwest
  735.     Direction.Number=7 ' direction number
  736.  Case "NW" ' northwest
  737.     Direction.Number=8 ' direction number
  738.  Case "U" ' up
  739.     Direction.Number=9 ' direction number
  740.  Case "D" ' down
  741.     Direction.Number=10 ' direction number
  742.  Case "I" ' in
  743.     Direction.Number=11 ' direction number
  744.  Case "O" ' out
  745.     Direction.Number=12 ' direction number
  746.  Case "G" ' go to portal
  747.     Direction.Number=13 ' go to direction number
  748.  Case Else ' otherwise
  749.     Direction.Number=Entry.Link ' no direction found
  750.  End Select ' end selection of direction
  751. End Sub ' end routine to convert direction
  752.  
  753.  Rem * routine determines direction opposite to input direction.
  754.  Rem * input variables:
  755.  Rem *   Direction.Number - direction number.
  756.  Rem * output variables:
  757.  Rem *   Return.Direction - opposite direction number.
  758.  
  759. Sub Find.Back.Link(Direction.Number,Return.Direction)
  760.  On Local Error Resume Next ' local error resume
  761.  Select Case Direction.Number ' selection of direction number
  762.  Case 1 ' north
  763.     Return.Direction=3 ' south
  764.  Case 2 ' east
  765.     Return.Direction=4 ' west
  766.  Case 3 ' south
  767.     Return.Direction=1 ' north
  768.  Case 4 ' west
  769.     Return.Direction=2 ' east
  770.  Case 5 ' northeast
  771.     Return.Direction=7 ' southwest
  772.  Case 6 ' southeast
  773.     Return.Direction=8 ' northwest
  774.  Case 7 ' southwest
  775.     Return.Direction=5 ' northeast
  776.  Case 8 ' northwest
  777.     Return.Direction=6 ' southeast
  778.  Case 9 ' up
  779.     Return.Direction=10 ' down
  780.  Case 10 ' down
  781.     Return.Direction=9 ' up
  782.  Case 11 ' in
  783.     Return.Direction=12 ' in
  784.  Case 12 ' out
  785.     Return.Direction=11 ' out
  786.  Case Else ' default
  787.     Return.Direction=0 ' no direction
  788.  End Select ' end selection of direction
  789. End Sub ' end routine to find return direction
  790.  
  791.  Rem * routine displays room number links.
  792.  Rem * input variables:
  793.  Rem *   Room.Number! - room number to display.
  794.  
  795. Sub Display.Room.Links(Room.Number!)
  796.  On Local Error Resume Next ' local error resume
  797.  Graphics.Off=False ' reset color
  798.  Outpt="Room number"+Str$(Room.Number!)+":" ' make room number message
  799.  Call IO.O ' send message
  800.  Graphics.Off=True ' reset color
  801.  Outpt=Nul ' clear output string
  802.  For Link.Number=1 To 4 ' loop through room directions
  803.     ' make display line containing room directions
  804.     Inpt=Mid$("NESW",Link.Number,1)+"  "+Str$(RoomRecord.Direct(Link.Number))
  805.     Outpt=Outpt+Inpt+Space$(10-Len(Inpt)) ' pad with blanks
  806.  Next ' end loop through room directions
  807.  Call IO.O ' send line one of room directions
  808.  Outpt=Nul ' clear output string
  809.  For Link.Number=5 To 8 ' loop through room directions
  810.     ' make display line containing room directions
  811.     Inpt=Mid$("NESESWNW",(Link.Number-4)*2-1,2)+" "+ _
  812.     Str$(RoomRecord.Direct(Link.Number))
  813.     Outpt=Outpt+Inpt+Space$(10-Len(Inpt)) ' pad with blanks
  814.  Next ' end loop through room directions
  815.  Call IO.O ' send line one of room directions
  816.  Outpt=Nul ' clear output string
  817.  For Link.Number=9 To 12 ' loop through room directions
  818.     ' make display line containing room directions
  819.     Inpt=Mid$("UDIO",Link.Number-8,1)+"  "+ _
  820.     Str$(RoomRecord.Direct(Link.Number))
  821.     Outpt=Outpt+Inpt+Space$(10-Len(Inpt)) ' pad with blanks
  822.  Next ' end loop through room directions
  823.  Call IO.O ' send line two of room directions
  824.  Outpt=Nul ' clear output string
  825. End Sub ' end routine to display room links
  826.  
  827.  Rem * routine moves player in a certain direction.
  828.  Rem * input variables:
  829.  Rem *   Direction.Number - direction to go.
  830.  Rem * processing variables:
  831.  Rem *   New.Room - true if room can be entered, false if not.
  832.  
  833. Sub Go.Direction(Direction.Number)
  834.  On Local Error Resume Next ' local error resume
  835.  ' change last command to direction
  836.  Entry.Command=Last.Command.Number ' store room entry command
  837.  Last.Command=Ucase$(Direction(Direction.Number))
  838.  Last.Command.Number=True ' reset last command number
  839.  ' routine to check if next room can be entered
  840.  Call Verify.Room(Direction.Number)
  841.  If New.Room Then ' check next room variable
  842.     Call Enter.Room ' routine to move the player
  843.  Endif ' end check next room
  844. End Sub ' end routine to move player
  845.  
  846.  Rem * routine compares player input to direction.
  847.  Rem * input variables:
  848.  Rem *   User.Command - original command input.
  849.  Rem * output variables:
  850.  Rem *   Direction.Number - contains direction number.
  851.  
  852. Sub Get.Direction(Direction.Number)
  853.  On Local Error Resume Next ' local error resume
  854.  For Direction.Number=1 To 12 ' loop through direction names
  855.     Outpts=Direction(Direction.Number) ' store direction name
  856.     Outpts=Rtrim$(Outpts) ' trim name
  857.     Outpts=Ucase$(Outpts) ' uppercase name
  858.     If User.Command=Outpts Then ' compare to player direction
  859.        Exit Sub ' exit routine
  860.     Endif ' end check directions
  861.  Next ' end loop through direction names
  862.  ' routine to get direction
  863.  Call Find.Link(User.Command,Direction.Number,False)
  864.  If Direction.Number=13 Then ' check enter portal link
  865.     Direction.Number=False ' reset direction
  866.  Endif ' end check direction
  867. End Sub ' end routine to compare direction
  868.  
  869.  Rem * routine to add item of treasure to player inventory.
  870.  Rem * input variables:
  871.  Rem *   Treasure.Number - treasure file index number.
  872.  Rem *   Treasure.Charges - treasure charges.
  873.  Rem * output variables:
  874.  Rem *   Item.Added - true if item added, false if not.
  875.  
  876. Sub Add.Inventory(Treasure.Number,Treasure.Charges,Item.Added)
  877.  On Local Error Resume Next ' local error resume
  878.  Item.Added=False ' clear return variable
  879.  For Array.Index=1 To 20 ' loop through all player inventory
  880.     If UserRecord.Inv(Array.Index)=False Then ' check for empty inventory
  881.        UserRecord.Inv(Array.Index)=Treasure.Number ' add treasure index
  882.        UserRecord.Charges(Array.Index)=Treasure.Charges ' add treasure charges
  883.        Weight=Weight+TreasureRecord.Weight ' increment player weight
  884.        Item.Added=True ' set return flag
  885.        Exit Sub ' exit routine
  886.     Endif ' end check empty inventory
  887.  Next ' end loop through player inventory
  888. End Sub ' end routine to add item of treasure to player inventory
  889.  
  890.  Rem * routine to add an object to player inventory.
  891.  Rem * input variables:
  892.  Rem *   Object.Number - object file index number.
  893.  Rem *   Object.Charges - object charges.
  894.  Rem * output variables:
  895.  Rem *   Item.Added - true if item added, false if not.
  896.  
  897. Sub Add.Object(Object.Number,Object.Charges,Item.Added)
  898.  On Local Error Resume Next ' local error resume
  899.  Item.Added=False ' clear return variable
  900.  For Array.Index=1 To 5 ' loop through all player inventory
  901.     If UserRecord.Object(Array.Index)=False Then ' check for empty inventory
  902.        UserRecord.Object(Array.Index)=Object.Number ' add object index
  903.        UserRecord.ObjCharges(Array.Index)=Object.Charges ' add object charges
  904.        Item.Added=True ' set return flag
  905.        Exit Sub ' exit routine
  906.     Endif ' end check empty inventory
  907.  Next ' end loop through player inventory
  908. End Sub ' end routine to add item of treasure to player inventory
  909.  
  910.  Rem * routine removes an item of treasure from player inventory.
  911.  Rem * input variables:
  912.  Rem *   Inventory.Number - number of inventory.
  913.  Rem *   Leave.Item - false to leave inventory in room, true to discard.
  914.  
  915. Sub Discard.Inventory(Inventory.Number,Leave.Item)
  916.  On Local Error Resume Next ' local error resume
  917.  ' store player treasure index
  918.  Inventory.Index=UserRecord.Inv(Inventory.Number)
  919.  ' store player treasure charges
  920.  Inventory.Charges=UserRecord.Charges(Inventory.Number)
  921.  Call Read.Record(TreasureFile,Abs(Inventory.Index)) ' get treasure record of item
  922.  Weight=Weight-TreasureRecord.Weight ' subtract weight
  923.  If Weight<False Then ' compare weight
  924.     Weight=False ' clear weight
  925.  Endif ' end check weight
  926.  For Array.Index=Inventory.Number To 19 ' loop through player inventory
  927.     ' pack item removed
  928.     UserRecord.Inv(Array.Index)=UserRecord.Inv(Array.Index+1)
  929.     ' pack item removed
  930.     UserRecord.Charges(Array.Index)=UserRecord.Charges(Array.Index+1)
  931.  Next ' end loop through player inventory
  932.  UserRecord.Inv(20)=False ' clear last item
  933.  UserRecord.Charges(20)=False ' clear last item
  934.  If UserRecord.Inv(1)=False Then ' check player inventory empty
  935.     Weight=False ' clear weight
  936.  Endif ' end check player inventory
  937.  Select Case Inventory.Number ' select weapon
  938.  Case Weapon4 ' check armor being dropped
  939.     Weapon1=False ' clear item
  940.     Weapon4=False ' clear item
  941.  Case Weapon5 ' check shield being dropped
  942.     Weapon3=False ' clear item
  943.     Weapon5=False ' clear item
  944.  Case Weapon6 ' check weapon being dropped
  945.     Weapon2=False ' clear item
  946.     Weapon6=False ' clear item
  947.     Weapon10=False ' clear item
  948.  Case Weapon7 ' check ring being dropped
  949.     Weapon7=False ' clear item
  950.     Weapon8=False ' clear item
  951.     Weapon9=False ' clear item
  952.  End Select ' end check item
  953.  Select Case Inventory.Number ' select weapon
  954.  Case Is<Weapon4 ' check armor index
  955.     Weapon4=Weapon4-1 ' shift item index
  956.  Case Is<Weapon5 ' check shield index
  957.     Weapon5=Weapon5-1 ' shift item index
  958.  Case Is<Weapon6 ' check weapon index
  959.     Weapon6=Weapon6-1 ' shift item index
  960.  Case Is<Weapon7 ' check ring index
  961.     Weapon7=Weapon7-1 ' shift item index
  962.  End Select ' end check index shift
  963.  If Leave.Item=False Then ' verify drop item in room
  964.     ' routine to add item to room
  965.     Call Add.Room.Treasure(Inventory.Index,Inventory.Charges,False,Item.Added)
  966.  Endif ' end check room
  967. End Sub ' end routine to remove player item
  968.  
  969.  Rem * routine adds item to room.
  970.  Rem * input variables:
  971.  Rem *   Treasure.Number - treasure file index.
  972.  Rem *   Treasure.Charges - treasure charges.
  973.  Rem *   Treasure.Flags flags
  974.  Rem * output variables:
  975.  Rem *   Item.Added - return true if item added to room, false if not.
  976.  
  977. Sub Add.Room.Treasure(Treasure.Number, _
  978. Treasure.Charges,Treasure.Flags,Item.Added)
  979.  On Local Error Resume Next ' local error resume
  980.  Item.Added=False ' clear return flag
  981.  For Array.Index=1 To 20 ' loop through room treasure inventory
  982.     ' check empty room inventory
  983.     If RoomRecord.Treasure(Array.Index)=False Then
  984.        RoomRecord.Treasure(Array.Index)=Treasure.Number ' add treasure index
  985.        ' add treasure charges
  986.        RoomRecord.TreCharges(Array.Index)=Treasure.Charges
  987.        RoomRecord.Flags(Array.Index)=Treasure.Flags ' add treasure flags
  988.        Call Share.Room.Record(Room) ' write room record
  989.        Item.Added=True ' set return flag
  990.        Exit Sub ' exit routine
  991.     Endif ' end check empty inventory
  992.  Next ' end loop through room treasure inventory
  993. End Sub ' end routine to add item to room
  994.  
  995.  Rem * routine removes item of treasure from room.
  996.  Rem * input variables:
  997.  Rem *   Inventory.Number - room inventory number to remove.
  998.  
  999. Sub Discard.Room.Treasure(Inventory.Number)
  1000.  On Local Error Resume Next ' local error resume
  1001.  RoomRecord.Treasure(Inventory.Number)=False ' clear treasure items
  1002.  RoomRecord.TreCharges(Inventory.Number)=False ' clear treasure items
  1003.  RoomRecord.Flags(Inventory.Number)=False ' clear treasure items
  1004.  Call Share.Room.Record(Room) ' write room record
  1005. End Sub ' end routine to remove item from room
  1006.  
  1007.  Rem * routine adds object to room.
  1008.  Rem * input variables:
  1009.  Rem *   Object.Number - object index.
  1010.  Rem *   Object.Charges - object charges.
  1011.  Rem * output variables:
  1012.  Rem *   Item.Added - true if item added, false if not.
  1013.  
  1014. Sub Add.Room.Object(Object.Number,Object.Charges,Item.Added)
  1015.  On Local Error Resume Next ' local error resume
  1016.  Item.Added=False ' clear return flag
  1017.  For Array.Index=1 To 20 ' loop through room object inventory
  1018.     ' check empty object inventory
  1019.     If RoomRecord.Object(Array.Index)=False Then
  1020.        RoomRecord.Object(Array.Index)=Object.Number ' add object index
  1021.        RoomRecord.ObjCharges(Array.Index)=Object.Charges ' add object charges
  1022.        Call Share.Room.Record(Room) ' write room record
  1023.        Item.Added=True ' set return flag
  1024.        Exit Sub ' exit routine
  1025.     Endif ' end check empty object inventory
  1026.  Next ' end loop through room object inventory
  1027. End Sub ' end routine to add item to room
  1028.  
  1029.  Rem * routine removes an object from room.
  1030.  Rem * input variables:
  1031.  Rem *   Inventory.Number - room inventory number to remove.
  1032.  
  1033. Sub Discard.Room.Object(Inventory.Number)
  1034.  On Local Error Resume Next ' local error resume
  1035.  RoomRecord.Object(Inventory.Number)=False ' clear treasure items
  1036.  RoomRecord.ObjCharges(Inventory.Number)=False ' clear treasure items
  1037.  Call Share.Room.Record(Room) ' write room record
  1038. End Sub ' end routine to remove item from room
  1039.  
  1040.  Rem * routine removes an object from inventory.
  1041.  Rem * input variables:
  1042.  Rem *   Inventory.Number - player inventory number to remove.
  1043.  
  1044. Sub Discard.Inventory.Object(Inventory.Number)
  1045.  On Local Error Resume Next ' local error resume
  1046.  For Inventory.Count=Inventory.Number To 4 ' loop packer
  1047.     ' shift object items
  1048.     UserRecord.Object(Inventory.Count)=UserRecord.Object(Inventory.Count+1)
  1049.     ' shift object items
  1050.     UserRecord.ObjCharges(Inventory.Count)= _
  1051.     UserRecord.ObjCharges(Inventory.Count+1)
  1052.  Next ' end packing
  1053.  UserRecord.Object(5)=False ' clear treasure items
  1054.  UserRecord.ObjCharges(5)=False ' clear treasure items
  1055. End Sub ' end routine to remove item from room
  1056.  
  1057.  Rem * routine removes treasure from room after player leaves to new room.
  1058.  Rem * input variables:
  1059.  Rem *   Room - number of room to clean.
  1060.  
  1061. Sub Clean.Room
  1062.  On Local Error Resume Next ' local error resume
  1063.  If Room<=False Or Room>Lof(RoomFile)/Len(RoomRecord) Then ' check file bounds
  1064.     Exit Sub ' exit routine
  1065.  Endif ' end check file bounds
  1066.  Call Read.Room.Record(Room) ' get room record
  1067.  Call Clear.Container(0,True) ' routine to clear container record
  1068.  RoomRecord.Container=ContainerRec ' store container record in room
  1069.  Call Share.Room.Record(Room) ' write room record
  1070.  For Array.Index=1 To 20 ' loop through room treasure
  1071.     Treasure.Number=RoomRecord.Treasure(Array.Index) ' store treasure index
  1072.     If Treasure.Number>False And _
  1073.     Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then ' file bounds
  1074.        Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  1075.        If TreasureRecord.Permanent=False Then ' check permanent treasure
  1076.           If TreasureRecord.Invisible=False Then ' check invisible treasure
  1077.              ' check treasure flags
  1078.              If RoomRecord.Flags(Array.Index)=False Then
  1079.                 ' remove item from room
  1080.                 Call Discard.Room.Treasure(Array.Index)
  1081.              Endif ' end check flags
  1082.           Endif ' end check invisible
  1083.        Endif ' end check permanent
  1084.     Endif ' end check file bounds
  1085.  Next ' end loop through room treasure
  1086. End Sub ' end routine to clean room
  1087.  
  1088.  Rem * routine lists users.
  1089.  
  1090. Sub User.List
  1091.  On Local Error Resume Next ' local error resume
  1092.  Call Share.Record(UserFile,User.Index) ' store player user record
  1093.  Outpt="(hit <control-k> to interrupt).." ' make message
  1094.  Call IO.O ' send message
  1095.  Graphics.Off=True ' reset color
  1096.  Gosub Heading ' subroutine to display heading
  1097.  Allow.Break=True ' enable control-k checking
  1098.  Break=False ' reset control-k flag
  1099.  Continue=False ' reset continuous flag
  1100.  Page.Length=3 ' set page length
  1101.  For User.Number=1 To Lof(UserFile)/Len(UserRecord) ' loop through all users
  1102.     Call Read.Record(UserFile,User.Number) ' get next user record
  1103.     Inpt=UserRecord.CodeName ' store user codename
  1104.     Call Decrypt(Inpt) ' routine to decrypt codename
  1105.     Inpt=Lcase$(Inpt) ' lowercase codename,
  1106.     List.User=True ' set list user flag
  1107.     If Left$(Inpt,9)=Deleted$ Then ' check user record exists
  1108.        List.User=False ' reset list user flag
  1109.     Else ' check user
  1110.        If UserRecord.Flags And Locked.User Then ' check locked user
  1111.           If Normal.User Then ' compare DM or Sysop
  1112.              List.User=False ' reset list user flag
  1113.           Endif ' end compare normal user
  1114.        Endif ' end check locked mailbox
  1115.     Endif ' end check user
  1116.     If List.User Then ' check list user flag
  1117.        Outpt=Mid$(Str$(User.Number),2)+"." ' make output line
  1118.        Outpt=Outpt+Space$(7-Len(Outpt)) ' with user number,
  1119.        Mid$(Inpt,1,1)=Ucase$(Mid$(Inpt,1,1)) ' with codename,
  1120.        Outpt=Outpt+Inpt+" " ' make output line
  1121.        Inpt=UserRecord.ClassName ' with user class name,
  1122.        Call Decrypt(Inpt) ' decrypt classname
  1123.        Outpt=Outpt+Inpt+" " ' make output line
  1124.        If UserRecord.Race<=False Then ' verify race in bounds
  1125.           UserRecord.Race=1 ' reset race
  1126.        Endif ' end verify race
  1127.        Inpt=Race(UserRecord.Race) ' with user race name
  1128.        Inpt=Rtrim$(Inpt) ' make output line
  1129.        Inpt=Inpt+Space$(8-Len(Inpt)) ' append blanks
  1130.        Outpt=Outpt+Inpt ' with race name,
  1131.        If UserRecord.Level<=False Then ' check player level
  1132.           Inpt=" "+Dead$ ' player is dead, append
  1133.        Else ' check level
  1134.           Inpt=Str$(UserRecord.Level) ' add player level,
  1135.        Endif ' end check level
  1136.        Inpt=Inpt+Space$(7-Len(Inpt)) ' make output line
  1137.        If UserRecord.ClassType>=AsstDM Then ' check special class type,
  1138.           Inpt=Inpt+"*" ' add an asterick for DMs
  1139.        Endif ' end check class type
  1140.        If UserRecord.Flags And Locked.User Then ' check locked user
  1141.           Inpt=Inpt+Mask$ ' add mask character for locked mailbox
  1142.        Endif ' end check class type
  1143.        Outpt=Outpt+Inpt ' add to output line
  1144.        Call IO.O ' send output line
  1145.        If Break Then ' check control-k entered
  1146.           Exit For ' exit loop through user file
  1147.        Endif ' end check control-k
  1148.        Page.Length=Page.Length+1 ' increment page length
  1149.        If Page.Length=UserRecord.Pagelength Then ' compare page length
  1150.           Page.Length=3 ' reset page length
  1151.           If Continue=False Then ' check continuous flag
  1152.              Call More.Prompt ' pause for more
  1153.              If No Then ' more response
  1154.                 Exit For ' exit loop through user file
  1155.              Endif ' end check response
  1156.              Gosub Heading ' subroutine to display heading
  1157.           Endif ' end check continuous flag
  1158.        Endif ' end compare page length
  1159.     Endif ' end check valid user
  1160.  Next ' end loop through user file
  1161.  Allow.Break=False ' disable control-k checking
  1162.  If Break Then ' check control-k flag
  1163.     Break=False ' reset control-k flag
  1164.     Outpt=Nul ' set output to null
  1165.     Call IO.O ' send empty return
  1166.  Endif ' end check control-k flag
  1167.  If Page.Length>3 Then ' recheck page length
  1168.     Call More.Prompt ' display more prompt
  1169.  Endif ' end check last page length
  1170.  Call Read.Record(UserFile,User.Index) ' get current user record
  1171.  Exit Sub ' exit routine
  1172.  
  1173. Heading:
  1174.  ' make heading message
  1175.  Outpt="The Adventure Door v"+Version$+" User List For "+FNclock$+"."
  1176.  Call IO.O ' send message
  1177.  Outpt=Nul ' empty cr/lf
  1178.  Call IO.O ' send empty cr/lf
  1179.  ' make heading message
  1180.  Outpt="Number User Name                      Class Name"+ _
  1181.  "           Race     Level DM"
  1182.  Call IO.O ' send heading message
  1183.  Outpt=String$(76,"-") ' make heading
  1184.  Call IO.O ' send heading
  1185.  Return ' exit subroutine
  1186. End Sub ' end routine to display users
  1187.  
  1188.  Rem * routine reads player userfile record, sets some variables.
  1189.  Rem * input variables:
  1190.  Rem *   User.Index - number of user file record.
  1191.  
  1192. Sub Get.User.Record
  1193.  On Local Error Resume Next ' local error resume
  1194.  Call Read.Record(UserFile,User.Index) ' read user file record
  1195.  Weight=False ' clear inventory weight
  1196.  For Inventory.Number=1 To 20 ' loop through player inventory
  1197.     Treasure.Number=UserRecord.Inv(Inventory.Number) ' store treasure number
  1198.     If Treasure.Number>False And _
  1199.     Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then ' file bounds
  1200.        Call Read.Record(TreasureFile,Treasure.Number) ' get treasur record
  1201.        Weight=Weight+TreasureRecord.Weight ' add weight
  1202.     Endif ' end check file bounds
  1203.  Next ' end loop through player userfile record
  1204.  User.Echo=UserRecord.Echo ' store user preference
  1205.  User.LineFeeds=UserRecord.LineFeeds ' store user preference
  1206.  User.LineLength=UserRecord.LineLength ' store user preference
  1207.  User.PageLength=UserRecord.PageLength ' store user preference
  1208.  User.Wordwrap=UserRecord.Wordwrap ' store user preference
  1209.  Call Get.User.Stats ' routine to set any special player statistics
  1210.  Room=UserRecord.Room ' store player room number
  1211.  Hidden.Player=False ' reset hidden player flag
  1212.  If UserRecord.Brief Then ' check player brief mode
  1213.     Action.Prompt="Next?" ' store command prompt
  1214.  Else ' check player
  1215.     Action.Prompt="Command? " ' store command prompt
  1216.  Endif ' end compare player brief mode
  1217.  If UserRecord.Beauty<=1 Or UserRecord.Beauty>MaxStat Then ' check lady player
  1218.     UserRecord.Beauty=Int(Rnd*15+5) ' recalculate lady stats
  1219.  Endif ' end check lady stats
  1220.  ' check lady player
  1221.  If UserRecord.Glamour<=1 Or UserRecord.Glamour>MaxStat Then
  1222.     UserRecord.Glamour=Int(Rnd*15+5) ' recalculate lady stats
  1223.  Endif ' end check lady stats
  1224.  Sorting=UserRecord.Sort ' get user sort preference
  1225. End Sub ' end routine to read user record
  1226.  
  1227.  Rem * routine sets any special player statistics and attributes.
  1228.  
  1229. Sub Get.User.Stats
  1230.  On Local Error Resume Next ' local error resume
  1231.  If UserRecord.Flags And Special.Char1 Then ' check player is town mayor
  1232.     Town.Mayor=True ' set town mayor flag
  1233.  Else ' check player
  1234.     Town.Mayor=False ' set town mayor flag
  1235.  Endif ' end check player special stats
  1236.  If UserRecord.Flags And Special.Char2 Then ' check player is governor
  1237.     Governor=True ' set governor flag
  1238.  Else ' check player
  1239.     Governor=False ' set governor flag
  1240.  Endif ' end check player special stats
  1241.  If UserRecord.Flags And Special.Char3 Then ' check player is guild master
  1242.     Guild.Master=True ' set guild master flag
  1243.  Else ' check player
  1244.     Guild.Master=False ' set guild master flag
  1245.  Endif ' end check player special stats
  1246.  If UserRecord.Flags And Special.Char4 Then ' check player is sysop
  1247.     Sysop=True ' set sysop flag
  1248.  Else ' check player
  1249.     Sysop=False ' set sysop flag
  1250.  Endif ' end check player special stats
  1251.  If UserRecord.ClassType=AsstDM Then ' check player is assistant DM
  1252.     Dungeon.Master.Assistant=True ' set asst. dm flag
  1253.  Else ' check player
  1254.     Dungeon.Master.Assistant=False ' set asst. dm flag
  1255.  Endif ' end check player
  1256.  If UserRecord.ClassType=DM Then ' check player is dungeon master
  1257.     Dungeon.Master=True ' set dm flag
  1258.  Else ' check player
  1259.     Dungeon.Master=False ' set dm flag
  1260.  Endif ' end check player
  1261.  ' check special player types
  1262.  If Dungeon.Master Or Dungeon.Master.Assistant Or Sysop Then
  1263.     Normal.User=False ' set normal player mode off
  1264.  Else ' check player
  1265.     Normal.User=True ' set normal  player mode on
  1266.  Endif ' end check player
  1267. End Sub ' end routine to set player special statistics/attributes
  1268.  
  1269.  Rem * routine writes user record.
  1270.  
  1271. Sub Put.User.Record
  1272.  On Local Error Resume Next ' local error resume
  1273.  UserRecord.Echo=User.Echo ' write user preference
  1274.  UserRecord.LineFeeds=User.LineFeeds ' write user preference
  1275.  UserRecord.LineLength=User.LineLength ' write user preference
  1276.  UserRecord.PageLength=User.PageLength ' write user preference
  1277.  UserRecord.Wordwrap=User.Wordwrap ' write user preference
  1278.  UserRecord.Sort=Sorting ' user sort preference
  1279.  UserRecord.Room=Room ' store current room
  1280.  Call Share.Record(UserFile,User.Index) ' write user record
  1281. End Sub ' end routine to write user record
  1282.  
  1283.  Rem * routine updates player health, room lights, drunkeness, and poison.
  1284.  Rem * input variables:
  1285.  Rem *   Room.Rate - stores rounds counter.
  1286.  Rem *   Room.Health.Rate - stores health update rate.
  1287.  
  1288. Sub Health.Update
  1289.  On Local Error Resume Next ' local error resume
  1290.  Graphics.Off=False ' reset color
  1291.  Room.Rate=Room.Rate+1 ' increment room health counter
  1292.  If Room.Rate<Room.Health.Rate Then ' compare health rate
  1293.     Exit Sub ' exit routine
  1294.  Endif ' end check counter
  1295.  Room.Rate=False ' reset room health counter
  1296.  ' determine any lights in player inventory go out
  1297.  For Inventory.Number=1 To 20 ' loop through player inventory
  1298.     ' get player inventory charges
  1299.     Charges.Number=UserRecord.Charges(Inventory.Number)
  1300.     If Charges.Number<False Then ' check for light on
  1301.        Charges.Number=Charges.Number+1 ' decrement negatively light charges
  1302.        UserRecord.Charges(Inventory.Number)=Charges.Number ' store new charges
  1303.        If Charges.Number=False Then ' compare charges
  1304.           ' get treasure record
  1305.           Call Read.Record(TreasureFile,UserRecord.Inv(Inventory.Number))
  1306.           Outpts=TreasureRecord.ShortName ' get light name
  1307.           Outpts=Rtrim$(Outpts) ' trim name
  1308.           Outpts=Lcase$(Outpts) ' lowercase name
  1309.           Outpt="The "+Outpts+" went out!" ' make light out message
  1310.           Call IO.O ' send message
  1311.        Endif ' end compare charges remaining
  1312.     Endif ' end check light on
  1313.  Next ' end loop through player inventory
  1314.  If Intoxicated>False Then ' verify player drunk
  1315.     Intoxicated=Intoxicated-1 ' decrement drunkeness
  1316.     If Intoxicated<=False Then ' compare drunkeness counter
  1317.        Intoxicated=False ' reset counter
  1318.        Outpt="Your drunk is over.." ' make message
  1319.     Else ' check drunk
  1320.        UserRecord.Fatigue=UserRecord.Fatigue-2 ' decrement fatigue for drunk
  1321.        If UserRecord.Fatigue<=False Then ' compare fatigue
  1322.           UserRecord.Fatigue=False ' reset fatigue
  1323.           Intoxicated=False ' reset drunkeness
  1324.           Outpt="Your drunk is over.." ' make message
  1325.        Else ' compare still drunk
  1326.           Outpt="You feel drunk!" ' make message
  1327.        Endif ' end compare drunk
  1328.     Endif ' end check drunk
  1329.     Call IO.O ' send drunkeness message
  1330.  Else ' verify drunk player
  1331.     New.Stat!=UserRecord.Fatigue+4 ' increment player fatigue
  1332.     If New.Stat!>MaxInt Then ' check maximum fatigue
  1333.        New.Stat!=MaxInt ' reduce to maximum integer
  1334.     Endif ' end check maximum fatigue
  1335.     UserRecord.Fatigue=Cint(New.Stat!) ' store new fatigue
  1336.  Endif ' end verify drunk player
  1337.  If UserRecord.Poison Then ' verify player poisoned
  1338.     UserRecord.Vitality=UserRecord.Vitality-2 ' decrement player vitality
  1339.     Outpt="You feel poison running through your veins!" ' make message
  1340.     Call IO.O ' send poisoned message
  1341.     If UserRecord.Vitality<=False Then ' check vitality
  1342.        UserRecord.Vitality=False ' reset vitality
  1343.        Message1="You finally died from your poisonous wounds!" ' message
  1344.        Call Player.Died ' routine for dead player
  1345.     Endif ' end check vitality
  1346.  Else ' verify poisoned player
  1347.     New.Stat!=UserRecord.Vitality+3 ' increment player vitality
  1348.     If New.Stat!>MaxInt Then ' check maximum integer
  1349.        New.Stat!=MaxInt ' reset to maximum integer
  1350.     Endif ' end check maximum integer
  1351.     UserRecord.Vitality=Cint(New.Stat!) ' store new vitality
  1352.  Endif ' end verify poisoned player
  1353.  New.Stat!=UserRecord.Magic+2 ' increment player magic points
  1354.  If New.Stat!>MaxInt Then ' compare magic points to maximum integer
  1355.     New.Stat!=MaxInt ' reset to maximum integer
  1356.  Endif ' end check maximum integer
  1357.  UserRecord.Magic=Cint(New.Stat!) ' store new magic points
  1358.  New.Stat!=UserRecord.Psionic+1 ' increment psionic points
  1359.  If New.Stat!>MaxInt Then ' check maximum psionic points
  1360.     New.Stat!=MaxInt ' reset to maximum integer
  1361.  Endif ' end check maximum integer
  1362.  UserRecord.Psionic=Cint(New.Stat!) ' store new psionic points
  1363.  Call New.Stats ' routine to update statistics
  1364.  If Invisible>False Then ' check invisible counter
  1365.     Invisible=Invisible-1 ' decrement invisible counter
  1366.     If Invisible<=False Then ' compare counter
  1367.        UserRecord.Invisible=False ' reset invisible
  1368.        Invisible=False ' reset invisible
  1369.        Outpt="You are no longer invisible!" ' make message
  1370.        Call IO.O ' send invisible message
  1371.     Endif ' end compare counter
  1372.  Endif ' end check counter
  1373. End Sub ' end health update routine
  1374.  
  1375.  Rem * routine searches current room, displays hidden items.
  1376.  
  1377. Sub Search.Room
  1378.  On Local Error Resume Next ' local error resume
  1379.  Outpt="You search the room.." ' make message
  1380.  Call IO.O ' send search message
  1381.  Graphics.Off=True ' reset color
  1382.  Outpt="You find " ' make first display message
  1383.  Carriage.Return=True ' disable cr/lf
  1384.  Call IO.O ' send first message
  1385.  Items.Displayed=False ' items displayed counter
  1386.  For Room.Objects=1 To 20 ' loop through room objects
  1387.     Object.Number=RoomRecord.Object(Room.Objects) ' get room object index
  1388.     ' file bounds
  1389.     If Object.Number>False And _
  1390.     Object.Number<=Lof(ObjectFile)/Len(ObjectRecord) Then
  1391.        Call Read.Record(ObjectFile,Object.Number) ' get object record
  1392.        Charges.Number=False ' set display flag
  1393.        If ObjectRecord.Invisible Then ' check object invisible
  1394.           If Rnd<.5 Then ' random chance
  1395.              Charges.Number=True ' set display flag
  1396.           Endif ' end random chance
  1397.        Endif ' end check invisible object
  1398.        If ObjectRecord.Hidden Then ' check object hidden
  1399.           If Normal.User Then ' verify non DM
  1400.              Charges.Number=False ' set display flag
  1401.           Endif ' end verify normal player
  1402.        Endif ' end check hidden object
  1403.        If Charges.Number Then ' check display flag
  1404.           Carriage.Return=True ' disable cr/lf
  1405.           Call IO.O ' send previous string
  1406.           Outpt=Rtrim$(ObjectRecord.ObjectName)+", " ' store object name
  1407.           Items.Displayed=Items.Displayed+1 ' increment item displayed counter
  1408.        Endif ' end check display flag
  1409.     Endif ' end check file bounds
  1410.  Next ' end loop through room objects
  1411.  For Room.Treasure=1 To 20 ' loop through room treasure
  1412.     Treasure.Number=RoomRecord.Treasure(Room.Treasure) ' get treasure index
  1413.     If Treasure.Number>False And _
  1414.     Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then ' file bounds
  1415.        Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  1416.        Charges.Number=False ' set display flag
  1417.        If TreasureRecord.Invisible Then ' check treasure invisible
  1418.           If Rnd<.5 Then ' random chance
  1419.              Charges.Number=True ' set display flag
  1420.           Endif ' end random chance
  1421.        Endif ' end invisible treasure
  1422.        ' check treasure hidden
  1423.        If RoomRecord.Flags(Room.Treasure)=Hidden.Object Then
  1424.           If Rnd<.5 Then ' random chance
  1425.              Charges.Number=True ' set display flag
  1426.           Endif ' end random chance
  1427.        Endif ' end check hidden treasure
  1428.        If Charges.Number Then ' check display flag
  1429.           Carriage.Return=True ' disable cr/lf
  1430.           Call IO.O ' send previous string
  1431.           Outpt=Rtrim$(TreasureRecord.TreasureName)+", " ' store treasure name
  1432.           Items.Displayed=Items.Displayed+1 ' increment displayed counter
  1433.        Endif ' end check display flag
  1434.     Endif ' end check file bounds
  1435.  Next ' end loop through room treasure
  1436.  If Items.Displayed=False Then ' check items displayed counter
  1437.     Outpt="nothing.." ' make message
  1438.  Else ' check item counter
  1439.     Outpt=Left$(Outpt,Len(Outpt)-2)+"." ' trim comma, add period
  1440.     If Items.Displayed>1 Then ' check counter
  1441.        Outpt="and "+Outpt ' append string
  1442.     Endif ' end check counter
  1443.  Endif ' end check counter
  1444.  Call IO.O ' send message
  1445. End Sub ' end routine to search room
  1446.  
  1447.  Rem * routine processes actions, routine is entered when a trigger is
  1448.  Rem * activated.
  1449.  Rem * input variables:
  1450.  Rem *   Activate.Action$ - the display string which activated the action.
  1451.  Rem *   Trigger.Action$ - prefix string of what hit player.
  1452.  
  1453. Sub Actions(Activate.Action$,Trigger.Action$)
  1454.  On Local Error Resume Next ' local error resume
  1455.  If Room=1 Then ' check resurrected room
  1456.     Exit Sub ' exit routine
  1457.  Endif ' end check room
  1458.  Inpt=Nul ' reset output string
  1459.  Graphics.Off=False ' reset color
  1460.  Select Case ActionRecord.Inventory ' selection of room action
  1461.  Case 1 ' inventory action 1 breaks all weapons
  1462.     Item.Broke=False ' weapon broke flag
  1463.     Weapon2=False ' reset weapon held
  1464.     Weapon6=False ' reset weapon held
  1465.     Weapon10=False ' reset weapon held
  1466.     For Inventory.Number=1 To 20 ' loop through all player inventory
  1467.        Treasure.Number=UserRecord.Inv(Inventory.Number) ' get treasure index
  1468.        If Treasure.Number>False And _
  1469.        Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then 'file bounds
  1470.           Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  1471.           If TreasureRecord.Plus Then ' check weapon plus
  1472.              If TreasureRecord.Type=False Then ' check weapon
  1473.                 ' check weapon charges
  1474.                 If UserRecord.Charges(Inventory.Number) Then
  1475.                    ' clear weapon charges
  1476.                    UserRecord.Charges(Inventory.Number)=False
  1477.                    Item.Broke=True ' set weapon broke flag
  1478.                 Endif ' end check charges
  1479.              Endif ' end check weapon
  1480.           Endif ' end check weapon plus
  1481.        Endif ' end check file bounds
  1482.     Next ' end loop through player inventory
  1483.     If Item.Broke Then ' compare weapon broke flag
  1484.        Outpt=Activate.Action$ ' copy routine string
  1485.        Call IO.O ' send string
  1486.        Outpt="All your weapons break!" ' make message
  1487.        Call IO.O ' send weapon message
  1488.     Endif ' end compare broke flag
  1489.  Case 2 ' inventory action 2 breaks all shields
  1490.     Item.Broke=False ' set shield broke flag
  1491.     Weapon3=False ' clear shield held
  1492.     Weapon5=False ' clear shield held
  1493.     For Inventory.Number=1 To 20 ' loop through all player inventory
  1494.        Treasure.Number=UserRecord.Inv(Inventory.Number) ' get treasure index
  1495.        If Treasure.Number>False And _
  1496.        Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then 'file bounds
  1497.           Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  1498.           If TreasureRecord.Type<False Then ' check shield type
  1499.              If UserRecord.Charges(Inventory.Number) Then ' check charges
  1500.                 ' clear shield charges
  1501.                 UserRecord.Charges(Inventory.Number)=False
  1502.                 Item.Broke=True ' set shield broke flag
  1503.              Endif ' end check charges
  1504.           Endif ' end check shield
  1505.        Endif ' end check file bounds
  1506.     Next ' end loop through player inventory
  1507.     If Item.Broke Then ' compare shield broke flag
  1508.        Outpt=Activate.Action$ ' copy routine string
  1509.        Call IO.O ' send string
  1510.        Outpt="All your shields break!" ' make message
  1511.        Call IO.O ' send shield message
  1512.     Endif ' end compare broke flag
  1513.  Case 3 ' inventory action 3 breaks all armor
  1514.     Item.Broke=False ' set armor broke flag
  1515.     Weapon1=False ' clear armor worn
  1516.     Weapon4=False ' clear armor worn
  1517.     For Inventory.Number=1 To 20 ' loop through all player inventory
  1518.        Treasure.Number=UserRecord.Inv(Inventory.Number) ' get treasure index
  1519.        If Treasure.Number>False And _
  1520.        Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then 'file bounds
  1521.           Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  1522.           If TreasureRecord.Type>False Then ' check armor
  1523.              If UserRecord.Charges(Inventory.Number) Then ' check charges
  1524.                 ' clear armor charges
  1525.                 UserRecord.Charges(Inventory.Number)=False
  1526.                 Item.Broke=True ' set armor broke flag
  1527.              Endif ' end check charges
  1528.           Endif ' end check armor
  1529.        Endif ' end check file bounds
  1530.     Next ' end loop through player inventory
  1531.     If Item.Broke Then ' compare armor broke flag
  1532.        Outpt=Activate.Action$ ' copy routine message
  1533.        Call IO.O ' send message
  1534.        Outpt="All your armor breaks!" ' make message
  1535.        Call IO.O ' send armor message
  1536.     Endif ' end compare broke flag
  1537.  Case 4 ' inventory action 4 breaks all magic items
  1538.     Item.Broke=False ' set magic item broke flag
  1539.     Weapon7=False ' clear ring held
  1540.     Weapon8=False ' clear ring held
  1541.     For Inventory.Number=1 To 20 ' loop through all player inventory
  1542.        Treasure.Number=UserRecord.Inv(Inventory.Number) ' get treasure index
  1543.        If Treasure.Number>False And _
  1544.        Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then 'file bounds
  1545.           Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  1546.           If TreasureRecord.Spell Then ' check magic item
  1547.              If UserRecord.Charges(Inventory.Number) Then ' check charges
  1548.                 ' clear magic item charges
  1549.                 UserRecord.Charges(Inventory.Number)=False
  1550.                 Item.Broke=True ' set magic item broke flag
  1551.              Endif ' end check charges
  1552.           Endif ' end check magic item
  1553.        Endif ' end check file bounds
  1554.     Next ' end loop through player inventory
  1555.     If Item.Broke Then ' compare magic item broke flag
  1556.        Outpt=Activate.Action$ ' copy routine string
  1557.        Call IO.O ' send string
  1558.        Outpt="All your magic items break!" ' make message
  1559.        Call IO.O ' send magic item message
  1560.     Endif ' end compare broke flag
  1561.  End Select ' end selection of action
  1562.  If ActionRecord.Fumble Then ' verify room fumble action
  1563.     Call Fumble ' routine to fumble weapon/shield
  1564.  Endif ' end verify fumble action
  1565.  Teleport.Number=ActionRecord.Teleport
  1566.  If Teleport.Number>False And Teleport.Number<>Room Then
  1567.     Outpt=Activate.Action$ ' copy routine string
  1568.     Call IO.O ' send string
  1569.     Outpt="You are teleported elsewhere!" ' make message
  1570.     Call IO.O ' send teleport message
  1571.     Next.Room=Teleport.Number ' store new room number
  1572.     Teleported=True ' set teleporting flag
  1573.     Call Enter.Room ' routine to move player to new room
  1574.  Endif ' end verify teleport action
  1575.  Room.Hits#=Cdbl(Int(ActionRecord.HitPoints)) ' store room hit action
  1576.  If Room.Hits#>False Then ' verify hit points action
  1577.     Outpt=Activate.Action$ ' copy routine string
  1578.     Call IO.O ' send string
  1579.     Outpt=Trigger.Action$ ' copy second routine string
  1580.     Call Hit.Player(Room.Hits#) ' routine to hit player
  1581.  Endif ' end verify hit points action
  1582. End Sub ' end routine to activate room actions
  1583.  
  1584.  Rem * routine to verify monster blocking exits, then check valid direction.
  1585.  Rem * input variables:
  1586.  Rem *   Direction.Number - direction to go.
  1587.  Rem * output variables:
  1588.  Rem *   Next.Room - number of new room to enter.
  1589.  
  1590. Sub Verify.Room(Direction.Number)
  1591.  On Local Error Resume Next ' local error resume
  1592.  New.Room=False ' enter new room flag
  1593.  If UserRecord.ClassType<Lady Then ' check normal player class
  1594.     For Array.Index=1 To Number.Monsters ' loop through monsters in room
  1595.        If MonsterArray(Array.Index).Block Then ' check monster blocks exits
  1596.           ' random percent
  1597.           If Rnd<(MonsterArray(Array.Index).BlockPercent/100) Then
  1598.              Inpt=MonsterArray(Array.Index).MonsterName ' store monster name
  1599.              Inpt=Rtrim$(Inpt) ' trim name
  1600.              Outpt="The "+Inpt+" blocks your way!" ' make block message
  1601.              Call IO.O ' send block message
  1602.              Exit Sub ' exit routine
  1603.           Endif ' end check random percentage
  1604.        Endif ' end check monster blocks exits
  1605.     Next ' end loop through monsters
  1606.  Endif ' end check normal user
  1607.  Next.Room=RoomRecord.Direct(Direction.Number) ' get room number of direction
  1608.  If Next.Room=False Then ' check next room number
  1609.     If Normal.User Then ' check DM status
  1610.        Outpt="You can't go in that direction!" ' make entry message
  1611.        Call IO.O ' send entry message
  1612.     Else ' check DM status
  1613.        Call Add.Room(Direction.Number,Room.Added) ' routine to add new room
  1614.        New.Room=Room.Added ' store new room flag
  1615.     Endif ' end check DM
  1616.     Exit Sub ' exit routine
  1617.  Else ' check next room number
  1618.     ' routine to verify room direction restricted
  1619.     Call Restrict(Direction.Number,Restricted)
  1620.     If Restricted Then ' check room restricted flag
  1621.        Outpt="Your level does not permit entrance to that room!" ' message
  1622.        Call IO.O ' send restricted message
  1623.        Exit Sub ' exit routine
  1624.     Endif ' end check room restricted
  1625.     ' routine to verify room entry type restricted
  1626.     Call Restrict.Room.Type(Restricted)
  1627.     If Restricted Then ' check room restricted flag
  1628.        Outpt="You can't walk to that room!" ' message
  1629.        Call IO.O ' send restricted message
  1630.        Exit Sub ' exit routine
  1631.     Endif ' end check room restricted
  1632.  Endif ' end check next room number
  1633.  New.Room=True ' store next room valid flag
  1634. End Sub ' end routine to verify room entry, direction
  1635.  
  1636.  Rem * routine to exit a room with the Out command.
  1637.  
  1638. Sub Exit.Room
  1639.  On Local Error Resume Next ' local error resume
  1640.  Entry.Command=Last.Command.Number ' store room entry command
  1641.  User.Command="O" ' store out command
  1642.  Last.Command="OUT" ' store out command
  1643.  Last.Command.Number=True ' reset command type
  1644.  Call Verify.Room(5) ' routine to verify valid room
  1645.  If New.Room Then ' check valid room flag
  1646.     Call Enter.Room ' routine to move player to room
  1647.  Endif ' end check valid room
  1648. End Sub ' end routine to go Out
  1649.  
  1650.  Rem * routine to use the Up direction.
  1651.  
  1652. Sub Climb
  1653.  On Local Error Resume Next ' local error resume
  1654.  Entry.Command=Last.Command.Number ' store room entry command
  1655.  User.Command="U" ' store up command
  1656.  Last.Command="UP" ' store up command
  1657.  Last.Command.Number=True ' store command type
  1658.  Call Verify.Room(6) ' routine to check valid room
  1659.  If New.Room Then ' check valid room flag
  1660.     Call Enter.Room ' routine to move player to room
  1661.  Endif ' end check valid room
  1662. End Sub ' end routine to go Up
  1663.  
  1664.  Rem * routine processes room traps.
  1665.  
  1666. Sub Traps
  1667.  On Local Error Resume Next ' local error resume
  1668.  New.Room=False ' reset next room flag
  1669.  If Rnd<.5 Then ' random chance
  1670.     Outpt="It's trapped! " ' make trap message
  1671.     Select Case ObjectRecord.Trap ' selection of room trap type
  1672.     Case 1 ' type 1
  1673.        Outpt=Outpt+"Poison needles!" ' make trap message
  1674.        Call IO.O ' send trap message
  1675.        UserRecord.Poison=True ' set player poison flag
  1676.     Case 2 ' type 2
  1677.        New.Room=ObjectRecord.Teleport ' store teleport room number
  1678.        ' file bounds
  1679.        If New.Room>False And New.Room<=Lof(RoomFile)/Len(RoomRecord) Then
  1680.           If New.Room<>Room Then ' check destination room for recursion
  1681.              Outpt=Outpt+"Falling door!" ' make trap message
  1682.              Call IO.O ' send trap message
  1683.              Pass.Door=False ' clear pass door flag
  1684.              Number.Monsters=False ' clear number of monsters
  1685.              Next.Room=New.Room ' store room trap teleport number
  1686.              Teleported=True ' set teleporting flag
  1687.              Call Enter.Room ' routine to move player to a room
  1688.           Endif ' end check destination room
  1689.        Endif ' end check file bounds
  1690.     Case 3 ' type 3
  1691.        Outpt=Outpt+"Deadly spears!" ' make trap message
  1692.        Call IO.O ' send trap message
  1693.        Outpt="You are hit for" ' make hits message
  1694.        ' get object trap hits on player
  1695.        Room.Hits#=Cdbl(Int(ObjectRecord.Teleport))
  1696.        If Room.Hits#>False Then ' check hits
  1697.           Call Hit.Player(Room.Hits#) ' routine to hit player
  1698.        Endif ' end check hits
  1699.     End Select ' end selection of trap type
  1700.  Endif ' end check random chance
  1701. End Sub ' end routine for room traps
  1702.  
  1703.  Rem * routine to hide player.
  1704.  
  1705. Sub Hide.User
  1706.  On Local Error Resume Next ' local error resume
  1707.  If Hidden.Player Then ' check player already hidden
  1708.     Outpt="You hide in the shadows!" ' make hide message
  1709.     Call IO.O ' send hide message
  1710.     Exit Sub ' exit routine
  1711.  Endif ' end check player hidden
  1712.  Hide.Flag=False ' set hide flag
  1713.  If Number.Monsters=False Then ' check number of monsters in room
  1714.     Hide.Flag=True ' set hide flag
  1715.  Else ' check monsters
  1716.     If Rnd>.66 Then ' random chance
  1717.        Hide.Flag=True ' set hide flag
  1718.     Endif ' end check random chance
  1719.  Endif ' end check monsters in room
  1720.  If Hide.Flag Then ' check hide flag
  1721.     Hidden.Player=True ' set player hide flag
  1722.     Outpt="You hide in the shadows!" ' make hide message
  1723.  Else ' check hide flag
  1724.     Outpt="Didn't work!" ' make hide message
  1725.  Endif ' end check hide flag
  1726.  Call IO.O ' send hide message
  1727. End Sub ' end routine to hide player
  1728.  
  1729.  Rem * routine for player to use a vehicle.
  1730.  
  1731. Sub Enter.Vehicle
  1732.  On Local Error Resume Next ' local error resume
  1733.  Call Check.Room.Treasure ' routine finds vehicle name in room
  1734.  If Index.Number=False Then ' check room vehicle found
  1735.     Outpt="That's not a vehicle!" ' make error message
  1736.     Call IO.O ' send error message
  1737.     Exit Sub ' exit routine
  1738.  Endif ' end check vehicle found
  1739.  If TreasureRecord.Vehicle=False Then ' check item is vehicle
  1740.     Outpt="That's not a vehicle!" ' make error message
  1741.     Call IO.O ' send error message
  1742.     Exit Sub ' exit routine
  1743.  Endif ' end check vehicle
  1744.  Outpts=TreasureRecord.ShortName ' store treasure name
  1745.  Outpts=Rtrim$(Outpts) ' trim name
  1746.  Outpts=Lcase$(Outpts) ' lowercase name
  1747.  If Charges.Number=False Then ' check vehicle hits
  1748.     Outpt="The "+Outpts+" is damaged!" ' make error message
  1749.     Call IO.O ' send error message
  1750.     Exit Sub ' exit routine
  1751.  Endif ' end chekc vehicle hits
  1752.  Vehicle1=Array.Number ' store vehicle variable
  1753.  Vehicle2=Charges.Number ' store vehicle variable
  1754.  Vehicle3=Index.Number ' store vehicle variable
  1755.  Vehicle4=TreasureRecord.VehicleType ' store vehicle variable
  1756.  Outpt="You enter the "+Outpts+"." ' make vehicle message
  1757.  Call IO.O ' send vehicle message
  1758. End Sub ' end routine to use vehicle
  1759.  
  1760.  Rem * routine to move player and vehicle in a direction or through a portal.
  1761.  
  1762. Sub Ride.Vehicle
  1763.  On Local Error Resume Next ' local error resume
  1764.  If Vehicle3=False Then ' check player using a vehicle
  1765.     Outpt="You're not riding a vehicle!" ' make error message
  1766.     Call IO.O ' send error message
  1767.     Exit Sub ' exit routine
  1768.  Endif ' end check player vehicle
  1769.  User.Command=Parsed.Command1 ' store direction parameter
  1770.  Call Get.Direction(Direction.Number) ' routine verifies direction
  1771.  If Direction.Number Then ' compare direction number
  1772.     Next.Room=RoomRecord.Direct(Direction.Number) ' get room direction
  1773.     If Next.Room=False Then ' check room direction number
  1774.        Outpt="You can't travel in that direction!" ' make error message
  1775.        Call IO.O ' send error message
  1776.        Exit Sub ' exit routine
  1777.     Endif ' end check room direction number
  1778.     Call Vehicle.Type ' routine compares vehicle to room type
  1779.     If Next.Room=False Then ' check room type flag
  1780.        Outpt="You can't travel in that direction!" ' make error message
  1781.        Call IO.O ' send error message
  1782.        Exit Sub ' exit routine
  1783.     Endif ' end compare vehicle to room type
  1784.     Outpts=Direction(Direction.Number) ' store dirction name
  1785.     Outpts=Rtrim$(Outpts) ' trim name
  1786.     Outpts=Lcase$(Outpts) ' lowercase name
  1787.     Outpt="You ride "+Outpts+"!" ' make vehicle message
  1788.     Call IO.O ' send vehicle message
  1789.     Call Enter.Room ' routine moves player to room
  1790.     Exit Sub ' exit routine
  1791.  Endif ' end compare direction number
  1792.  Call Check.Room.Objects ' routine searches room for portal name
  1793.  If Index.Number=False Then ' check room portal number
  1794.     Outpt="You can't travel in that direction!" ' make error message
  1795.     Call IO.O ' send error message
  1796.     Exit Sub ' exit routine
  1797.  Endif ' end check room portal
  1798.  If ObjectRecord.RoomLink=False Then ' check portal goes to room
  1799.     Outpt="You can't travel there!" ' make error message
  1800.     Call IO.O ' send error message
  1801.     Exit Sub ' exit routine
  1802.  Endif ' end check portal to room number
  1803.  If ObjectRecord.JailTrap Then ' check room portal is a jail trap
  1804.     Outpt="Trapped portal!" ' make error message
  1805.     Call IO.O ' send error message
  1806.     Exit Sub ' exit routine
  1807.  Endif ' end check room portal type
  1808.  If ObjectRecord.Closed Then ' check roomportal is locked
  1809.     If Pass.Door=False Then ' check pass door spell in effect
  1810.        Outpt="You can't, it's closed!" ' make entry error message
  1811.        Call IO.O ' send entry error message
  1812.        Exit Sub ' exit routine
  1813.     Endif ' end check pass door spell
  1814.  Endif ' end check room portal locked
  1815.  If ObjectRecord.Relocks Then ' check room portal relocks
  1816.     ObjectRecord.DoorLock=2 ' reset room portal lock
  1817.     ObjectRecord.Closed=True ' reset room portal lock
  1818.     Call Share.Record(ObjectFile,Index.Number) ' write object record
  1819.  Endif ' end check room portal relock
  1820.  Outpt=ObjectRecord.ShortDesc ' store room entry display description
  1821.  If Outpt<>String$(80,0) Then ' check description to nulls
  1822.     Outpt=Rtrim$(Outpt) ' trim description
  1823.     If Outpt<>Nul Then ' compare length of description
  1824.        Call IO.O ' send room entry description message
  1825.     Endif ' end compare description length
  1826.  Endif ' end check description
  1827.  Pass.Door=False ' reset pass door spell
  1828.  Number.Monsters=False ' reset number of monsters in room
  1829.  ' store room number of object portal destination
  1830.  Next.Room=ObjectRecord.RoomLink ' store
  1831.  Call Vehicle.Type ' routine to verify vehicle to room type
  1832.  If Next.Room=False Then ' check verified room number
  1833.     Outpt="You can't travel in that direction!" ' make error message
  1834.     Call IO.O ' send error message
  1835.     Exit Sub ' exit routine
  1836.  Endif ' end check vehicle to room type
  1837.  Outpts=ObjectRecord.ShortName ' store object name
  1838.  Outpts=Rtrim$(Outpts) ' trim name
  1839.  Outpts=Lcase$(Outpts) ' lowercase name
  1840.  Outpt="You ride to the "+Outpts+"!" ' make vehicle message
  1841.  Call IO.O ' send message
  1842.  Call Enter.Room ' routine moves player to room
  1843. End Sub ' end routine to move player and vehicle
  1844.  
  1845.  Rem * routine remove player from vehicle.
  1846.  
  1847. Sub Exit.Vehicle
  1848.  On Local Error Resume Next ' local error resume
  1849.  Call Check.Room.Treasure ' routine finds vehicle name in room
  1850.  If Array.Number=Vehicle1 Then ' compare treasure number to vehicle number
  1851.     Outpts=TreasureRecord.ShortName ' store treasure name
  1852.     Outpts=Rtrim$(Outpts) ' trim name
  1853.     Outpts=Lcase$(Outpts) ' lowercase name
  1854.     Vehicle1=False ' reset vehicle variable
  1855.     Vehicle2=False' reset vehicle variable
  1856.     Vehicle3=False' reset vehicle variable
  1857.     Outpt="You exit the "+Outpts+"!" ' make vehicle message
  1858.  Else ' compare vehicle numbers
  1859.     Outpt="You can't exit that!" ' make error message
  1860.  Endif ' end compare vehicle
  1861.  Call IO.O ' send message
  1862. End Sub ' end routine to exit vehicle
  1863.  
  1864.  Rem * routine verifies vehicle type can enter room type.
  1865.  Rem * output variables:
  1866.  Rem *   Next.Room - false for invalid vehicle to room type.
  1867.  
  1868. Sub Vehicle.Type
  1869.  On Local Error Resume Next ' local error resume
  1870.  If Next.Room<=False Or _
  1871.  Next.Room>Lof(RoomFile)/Len(RoomRecord) Then ' file bounds
  1872.     Next.Room=False ' return next room number
  1873.     Exit Sub ' exit routine
  1874.  Endif ' end check file bounds
  1875.  Call Read.Room.Record(Next.Room) ' get destination room
  1876.  If Vehicle4<>3 Then ' check all terrain vehicle
  1877.     Action.Number=RoomRecord.Action ' store room action number
  1878.     If Action.Number>False And _
  1879.     Action.Number<=Lof(ActionFile)/Len(ActionRecord) Then
  1880.        Call Read.Record(ActionFile,Action.Number) ' read action record
  1881.        If ActionRecord.Attribute2<>Vehicle4 Then ' check vehicle terrain type
  1882.           Next.Room=False ' reset next room number
  1883.        Endif ' end check vehicle terrain type
  1884.     Endif ' end check action number range
  1885.  Endif ' end check all terrain vehicle
  1886.  Call Read.Room.Record(Room) ' restore room record
  1887. End Sub ' end routine to compare vehicle to room type
  1888.  
  1889.  Rem * routine determines if player can train for next level.
  1890.  
  1891. Sub Train
  1892.  On Local Error Resume Next ' local error resume
  1893.  If UserRecord.Level<=False Then ' verify player level
  1894.     Call Train.Stats ' train player
  1895.     Exit Sub ' exit routine
  1896.  Endif ' end verify player level
  1897.  ' calculate experience needed to reach next level
  1898.  Call Experience(Exp.Required#)
  1899.  If UserRecord.Experience<Exp.Required# Then ' compare player experience
  1900.     Outpt="You don't have enough experience to train!" ' train error message
  1901.     Call IO.O ' send train error message
  1902.     Exit Sub ' exit routine
  1903.  Endif ' end compare player experience
  1904.  Call Gold(Gold.Required#) ' routine calculates gold needed for level
  1905.  If UserRecord.Gold<Gold.Required# Then ' compare to player gold
  1906.     Outpt="You don't have enough Gold to train!" ' make train error message
  1907.     Call IO.O ' send train error message
  1908.     Exit Sub ' exit routine
  1909.  Endif ' end compare gold
  1910.  Call Train.Stats ' routine to train for next level
  1911. End Sub ' end train routine
  1912.  
  1913.  Rem * routine teleports player to room.
  1914.  Rem * input variables:
  1915.  Rem *   Parsed.Command1 - parameter containing room number.
  1916.  
  1917. Sub Teleport.User
  1918.  On Local Error Resume Next ' local error resume
  1919.  Next.Room=Int(Val(Parsed.Command1)) ' convert parameter to room number
  1920.  Graphics.Off=True ' reset color
  1921.  Outpt="A Dark Cloud Passes Overhead..." ' make ghod message
  1922.  Call IO.O ' send ghod message
  1923.  Outpt="  A Bolt Of Lightning Strikes..." ' make ghod message
  1924.  Call IO.O ' send ghod message
  1925.  Outpt="The Cloud Disappears..." ' make ghod message
  1926.  Call IO.O ' send ghod message
  1927.  Graphics.Off=False ' reset color
  1928.  Teleported=True ' set teleporting flag
  1929.  Call Enter.Room ' routine moves player to room
  1930. End Sub ' end routine to teleport player
  1931.  
  1932.  Rem * routine moves player to room number in an object.
  1933.  Rem * input variables:
  1934.  Rem *   Parsed.Command1 - contains the object name.
  1935.  
  1936. Sub Enter.Object
  1937.  On Local Error Resume Next ' local error resume
  1938.  User.Command=Parsed.Command1 ' store command parameter
  1939.  Call Get.Direction(Direction.Number) ' compare name to direction to go to
  1940.  If Direction.Number Then ' check direction flag
  1941.     Entry.Command=Last.Command.Number ' store room entry command
  1942.     Call Verify.Room(Direction.Number) ' routine verifies room number
  1943.     If New.Room Then ' check room flag
  1944.        Call Enter.Room ' routine moves player
  1945.     Endif ' end check room flag
  1946.     Exit Sub ' exit routine
  1947.  Endif ' end check direction
  1948.  Call Check.Room.Objects ' compare object name
  1949.  If Index.Number=False Then ' check object name flag
  1950.     Call Check.Room.Treasure ' compare treasure name
  1951.     If Index.Number Then ' check treasure name flag
  1952.        If TreasureRecord.Vehicle Then ' object to move to is vehicle
  1953.           Call Enter.Vehicle ' routine to enter vehicle
  1954.           Exit Sub ' exit routine
  1955.        Endif ' end check object name
  1956.     Endif ' end check treasure flag
  1957.     Outpt="You can't go there!" ' make error message
  1958.     Call IO.O ' send error message
  1959.     Exit Sub ' exit routine
  1960.  Endif ' end check object name flag
  1961.  If ObjectRecord.RoomLink=False Then ' check object portal room number
  1962.     Outpt="You can't go there!" ' make error message
  1963.     Call IO.O ' send error message
  1964.     Exit Sub ' exit routine
  1965.  Endif ' end check portal room number
  1966.  Call Restrict(12,Restricted) ' routine checks enter command restricted
  1967.  If Restricted Then ' compare restrict flag
  1968.     Outpt="Your level does not permit entrance to that room!" ' message
  1969.     Call IO.O ' send error message
  1970.     Exit Sub ' exit routine
  1971.  Endif ' end compare restricted room
  1972.  If ObjectRecord.JailTrap Then ' check object is jailed
  1973.     Outpt="Trapped portal!" ' make error message
  1974.     Call IO.O ' send error message
  1975.     Exit Sub ' exit routine
  1976.  Endif ' end check jailed object
  1977.  If ObjectRecord.Closed Then ' check object lock
  1978.     If Pass.Door=False Then ' check pass door spell in effect
  1979.        Outpt="You can't, it's closed!" ' make error message
  1980.        Call IO.O ' send error message
  1981.        Exit Sub ' exit routine
  1982.     Endif ' end check pass door spell
  1983.  Endif ' end check object lock
  1984.  If ObjectRecord.Relocks Then ' check object relocks after entry
  1985.     ObjectRecord.DoorLock=2 ' relock object
  1986.     ObjectRecord.Closed=True ' relock object
  1987.     Call Share.Record(ObjectFile,Index.Number) ' write object record
  1988.  Endif ' end check relocking object
  1989.  Outpt=ObjectRecord.ShortDesc ' store entry description
  1990.  If Outpt<>String$(80,0) Then ' compare description to nulls
  1991.     Outpt=Rtrim$(Outpt) ' trim description
  1992.     If Outpt<>Nul Then ' compare length of description
  1993.        Call IO.O ' send entry description message
  1994.     Endif ' end compare description length
  1995.  Endif ' end compare description
  1996.  If ObjectRecord.Trap Then ' verify object has trap
  1997.     Call Traps ' routine to activate object trap
  1998.     If New.Room Then ' check teleporting trap
  1999.        Exit Sub ' exit routine
  2000.     Endif ' end check teleporting trap
  2001.  Endif ' end verify object trap
  2002.  Pass.Door=False ' reset pass door spell
  2003.  Number.Monsters=False ' set monsters in room to zero
  2004.  Next.Room=ObjectRecord.RoomLink ' store object portal room number
  2005.  Call Enter.Room ' routine to move player to new room
  2006. End Sub ' end routine to move player through an object to room
  2007.  
  2008.  Rem * routine moves player to new room number.
  2009.  Rem * input variables:
  2010.  Rem *   Next.Room - contains new room number to move player to.
  2011.  
  2012. Sub Enter.Room
  2013.  On Local Error Resume Next ' local error resume
  2014.  New.Room=True ' set room entry flag
  2015.  Call Clean.Room ' routine to remove treasure from old room
  2016.  If Next.Room>False And _
  2017.  Next.Room<=Lof(RoomFile)/Len(RoomRecord) Then ' file bounds
  2018.     Swap Room,Next.Room ' store new room, saving old room number
  2019.  Endif ' end check room file bounds
  2020.  Call Status.Line(False) ' routine updates status line
  2021.  Monster.Rate1=False ' reset room monster encounter rate
  2022.  Call Read.Room.Record(Room) ' get the new room record
  2023.  If Vehicle1>False Then ' verify vehicle variable used
  2024.     Move.Vehicle=False ' move vehicle flag
  2025.     Entry.Command=Last.Command.Number ' store command number to enter room
  2026.     ' vehicle entered room
  2027.     If Entry.Command=RideVehicle Or Entry.Command=DriveVehicle Then
  2028.        For Treasure.Number=1 To 20 ' loop through room treasure
  2029.           ' check empty treasure
  2030.           If RoomRecord.Treasure(Treasure.Number)=False Then
  2031.              ' store vehicle inventory
  2032.              RoomRecord.TreCharges(Treasure.Number)=Vehicle2
  2033.              ' store vehicle inventory
  2034.              RoomRecord.Treasure(Treasure.Number)=Vehicle3
  2035.              Call Share.Room.Record(Room) ' write new room record
  2036.              Call Read.Room.Record(Next.Room) ' get previous room
  2037.              RoomRecord.Treasure(Vehicle1)=False ' reset vehicle inventory
  2038.              RoomRecord.TreCharges(Vehicle1)=False ' reset vehicle inventory
  2039.              Call Share.Room.Record(Next.Room) ' write room record
  2040.              Call Read.Room.Record(Room) ' get current room record
  2041.              Move.Vehicle=True ' set move vehicle flag
  2042.              Vehicle1=Treasure.Number ' store new vehicle treasure number
  2043.              Exit For ' exit loop through treasure in room
  2044.           Endif ' end check for empty treasure in room
  2045.        Next ' end loop through room treasure inventory
  2046.     Endif ' end check command used to enter room
  2047.     If Move.Vehicle=False Then ' verify vehicle moves to new room
  2048.        Call Read.Record(TreasureFile,Vehicle3) ' get treasure record
  2049.        Outpts=TreasureRecord.ShortName ' store treasure name
  2050.        Outpts=Rtrim$(Outpts) ' trim name
  2051.        Outpts=Lcase$(Outpts) ' lowercase name
  2052.        Outpt="You exit the "+Outpts+"." ' make vehicle message
  2053.        Call IO.O ' send vehicle message
  2054.        Vehicle1=False ' reset vehicle varible
  2055.        Vehicle2=False ' reset vehicle varible
  2056.        Vehicle3=False ' reset vehicle varible
  2057.        Vehicle4=False ' reset vehicle varible
  2058.     Endif ' end verify vehicle moves
  2059.  Endif ' end verify vehicle used
  2060.  For Array.Index=1 To Number.Monsters ' loop through room monsters
  2061.     ' compare permanent monster
  2062.     If MonsterArray(Array.Index).Permanent=True Then
  2063.        ' store permanent monster file index
  2064.        Monster.Number=MonsterIndex(Array.Index)
  2065.        Call Read.Record(MonsterFile,Monster.Number) ' get monster file record
  2066.        ' store permanent level
  2067.        MonsterRecord.Level=MonsterArray(Array.Index).Level
  2068.        MonsterRecord.Hits=MonsterArray(Array.Index).Hits ' stor permanent hits
  2069.        Call Share.Record(MonsterFile,Monster.Number) ' write monster record
  2070.     Endif ' end compare permanent monster
  2071.  Next ' end loop through room monsters
  2072.  If Room=1 Then ' check safe room
  2073.     Monster.Follow=False ' monsters followed flag
  2074.  Else ' end check safe room
  2075.     If UserRecord.ClassType<Lady Then ' check class number
  2076.        Monster.Follow=True ' monsters followed flag
  2077.     Else ' check class number
  2078.        Monster.Follow=False ' monsters followed flag
  2079.     Endif ' end check class number
  2080.  Endif ' end check safe room
  2081.  Teleported.Flag=Teleported ' store teleporting flag
  2082.  Teleported=False ' reset teleporting flag
  2083.  If Monster.Follow Then ' compare number of monsters followed
  2084.     If Teleported.Flag Then ' compare teleporting flag
  2085.        Outpts=" teleports with you!" ' make follow message
  2086.     Else ' check teleporting flag
  2087.        Outpts=" follows you!" ' make follow message
  2088.     Endif ' end check teleporting flag
  2089.     Monsters.Followed=False ' number of monsters which followed counter
  2090.     For Array.Index=1 To Number.Monsters ' loop through all monsters in room
  2091.        Monster.Followed=False ' set followed flag
  2092.        If MonsterArray(Array.Index).Follow Then ' check monster follows
  2093.           If Teleported.Flag Then ' check player teleported
  2094.              ' random chance monster teleports with player
  2095.              If Rnd<(MonsterArray(Array.Index).Teleport/100) Then
  2096.                 Monster.Followed=True ' set followed flag
  2097.              Endif ' end random chance
  2098.           Else ' check player teleported
  2099.              ' random chance monster follows player
  2100.              If Rnd<(MonsterArray(Array.Index).FollowPercent/100) Then
  2101.                 Monster.Followed=True ' set followed flag
  2102.              Endif ' end random chance
  2103.           Endif ' end check player teleported
  2104.           If Monster.Followed Then ' verify followed flag
  2105.              ' permanent monster
  2106.              If MonsterArray(Array.Index).Permanent=False Then
  2107.                 ' increment number of monsters
  2108.                 Monsters.Followed=Monsters.Followed+1
  2109.                 ' store monster
  2110.                 MonsterArray(Monsters.Followed)=MonsterArray(Array.Index)
  2111.                 ' store monster
  2112.                 MonsterIndex(Monsters.Followed)=MonsterIndex(Array.Index)
  2113.                 ' store monster name
  2114.                 Inpt=MonsterArray(Monsters.Followed).MonsterName
  2115.                 Inpt=Rtrim$(Inpt) ' trim name
  2116.                 Inpt=Lcase$(Inpt) ' lowercase name
  2117.                 Outpt="The "+Inpt+Outpts ' make followed message
  2118.                 Call IO.O ' send message
  2119.              Endif ' end check permanent monster
  2120.           Endif ' end verify followed flag
  2121.        Endif ' end check monster follows
  2122.     Next ' end loop through monsters in room
  2123.  Endif ' end compare number of monsters following
  2124.  Monster.Rate1=False ' reset room monster encounter rate
  2125.  Number.Monsters=Monsters.Followed ' store number of monsters followed
  2126.  Room.Rate=False ' reset room rate counter
  2127.  Rust.Rate=False ' reset room rate counter
  2128.  Steal.Rate=False ' reset room rate counter
  2129.  Teleported=False ' reset teleporting flag
  2130.  Call Check.Next.Room ' routine to get new room record
  2131.  Call Encounter.Permanent ' routine to get permanent monsters
  2132.  Call Display.Room ' routine displays room description
  2133.  Action.Number=RoomRecord.Action ' store room action number
  2134.  ' check file bounds
  2135.  If Action.Number>False And _
  2136.  Action.Number<=Lof(ActionFile)/Len(ActionRecord) Then
  2137.     Call Read.Record(ActionFile,Action.Number) ' read action record
  2138.     If ActionRecord.SpellTrigger=False Then ' check room spell action
  2139.        If ActionRecord.MonsterTrigger=False Then ' check room monster action
  2140.           ' check room monster talk action
  2141.           If ActionRecord.MonsterTalk=False Then
  2142.              Action1$="As you enter the room," ' make action message
  2143.              Action2$="You are hit for" ' make action message
  2144.              Call Actions(Action1$,Action2$) ' routine for room actions
  2145.           Endif ' end check room action
  2146.        Endif ' end check room action
  2147.     Endif ' end check room action
  2148.  Endif ' end check file bounds
  2149. End Sub ' end routine to move player to new room
  2150.  
  2151.  Rem * routine toggles invisible mode.
  2152.  
  2153. Sub Toggle.Invisible
  2154.  On Local Error Resume Next ' local error resume
  2155.  UserRecord.Invisible=Not UserRecord.Invisible ' negate player invisible mode
  2156.  If UserRecord.Invisible Then ' check invisible
  2157.     Outpt="You are invisible!" ' make message
  2158.  Else ' check invisible
  2159.     Outpt="You are no longer invisible!" ' make message
  2160.  Endif ' end check invisible
  2161.  Call IO.O ' send message
  2162. End Sub ' end routine to toggle invisible mode
  2163.  
  2164.  Rem * routine toggles linefeed mode.
  2165.  
  2166. Sub Toggle.Linefeeds
  2167.  On Local Error Resume Next ' local error resume
  2168.  User.Linefeeds=Not User.Linefeeds ' negate player linefeed mode
  2169.  If User.Linefeeds Then ' check linefeeds
  2170.     Outpt="Linefeeds toggled off." ' make message
  2171.  Else ' check linefeeds
  2172.     Outpt="Linefeeds toggled on." ' make message
  2173.  Endif ' end check linefeeds
  2174.  Call IO.O ' send message
  2175. End Sub ' end routine to toggle linefeed mode
  2176.  
  2177.  Rem * routine toggles echo mode.
  2178.  
  2179. Sub Toggle.Echo
  2180.  On Local Error Resume Next ' local error resume
  2181.  User.Echo=Not User.Echo ' negate player echo mode
  2182.  If User.Echo Then ' check echo
  2183.     Outpt="Echo toggled off." ' make message
  2184.  Else ' check echo
  2185.     Outpt="Echo toggled on." ' make message
  2186.  Endif ' end check echo
  2187.  Call IO.O ' send message
  2188. End Sub ' end routine to toggle echo mode
  2189.  
  2190.  Rem * routine toggles word wrap mode.
  2191.  
  2192. Sub Toggle.Wordwrap
  2193.  On Local Error Resume Next ' local error resume
  2194.  User.Wordwrap=Not User.Wordwrap ' negate player word wrap mode
  2195.  If User.Wordwrap Then ' check word wrap
  2196.     Outpt="Word wrap toggled off." ' make message
  2197.  Else ' check word wrap
  2198.     Outpt="Word wrap toggled on." ' make message
  2199.  Endif ' end check word wrap
  2200.  Call IO.O ' send message
  2201. End Sub ' end routine to toggle word wrap mode
  2202.  
  2203. Rem * routine to toggle player Ansi mode.
  2204.  
  2205. Sub Toggle.ANSI
  2206.  On Local Error Resume Next ' local error resume
  2207.  Color.Graphics=Not Color.Graphics ' negate ansi color flag
  2208.  If Color.Graphics Then ' check ansi toggle
  2209.     Outpt="ANSI codes enabled." ' make message
  2210.  Else ' check ansi
  2211.     Outpt="ANSI codes disabled." ' make message
  2212.  Endif ' end check ansi toggle
  2213.  Call IO.O ' send message
  2214. End Sub ' end routine to toggle ansi
  2215.  
  2216.  Rem * routine to toggle brief mode.
  2217.  
  2218. Sub Brief.Mode
  2219.  On Local Error Resume Next ' local error resume
  2220.  If Normal.User Then ' verify non DM
  2221.     If UserRecord.Level<=1 Then ' check player level
  2222.        Outpt="Brief mode not allowed until level two!" ' make error message
  2223.        Call IO.O ' send message
  2224.        Exit Sub ' exit routine
  2225.     Endif ' end check player level
  2226.  Endif ' end check normal player
  2227.  UserRecord.Brief=Not UserRecord.Brief ' negate brief mode
  2228.  If UserRecord.Brief Then ' check brief mode
  2229.     Action.Prompt="Next?" ' store new command prompt
  2230.     Outpt="Brief mode on." ' make message
  2231.  Else ' check brief mode
  2232.     Action.Prompt="Command? " ' store new command prompt
  2233.     Outpt="Brief mode off." ' make message
  2234.  Endif ' end check brief mode
  2235.  Call IO.O ' send message
  2236. End Sub ' end routine to toggle brief mode
  2237.  
  2238.  Rem * routine to change pagelength.
  2239.  
  2240. Sub Change.Pagelength
  2241.  On Local Error Resume Next ' local error resume
  2242.  Outpt="Enter pagelength(1-50)? " ' make input prompt
  2243.  No.Input.Out="24" ' default input
  2244.  Call IO.I ' get user input
  2245.  Page.Length=Int(Val(Inpt)) ' convert input to integer
  2246.  If Page.Length>=1 And Page.Length<=50 Then ' check pagelength bounds
  2247.     User.Pagelength=Page.Length ' store new pagelength
  2248.     Outpt="Pagelength now"+Str$(Page.Length)+" lines." ' make output message
  2249.  Else ' check bounds
  2250.     Outpt="Pagelength not changed." ' make output message
  2251.  Endif ' end check bounds
  2252.  Call IO.O ' send output
  2253. End Sub ' end routine to change pagelength
  2254.  
  2255.  Rem * routine to change linelength.
  2256.  
  2257. Sub Change.Linelength
  2258.  On Local Error Resume Next ' local error resume
  2259.  Outpt="Enter linelength(1-132)? " ' make input prompt
  2260.  No.Input.Out="80" ' default input
  2261.  Call IO.I ' get user input
  2262.  Line.Length=Int(Val(Inpt)) ' convert input to integer
  2263.  If Line.Length>=1 And Line.Length<=132 Then ' check linelength bounds
  2264.     User.Linelength=Line.Length ' store new linelength
  2265.     Outpt="Linelength now"+Str$(Line.Length)+" characters." ' make output message
  2266.  Else ' check bounds
  2267.     Outpt="Linelength not changed." ' make output message
  2268.  Endif ' end check bounds
  2269.  Call IO.O ' send output
  2270. End Sub ' end routine to change linelength
  2271.  
  2272.  Rem * routine to display preferences.
  2273.  
  2274. Sub Display.Prefs
  2275.  On Local Error Resume Next ' local error resume
  2276.  Graphics.Off=True ' reset color
  2277.  If User.Linefeeds Then ' check linefeeds
  2278.     Outpt="Linefeeds toggled off." ' make message
  2279.  Else ' check linefeeds
  2280.     Outpt="Linefeeds toggled on." ' make message
  2281.  Endif ' end check linefeeds
  2282.  Call IO.O ' send message
  2283.  If User.Echo Then ' check echo
  2284.     Outpt="Echo toggled off." ' make message
  2285.  Else ' check echo
  2286.     Outpt="Echo toggled on." ' make message
  2287.  Endif ' end check echo
  2288.  Call IO.O ' send message
  2289.  If User.Wordwrap Then ' check word wrap
  2290.     Outpt="Word wrap toggled off." ' make message
  2291.  Else ' check word wrap
  2292.     Outpt="Word wrap toggled on." ' make message
  2293.  Endif ' end check word wrap
  2294.  Call IO.O ' send message
  2295.  If Color.Graphics Then ' check ansi toggle
  2296.     Outpt="ANSI codes enabled." ' make message
  2297.  Else ' check ansi
  2298.     Outpt="ANSI codes disabled." ' make message
  2299.  Endif ' end check ansi toggle
  2300.  Call IO.O ' send message
  2301.  If UserRecord.Brief Then ' check brief mode
  2302.     Outpt="Brief mode on." ' make message
  2303.  Else ' check brief mode
  2304.     Outpt="Brief mode off." ' make message
  2305.  Endif ' end check brief mode
  2306.  Call IO.O ' send message
  2307.  Outpt="Pagelength now"+Str$(User.Pagelength)+" lines." ' make message
  2308.  Call IO.O ' send output
  2309.  Outpt="Linelength now"+Str$(User.Linelength)+" characters." ' make message
  2310.  Call IO.O ' send output
  2311.  Select Case UserRecord.Sort ' check sorting preference
  2312.  Case -1 ' check value
  2313.     Outpt="Inventory charges sorting on." ' make display message
  2314.  Case 0 ' check value
  2315.     Outpt="Inventory sorting off." ' make display message
  2316.  Case 1 ' check value
  2317.     Outpt="Inventory plus sorting on." ' make display message
  2318.  Case Else ' check sorting
  2319.     Outpt="Inventory sorting off." ' make display message
  2320.  End Select ' end check sorting
  2321.  Call IO.O ' send display message
  2322.  ' check player locked mailbox
  2323.  If UserRecord.Flags And Locked.User Then
  2324.     Outpt="Mailbox locked." ' make locked message
  2325.  Else ' check player locked
  2326.     Outpt="Mailbox unlocked." ' make locked message
  2327.  Endif ' end check player locked flag
  2328.  Call IO.O ' send message
  2329.  Graphics.Off=False ' reset color
  2330. End Sub ' end display preferences routine
  2331.  
  2332.  Rem * routine to have the blacksmith repair some item of treasure.
  2333.  
  2334. Sub Weapons.Shop
  2335.  On Local Error Resume Next ' local error resume
  2336.  Call Check.Inventory.Treasure ' routine to find treasure name
  2337.  If Index.Number=False Then ' check treasure index
  2338.     Outpt="The Blacksmith says: You can't repair that!" ' make error message
  2339.     Call IO.O ' send error message
  2340.     Exit Sub ' exit routine
  2341.  Endif ' end check treasure index
  2342.  If TreasureRecord.Spell Then ' compare treasure is magic
  2343.     Outpt="The Blacksmith says: Can't fix that here!" ' make error message
  2344.     Call IO.O ' send error message
  2345.     Exit Sub ' exit routine
  2346.  Endif ' end compare magical treasure
  2347.  If TreasureRecord.Type=False Then ' check treasure is weapon, shield, armor
  2348.     If TreasureRecord.Plus=False Then ' check weapon plus
  2349.        Outpt="The Blacksmith says: Can't fix that here!" ' make error message
  2350.        Call IO.O ' send error message
  2351.        Exit Sub ' exit routine
  2352.     Endif ' end check weapon plus
  2353.  Endif ' end check treasuer type
  2354.  If UserRecord.Charges(Array.Number)<>False Then ' compare treasure charges
  2355.     Outpt="The Blacksmith says: That isn't broken!" ' make error message
  2356.     Call IO.O ' send error message
  2357.     Exit Sub ' exit routine
  2358.  Endif ' end compare treasure charges
  2359.  Item.Cost#=Int(TreasureRecord.Gold*.5) ' calculate price to repair item
  2360.  If Item.Cost#>UserRecord.Gold Then ' compare price to player gold
  2361.     Outpt="The Blacksmith says: You don't have enough gold!" ' make message
  2362.     Call IO.O ' send message
  2363.     Exit Sub ' exit routine
  2364.  Endif ' end compare price to gold
  2365.  ' make input prompt
  2366.  Outpt="The Blacksmith asks: How about"+Str$(Item.Cost#)+" gold(y/n)? "
  2367.  No.Input.Out="Y" ' default input
  2368.  Call IO.I ' get input
  2369.  If Yes Then ' compare response
  2370.     UserRecord.Gold=UserRecord.Gold-Item.Cost# ' decrement player gold
  2371.     ' store repaired charges
  2372.     UserRecord.Charges(Array.Number)=TreasureRecord.Charges
  2373.     Outpt="The Blacksmith says: There, it's repaired!" ' make message
  2374.  Else ' compare yresponse
  2375.     Outpt="The Blacksmith says: It ain't repaired!" ' make message
  2376.  Endif ' end compare response
  2377.  Call IO.O ' send message
  2378. End Sub ' end routine to repair item
  2379.  
  2380.  Rem * routine to repair an item of magical treasure.
  2381.  
  2382. Sub Alchemist
  2383.  On Local Error Resume Next ' local error resume
  2384.  Call Check.Inventory.Treasure ' routine to find treasure name
  2385.  If Index.Number=False Then ' check treasure index found
  2386.     Outpt="The Alchemist says: That can't be recharged here!" ' make message
  2387.     Call IO.O ' send error message
  2388.     Exit Sub ' exit routine
  2389.  Endif ' end check treasure index
  2390.  Spell.Number=TreasureRecord.Spell ' store treasure spell number
  2391.  ' file bounds
  2392.  If Spell.Number<=False Or Spell.Number>Lof(SpellFile)/Len(SpellRecord) Then
  2393.     Outpt="The Alchemist says: You can't recharge that here!" ' make message
  2394.     Call IO.O ' send error message
  2395.     Exit Sub ' exit routine
  2396.  Endif ' end check file bounds
  2397.  Call Read.Record(SpellFile,Spell.Number) ' get spell record of magic item
  2398.  If SpellRecord.SpellType=Wish Then ' compare to wish item
  2399.     Outpt="The Alchemist says: I won't recharge that item!" ' make message
  2400.     Call IO.O ' send error message
  2401.     Exit Sub ' exit routine
  2402.  Endif ' end cmopare wish item
  2403.  If UserRecord.Charges(Array.Number)<>False Then ' check item charges
  2404.     Outpt="The Alchemist says: That's not discharged!" ' make message
  2405.     Call IO.O ' send error message
  2406.     Exit Sub ' exit routine
  2407.  Endif ' end check charges remaining
  2408.  Item.Cost#=Int(TreasureRecord.Gold*.5) ' calculate price to repair
  2409.  If Item.Cost#>UserRecord.Gold Then ' compare price to player gold
  2410.     Outpt="The Alchemist says: You don't have enough gold!" ' make message
  2411.     Call IO.O ' send error message
  2412.     Exit Sub ' exit routine
  2413.  Endif ' end compare price to gold
  2414.  ' make input prompt
  2415.  Outpt="The Alchemist says: How about"+Str$(Item.Cost#)+" gold(y/n)? "
  2416.  No.Input.Out="Y" ' default input
  2417.  Call IO.I ' get input
  2418.  If Yes Then ' compare response
  2419.     UserRecord.Gold=UserRecord.Gold-Item.Cost# ' decrement player gold
  2420.     ' store item charges
  2421.     UserRecord.Charges(Array.Number)=TreasureRecord.Charges
  2422.     Outpt="The Alchemist chants an invocation!" ' make message
  2423.  Else ' compare response
  2424.     Outpt="The Alchemist says: Didn't repair it!" ' make message
  2425.  Endif ' end compare response
  2426.  Call IO.O ' send message
  2427. End Sub ' end routine to repair magic item
  2428.  
  2429.  Rem * routine to sell treasure item from list.
  2430.  Rem * input variables:
  2431.  Rem *   Parsed.Command1 - number of item to purchase.
  2432.  
  2433. Sub Weapons.Shoppe
  2434.  On Local Error Resume Next ' local error resume
  2435.  Treasure.Number=Int(Val(Parsed.Command1)) ' convert parameter to integer
  2436.  If Treasure.Number<=False Or Treasure.Number>20 Then ' compare integer bounds
  2437.     Outpt="The Blacksmith says: You can't buy that!" ' make error message
  2438.     Call IO.O ' send error message
  2439.     Exit Sub ' exit routine
  2440.  Endif ' end compare range
  2441.  If Treasure.Number>Lof(TreasureFile)/Len(TreasureRecord) Then ' check bounds
  2442.     Outpt="The Blacksmith says: You can't buy that!" ' make error message
  2443.     Call IO.O ' send error message
  2444.     Exit Sub ' exit routine
  2445.  Endif ' end compare file bounds
  2446.  Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  2447.  If UserRecord.Gold-TreasureRecord.Gold<False Then ' compute price
  2448.     Outpt="The Blacksmith says: You don't have enough gold!" ' make message
  2449.     Call IO.O ' send error message
  2450.     Exit Sub ' exit routine
  2451.  Endif ' end compare price to player gold
  2452.  If Weight+TreasureRecord.Weight>UserRecord.Stats(1)*10 Then ' compute weight
  2453.     Outpt="The Blacksmith says: You can't carry any more!" ' make message
  2454.     Call IO.O ' send error message
  2455.     Exit Sub ' exit routine
  2456.  Endif ' end compare weight of new item
  2457.  Call TreasureCharges(Charges.Amount) ' routine to get treasure charges
  2458.  ' routine to add item to player inventory
  2459.  Call Add.Inventory(Treasure.Number,Charges.Amount,Item.Added)
  2460.  If Item.Added Then ' check return variable for added inventory
  2461.     UserRecord.Gold=UserRecord.Gold-TreasureRecord.Gold ' decrement gold
  2462.     Outpt="The Blacksmith says: There, sold!" ' make message
  2463.  Else ' check inventory added
  2464.     Outpt="The Blacksmith says: You can't carry any more!" ' make message
  2465.  Endif ' end check inventory added flag
  2466.  Call IO.O ' send output message
  2467. End Sub ' end routine to purchase item for sale
  2468.  
  2469.  Rem * routine displays a sorted list of the top ten players, writes the
  2470.  Rem * top ten ranking bulletin file.
  2471.  
  2472. Sub Top.Ten
  2473.  On Local Error Resume Next ' local error resume
  2474.  Call Share.Record(UserFile,User.Index) ' store player user record
  2475.  Max.Users=Lof(UserFile)/Len(UserRecord) ' store length of user file
  2476.  Redim Temp.Array1(1 To Max.Users) As Integer, _
  2477.  Temp.ArrayZ(1 To Max.Users) As Double ' dimension working arrays
  2478.  Close #TempFile ' close work file
  2479.  Open "ranklist.dat" For Output As #TempFile ' open to work file
  2480.  Outpt="The Adventure Door v"+Version$+" Top Ten Player Rankings For "+FNclock$+"."
  2481.  Print #TempFile,Outpt ' write to file
  2482.  Outpt=Nul ' make empty string
  2483.  Print #TempFile,Outpt ' write to file
  2484.  Player.Count=False ' reset player counter
  2485.  For User.Number=1 To Max.Users ' loop through user file
  2486.     Call Read.Record(UserFile,User.Number) ' get next user file record
  2487.     Outpt=UserRecord.CodeName ' store player codename
  2488.     Call Decrypt(Outpt) ' decrypt codename
  2489.     If Left$(Outpt,9)<>Deleted$ Then ' compare deleted user record
  2490.        If UserRecord.Level>False Then ' check user level
  2491.           If (UserRecord.Flags And Locked.User)=False Then ' check locked user
  2492.              Score#=UserRecord.MonstersKilled*UserRecord.Level ' compute score
  2493.              If Score#>False Then ' compare score
  2494.                 ' increment high score player counter
  2495.                 Player.Count=Player.Count+1
  2496.                 Temp.Array1(Player.Count)=User.Number ' store record index
  2497.                 Temp.ArrayZ(Player.Count)=Int(Score#) ' store score
  2498.              Endif ' end compare score
  2499.           Endif ' end check locked user record
  2500.        Endif ' end check user level
  2501.     Endif ' end compare deleted user
  2502.  Next ' end loop through user file
  2503.  ' bubble sort
  2504.  For Sort1=1 To Player.Count ' loop through all items to sort
  2505.     For Sort2=Sort1+1 To Player.Count ' loop through remaining items
  2506.        If Temp.ArrayZ(Sort1)<Temp.ArrayZ(Sort2) Then ' compare scores
  2507.           Swap Temp.Array1(Sort1),Temp.Array1(Sort2) ' swap lower array
  2508.           Swap Temp.ArrayZ(Sort1),Temp.ArrayZ(Sort2) ' swap lower array
  2509.        Endif ' end compare scores
  2510.     Next ' end loop through array
  2511.  Next ' end loop through array
  2512.  If Player.Count>10 Then ' check maximum number of users
  2513.     Player.Count=10 ' reset to top ten
  2514.  Endif ' end check maximum scoring players
  2515.  ' make header
  2516.  Outpt="Username                       Level Classname            Ranking"
  2517.  Print #TempFile,Outpt ' write to file
  2518.  Outpt=String$(65,"-") ' make header line
  2519.  Print #TempFile,Outpt ' write to file
  2520.  For Array.Number=1 To Player.Count ' loop through high scoring players
  2521.     User.Number=Temp.Array1(Array.Number) ' get user file record number
  2522.     Call Read.Record(UserFile,User.Number) ' get user file record
  2523.     Outpt=UserRecord.CodeName ' store player codename
  2524.     Call Decrypt(Outpt) ' decrypt codename
  2525.     Outpt=Lcase$(Outpt) ' lowercase codename
  2526.     Mid$(Outpt,1,1)=Ucase$(Mid$(Outpt,1,1)) ' uppercase first word
  2527.     Outpt=Outpt+Str$(UserRecord.Level) ' add player level
  2528.     Outpt=Outpt+Space$(7-Len(Str$(UserRecord.Level))) ' pad blanks
  2529.     Inpt=UserRecord.ClassName ' store player class name
  2530.     Call Decrypt(Inpt) ' decrypt class name
  2531.     Outpt=Outpt+Inpt ' append class name
  2532.     Outpt=Outpt+Str$(Temp.ArrayZ(Array.Number)) ' add score
  2533.     Print #TempFile,Outpt ' write to file
  2534.  Next ' end loop through top ten players
  2535.  If Player.Count=False Then ' compare number of players
  2536.     Outpt="No users have top scores." ' make score message
  2537.     Print #TempFile,Outpt ' write to file
  2538.  Endif ' end compare number of players
  2539.  Close #TempFile ' close work file
  2540.  Call Read.Record(UserFile,User.Index) ' get user file record
  2541.  User.Line.Length=User.Linelength
  2542.  User.Linelength=80
  2543.  Call Out.File("ranklist.dat")
  2544.  User.Linelength=User.Line.Length
  2545.  Redim Temp.Array1(1) As Integer, _
  2546.  Temp.ArrayZ(1) As Double ' remove temporary arrays
  2547. End Sub ' end routine to display and write top ten list
  2548.  
  2549.  Rem * routine deletes a user record.
  2550.  
  2551. Sub Delete.User
  2552.  On Local Error Resume Next ' local error resume
  2553.  Outpt=Deleted$ ' store deleted string
  2554.  Call Valid(Outpt,30) ' validate string
  2555.  Call Encrypt(Outpt,True) ' encrypt string
  2556.  UserRecord.CodeName=Outpt ' store string in codename
  2557.  Outpt=Deleted$ ' store deleted string
  2558.  Call Valid(Outpt,20) ' validate string
  2559.  Call Encrypt(Outpt,False) ' encrypt string
  2560.  UserRecord.PassWord=Outpt ' store string in password
  2561.  Outpt=Deleted$ ' store deleted string
  2562.  Call Valid(Outpt,20) ' validate string
  2563.  Call Encrypt(Outpt,True) ' encrypt string
  2564.  UserRecord.ClassName=Outpt ' store string in class name
  2565.  UserRecord.ClassType=False ' reset class number
  2566.  UserRecord.Flags=False  ' reset user flags
  2567.  UserRecord.FromHour=False ' reset time restriction
  2568.  UserRecord.FromMin=False ' reset time restriction
  2569.  UserRecord.Level=False ' reset player level
  2570.  UserRecord.MaxCalls=False ' reset maximum calls allowed
  2571.  UserRecord.MonstersKilled=False ' reset score counter
  2572.  UserRecord.ToHour=False ' reset time restriction
  2573.  UserRecord.ToMin=False ' reset time restriction
  2574.  For Array.Index=1 To 20 ' loop through inventory
  2575.     UserRecord.Inv(Array.Index)=False ' reset inventory
  2576.     UserRecord.Charges(Array.Index)=False ' reset inventory
  2577.  Next ' end loop through inventory
  2578.  For Array.Index=1 To 5 ' loop through object inventory
  2579.     UserRecord.Object(Array.Index)=False ' reset inventory
  2580.     UserRecord.ObjCharges(Array.Index)=False ' reset inventory
  2581.  Next ' end loop through inventory
  2582.  Call Clear.Container(0,True) ' clear container record
  2583.  For Array.Index=1 To 3 ' loop through all containers
  2584.     UserRecord.Container(Array.Index)=ContainerRec ' store container record
  2585.  Next ' end loop through containers
  2586. End Sub ' end routine to delete a user record
  2587.