home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / DNDOOR46.ZIP / DNDS4.BAS < prev    next >
BASIC Source File  |  2001-07-11  |  117KB  |  2,592 lines

  1.  Rem * Filename: dnds4.bas Version: v4.6 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.  If Room.Number!<=0! Then ' check number
  798.     Exit Sub ' exit subroutine
  799.  Endif ' end check number
  800.  Graphics.Off=False ' reset color
  801.  Outpt="Room number"+Str$(Room.Number!)+":" ' make room number message
  802.  Call IO.O ' send message
  803.  Graphics.Off=True ' reset color
  804.  Outpt=Nul ' clear output string
  805.  For Link.Number=1 To 4 ' loop through room directions
  806.     ' make display line containing room directions
  807.     Inpt=Mid$("NESW",Link.Number,1)+"  "+Str$(RoomRecord.Direct(Link.Number))
  808.     Outpt=Outpt+Inpt+Space$(10-Len(Inpt)) ' pad with blanks
  809.  Next ' end loop through room directions
  810.  Call IO.O ' send line one of room directions
  811.  Outpt=Nul ' clear output string
  812.  For Link.Number=5 To 8 ' loop through room directions
  813.     ' make display line containing room directions
  814.     Inpt=Mid$("NESESWNW",(Link.Number-4)*2-1,2)+" "+ _
  815.     Str$(RoomRecord.Direct(Link.Number))
  816.     Outpt=Outpt+Inpt+Space$(10-Len(Inpt)) ' pad with blanks
  817.  Next ' end loop through room directions
  818.  Call IO.O ' send line one of room directions
  819.  Outpt=Nul ' clear output string
  820.  For Link.Number=9 To 12 ' loop through room directions
  821.     ' make display line containing room directions
  822.     Inpt=Mid$("UDIO",Link.Number-8,1)+"  "+ _
  823.     Str$(RoomRecord.Direct(Link.Number))
  824.     Outpt=Outpt+Inpt+Space$(10-Len(Inpt)) ' pad with blanks
  825.  Next ' end loop through room directions
  826.  Call IO.O ' send line two of room directions
  827.  Outpt=Nul ' clear output string
  828. End Sub ' end routine to display room links
  829.  
  830.  Rem * routine moves player in a certain direction.
  831.  Rem * input variables:
  832.  Rem *   Direction.Number - direction to go.
  833.  Rem * processing variables:
  834.  Rem *   New.Room - true if room can be entered, false if not.
  835.  
  836. Sub Go.Direction(Direction.Number)
  837.  On Local Error Resume Next ' local error resume
  838.  ' change last command to direction
  839.  Entry.Command=Last.Command.Number ' store room entry command
  840.  Last.Command=Ucase$(Direction(Direction.Number))
  841.  Last.Command.Number=True ' reset last command number
  842.  ' routine to check if next room can be entered
  843.  Call Verify.Room(Direction.Number)
  844.  If New.Room Then ' check next room variable
  845.     Call Enter.Room ' routine to move the player
  846.  Endif ' end check next room
  847. End Sub ' end routine to move player
  848.  
  849.  Rem * routine compares player input to direction.
  850.  Rem * input variables:
  851.  Rem *   User.Command - original command input.
  852.  Rem * output variables:
  853.  Rem *   Direction.Number - contains direction number.
  854.  
  855. Sub Get.Direction(Direction.Number)
  856.  On Local Error Resume Next ' local error resume
  857.  For Direction.Number=1 To 12 ' loop through direction names
  858.     Outpts=Direction(Direction.Number) ' store direction name
  859.     Outpts=Rtrim$(Outpts) ' trim name
  860.     Outpts=Ucase$(Outpts) ' uppercase name
  861.     If User.Command=Outpts Then ' compare to player direction
  862.        Exit Sub ' exit routine
  863.     Endif ' end check directions
  864.  Next ' end loop through direction names
  865.  ' routine to get direction
  866.  Call Find.Link(User.Command,Direction.Number,False)
  867.  If Direction.Number=13 Then ' check enter portal link
  868.     Direction.Number=False ' reset direction
  869.  Endif ' end check direction
  870. End Sub ' end routine to compare direction
  871.  
  872.  Rem * routine to add item of treasure to player inventory.
  873.  Rem * input variables:
  874.  Rem *   Treasure.Number - treasure file index number.
  875.  Rem *   Treasure.Charges - treasure charges.
  876.  Rem * output variables:
  877.  Rem *   Item.Added - true if item added, false if not.
  878.  
  879. Sub Add.Inventory(Treasure.Number,Treasure.Charges,Item.Added)
  880.  On Local Error Resume Next ' local error resume
  881.  Item.Added=False ' clear return variable
  882.  For Array.Index=1 To 20 ' loop through all player inventory
  883.     If UserRecord.Inv(Array.Index)=False Then ' check for empty inventory
  884.        UserRecord.Inv(Array.Index)=Treasure.Number ' add treasure index
  885.        UserRecord.Charges(Array.Index)=Treasure.Charges ' add treasure charges
  886.        Weight=Weight+TreasureRecord.Weight ' increment player weight
  887.        Item.Added=True ' set return flag
  888.        Exit Sub ' exit routine
  889.     Endif ' end check empty inventory
  890.  Next ' end loop through player inventory
  891. End Sub ' end routine to add item of treasure to player inventory
  892.  
  893.  Rem * routine to add an object to player inventory.
  894.  Rem * input variables:
  895.  Rem *   Object.Number - object file index number.
  896.  Rem *   Object.Charges - object charges.
  897.  Rem * output variables:
  898.  Rem *   Item.Added - true if item added, false if not.
  899.  
  900. Sub Add.Object(Object.Number,Object.Charges,Item.Added)
  901.  On Local Error Resume Next ' local error resume
  902.  Item.Added=False ' clear return variable
  903.  For Array.Index=1 To 5 ' loop through all player inventory
  904.     If UserRecord.Object(Array.Index)=False Then ' check for empty inventory
  905.        UserRecord.Object(Array.Index)=Object.Number ' add object index
  906.        UserRecord.ObjCharges(Array.Index)=Object.Charges ' add object charges
  907.        Item.Added=True ' set return flag
  908.        Exit Sub ' exit routine
  909.     Endif ' end check empty inventory
  910.  Next ' end loop through player inventory
  911. End Sub ' end routine to add item of treasure to player inventory
  912.  
  913.  Rem * routine removes an item of treasure from player inventory.
  914.  Rem * input variables:
  915.  Rem *   Inventory.Number - number of inventory.
  916.  Rem *   Leave.Item - false to leave inventory in room, true to discard.
  917.  
  918. Sub Discard.Inventory(Inventory.Number,Leave.Item)
  919.  On Local Error Resume Next ' local error resume
  920.  ' store player treasure index
  921.  Inventory.Index=UserRecord.Inv(Inventory.Number)
  922.  ' store player treasure charges
  923.  Inventory.Charges=UserRecord.Charges(Inventory.Number)
  924.  Call Read.Record(TreasureFile,Abs(Inventory.Index)) ' get treasure record of item
  925.  Weight=Weight-TreasureRecord.Weight ' subtract weight
  926.  If Weight<False Then ' compare weight
  927.     Weight=False ' clear weight
  928.  Endif ' end check weight
  929.  For Array.Index=Inventory.Number To 19 ' loop through player inventory
  930.     ' pack item removed
  931.     UserRecord.Inv(Array.Index)=UserRecord.Inv(Array.Index+1)
  932.     ' pack item removed
  933.     UserRecord.Charges(Array.Index)=UserRecord.Charges(Array.Index+1)
  934.  Next ' end loop through player inventory
  935.  UserRecord.Inv(20)=False ' clear last item
  936.  UserRecord.Charges(20)=False ' clear last item
  937.  If UserRecord.Inv(1)=False Then ' check player inventory empty
  938.     Weight=False ' clear weight
  939.  Endif ' end check player inventory
  940.  Select Case Inventory.Number ' select weapon
  941.  Case Weapon4 ' check armor being dropped
  942.     Weapon1=False ' clear item
  943.     Weapon4=False ' clear item
  944.  Case Weapon5 ' check shield being dropped
  945.     Weapon3=False ' clear item
  946.     Weapon5=False ' clear item
  947.  Case Weapon6 ' check weapon being dropped
  948.     Weapon2=False ' clear item
  949.     Weapon6=False ' clear item
  950.     Weapon10=False ' clear item
  951.  Case Weapon7 ' check ring being dropped
  952.     Weapon7=False ' clear item
  953.     Weapon8=False ' clear item
  954.     Weapon9=False ' clear item
  955.  End Select ' end check item
  956.  Select Case Inventory.Number ' select weapon
  957.  Case Is<Weapon4 ' check armor index
  958.     Weapon4=Weapon4-1 ' shift item index
  959.  Case Is<Weapon5 ' check shield index
  960.     Weapon5=Weapon5-1 ' shift item index
  961.  Case Is<Weapon6 ' check weapon index
  962.     Weapon6=Weapon6-1 ' shift item index
  963.  Case Is<Weapon7 ' check ring index
  964.     Weapon7=Weapon7-1 ' shift item index
  965.  End Select ' end check index shift
  966.  If Leave.Item=False Then ' verify drop item in room
  967.     ' routine to add item to room
  968.     Call Add.Room.Treasure(Inventory.Index,Inventory.Charges,False,Item.Added)
  969.  Endif ' end check room
  970. End Sub ' end routine to remove player item
  971.  
  972.  Rem * routine adds item to room.
  973.  Rem * input variables:
  974.  Rem *   Treasure.Number - treasure file index.
  975.  Rem *   Treasure.Charges - treasure charges.
  976.  Rem *   Treasure.Flags flags
  977.  Rem * output variables:
  978.  Rem *   Item.Added - return true if item added to room, false if not.
  979.  
  980. Sub Add.Room.Treasure(Treasure.Number, _
  981. Treasure.Charges,Treasure.Flags,Item.Added)
  982.  On Local Error Resume Next ' local error resume
  983.  Item.Added=False ' clear return flag
  984.  For Array.Index=1 To 20 ' loop through room treasure inventory
  985.     ' check empty room inventory
  986.     If RoomRecord.Treasure(Array.Index)=False Then
  987.        RoomRecord.Treasure(Array.Index)=Treasure.Number ' add treasure index
  988.        ' add treasure charges
  989.        RoomRecord.TreCharges(Array.Index)=Treasure.Charges
  990.        RoomRecord.Flags(Array.Index)=Treasure.Flags ' add treasure flags
  991.        Call Share.Room.Record(Room) ' write room record
  992.        Item.Added=True ' set return flag
  993.        Exit Sub ' exit routine
  994.     Endif ' end check empty inventory
  995.  Next ' end loop through room treasure inventory
  996. End Sub ' end routine to add item to room
  997.  
  998.  Rem * routine removes item of treasure from room.
  999.  Rem * input variables:
  1000.  Rem *   Inventory.Number - room inventory number to remove.
  1001.  
  1002. Sub Discard.Room.Treasure(Inventory.Number)
  1003.  On Local Error Resume Next ' local error resume
  1004.  RoomRecord.Treasure(Inventory.Number)=False ' clear treasure items
  1005.  RoomRecord.TreCharges(Inventory.Number)=False ' clear treasure items
  1006.  RoomRecord.Flags(Inventory.Number)=False ' clear treasure items
  1007.  Call Share.Room.Record(Room) ' write room record
  1008. End Sub ' end routine to remove item from room
  1009.  
  1010.  Rem * routine adds object to room.
  1011.  Rem * input variables:
  1012.  Rem *   Object.Number - object index.
  1013.  Rem *   Object.Charges - object charges.
  1014.  Rem * output variables:
  1015.  Rem *   Item.Added - true if item added, false if not.
  1016.  
  1017. Sub Add.Room.Object(Object.Number,Object.Charges,Item.Added)
  1018.  On Local Error Resume Next ' local error resume
  1019.  Item.Added=False ' clear return flag
  1020.  For Array.Index=1 To 20 ' loop through room object inventory
  1021.     ' check empty object inventory
  1022.     If RoomRecord.Object(Array.Index)=False Then
  1023.        RoomRecord.Object(Array.Index)=Object.Number ' add object index
  1024.        RoomRecord.ObjCharges(Array.Index)=Object.Charges ' add object charges
  1025.        Call Share.Room.Record(Room) ' write room record
  1026.        Item.Added=True ' set return flag
  1027.        Exit Sub ' exit routine
  1028.     Endif ' end check empty object inventory
  1029.  Next ' end loop through room object inventory
  1030. End Sub ' end routine to add item to room
  1031.  
  1032.  Rem * routine removes an object from room.
  1033.  Rem * input variables:
  1034.  Rem *   Inventory.Number - room inventory number to remove.
  1035.  
  1036. Sub Discard.Room.Object(Inventory.Number)
  1037.  On Local Error Resume Next ' local error resume
  1038.  RoomRecord.Object(Inventory.Number)=False ' clear treasure items
  1039.  RoomRecord.ObjCharges(Inventory.Number)=False ' clear treasure items
  1040.  Call Share.Room.Record(Room) ' write room record
  1041. End Sub ' end routine to remove item from room
  1042.  
  1043.  Rem * routine removes an object from inventory.
  1044.  Rem * input variables:
  1045.  Rem *   Inventory.Number - player inventory number to remove.
  1046.  
  1047. Sub Discard.Inventory.Object(Inventory.Number)
  1048.  On Local Error Resume Next ' local error resume
  1049.  For Inventory.Count=Inventory.Number To 4 ' loop packer
  1050.     ' shift object items
  1051.     UserRecord.Object(Inventory.Count)=UserRecord.Object(Inventory.Count+1)
  1052.     ' shift object items
  1053.     UserRecord.ObjCharges(Inventory.Count)= _
  1054.     UserRecord.ObjCharges(Inventory.Count+1)
  1055.  Next ' end packing
  1056.  UserRecord.Object(5)=False ' clear treasure items
  1057.  UserRecord.ObjCharges(5)=False ' clear treasure items
  1058. End Sub ' end routine to remove item from room
  1059.  
  1060.  Rem * routine removes treasure from room after player leaves to new room.
  1061.  Rem * input variables:
  1062.  Rem *   Room - number of room to clean.
  1063.  
  1064. Sub Clean.Room
  1065.  On Local Error Resume Next ' local error resume
  1066.  If Room<=False Or Room>Lof(RoomFile)/Len(RoomRecord) Then ' check file bounds
  1067.     Exit Sub ' exit routine
  1068.  Endif ' end check file bounds
  1069.  Call Read.Room.Record(Room) ' get room record
  1070.  If RoomRecord.Container.Permanent=False Then ' check permanent container
  1071.     Call Clear.Container(0,True) ' routine to clear container record
  1072.     RoomRecord.Container=ContainerRec ' store container record in room
  1073.  Endif ' end check permanent container
  1074.  Call Share.Room.Record(Room) ' write room record
  1075.  For Array.Index=1 To 20 ' loop through room treasure
  1076.     Treasure.Number=RoomRecord.Treasure(Array.Index) ' store treasure index
  1077.     If Treasure.Number>False And _
  1078.     Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then ' file bounds
  1079.        Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  1080.        If TreasureRecord.Permanent=False Then ' check permanent treasure
  1081.           If TreasureRecord.Invisible=False Then ' check invisible treasure
  1082.              ' check treasure flags
  1083.              If RoomRecord.Flags(Array.Index)=False Then
  1084.                 ' remove item from room
  1085.                 Call Discard.Room.Treasure(Array.Index)
  1086.              Endif ' end check flags
  1087.           Endif ' end check invisible
  1088.        Endif ' end check permanent
  1089.     Endif ' end check file bounds
  1090.  Next ' end loop through room treasure
  1091. End Sub ' end routine to clean room
  1092.  
  1093.  Rem * routine lists users.
  1094.  
  1095. Sub User.List
  1096.  On Local Error Resume Next ' local error resume
  1097.  Call Share.Record(UserFile,User.Index) ' store player user record
  1098.  Outpt="(hit <control-k> to interrupt).." ' make message
  1099.  Call IO.O ' send message
  1100.  Graphics.Off=True ' reset color
  1101.  Gosub Heading ' subroutine to display heading
  1102.  Allow.Break=True ' enable control-k checking
  1103.  Break=False ' reset control-k flag
  1104.  Continue=False ' reset continuous flag
  1105.  Page.Length=3 ' set page length
  1106.  For User.Number=1 To Lof(UserFile)/Len(UserRecord) ' loop through all users
  1107.     Call Read.Record(UserFile,User.Number) ' get next user record
  1108.     Inpt=UserRecord.CodeName ' store user codename
  1109.     Call Decrypt(Inpt) ' routine to decrypt codename
  1110.     Inpt=Lcase$(Inpt) ' lowercase codename,
  1111.     List.User=True ' set list user flag
  1112.     If Left$(Inpt,9)=Deleted$ Then ' check user record exists
  1113.        List.User=False ' reset list user flag
  1114.     Else ' check user
  1115.        If UserRecord.Flags And Locked.User Then ' check locked user
  1116.           If Normal.User Then ' compare DM or Sysop
  1117.              List.User=False ' reset list user flag
  1118.           Endif ' end compare normal user
  1119.        Endif ' end check locked mailbox
  1120.     Endif ' end check user
  1121.     If List.User Then ' check list user flag
  1122.        Outpt=Mid$(Str$(User.Number),2)+"." ' make output line
  1123.        Outpt=Outpt+Space$(7-Len(Outpt)) ' with user number,
  1124.        Mid$(Inpt,1,1)=Ucase$(Mid$(Inpt,1,1)) ' with codename,
  1125.        Outpt=Outpt+Inpt+" " ' make output line
  1126.        Inpt=UserRecord.ClassName ' with user class name,
  1127.        Call Decrypt(Inpt) ' decrypt classname
  1128.        Outpt=Outpt+Inpt+" " ' make output line
  1129.        If UserRecord.Race<=False Then ' verify race in bounds
  1130.           UserRecord.Race=1 ' reset race
  1131.        Endif ' end verify race
  1132.        Inpt=Race(UserRecord.Race) ' with user race name
  1133.        Inpt=Rtrim$(Inpt) ' make output line
  1134.        Inpt=Inpt+Space$(8-Len(Inpt)) ' append blanks
  1135.        Outpt=Outpt+Inpt ' with race name,
  1136.        If UserRecord.Level<=False Then ' check player level
  1137.           Inpt=" "+Dead$ ' player is dead, append
  1138.        Else ' check level
  1139.           Inpt=Str$(UserRecord.Level) ' add player level,
  1140.        Endif ' end check level
  1141.        Inpt=Inpt+Space$(7-Len(Inpt)) ' make output line
  1142.        If UserRecord.ClassType>=AsstDM Then ' check special class type,
  1143.           Inpt=Inpt+"*" ' add an asterick for DMs
  1144.        Endif ' end check class type
  1145.        If UserRecord.Flags And Locked.User Then ' check locked user
  1146.           Inpt=Inpt+Mask$ ' add mask character for locked mailbox
  1147.        Endif ' end check class type
  1148.        Outpt=Outpt+Inpt ' add to output line
  1149.        Call IO.O ' send output line
  1150.        If Break Then ' check control-k entered
  1151.           Exit For ' exit loop through user file
  1152.        Endif ' end check control-k
  1153.        Page.Length=Page.Length+1 ' increment page length
  1154.        If Page.Length=UserRecord.Pagelength Then ' compare page length
  1155.           Page.Length=3 ' reset page length
  1156.           If Continue=False Then ' check continuous flag
  1157.              Call More.Prompt ' pause for more
  1158.              If No Then ' more response
  1159.                 Exit For ' exit loop through user file
  1160.              Endif ' end check response
  1161.              Gosub Heading ' subroutine to display heading
  1162.           Endif ' end check continuous flag
  1163.        Endif ' end compare page length
  1164.     Endif ' end check valid user
  1165.  Next ' end loop through user file
  1166.  Allow.Break=False ' disable control-k checking
  1167.  If Break Then ' check control-k flag
  1168.     Break=False ' reset control-k flag
  1169.     Outpt=Nul ' set output to null
  1170.     Call IO.O ' send empty return
  1171.  Endif ' end check control-k flag
  1172.  If Page.Length>3 Then ' recheck page length
  1173.     Call More.Prompt ' display more prompt
  1174.  Endif ' end check last page length
  1175.  Call Read.Record(UserFile,User.Index) ' get current user record
  1176.  Exit Sub ' exit routine
  1177.  
  1178. Heading:
  1179.  ' make heading message
  1180.  Outpt="The Adventure Door v"+Version$+" User List For "+FNclock$+"."
  1181.  Call IO.O ' send message
  1182.  Outpt=Nul ' empty cr/lf
  1183.  Call IO.O ' send empty cr/lf
  1184.  ' make heading message
  1185.  Outpt="Number User Name                      Class Name"+ _
  1186.  "           Race     Level DM"
  1187.  Call IO.O ' send heading message
  1188.  Outpt=String$(76,"-") ' make heading
  1189.  Call IO.O ' send heading
  1190.  Return ' exit subroutine
  1191. End Sub ' end routine to display users
  1192.  
  1193.  Rem * routine reads player userfile record, sets some variables.
  1194.  Rem * input variables:
  1195.  Rem *   User.Index - number of user file record.
  1196.  
  1197. Sub Get.User.Record
  1198.  On Local Error Resume Next ' local error resume
  1199.  Call Read.Record(UserFile,User.Index) ' read user file record
  1200.  Weight=False ' clear inventory weight
  1201.  For Inventory.Number=1 To 20 ' loop through player inventory
  1202.     Treasure.Number=UserRecord.Inv(Inventory.Number) ' store treasure number
  1203.     If Treasure.Number>False And _
  1204.     Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then ' file bounds
  1205.        Call Read.Record(TreasureFile,Treasure.Number) ' get treasur record
  1206.        Weight=Weight+TreasureRecord.Weight ' add weight
  1207.     Endif ' end check file bounds
  1208.  Next ' end loop through player userfile record
  1209.  User.Echo=UserRecord.Echo ' store user preference
  1210.  User.LineFeeds=UserRecord.LineFeeds ' store user preference
  1211.  User.LineLength=UserRecord.LineLength ' store user preference
  1212.  User.PageLength=UserRecord.PageLength ' store user preference
  1213.  User.Wordwrap=UserRecord.Wordwrap ' store user preference
  1214.  Call Get.User.Stats ' routine to set any special player statistics
  1215.  Room=UserRecord.Room ' store player room number
  1216.  Hidden.Player=False ' reset hidden player flag
  1217.  If UserRecord.Brief Then ' check player brief mode
  1218.     Action.Prompt="Next?" ' store command prompt
  1219.  Else ' check player
  1220.     Action.Prompt="Command? " ' store command prompt
  1221.  Endif ' end compare player brief mode
  1222.  If UserRecord.Beauty<=1 Or UserRecord.Beauty>MaxStat Then ' check lady player
  1223.     UserRecord.Beauty=Int(Rnd*15+5) ' recalculate lady stats
  1224.  Endif ' end check lady stats
  1225.  ' check lady player
  1226.  If UserRecord.Glamour<=1 Or UserRecord.Glamour>MaxStat Then
  1227.     UserRecord.Glamour=Int(Rnd*15+5) ' recalculate lady stats
  1228.  Endif ' end check lady stats
  1229.  Sorting=UserRecord.Sort ' get user sort preference
  1230. End Sub ' end routine to read user record
  1231.  
  1232.  Rem * routine sets any special player statistics and attributes.
  1233.  
  1234. Sub Get.User.Stats
  1235.  On Local Error Resume Next ' local error resume
  1236.  If UserRecord.Flags And Special.Char1 Then ' check player is town mayor
  1237.     Town.Mayor=True ' set town mayor flag
  1238.  Else ' check player
  1239.     Town.Mayor=False ' set town mayor flag
  1240.  Endif ' end check player special stats
  1241.  If UserRecord.Flags And Special.Char2 Then ' check player is governor
  1242.     Governor=True ' set governor flag
  1243.  Else ' check player
  1244.     Governor=False ' set governor flag
  1245.  Endif ' end check player special stats
  1246.  If UserRecord.Flags And Special.Char3 Then ' check player is guild master
  1247.     Guild.Master=True ' set guild master flag
  1248.  Else ' check player
  1249.     Guild.Master=False ' set guild master flag
  1250.  Endif ' end check player special stats
  1251.  If UserRecord.Flags And Special.Char4 Then ' check player is sysop
  1252.     Sysop=True ' set sysop flag
  1253.  Else ' check player
  1254.     Sysop=False ' set sysop flag
  1255.  Endif ' end check player special stats
  1256.  If UserRecord.ClassType=AsstDM Then ' check player is assistant DM
  1257.     Dungeon.Master.Assistant=True ' set asst. dm flag
  1258.  Else ' check player
  1259.     Dungeon.Master.Assistant=False ' set asst. dm flag
  1260.  Endif ' end check player
  1261.  If UserRecord.ClassType=DM Then ' check player is dungeon master
  1262.     Dungeon.Master=True ' set dm flag
  1263.  Else ' check player
  1264.     Dungeon.Master=False ' set dm flag
  1265.  Endif ' end check player
  1266.  ' check special player types
  1267.  If Dungeon.Master Or Dungeon.Master.Assistant Or Sysop Then
  1268.     Normal.User=False ' set normal player mode off
  1269.  Else ' check player
  1270.     Normal.User=True ' set normal  player mode on
  1271.  Endif ' end check player
  1272. End Sub ' end routine to set player special statistics/attributes
  1273.  
  1274.  Rem * routine writes user record.
  1275.  
  1276. Sub Put.User.Record
  1277.  On Local Error Resume Next ' local error resume
  1278.  UserRecord.Echo=User.Echo ' write user preference
  1279.  UserRecord.LineFeeds=User.LineFeeds ' write user preference
  1280.  UserRecord.LineLength=User.LineLength ' write user preference
  1281.  UserRecord.PageLength=User.PageLength ' write user preference
  1282.  UserRecord.Wordwrap=User.Wordwrap ' write user preference
  1283.  UserRecord.Sort=Sorting ' user sort preference
  1284.  UserRecord.Room=Room ' store current room
  1285.  Call Share.Record(UserFile,User.Index) ' write user record
  1286. End Sub ' end routine to write user record
  1287.  
  1288.  Rem * routine updates player health, room lights, drunkeness, and poison.
  1289.  Rem * input variables:
  1290.  Rem *   Room.Rate - stores rounds counter.
  1291.  Rem *   Room.Health.Rate - stores health update rate.
  1292.  
  1293. Sub Health.Update
  1294.  On Local Error Resume Next ' local error resume
  1295.  Graphics.Off=False ' reset color
  1296.  Room.Rate=Room.Rate+1 ' increment room health counter
  1297.  If Room.Rate<Room.Health.Rate Then ' compare health rate
  1298.     Exit Sub ' exit routine
  1299.  Endif ' end check counter
  1300.  Room.Rate=False ' reset room health counter
  1301.  ' determine any lights in player inventory go out
  1302.  For Inventory.Number=1 To 20 ' loop through player inventory
  1303.     ' get player inventory charges
  1304.     Charges.Number=UserRecord.Charges(Inventory.Number)
  1305.     If Charges.Number<False Then ' check for light on
  1306.        Charges.Number=Charges.Number+1 ' decrement negatively light charges
  1307.        UserRecord.Charges(Inventory.Number)=Charges.Number ' store new charges
  1308.        If Charges.Number=False Then ' compare charges
  1309.           ' get treasure record
  1310.           Call Read.Record(TreasureFile,UserRecord.Inv(Inventory.Number))
  1311.           Outpts=TreasureRecord.ShortName ' get light name
  1312.           Outpts=Rtrim$(Outpts) ' trim name
  1313.           Outpts=Lcase$(Outpts) ' lowercase name
  1314.           Outpt="The "+Outpts+" went out!" ' make light out message
  1315.           Call IO.O ' send message
  1316.        Endif ' end compare charges remaining
  1317.     Endif ' end check light on
  1318.  Next ' end loop through player inventory
  1319.  If Intoxicated>False Then ' verify player drunk
  1320.     Intoxicated=Intoxicated-1 ' decrement drunkeness
  1321.     If Intoxicated<=False Then ' compare drunkeness counter
  1322.        Intoxicated=False ' reset counter
  1323.        Outpt="Your drunk is over.." ' make message
  1324.     Else ' check drunk
  1325.        UserRecord.Fatigue=UserRecord.Fatigue-2 ' decrement fatigue for drunk
  1326.        If UserRecord.Fatigue<=False Then ' compare fatigue
  1327.           UserRecord.Fatigue=False ' reset fatigue
  1328.           Intoxicated=False ' reset drunkeness
  1329.           Outpt="Your drunk is over.." ' make message
  1330.        Else ' compare still drunk
  1331.           Outpt="You feel drunk!" ' make message
  1332.        Endif ' end compare drunk
  1333.     Endif ' end check drunk
  1334.     Call IO.O ' send drunkeness message
  1335.  Else ' verify drunk player
  1336.     New.Stat!=UserRecord.Fatigue+4 ' increment player fatigue
  1337.     If New.Stat!>MaxInt Then ' check maximum fatigue
  1338.        New.Stat!=MaxInt ' reduce to maximum integer
  1339.     Endif ' end check maximum fatigue
  1340.     UserRecord.Fatigue=Cint(New.Stat!) ' store new fatigue
  1341.  Endif ' end verify drunk player
  1342.  If UserRecord.Poison Then ' verify player poisoned
  1343.     UserRecord.Vitality=UserRecord.Vitality-2 ' decrement player vitality
  1344.     Outpt="You feel poison running through your veins!" ' make message
  1345.     Call IO.O ' send poisoned message
  1346.     If UserRecord.Vitality<=False Then ' check vitality
  1347.        UserRecord.Vitality=False ' reset vitality
  1348.        Message1="You finally died from your poisonous wounds!" ' message
  1349.        Call Player.Died ' routine for dead player
  1350.     Endif ' end check vitality
  1351.  Else ' verify poisoned player
  1352.     New.Stat!=UserRecord.Vitality+3 ' increment player vitality
  1353.     If New.Stat!>MaxInt Then ' check maximum integer
  1354.        New.Stat!=MaxInt ' reset to maximum integer
  1355.     Endif ' end check maximum integer
  1356.     UserRecord.Vitality=Cint(New.Stat!) ' store new vitality
  1357.  Endif ' end verify poisoned player
  1358.  New.Stat!=UserRecord.Magic+2 ' increment player magic points
  1359.  If New.Stat!>MaxInt Then ' compare magic points to maximum integer
  1360.     New.Stat!=MaxInt ' reset to maximum integer
  1361.  Endif ' end check maximum integer
  1362.  UserRecord.Magic=Cint(New.Stat!) ' store new magic points
  1363.  New.Stat!=UserRecord.Psionic+1 ' increment psionic points
  1364.  If New.Stat!>MaxInt Then ' check maximum psionic points
  1365.     New.Stat!=MaxInt ' reset to maximum integer
  1366.  Endif ' end check maximum integer
  1367.  UserRecord.Psionic=Cint(New.Stat!) ' store new psionic points
  1368.  Call New.Stats ' routine to update statistics
  1369.  If Invisible>False Then ' check invisible counter
  1370.     Invisible=Invisible-1 ' decrement invisible counter
  1371.     If Invisible<=False Then ' compare counter
  1372.        UserRecord.Invisible=False ' reset invisible
  1373.        Invisible=False ' reset invisible
  1374.        Outpt="You are no longer invisible!" ' make message
  1375.        Call IO.O ' send invisible message
  1376.     Endif ' end compare counter
  1377.  Endif ' end check counter
  1378. End Sub ' end health update routine
  1379.  
  1380.  Rem * routine searches current room, displays hidden items.
  1381.  
  1382. Sub Search.Room
  1383.  On Local Error Resume Next ' local error resume
  1384.  Outpt="You search the room.." ' make message
  1385.  Call IO.O ' send search message
  1386.  Graphics.Off=True ' reset color
  1387.  Outpt="You find " ' make first display message
  1388.  Carriage.Return=True ' disable cr/lf
  1389.  Call IO.O ' send first message
  1390.  Items.Displayed=False ' items displayed counter
  1391.  For Room.Objects=1 To 20 ' loop through room objects
  1392.     Object.Number=RoomRecord.Object(Room.Objects) ' get room object index
  1393.     ' file bounds
  1394.     If Object.Number>False And _
  1395.     Object.Number<=Lof(ObjectFile)/Len(ObjectRecord) Then
  1396.        Call Read.Record(ObjectFile,Object.Number) ' get object record
  1397.        Charges.Number=False ' set display flag
  1398.        If ObjectRecord.Invisible Then ' check object invisible
  1399.           If Rnd<.5 Then ' random chance
  1400.              Charges.Number=True ' set display flag
  1401.           Endif ' end random chance
  1402.        Endif ' end check invisible object
  1403.        If ObjectRecord.Hidden Then ' check object hidden
  1404.           If Normal.User Then ' verify non DM
  1405.              Charges.Number=False ' set display flag
  1406.           Endif ' end verify normal player
  1407.        Endif ' end check hidden object
  1408.        If Charges.Number Then ' check display flag
  1409.           Carriage.Return=True ' disable cr/lf
  1410.           Call IO.O ' send previous string
  1411.           Outpt=Rtrim$(ObjectRecord.ObjectName)+", " ' store object name
  1412.           Items.Displayed=Items.Displayed+1 ' increment item displayed counter
  1413.        Endif ' end check display flag
  1414.     Endif ' end check file bounds
  1415.  Next ' end loop through room objects
  1416.  For Room.Treasure=1 To 20 ' loop through room treasure
  1417.     Treasure.Number=RoomRecord.Treasure(Room.Treasure) ' get treasure index
  1418.     If Treasure.Number>False And _
  1419.     Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then ' file bounds
  1420.        Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  1421.        Charges.Number=False ' set display flag
  1422.        If TreasureRecord.Invisible Then ' check treasure invisible
  1423.           If Rnd<.5 Then ' random chance
  1424.              Charges.Number=True ' set display flag
  1425.           Endif ' end random chance
  1426.        Endif ' end invisible treasure
  1427.        ' check treasure hidden
  1428.        If RoomRecord.Flags(Room.Treasure)=Hidden.Object Then
  1429.           If Rnd<.5 Then ' random chance
  1430.              Charges.Number=True ' set display flag
  1431.           Endif ' end random chance
  1432.        Endif ' end check hidden treasure
  1433.        If Charges.Number Then ' check display flag
  1434.           Carriage.Return=True ' disable cr/lf
  1435.           Call IO.O ' send previous string
  1436.           Outpt=Rtrim$(TreasureRecord.TreasureName)+", " ' store treasure name
  1437.           Items.Displayed=Items.Displayed+1 ' increment displayed counter
  1438.        Endif ' end check display flag
  1439.     Endif ' end check file bounds
  1440.  Next ' end loop through room treasure
  1441.  If Items.Displayed=False Then ' check items displayed counter
  1442.     Outpt="nothing.." ' make message
  1443.  Else ' check item counter
  1444.     Outpt=Left$(Outpt,Len(Outpt)-2)+"." ' trim comma, add period
  1445.     If Items.Displayed>1 Then ' check counter
  1446.        Outpt="and "+Outpt ' append string
  1447.     Endif ' end check counter
  1448.  Endif ' end check counter
  1449.  Call IO.O ' send message
  1450. End Sub ' end routine to search room
  1451.  
  1452.  Rem * routine processes actions, routine is entered when a trigger is
  1453.  Rem * activated.
  1454.  Rem * input variables:
  1455.  Rem *   Activate.Action$ - the display string which activated the action.
  1456.  Rem *   Trigger.Action$ - prefix string of what hit player.
  1457.  
  1458. Sub Actions(Activate.Action$,Trigger.Action$)
  1459.  On Local Error Resume Next ' local error resume
  1460.  If Room=1 Then ' check resurrected room
  1461.     Exit Sub ' exit routine
  1462.  Endif ' end check room
  1463.  Inpt=Nul ' reset output string
  1464.  Graphics.Off=False ' reset color
  1465.  Select Case ActionRecord.Inventory ' selection of room action
  1466.  Case 1 ' inventory action 1 breaks all weapons
  1467.     Item.Broke=False ' weapon broke flag
  1468.     Weapon2=False ' reset weapon held
  1469.     Weapon6=False ' reset weapon held
  1470.     Weapon10=False ' reset weapon held
  1471.     For Inventory.Number=1 To 20 ' loop through all player inventory
  1472.        Treasure.Number=UserRecord.Inv(Inventory.Number) ' get treasure index
  1473.        If Treasure.Number>False And _
  1474.        Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then 'file bounds
  1475.           Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  1476.           If TreasureRecord.Plus Then ' check weapon plus
  1477.              If TreasureRecord.Type=False Then ' check weapon
  1478.                 ' check weapon charges
  1479.                 If UserRecord.Charges(Inventory.Number) Then
  1480.                    ' clear weapon charges
  1481.                    UserRecord.Charges(Inventory.Number)=False
  1482.                    Item.Broke=True ' set weapon broke flag
  1483.                 Endif ' end check charges
  1484.              Endif ' end check weapon
  1485.           Endif ' end check weapon plus
  1486.        Endif ' end check file bounds
  1487.     Next ' end loop through player inventory
  1488.     If Item.Broke Then ' compare weapon broke flag
  1489.        Outpt=Activate.Action$ ' copy routine string
  1490.        Call IO.O ' send string
  1491.        Outpt="All your weapons break!" ' make message
  1492.        Call IO.O ' send weapon message
  1493.     Endif ' end compare broke flag
  1494.  Case 2 ' inventory action 2 breaks all shields
  1495.     Item.Broke=False ' set shield broke flag
  1496.     Weapon3=False ' clear shield held
  1497.     Weapon5=False ' clear shield held
  1498.     For Inventory.Number=1 To 20 ' loop through all player inventory
  1499.        Treasure.Number=UserRecord.Inv(Inventory.Number) ' get treasure index
  1500.        If Treasure.Number>False And _
  1501.        Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then 'file bounds
  1502.           Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  1503.           If TreasureRecord.Type<False Then ' check shield type
  1504.              If UserRecord.Charges(Inventory.Number) Then ' check charges
  1505.                 ' clear shield charges
  1506.                 UserRecord.Charges(Inventory.Number)=False
  1507.                 Item.Broke=True ' set shield broke flag
  1508.              Endif ' end check charges
  1509.           Endif ' end check shield
  1510.        Endif ' end check file bounds
  1511.     Next ' end loop through player inventory
  1512.     If Item.Broke Then ' compare shield broke flag
  1513.        Outpt=Activate.Action$ ' copy routine string
  1514.        Call IO.O ' send string
  1515.        Outpt="All your shields break!" ' make message
  1516.        Call IO.O ' send shield message
  1517.     Endif ' end compare broke flag
  1518.  Case 3 ' inventory action 3 breaks all armor
  1519.     Item.Broke=False ' set armor broke flag
  1520.     Weapon1=False ' clear armor worn
  1521.     Weapon4=False ' clear armor worn
  1522.     For Inventory.Number=1 To 20 ' loop through all player inventory
  1523.        Treasure.Number=UserRecord.Inv(Inventory.Number) ' get treasure index
  1524.        If Treasure.Number>False And _
  1525.        Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then 'file bounds
  1526.           Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  1527.           If TreasureRecord.Type>False Then ' check armor
  1528.              If UserRecord.Charges(Inventory.Number) Then ' check charges
  1529.                 ' clear armor charges
  1530.                 UserRecord.Charges(Inventory.Number)=False
  1531.                 Item.Broke=True ' set armor broke flag
  1532.              Endif ' end check charges
  1533.           Endif ' end check armor
  1534.        Endif ' end check file bounds
  1535.     Next ' end loop through player inventory
  1536.     If Item.Broke Then ' compare armor broke flag
  1537.        Outpt=Activate.Action$ ' copy routine message
  1538.        Call IO.O ' send message
  1539.        Outpt="All your armor breaks!" ' make message
  1540.        Call IO.O ' send armor message
  1541.     Endif ' end compare broke flag
  1542.  Case 4 ' inventory action 4 breaks all magic items
  1543.     Item.Broke=False ' set magic item broke flag
  1544.     Weapon7=False ' clear ring held
  1545.     Weapon8=False ' clear ring held
  1546.     For Inventory.Number=1 To 20 ' loop through all player inventory
  1547.        Treasure.Number=UserRecord.Inv(Inventory.Number) ' get treasure index
  1548.        If Treasure.Number>False And _
  1549.        Treasure.Number<=Lof(TreasureFile)/Len(TreasureRecord) Then 'file bounds
  1550.           Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  1551.           If TreasureRecord.Spell Then ' check magic item
  1552.              If UserRecord.Charges(Inventory.Number) Then ' check charges
  1553.                 ' clear magic item charges
  1554.                 UserRecord.Charges(Inventory.Number)=False
  1555.                 Item.Broke=True ' set magic item broke flag
  1556.              Endif ' end check charges
  1557.           Endif ' end check magic item
  1558.        Endif ' end check file bounds
  1559.     Next ' end loop through player inventory
  1560.     If Item.Broke Then ' compare magic item broke flag
  1561.        Outpt=Activate.Action$ ' copy routine string
  1562.        Call IO.O ' send string
  1563.        Outpt="All your magic items break!" ' make message
  1564.        Call IO.O ' send magic item message
  1565.     Endif ' end compare broke flag
  1566.  End Select ' end selection of action
  1567.  If ActionRecord.Fumble Then ' verify room fumble action
  1568.     Call Fumble ' routine to fumble weapon/shield
  1569.  Endif ' end verify fumble action
  1570.  Teleport.Number=ActionRecord.Teleport
  1571.  If Teleport.Number>False And Teleport.Number<>Room Then
  1572.     Outpt=Activate.Action$ ' copy routine string
  1573.     Call IO.O ' send string
  1574.     Outpt="You are teleported elsewhere!" ' make message
  1575.     Call IO.O ' send teleport message
  1576.     Next.Room=Teleport.Number ' store new room number
  1577.     Teleported=True ' set teleporting flag
  1578.     Call Enter.Room ' routine to move player to new room
  1579.  Endif ' end verify teleport action
  1580.  Room.Hits#=Cdbl(Int(ActionRecord.HitPoints)) ' store room hit action
  1581.  If Room.Hits#>False Then ' verify hit points action
  1582.     Outpt=Activate.Action$ ' copy routine string
  1583.     Call IO.O ' send string
  1584.     Outpt=Trigger.Action$ ' copy second routine string
  1585.     Call Hit.Player(Room.Hits#) ' routine to hit player
  1586.  Endif ' end verify hit points action
  1587. End Sub ' end routine to activate room actions
  1588.  
  1589.  Rem * routine to verify monster blocking exits, then check valid direction.
  1590.  Rem * input variables:
  1591.  Rem *   Direction.Number - direction to go.
  1592.  Rem * output variables:
  1593.  Rem *   Next.Room - number of new room to enter.
  1594.  
  1595. Sub Verify.Room(Direction.Number)
  1596.  On Local Error Resume Next ' local error resume
  1597.  New.Room=False ' enter new room flag
  1598.  If UserRecord.ClassType<Lady Then ' check normal player class
  1599.     For Array.Index=1 To Number.Monsters ' loop through monsters in room
  1600.        If MonsterArray(Array.Index).Block Then ' check monster blocks exits
  1601.           ' random percent
  1602.           If Rnd<(MonsterArray(Array.Index).BlockPercent/100) Then
  1603.              Inpt=MonsterArray(Array.Index).MonsterName ' store monster name
  1604.              Inpt=Rtrim$(Inpt) ' trim name
  1605.              Outpt="The "+Inpt+" blocks your way!" ' make block message
  1606.              Call IO.O ' send block message
  1607.              Exit Sub ' exit routine
  1608.           Endif ' end check random percentage
  1609.        Endif ' end check monster blocks exits
  1610.     Next ' end loop through monsters
  1611.  Endif ' end check normal user
  1612.  Next.Room=RoomRecord.Direct(Direction.Number) ' get room number of direction
  1613.  If Next.Room=False Then ' check next room number
  1614.     If Normal.User Then ' check DM status
  1615.        Outpt="You can't go in that direction!" ' make entry message
  1616.        Call IO.O ' send entry message
  1617.     Else ' check DM status
  1618.        Call Add.Room(Direction.Number,Room.Added) ' routine to add new room
  1619.        New.Room=Room.Added ' store new room flag
  1620.     Endif ' end check DM
  1621.     Exit Sub ' exit routine
  1622.  Else ' check next room number
  1623.     ' routine to verify room direction restricted
  1624.     Call Restrict(Direction.Number,Restricted)
  1625.     If Restricted Then ' check room restricted flag
  1626.        Outpt="Your level does not permit entrance to that room!" ' message
  1627.        Call IO.O ' send restricted message
  1628.        Exit Sub ' exit routine
  1629.     Endif ' end check room restricted
  1630.     ' routine to verify room entry type restricted
  1631.     Call Restrict.Room.Type(Restricted)
  1632.     If Restricted Then ' check room restricted flag
  1633.        Outpt="You can't walk to that room!" ' message
  1634.        Call IO.O ' send restricted message
  1635.        Exit Sub ' exit routine
  1636.     Endif ' end check room restricted
  1637.  Endif ' end check next room number
  1638.  New.Room=True ' store next room valid flag
  1639. End Sub ' end routine to verify room entry, direction
  1640.  
  1641.  Rem * routine to exit a room with the Out command.
  1642.  
  1643. Sub Exit.Room
  1644.  On Local Error Resume Next ' local error resume
  1645.  Entry.Command=Last.Command.Number ' store room entry command
  1646.  User.Command="O" ' store out command
  1647.  Last.Command="OUT" ' store out command
  1648.  Last.Command.Number=True ' reset command type
  1649.  Call Verify.Room(5) ' routine to verify valid room
  1650.  If New.Room Then ' check valid room flag
  1651.     Call Enter.Room ' routine to move player to room
  1652.  Endif ' end check valid room
  1653. End Sub ' end routine to go Out
  1654.  
  1655.  Rem * routine to use the Up direction.
  1656.  
  1657. Sub Climb
  1658.  On Local Error Resume Next ' local error resume
  1659.  Entry.Command=Last.Command.Number ' store room entry command
  1660.  User.Command="U" ' store up command
  1661.  Last.Command="UP" ' store up command
  1662.  Last.Command.Number=True ' store command type
  1663.  Call Verify.Room(6) ' routine to check valid room
  1664.  If New.Room Then ' check valid room flag
  1665.     Call Enter.Room ' routine to move player to room
  1666.  Endif ' end check valid room
  1667. End Sub ' end routine to go Up
  1668.  
  1669.  Rem * routine processes room traps.
  1670.  
  1671. Sub Traps
  1672.  On Local Error Resume Next ' local error resume
  1673.  New.Room=False ' reset next room flag
  1674.  If Rnd<.5 Then ' random chance
  1675.     Outpt="It's trapped! " ' make trap message
  1676.     Select Case ObjectRecord.Trap ' selection of room trap type
  1677.     Case 1 ' type 1
  1678.        Outpt=Outpt+"Poison needles!" ' make trap message
  1679.        Call IO.O ' send trap message
  1680.        UserRecord.Poison=True ' set player poison flag
  1681.     Case 2 ' type 2
  1682.        New.Room=ObjectRecord.Teleport ' store teleport room number
  1683.        ' file bounds
  1684.        If New.Room>False And New.Room<=Lof(RoomFile)/Len(RoomRecord) Then
  1685.           If New.Room<>Room Then ' check destination room for recursion
  1686.              Outpt=Outpt+"Falling door!" ' make trap message
  1687.              Call IO.O ' send trap message
  1688.              Pass.Door=False ' clear pass door flag
  1689.              Number.Monsters=False ' clear number of monsters
  1690.              Next.Room=New.Room ' store room trap teleport number
  1691.              Teleported=True ' set teleporting flag
  1692.              Call Enter.Room ' routine to move player to a room
  1693.           Endif ' end check destination room
  1694.        Endif ' end check file bounds
  1695.     Case 3 ' type 3
  1696.        Outpt=Outpt+"Deadly spears!" ' make trap message
  1697.        Call IO.O ' send trap message
  1698.        Outpt="You are hit for" ' make hits message
  1699.        ' get object trap hits on player
  1700.        Room.Hits#=Cdbl(Int(ObjectRecord.Teleport))
  1701.        If Room.Hits#>False Then ' check hits
  1702.           Call Hit.Player(Room.Hits#) ' routine to hit player
  1703.        Endif ' end check hits
  1704.     End Select ' end selection of trap type
  1705.  Endif ' end check random chance
  1706. End Sub ' end routine for room traps
  1707.  
  1708.  Rem * routine to hide player.
  1709.  
  1710. Sub Hide.User
  1711.  On Local Error Resume Next ' local error resume
  1712.  If Hidden.Player Then ' check player already hidden
  1713.     Outpt="You hide in the shadows!" ' make hide message
  1714.     Call IO.O ' send hide message
  1715.     Exit Sub ' exit routine
  1716.  Endif ' end check player hidden
  1717.  Hide.Flag=False ' set hide flag
  1718.  If Number.Monsters=False Then ' check number of monsters in room
  1719.     Hide.Flag=True ' set hide flag
  1720.  Else ' check monsters
  1721.     If Rnd>.66 Then ' random chance
  1722.        Hide.Flag=True ' set hide flag
  1723.     Endif ' end check random chance
  1724.  Endif ' end check monsters in room
  1725.  If Hide.Flag Then ' check hide flag
  1726.     Hidden.Player=True ' set player hide flag
  1727.     Outpt="You hide in the shadows!" ' make hide message
  1728.  Else ' check hide flag
  1729.     Outpt="Didn't work!" ' make hide message
  1730.  Endif ' end check hide flag
  1731.  Call IO.O ' send hide message
  1732. End Sub ' end routine to hide player
  1733.  
  1734.  Rem * routine for player to use a vehicle.
  1735.  
  1736. Sub Enter.Vehicle
  1737.  On Local Error Resume Next ' local error resume
  1738.  Call Check.Room.Treasure ' routine finds vehicle name in room
  1739.  If Index.Number=False Then ' check room vehicle found
  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 found
  1744.  If TreasureRecord.Vehicle=False Then ' check item is vehicle
  1745.     Outpt="That's not a vehicle!" ' make error message
  1746.     Call IO.O ' send error message
  1747.     Exit Sub ' exit routine
  1748.  Endif ' end check vehicle
  1749.  Outpts=TreasureRecord.ShortName ' store treasure name
  1750.  Outpts=Rtrim$(Outpts) ' trim name
  1751.  Outpts=Lcase$(Outpts) ' lowercase name
  1752.  If Charges.Number=False Then ' check vehicle hits
  1753.     Outpt="The "+Outpts+" is damaged!" ' make error message
  1754.     Call IO.O ' send error message
  1755.     Exit Sub ' exit routine
  1756.  Endif ' end chekc vehicle hits
  1757.  Vehicle1=Array.Number ' store vehicle variable
  1758.  Vehicle2=Charges.Number ' store vehicle variable
  1759.  Vehicle3=Index.Number ' store vehicle variable
  1760.  Vehicle4=TreasureRecord.VehicleType ' store vehicle variable
  1761.  Outpt="You enter the "+Outpts+"." ' make vehicle message
  1762.  Call IO.O ' send vehicle message
  1763. End Sub ' end routine to use vehicle
  1764.  
  1765.  Rem * routine to move player and vehicle in a direction or through a portal.
  1766.  
  1767. Sub Ride.Vehicle
  1768.  On Local Error Resume Next ' local error resume
  1769.  If Vehicle3=False Then ' check player using a vehicle
  1770.     Outpt="You're not riding a vehicle!" ' make error message
  1771.     Call IO.O ' send error message
  1772.     Exit Sub ' exit routine
  1773.  Endif ' end check player vehicle
  1774.  User.Command=Parsed.Command1 ' store direction parameter
  1775.  Call Get.Direction(Direction.Number) ' routine verifies direction
  1776.  If Direction.Number Then ' compare direction number
  1777.     Next.Room=RoomRecord.Direct(Direction.Number) ' get room direction
  1778.     If Next.Room=False Then ' check room direction number
  1779.        Outpt="You can't travel in that direction!" ' make error message
  1780.        Call IO.O ' send error message
  1781.        Exit Sub ' exit routine
  1782.     Endif ' end check room direction number
  1783.     Call Vehicle.Type ' routine compares vehicle to room type
  1784.     If Next.Room=False Then ' check room type flag
  1785.        Outpt="You can't travel in that direction!" ' make error message
  1786.        Call IO.O ' send error message
  1787.        Exit Sub ' exit routine
  1788.     Endif ' end compare vehicle to room type
  1789.     Outpts=Direction(Direction.Number) ' store dirction name
  1790.     Outpts=Rtrim$(Outpts) ' trim name
  1791.     Outpts=Lcase$(Outpts) ' lowercase name
  1792.     Outpt="You ride "+Outpts+"!" ' make vehicle message
  1793.     Call IO.O ' send vehicle message
  1794.     Call Enter.Room ' routine moves player to room
  1795.     Exit Sub ' exit routine
  1796.  Endif ' end compare direction number
  1797.  Call Check.Room.Objects ' routine searches room for portal name
  1798.  If Index.Number=False Then ' check room portal number
  1799.     Outpt="You can't travel in that direction!" ' make error message
  1800.     Call IO.O ' send error message
  1801.     Exit Sub ' exit routine
  1802.  Endif ' end check room portal
  1803.  If ObjectRecord.RoomLink=False Then ' check portal goes to room
  1804.     Outpt="You can't travel there!" ' make error message
  1805.     Call IO.O ' send error message
  1806.     Exit Sub ' exit routine
  1807.  Endif ' end check portal to room number
  1808.  If ObjectRecord.JailTrap Then ' check room portal is a jail trap
  1809.     Outpt="Trapped portal!" ' make error message
  1810.     Call IO.O ' send error message
  1811.     Exit Sub ' exit routine
  1812.  Endif ' end check room portal type
  1813.  If ObjectRecord.Closed Then ' check roomportal is locked
  1814.     If Pass.Door=False Then ' check pass door spell in effect
  1815.        Outpt="You can't, it's closed!" ' make entry error message
  1816.        Call IO.O ' send entry error message
  1817.        Exit Sub ' exit routine
  1818.     Endif ' end check pass door spell
  1819.  Endif ' end check room portal locked
  1820.  If ObjectRecord.Relocks Then ' check room portal relocks
  1821.     ObjectRecord.DoorLock=2 ' reset room portal lock
  1822.     ObjectRecord.Closed=True ' reset room portal lock
  1823.     Call Share.Record(ObjectFile,Index.Number) ' write object record
  1824.  Endif ' end check room portal relock
  1825.  Outpt=ObjectRecord.ShortDesc ' store room entry display description
  1826.  If Outpt<>String$(80,0) Then ' check description to nulls
  1827.     Outpt=Rtrim$(Outpt) ' trim description
  1828.     If Outpt<>Nul Then ' compare length of description
  1829.        Call IO.O ' send room entry description message
  1830.     Endif ' end compare description length
  1831.  Endif ' end check description
  1832.  Pass.Door=False ' reset pass door spell
  1833.  Number.Monsters=False ' reset number of monsters in room
  1834.  ' store room number of object portal destination
  1835.  Next.Room=ObjectRecord.RoomLink ' store
  1836.  Call Vehicle.Type ' routine to verify vehicle to room type
  1837.  If Next.Room=False Then ' check verified room number
  1838.     Outpt="You can't travel in that direction!" ' make error message
  1839.     Call IO.O ' send error message
  1840.     Exit Sub ' exit routine
  1841.  Endif ' end check vehicle to room type
  1842.  Outpts=ObjectRecord.ShortName ' store object name
  1843.  Outpts=Rtrim$(Outpts) ' trim name
  1844.  Outpts=Lcase$(Outpts) ' lowercase name
  1845.  Outpt="You ride to the "+Outpts+"!" ' make vehicle message
  1846.  Call IO.O ' send message
  1847.  Call Enter.Room ' routine moves player to room
  1848. End Sub ' end routine to move player and vehicle
  1849.  
  1850.  Rem * routine remove player from vehicle.
  1851.  
  1852. Sub Exit.Vehicle
  1853.  On Local Error Resume Next ' local error resume
  1854.  Call Check.Room.Treasure ' routine finds vehicle name in room
  1855.  If Array.Number=Vehicle1 Then ' compare treasure number to vehicle number
  1856.     Outpts=TreasureRecord.ShortName ' store treasure name
  1857.     Outpts=Rtrim$(Outpts) ' trim name
  1858.     Outpts=Lcase$(Outpts) ' lowercase name
  1859.     Vehicle1=False ' reset vehicle variable
  1860.     Vehicle2=False' reset vehicle variable
  1861.     Vehicle3=False' reset vehicle variable
  1862.     Outpt="You exit the "+Outpts+"!" ' make vehicle message
  1863.  Else ' compare vehicle numbers
  1864.     Outpt="You can't exit that!" ' make error message
  1865.  Endif ' end compare vehicle
  1866.  Call IO.O ' send message
  1867. End Sub ' end routine to exit vehicle
  1868.  
  1869.  Rem * routine verifies vehicle type can enter room type.
  1870.  Rem * output variables:
  1871.  Rem *   Next.Room - false for invalid vehicle to room type.
  1872.  
  1873. Sub Vehicle.Type
  1874.  On Local Error Resume Next ' local error resume
  1875.  If Next.Room<=False Or _
  1876.  Next.Room>Lof(RoomFile)/Len(RoomRecord) Then ' file bounds
  1877.     Next.Room=False ' return next room number
  1878.     Exit Sub ' exit routine
  1879.  Endif ' end check file bounds
  1880.  Call Read.Room.Record(Next.Room) ' get destination room
  1881.  If Vehicle4<>3 Then ' check all terrain vehicle
  1882.     Action.Number=RoomRecord.Action ' store room action number
  1883.     If Action.Number>False And _
  1884.     Action.Number<=Lof(ActionFile)/Len(ActionRecord) Then
  1885.        Call Read.Record(ActionFile,Action.Number) ' read action record
  1886.        If ActionRecord.Attribute2<>Vehicle4 Then ' check vehicle terrain type
  1887.           Next.Room=False ' reset next room number
  1888.        Endif ' end check vehicle terrain type
  1889.     Endif ' end check action number range
  1890.  Endif ' end check all terrain vehicle
  1891.  Call Read.Room.Record(Room) ' restore room record
  1892. End Sub ' end routine to compare vehicle to room type
  1893.  
  1894.  Rem * routine determines if player can train for next level.
  1895.  
  1896. Sub Train
  1897.  On Local Error Resume Next ' local error resume
  1898.  If UserRecord.Level<=False Then ' verify player level
  1899.     Call Train.Stats ' train player
  1900.     Exit Sub ' exit routine
  1901.  Endif ' end verify player level
  1902.  ' calculate experience needed to reach next level
  1903.  Call Experience(Exp.Required#)
  1904.  If UserRecord.Experience<Exp.Required# Then ' compare player experience
  1905.     Outpt="You don't have enough experience to train!" ' train error message
  1906.     Call IO.O ' send train error message
  1907.     Exit Sub ' exit routine
  1908.  Endif ' end compare player experience
  1909.  Call Gold(Gold.Required#) ' routine calculates gold needed for level
  1910.  If UserRecord.Gold<Gold.Required# Then ' compare to player gold
  1911.     Outpt="You don't have enough Gold to train!" ' make train error message
  1912.     Call IO.O ' send train error message
  1913.     Exit Sub ' exit routine
  1914.  Endif ' end compare gold
  1915.  Call Train.Stats ' routine to train for next level
  1916. End Sub ' end train routine
  1917.  
  1918.  Rem * routine teleports player to room.
  1919.  Rem * input variables:
  1920.  Rem *   Parsed.Command1 - parameter containing room number.
  1921.  
  1922. Sub Teleport.User
  1923.  On Local Error Resume Next ' local error resume
  1924.  Next.Room=Int(Val(Parsed.Command1)) ' convert parameter to room number
  1925.  Graphics.Off=True ' reset color
  1926.  Outpt="A Dark Cloud Passes Overhead..." ' make ghod message
  1927.  Call IO.O ' send ghod message
  1928.  Outpt="  A Bolt Of Lightning Strikes..." ' make ghod message
  1929.  Call IO.O ' send ghod message
  1930.  Outpt="The Cloud Disappears..." ' make ghod message
  1931.  Call IO.O ' send ghod message
  1932.  Graphics.Off=False ' reset color
  1933.  Teleported=True ' set teleporting flag
  1934.  Call Enter.Room ' routine moves player to room
  1935. End Sub ' end routine to teleport player
  1936.  
  1937.  Rem * routine moves player to room number in an object.
  1938.  Rem * input variables:
  1939.  Rem *   Parsed.Command1 - contains the object name.
  1940.  
  1941. Sub Enter.Object
  1942.  On Local Error Resume Next ' local error resume
  1943.  User.Command=Parsed.Command1 ' store command parameter
  1944.  Call Get.Direction(Direction.Number) ' compare name to direction to go to
  1945.  If Direction.Number Then ' check direction flag
  1946.     Entry.Command=Last.Command.Number ' store room entry command
  1947.     Call Verify.Room(Direction.Number) ' routine verifies room number
  1948.     If New.Room Then ' check room flag
  1949.        Call Enter.Room ' routine moves player
  1950.     Endif ' end check room flag
  1951.     Exit Sub ' exit routine
  1952.  Endif ' end check direction
  1953.  Call Check.Room.Objects ' compare object name
  1954.  If Index.Number=False Then ' check object name flag
  1955.     Call Check.Room.Treasure ' compare treasure name
  1956.     If Index.Number Then ' check treasure name flag
  1957.        If TreasureRecord.Vehicle Then ' object to move to is vehicle
  1958.           Call Enter.Vehicle ' routine to enter vehicle
  1959.           Exit Sub ' exit routine
  1960.        Endif ' end check object name
  1961.     Endif ' end check treasure flag
  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 object name flag
  1966.  If ObjectRecord.RoomLink=False Then ' check object portal room number
  1967.     Outpt="You can't go there!" ' make error message
  1968.     Call IO.O ' send error message
  1969.     Exit Sub ' exit routine
  1970.  Endif ' end check portal room number
  1971.  Call Restrict(12,Restricted) ' routine checks enter command restricted
  1972.  If Restricted Then ' compare restrict flag
  1973.     Outpt="Your level does not permit entrance to that room!" ' message
  1974.     Call IO.O ' send error message
  1975.     Exit Sub ' exit routine
  1976.  Endif ' end compare restricted room
  1977.  If ObjectRecord.JailTrap Then ' check object is jailed
  1978.     Outpt="Trapped portal!" ' make error message
  1979.     Call IO.O ' send error message
  1980.     Exit Sub ' exit routine
  1981.  Endif ' end check jailed object
  1982.  If ObjectRecord.Closed Then ' check object lock
  1983.     If Pass.Door=False Then ' check pass door spell in effect
  1984.        Outpt="You can't, it's closed!" ' make error message
  1985.        Call IO.O ' send error message
  1986.        Exit Sub ' exit routine
  1987.     Endif ' end check pass door spell
  1988.  Endif ' end check object lock
  1989.  If ObjectRecord.Relocks Then ' check object relocks after entry
  1990.     ObjectRecord.DoorLock=2 ' relock object
  1991.     ObjectRecord.Closed=True ' relock object
  1992.     Call Share.Record(ObjectFile,Index.Number) ' write object record
  1993.  Endif ' end check relocking object
  1994.  Outpt=ObjectRecord.ShortDesc ' store entry description
  1995.  If Outpt<>String$(80,0) Then ' compare description to nulls
  1996.     Outpt=Rtrim$(Outpt) ' trim description
  1997.     If Outpt<>Nul Then ' compare length of description
  1998.        Call IO.O ' send entry description message
  1999.     Endif ' end compare description length
  2000.  Endif ' end compare description
  2001.  If ObjectRecord.Trap Then ' verify object has trap
  2002.     Call Traps ' routine to activate object trap
  2003.     If New.Room Then ' check teleporting trap
  2004.        Exit Sub ' exit routine
  2005.     Endif ' end check teleporting trap
  2006.  Endif ' end verify object trap
  2007.  Pass.Door=False ' reset pass door spell
  2008.  Number.Monsters=False ' set monsters in room to zero
  2009.  Next.Room=ObjectRecord.RoomLink ' store object portal room number
  2010.  Call Enter.Room ' routine to move player to new room
  2011. End Sub ' end routine to move player through an object to room
  2012.  
  2013.  Rem * routine moves player to new room number.
  2014.  Rem * input variables:
  2015.  Rem *   Next.Room - contains new room number to move player to.
  2016.  
  2017. Sub Enter.Room
  2018.  On Local Error Resume Next ' local error resume
  2019.  New.Room=True ' set room entry flag
  2020.  Call Clean.Room ' routine to remove treasure from old room
  2021.  If Next.Room>False And _
  2022.  Next.Room<=Lof(RoomFile)/Len(RoomRecord) Then ' file bounds
  2023.     Swap Room,Next.Room ' store new room, saving old room number
  2024.  Endif ' end check room file bounds
  2025.  Call Status.Line(False) ' routine updates status line
  2026.  Monster.Rate1=False ' reset room monster encounter rate
  2027.  Call Read.Room.Record(Room) ' get the new room record
  2028.  If Vehicle1>False Then ' verify vehicle variable used
  2029.     Move.Vehicle=False ' move vehicle flag
  2030.     Entry.Command=Last.Command.Number ' store command number to enter room
  2031.     ' vehicle entered room
  2032.     If Entry.Command=RideVehicle Or Entry.Command=DriveVehicle Then
  2033.        For Treasure.Number=1 To 20 ' loop through room treasure
  2034.           ' check empty treasure
  2035.           If RoomRecord.Treasure(Treasure.Number)=False Then
  2036.              ' store vehicle inventory
  2037.              RoomRecord.TreCharges(Treasure.Number)=Vehicle2
  2038.              ' store vehicle inventory
  2039.              RoomRecord.Treasure(Treasure.Number)=Vehicle3
  2040.              Call Share.Room.Record(Room) ' write new room record
  2041.              Call Read.Room.Record(Next.Room) ' get previous room
  2042.              RoomRecord.Treasure(Vehicle1)=False ' reset vehicle inventory
  2043.              RoomRecord.TreCharges(Vehicle1)=False ' reset vehicle inventory
  2044.              Call Share.Room.Record(Next.Room) ' write room record
  2045.              Call Read.Room.Record(Room) ' get current room record
  2046.              Move.Vehicle=True ' set move vehicle flag
  2047.              Vehicle1=Treasure.Number ' store new vehicle treasure number
  2048.              Exit For ' exit loop through treasure in room
  2049.           Endif ' end check for empty treasure in room
  2050.        Next ' end loop through room treasure inventory
  2051.     Endif ' end check command used to enter room
  2052.     If Move.Vehicle=False Then ' verify vehicle moves to new room
  2053.        Call Read.Record(TreasureFile,Vehicle3) ' get treasure record
  2054.        Outpts=TreasureRecord.ShortName ' store treasure name
  2055.        Outpts=Rtrim$(Outpts) ' trim name
  2056.        Outpts=Lcase$(Outpts) ' lowercase name
  2057.        Outpt="You exit the "+Outpts+"." ' make vehicle message
  2058.        Call IO.O ' send vehicle message
  2059.        Vehicle1=False ' reset vehicle varible
  2060.        Vehicle2=False ' reset vehicle varible
  2061.        Vehicle3=False ' reset vehicle varible
  2062.        Vehicle4=False ' reset vehicle varible
  2063.     Endif ' end verify vehicle moves
  2064.  Endif ' end verify vehicle used
  2065.  For Array.Index=1 To Number.Monsters ' loop through room monsters
  2066.     ' compare permanent monster
  2067.     If MonsterArray(Array.Index).Permanent=True Then
  2068.        ' store permanent monster file index
  2069.        Monster.Number=MonsterIndex(Array.Index)
  2070.        Call Read.Record(MonsterFile,Monster.Number) ' get monster file record
  2071.        ' store permanent level
  2072.        MonsterRecord.Level=MonsterArray(Array.Index).Level
  2073.        MonsterRecord.Hits=MonsterArray(Array.Index).Hits ' stor permanent hits
  2074.        Call Share.Record(MonsterFile,Monster.Number) ' write monster record
  2075.     Endif ' end compare permanent monster
  2076.  Next ' end loop through room monsters
  2077.  If Room=1 Then ' check safe room
  2078.     Monster.Follow=False ' monsters followed flag
  2079.  Else ' end check safe room
  2080.     If UserRecord.ClassType<Lady Then ' check class number
  2081.        Monster.Follow=True ' monsters followed flag
  2082.     Else ' check class number
  2083.        Monster.Follow=False ' monsters followed flag
  2084.     Endif ' end check class number
  2085.  Endif ' end check safe room
  2086.  Teleported.Flag=Teleported ' store teleporting flag
  2087.  Teleported=False ' reset teleporting flag
  2088.  If Monster.Follow Then ' compare number of monsters followed
  2089.     If Teleported.Flag Then ' compare teleporting flag
  2090.        Outpts=" teleports with you!" ' make follow message
  2091.     Else ' check teleporting flag
  2092.        Outpts=" follows you!" ' make follow message
  2093.     Endif ' end check teleporting flag
  2094.     Monsters.Followed=False ' number of monsters which followed counter
  2095.     For Array.Index=1 To Number.Monsters ' loop through all monsters in room
  2096.        Monster.Followed=False ' set followed flag
  2097.        If MonsterArray(Array.Index).Follow Then ' check monster follows
  2098.           If Teleported.Flag Then ' check player teleported
  2099.              ' random chance monster teleports with player
  2100.              If Rnd<(MonsterArray(Array.Index).Teleport/100) Then
  2101.                 Monster.Followed=True ' set followed flag
  2102.              Endif ' end random chance
  2103.           Else ' check player teleported
  2104.              ' random chance monster follows player
  2105.              If Rnd<(MonsterArray(Array.Index).FollowPercent/100) Then
  2106.                 Monster.Followed=True ' set followed flag
  2107.              Endif ' end random chance
  2108.           Endif ' end check player teleported
  2109.           If Monster.Followed Then ' verify followed flag
  2110.              ' permanent monster
  2111.              If MonsterArray(Array.Index).Permanent=False Then
  2112.                 ' increment number of monsters
  2113.                 Monsters.Followed=Monsters.Followed+1
  2114.                 ' store monster
  2115.                 MonsterArray(Monsters.Followed)=MonsterArray(Array.Index)
  2116.                 ' store monster
  2117.                 MonsterIndex(Monsters.Followed)=MonsterIndex(Array.Index)
  2118.                 ' store monster name
  2119.                 Inpt=MonsterArray(Monsters.Followed).MonsterName
  2120.                 Inpt=Rtrim$(Inpt) ' trim name
  2121.                 Inpt=Lcase$(Inpt) ' lowercase name
  2122.                 Outpt="The "+Inpt+Outpts ' make followed message
  2123.                 Call IO.O ' send message
  2124.              Endif ' end check permanent monster
  2125.           Endif ' end verify followed flag
  2126.        Endif ' end check monster follows
  2127.     Next ' end loop through monsters in room
  2128.  Endif ' end compare number of monsters following
  2129.  Monster.Rate1=False ' reset room monster encounter rate
  2130.  Number.Monsters=Monsters.Followed ' store number of monsters followed
  2131.  Room.Rate=False ' reset room rate counter
  2132.  Rust.Rate=False ' reset room rate counter
  2133.  Steal.Rate=False ' reset room rate counter
  2134.  Teleported=False ' reset teleporting flag
  2135.  Call Check.Next.Room ' routine to get new room record
  2136.  Call Encounter.Permanent ' routine to get permanent monsters
  2137.  Call Display.Room ' routine displays room description
  2138.  Action.Number=RoomRecord.Action ' store room action number
  2139.  ' check file bounds
  2140.  If Action.Number>False And _
  2141.  Action.Number<=Lof(ActionFile)/Len(ActionRecord) Then
  2142.     Call Read.Record(ActionFile,Action.Number) ' read action record
  2143.     If ActionRecord.SpellTrigger=False Then ' check room spell action
  2144.        If ActionRecord.MonsterTrigger=False Then ' check room monster action
  2145.           ' check room monster talk action
  2146.           If ActionRecord.MonsterTalk=False Then
  2147.              Action1$="As you enter the room," ' make action message
  2148.              Action2$="You are hit for" ' make action message
  2149.              Call Actions(Action1$,Action2$) ' routine for room actions
  2150.           Endif ' end check room action
  2151.        Endif ' end check room action
  2152.     Endif ' end check room action
  2153.  Endif ' end check file bounds
  2154. End Sub ' end routine to move player to new room
  2155.  
  2156.  Rem * routine toggles invisible mode.
  2157.  
  2158. Sub Toggle.Invisible
  2159.  On Local Error Resume Next ' local error resume
  2160.  UserRecord.Invisible=Not UserRecord.Invisible ' negate player invisible mode
  2161.  If UserRecord.Invisible Then ' check invisible
  2162.     Outpt="You are invisible!" ' make message
  2163.  Else ' check invisible
  2164.     Outpt="You are no longer invisible!" ' make message
  2165.  Endif ' end check invisible
  2166.  Call IO.O ' send message
  2167. End Sub ' end routine to toggle invisible mode
  2168.  
  2169.  Rem * routine toggles linefeed mode.
  2170.  
  2171. Sub Toggle.Linefeeds
  2172.  On Local Error Resume Next ' local error resume
  2173.  User.Linefeeds=Not User.Linefeeds ' negate player linefeed mode
  2174.  If User.Linefeeds Then ' check linefeeds
  2175.     Outpt="Linefeeds toggled off." ' make message
  2176.  Else ' check linefeeds
  2177.     Outpt="Linefeeds toggled on." ' make message
  2178.  Endif ' end check linefeeds
  2179.  Call IO.O ' send message
  2180. End Sub ' end routine to toggle linefeed mode
  2181.  
  2182.  Rem * routine toggles echo mode.
  2183.  
  2184. Sub Toggle.Echo
  2185.  On Local Error Resume Next ' local error resume
  2186.  User.Echo=Not User.Echo ' negate player echo mode
  2187.  If User.Echo Then ' check echo
  2188.     Outpt="Echo toggled off." ' make message
  2189.  Else ' check echo
  2190.     Outpt="Echo toggled on." ' make message
  2191.  Endif ' end check echo
  2192.  Call IO.O ' send message
  2193. End Sub ' end routine to toggle echo mode
  2194.  
  2195.  Rem * routine toggles word wrap mode.
  2196.  
  2197. Sub Toggle.Wordwrap
  2198.  On Local Error Resume Next ' local error resume
  2199.  User.Wordwrap=Not User.Wordwrap ' negate player word wrap mode
  2200.  If User.Wordwrap Then ' check word wrap
  2201.     Outpt="Word wrap toggled off." ' make message
  2202.  Else ' check word wrap
  2203.     Outpt="Word wrap toggled on." ' make message
  2204.  Endif ' end check word wrap
  2205.  Call IO.O ' send message
  2206. End Sub ' end routine to toggle word wrap mode
  2207.  
  2208. Rem * routine to toggle player Ansi mode.
  2209.  
  2210. Sub Toggle.ANSI
  2211.  On Local Error Resume Next ' local error resume
  2212.  Color.Graphics=Not Color.Graphics ' negate ansi color flag
  2213.  If Color.Graphics Then ' check ansi toggle
  2214.     Outpt="ANSI codes enabled." ' make message
  2215.  Else ' check ansi
  2216.     Outpt="ANSI codes disabled." ' make message
  2217.  Endif ' end check ansi toggle
  2218.  Call IO.O ' send message
  2219. End Sub ' end routine to toggle ansi
  2220.  
  2221.  Rem * routine to toggle brief mode.
  2222.  
  2223. Sub Brief.Mode
  2224.  On Local Error Resume Next ' local error resume
  2225.  If Normal.User Then ' verify non DM
  2226.     If UserRecord.Level<=1 Then ' check player level
  2227.        Outpt="Brief mode not allowed until level two!" ' make error message
  2228.        Call IO.O ' send message
  2229.        Exit Sub ' exit routine
  2230.     Endif ' end check player level
  2231.  Endif ' end check normal player
  2232.  UserRecord.Brief=Not UserRecord.Brief ' negate brief mode
  2233.  If UserRecord.Brief Then ' check brief mode
  2234.     Action.Prompt="Next?" ' store new command prompt
  2235.     Outpt="Brief mode on." ' make message
  2236.  Else ' check brief mode
  2237.     Action.Prompt="Command? " ' store new command prompt
  2238.     Outpt="Brief mode off." ' make message
  2239.  Endif ' end check brief mode
  2240.  Call IO.O ' send message
  2241. End Sub ' end routine to toggle brief mode
  2242.  
  2243.  Rem * routine to change pagelength.
  2244.  
  2245. Sub Change.Pagelength
  2246.  On Local Error Resume Next ' local error resume
  2247.  Outpt="Enter pagelength(1-50)? " ' make input prompt
  2248.  No.Input.Out="24" ' default input
  2249.  Call IO.I ' get user input
  2250.  Page.Length=Int(Val(Inpt)) ' convert input to integer
  2251.  If Page.Length>=1 And Page.Length<=50 Then ' check pagelength bounds
  2252.     User.Pagelength=Page.Length ' store new pagelength
  2253.     Outpt="Pagelength now"+Str$(Page.Length)+" lines." ' make output message
  2254.  Else ' check bounds
  2255.     Outpt="Pagelength not changed." ' make output message
  2256.  Endif ' end check bounds
  2257.  Call IO.O ' send output
  2258. End Sub ' end routine to change pagelength
  2259.  
  2260.  Rem * routine to change linelength.
  2261.  
  2262. Sub Change.Linelength
  2263.  On Local Error Resume Next ' local error resume
  2264.  Outpt="Enter linelength(1-132)? " ' make input prompt
  2265.  No.Input.Out="80" ' default input
  2266.  Call IO.I ' get user input
  2267.  Line.Length=Int(Val(Inpt)) ' convert input to integer
  2268.  If Line.Length>=1 And Line.Length<=132 Then ' check linelength bounds
  2269.     User.Linelength=Line.Length ' store new linelength
  2270.     Outpt="Linelength now"+Str$(Line.Length)+" characters." ' make output message
  2271.  Else ' check bounds
  2272.     Outpt="Linelength not changed." ' make output message
  2273.  Endif ' end check bounds
  2274.  Call IO.O ' send output
  2275. End Sub ' end routine to change linelength
  2276.  
  2277.  Rem * routine to display preferences.
  2278.  
  2279. Sub Display.Prefs
  2280.  On Local Error Resume Next ' local error resume
  2281.  Graphics.Off=True ' reset color
  2282.  If User.Linefeeds Then ' check linefeeds
  2283.     Outpt="Linefeeds toggled off." ' make message
  2284.  Else ' check linefeeds
  2285.     Outpt="Linefeeds toggled on." ' make message
  2286.  Endif ' end check linefeeds
  2287.  Call IO.O ' send message
  2288.  If User.Echo Then ' check echo
  2289.     Outpt="Echo toggled off." ' make message
  2290.  Else ' check echo
  2291.     Outpt="Echo toggled on." ' make message
  2292.  Endif ' end check echo
  2293.  Call IO.O ' send message
  2294.  If User.Wordwrap Then ' check word wrap
  2295.     Outpt="Word wrap toggled off." ' make message
  2296.  Else ' check word wrap
  2297.     Outpt="Word wrap toggled on." ' make message
  2298.  Endif ' end check word wrap
  2299.  Call IO.O ' send message
  2300.  If Color.Graphics Then ' check ansi toggle
  2301.     Outpt="ANSI codes enabled." ' make message
  2302.  Else ' check ansi
  2303.     Outpt="ANSI codes disabled." ' make message
  2304.  Endif ' end check ansi toggle
  2305.  Call IO.O ' send message
  2306.  If UserRecord.Brief Then ' check brief mode
  2307.     Outpt="Brief mode on." ' make message
  2308.  Else ' check brief mode
  2309.     Outpt="Brief mode off." ' make message
  2310.  Endif ' end check brief mode
  2311.  Call IO.O ' send message
  2312.  Outpt="Pagelength now"+Str$(User.Pagelength)+" lines." ' make message
  2313.  Call IO.O ' send output
  2314.  Outpt="Linelength now"+Str$(User.Linelength)+" characters." ' make message
  2315.  Call IO.O ' send output
  2316.  Select Case UserRecord.Sort ' check sorting preference
  2317.  Case -1 ' check value
  2318.     Outpt="Inventory charges sorting on." ' make display message
  2319.  Case 0 ' check value
  2320.     Outpt="Inventory sorting off." ' make display message
  2321.  Case 1 ' check value
  2322.     Outpt="Inventory plus sorting on." ' make display message
  2323.  Case Else ' check sorting
  2324.     Outpt="Inventory sorting off." ' make display message
  2325.  End Select ' end check sorting
  2326.  Call IO.O ' send display message
  2327.  ' check player locked mailbox
  2328.  If UserRecord.Flags And Locked.User Then
  2329.     Outpt="Mailbox locked." ' make locked message
  2330.  Else ' check player locked
  2331.     Outpt="Mailbox unlocked." ' make locked message
  2332.  Endif ' end check player locked flag
  2333.  Call IO.O ' send message
  2334.  Graphics.Off=False ' reset color
  2335. End Sub ' end display preferences routine
  2336.  
  2337.  Rem * routine to have the blacksmith repair some item of treasure.
  2338.  
  2339. Sub Weapons.Shop
  2340.  On Local Error Resume Next ' local error resume
  2341.  Call Check.Inventory.Treasure ' routine to find treasure name
  2342.  If Index.Number=False Then ' check treasure index
  2343.     Outpt="The Blacksmith says: You can't repair that!" ' make error message
  2344.     Call IO.O ' send error message
  2345.     Exit Sub ' exit routine
  2346.  Endif ' end check treasure index
  2347.  If TreasureRecord.Spell Then ' compare treasure is magic
  2348.     Outpt="The Blacksmith says: Can't fix that here!" ' make error message
  2349.     Call IO.O ' send error message
  2350.     Exit Sub ' exit routine
  2351.  Endif ' end compare magical treasure
  2352.  If TreasureRecord.Type=False Then ' check treasure is weapon, shield, armor
  2353.     If TreasureRecord.Plus=False Then ' check weapon plus
  2354.        Outpt="The Blacksmith says: Can't fix that here!" ' make error message
  2355.        Call IO.O ' send error message
  2356.        Exit Sub ' exit routine
  2357.     Endif ' end check weapon plus
  2358.  Endif ' end check treasuer type
  2359.  If UserRecord.Charges(Array.Number)<>False Then ' compare treasure charges
  2360.     Outpt="The Blacksmith says: That isn't broken!" ' make error message
  2361.     Call IO.O ' send error message
  2362.     Exit Sub ' exit routine
  2363.  Endif ' end compare treasure charges
  2364.  Item.Cost#=Int(TreasureRecord.Gold*.5) ' calculate price to repair item
  2365.  If Item.Cost#>UserRecord.Gold Then ' compare price to player gold
  2366.     Outpt="The Blacksmith says: You don't have enough gold!" ' make message
  2367.     Call IO.O ' send message
  2368.     Exit Sub ' exit routine
  2369.  Endif ' end compare price to gold
  2370.  ' make input prompt
  2371.  Outpt="The Blacksmith asks: How about"+Str$(Item.Cost#)+" gold(y/n)? "
  2372.  No.Input.Out="Y" ' default input
  2373.  Call IO.I ' get input
  2374.  If Yes Then ' compare response
  2375.     UserRecord.Gold=UserRecord.Gold-Item.Cost# ' decrement player gold
  2376.     ' store repaired charges
  2377.     UserRecord.Charges(Array.Number)=TreasureRecord.Charges
  2378.     Outpt="The Blacksmith says: There, it's repaired!" ' make message
  2379.  Else ' compare yresponse
  2380.     Outpt="The Blacksmith says: It ain't repaired!" ' make message
  2381.  Endif ' end compare response
  2382.  Call IO.O ' send message
  2383. End Sub ' end routine to repair item
  2384.  
  2385.  Rem * routine to repair an item of magical treasure.
  2386.  
  2387. Sub Alchemist
  2388.  On Local Error Resume Next ' local error resume
  2389.  Call Check.Inventory.Treasure ' routine to find treasure name
  2390.  If Index.Number=False Then ' check treasure index found
  2391.     Outpt="The Alchemist says: That can't be recharged here!" ' make message
  2392.     Call IO.O ' send error message
  2393.     Exit Sub ' exit routine
  2394.  Endif ' end check treasure index
  2395.  Spell.Number=TreasureRecord.Spell ' store treasure spell number
  2396.  ' file bounds
  2397.  If Spell.Number<=False Or Spell.Number>Lof(SpellFile)/Len(SpellRecord) Then
  2398.     Outpt="The Alchemist says: You can't recharge that here!" ' make message
  2399.     Call IO.O ' send error message
  2400.     Exit Sub ' exit routine
  2401.  Endif ' end check file bounds
  2402.  Call Read.Record(SpellFile,Spell.Number) ' get spell record of magic item
  2403.  If SpellRecord.SpellType=Wish Then ' compare to wish item
  2404.     Outpt="The Alchemist says: I won't recharge that item!" ' make message
  2405.     Call IO.O ' send error message
  2406.     Exit Sub ' exit routine
  2407.  Endif ' end cmopare wish item
  2408.  If UserRecord.Charges(Array.Number)<>False Then ' check item charges
  2409.     Outpt="The Alchemist says: That's not discharged!" ' make message
  2410.     Call IO.O ' send error message
  2411.     Exit Sub ' exit routine
  2412.  Endif ' end check charges remaining
  2413.  Item.Cost#=Int(TreasureRecord.Gold*.5) ' calculate price to repair
  2414.  If Item.Cost#>UserRecord.Gold Then ' compare price to player gold
  2415.     Outpt="The Alchemist says: You don't have enough gold!" ' make message
  2416.     Call IO.O ' send error message
  2417.     Exit Sub ' exit routine
  2418.  Endif ' end compare price to gold
  2419.  ' make input prompt
  2420.  Outpt="The Alchemist says: How about"+Str$(Item.Cost#)+" gold(y/n)? "
  2421.  No.Input.Out="Y" ' default input
  2422.  Call IO.I ' get input
  2423.  If Yes Then ' compare response
  2424.     UserRecord.Gold=UserRecord.Gold-Item.Cost# ' decrement player gold
  2425.     ' store item charges
  2426.     UserRecord.Charges(Array.Number)=TreasureRecord.Charges
  2427.     Outpt="The Alchemist chants an invocation!" ' make message
  2428.  Else ' compare response
  2429.     Outpt="The Alchemist says: Didn't repair it!" ' make message
  2430.  Endif ' end compare response
  2431.  Call IO.O ' send message
  2432. End Sub ' end routine to repair magic item
  2433.  
  2434.  Rem * routine to sell treasure item from list.
  2435.  Rem * input variables:
  2436.  Rem *   Parsed.Command1 - number of item to purchase.
  2437.  
  2438. Sub Weapons.Shoppe
  2439.  On Local Error Resume Next ' local error resume
  2440.  Treasure.Number=Int(Val(Parsed.Command1)) ' convert parameter to integer
  2441.  If Treasure.Number<=False Or Treasure.Number>20 Then ' compare integer 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 range
  2446.  If Treasure.Number>Lof(TreasureFile)/Len(TreasureRecord) Then ' check bounds
  2447.     Outpt="The Blacksmith says: You can't buy that!" ' make error message
  2448.     Call IO.O ' send error message
  2449.     Exit Sub ' exit routine
  2450.  Endif ' end compare file bounds
  2451.  Call Read.Record(TreasureFile,Treasure.Number) ' get treasure record
  2452.  If UserRecord.Gold-TreasureRecord.Gold<False Then ' compute price
  2453.     Outpt="The Blacksmith says: You don't have enough gold!" ' make message
  2454.     Call IO.O ' send error message
  2455.     Exit Sub ' exit routine
  2456.  Endif ' end compare price to player gold
  2457.  If Weight+TreasureRecord.Weight>UserRecord.Stats(1)*10 Then ' compute weight
  2458.     Outpt="The Blacksmith says: You can't carry any more!" ' make message
  2459.     Call IO.O ' send error message
  2460.     Exit Sub ' exit routine
  2461.  Endif ' end compare weight of new item
  2462.  Call TreasureCharges(Charges.Amount) ' routine to get treasure charges
  2463.  ' routine to add item to player inventory
  2464.  Call Add.Inventory(Treasure.Number,Charges.Amount,Item.Added)
  2465.  If Item.Added Then ' check return variable for added inventory
  2466.     UserRecord.Gold=UserRecord.Gold-TreasureRecord.Gold ' decrement gold
  2467.     Outpt="The Blacksmith says: There, sold!" ' make message
  2468.  Else ' check inventory added
  2469.     Outpt="The Blacksmith says: You can't carry any more!" ' make message
  2470.  Endif ' end check inventory added flag
  2471.  Call IO.O ' send output message
  2472. End Sub ' end routine to purchase item for sale
  2473.  
  2474.  Rem * routine displays a sorted list of the top ten players, writes the
  2475.  Rem * top ten ranking bulletin file.
  2476.  
  2477. Sub Top.Ten
  2478.  On Local Error Resume Next ' local error resume
  2479.  Call Share.Record(UserFile,User.Index) ' store player user record
  2480.  Max.Users=Lof(UserFile)/Len(UserRecord) ' store length of user file
  2481.  Redim Temp.Array1(1 To Max.Users) As Integer, _
  2482.  Temp.ArrayZ(1 To Max.Users) As Double ' dimension working arrays
  2483.  Close #TempFile ' close work file
  2484.  Open "ranklist.dat" For Output As #TempFile ' open to work file
  2485.  Outpt="The Adventure Door v"+Version$+" Top Ten Player Rankings For "+FNclock$+"."
  2486.  Print #TempFile,Outpt ' write to file
  2487.  Outpt=Nul ' make empty string
  2488.  Print #TempFile,Outpt ' write to file
  2489.  Player.Count=False ' reset player counter
  2490.  For User.Number=1 To Max.Users ' loop through user file
  2491.     Call Read.Record(UserFile,User.Number) ' get next user file record
  2492.     Outpt=UserRecord.CodeName ' store player codename
  2493.     Call Decrypt(Outpt) ' decrypt codename
  2494.     If Left$(Outpt,9)<>Deleted$ Then ' compare deleted user record
  2495.        If UserRecord.Level>False Then ' check user level
  2496.           If (UserRecord.Flags And Locked.User)=False Then ' check locked user
  2497.              Score#=UserRecord.MonstersKilled*UserRecord.Level ' compute score
  2498.              If Score#>False Then ' compare score
  2499.                 ' increment high score player counter
  2500.                 Player.Count=Player.Count+1
  2501.                 Temp.Array1(Player.Count)=User.Number ' store record index
  2502.                 Temp.ArrayZ(Player.Count)=Int(Score#) ' store score
  2503.              Endif ' end compare score
  2504.           Endif ' end check locked user record
  2505.        Endif ' end check user level
  2506.     Endif ' end compare deleted user
  2507.  Next ' end loop through user file
  2508.  ' bubble sort
  2509.  For Sort1=1 To Player.Count ' loop through all items to sort
  2510.     For Sort2=Sort1+1 To Player.Count ' loop through remaining items
  2511.        If Temp.ArrayZ(Sort1)<Temp.ArrayZ(Sort2) Then ' compare scores
  2512.           Swap Temp.Array1(Sort1),Temp.Array1(Sort2) ' swap lower array
  2513.           Swap Temp.ArrayZ(Sort1),Temp.ArrayZ(Sort2) ' swap lower array
  2514.        Endif ' end compare scores
  2515.     Next ' end loop through array
  2516.  Next ' end loop through array
  2517.  If Player.Count>10 Then ' check maximum number of users
  2518.     Player.Count=10 ' reset to top ten
  2519.  Endif ' end check maximum scoring players
  2520.  ' make header
  2521.  Outpt="Username                       Level Classname            Ranking"
  2522.  Print #TempFile,Outpt ' write to file
  2523.  Outpt=String$(65,"-") ' make header line
  2524.  Print #TempFile,Outpt ' write to file
  2525.  For Array.Number=1 To Player.Count ' loop through high scoring players
  2526.     User.Number=Temp.Array1(Array.Number) ' get user file record number
  2527.     Call Read.Record(UserFile,User.Number) ' get user file record
  2528.     Outpt=UserRecord.CodeName ' store player codename
  2529.     Call Decrypt(Outpt) ' decrypt codename
  2530.     Outpt=Lcase$(Outpt) ' lowercase codename
  2531.     Mid$(Outpt,1,1)=Ucase$(Mid$(Outpt,1,1)) ' uppercase first word
  2532.     Outpt=Outpt+Str$(UserRecord.Level) ' add player level
  2533.     Outpt=Outpt+Space$(7-Len(Str$(UserRecord.Level))) ' pad blanks
  2534.     Inpt=UserRecord.ClassName ' store player class name
  2535.     Call Decrypt(Inpt) ' decrypt class name
  2536.     Outpt=Outpt+Inpt ' append class name
  2537.     Outpt=Outpt+Str$(Temp.ArrayZ(Array.Number)) ' add score
  2538.     Print #TempFile,Outpt ' write to file
  2539.  Next ' end loop through top ten players
  2540.  If Player.Count=False Then ' compare number of players
  2541.     Outpt="No users have top scores." ' make score message
  2542.     Print #TempFile,Outpt ' write to file
  2543.  Endif ' end compare number of players
  2544.  Close #TempFile ' close work file
  2545.  Call Read.Record(UserFile,User.Index) ' get user file record
  2546.  User.Line.Length=User.Linelength
  2547.  User.Linelength=80
  2548.  Call Out.File("ranklist.dat")
  2549.  User.Linelength=User.Line.Length
  2550.  Redim Temp.Array1(1) As Integer, _
  2551.  Temp.ArrayZ(1) As Double ' remove temporary arrays
  2552. End Sub ' end routine to display and write top ten list
  2553.  
  2554.  Rem * routine deletes a user record.
  2555.  
  2556. Sub Delete.User
  2557.  On Local Error Resume Next ' local error resume
  2558.  Outpt=Deleted$ ' store deleted string
  2559.  Call Valid(Outpt,30) ' validate string
  2560.  Call Encrypt(Outpt,True) ' encrypt string
  2561.  UserRecord.CodeName=Outpt ' store string in codename
  2562.  Outpt=Deleted$ ' store deleted string
  2563.  Call Valid(Outpt,20) ' validate string
  2564.  Call Encrypt(Outpt,False) ' encrypt string
  2565.  UserRecord.PassWord=Outpt ' store string in password
  2566.  Outpt=Deleted$ ' store deleted string
  2567.  Call Valid(Outpt,20) ' validate string
  2568.  Call Encrypt(Outpt,True) ' encrypt string
  2569.  UserRecord.ClassName=Outpt ' store string in class name
  2570.  UserRecord.ClassType=False ' reset class number
  2571.  UserRecord.Flags=False  ' reset user flags
  2572.  UserRecord.FromHour=False ' reset time restriction
  2573.  UserRecord.FromMin=False ' reset time restriction
  2574.  UserRecord.Level=False ' reset player level
  2575.  UserRecord.MaxCalls=False ' reset maximum calls allowed
  2576.  UserRecord.MonstersKilled=False ' reset score counter
  2577.  UserRecord.ToHour=False ' reset time restriction
  2578.  UserRecord.ToMin=False ' reset time restriction
  2579.  For Array.Index=1 To 20 ' loop through inventory
  2580.     UserRecord.Inv(Array.Index)=False ' reset inventory
  2581.     UserRecord.Charges(Array.Index)=False ' reset inventory
  2582.  Next ' end loop through inventory
  2583.  For Array.Index=1 To 5 ' loop through object inventory
  2584.     UserRecord.Object(Array.Index)=False ' reset inventory
  2585.     UserRecord.ObjCharges(Array.Index)=False ' reset inventory
  2586.  Next ' end loop through inventory
  2587.  Call Clear.Container(0,True) ' clear container record
  2588.  For Array.Index=1 To 3 ' loop through all containers
  2589.     UserRecord.Container(Array.Index)=ContainerRec ' store container record
  2590.  Next ' end loop through containers
  2591. End Sub ' end routine to delete a user record
  2592.