 Rem File: Train2.bas - for Cmd*.bas modules
 Rem $Include: 'dndbbs.inc'
Sub Main.Loop.Update
 On Local Error Goto Err.Trp17
 Call Time.Restriction
 Call Sort.Inventory
 Call Read.Mess
 If Auto.Pickup Then
    Call Take.All.Objects(VarQ)
 Endif
 If Len(Func.Buffer) Then
    Func.Buffer=Nul
 Endif
 If Config2(125)=False Then
    VarQ=1
 Else
    Call Count.Mess2(VarQ)
 Endif
 Room.Rate=Room.Rate+1
 If Room.Rate>=(Room.Health.Rate*VarQ) Then
    Room.Rate=False
    Call Health.Update
    If Config2(19) Then
       Call Team.Health.Update
    Endif
 Endif
 Call New.Stats
 If Room.Rate=False Then
    Call Status.Line(False)
 Endif
 Call Rust.Weapon
 Call Steal.Treasure
 Call Encounter.Monster
 Call Monster.Attack
 Call Monster.Attack.Team
 Call User.Attack

 ' team members hit first monster
 If Config2(19) Then
    If Room.Rate=False Then
       Call Get.Last.Monster(VarX)
       If VarX Then
          Call Team.Hit.Monster
       Endif
    Endif
 Endif
Err.Rsm17:
 Exit Sub
Err.Trp17:
 Resume Err.Rsm17
End Sub

Sub Time.Restriction
 On Local Error Goto Error.Trap7
 ' check user time restriction
 Var1$=Right$("00"+Mid$(Str$(UserRecord.FromHour),2),2)+":"
 Var1$=Var1$+Right$("00"+Mid$(Str$(UserRecord.FromMin),2),2)+"-"
 Var1$=Var1$+Right$("00"+Mid$(Str$(UserRecord.ToHour),2),2)+":"
 Var1$=Var1$+Right$("00"+Mid$(Str$(UserRecord.ToMin),2),2)

 Var1!=Csng(UserRecord.FromHour*3600!+UserRecord.FromMin*60!)
 Var2!=Csng(UserRecord.ToHour*3600!+UserRecord.ToMin*60!)

 Var2=True
 If Var1!>SFalse Or Var2!>SFalse Then
    ' check within range
    Call Check.Time2(Var2,Var1!,Var2!)
    If Var2=False Then
       VarX$="User"
       Goto End.Time
    Endif
 Endif

 ' check guest for open system times
 If GuestLogin Then
    Call OpenSystem.Times(VarQ2)
    If VarQ2=False Then
       Strng="Sorry, system is currently opened only at "+Strng2+"."
       Call IO.O
       Call Hang.Up(7)
       Exit Sub
    Endif
 Endif

 ' check time restrictions
 Var2=True
 If UserRecord.Flags And Special.Char1 Then
    Var1$=Rtrim$(GuestRecord.TownMayorTime)
    If Len(Var1$) Then
       VarX$="Town Mayor"
       Gosub Check.Time
       Goto End.Check
    Endif
 Endif
 If UserRecord.Flags And Special.Char2 Then
    Var1$=Rtrim$(GuestRecord.GovernorTime)
    If Len(Var1$) Then
       VarX$="Governor"
       Gosub Check.Time
       Goto End.Check
    Endif
 Endif
 If UserRecord.Flags And Special.Char3 Then
    Var1$=Rtrim$(GuestRecord.GuildMasterTime)
    If Len(Var1$) Then
       VarX$="GuildMaster"
       Gosub Check.Time
       Goto End.Check
    Endif
 Endif
 If UserRecord.Flags And Special.Char4 Then
    Var1$=Rtrim$(GuestRecord.SysopTime)
    If Len(Var1$) Then
       VarX$="Sysop"
       Gosub Check.Time
       Goto End.Check
    Endif
 Endif
 If UserRecord.ClassType=DM Then
    Var1$=Rtrim$(GuestRecord.DMTime)
    If Len(Var1$) Then
       VarX$="DM"
       Gosub Check.Time
       Goto End.Check
    Endif
 Endif
 If UserRecord.ClassType=AsstDM Then
    Var1$=Rtrim$(GuestRecord.AsstDMTime)
    If Len(Var1$) Then
       VarX$="Asst. DM"
       Gosub Check.Time
       Goto End.Check
    Endif
 Endif
 ' check special time restrictions
 For VarZ=1 To Special.Names
    Var1$=Rtrim$(SpecialUserTime(VarZ))
    If Len(Var1$) Then
       VarX$=Rtrim$(SpecialUserName(VarZ))
       If Ucase$(Rtrim$(UserRecord.CodeName))=VarX$ Then
          Gosub Check.Time
          Exit For
       Endif
    Endif
 Next
' check user is restricted
End.Check:
 If Var2 Then
    Exit Sub
 Endif
End.Time:
 Strng=Chr$(7)
 Call Put.Modem(Strng)
 Strng=Nul
 Call IO.O
 Strng="Time restriction notice."
 Call IO.O
 Strng=VarX$+" time restriction is "+Var1$
 Call IO.O
 Call Write.Record(UserFile,User.Index)
 Call Hang.Up(18)
 Exit Sub

' check time range
Check.Time:
 FromH=Val(Mid$(Var1$,1,2))
 FromM=Val(Mid$(Var1$,4,2))
 ToH=Val(Mid$(Var1$,7,2))
 ToM=Val(Mid$(Var1$,10,2))
 Var1!=Csng(FromH*3600!+FromM*60!)
 Var2!=Csng(ToH*3600!+ToM*60!)
 Call Check.Time2(Var2,Var1!,Var2!)
 Return
Error.Resume7:
 Exit Sub
Error.Trap7:
 Resume Error.Resume7
End Sub

' check current time is within range
Sub Check.Time2(Var2,Var1!,Var2!)
 On Local Error Goto Error.Trap7x
 Var2=False ' default to outside range
 If Var1!>SFalse Or Var2!>SFalse Then
    If Var1!=Var2! Then ' 01:00-01:00
       If Timeit=Var1! Then
          Var2=True
       Endif
    Else
       If Var1!<Var2! Then ' 02:00-04:00
          If Timeit>=Var1! And Timeit<=Var2! Then
             Var2=True
          Endif
       Else ' 22:00-02:00
          If Timeit>=Var1! Or Timeit<=Var2! Then
             Var2=True
          Endif
       Endif
    Endif
 Endif
Error.Resume7x:
 Exit Sub
Error.Trap7x:
 Resume Error.Resume7x
End Sub

Sub OpenSystem.Times(VarQ2)
 On Local Error Goto ErrorTrp6c
 VarQ2=True
 Var1$=Rtrim$(GuestRecord.OpenSystemTime1)
 Var2$=Rtrim$(GuestRecord.OpenSystemTime2)
 If Var1$<>Nul Then
    FromH=Val(Mid$(Var1$,1,2))
    FromM=Val(Mid$(Var1$,4,2))
    ToH=Val(Mid$(Var1$,7,2))
    ToM=Val(Mid$(Var1$,10,2))
    Var1!=Csng(FromH*3600!+FromM*60!)
    Var2!=Csng(ToH*3600!+ToM*60!)
    ' check within range
    Call Check.Time2(Var2,Var1!,Var2!)
    If Var2 Then
       Exit Sub
    Endif
    VarR1=True
 Endif
 If Var2$<>Nul Then
    FromH=Val(Mid$(Var2$,1,2))
    FromM=Val(Mid$(Var2$,4,2))
    ToH=Val(Mid$(Var2$,7,2))
    ToM=Val(Mid$(Var2$,10,2))
    Var1!=Csng(FromH*3600!+FromM*60!)
    Var2!=Csng(ToH*3600!+ToM*60!)
    ' check within range
    Call Check.Time2(Var2,Var1!,Var2!)
    If Var2 Then
       Exit Sub
    Endif
    VarR2=True
 Endif
 ' check either time range
 If VarR1 OR VarR2 Then
    VarQ2=False
    Strng2=Nul
    If Len(Var1$) Then
       Strng2=Var1$
       If Len(Var2$) Then
          Strng2=Strng2+", and "+Var2$
       Endif
    Else
       Strng2=Var2$
    Endif
 Endif
 Exit Sub
ErrorRsm6c:
 Exit Sub
ErrorTrp6c:
 Security.Guard=False
 Resume ErrorRsm6c
End Sub

Sub Sort.Inventory
 On Local Error Goto ErrorTrp33
 Static Sort.Count As Integer
 Sort.Count=Sort.Count+1
 If Sort.Count<=6 Then
    Exit Sub
 Endif
 Sort.Count=False
 If Sorting<=False Then
    Exit Sub
 Endif
 For VarS1!=1! To Lof(MessWorkFile6)/MessWorkRecLen6
    For VarS2!=VarS1!+1! To Lof(MessWorkFile6)/MessWorkRecLen6
       Call Read.Record(MessWorkFile6,VarS1!)
       If MessWorkRecord6.User=User.Index Then
          If Sorting=1 Then
             Var1=MessWorkRecord6.Charges
          Else
             Var1=MessWorkRecord6.Plus
          Endif
          Call Read.Record(MessWorkFile6,VarS2!)
          If MessWorkRecord6.User=User.Index Then
             If Sorting=1 Then
                Var2=MessWorkRecord6.Charges
             Else
                Var2=MessWorkRecord6.Plus
             Endif
             If Var1<Var2 Then
                Call Read.Record(MessWorkFile6,VarS1!)
                VarX!=MessWorkRecord6.Index
                VarY=MessWorkRecord6.User
                VarZ=MessWorkRecord6.Charges
                VarQ=MessWorkRecord6.Plus
                Call Read.Record(MessWorkFile6,VarS2!)
                Call Write.Record(MessWorkFile6,VarS1!)
                MessWorkRecord6.Index=VarX!
                MessWorkRecord6.User=VarY
                MessWorkRecord6.Charges=VarZ
                MessWorkRecord6.Plus=VarQ
                Call Write.Record(MessWorkFile6,VarS2!)
             Endif
          Endif
       Endif
    Next
 Next
ErrorRsm33:
 Exit Sub
ErrorTrp33:
 Resume ErrorRsm33
End Sub

Sub Team.Health.Update
 On Local Error Goto ErrorTrp57
 For VarX!=1! To Lof(MessWorkFile4)/MessWorkRecLen4
    User.Temp=VarX!
    Call Read.Record(MessWorkFile4,User.Temp)
    If MessWorkRecord4.Room=Room Then
       Call Read.Record(UserFile2,MessWorkRecord4.Index)
       Out4=UserRecord2.CodeName
       Out4=Rtrim$(Out4)
       Out4=Lcase$(Out4)
       If Len(Out4) Then
          Mid$(Out4,1,1)=Ucase$(Mid$(Out4,1,1))
       Endif
       Var4=False
       For Var!=1! To Lof(TeamFile)/TeamRecLen
          Call Read.Record(TeamFile,Var!)
          If TeamRecord.Deleted=False Then
             For VarY=1 To MaxTeamMembers
                Var2!=TeamRecord.UserIndex(VarY)
                If Var2!=User.Index Then
                   For VarZ=1 To MaxTeamMembers
                      Var2!=TeamRecord.UserIndex(VarZ)
                      If Var2!=MessWorkRecord4.Index Then
                         If TeamRecord.Activated(VarZ) Then
                            UserRecord2.Fatigue=UserRecord2.Fatigue+Config2(21)
                            UserRecord2.Magic=UserRecord2.Magic+Config2(23)
                            UserRecord2.Psionic=UserRecord2.Psionic+Config2(82)
                            UserRecord2.Vitality=UserRecord2.Vitality+Config2(22)
                            Call New.Stats2(Var5)
                            Call Write.Record(UserFile2,MessWorkRecord4.Index)
                            Var4=True
                            Exit For
                         Endif
                      Endif
                   Next
                   If Var4 Then
                      Exit For
                   Endif
                Endif
             Next
             If Var4 Then
                Exit For
             Endif
          Endif
       Next
    Endif
 Next
ErrorRsm57:
 Exit Sub
ErrorTrp57:
 Resume ErrorRsm57
End Sub

Sub Health.Update
 On Local Error Goto ErrorTrp56
 Graphics.Off=False

 ' lights in room inventory
 Temp5!=RoomRecord.First
 If Temp5! Then
    Do
       Call Read.Record(RoomInvFile,Temp5!)
       Temp6!=MessWorkRecord6.Next
       Temp6=MessWorkRecord6.Charges
       Temp7!=MessWorkRecord6.Index
       If Temp7!>SFalse And Temp7!<=Lof(TreasureFile)/TreasureRecLen Then
          Call Read.Record(TreasureFile,Temp7!)
          If TreasureRecord.LightType Then
             If Temp6<False Then
                Temp6=Temp6+1
                MessWorkRecord6.Charges=Temp6
                Call Write.Record(RoomInvFile,Temp5!)
                If Temp6=False Then
                   If (TreasureRecord.Edible And 4)=4 Then ' smokable
                      Call Delete.List.Node(Temp5!)
                      Call Clear.List.Node
                      Call Write.Record(RoomInvFile,Temp5!)
                   Endif
                   Out2=Rtrim$(TreasureRecord.Prefix1)
                   Out3=Lcase$(Rtrim$(TreasureRecord.ShortName))
                   Strng="The "+Out2+Out3
                   Call Convert.ANSI(True,VarQ,VarR)
                   Carriage.Return=True
                   Graphics.On=True
                   Call IO.O
                   Graphics.On=False
                   Graphics.Off=True
                   Strng=" went out!"
                   Call IO.O
                Endif
             Endif
          Endif
       Endif
       If Temp6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Temp6!
    Loop
 Endif

 ' lights in user inventory
 For Temp5!=1! To Lof(MessWorkFile6)/MessWorkRecLen6
    Call Read.Record(MessWorkFile6,Temp5!)
    If MessWorkRecord6.User=User.Index Then
       Temp6=MessWorkRecord6.Charges
       Temp7!=MessWorkRecord6.Index
       If Temp7!>SFalse And Temp7!<=Lof(TreasureFile)/TreasureRecLen Then
          Call Read.Record(TreasureFile,Temp7!)
          If TreasureRecord.LightType Then
             If Temp6<False Then
                Temp6=Temp6+1
                MessWorkRecord6.Charges=Temp6
                Call Write.Record(MessWorkFile6,Temp5!)
                If Temp6=False Then
                   If (TreasureRecord.Edible And 4)=4 Then ' smokable
                      Call Discard.Item(Temp5!)
                   Endif
                   Out2=Rtrim$(TreasureRecord.Prefix1)
                   Out3=Lcase$(Rtrim$(TreasureRecord.ShortName))
                   Strng="The "+Out2+Out3
                   Call Convert.ANSI(True,VarQ,VarR)
                   Carriage.Return=True
                   Graphics.On=True
                   Call IO.O
                   Graphics.On=False
                   Graphics.Off=True
                   Strng=" went out!"
                   Call IO.O
                Endif
             Endif
          Endif
       Endif
    Endif
 Next

 ' intoxicated
 If Intoxicated>False Then
    Intoxicated=Intoxicated-1
    If Intoxicated<=False Then
       Intoxicated=False
       Strng="Your drunk is over.."
    Else    
       UserRecord.Fatigue=UserRecord.Fatigue-Config2(21)
       If UserRecord.Fatigue<=False Then
          UserRecord.Fatigue=False
          Intoxicated=False
          Strng="Your drunk is over.."
       Else
          Strng="You feel drunk!"
       Endif
    Endif
    Call IO.O
 Endif

 ' increase stats
 UserRecord.Fatigue=UserRecord.Fatigue+Config2(21)
 UserRecord.Magic=UserRecord.Magic+Config2(23)
 UserRecord.Psionic=UserRecord.Psionic+Config2(82)
 If UserRecord.Poison=False Then
    UserRecord.Vitality=UserRecord.Vitality+Config2(22)
 Endif
 Call New.Stats

 ' invisible user
 If Invisible>False Then
    Invisible=Invisible-1
    If Invisible<=False Then
       UserRecord.Invisible=False
       Invisible=False
       Strng="You are no longer invisible!"
       Call IO.O
    Endif
 Endif

 ' poisoned user
 If UserRecord.Poison Then
    UserRecord.Vitality=UserRecord.Vitality-Config2(24)
    Strng="You feel poison running through your veins!"
    Call IO.O
    If UserRecord.Vitality<=False Then
       UserRecord.Vitality=False
       Message1="You finally died from your poisonous wounds!"
       Strng="died from poisonous wounds"
       Call Update.DayFile(Strng,False,1)
       Call Player.Died
    Endif
 Endif
ErrorRsm56:
 Exit Sub
ErrorTrp56:
 Resume ErrorRsm56
End Sub

Sub Rust.Weapon
 On Local Error Goto Err.Trap7
 If Room.Rust.Rate=False Then
    Exit Sub
 Endif
 If Config2(127)=False Then
    VarQ=1
 Else
    Call Count.Mess2(VarQ)
 Endif
 Rust.Rate=Rust.Rate+1
 If Rust.Rate<Room.Rust.Rate*VarQ Then
    Exit Sub
 Endif
 Rust.Rate=False
 For Var1=1 To 9
    Var2!=UserRecord.Weapon(Var1).Index
    If Var2! Then
       Call Read.Record(TreasureFile,Var2!)
       If TreasureRecord.Rustable Then
          If Rnd<(TreasureRecord.RustPercent/100) Then
             ' test antirust rings
             Var2!=UserRecord.Weapon(4).Index
             If Var2! Then
                Call Read.Record(TreasureFile,Var2!)
                If TreasureRecord.RingType=5 Then
                   Call Get.Ring.Hits(True,5)
                   Exit Sub
                Endif
             Endif
             Var2!=UserRecord.Weapon(9).Index
             If Var2! Then
                Call Read.Record(TreasureFile,Var2!)
                If TreasureRecord.RingType=5 Then
                   Call Get.Ring.Hits(False,5)
                   Exit Sub
                Endif
             Endif
             Call Read.Record(TreasureFile,Var2!)
             Strng=Lcase$(Rtrim$(TreasureRecord.ShortName))
             Strng="Your "+Strng+" rusts!"
             Call IO.O
             UserRecord.Weapon(Var1).Index=SFalse
             UserRecord.Weapon(Var1).Charges=False
             UserRecord.Weapon(Var1).Plus=False
          Endif
       Endif
    Endif
 Next
Err.Resume7:
 Exit Sub
Err.Trap7:
 Resume Err.Resume7
End Sub

Sub Steal.Treasure
 On Local Error Goto Err.Trap8
 If Room.Steal.Rate=False Then
    Exit Sub
 Endif
 If Config2(128)=False Then
    VarQ=1
 Else
    Call Count.Mess2(VarQ)
 Endif
 Steal.Rate=Steal.Rate+1
 If Steal.Rate<Room.Steal.Rate*VarQ Then
    Exit Sub
 Endif
 Steal.Rate=False
 For Temp2!=1! To Lof(MessWorkFile6)/MessWorkRecLen6
    Call Read.Record(MessWorkFile6,Temp2!)
    If MessWorkRecord6.User=User.Index Then
       VarZ!=MessWorkRecord6.Index
       If VarZ!>SFalse And VarZ!<=Lof(TreasureFile)/TreasureRecLen Then
          Call Read.Record(TreasureFile,VarZ!)
          If TreasureRecord.Stealable=True Then
             If Rnd<(TreasureRecord.StealPercent/100) Then
                For Temp3!=1! To Lof(MessWorkFile3)/MessWorkRecLen3
                   Call Read.Record(MessWorkFile3,Temp3!)
                   If MessWorkRecord3.Room=Room Then
                      If MessWorkRecord3.Monster.Permanent=False Then
                         ' test antisteal rings
                         Var2!=UserRecord.Weapon(4).Index
                         If Var2! Then
                            Call Read.Record(TreasureFile,Var2!)
                            If TreasureRecord.RingType=6 Then
                               Call Get.Ring.Hits(True,6)
                               Exit Sub
                            Endif
                         Endif
                         Var2!=UserRecord.Weapon(9).Index
                         If Var2! Then
                            Call Read.Record(TreasureFile,Var2!)
                            If TreasureRecord.RingType=6 Then
                               Call Get.Ring.Hits(False,6)
                               Exit Sub
                            Endif
                         Endif
                         Temp5!=Lof(MessWorkFile5)/MessWorkRecLen5+1!
                         MessWorkRecord5.Index=MessWorkRecord3.Index
                         MessWorkRecord5.Inv=MessWorkRecord6.Index
                         MessWorkRecord5.Charges=MessWorkRecord6.Charges
                         MessWorkRecord5.Room=Room
                         MessWorkRecord5.Monster=Temp3!
                         Call Write.Record(MessWorkFile5,Temp5!)
                         Strng=MessWorkRecord3.Monster.MonsterName
                         Strng=Rtrim$(Strng)
                         Call Read.Record(TreasureFile,VarZ!)
                         Out2=Lcase$(Rtrim$(TreasureRecord.ShortName))
                         If Normal.User=False Or Rnd<.8 Then
                            Strng="The "+Strng+" steals your "+Out2+"!"
                            Call IO.O
                         Endif
                         Call Discard(Temp2!,True)
                         Exit Sub
                      Endif
                   Endif
                Next
             Endif
          Endif
       Endif
    Endif
 Next
Err.Resume8:
 Exit Sub
Err.Trap8:
 Resume Err.Resume8
End Sub

Sub Encounter.Monster
 On Local Error Goto ErrorTrap22a
 If Config2(124)=False Then
    VarQ=1
 Else
    Call Count.Mess2(VarQ)
 Endif
 TempX!=RoomRecord.MonClass
 If TempX!>SFalse And TempX!<=MonClass.Max Then
    If Monster.Rate1=MaxInt Then
       Monster.Rate1=1
    Else
       Monster.Rate1=Monster.Rate1+1
    Endif
    If Low.Mem.Use Then
       Call Read.Record(MonClassFile,TempX!)
    Endif
    For Temp1=1 To MaxMonClass
       If Low.Mem.Use=False Then
          Choice=Monster.Class(TempX!,Temp1)
       Else
          Choice=MonClassRecord.Monsters(Temp1)
       Endif
       If Choice>SFalse And Choice<=Lof(MonsterFile)/MonsterRecLen Then
          If Low.Mem.Use=False Then
             Var2=Monster.Rate(TempX!,Temp1)
             Var3=Monster.Percent(TempX!,Temp1)
          Else
             Call Read.Record(MonsterFile,Choice)
             Var2=MonsterRecord.Rate
             Var3=MonsterRecord.RatePercent
          Endif
          If Var2>False Then
             If Monster.Rate1/(Var2*VarQ)=Int(Monster.Rate1/(Var2*VarQ)) Then
                If Rnd<(Var3/100) Then
                   Call Get.Monster2
                Endif
             Endif
          Endif
       Endif
    Next
    Monster.Rate2=Monster.Rate2+1
    If Monster.Rate2>=Room.Monster.Rate*VarQ Then
       Monster.Rate2=False
       Var=Int(Rnd*10+1)
       If Low.Mem.Use Then
          Choice=MonClassRecord.Monsters(Var)
       Else
          Choice=Monster.Class(TempX!,Var)
       Endif
       If Choice>SFalse And Choice<=Lof(MonsterFile)/MonsterRecLen Then
          If Low.Mem.Use=False Then
             Var2=Monster.Rate(TempX!,Var)
          Else
             Call Read.Record(MonsterFile,Choice)
             Var2=MonsterRecord.Rate
          Endif
          If Var2=False Then
             If Rnd<Config1(5) Then
                Call Get.Monster2
             Endif
          Endif
       Endif
    Endif
 Endif
ErrorResume22a:
 Exit Sub
ErrorTrap22a:
 Resume ErrorResume22a
End Sub

Sub Monster.Attack
 On Local Error Goto ErrorTrap11
 Gosub Get.Config1
 Call Safe.Room
 If TempA Then
    Exit Sub
 Endif
 If Config2(129)=False Then
    VarQ=1
 Else
    Call Count.Mess2(VarQ)
 Endif
 Monster.Cycle=Monster.Cycle+1
 If Monster.Cycle>=Room.Monster.Rate*VarQ Then
    Monster.Cycle=False
 Endif
 For Monster.Temp=1! To Lof(MessWorkFile3)/MessWorkRecLen3
    Call Read.Record(MessWorkFile3,Monster.Temp)
    If MessWorkRecord3.Room=Room Then
       Temp6=MessWorkRecord3.Monster.Magic
       If Temp6>=False Then
          If UserRecord.Stats(6)<=1 Then
             Temp6=False
          Endif
          If Temp6>False Then
             Temp6=Temp6-1
          Endif
          If Temp6=False Then
             MessWorkRecord3.Monster.Magic=Room.Monster.Rate
          Else
             MessWorkRecord3.Monster.Magic=Temp6
          Endif
          Call Write.Record(MessWorkFile3,Monster.Temp)
       Endif
       If Temp6<True Then
          Temp6=False
       Else
          If Temp6=False Then
             Out2=Rtrim$(MessWorkRecord3.Monster.MonsterSavingThrow)
             If Len(Out2) Then
                Call Equate(Temp#)
                If Temp#=DTrue Then
                   Temp6=True
                Endif
             Else
                If Int(Rnd*4+1)>3 Then
                   Temp6=True
                Endif
             Endif
          Endif
       Endif
       If MessWorkRecord3.Monster.Magic<=True Then
          If MessWorkRecord3.Monster.Level>=Config2(37) Then
             If Monster.Cycle=False Then
                Temp#=MessWorkRecord3.Monster.Hits+_
                Int(MessWorkRecord3.Monster.Hits*Config1(9))
                If Temp#<Config2(62) Then
                   MessWorkRecord3.Monster.Hits=Temp#
                   Call Write.Record(MessWorkFile3,Monster.Temp)
                Endif
             Endif
          Endif
       Endif
       If Hidden.Player=False And Temp6=False Then
          Out3=MessWorkRecord3.Monster.MonsterName
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          Multiplier=MessWorkRecord3.Monster.Level+1
          If MessWorkRecord3.Monster.LevelDrain Then
             If Rnd<(MessWorkRecord3.Monster.DrainPercent/100) Then
                Strng="The "+Out3+" casts a level drain spell!"
                Call IO.O
                Var2!=UserRecord.Weapon(4).Index
                VarX=False
                If Var2! Then
                   Call Read.Record(TreasureFile,Var2!)
                   If TreasureRecord.RingType=2 Or TreasureRecord.RingType=3 Then
                      VarX=True
                      Call Get.Ring.Hits(True,2)
                   Endif
                Endif
                If VarX=False Then
                   Var2!=UserRecord.Weapon(9).Index
                   VarX=False
                   If Var2! Then
                      Call Read.Record(TreasureFile,Var2!)
                      If TreasureRecord.RingType=2 Or TreasureRecord.RingType=3 Then
                         VarX=True
                         Call Get.Ring.Hits(False,2)
                      Endif
                   Endif
                Endif
                If VarX=False Then
                   UserRecord.Level=UserRecord.Level-1
                   Strng="was drained a level"
                   Call Update.DayFile(Strng,False,3)
                   Call New.Stats
                   Strng="You've been drained a level!"
                   Call IO.O
                   UserRecord.Experience=False
                   If Config2(93)=False Then
                      Call Experience(Temp#)
                      UserRecord.Experience=Temp#
                   Endif
                   If UserRecord.Level<=False Then
                      UserRecord.Level=1
                      Call The.Or.An
                      Message1="You were just killed by "+Prefix1+Out3+"!"
                      Strng="was killed by "+Prefix1+Out3
                      Call Update.DayFile(Strng,False,1)
                      Call Player.Died
                      Exit For
                   Endif
                Endif
             Endif
          Endif
          If MessWorkRecord3.Monster.Poison Then
             If Rnd<(MessWorkRecord3.Monster.PoisonPercent/100) Then
                Strng="The "+Out3+" casts a poison spell!"
                Call IO.O
                VarX=False
                Var2!=UserRecord.Weapon(4).Index
                If Var2! Then
                   Call Read.Record(TreasureFile,Var2!)
                   If TreasureRecord.RingType=1 Or TreasureRecord.RingType=3 Then
                      VarX=True
                      Call Get.Ring.Hits(True,1)
                   Endif
                Endif
                If VarX=False Then
                   Var2!=UserRecord.Weapon(9).Index
                   If Var2! Then
                      Call Read.Record(TreasureFile,Var2!)
                      If TreasureRecord.RingType=1 Or TreasureRecord.RingType=3 Then
                         VarX=True
                         Call Get.Ring.Hits(False,1)
                      Endif
                   Endif
                Endif
                If VarX=False Then
                   UserRecord.Poison=True
                   Strng="You've been poisoned!"
                   Call IO.O
                Endif
             Endif
          Endif
          Magic.Spell=False
          Temp4!=MessWorkRecord3.Monster.Spell
          If Temp4!>SFalse And Temp4!<=Lof(SpellFile)/SpellRecLen Then
             Call Read.Record(SpellFile,Temp4!)
             Magic.Spell=SpellRecord.SpellType
             If Magic.Spell=2 Then
                If Rnd<(MessWorkRecord3.Monster.SpellPercent/100) Then
                   Strng=Rtrim$(SpellRecord.Prefix1)
                   Strng="The "+Out3+" casts a "+Strng+Rtrim$(SpellRecord.SpellName)
                   Call Convert.ANSI(True,VarQ,VarR)
                   Carriage.Return=True
                   Graphics.On=True
                   Call IO.O
                   Graphics.On=False
                   Strng=" spell!"
                   Graphics.Off=True
                   Call IO.O
                   VarX=False
                   Var2!=UserRecord.Weapon(4).Index
                   If Var2! Then
                      Call Read.Record(TreasureFile,Var2!)
                      If TreasureRecord.RingType=3 Then
                         If TreasureRecord.RingSpell=True Then
                            VarX=True
                            Call Get.Ring.Hits(True,3)
                         Else
                            If TreasureRecord.RingSpell=_
                            MessWorkRecord3.Monster.Spell Then
                               VarX=True
                               Call Get.Ring.Hits(True,3)
                            Endif
                         Endif
                      Endif
                   Endif
                   If VarX=False Then
                      Var2!=UserRecord.Weapon(9).Index
                      If Var2! Then
                         Call Read.Record(TreasureFile,Var2!)
                         If TreasureRecord.RingType=3 Then
                            If TreasureRecord.RingSpell=True Then
                               VarX=True
                               Call Get.Ring.Hits(False,3)
                            Else
                               If TreasureRecord.RingSpell=_
                               MessWorkRecord3.Monster.Spell Then
                                  VarX=True
                                  Call Get.Ring.Hits(False,3)
                               Endif
                            Endif
                         Endif
                      Endif
                   Endif
                   If VarX=False Then
                      Multiplier=Int((MessWorkRecord3.Monster.Level+_
                      SpellRecord.Level)/2+.5)
                   Endif
                Endif
             Endif
          Endif
          If MessWorkRecord3.Monster.Poison>False Then
             If Monster.Cycle=False Then
                MessWorkRecord3.Monster.Poison=_
                MessWorkRecord3.Monster.Poison-1
                Call Write.Record(MessWorkFile3,Monster.Temp)
                Strng="Poison drains the "+Out3+"!"
                Call IO.O
                If Len(option1$) Then
                   Out2=option1$
                   Call Equate(Temp#)
                Else
                   Temp#=Int(UserRecord.Level*UserRecord.Stats(7)/MessWorkRecord3.Monster.Level)
                Endif
                MessWorkRecord3.Monster.Hits=MessWorkRecord3.Monster.Hits-Temp#
                Call Write.Record(MessWorkFile3,Monster.Temp)
                If MessWorkRecord3.Monster.Hits<=False Then
                   Strng="The "+Out3+" died from poison!"
                   Call IO.O
                   Call Monster.Died
                   Exit For
                Endif
             Endif
          Endif
          If Config2(63) Then
             Out2=Config3(31)
             Call Equate(Temp#)
          Else
             Temp#=(UserRecord.Stats(4)/10)>_
             (Rnd*10+MessWorkRecord3.Monster.Level*2)
          Endif
          If Temp# Then
             Strng="The "+Out3+" missed!"
             Call IO.O
          Else
             If Previous.Command=True Then
                Multiplier=Multiplier-1
                Previous.Command=False
             Endif
             If Config2(63) Then
                If MessWorkRecord3.Monster.Psionic=False Then
                   Out2=Nul
                   If MessWorkRecord3.Monster.Equation=True Then
                      Out2=Rtrim$(MessWorkRecord3.Monster.MonsterEquate)
                   Endif
                   If Out2=Nul Then
                      Out2=Config3(29) ' attack equation
                   Endif
                Else
                   Out2=Config3(44) ' psionic
                Endif
                Call Equate(Temp#)
             Endif
             If Config2(63)=False Then
                If MessWorkRecord3.Monster.Psionic=False Then
                   Temp#=Int(Rnd*10+_
                   (MessWorkRecord3.Monster.Hits/10-_
                   (Abs(UserRecord.Weapon(1).Plus+_
                        UserRecord.Weapon(2).Plus+_
                        UserRecord.Weapon(3).Plus+_
                        UserRecord.Weapon(5).Plus+_
                        UserRecord.Weapon(6).Plus+_
                        UserRecord.Weapon(10).Plus)/2)+_
                        MessWorkRecord3.Weapon(1).Plus/2)*Multiplier)
                Else
                   Temp#=Rnd*(MessWorkRecord3.Monster.Hits/10-_
                   Psi.Defense.Mode)*MessWorkRecord3.Monster.Psionic
                Endif
             Endif
             If Temp#>MaxInt Then
                Temp2=MaxInt
             Else
                Temp2=Int(Temp#)
             Endif
             Call The.Or.An
             Prefix2=Prefix1
             Prefix1="The "
             Call Get.Hits
             If TempD Then
                Exit For
             Endif
          Endif
       Endif
    Endif
 Next
 Exit Sub
Get.Config1:
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[TRAIN]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Select Case Lcase$(Var2$)
             Case "monster.hit.drain"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option1$=Mid$(Var3$,2)
                      option1$=Left$(option1$,Len(option1$)-1)
                   Endif
                Endif
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrorResume11:
 Exit Sub
ErrorTrap11:
 Resume ErrorResume11
End Sub

Sub Monster.Attack.Team
 On Local Error Goto ErrorTrap11x
 Call Safe.Room
 If TempA Then
    Exit Sub
 Endif
 If Config2(19)=0 Then
    Exit Sub
 Endif
 For User.Temp=1! To Lof(MessWorkFile4)/MessWorkRecLen4
    Call Read.Record(MessWorkFile4,User.Temp)
    If MessWorkRecord4.Room=Room Then
       Call Read.Record(UserFile2,MessWorkRecord4.Index)
       Out4=Lcase$(Rtrim$(UserRecord2.CodeName))
       If Len(Out4) Then
          Mid$(Out4,1,1)=Ucase$(Mid$(Out4,1,1))
       Endif
       Var4=False
       For Var!=1! To Lof(TeamFile)/TeamRecLen
          Call Read.Record(TeamFile,Var!)
          If TeamRecord.Deleted=False Then
             For VarY=1 To MaxTeamMembers
                Var2!=TeamRecord.UserIndex(VarY)
                If Var2!=User.Index Then
                   For VarZ=1 To MaxTeamMembers
                      Var2!=TeamRecord.UserIndex(VarZ)
                      If Var2!=MessWorkRecord4.Index Then
                         If TeamRecord.Activated(VarZ) Then
                            Call Attack.Team.Member
                            Var4=True
                            Exit For
                         Endif
                      Endif
                   Next
                   If Var4 Then
                      Exit For
                   Endif
                Endif
             Next
             If Var4 Then
                Exit For
             Endif
          Endif
       Next
    Endif
 Next
ErrorResume11x:
 Exit Sub
ErrorTrap11x:
 Resume ErrorResume11x
End Sub

' offline user attacks online user.
Sub User.Attack
 On Local Error Goto ErrorTrap10
 If Config2(55)=False Then
    Exit Sub
 Endif
 For User.Temp=1! To Lof(MessWorkFile4)/MessWorkRecLen4
    Call Read.Record(MessWorkFile4,User.Temp)
    Var!=MessWorkRecord4.Index
    Call Search.Mess(Var!)
    If Temp! Then
       Call Remove.User2
    Endif
 Next
 Call Safe.Room
 If TempA Then
    Exit Sub
 Endif
 Gosub Get.Config4
 For User.Temp=1! To Lof(MessWorkFile4)/MessWorkRecLen4
    Call Read.Record(MessWorkFile4,User.Temp)
    If MessWorkRecord4.Room=Room Then
       Call Find.Team.Member(Var4)
       If Var4=False Then
          Call Read.Record(UserFile2,MessWorkRecord4.Index)
          Out3=UserRecord2.CodeName
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
          If Hidden.Player=False Then
             Aligned=MessWorkRecord4.Align1+MessWorkRecord4.Align2
             If Aligned>False Then
                If Len(option1$) Then
                   Out2=option1$
                   Call Equate(Temp#)
                Else
                   Temp#=(UserRecord2.Stats(4)/10)>(Rnd*10+UserRecord2.Level*2)
                Endif
                If Temp# Then
                   Strng=Out3+" missed!"
                   Call IO.O
                Else
                   If Previous.Command=True Then
                      Multiplier=Multiplier-1
                      Previous.Command=False
                   Endif
                   If Len(option2$) Then
                      Out2=option2$
                      Call Equate(Temp#)
                   Else
                      Temp#=Int(Rnd*10+_
                      (MessWorkRecord4.Hits/10-_
                      (Abs(UserRecord2.Weapon(1).Plus+_
                           UserRecord2.Weapon(2).Plus+_
                           UserRecord2.Weapon(3).Plus+_
                           UserRecord2.Weapon(5).Plus+_
                           UserRecord2.Weapon(6).Plus+_
                           UserRecord2.Weapon(10).Plus)/2))*Multiplier)
                   Endif
                   If Temp#>MaxInt Then
                      Temp2=MaxInt
                   Else
                      Temp2=Int(Temp#)
                   Endif
                   Prefix1=Nul
                   Prefix2=Nul
                   Temp3#=UserRecord2.Gold
                   Call Get.Hits
                   If TempD Then
                      Graphics.Off=True
                      Last.Command.Number=False
                      Out3=UserRecord2.CodeName
                      Out3=Rtrim$(Out3)
                      Out3=Lcase$(Out3)
                      Strng="was killed by "+Out3
                      Call Update.DayFile(Strng,False,1)
                      Strng=UserRecord.CodeName
                      Strng=Rtrim$(Strng)
                      Strng=Lcase$(Strng)
                      Out2="You killed "+Strng
                      Temp2!=MessWorkRecord4.Index
                      Call Update.Logfile(Out2,Temp2!)
                      If Temp3#>False Then
                         Call Amount4(Temp3#,Var$)
                         Out2="You found"+Var$+" gold on "+Strng
                         Call Update.LogFile(Out2,Temp2!)
                      Endif
                      Call Read.Record(UserFile2,Temp2!)
                      UserRecord2.PlayersKilled=UserRecord2.PlayersKilled+1
                      UserRecord2.Gold=UserRecord2.Gold+Temp3#
                      Call Write.Record(UserFile2,Temp2!)
                      Exit For
                   Endif
                Endif
             Endif
          Endif
       Endif
    Endif
 Next
 Exit Sub
Get.Config4:
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[TRAIN]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Select Case Lcase$(Var2$)
             Case "offline.user.miss.equation"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option1$=Mid$(Var3$,2)
                      option1$=Left$(option1$,Len(option1$)-1)
                   Endif
                Endif
             Case "offline.user.hits"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option2$=Mid$(Var3$,2)
                      option2$=Left$(option2$,Len(option2$)-1)
                   Endif
                Endif
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrorResume10:
 Exit Sub
ErrorTrap10:
 Resume ErrorResume10
End Sub

Sub Get.Monster2
 On Local Error Goto ErrorTrap23
 Gosub Get.Config9
 Call Safe.Room
 If TempA Then
    Exit Sub
 Endif
 If Choice>SFalse And Choice<=Lof(MonsterFile)/MonsterRecLen Then
    Call Read.Record(MonsterFile,Choice)
    If MonsterRecord.Permanent=False Then
       Number.Appearing=Int(Rnd*MonsterRecord.NumberAppearing)+1
       VarY=False
       If MonsterRecord.Magic=False Then
          Out2=Rtrim$(MonsterRecord.MonsterSurprise)
          If Len(Out2) Then
             Call Equate(Temp#)
             If Temp#=DTrue Then
                VarY=True
             Endif
          Else
             Var1=Int(Rnd*6+1)
             Var2=Int(Rnd*6+1)
             Var3=Int(Rnd*6+1)
             If Var1+Var2+Var3>UserRecord.Stats(2) Then
                VarY=True
             Endif
          Endif
          If UserRecord.Stats(7)<5 Then
             VarY=True
          Endif
       Endif
       Call Get.Monster.Stats2(VarX,VarY)
       If VarX=False Then
          Strng="The new monsters leave."
          Call IO.O
          Exit Sub
       Endif
       VarX$=Rtrim$(MonsterRecord.MonsterName)
       If Number.Appearing>1 Then
          Var$=Rtrim$(MonsterRecord.PluralName)
          If Var$=Nul Then
             Call Plural.Name(VarX$,Var$)
          Endif
       Endif
       Select Case Number.Appearing
       Case Is>10
          Strng=Str$(Number.Appearing)+" "+Var$
       Case Is>1
          Strng=" "+Rtrim$(Numeral(Number.Appearing))+" "+Var$
       Case Else
          If Instr("aeiou",Left$(VarX$,1)) Then
             Strng="an "
          Else
             Strng="a "
          Endif
          Strng=" "+Strng+VarX$
       End Select
       If MonsterRecord.Invisible=False Then
          Strng="You encounter"+Strng+"!"
          Out2=Strng
          Call IO.O
          Call Send.Mess(8,SFalse,Room,Out2)
          If VarY Then
             If Number.Appearing>1 Then
                Strng="The "+Var$+" have surprise!"
             Else
                Strng="The "+VarX$+" has surprise!"
             Endif
             Call IO.O
          Endif
       Else
          If Normal.User=False Then
             Strng="You encounter"+Strng+" [inv]!"
             Call IO.O
          Else
             If Len(option1$) Then
                Out2=option1$
                Call Equate(Temp#)
                If Temp# Then
                   Strng="You sense an encounter!"
                   Call IO.O
                Endif
             Else
                If Rnd>.75 Then
                   Strng="You sense an encounter!"
                   Call IO.O
                Endif
             Endif
          Endif
       Endif
    Endif
 Endif
 Exit Sub
Get.Config9:
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[TRAIN]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Select Case Lcase$(Var2$)
             Case "offline.sense.encounter"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option1$=Mid$(Var3$,2)
                      option1$=Left$(option1$,Len(option1$)-1)
                   Endif
                Endif
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrorResume23:
 Exit Sub
ErrorTrap23:
 Resume ErrorResume23
End Sub

Sub Find.Team.Member(Var4)
 On Local Error Goto ErrorTrap10a
 Var4=False
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    If TeamRecord.Deleted=False Then
       For VarY=1 To MaxTeamMembers
          Var2!=TeamRecord.UserIndex(VarY)
          If Var2!=User.Index Then
             For VarZ=1 To MaxTeamMembers
                Var2!=TeamRecord.UserIndex(VarZ)
                If Var2!=MessWorkRecord4.Index Then
                   If TeamRecord.Activated(VarZ) Then
                      Var4=True
                      Exit Sub
                   Endif
                Endif
             Next
          Endif
       Next
    Endif
 Next
ErrorResume10a:
 Exit Sub
ErrorTrap10a:
 Resume ErrorResume10a
End Sub

Sub Attack.Team.Member
 On Local Error Goto ErrorTrap11z
 Gosub Get.Config6
 For Monster.Temp=1! To Lof(MessWorkFile3)/MessWorkRecLen3
    Call Read.Record(MessWorkFile3,Monster.Temp)
    If MessWorkRecord3.Room=Room Then
       ' check monster round rate
       Temp6=MessWorkRecord3.Monster.Magic
       If Temp6>=False Then
          If UserRecord2.Stats(6)<=1 Then
             Temp6=False
          Endif
          If Temp6>False Then
             Temp6=Temp6-1
          Endif
          ' reset monster round rate
          If Temp6=False Then
             MessWorkRecord3.Monster.Magic=Room.Monster.Rate
          Else
             MessWorkRecord3.Monster.Magic=Temp6
          Endif
          Call Write.Record(MessWorkFile3,Monster.Temp)
       Endif
       ' permanent monster
       If Temp6<True Then
          Temp6=False
       Else
          ' saving throw
          If Temp6=False Then
             Out2=Rtrim$(MessWorkRecord3.Monster.MonsterSavingThrow)
             If Len(Out2) Then
                Call Equate(Temp#)
                If Temp#=DTrue Then
                   Temp6=True
                Endif
             Else
                If Int(Rnd*4+1)>3 Then
                   Temp6=True
                Endif
             Endif
          Endif
       Endif
       ' regenerate hits
       If MessWorkRecord3.Monster.Magic<=True Then
          If MessWorkRecord3.Monster.Level>=Config2(37) Then
             If Monster.Cycle=False Then
                Temp#=MessWorkRecord3.Monster.Hits+_
                Int(MessWorkRecord3.Monster.Hits*Config1(9))
                If Temp#<Config2(62) Then
                   MessWorkRecord3.Monster.Hits=Temp#
                   Call Write.Record(MessWorkFile3,Monster.Temp)
                Endif
             Endif
          Endif
       Endif
       ' monster attacks
       If UserRecord2.Hidden=False And Temp6=False Then
          Out3=MessWorkRecord3.Monster.MonsterName
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          Multiplier2=MessWorkRecord3.Monster.Level+1
          If MessWorkRecord3.Monster.LevelDrain Then
             If Rnd<(MessWorkRecord3.Monster.DrainPercent/100) Then
                Strng="The "+Out3+" casts a level drain spell!"
                Call IO.O
                Var2!=UserRecord2.Weapon(4).Index
                VarX=False
                If Var2! Then
                   Call Read.Record(TreasureFile,Var2!)
                   If TreasureRecord.RingType=2 Or TreasureRecord.RingType=3 Then
                      VarX=True
                      Call Get.Ring.Hits2(True,2)
                   Endif
                Endif
                If VarX=False Then
                   Var2!=UserRecord2.Weapon(9).Index
                   VarX=False
                   If Var2! Then
                      Call Read.Record(TreasureFile,Var2!)
                      If TreasureRecord.RingType=2 Or TreasureRecord.RingType=3 Then
                         VarX=True
                         Call Get.Ring.Hits2(False,2)
                      Endif
                   Endif
                Endif
                If VarX=False Then
                   UserRecord2.Level=UserRecord2.Level-1
                   Call The.Or.An
                   Out2="You were drained a level"
                   Out2=Out2+" in offline team player fighting"
                   Temp2!=MessWorkRecord4.Index
                   Call Update.Logfile(Out2,Temp2!)
                   Strng=Out4+"was drained a level!"
                   Call IO.O
                   Call New.Stats2(Var5)
                   UserRecord2.Experience=False
                   If Config2(93)=False Then
                      Call Experience(Temp#)
                      UserRecord2.Experience=Temp#
                   Endif
                   If UserRecord2.Level<=False Then
                      UserRecord2.Level=1
                      Call The.Or.An
                      Out2="You were killed by "+Prefix1+Out3
                      Out2=Out2+" in offline team player fighting"
                      Temp2!=MessWorkRecord4.Index
                      Call Update.Logfile(Out2,Temp2!)
                      Strng=Out4+" was killed by "+Prefix1+Out3+"!"
                      Call IO.O
                      Call Team.Member.Died
                      Exit For
                   Endif
                Endif
             Endif
          Endif
          If MessWorkRecord3.Monster.Poison Then
             If Rnd<(MessWorkRecord3.Monster.PoisonPercent/100) Then
                Strng="The "+Out3+" casts a poison spell!"
                Call IO.O
                VarX=False
                Var2!=UserRecord2.Weapon(4).Index
                If Var2! Then
                   Call Read.Record(TreasureFile,Var2!)
                   If TreasureRecord.RingType=1 Or TreasureRecord.RingType=3 Then
                      VarX=True
                      Call Get.Ring.Hits2(True,1)
                   Endif
                Endif
                If VarX=False Then
                   Var2!=UserRecord2.Weapon(9).Index
                   If Var2! Then
                      Call Read.Record(TreasureFile,Var2!)
                      If TreasureRecord.RingType=1 Or TreasureRecord.RingType=3 Then
                         VarX=True
                         Call Get.Ring.Hits2(False,1)
                      Endif
                   Endif
                Endif
                If VarX=False Then
                   UserRecord2.Poison=True
                   Strng=Out4+" was poisoned!"
                   Call IO.O
                Endif
             Endif
          Endif
          Magic.Spell=False
          Temp4!=MessWorkRecord3.Monster.Spell
          If Temp4!>SFalse And Temp4!<=Lof(SpellFile)/SpellRecLen Then
             Call Read.Record(SpellFile,Temp4!)
             Magic.Spell=SpellRecord.SpellType
             If Magic.Spell=2 Then
                If Rnd<(MessWorkRecord3.Monster.SpellPercent/100) Then
                   Strng=Rtrim$(SpellRecord.Prefix1)
                   Strng="The "+Out3+" casts a "+Strng+Rtrim$(SpellRecord.SpellName)
                   Call Convert.ANSI(True,VarQ,VarR)
                   Carriage.Return=True
                   Graphics.On=True
                   Call IO.O
                   Graphics.On=False
                   Strng=" spell!"
                   Graphics.Off=True
                   Call IO.O
                   VarX=False
                   Var2!=UserRecord2.Weapon(4).Index
                   If Var2! Then
                      Call Read.Record(TreasureFile,Var2!)
                      If TreasureRecord.RingType=3 Then
                         If TreasureRecord.RingSpell=True Then
                            VarX=True
                            Call Get.Ring.Hits2(True,3)
                         Else
                            If TreasureRecord.RingSpell=_
                            MessWorkRecord3.Monster.Spell Then
                               VarX=True
                               Call Get.Ring.Hits2(True,3)
                            Endif
                         Endif
                      Endif
                   Endif
                   If VarX=False Then
                      Var2!=UserRecord2.Weapon(9).Index
                      If Var2! Then
                         Call Read.Record(TreasureFile,Var2!)
                         If TreasureRecord.RingType=3 Then
                            If TreasureRecord.RingSpell=True Then
                               VarX=True
                               Call Get.Ring.Hits2(False,3)
                            Else
                               If TreasureRecord.RingSpell=_
                               MessWorkRecord3.Monster.Spell Then
                                  VarX=True
                                  Call Get.Ring.Hits2(False,3)
                               Endif
                            Endif
                         Endif
                      Endif
                   Endif
                   If VarX=False Then
                      Multiplier2=Int((MessWorkRecord3.Monster.Level+_
                      SpellRecord.Level)/2+.5)
                   Endif
                Endif
             Endif
          Endif
          If MessWorkRecord3.Monster.Poison>False Then
             If Monster.Cycle=False Then
                MessWorkRecord3.Monster.Poison=_
                MessWorkRecord3.Monster.Poison-1
                Call Write.Record(MessWorkFile3,Monster.Temp)
                Strng="Poison drains the "+Out3+"!"
                Call IO.O
                If Len(option1$) Then
                   Out2=option1$
                   Call Equate(Temp#)
                   Temp=Int(Temp#)
                Else
                   Temp=Int(UserRecord2.Level*UserRecord2.Stats(7)/_
                   MessWorkRecord3.Monster.Level)
                Endif
                MessWorkRecord3.Monster.Hits=_
                MessWorkRecord3.Monster.Hits-Temp
                Call Write.Record(MessWorkFile3,Monster.Temp)
                If MessWorkRecord3.Monster.Hits<=False Then
                   Strng="The "+Out3+" died from poison!"
                   Call IO.O
                   Call Monster.Died
                   Exit For
                Endif
             Endif
          Endif
          If Len(option2$) Then
             Out2=option2$
             Call Equate(Temp#)
          Else
             Temp#=(UserRecord2.Stats(4)/10)>_
             (Rnd*10+MessWorkRecord3.Monster.Level*2)
          Endif
          If Temp# Then
             Strng="The "+Out3+" missed!"
             Call IO.O
          Else
             If Previous.Command=True Then
                Multiplier2=Multiplier2-1
                Previous.Command=False
             Endif
             If MessWorkRecord3.Monster.Psionic=False Then
                If Len(option3$) Then
                   Out2=option3$
                   Call Equate(Temp#)
                Else
                   Temp#=Int(Rnd*10+_
                   (MessWorkRecord3.Monster.Hits/10-_
                   (Abs(UserRecord2.Weapon(1).Plus+_
                        UserRecord2.Weapon(2).Plus+_
                        UserRecord2.Weapon(3).Plus+_
                        UserRecord2.Weapon(5).Plus+_
                        UserRecord2.Weapon(6).Plus+_
                        UserRecord.Weapon(10).Plus)/2)+_
                        MessWorkRecord3.Weapon(1).Plus/2)*Multiplier)
                Endif
             Else
                If Len(option4$) Then
                   Out2=option4$
                   Call Equate(Temp#)
                Else
                   Temp#=Rnd*(MessWorkRecord3.Monster.Hits/10-_
                   Psi.Defense.Mode)*MessWorkRecord3.Monster.Psionic
                Endif
             Endif
             If Temp#>MaxInt Then
                Temp2=MaxInt
             Else
                Temp2=Int(Temp#)
             Endif
             Call The.Or.An
             Prefix2=Prefix1
             Prefix1="The "
             Call Get.Hits2
             If TempD Then
                Exit For
             Endif
          Endif
       Endif
    Endif
 Next
 Exit Sub
Get.Config6:
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[TRAIN]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Select Case Lcase$(Var2$)
             Case "offline.poison.hits"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option1$=Mid$(Var3$,2)
                      option1$=Left$(option1$,Len(option1$)-1)
                   Endif
                Endif
             Case "monster.miss.offline.user"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option2$=Mid$(Var3$,2)
                      option2$=Left$(option2$,Len(option2$)-1)
                   Endif
                Endif
             Case "monster.hits.offline.user"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option3$=Mid$(Var3$,2)
                      option3$=Left$(option3$,Len(option3$)-1)
                   Endif
                Endif
             Case "monster.psi.hits.offline.user"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option4$=Mid$(Var3$,2)
                      option4$=Left$(option4$,Len(option4$)-1)
                   Endif
                Endif
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrorResume11z:
 Exit Sub
ErrorTrap11z:
 Resume ErrorResume11z
End Sub

Sub Get.Hits2
 On Local Error Goto ErrorTrap13x
 Call He.She2(Prefix3$,Prefix4$)
 TempD=False
 Select Case Previous.Command
 Case Lunge
    Temp2=Temp2-UserRecord2.Stats(4)/2-UserRecord2.Stats(1)/2
 Case Dodge
    Temp2=Temp2-(UserRecord2.Stats(4)+UserRecord2.Stats(1))/2
 Case Feint
    Temp2=Temp2-UserRecord2.Stats(4)/2-UserRecord2.Stats(1)
 Case Parry
    Temp2=Temp2-UserRecord2.Stats(4)-UserRecord2.Stats(1)
 Case Thrust
    Temp2=Temp2+UserRecord2.Stats(4)/2+UserRecord2.Stats(1)
 Case Charge
    Temp2=Temp2+UserRecord2.Stats(4)+UserRecord2.Stats(1)
 Case Resist
    Temp2=Temp2-UserRecord2.Stats(1)/2
 Case Beat
    Temp2=Temp2+UserRecord2.Stats(4)/2+UserRecord2.Stats(1)/2
 Case Punch
    Temp2=Temp2+(UserRecord2.Stats(4)+UserRecord2.Stats(1))/2
 Case Bewitch
    Temp2=Int(Temp2/2)-UserRecord2.Beauty
 Case Bewilder
    Temp2=Int(Temp2/2)-UserRecord2.Glamour
 End Select
 Temp2=Int(Temp2)
 Previous.Command=False
 If Temp2<=False Then
    Strng=Prefix1+Out3+" missed "+Out4+"!"
    Call IO.O
    Exit Sub
 Endif
 If Monster.Temp Then
    If Magic.Spell=False Then
       Strng=Prefix1+Out3+" attacks "+Out4
       If MessWorkRecord3.Monster.Psionic Then
          Strng=Strng+" with psionics"
       Endif
       Strng=Strng+"!"
       Call IO.O
    Endif
 Endif
 If UserRecord2.Invisible Then
    Strng=Prefix3$+" invisibility protects "+Prefix4$+"!"
    Call IO.O
    Exit Sub
 Endif
 ' check for invisibility cloak being worn.
 Var2!=UserRecord2.Weapon(8).Index
 If Var2! Then
    Call Read.Record(TreasureFile,Var2!)
    If TreasureRecord.Spell Then
       Var1!=TreasureRecord.Spell
       If Var1!>SFalse And Var1!<=Lof(SpellFile)/SpellRecLen Then
          Call Read.Record(SpellFile,Var1!)
          If SpellRecord.SpellType=Invisibly Then
             Var$=Rtrim$(TreasureRecord.ShortName)
             Var$=Lcase$(Var$)
             Strng=Prefix3$+" "+Var$+" protects "+Prefix4$+"!"
             Call IO.O
             Var3=UserRecord2.Weapon(8).Charges
             If Var3>False Then
                Var3=Var3-1
                UserRecord2.Weapon(8).Charges=Var3
                If Var3<=False Then
                   UserRecord2.Weapon(8).Index=SFalse
                   UserRecord2.Weapon(8).Charges=False
                   UserRecord2.Weapon(8).Plus=False
                   Strng=Prefix3$+" "+Var$+" disintegrates!"
                   Call IO.O
                Endif
             Endif
             Exit Sub
          Endif
       Endif
    Endif
 Endif
 ' check for invisibility rings being worn.
 Var2!=UserRecord2.Weapon(4).Index
 If Var2! Then
    Call Read.Record(TreasureFile,Var2!)
    If TreasureRecord.RingType=3 Then
       Var1!=TreasureRecord.RingSpell
       If Var1!>SFalse And Var1!<=Lof(SpellFile)/SpellRecLen Then
          Call Read.Record(SpellFile,Var1!)
          If SpellRecord.SpellType=Invisibly Then
             Var$=Rtrim$(TreasureRecord.ShortName)
             Var$=Lcase$(Var$)
             Strng=Prefix3$+" "+Var$+" protects "+Prefix4$+"!"
             Call IO.O
             Var3=UserRecord2.Weapon(4).Charges
             If Var3>False Then
                Var3=Var3-1
                UserRecord2.Weapon(4).Charges=Var3
                If Var3<=False Then
                   UserRecord2.Weapon(4).Index=SFalse
                   UserRecord2.Weapon(4).Charges=False
                   UserRecord2.Weapon(4).Plus=False
                   Strng=Prefix3$+" "+Var$+" disintegrates!"
                   Call IO.O
                Endif
             Endif
             Exit Sub
          Endif
       Endif
    Endif
 Endif
 Var2!=UserRecord2.Weapon(9).Index
 If Var2! Then
    Call Read.Record(TreasureFile,Var2!)
    If TreasureRecord.RingType=3 Then
       Var1!=TreasureRecord.RingSpell
       If Var1!>SFalse And Var1!<=Lof(SpellFile)/SpellRecLen Then
          Call Read.Record(SpellFile,Var1!)
          If SpellRecord.SpellType=Invisibly Then
             Var$=Rtrim$(TreasureRecord.ShortName)
             Var$=Lcase$(Var$)
             Strng=Prefix3$+" "+Var$+" protects "+Prefix4$+"!"
             Call IO.O
             Var3=UserRecord2.Weapon(9).Charges
             If Var3>False Then
                Var3=Var3-1
                UserRecord2.Weapon(9).Charges=Var3
                If Var3<=False Then
                   UserRecord2.Weapon(9).Index=SFalse
                   UserRecord2.Weapon(9).Charges=False
                   UserRecord2.Weapon(9).Plus=False
                   Strng=Prefix3$+" "+Var$+" disintegrates!"
                   Call IO.O
                Endif
             Endif
             Exit Sub
          Endif
       Endif
    Endif
 Endif
 ' check for invisibility armor being worn.
 Var2!=UserRecord2.Weapon(1).Index
 If Var2! Then
    Call Read.Record(TreasureFile,Var2!)
    Var1!=TreasureRecord.Spell
    If Var1!>SFalse And Var1!<=Lof(SpellFile)/SpellRecLen Then
       Call Read.Record(SpellFile,Var1!)
       If SpellRecord.SpellType=Invisibly Then
          Var$=Rtrim$(TreasureRecord.ShortName)
          Var$=Lcase$(Var$)
          Strng=Prefix3$+" "+Var$+" protects "+Prefix4$+"!"
          Call IO.O
          Var2=UserRecord2.Weapon(1).Charges
          Var2=Var2-1
          UserRecord2.Weapon(1).Charges=Var2
          If Var2<=False Then
             Strng=Prefix3$+" "+Var$+" crumbles!"
             Call IO.O
             Call Add.Inventory2(Var2!,Var2)
             UserRecord2.Weapon(1).Index=SFalse
             UserRecord2.Weapon(1).Plus=False
             Call Discard2(Temp0!,False)
          Endif
          Exit Sub
       Endif
    Endif
 Endif
 Strng=Prefix1+Out3+" hits "+Out4+" for"
 Call Hit.Player2(Temp2)
 If UserRecord2.Vitality=False Then
    TempD=True
    Exit Sub
 Endif
 Call Get.Weapon.Hits2
ErrorResume13x:
 Exit Sub
ErrorTrap13x:
 Resume ErrorResume13x
End Sub

Sub Get.Weapon.Hits2
 On Local Error Goto ErrorTrap14x
 Call He.She2(Prefix3$,Prefix4$)
 For VarX=1 To 6
    Select Case VarX
    Case 1, 2, 3, 5, 6
       Var1!=UserRecord2.Weapon(VarX).Index
       If Var1! Then
          Var2=UserRecord2.Weapon(VarX).Charges
          Var2=Var2-1
          UserRecord2.Weapon(VarX).Charges=Var2
          If Var2<=False Then
             Call Read.Record(TreasureFile,Var1!)
             Out2=TreasureRecord.ShortName
             Out2=Rtrim$(Out2)
             Out2=Lcase$(Out2)
             Select Case VarX
             Case 1
                Strng="crumbles"
             Case 2
                Strng="falls apart"
             Case 3
                Strng="cracks"
             Case 5
                Strng="breaks in half"
             Case 6
                Strng="falls off"
             End Select
             Strng=Prefix3$+" "+Out2+" "+Strng+"!"
             Call IO.O
             Call Add.Inventory2(Var1!,Var2)
             UserRecord2.Weapon(VarX).Index=SFalse
             UserRecord2.Weapon(VarX).Plus=False
             Call Discard2(Temp0!,False)
          Endif
       Endif
    End Select
 Next
ErrorResume14x:
 Exit Sub
ErrorTrap14x:
 Resume ErrorResume14x
End Sub

Sub Get.Ring.Hits2(Var1,Var2)
 On Local Error Goto ErrorTrap15b
 If Var1 Then
    Var=UserRecord2.Weapon(4).Charges
 Else
    Var=UserRecord2.Weapon(9).Charges
 Endif
 Select Case Var2
 Case 1, 2
    Var=Var-MessWorkRecord3.Monster.Level
 Case 3
    Var=Var-SpellRecord.Level
 Case 4 To 9
    Var=Var-1
 End Select
 If Var1 Then
    UserRecord2.Weapon(4).Charges=Var
 Else
    UserRecord2.Weapon(9).Charges=Var
 Endif
 If Var1 Then
    Strng=Out4+"'s left ring absorbs the "
 Else
    Strng=Out4+"'s right ring absorbs the "
 Endif
 Select Case Var2
 Case 1
    Strng=Strng+"poison spell!"
 Case 2
    Strng=Strng+"level drain!"
 Case 3
    Strng=Strng+"spell!"
 Case 4
    Strng=Strng+"trap spell!"
 Case 5
    Strng=Strng+"rusting spell!"
 Case 6
    Strng=Strng+"stealing spell!"
 Case 7
    Strng=Strng+"inventory damage spell!"
 Case 8
    Strng=Strng+"fumble spell!"
 Case 9
    Strng=Strng+"teleport spell!"
 End Select
 Call IO.O
 If Var<=False Then
    If Var1 Then
       Strng=Out4+"'s left ring disintegrated!"
       UserRecord2.Weapon(4).Index=SFalse
       UserRecord2.Weapon(4).Charges=False
       UserRecord2.Weapon(4).Plus=False
    Else
       Strng=Out4+"'s right ring disintegrated!"
       UserRecord2.Weapon(9).Index=SFalse
       UserRecord2.Weapon(9).Charges=False
       UserRecord2.Weapon(9).Plus=False
    Endif
    Call IO.O
    Call Write.Record(UserFile2,MessWorkRecord4.Index)
 Endif
ErrorResume15b:
 Exit Sub
ErrorTrap15b:
 Resume ErrorResume15b
End Sub

Sub Hit.Player2(Var)
 On Local Error Goto ErrorTrap16x
 If Var>False Then
    If UserRecord2.Fatigue-Var>=False Then
       UserRecord2.Fatigue=UserRecord2.Fatigue-Var
       Strng=Strng+Str$(Var)+" fatigue points!"
       Call IO.O
       Exit Sub
    Endif
    Var=Var-UserRecord2.Fatigue
    If UserRecord2.Fatigue>False Then
       Strng=Strng+Str$(UserRecord2.Fatigue)+" fatigue and"
    Endif
    UserRecord2.Fatigue=False
 Endif
 Var1=Abs(Var)
 If Var1>False Then
    Strng=Strng+Str$(Var1)+" vitality points!"
    Call IO.O
    If UserRecord2.Vitality-Var1<=False Then
       UserRecord2.Vitality=False
       Call The.Or.An
       Out2="You were killed by "+Prefix1+Out3
       Out2=Out2+" in offline team player fighting"
       Temp2!=MessWorkRecord4.Index
       Call Update.Logfile(Out2,Temp2!)
       Strng=Out4+" was killed by "+Prefix1+Out3+"!"
       Call IO.O
       Call Team.Member.Died
       Exit Sub
    Endif
    UserRecord2.Vitality=UserRecord2.Vitality-Var1
 Endif
ErrorResume16x:
 Exit Sub
ErrorTrap16x:
 Resume ErrorResume16x
End Sub

Sub Add.Inventory2(Var1!,Var2)
 On Local Error Goto ErrorTrp29x
 VarQ1!=MessWorkRecord6.Desc(1)
 VarQ2!=MessWorkRecord6.Desc(2)
 VarQ3!=MessWorkRecord6.Desc(3)
 VarQ4!=MessWorkRecord6.Desc(4)
' Call Pack.Inventory(Var!)
 Var!=Lof(MessWorkFile6)/MessWorkRecLen6+1!
 Temp0!=Var!
 If Var!=SFalse Then
    Exit Sub
 Endif
 MessWorkRecord6.User=MessWorkRecord4.Index
 MessWorkRecord6.Room=SFalse
 MessWorkRecord6.Index=Var1!
 MessWorkRecord6.Charges=Var2
 MessWorkRecord6.Plus=False
 MessWorkRecord6.Prev=SFalse
 MessWorkRecord6.Next=SFalse
 If Var1!>SFalse Then
    VarX=TreasureRecord.Plus
    If TreasureRecord.Spell Then
       Call Read.Record(SpellFile,TreasureRecord.Spell)
       VarX=SpellRecord.Level
    Endif
    MessWorkRecord6.Plus=VarX
 Endif
 MessWorkRecord6.Desc(1)=VarQ1!
 MessWorkRecord6.Desc(2)=VarQ2!
 MessWorkRecord6.Desc(3)=VarQ3!
 MessWorkRecord6.Desc(4)=VarQ4!
 Call Write.Record(MessWorkFile6,Var!)
ErrorRsm29x:
 Exit Sub
ErrorTrp29x:
 Resume ErrorRsm29x
End Sub

Sub Discard2(Var1!,Var2)
 On Local Error Goto ErrorTrp28x
 Call Read.Record(MessWorkFile6,Var1!)
 VarA!=MessWorkRecord6.Index
 VarB=MessWorkRecord6.Charges
 MessWorkRecord6.User=SFalse
 Call Write.Record(MessWorkFile6,Var1!)
 If Var2=False Then
    Call Drop.Inventory(VarA!,VarB)
 Endif
ErrorRsm28x:
 Exit Sub
ErrorTrp28x:
 Resume ErrorRsm28x
End Sub

Sub Discard.Item(Var1!)
 On Local Error Goto ErrorTrp28x2
 Call Read.Record(MessWorkFile6,Var1!)
 VarA!=MessWorkRecord6.Index
 VarB=MessWorkRecord6.Charges
 Call Read.Record(TreasureFile,VarA!)
 Weight=Weight-TreasureRecord.Weight
 If Weight<False Then
    Weight=False
 Endif
 MessWorkRecord6.User=SFalse
 MessWorkRecord6.Room=SFalse
 MessWorkRecord6.Index=SFalse
 MessWorkRecord6.Charges=False
 MessWorkRecord6.Plus=False
 MessWorkRecord6.Prev=SFalse
 MessWorkRecord6.Next=SFalse
 Call Write.Record(MessWorkFile6,Var1!)
ErrorRsm28x2:
 Exit Sub
ErrorTrp28x2:
 Resume ErrorRsm28x2
End Sub

Sub He.She2(Var1$,Var2$)
 On Local Error Goto ErrorTrp13x2
 Var1$="His" ' male
 Var2$="him"
 If UserRecord2.ClassType=Lady Then
    Var1$="Her" ' female
    Var2$="her"
 Endif
ErrorRsm13x2:
 Exit Sub
ErrorTrp13x2:
 Resume ErrorRsm13x2
End Sub

Sub Team.Member.Died
 On Local Error Goto ErrorTrap11z1
 Gosub Get.Config2
 MessWorkRecord4.Room=Int(Val(Config3(24))+.5)
 Call Write.Record(MessWorkFile4,User.Temp)
 UserRecord2.Room=Int(Val(Config3(24))+.5)
 Call Write.Record(UserFile2,MessWorkRecord4.Index)
 UserRecord2.Poison=False
 Call Is.Normal(Normal.User2)
 If Normal.User2 Then
    Exit Sub
 Endif
 Temp4=UserRecord2.Stats(5)
 If Temp4>1 Then
    UserRecord2.Stats(5)=Temp4-1
    Out3=Stat(5)
    Out3=Rtrim$(Out3)
    Out3=Lcase$(Out3)
    Out2="You lost one "+Out3+" point in offline team player fighting"
    Gosub StoreMess
 Endif
 Temp4=UserRecord2.Stats(6)
 If Temp4>1 Then
    UserRecord2.Stats(6)=Temp4-1
    Out3=Stat(6)
    Out3=Rtrim$(Out3)
    Out3=Lcase$(Out3)
    Out2="You lost one "+Out3+" point in offline team player fighting"
    Gosub StoreMess
 Endif
 If Len(option1$) Then
    Out2=option1$
    Call Equate(Temp#)
 Else
    Temp#=Rnd>.5
 Endif
 If Temp# Then
    If Len(option2$) Then
       Out2=option2$
       Call Equate(Temp#)
    Else
       Temp#=Int(Rnd*4+1)
    Endif
    Temp2=Int(Temp#)
    If Temp2>=1 And Temp2<=7 Then
       Temp4=UserRecord2.Stats(Temp2)
       If Temp4>1 Then
          UserRecord2.Stats(Temp2)=Temp4-1
          Out3=Stat(Temp2)
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          Out2="You lost one "+Out3+" point in offline team player fighting"
          Gosub StoreMess
       Endif
    Endif
 Endif
 UserRecord2.Gold=Config2(32)
 UserRecord2.Poison=False
 Call Write.Record(UserFile2,MessWorkRecord4.Index)
 UserRecord2.Fatigue=False
 UserRecord2.Vitality=False
 UserRecord2.Magic=False
 UserRecord2.Psionic=False
 Out2=Out4+" has just died!"
 Call Send.Mess(8,SFalse,Room,Out2)
 If Len(option3$) Then
    Out2=option3$
    Call Equate(Temp#)
 Else
    Temp#=(Int(Rnd*10+10)+UserRecord2.Stats(5)/2)>20
 Endif
 If Temp#=DFalse Then
    Out2="Your constitution roll failed in offline team player fighting"
    Gosub StoreMess
    Strng=Nul
    Temp1=UserRecord2.Level
    If Temp1>=1 Then
       Temp1=Int(Temp1/2+.5)
    Else
       Temp1=False
    Endif
    Select Case Temp1
    Case 1 To 10
       Strng="lost "+Rtrim$(Numeral(Temp1))
    Case Is>10
       Strng="lost"+Str$(Temp1)
    End Select
    Select Case Temp1
    Case 1
       Strng=Strng+" level"
    Case Is>1
       Strng=Strng+" levels"
    End Select
    If Len(Strng) Then
       Out2="You "+Lcase$(Strng)+" in offline team player fighting"
       Gosub StoreMess
    Endif
    UserRecord2.Level=Int(UserRecord2.Level/2)
    UserRecord2.TimesDied=UserRecord2.TimesDied+1#
    Out2="You were not resurrected in offline team player fighting"
    Gosub StoreMess
 Else
    UserRecord2.Level=UserRecord2.Level-1
    UserRecord2.TimesDied=UserRecord2.TimesDied+1#
    Out2="You lost one level in offline team player fighting"
    Gosub StoreMess
    Out2="You were resurrected in offline team player fighting"
    Gosub StoreMess
    If UserRecord2.Stats(5)<=1 Then
       Out2="Your constitution failed in offline team player fighting"
       Gosub StoreMess
       UserRecord2.Level=1
    Endif
 Endif
 Call Zero.Stats2
 Exit Sub
StoreMess:
 Call Update.Logfile(Out2,MessWorkRecord4.Index)
 Return
Get.Config2:
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[TRAIN]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Select Case Lcase$(Var2$)
             Case "team.lose.point.equation"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option1$=Mid$(Var3$,2)
                      option1$=Left$(option1$,Len(option1$)-1)
                   Endif
                Endif
             Case "team.lose.point"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option2$=Mid$(Var3$,2)
                      option2$=Left$(option2$,Len(option2$)-1)
                   Endif
                Endif
             Case "team.roll.lost"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option3$=Mid$(Var3$,2)
                      option3$=Left$(option3$,Len(option3$)-1)
                   Endif
                Endif
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrorResume11z1:
 Exit Sub
ErrorTrap11z1:
 Resume ErrorResume11z1
End Sub

Sub Zero.Stats2
 On Local Error Goto ErrorTrap26z
 UserRecord2.Experience=False
 If Config2(93)=False Then
    Call Experience2(Temp#)
    UserRecord2.Experience=Temp#
 Endif
 Call New.Stats2(Var5)
 UserRecord2.Flags=UserRecord2.Flags And Not Wished
 UserRecord2.Flags=UserRecord2.Flags And Not Rerolled
 UserRecord2.Flags=UserRecord2.Flags And Not Alignmented
 Call Write.Record(UserFile2,MessWorkRecord4.Index)
ErrorResume26z:
 Exit Sub
ErrorTrap26z:
 Resume ErrorResume26z
End Sub

Sub Is.Normal(Var5)
 On Local Error Goto ErrorTrp17z2
 Var5=False
 If UserRecord2.ClassType=AsstDM Or UserRecord2.Level>999 Then
    Var1=True
 Else
    Var1=False
 Endif
 If UserRecord2.ClassType=DM Or UserRecord2.Level>9999 Then
    Var2=True
 Else
    Var2=False
 Endif
 If UserRecord2.Flags And Special.Char4 Then
    Var3=True
 Else
    Var3=False
 Endif
 If Var1 Or Var2 Or Var3 Then
    Var5=True
 Endif
ErrorRsm17z2:
 Exit Sub
ErrorTrp17z2:
 Resume ErrorRsm17z2
End Sub

Sub Restrict2(Var1)
 On Local Error Goto ErrTrap7
 TempB=False
 If Sysop Then
    Exit Sub
 Endif
 Var!=RoomRecord.Action
 If Var!>SFalse And Var!<=Lof(ActionFile)/ActionRecLen Then
    Call Read.Record(ActionFile,Var!)
    If ActionRecord.Level>False Then
       If UserRecord.Level<ActionRecord.Level Then
          If ActionRecord.Restrictions And 2^Var1 Then
             TempB=True
          Endif
       Endif
    Endif
    If ActionRecord.Level<False Then
       If UserRecord.Level>Abs(ActionRecord.Level) Then
          If ActionRecord.Restrictions And 2^Var1 Then
             TempB=True
          Endif
       Endif
    Endif
 Endif
ErrResume7:
 Exit Sub
ErrTrap7:
 Resume ErrResume7
End Sub

Sub Count.Mess2(Var)
 On Local Error Goto ErrorTrap17
 VarX=False
 For VarZ=False To MaxNodes
    Call Read.Message.Record(MessWorkFile1,VarZ+1)
    Strng=Rtrim$(MessWorkRecord1.UserName)
    Call Valid.Name(Strng)
    If TempA Then
       If MessWorkRecord1.RoomNumber=Room Then
          VarX=VarX+1
       Endif
    Endif
 Next
 Var=VarX
ErrorResume17:
 Exit Sub
ErrorTrap17:
 Resume ErrorResume17
End Sub

Sub Remove.User2
 On Local Error Goto ErrorTrap9
 Call Read.Record(MessWorkFile4,User.Temp)
 MessWorkRecord4.Room=SFalse
 Call Write.Record(MessWorkFile4,User.Temp)
 User.Attacked=False
ErrorResume9:
 Exit Sub
ErrorTrap9:
 Resume ErrorResume9
End Sub

Sub Enter.New.Room
 On Local Error Goto Err.Trap10
 Call Check.Room.Number(Room)
 Monster.Rate1=False
 Call Encounter.Permanent
 If Config2(55) Then ' offline user fights
    Call Encounter.Offline.User
 Endif
 If Node>False Then
    Out2=UserRecord.CodeName
    Out2=Rtrim$(Out2)
    Out2=Lcase$(Out2)
    Out2=Out2+" just entered the room."
    Call Send.Mess(8,SFalse,Room,Out2)
 Endif
 Call Reset.Room.Rates
 If Room.Toggle Then
    Call Display.Sorted.Room
 Else
    Call Show.Room
    Call Display.Users(True)
    Call Display.Users(False)
 Endif
 New.Room=False
Err.Resume10:
 Exit Sub
Err.Trap10:
 Resume Err.Resume10
End Sub

Sub Encounter.Permanent
 On Local Error Goto ErrorTrap19
 Var1$=","+Mid$(Str$(Room),2)+","
 For Choice=1! To NonPlayer.Max
    If Low.Mem.Use=False Then
       Var2$=","+Rtrim$(Nonplayer.Rooms(Choice))+","
    Else
       Call Read.Record(NonPlayerFile,Choice)
       Var2$=","+Rtrim$(MonsterRecord.PluralName)+","
    Endif
    If Instr(Var2$,Var1$) Then
       Gosub Check.In.Room
       If TempA=False Then
          For Temp5!=1! To Lof(MessWorkFile3)/MessWorkRecLen3
             Call Read.Record(MessWorkFile3,Temp5!)
             If MessWorkRecord3.IsAutomaton=False Then
                If MessWorkRecord3.Room=SFalse Then
                   Exit For
                Endif
             Endif
          Next
          Call Read.Record(NonPlayerFile,Choice)
          MessWorkRecord3.Index=Choice
          MessWorkRecord3.Monster=MonsterRecord
          MessWorkRecord3.Monster.Magic=True
          MessWorkRecord3.Monster.Permanent=-2
          MessWorkRecord3.Room=Room
          MessWorkRecord3.AutoMode=False
          Call Write.Record(MessWorkFile3,Temp5!)
          Call Add.Monster.Inventory2(True)
       Endif
    Endif
 Next
 Var!=RoomRecord.MonClass
 If Var!>SFalse And Var!<=MonClass.Max Then
    If Low.Mem.Use Then
       Call Read.Record(MonClassFile,Var!)
    Endif
    For Temp1=1 To MaxMonClass
       If Low.Mem.Use=False Then
          Choice=Monster.Class(Var!,Temp1)
       Else
          Choice=MonClassRecord.Monsters(Temp1)
       Endif
       If Choice>SFalse And Choice<=Lof(MonsterFile)/MonsterRecLen Then
          Gosub Check.In.Room
          If TempA=False Then
             Call Read.Record(MonsterFile,Choice)
             If MonsterRecord.Permanent=True Then
                Number.Appearing=1
                Call Get.Monster.Stats2(VarX,1)
             Endif
          Endif
       Endif
    Next
 Endif
 Exit Sub

Check.In.Room:
 TempA=False
 For Temp5!=1! To Lof(MessWorkFile3)/MessWorkRecLen3
    Call Read.Record(MessWorkFile3,Temp5!)
    If MessWorkRecord3.Index=Choice Then
       If MessWorkRecord3.Room=Room Then
          TempA=True
          Exit For
       Endif
    Endif
 Next
 Return
ErrorResume19:
 Exit Sub
ErrorTrap19:
 Resume ErrorResume19
End Sub

Sub Encounter.Offline.User
 On Local Error Goto ErrorTrap18
 Call Safe.Room
 If TempA Then
    Exit Sub
 Endif
 Gosub Get.Config5
 For TempX!=1! To Lof(UserFile2)/UserRecLen
    If TempX!<>User.Index Then
       Call Read.Record(UserFile2,TempX!)
       If UserRecord2.Room=Room Then
          If UserRecord2.Level>False Then
             Call Search.Mess(TempX!)
             If Temp!=SFalse Then
                Out2=UserRecord2.CodeName
                Out2=Left$(Out2,9)
                If Out2<>Deleted$ Then
                   TempB=False
                   For Temp5!=1! To Lof(MessWorkFile4)/MessWorkRecLen4
                      Call Read.Record(MessWorkFile4,Temp5!)
                      If MessWorkRecord4.Index=TempX! Then
                         If MessWorkRecord4.Room=Room Then
                            TempB=True
                            Exit For
                         Endif
                      Endif
                   Next
                   If TempB=False Then
                      For Temp5!=1! To Lof(MessWorkFile4)/MessWorkRecLen4
                         Call Read.Record(MessWorkFile4,Temp5!)
                         If MessWorkRecord4.Room=SFalse Then
                            Exit For
                         Endif
                      Next
                      If Len(option1$) Then
                         Out2=option1$
                         Call Equate(Temp#)
                      Else
                         Temp#=(Cdbl(UserRecord2.Fatigue)+_
                            Cdbl(UserRecord2.Vitality)+_
                            Cdbl(UserRecord2.Magic))*_
                            Cdbl(UserRecord2.Level)+_
                            Cdbl(UserRecord2.Stats(1))
                      Endif
                      MessWorkRecord4.Index=TempX!
                      MessWorkRecord4.Room=Room
                      MessWorkRecord4.Hits=Temp#
                      MessWorkRecord4.Exp=UserRecord2.Experience
                      MessWorkRecord4.Align1=UserRecord2.Align1
                      MessWorkRecord4.Align2=UserRecord2.Align2
                      Call Write.Record(MessWorkFile4,Temp5!)
                   Endif
                Endif
             Endif
          Endif
       Endif
    Endif
 Next
 ' Encounter.Team.User
 For TempX!=1! To Lof(UserFile2)/UserRecLen
    If TempX!<>User.Index Then
       Call Read.Record(UserFile2,TempX!)
       If UserRecord2.Level>False Then
          Call Search.Mess(TempX!)
          If Temp!=SFalse Then
             Out2=UserRecord2.CodeName
             Out2=Left$(Out2,9)
             If Out2<>Deleted$ Then
                TempB=False
                For Temp5!=1! To Lof(MessWorkFile4)/MessWorkRecLen4
                   Call Read.Record(MessWorkFile4,Temp5!)
                   If MessWorkRecord4.Index=TempX! Then
                      If MessWorkRecord4.Room=Room Then
                         TempB=True
                         Exit For
                      Endif
                   Endif
                Next
                If TempB=False Then
                   MessWorkRecord4.Index=TempX!
                   Call Find.Team.Member(Var4)
                   If Var4=False Then
                      TempB=True
                   Endif
                Endif
                If TempB=False Then
                   For Temp5!=1! To Lof(MessWorkFile4)/MessWorkRecLen4
                      Call Read.Record(MessWorkFile4,Temp5!)
                      If MessWorkRecord4.Room=SFalse Then
                         Exit For
                      Endif
                   Next
                   If Len(option1$) Then
                      Out2=option1$
                      Call Equate(Temp#)
                   Else
                      Temp#=(Cdbl(UserRecord2.Fatigue)+_
                         Cdbl(UserRecord2.Vitality)+_
                         Cdbl(UserRecord2.Magic))*_
                         Cdbl(UserRecord2.Level)+_
                         Cdbl(UserRecord2.Stats(1))
                   Endif
                   MessWorkRecord4.Index=TempX!
                   MessWorkRecord4.Room=Room
                   MessWorkRecord4.Hits=Temp#
                   MessWorkRecord4.Exp=UserRecord2.Experience
                   MessWorkRecord4.Align1=UserRecord2.Align1
                   MessWorkRecord4.Align2=UserRecord2.Align2
                   Call Write.Record(MessWorkFile4,Temp5!)
                Endif
             Endif
          Endif
       Endif
    Endif
 Next
 Exit Sub
Get.Config5:
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[TRAIN]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Select Case Lcase$(Var2$)
             Case "offline.user.hit.points"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option1$=Mid$(Var3$,2)
                      option1$=Left$(option1$,Len(option1$)-1)
                   Endif
                Endif
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrorResume18:
 Exit Sub
ErrorTrap18:
 Resume ErrorResume18
End Sub

Sub Get.Monster.Stats2(VarY,VarZ)
 On Local Error Goto ErrorTrap24
 VarY=True
 If Config2(120)>False Then
    Temp5=False
    For Temp2!=1! To Lof(MessWorkFile3)/MessWorkRecLen3
       Call Read.Record(MessWorkFile3,Temp2!)
       If MessWorkRecord3.Room=Room Then
          Temp5=Temp5+1
          If Temp5>=Config2(120) Then
             VarY=False
             Exit Sub
          Endif
       Endif
    Next
    If Temp5+Number.Appearing>Config2(120) Then
       VarY=False
       Exit Sub
    Endif
 Endif
 For Temp2=1 To Number.Appearing
    For Temp5!=1! To Lof(MessWorkFile3)/MessWorkRecLen3
       Call Read.Record(MessWorkFile3,Temp5!)
       If MessWorkRecord3.IsAutomaton=False Then
          If MessWorkRecord3.Room=SFalse Then
             Exit For
          Endif
       Endif
    Next
    If Config2(121)>False Then
       If Temp5!>Config2(121) Then
          VarY=False
          Exit Sub
       Endif
    Endif
    Call Read.Record(MonsterFile,Choice)
    MessWorkRecord3.Index=Choice
    MessWorkRecord3.Monster=MonsterRecord
    MessWorkRecord3.Room=Room
    MessWorkRecord3.AutoMode=False
    If VarZ=True Then
       MessWorkRecord3.Monster.Magic=Int(Rnd*3+1)
    Endif
    If VarZ=False Then
       MessWorkRecord3.Monster.Magic=Int(Rnd*Room.Monster.Rate+1)
    Endif
    If MessWorkRecord3.Monster.Psionic Then
       Temp4!=MessWorkRecord3.Monster.PsionicSpell
       MessWorkRecord3.Monster.Psionic=False
       If Temp4!>SFalse And Temp4!<=Lof(SpellFile)/SpellRecLen Then
          Call Read.Record(SpellFile,Temp4!)
          If SpellRecord.Psionic Then
             If SpellRecord.PsionicMode=PsiAttack Then
                MessWorkRecord3.Monster.Psionic=SpellRecord.Level
             Endif
          Endif
       Endif
    Endif
    Call Write.Record(MessWorkFile3,Temp5!)
    Call Add.Monster.Inventory2(False)
 Next
 Var!=RoomRecord.Action
 If Var!>SFalse And Var!<=Lof(ActionFile)/ActionRecLen Then
    Call Read.Record(ActionFile,Var!)
    Var2=Abs(MessWorkRecord3.Monster.Permanent)+1
    If ActionRecord.MonsterTrigger(Var2)=Choice Then
       Out3="As you step forward,"
       Out4="The monster hits you for"
       Call Actions(Var!)
    Endif
 Endif
ErrorResume24:
 Exit Sub
ErrorTrap24:
 Resume ErrorResume24
End Sub

Sub Add.Monster.Inventory2(VarX)
 On Local Error Goto ErrorTrap24a
 If VarX=False Then
    Var!=MonsterRecord.First
    If Var! Then
       Do While Lost.Carrier=False
          Call Read.Record(MonInvFile,Var!)
          Var1!=MessWorkRecord6.Next
          Temp6!=MessWorkRecord6.User
          If Temp6! Then
             Temp7=False
             If Temp6!>SFalse And Temp6!<=Lof(TreasureFile)/TreasureRecLen Then
                Call Read.Record(TreasureFile,Temp6!)
                Temp7=TreasureRecord.Charges
             Endif
             Temp8=True
             If MessWorkRecord3.Monster.Permanent=False Then
                If Rnd>Config1(24) Then
                   Temp8=False
                Endif
             Endif
             If Temp8 Then
                For Temp9!=1! To Lof(MessWorkFile5)/MessWorkRecLen5
                   Call Read.Record(MessWorkFile5,Temp9!)
                   If MessWorkRecord5.Index=SFalse Then
                      Exit For
                   Endif
                Next
                MessWorkRecord5.Index=Choice
                MessWorkRecord5.Inv=Temp6!
                MessWorkRecord5.Charges=Temp7
                MessWorkRecord5.Room=Room
                MessWorkRecord5.Monster=Temp5!
                MessWorkRecord5.IsAutomaton=False
                Call Write.Record(MessWorkFile5,Temp9!)
             Endif
          Endif
          If Var1!=SFalse Then
             Exit Do
          Endif
          Var!=Var1!
       Loop
    Endif
 Else
    Var!=MonsterRecord.First
    If Var! Then
       Do While Lost.Carrier=False
          Call Read.Record(MonInvFile,Var!)
          Var1!=MessWorkRecord6.Next
          Temp6!=MessWorkRecord6.User
          If Temp6! Then
             Temp7=False
             If Temp6!>SFalse And Temp6!<=Lof(TreasureFile)/TreasureRecLen Then
                Call Read.Record(TreasureFile,Temp6!)
                Temp7=TreasureRecord.Charges
             Endif
             For Temp9!=1! To Lof(MessWorkFile5)/MessWorkRecLen5
                Call Read.Record(MessWorkFile5,Temp9!)
                If MessWorkRecord5.Index=SFalse Then
                   Exit For
                Endif
             Next
             MessWorkRecord5.Index=-Choice
             MessWorkRecord5.Inv=Temp6!
             MessWorkRecord5.Charges=Temp7
             MessWorkRecord5.Room=Room
             MessWorkRecord5.Monster=Temp5!
             MessWorkRecord5.IsAutomaton=False
             Call Write.Record(MessWorkFile5,Temp9!)
          Endif
          If Var1!=SFalse Then
             Exit Do
          Endif
          Var!=Var1!
       Loop
    Endif
 Endif
 For Var=1 To 3
    MessWorkRecord3.Weapon(Var).Index=0!
    MessWorkRecord3.Weapon(Var).Charges=0
    MessWorkRecord3.Weapon(Var).Plus=0
 Next
 Var!=MonsterRecord.Weapon
 If Var!>SFalse And Var!<=Lof(TreasureFile)/TreasureRecLen Then
    Call Read.Record(TreasureFile,Var!)
    MessWorkRecord3.Weapon(1).Index=Var!
    MessWorkRecord3.Weapon(1).Charges=TreasureRecord.Charges
    MessWorkRecord3.Weapon(1).Plus=TreasureRecord.Plus
 Endif
 Var!=MonsterRecord.Shield
 If Var!>SFalse And Var!<=Lof(TreasureFile)/TreasureRecLen Then
    Call Read.Record(TreasureFile,Var!)
    MessWorkRecord3.Weapon(2).Index=Var!
    MessWorkRecord3.Weapon(2).Charges=TreasureRecord.Charges
    MessWorkRecord3.Weapon(2).Plus=TreasureRecord.Plus
 Endif
 Var!=MonsterRecord.Armor
 If Var!>SFalse And Var!<=Lof(TreasureFile)/TreasureRecLen Then
    Call Read.Record(TreasureFile,Var!)
    MessWorkRecord3.Weapon(3).Index=Var!
    MessWorkRecord3.Weapon(3).Charges=TreasureRecord.Charges
    MessWorkRecord3.Weapon(3).Plus=TreasureRecord.Plus
 Endif
 Call Write.Record(MessWorkFile3,Temp5!)
ErrorResume24a:
 Exit Sub
ErrorTrap24a:
 Resume ErrorResume24a
End Sub

Sub Player.Attack
 On Local Error Goto ErrorTrap12
 Graphics.Off=True
 Monster.Temp=SFalse
 Prefix2=Nul
 Out6=Out3
 Call Hit.Player(Temp2)
 If UserRecord.Vitality=False Then
    Out2="Was just killed by "+Out6+"!"
    If Node>False Then
       Call Send.Mess(4,SFalse,SFalse,Out2)
    Endif
    Last.Command=Dead$
    Call Update.Mess(4)
    Call Read.Mess
 Endif
ErrorResume12:
 Exit Sub
ErrorTrap12:
 Resume ErrorResume12
End Sub

Sub Get.Hits
 On Local Error Goto ErrorTrap13
 Gosub Get.Config3
 TempD=False
 Select Case Previous.Command
 Case Lunge
    Temp2=Temp2-UserRecord.Stats(4)/2-UserRecord.Stats(1)/2
 Case Dodge
    Temp2=Temp2-(UserRecord.Stats(4)+UserRecord.Stats(1))/2
 Case Feint
    Temp2=Temp2-UserRecord.Stats(4)/2-UserRecord.Stats(1)
 Case Parry
    Temp2=Temp2-UserRecord.Stats(4)-UserRecord.Stats(1)
 Case Thrust
    Temp2=Temp2+UserRecord.Stats(4)/2+UserRecord.Stats(1)
 Case Charge
    Temp2=Temp2+UserRecord.Stats(4)+UserRecord.Stats(1)
 Case Resist
    Temp2=Temp2-UserRecord.Stats(1)/2
 Case Beat
    Temp2=Temp2+UserRecord.Stats(4)/2+UserRecord.Stats(1)/2
 Case Punch
    Temp2=Temp2+(UserRecord.Stats(4)+UserRecord.Stats(1))/2
 Case Bewitch
    Temp2=Int(Temp2/2)-UserRecord.Beauty
 Case Bewilder
    Temp2=Int(Temp2/2)-UserRecord.Glamour
 End Select
 Temp2=Int(Temp2)
 Previous.Command=False
 If Temp2<=False Then
    Strng=Prefix1+Out3+" missed!"
    Call IO.O
    Exit Sub
 Endif
 If Monster.Temp Then
    If Magic.Spell=False Then
       Strng=Prefix1+Out3+" attacks you"
       If MessWorkRecord3.Monster.Psionic Then
          Strng=Strng+" with psionics"
       Endif
       Strng=Strng+"!"
       Call IO.O
    Endif
 Endif
 If UserRecord.Invisible Then
    Strng="Your invisibility protects you!"
    Call IO.O
    Exit Sub
 Endif
 ' check for invisibility cloak being worn.
 Var2!=UserRecord.Weapon(8).Index
 If Var2! Then
    Call Read.Record(TreasureFile,Var2!)
    If TreasureRecord.Spell Then
       Var1!=TreasureRecord.Spell
       If Var1!>SFalse And Var1!<=Lof(SpellFile)/SpellRecLen Then
          Call Read.Record(SpellFile,Var1!)
          If SpellRecord.SpellType=Invisibly Then
             Var$=Rtrim$(TreasureRecord.ShortName)
             Var$=Lcase$(Var$)
             Strng="Your "+Var$+" protects you!"
             Call IO.O
             Var3=UserRecord.Weapon(8).Charges
             If Var3>False Then
                Var3=Var3-1
                UserRecord.Weapon(8).Charges=Var3
                If Var3<=False Then
                   UserRecord.Weapon(8).Index=SFalse
                   UserRecord.Weapon(8).Charges=False
                   UserRecord.Weapon(8).Plus=False
                   Strng="Your "+Var$+" disintegrates!"
                   Call IO.O
                Endif
             Endif
             Exit Sub
          Endif
       Endif
    Endif
 Endif
 ' check for invisibility rings being worn.
 Var2!=UserRecord.Weapon(4).Index
 If Var2! Then
    Call Read.Record(TreasureFile,Var2!)
    If TreasureRecord.RingType=3 Then
       Var1!=TreasureRecord.RingSpell
       If Var1!>SFalse And Var1!<=Lof(SpellFile)/SpellRecLen Then
          Call Read.Record(SpellFile,Var1!)
          If SpellRecord.SpellType=Invisibly Then
             Var$=Rtrim$(TreasureRecord.ShortName)
             Var$=Lcase$(Var$)
             Strng="Your "+Var$+" protects you!"
             Call IO.O
             Var3=UserRecord.Weapon(4).Charges
             If Var3>False Then
                Var3=Var3-1
                UserRecord.Weapon(4).Charges=Var3
                If Var3<=False Then
                   UserRecord.Weapon(4).Index=SFalse
                   UserRecord.Weapon(4).Charges=False
                   UserRecord.Weapon(4).Plus=False
                   Strng="Your "+Var$+" disintegrates!"
                   Call IO.O
                Endif
             Endif
             Exit Sub
          Endif
       Endif
    Endif
 Endif
 Var2!=UserRecord.Weapon(9).Index
 If Var2! Then
    Call Read.Record(TreasureFile,Var2!)
    If TreasureRecord.RingType=3 Then
       Var1!=TreasureRecord.RingSpell
       If Var1!>SFalse And Var1!<=Lof(SpellFile)/SpellRecLen Then
          Call Read.Record(SpellFile,Var1!)
          If SpellRecord.SpellType=Invisibly Then
             Var$=Rtrim$(TreasureRecord.ShortName)
             Var$=Lcase$(Var$)
             Strng="Your "+Var$+" protects you!"
             Call IO.O
             Var3=UserRecord.Weapon(9).Charges
             If Var3>False Then
                Var3=Var3-1
                UserRecord.Weapon(9).Charges=Var3
                If Var3<=False Then
                   UserRecord.Weapon(9).Index=SFalse
                   UserRecord.Weapon(9).Charges=False
                   UserRecord.Weapon(9).Plus=False
                   Strng="Your "+Var$+" disintegrates!"
                   Call IO.O
                Endif
             Endif
             Exit Sub
          Endif
       Endif
    Endif
 Endif
 ' check for invisibility armor being worn.
 Var2!=UserRecord.Weapon(1).Index
 If Var2! Then
    Call Read.Record(TreasureFile,Var2!)
    Var1!=TreasureRecord.Spell
    If Var1!>SFalse And Var1!<=Lof(SpellFile)/SpellRecLen Then
       Call Read.Record(SpellFile,Var1!)
       If SpellRecord.SpellType=Invisibly Then
          Var$=Rtrim$(TreasureRecord.ShortName)
          Var$=Lcase$(Var$)
          Strng="Your "+Var$+" protects you!"
          Call IO.O
          Var2=UserRecord.Weapon(1).Charges
          Var2=Var2-1
          UserRecord.Weapon(1).Charges=Var2
          If Var2<=False Then
             Strng="Your "+Var$+" crumbles!"
             Call IO.O
             Call Add.Inventory(Var2!,Var2)
             UserRecord.Weapon(1).Index=SFalse
             UserRecord.Weapon(1).Plus=False
             Call Discard(Temp0!,False)
          Endif
          Exit Sub
       Endif
    Endif
 Endif
 If Vehicle1 Then
    If Len(option1$) Then
       Out2=option1$
       Call Equate(Temp#)
    Else
       Temp#=Rnd>.75
    Endif
    If Temp# Then
       Call Read.Record(RoomInvFile,Vehicle1)
       If MessWorkRecord6.Charges>False Then
          Call Read.Record(TreasureFile,Vehicle3)
          Out2=TreasureRecord.ShortName
          Out2=Rtrim$(Out2)
          Out2=Lcase$(Out2)
          Var$=Prefix1+Out3+" hits your "+Out2+" for"+Str$(Temp2)+" hits!"
          Strng=Var$
          Call IO.O
          Call Send.Vehicle(Var$)
          MessWorkRecord6.Charges=MessWorkRecord6.Charges-Temp2
          If MessWorkRecord6.Charges<=False Then
             MessWorkRecord6.Charges=False
             MessWorkRecord6.User=SFalse
          Endif
          Call Write.Record(RoomInvFile,Vehicle1)
          If MessWorkRecord6.Charges<=False Then
             Var$=Prefix1+Out3+" damaged your "+Out2+"!"
             Strng=Var$
             Call IO.O
             Call Send.Vehicle(Var$)
             Call Clear.Vehicles
             Strng="You exit the "+Out2+"!"
             Call IO.O
          Endif
          Exit Sub
       Endif
    Endif
 Endif
 Strng=Prefix1+Out3+" hits you for"
 Call Hit.Player(Temp2)
 If UserRecord.Vitality=False Then
    TempD=True
    Exit Sub
 Endif
 Call Get.Weapon.Hits
 Exit Sub
Get.Config3:
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[TRAIN]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Select Case Lcase$(Var2$)
             Case "vehicle.hit.equation"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option1$=Mid$(Var3$,2)
                      option1$=Left$(option1$,Len(option1$)-1)
                   Endif
                Endif
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrorResume13:
 Exit Sub
ErrorTrap13:
 Resume ErrorResume13
End Sub

Sub Clear.Vehicles
 On Local Error Goto ErrorTrap13a2
 Call Read.Record(RoomInvFile,Vehicle1)
 Var$="exit vehicle"
 Var2!=MessWorkRecord6.User
 If Var2!>SFalse Then
    If Var2!<>User.Index Then
       Call Send.Mess(35,Var2!,Room,Var$)
    Endif
    MessWorkRecord6.User=SFalse
    For Var2=1 To 4
       Var2!=MessWorkRecord6.Temp(Var2)
       If Var2!>SFalse Then
          If Var2!<>User.Index Then
             Call Send.Mess(35,Var2!,Room,Var$)
          Endif
       Endif
       MessWorkRecord6.Temp(Var2)=SFalse
    Next
    Call Write.Record(RoomInvFile,Vehicle1)
 Endif
 Vehicle1=SFalse
 Vehicle2=False
 Vehicle3=SFalse
ErrorResume13a2:
 Exit Sub
ErrorTrap13a2:
 Resume ErrorResume13a2
End Sub

Sub Read.Mess
 On Local Error Goto ErrorTrap13a
 Call Read.Group.Mess
 Redim Temp.Array1(1 To 16) As Integer
 Redim Temp.Array3(1 To 16) As Single
 Redim Temp.Array4(1 To 16) As Single
 Redim Temp.ArrayS(1 To 16) As String
 Redim Temp.ArrayX(1 To 16) As Single
 Max.Array=16 ' array size variable
 Graphics.Off=True
 TempQ=False ' dead user flag
 VarX2=Node+1
 Call Read.Message.Record(MessWorkFile1,VarX2)
 If Left$(MessWorkRecord1.LastCommand,Len(Dead$))=Dead$ Then
    TempQ=True
 Endif
 If MessWorkRecord1.OfferTime=True Then
    If TempQ=False Then
       Strng="The offer was accepted!"
       Call IO.O
       Var1#=MessWorkRecord1.GoldFor
       If Var1#>DFalse Then
          UserRecord.Gold=UserRecord.Gold+Var1#
          Strng="You now have "+Form$(UserRecord.Gold)+" gold."
          Call IO.O
       Else
          If MessWorkRecord1.ContainerFor=False Then
             Temp7!=MessWorkRecord1.ItemFor
             Temp6=MessWorkRecord1.ForCharges
             Strng=Nul
             If Temp7!>SFalse Then
                Call Read.Record(TreasureFile,Temp7!)
                Strng=Rtrim$(TreasureRecord.TreasureName)
             Else
                If Temp7!<SFalse Then
                   Call Read.Record(ObjectFile,Abs(Temp7!))
                   Strng=Rtrim$(ObjectRecord.ObjectName)
                Endif
             Endif
             If Temp7! Then
                Call Add.Inventory(Temp7!,Temp6)
                Strng="You now have "+Lcase$(Strng)+"!"
                Call IO.O
             Endif
          Endif
       Endif
    Endif
    MessWorkRecord1.OfferTime=False
    VarX2=Node+1
    Call Write.Message.Record(MessWorkFile1,VarX2)
 Endif
 Var1=False
 For Var!=1 To Lof(MessWorkFile2)/MessWorkRecLen2
    If Var1>=1024 Then
       Exit For
    Endif
    Call Read.Record(MessWorkFile2,Var!)
    If Mid$(MessWorkRecord2.Flags,Node+1,1)="0" Then
       If TempQ Then
          Var1=1
       Else
          If Var1=Max.Array Then
             Max.Array=Max.Array+16 ' extend message arrays
             Redim Preserve Temp.Array1(1 To Max.Array) As Integer
             Redim Preserve Temp.Array3(1 To Max.Array) As Single
             Redim Preserve Temp.Array4(1 To Max.Array) As Single
             Redim Preserve Temp.ArrayS(1 To Max.Array) As String
             Redim Preserve Temp.ArrayX(1 To Max.Array) As Single
          Endif
          Var1=Var1+1
       Endif
       If MessWorkRecord2.Node=False Then
          Out3="P##"
       Else
          If Brief.Messages Then
             Select Case MessWorkRecord2.Node
             Case 1 To 10 ' 0-9
                Out3="P#"+Mid$(Str$(MessWorkRecord2.Node-1),2)
             Case 11 To 36 ' A-Z
                Out3="P#"+Chr$(MessWorkRecord2.Node+54)
             Case 37 To 126 ' 10-99
                Out3="P#"+Mid$(Str$(MessWorkRecord2.Node-27),2)
             Case Else
                Out3="P?"
             End Select
          Else
             Out3=Lcase$(Rtrim$(MessWorkRecord2.UserName))
             If Len(Out3) Then
                Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
             Else
                Out3="P?"
             Endif
          Endif
       Endif
       Temp.Array3(Var1)=MessWorkRecord2.UserIndex
       Select Case MessWorkRecord2.MessageType
       Case 1
          Strng=Out3+" Sends: "+MessWorkRecord2.Message
       Case 2
          Strng=Out3+" Yells: "+MessWorkRecord2.Message
       Case 3
          Strng=Out3+" Says: "+MessWorkRecord2.Message
       Case 4
          Strng=Mask$+Mask$+Mask$+" "+Out3+": "+MessWorkRecord2.Message
       Case 5
          Strng=MessWorkRecord2.Message
       Case 6
          Out4=MessWorkRecord2.Message2
          Out4=Rtrim$(Out4)
          Out4=Lcase$(Out4)
          Mid$(Out4,1,1)=Ucase$(Mid$(Out4,1,1))
          Strng=Out3+" Sends to "+Out4+": "+MessWorkRecord2.Message
       Case 7
          Out4=MessWorkRecord2.Message2
          Out4=Rtrim$(Out4)
          Out4=Lcase$(Out4)
          Mid$(Out4,1,1)=Ucase$(Mid$(Out4,1,1))
          Strng=Out3+" Whispers to "+Out4+": "+MessWorkRecord2.Message
       Case 8
          Strng=MessWorkRecord2.Message
       Case 9
          Strng=Out3
          Temp.Array3(Var1)=Int(Val(Left$(MessWorkRecord2.Message,6))+.5)
       Case 10
          Strng=Out3+" Transmits: "+MessWorkRecord2.Message
       Case 11
          Strng=Out3+": "+MessWorkRecord2.Message 
       Case 12
          Strng=Out3+" aborted program!"
       Case 13
          Strng=Out3+" gives you "+MessWorkRecord2.Message
       Case 14
          Strng=Out3+" aborted program!"
       Case 15
          Out2=MessWorkRecord2.Message
          If Val(Out2) Then
             Strng=Out3+Chr$(1)+Str$(Val(Out2))
          Else
             Strng=Out3+Chr$(1)+Out2
          Endif
       Case 16
          Out2=MessWorkRecord2.Message
          If Val(Out2) Then
             Strng=Out3+Chr$(1)+Str$(Val(Out2))
          Else
             Strng=Out3+Chr$(1)+Out2
          Endif
       Case 17
          Strng="Evil Laughter Sounds From Above..."
          Call IO.O
          Strng="   A Bolt of Lightning Strikes..."
          Call IO.O
          Strng="You were just struck dead!"
       Case 18
          Strng="You were just teleported elsewhere!"
          Temp.Array3(Var1)=Int(Val(MessWorkRecord2.Message)+.5)
       Case 19
          Strng=Out3+" "+MessWorkRecord2.Message
       Case 20
          Strng=Out3+" loses you!"
          Temp.Array3(Var1)=MessWorkRecord2.UserIndex
       Case 21
          Strng=Out3+" launchs "+MessWorkRecord2.Message
          Strng=Rtrim$(Strng)
          Strng=Strng+" at you!"
       Case 22
          Strng=Out3+" fires "+MessWorkRecord2.Message
          Strng=Rtrim$(Strng)
          Strng=Strng+" at you!"
       Case 23
          Strng=Out3+" blesses you!"
       Case 24
          Strng=Out3+" curses you!"
       Case 25
          Strng=Out3+" sends group."
       Case 26
          Strng=Out3+": "+MessWorkRecord2.Message
       Case 27
          Strng=MessWorkRecord2.Message
       Case 28
          Strng=Mask$+Mask$+Mask$+": "+MessWorkRecord2.Message
       Case 30
          Strng=Out3+" aborted program!"
       Case 32, 33
          Strng=Out3+" shutdown program!"
       Case 36
          Strng="You move with the vehicle!"
          Temp.Array3(Var1)=Int(Val(MessWorkRecord2.Message)+.5)
       Case 37
          Strng=Out3+" imbues you!"
       Case 38
          Strng=Out3+" zaps you!"
       Case 39
          Strng=Out3+" grants you a wish!"
       Case 40
          Strng=Out3+" robbed you of a wish!"
       End Select
       Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
       Temp.ArrayS(Var1)=Rtrim$(Strng)
       Temp.Array1(Var1)=MessWorkRecord2.MessageType
       Temp.ArrayX(Var1)=MessWorkRecord2.MessageTime
       Mid$(MessWorkRecord2.Flags,Node+1,1)="1"
       'Node.Work.Array1(Var1)=MessWorkRecord2.Flags
       Call Write.Record(MessWorkFile2,Var!)
    Endif
 Next
Finish.Read.Mess:
 If TempQ Then
    Goto Exit.Read.Mess
 Endif
 If Var1=False Then
    Goto Exit.Read.Mess
 Endif
 ' sort message arrays by time
 For VarS1=1 To Var1
    For VarS2=VarS1+1 To Var1
       If Temp.ArrayX(VarS1)>Temp.ArrayX(VarS2) Then
          'Swap Node.Work.Array1(VarS1),Node.Work.Array1(VarS2)
          Swap Temp.Array1(VarS1),Temp.Array1(VarS2)
          Swap Temp.Array3(VarS1),Temp.Array3(VarS2)
          Swap Temp.Array4(VarS1),Temp.Array4(VarS2)
          Swap Temp.ArrayS(VarS1),Temp.ArrayS(VarS2)
          Swap Temp.ArrayX(VarS1),Temp.ArrayX(VarS2)
       Endif
    Next
 Next
 ' display messages
 VarF=False
 For VarX=1 To Var1
    Select Case Temp.Array1(VarX)
    Case 9
       Strng=Temp.ArrayS(VarX)+" attacks you!"
       Call IO.O
       Strng=Temp.ArrayS(VarX)+" hits you for"
       Temp2=Cint(Temp.Array3(VarX))
       Call Player.Attack
       If UserRecord.Vitality<=False Then
          Exit For
       Endif
    Case 12
       Strng=Temp.ArrayS(VarX)
       Call IO.O
       If Node>False Then
          Call Hang.Up(11)
          Exit For
       Endif
    Case 13
       Strng=Temp.ArrayS(VarX)+"!!"
       Call IO.O
    Case 14
       Strng=Temp.ArrayS(VarX)
       Call IO.O
       If Node>False Then
          Call Hang.Up(11)
          Exit For
       Endif
    Case 15
       Out2=Temp.ArrayS(VarX)
       Out2=Mid$(Out2,Instr(Out2,Chr$(1))+1)
       Out3=Temp.ArrayS(VarX)
       Out3=Left$(Out3,Instr(Out3,Chr$(1))-1)
       Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
       Temp#=Val(Out2)
       Select Case Temp#
       Case 1
          Strng=Out3+" gives you one gold.."
       Case 2 To 10
          Strng=Out3+" gives you "+Rtrim$(Numeral(Temp#))+" gold."
       Case Is>10
          Call Amount4(Temp#,Var$)
          Strng=Out3+" gives you"+Var$+" gold!"
       End Select
       Call IO.O
       UserRecord.Gold=UserRecord.Gold+Temp#
    Case 16
       Out2=Temp.ArrayS(VarX)
       Out2=Mid$(Out2,Instr(Out2,Chr$(1))+1)
       Out3=Temp.ArrayS(VarX)
       Out3=Left$(Out3,Instr(Out3,Chr$(1))-1)
       Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
       Temp#=Val(Out2)

       Var$=""
       Select Case Temp#
       Case 1
          Var$=" one gold"
       Case 2 To 10
          Var$=" "+Rtrim$(Numeral(Temp#))+" gold"
       Case Is>10
          Call Amount4(Temp#,Var2$)
          Var$=Var2$+" gold"
       End Select
       If Var$="" Then
          Var$=" "+Rtrim$(Out2)
       Endif

       If Normal.User=False Then
          Strng="You catch "+Out3+" stealing"+Var$+" from you!"
          Call IO.O
       Else
          If Rnd>.66 Then
             Strng="You catch "+Out3+" stealing"+Var$+" from you!"
             Call IO.O
          Endif
       Endif
       UserRecord.Gold=UserRecord.Gold-Temp#
       If UserRecord.Gold<0# Then
          UserRecord.Gold=0#
       Endif
    Case 17
       Message1="You were just killed!"
       Strng="was killed by the Ghods!"
       Call Update.DayFile(Strng,False,1)
       Call Player.Died
    Case 18
       Strng=Temp.ArrayS(VarX)
       Call IO.O
       Next.Room=Temp.Array3(VarX)
       Call Teleport
       Action.Recurse=0
       Call Enter.Room
    Case 19
       Strng=Temp.ArrayS(VarX)
       Call IO.O
       Strng="Type 'Accept' to trade."
       Call IO.O
    Case 20
       If Follow.Mode Then
          Temp2!=Temp.Array3(VarX)
          If Temp2!=Following Then
             Strng=Temp.ArrayS(VarX)
             Call IO.O
             Auto.Break=True
          Endif
       Endif
    Case 23 ' bless
       If UserRecord.Stats(6)<MaxInt Then
          UserRecord.Stats(6)=UserRecord.Stats(6)+1
          Strng=Temp.ArrayS(VarX)
          Call IO.O
          Strng="You feel a glow about you!"
          Call IO.O
          Strng="You now have "+Form$(Cdbl(UserRecord.Stats(6)))+" piety points."
          Call IO.O
          'Call New.Stats
       Endif
    Case 24 ' curse
       If UserRecord.Stats(6)>False Then
          UserRecord.Stats(6)=UserRecord.Stats(6)-1
          Strng=Temp.ArrayS(VarX)
          Call IO.O
          Strng="You feel a darkening about you!"
          Call IO.O
          Strng="You now have "+Form$(Cdbl(UserRecord.Stats(6)))+" piety points."
          Call IO.O
          'Call New.Stats
       Endif
    Case 25 ' /group
       Strng=Temp.ArrayS(VarX)
    Case 26 ' /chat message
       If Chat.Mode Then
          Chat.Mode=1
          ' convert chat string.
          Strng=Temp.ArrayS(VarX)
          Call Convert.String
          Call Convert.ANSI(True,VarQ,VarR)
          Graphics.On=True
          Call IO.O
          Graphics.On=False
       Endif
    Case 27
       Out2=Temp.ArrayS(VarX)
       Out2=Ltrim$(Out2)
       Out3=Mid$(Out2,Instr(Out2," ")+1)
       Out3=Ltrim$(Out3)
       Out2=Left$(Out2,Instr(Out2," ")-1)
       VarQ1#=Cdbl(Val(Out2))
       VarQ2#=Cdbl(Val(Out3))
       Call Add.Experience(VarQ1#,VarQ2#)
    Case 30 ' dndpack suspend mode on
       VarX2=Node+1
       Call Read.Message.Record(MessWorkFile1,VarX2)
       MessWorkRecord1.SuspendNode=True
       Call Write.Message.Record(MessWorkFile1,VarX2)
       Suspend.Node=True
       Call Hang.Up(3)
       Exit For
    Case 31 ' dndpack suspend mode off
       VarX2=Node+1
       Call Read.Message.Record(MessWorkFile1,VarX2)
       MessWorkRecord1.SuspendNode=False
       Call Write.Message.Record(MessWorkFile1,VarX2)
       Suspend.Node=False
    Case 32, 33 ' shut down node
       Strng=Temp.ArrayS(VarX)
       Call IO.O
       If Node>False Then
          Call Hang.Up(4)
          Exit For
       Endif
    Case 35
       Vehicle1=SFalse
       Vehicle2=False
       Vehicle3=SFalse
    Case 36
       Strng=Temp.ArrayS(VarX)
       Call IO.O
       Next.Room=Temp.Array3(VarX)
       Ignore.Vehicle=True
       Action.Recurse=0
       Call Enter.Room
       Ignore.Vehicle=False
    Case 37 ' imbue
       If UserRecord.Psionic<UserRecord.PsionicMax Then
          UserRecord.Psionic=UserRecord.Psionic+1
          Strng=Temp.ArrayS(VarX)
          Call IO.O
          Strng="You feel a light about you!"
          Call IO.O
          Strng="You now have "+Form$(Cdbl(UserRecord.Psionic))+" psionic points."
          Call IO.O
          'Call New.Stats
       Endif
    Case 38 ' zap
       If UserRecord.Psionic>0 Then
          UserRecord.Psionic=UserRecord.Psionic-1
          Strng=Temp.ArrayS(VarX)
          Call IO.O
          Strng="You feel a darkening about you!"
          Call IO.O
          Strng="You now have "+Form$(Cdbl(UserRecord.Psionic))+" psionic points."
          Call IO.O
          'Call New.Stats
       Endif
    Case 39 ' grantwish
       If UserRecord.WishsLeft<MaxInt Then
          UserRecord.WishsLeft=UserRecord.WishsLeft+1
          Strng=Temp.ArrayS(VarX)
          Call IO.O
          Strng="You now have "+Form$(Cdbl(UserRecord.WishsLeft))+" wishes."
          Call IO.O
       Endif
    Case 40 ' stealwish
       If UserRecord.WishsLeft>0 Then
          UserRecord.WishsLeft=UserRecord.WishsLeft-1
          Strng=Temp.ArrayS(VarX)
          Call IO.O
          Strng="You now have "+Form$(Cdbl(UserRecord.WishsLeft))+" wishes."
          Call IO.O
       Endif
    Case Else
       Strng=Temp.ArrayS(VarX)
       Call Convert.String
       Call Convert.ANSI(True,VarQ,VarR)
       Graphics.On=True
       Call IO.O
       Graphics.On=False
    End Select
 Next
Exit.Read.Mess:
 VarX2=Node+1
 Call Read.Message.Record(MessWorkFile1,VarX2)
 If MessWorkRecord1.OfferTime>False Then
    If Time.Elapsed(MessWorkRecord1.OfferTime,30!) Then
       MessWorkRecord1.OfferTime=False
       Call Write.Message.Record(MessWorkFile1,VarX2)
       If TempQ=False Then
          Strng="Offer expired!"
          Call IO.O
       Endif
       Call Clear.Container.Swap
    Endif
 Endif
 Erase Temp.Array1, Temp.Array3, Temp.Array4, Temp.ArrayS, Temp.ArrayX
ErrorResume13a:
 Exit Sub
ErrorTrap13a:
 ' Out of memory/Subscript out of range/Out of string space.
 If Err=7 Or Err=9 Or Err=14 Then
    Resume Finish.Read.Mess
 Endif
 Resume ErrorResume13a
End Sub

Sub Clear.Container.Swap
 On Local Error Goto ErrorTrp32x
 Temp5!=UserRecord.First2
 If Temp5! Then
    Do
       Call Read.Record(ContainerFile,Temp5!)
       Var6!=ContainerRecord.Next
       ContainerRecord.SwapFlag=False
       Call Write.Record(ContainerFile,Temp5!)
       If Var6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Var6!
    Loop
 Endif
 Var1=MessWorkRecord1.FromNode
 Call Read.Message.Record(MessWorkFile1,Var1+1)
 Var2!=MessWorkRecord1.UserIndex
 Call Read.Record(UserFile2,Var2!)
 Temp5!=UserRecord2.First2
 If Temp5! Then
    Do
       Call Read.Record(ContainerFile,Temp5!)
       Var6!=ContainerRecord.Next
       ContainerRecord.SwapFlag=False
       Call Write.Record(ContainerFile,Temp5!)
       If Var6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Var6!
    Loop
 Endif
ErrorRsm32x:
 Exit Sub
ErrorTrp32x:
 Resume ErrorRsm32x
End Sub

Sub Read.Group.Mess
 On Local Error Goto ErrorTrap12a
 Do While Lost.Carrier=False
    Redim Temp.Array1(1 To 9) As Integer ' group line number
    Redim Temp.ArrayS(1 To 9) As String ' group message line
    VarX=False
    For Var!=1! To Lof(MessWorkFile2)/MessWorkRecLen2
       Call Read.Record(MessWorkFile2,Var!)
       If Mid$(MessWorkRecord2.Flags,Node+1,1)="0" Then
          If MessWorkRecord2.MessageType=25 Then
             If MessWorkRecord2.RoomNumber=Room Or Monitor.Mode Then
                TempQ$=MessWorkRecord2.Message2
                TempQ$=Mid$(TempQ$,3)
                TempQ$=Rtrim$(TempQ$)
                VarX=True
                Out3=Lcase$(Rtrim$(MessWorkRecord2.UserName))
                If Len(Out3) Then
                   Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
                Else
                   Out3="P?"
                Endif
                Exit For
             Endif
          Endif
       Endif
    Next
    If VarX=False Then
       Exit Do
    Endif
    Var1=False
    For Var!=1! To Lof(MessWorkFile2)/MessWorkRecLen2
       Call Read.Record(MessWorkFile2,Var!)
       If Mid$(MessWorkRecord2.Flags,Node+1,1)="0" Then
          If MessWorkRecord2.MessageType=25 Then
             If MessWorkRecord2.RoomNumber=Room Or Monitor.Mode Then
                Temp2$=MessWorkRecord2.Message2
                Temp$=Mid$(Temp2$,3)
                Temp$=Rtrim$(Temp$)
                If Temp$=TempQ$ Then
                   If Var1<9 Then
                      Var1=Var1+1
                      Temp.Array1(Var1)=Int(Val(Left$(Temp2$,2))+.5)
                      Temp.ArrayS(Var1)=Rtrim$(MessWorkRecord2.Message)
                      Mid$(MessWorkRecord2.Flags,Node+1,1)="1"
                      Node.Work.Array1(Var1)=MessWorkRecord2.Flags
                      Call Write.Record(MessWorkFile2,Var!)
                   Endif
                Endif
             Endif
          Endif
       Endif
    Next
    If Var1>False Then
       ' sort by grouped line number
       For VarS1=1 To Var1
          For VarS2=VarS1+1 To Var1
             If Temp.Array1(VarS1)>Temp.Array1(VarS2) Then
                Swap Temp.Array1(VarS1),Temp.Array1(VarS2)
                Swap Temp.ArrayS(VarS1),Temp.ArrayS(VarS2)
             Endif
          Next
       Next
       ' display grouped message
       Graphics.Off=False
       Strng=Out3+" Sends group:"
       Call IO.O
       Graphics.Off=True
       For VarX=1 To Var1
          Strng=Rtrim$(Temp.ArrayS(VarX))
          Call Convert.String
          Call Convert.ANSI(True,VarQ,VarR)
          Graphics.On=True
          Call IO.O
          Graphics.On=False
       Next
       If Auto.Mode Or Chat.Mode Or Follow.Mode Or Monitor.Mode Or Wait.Mode Then
          Eat$ = Nul
       Else
          Call More.Prompt
       Endif
    Endif
    Erase Temp.Array1, Temp.ArrayS
 Loop
ErrorResume12a:
 Exit Sub
ErrorTrap12a:
 Resume ErrorResume12a
End Sub

Sub Pause.Second
 On Local Error Goto Error.Trap4
 Timer.Temp!=Timeit!
 Do Until Time.Elapsed(Timer.Temp!,1!)
    Call Get.Modem(True)
    Call Check.Break
    Call Read.Keyboard(VarX$)
    Select Case VarX$
    Case Chr$(3)
       Call Set.Break
    Case Chr$(11)
       Call Set.Break
    Case Chr$(27)
       If Chat Then
	  Chat=False
       Else
          If Local.Mode=False Or Normal.User=False Then
             Call Status.Line(True)
          Endif
       Endif
    Case Chr$(0)+Chr$(79) ' end
       Call Hang.Up(4)
    Case Chr$(0)+Chr$(147) ' control-delete
       If Logged.In Then ' lockout user
          If User.Index>SFalse Then
             Close #TempFile1
             Open DND.Path+"delete.log" For Append Shared As #TempFile1
             Print #TempFile1,Lcase$(Rtrim$(UserRecord.CodeName))
             Print #TempFile1,Fclock$+" ("+DateS$+")"
             Print #TempFile1,"Locked out."
             Close #TempFile1
             Strng=Nul
             Call IO.O
             Graphics.Off=True
             Strng="User locked out: "+Fclock$+"."
             Call IO.O
             Graphics.Off=False
             Call Hang.Up(4)
          Endif
       Endif
    End Select
    Call Release.Time(1)
 Loop
Error.Resume4:
 Exit Sub
Error.Trap4:
 Resume Error.Resume4
End Sub

Sub Take.All.Objects(VarQ)
 On Local Error Goto ErrTrap25a
 VarQ=False
 Temp6=False
 Temp7!=SFalse
 Temp5!=RoomRecord.First
 If Temp5! Then
    Do While Lost.Carrier=False
       Call Read.Record(RoomInvFile,Temp5!)
       If MessWorkRecord6.Room=SFalse Then
          Exit Do
       Endif
       Temp6!=MessWorkRecord6.Next
       TempA!=MessWorkRecord6.Index
       If TempA!>SFalse And TempA!<=Lof(TreasureFile)/TreasureRecLen Then
          Call Read.Record(TreasureFile,TempA!)
          Out3=TreasureRecord.TreasureName
          Out3=Rtrim$(Out3)
          Temp7!=TempA!
          Temp6=MessWorkRecord6.Charges
          Temp4=False
          If TreasureRecord.Coin Then
             Strng2=Rtrim$(TreasureRecord.Prefix1)
             Strng3=Lcase$(Out3)
             Call Delete.List.Node(Temp5!)
             Call Clear.List.Node
             Call Write.Record(RoomInvFile,Temp5!)
             Graphics.Off=False
             Strng="You take "+Strng2+Strng3
             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=True
             Graphics.On=True
             Call IO.O
             Graphics.On=False
             Graphics.Off=True
             Strng="!"
             Call IO.O
             Graphics.Off=False
             If TreasureRecord.Gold>0# Then
                UserRecord.Gold=UserRecord.Gold+TreasureRecord.Gold
                Select Case UserRecord.Gold
                Case 1
                   Strng="You now have one gold.."
                Case 2 To 10
                   Strng="You now have "+Rtrim$(Numeral(UserRecord.Gold))+" gold."
                Case Is>10
                   Call Amount4(UserRecord.Gold,Var$)
                   Strng="You now have"+Var$+" gold!"
                End Select
                Call IO.O
             Endif
             VarQ=True
          Endif
       Endif
       If Temp6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Temp6!
    Loop
 Endif
 Temp6=False
 Temp7!=SFalse
 Temp5!=RoomRecord.First
 If Temp5! Then
    Do While Lost.Carrier=False
       Call Read.Record(RoomInvFile,Temp5!)
       If MessWorkRecord6.Room=SFalse Then
          Exit Do
       Endif
       Temp6!=MessWorkRecord6.Next
       TempA!=MessWorkRecord6.Index
       If TempA!<SFalse Then
          Call Read.Record(ObjectFile,Abs(TempA!))
          Out3=ObjectRecord.ObjectName
          Out3=Rtrim$(Out3)
          Temp7!=TempA!
          Temp6=MessWorkRecord6.Charges
          If ObjectRecord.Permanent=False Then
             Graphics.Off=False
             Strng2=Rtrim$(ObjectRecord.Prefix1)
             Out3=Lcase$(Out3)
             Strng="You take "+Strng2+Out3
             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=True
             Graphics.On=True
             Call IO.O
             Strng=Nul
             If ObjectRecord.Invisible Then
                Strng=" [inv]"
             Endif
             Graphics.On=False
             Graphics.Off=True
             Strng=Strng+"!"
             Call IO.O
             Graphics.Off=False
             Call Add.Inventory(Temp7!,Temp6)
             Call Delete.List.Node(Temp5!)
             Call Clear.List.Node
             Call Write.Record(RoomInvFile,Temp5!)
             VarQ=True
          Endif
       Endif
       If TempA!>SFalse And TempA!<=Lof(TreasureFile)/TreasureRecLen Then
          Call Read.Record(TreasureFile,TempA!)
          Out3=TreasureRecord.TreasureName
          Out3=Rtrim$(Out3)
          Temp7!=TempA!
          Temp6=MessWorkRecord6.Charges
          Temp4=False
          If UserRecord.Encumbrance>=False Then
             Temp1#=Cdbl(Weight+TreasureRecord.Weight)
             Temp2#=Cdbl(UserRecord.Stats(1))*Cdbl(UserRecord.Encumbrance)
             If Temp1#>Temp2# Then
                Strng="You can't carry any more!"
                Call IO.O
                Exit Do
             Endif
          Endif
          TempQ1=True
          If TreasureRecord.Permanent Then
             If Normal.User Then
                TempQ1=False
             Else
                If Config2(138)=False Then
                   TempQ1=False
                Endif
             Endif
          Endif
          TempZ=0
          If TreasureRecord.Invisible Then
             TempZ=-1
             If Normal.User Then
                TempQ1=False
             Else
                If Config2(139)=False Then
                   TempQ1=False
                Endif
             Endif
          Endif
          If MessWorkRecord6.Plus=Hidden.Object Then
             TempZ=-1
             If Normal.User Then
                TempQ1=False
             Else
                If Config2(140)=False Then
                   TempQ1=False
                Endif
             Endif
          Endif
          If TreasureRecord.Vehicle Then
             Var2!=MessWorkRecord6.User
             If Var2!>SFalse And Var2!<=Lof(UserFile)/UserRecLen Then
                TempQ1=False
             Endif
          Endif
          If TempQ1 Then
             Strng2=Rtrim$(TreasureRecord.Prefix1)
             Strng3=Lcase$(Out3)
             TempZ2=0
             If TreasureRecord.LightType Then
                If MessWorkRecord6.Charges<False Then
                   TempZ2=-1
                Endif
             Endif
             Call Add.Inventory(Temp7!,Temp6)
             Call Delete.List.Node(Temp5!)
             Call Clear.List.Node
             Call Write.Record(RoomInvFile,Temp5!)
             Graphics.Off=False
             Strng="You take "+Strng2+Strng3
             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=True
             Graphics.On=True
             Call IO.O
             Graphics.On=False
             Graphics.Off=True
             Strng=Nul
             If TempZ2 Then
                Strng=" [lit]"
             Endif
             If TempZ Then
                Strng=Strng+" [inv]"
             Endif
             Strng=Strng+"!"
             Call IO.O
             Graphics.Off=False
             VarQ=True
          Endif
       Endif
       If Temp6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Temp6!
    Loop
 Endif
 If Config2(142) Then
    Temp6=False
    Temp7!=SFalse
    TempA!=SFalse
    Temp5!=RoomRecord.First2
    If Temp5! Then
       Do While Lost.Carrier=False
          Call Read.Record(ContainerFile,Temp5!)
          Var6!=ContainerRecord.Next
          If ContainerRecord.DeletedContainer=False Then
             If ContainerRecord.WithinContainer=SFalse Then
                Out3=ContainerRecord.ContainerName
                Out3=Rtrim$(Out3)
                TempA!=Temp5!
                Call Get.Container2(VarZ)
                If VarZ Then
                   VarQ=True
                Endif
             Endif
          Endif
          If Var6!=SFalse Then
             Exit Do
          Endif
          Temp5!=Var6!
       Loop
    Endif
 Endif
ErrResume25a:
 Exit Sub
ErrTrap25a:
 Resume ErrResume25a
End Sub

Sub Get.Container2(Var9)
 On Local Error Goto ErrTrap42a
 Var9=False
 If UserRecord.Encumbrance>=False Then
    Temp1#=Cdbl(Weight+ContainerRecord.Weight)
    Temp2#=Cdbl(UserRecord.Stats(1))*Cdbl(UserRecord.Encumbrance)
    If Temp1#>Temp2# Then
       Exit Sub
    Endif
 Endif
 If ContainerRecord.InvisibleContainer Then
    If Sysop Then
       TempZ=-1
    Else
       Exit Sub
    Endif
 Endif
 Strng2=Rtrim$(ContainerRecord.Prefix1)
 Strng3=Lcase$(Out3)
 Call Delete.Room.Container(TempA!)
 Call Read.Record(ContainerFile,TempA!)
 ContainerRecord.UserNumber=User.Index
 ContainerRecord.RoomNumber=SFalse
 ContainerRecord.InvisibleContainer=False
 Call Add.User.Container(TempA!)
 Weight=Weight+ContainerRecord.Weight
 Graphics.Off=False
 Strng="You take "+Strng2+Strng3
 Call Convert.ANSI(True,VarQ,VarR)
 Carriage.Return=True
 Graphics.On=True
 Call IO.O
 Graphics.On=False
 Graphics.Off=True
 Strng=Nul
 If TempZ Then
    Strng=" [inv]"
 Endif
 Strng=Strng+"!"
 Call IO.O
 Graphics.Off=False
 Var9=True
ErrResume42a:
 Exit Sub
ErrTrap42a:
 Resume ErrResume42a
End Sub

Sub Amount4(Var#,Var$)
 VarX$=Ltrim$(Str$(Var#)) ' 1.111D308
 V=Instr(VarX$,"D")
 If V Then
    If Mid$(VarX$,2,1)="." Then
       VarX$=Left$(VarX$,1)+Mid$(VarX$,V)
    Endif
    Var$=" "+VarX$
 Else
    Var$=" "+Form$(Var#)
 Endif
End Sub
