 Rem File: Spell.bas - for Cmd*.bas modules
 Rem $Include: 'dndbbs.inc'

' VarZZ=-1 cast/0 error
Sub Attack.Monster(VarZZ)
 On Local Error Goto ErrorTrap1
 Gosub Get.Config
 VarZZ=True
 Prefix1=Nul
 User.Temp=SFalse
 Monster.Temp=SFalse
 Parse.Temp2=Parse.Temp
 If Magic.Spell=CurePoison Then
    Eat$ = Nul
 Else
    If Intoxicated>False Then
       Strng="You are too drunk to fight!"
       Call IO.O
       VarZZ=0
       Exit Sub
    Endif
    Call Safe.Room
    If TempA Then
       Strng="This is a safe haven!"
       Call IO.O
       VarZZ=0
       Exit Sub
    Endif
 Endif
 If Params=False Then
    Parse.Temp=Last.Monster.Temp
 Endif
 Last.Monster.Temp=Parse.Temp
 ' online user
 Call Search.Mess(SFalse)
 Var1=TempC
 If Temp!=Room Then
    If TempB!=User.Index Then ' self
       If Magic.Spell Then
          If Magic.Spell=Damnate Then
             Graphics.Off=True
             Strng="Evil Laughter Sounds From Above..."
             Call IO.O
             Strng="   A Bolt of Lightning Strikes..."
             Call IO.O
             Graphics.Off=False
             Message1="You just killed yourself!"
             Strng="was damnated"
             Call Update.DayFile(Strng,False,1)
             Call Player.Died
             Exit Sub
          Else
             If Magic.Spell=Resurrect Then
                Graphics.Off=True
                Strng="Evil Laughter Sounds From Above..."
                Call IO.O
                Strng="   A Bolt of Lightning Strikes..."
                Call IO.O
                Graphics.Off=False
                If UserRecord.Level<MaxInt Then
                   UserRecord.Level=UserRecord.Level+1
                   Call Write.Record(UserFile,User.Index)
                   Call New.Stats
                   Strng="User is increased 1 level!"
                   Call IO.O
                Else
                   Strng="Nothing happened!"
                   Call IO.O
                Endif
                Exit Sub
             Else
                If Magic.Spell=GrantWish Then
                   Graphics.Off=True
                   Strng="Evil Laughter Sounds From Above..."
                   Call IO.O
                   Strng="   A Bolt of Lightning Strikes..."
                   Call IO.O
                   Graphics.Off=False
                   If UserRecord.WishsLeft=True Then
                      Strng="Nothing happens!
                   Else
                      If UserRecord.WishsLeft<MaxInt Then
                         UserRecord.WishsLeft=UserRecord.WishsLeft+1
                         Call Write.Record(UserFile,User.Index)
                         Strng="Ypu were just granted a wish!"
                         Call IO.O
                      Else
                         Strng="Nothing happened!"
                         Call IO.O
                      Endif
                   Endif
                   Exit Sub
                Else
                   Strng="Nothing happened!"
                   Call IO.O
                   Exit Sub
                Endif
             Endif
          Endif
       Endif
       Graphics.Off=False
       Strng="Punch! You hit yourself in the face!"
       Call IO.O
       Select Case Rnd
       Case Is>.99
          Strng="You knocked your front two teeth out!"
          Call IO.O
       Case Is>.98
          Strng="You blackened your left eye!"
          Call IO.O
       Case Is>.9
          Strng="You hurt your nose!"
          Call IO.O
       End Select
       Exit Sub
    Endif
    If MessWorkRecord1.Monitor Then
       Graphics.Off=False
       Strng="That player isn't here!"
       Call IO.O
       VarZZ=0
       Exit Sub
    Endif
    User.Temp=TempB!
    Out3=MessWorkRecord1.UserName
    Out3=Rtrim$(Out3)
    Out3=Lcase$(Out3)
    Last.Command="Attacking"
    Call Update.Mess(4)
    Call Read.Message.Record(MessWorkFile1,Var1+1)
    If MessWorkRecord1.Vitality<=SFalse Then
       Strng="User is dead!"
       Call IO.O
       VarZZ=0
       Exit Sub
    Endif
    Call Read.Record(UserFile2,TempB!)
    If UserRecord2.Level=False Then
       Strng="User is dead!"
       Call IO.O
       VarZZ=0
       Exit Sub
    Endif
    If Magic.Spell Then
       Select Case Magic.Spell
       Case Resurrect
          Call Resurrect.Game.Player
          Exit Sub
       Case Damnate
          Call Damn.Game.Player
          Exit Sub
       Case GrantWish
          If UserRecord2.WishsLeft=True Then
             Strng="Didn't work!"
             Call IO.O
             Exit Sub
          Endif
          If UserRecord2.WishsLeft=MaxInt Then
             Strng="Didn't work!"
             Call IO.O
             Exit Sub
          Endif
          Call Grant.Game.Player
          Exit Sub
       Case StealWish
          If UserRecord2.WishsLeft=0 Then
             Strng="Didn't work!"
             Call IO.O
             Exit Sub
          Endif
          Call Steal.Game.Player
          Exit Sub
       Case CurePoison
          If UserRecord2.Poison=False Then
             Strng="Didn't work!"
             Call IO.O
             Exit Sub
          Endif
          UserRecord2.Poison=False
          Call Write.Record(UserFile2,User.Temp)
          Strng="You curepoison "+Out3+"!"
          Call IO.O
          Out2="You've been curepoisoned!"
          Call Send.Mess(5,User.Temp,Room,Out2)
          Exit Sub
       Case Poison
          Out4=UserRecord2.CodeName
          Out4=Rtrim$(Out4)
          Out4=Lcase$(Out4)
          If Len(Out4) Then
             Mid$(Out4,1,1)=Ucase$(Mid$(Out4,1,1))
          Endif
          If UserRecord2.Poison Then
             Strng="Didn't work!"
             Call IO.O
             Exit Sub
          Endif
          If Len(option1$) Then
             Out2=option1$
             Call Equate(Temp#)
          Else
             Temp#=Rnd>.5
          Endif
          If Temp# Then
             Strng="Didn't work!"
             Call IO.O
             Exit Sub
          Endif
          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.Hits3(True)
                Call Write.Record(UserFile2,User.Temp)
             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.Hits3(False)
                   Call Write.Record(UserFile2,User.Temp)
                Endif
             Endif
          Endif
          If VarX=False Then
             UserRecord2.Poison=True
             Call Write.Record(UserFile2,User.Temp)
             Strng="You poison "+Out3+"!"
             Call IO.O
             Out2="You've been poisoned!"
             Call Send.Mess(5,User.Temp,Room,Out2)
          Endif
          Exit Sub
       End Select
       Strng="Nothing happened!"
       Call IO.O
       Exit Sub
    Endif
    Call Hit.Game.Player
    Exit Sub
 Endif
 ' offline user
 Call Num2
 Call Check.User
 If User.Temp Then
    If Magic.Spell Then
       Select Case Magic.Spell
       Case CurePoison
          If UserRecord2.Poison=False Then
             Strng="Didn't work!"
             Call IO.O
             Exit Sub
          Endif
          UserRecord2.Poison=False
          Call Write.Record(UserFile2,MessWorkRecord4.Index)
          Strng="You curepoison "+Out3+"!"
          Call IO.O
          Exit Sub
       End Select
    Endif
    Var3=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!=MessWorkRecord4.Index Then
                Var3=True
                Exit For
             Endif
          Next
          If Var3 Then
             Exit For
          Endif
       Endif
    Next
    If Magic.Spell=GrantWish Or Magic.Spell=Resurrect Or Magic.Spell=StealWish Then
       Goto Next.Spell
    Endif
    If Var3 Then
       For VarY=1 To MaxTeamMembers
          Var2!=TeamRecord.UserIndex(VarY)
          If Var2!=User.Index Then
             Strng="You can't! That's a team member!"
             Call IO.O
             VarZZ=0
             Exit Sub
          Endif
       Next
    Endif
    Out3=Lcase$(Out3)
    If MessWorkRecord4.Align1+MessWorkRecord4.Align2<False Then
       If UserRecord2.Align1+UserRecord2.Align2<False Then
          Strng="Your alignment might change!"
          Call IO.O
       Endif
    Endif
    User.Attacked=User.Temp
    Last.Command="Attacking"
    Call Update.Mess(4)
Next.Spell:
    If Magic.Spell Then
       Select Case Magic.Spell
       Case Resurrect
          Call Resurrect.User
          Exit Sub
       Case Damnate
          Call Damn.User
          Exit Sub
       Case GrantWish
          Call Grant.User
          Exit Sub
       Case StealWish
          Call Steal.User
          Exit Sub
       Case Poison
          Out4=UserRecord2.CodeName
          Out4=Rtrim$(Out4)
          Out4=Lcase$(Out4)
          If Len(Out4) Then
             Mid$(Out4,1,1)=Ucase$(Mid$(Out4,1,1))
          Endif
          If UserRecord2.Poison Then
             Strng="Didn't work!"
             Call IO.O
             Exit Sub
          Endif
          If Len(option1$) Then
             Out2=option1$
             Call Equate(Temp#)
          Else
             Temp#=Rnd>.5
          Endif
          If Temp# Then
             Strng="Didn't work!"
             Call IO.O
             Exit Sub
          Endif
          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.Hits3(True)
                Call Write.Record(UserFile2,MessWorkRecord4.Index)
             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.Hits3(False)
                   Call Write.Record(UserFile2,MessWorkRecord4.Index)
                Endif
             Endif
          Endif
          If VarX=False Then
             UserRecord2.Poison=True
             Call Write.Record(UserFile2,MessWorkRecord4.Index)
             Strng="You poison "+Out3+"!"
             Call IO.O
          Endif
          Exit Sub
       End Select
       Strng="Nothing happened!"
       Call IO.O
       Exit Sub
    Endif
    Call Hit.User
    Exit Sub
 Endif
 Previous.Command=False
 Call Num
 Call Check.Monster
 If Monster.Temp=SFalse Then
    If Params=False Then
       Call Get.Last.Monster(Var)
       If Var Then
          Parsed.Command1=Last.Monster
       Endif
    Endif
    If Monster.Temp=SFalse Then
       Call Check.Room.Items
       If Temp7!<SFalse Then
          If ObjectRecord.JailTrap Then
             Call Jail
             Exit Sub
          Endif
          Strng="Nothing happens.."
          Call IO.O
          Exit Sub
       Endif
       Strng="You can't attack that!"
       Call IO.O
       VarZZ=0
       Exit Sub
    Endif
 Endif
 If MessWorkRecord3.Monster.Jail Then
    Call Jail
    Exit Sub
 Endif
 Monster.Attacked=Monster.Temp
 Last.Command="Attacking"
 Call Update.Mess(4)
 Call The.Or.An
 Out3=MessWorkRecord3.Monster.MonsterName
 Out3=Rtrim$(Out3)
 Out3=Lcase$(Out3)
 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.AttackMonster(Var2)=MessWorkRecord3.Index Then
       Out3="As you attack it,"
       Out4="The monster hits you for"
       Call Actions(Var!)
    Endif
 Endif
 Select Case Last.Command.Number
 Case Charm
    If MessWorkRecord3.Monster.Magic<=True Then
       Strng="Didn't work!"
       Call IO.O
       Exit Sub
    Endif
    If Len(option6$) Then
       Out2=option6$
       Call Equate(Temp#)
    Else
       Temp#=Int(Rnd*10+4)>UserRecord.Beauty
    Endif
    If Temp# Then
       Strng="Didn't work!"
       Call IO.O
       Exit Sub
    Endif
    MessWorkRecord3.Monster.Magic=5
    Call Write.Record(MessWorkFile3,Monster.Temp)
    Strng="It worked!"
    Call IO.O
    Exit Sub
 Case Beguile
    If Len(option7$) Then
       Out2=option7$
       Call Equate(Temp#)
    Else
       Temp#=Int(Rnd*12+5)>(UserRecord.Beauty+UserRecord.Glamour)
    Endif
    If Temp# Then
       Strng="Didn't work!"
       Call IO.O
       Exit Sub
    Endif
    Call Monster.Died
    Exit Sub
 Case Circled
    If MessWorkRecord3.Monster.Magic<=True Then
       Strng="Didn't work!"
       Call IO.O
       Exit Sub
    Endif
    If Config2(63) Then
       Out2=Config3(35)
       Call Equate(Temp#)
    Else
       Temp#=(Rnd*5+UserRecord.Level)>MessWorkRecord3.Monster.Level
    Endif
    If Temp# Then
       Previous.Command=True
       MessWorkRecord3.Monster.Magic=4
       Call Write.Record(MessWorkFile3,Monster.Temp)
       Strng="It worked!"
       Call IO.O
       Exit Sub
    Endif
    Strng="Didn't work!"
    Call IO.O
    Exit Sub
 Case Feint
    If MessWorkRecord3.Monster.Magic<=True Then
       Strng="Didn't work!"
       Call IO.O
       Exit Sub
    Endif
    If Config2(63) Then
       Out2=Config3(34)
       Call Equate(Temp#)
    Else
       Temp#=UserRecord.Stats(4)>(Rnd*5+MessWorkRecord3.Monster.Level/2)
    Endif
    If Temp# Then
       Previous.Command=Last.Command.Number
       MessWorkRecord3.Monster.Magic=3
       Call Write.Record(MessWorkFile3,Monster.Temp)
       Strng="It worked!"
       Call IO.O
       Exit Sub
    Endif
    Strng="Didn't work!"
    Call IO.O
    Exit Sub
 Case Resist, Parry
    Previous.Command=Last.Command.Number
    Strng="It worked!"
    Call IO.O
    Exit Sub
 Case Turn
    Magic.Spell=TurnUndead
 Case Bemuse
    If MessWorkRecord3.Monster.LevelDrain Then
       Strng="Didn't work!"
       Call IO.O
       Exit Sub
    Endif
    If Len(option8$) Then
       Out2=option8$
       Call Equate(Temp#)
    Else
       Temp#=Int(Rnd*8+5)>UserRecord.Glamour
    Endif
    If Temp# Then
       Strng="Didn't work!"
       Call IO.O
       Exit Sub
    Endif
    MessWorkRecord3.Monster.Level=MessWorkRecord3.Monster.Level-1
    Call Write.Record(MessWorkFile3,Monster.Temp)
    Strng="You drain a level from the "+Out3+"!"
    Call IO.O
    If MessWorkRecord3.Monster.Level<=False Then
       Strng="You killed the "+Out3+"!"
       Call IO.O
       Call Monster.Died
       Exit Sub
    Endif
    Exit Sub
 Case Befuddle
    If MessWorkRecord3.Monster.Magic<=True Then
       Strng="Didn't work!"
       Call IO.O
       Exit Sub
    Endif
    If Len(option5$) Then
       Out2=option5$
       Call Equate(Temp#)
    Else
       Temp#=(UserRecord.Stats(3)+UserRecord.Stats(4))>(Rnd*10+MessWorkRecord3.Monster.Level/2)
    Endif
    If Temp# Then
       Previous.Command=True
       MessWorkRecord3.Monster.Magic=6
       Call Write.Record(MessWorkFile3,Monster.Temp)
       Strng="It worked!"
       Call IO.O
       Exit Sub
    Endif
    Strng="Didn't work!"
    Call IO.O
    Exit Sub
 Case Lunge, Dodge
    If UserRecord.Weapon(5).Index Then
       Strng="You must return your shield!"
       Call IO.O
       VarZZ=0
       Exit Sub
    Endif
 Case Beat, Punch
    If UserRecord.Weapon(7).Index Then
       Strng="You must return your weapon!"
       Call IO.O
       VarZZ=0
       Exit Sub
    Endif
 Case Shield, Guard
    If UserRecord.Weapon(5).Index Then
       Previous.Command=True
       Strng="It worked!"
       Call IO.O
       Exit Sub
    Endif
    Previous.Command=False
    Strng="You are not holding a shield!"
    Call IO.O
    VarZZ=0
    Exit Sub
 End Select
 If Magic.Spell Then
    Select Case Magic.Spell
    Case Resurrect
       Call Resurrect.Monster
       Exit Sub
    Case Damnate
       Call Damn.Monster
       Exit Sub
    Case CurePoison
       If MessWorkRecord3.Monster.Poison<=False Then
          Strng="Didn't work!"
          Call IO.O
          Exit Sub
       Endif
       MessWorkRecord3.Monster.Poison=False
       Call Write.Record(MessWorkFile3,Monster.Temp)
       Strng="You curepoison the "+Out3+"!"
       Call IO.O
       Exit Sub
    Case Poison
       If MessWorkRecord3.Monster.Poison Then
          Strng="Didn't work!"
          Call IO.O
          Exit Sub
       Endif
       If Len(option1$) Then
          Out2=option1$
          Call Equate(Temp#)
       Else
          Temp#=Rnd>.5
       Endif
       If Temp# Then
          Strng="Didn't work!"
          Call IO.O
          Exit Sub
       Endif
       MessWorkRecord3.Monster.Poison=UserRecord.Level
       Call Write.Record(MessWorkFile3,Monster.Temp)
       Strng="You poison the "+Out3+"!"
       Call IO.O
       Exit Sub
    Case LevelDrain
       If MessWorkRecord3.Monster.LevelDrain Then
          Strng="Didn't work!"
          Call IO.O
          Exit Sub
       Endif
       If Len(option2$) Then
          Out2=option2$
          Call Equate(Temp#)
       Else
          Temp#=Rnd>.5
       Endif
       If Temp# Then
          Strng="Didn't work!"
          Call IO.O
          Exit Sub
       Endif
       MessWorkRecord3.Monster.Level=MessWorkRecord3.Monster.Level-1
       Call Write.Record(MessWorkFile3,Monster.Temp)
       Strng="You drain a level from the "+Out3+"!"
       Call IO.O
       If MessWorkRecord3.Monster.Level<=False Then
          Strng="You killed the "+Out3+"!"
          Call IO.O
          Call Monster.Died
       Endif
       Exit Sub
    Case Befuddled
       If MessWorkRecord3.Monster.Magic<=True Then
          Strng="Didn't work!"
          Call IO.O
          Exit Sub
       Endif
       If Len(option3$) Then
          Out2=option3$
          Call Equate(Temp#)
       Else
          Temp#=Rnd>.5
       Endif
       If Temp# Then
          Strng="Didn't work!"
          Call IO.O
          Exit Sub
       Endif
       MessWorkRecord3.Monster.Magic=4
       Call Write.Record(MessWorkFile3,Monster.Temp)
       Strng="It worked!"
       Call IO.O
       Exit Sub
    Case TurnUndead
       If MessWorkRecord3.Monster.LevelDrain=False Then
          Strng="That's not undead!"
          Call IO.O
          VarZZ=0
          Exit Sub
       Endif
       If Config2(63) Then
          Out2=Config3(33)
          Call Equate(Temp#)
       Else
          Temp#=(Rnd*UserRecord.Level+2)>MessWorkRecord3.Monster.Level
       Endif
       If Temp# Then
          Strng="You damned the "+Out3+"!"
          Call IO.O
          MessWorkRecord3.Monster.Level=MessWorkRecord3.Monster.Level-1
          Call Write.Record(MessWorkFile3,Monster.Temp)
          Strng="You drain a level from the "+Out3+"!"
          Call IO.O
          If MessWorkRecord3.Monster.Level<=False Then
             Strng="You killed the "+Out3+"!"
             Call IO.O
             Call Monster.Died
             Exit Sub
          Endif
       Endif
       Strng="Didn't work!"
       Call IO.O
       Exit Sub
    Case Intoxicate
       If Len(option4$) Then
          Out2=option4$
          Call Equate(Temp#)
       Else
          Temp#=Rnd>.5
       Endif
       If Temp# Then
          Strng="Didn't work!"
          Call IO.O
          Exit Sub
       Endif
       MessWorkRecord3.Monster.Magic=3
       Call Write.Record(MessWorkFile3,Monster.Temp)
       Strng="It worked!"
       Call IO.O
       Exit Sub
    End Select
 Endif
 If Magic.Spell=False Then
    If UserRecord.Fatigue<=False Then
       UserRecord.Fatigue=False
       Strng="You are too exhausted to fight!"
       Call IO.O
       VarZZ=0
       Exit Sub
    Endif
    If MessWorkRecord3.Monster.Magic<=True Then
       Strng="A magical force prevents your attack!"
       Call IO.O
       VarZZ=0
       Exit Sub
    Endif
 Endif
 If MessWorkRecord3.Monster.Permanent<True Then
    Strng="A mysterious force prevents your attack!"
    Call IO.O
    VarZZ=0
    Exit Sub
 Endif
 Select Case Last.Command.Number
 Case Shield, Guard
    If UserRecord.Weapon(5).Index Then
       Previous.Command=True
       Strng="It worked!"
       Call IO.O
       Exit Sub
    Endif
    Previous.Command=False
    Strng="You are not holding a shield!"
    Call IO.O
    VarZZ=0
    Exit Sub
 End Select
 If Config2(63) Then
    Out2=Config3(32)
    Call Equate(Temp#)
 Else
    Temp#=(Rnd*10+MessWorkRecord3.Monster.Level/10)>UserRecord.Stats(4)/2
 Endif
 If Temp# Then
    If Magic.Spell Then
       Strng="You missed!"
       Call IO.O
       Exit Sub
    Endif
    If Config2(63) Then
       Out2=Config3(36)
       Call Equate(Temp#)
    Else
       Temp#=(Rnd*10+5)>UserRecord.Stats(4)*2
    Endif
    If Temp# Then
       Call Fumble
    Endif
    Graphics.Off=False
    Strng="You missed the "+Out3+"!"
    Call IO.O
    Call Team.Hit.Monster
    Exit Sub
 Endif
 Strng=Nul
 If Magic.Spell=False Then
    Select Case UserRecord.Weapon(7).Plus
    Case False
       Strng="Punch!"
       Multiplier=Config2(43)
    Case Else
       Select Case Rnd
       Case Is>Config1(25)
          Strng="Deathly damage!"
          Multiplier=Config2(40)
       Case Is>Config1(26)
          Strng="Triple damage!"
          Multiplier=Config2(41)
       Case Is>Config1(27)
          Strng="Double damage!"
          Multiplier=Config2(42)
       End Select
    End Select
 Endif
 Select Case Last.Command.Number
 Case Attack, Killed
    If Strng<>Nul Then
       Call IO.O
    Endif
 Case Lunge, Dodge
    Multiplier=2
    Previous.Command=Last.Command.Number
 Case Backstab
    If Hidden.Player Then
       Multiplier=Multiplier+1
    Else
       Strng="The "+Out3+" sees you!"
       Call IO.O
       Multiplier=Multiplier-1
    Endif
 Case Thrust
    Multiplier=Multiplier+1
    Previous.Command=Last.Command.Number
 Case Charge
    Strng="Argh! You charge towards the "+Out3+"!"
    Call IO.O
    Multiplier=Multiplier+1
    Previous.Command=Last.Command.Number
 Case Counter
    Multiplier=Multiplier+1
 Case Pummel
    Strng="Your fists fly at the monster!"
    Call IO.O
    Multiplier=Config2(42)
 Case Launch
    Multiplier=Multiplier+2
 Case Beat, Punch
    Multiplier=2
    Previous.Command=Last.Command.Number
 Case Bewitch
    Multiplier=Multiplier+1
    Previous.Command=Last.Command.Number
 Case Bewilder
    Multiplier=Multiplier+1
    Previous.Command=Last.Command.Number
 End Select
 If Magic.Spell=False Then
    If Last.Command.Number=Launch Or Last.Command.Number=Fire Then
       Eat$ = Nul
    Else
       Var1!=UserRecord.Weapon(7).Index
       If Var1! Then
          Var2=UserRecord.Weapon(7).Charges
          Var2=Var2-1
          UserRecord.Weapon(7).Charges=Var2
          If Var2<=False Then
             Call Read.Record(TreasureFile,Var1!)
             Out2=TreasureRecord.ShortName
             Out2=Rtrim$(Out2)
             Out2=Lcase$(Out2)
             Strng="Your "+Out2+" breaks in half!"
             Call IO.O
             Call Add.Inventory(Var1!,Var2)
             UserRecord.Weapon(7).Index=SFalse
             UserRecord.Weapon(7).Charges=False
             UserRecord.Weapon(7).Plus=False
             Call Discard(Temp0!,False)
          Endif
       Endif
    Endif
 Endif
 Magic.Spell=True
 Call Hit.Monster
 Exit Sub
Get.Config:
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[SPELL]" 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 "poison.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 "level.drain.equation"
                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 "befuddle.spell.equation"
                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 "intoxicate.equation"
                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
             Case "befuddle.attack.equation"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option5$=Mid$(Var3$,2)
                      option5$=Left$(option5$,Len(option5$)-1)
                   Endif
                Endif
             Case "charm.attack.equation"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option6$=Mid$(Var3$,2)
                      option6$=Left$(option6$,Len(option6$)-1)
                   Endif
                Endif
             Case "beguile.attack.equation"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option7$=Mid$(Var3$,2)
                      option7$=Left$(option7$,Len(option7$)-1)
                   Endif
                Endif
             Case "bemuse.attack.equation"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option8$=Mid$(Var3$,2)
                      option8$=Left$(option8$,Len(option8$)-1)
                   Endif
                Endif
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrorResume1:
 Exit Sub
ErrorTrap1:
 Resume ErrorResume1
End Sub

' online user
Sub Damn.Game.Player
 On Local Error Goto ErrorTrap1a
 Out3=MessWorkRecord1.UserName
 Out2="Evil Laughter Sounds From Above..."
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Out2="   A Bolt of Lightning Strikes..."
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Out3=Rtrim$(Out3)
 Out3=Lcase$(Out3)
 Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
 Out2=Out3+" was just struck dead!"
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Call Send.Mess(17,TempB!,Room,"Damned")
ErrorResume1a:
 Exit Sub
ErrorTrap1a:
 Resume ErrorResume1a
End Sub

' online user
Sub Steal.Game.Player
 On Local Error Goto ErrorTrap11z
 If UserRecord2.WishsLeft=0 Then
    Strng="Nothing happens!"
    Call IO.O
    Exit Sub
 Endif
 If UserRecord.WishsLeft=-1 Then
    Strng="Nothing happens!"
    Call IO.O
    Exit Sub
 Endif
 If UserRecord.WishsLeft=MaxInt Then
    Strng="Nothing happens!"
    Call IO.O
    Exit Sub
 Endif
 UserRecord.WishsLeft=UserRecord.WishsLeft+1
 Out3=MessWorkRecord1.UserName
 Out2="Evil Laughter Sounds From Above..."
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Out2="   A Bolt of Lightning Strikes..."
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Out3=Rtrim$(Out3)
 Out3=Lcase$(Out3)
 Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
 Out2=Out3+" was just robbed of a wish!"
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Call Send.Mess(40,TempB!,Room,"StealWish")
ErrorResume11z:
 Exit Sub
ErrorTrap11z:
 Resume ErrorResume11z
End Sub

' online user
Sub Grant.Game.Player
 On Local Error Goto ErrorTrap1az
 Out3=MessWorkRecord1.UserName
 Out2="Evil Laughter Sounds From Above..."
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Out2="   A Bolt of Lightning Strikes..."
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Out3=Rtrim$(Out3)
 Out3=Lcase$(Out3)
 Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
 Out2=Out3+" was just granted a wish!"
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Call Send.Mess(39,TempB!,Room,"GrantedWish")
ErrorResume1az:
 Exit Sub
ErrorTrap1az:
 Resume ErrorResume1az
End Sub

' online user
Sub Resurrect.Game.Player
 On Local Error Goto ErrorTrap1ax
 Out3=MessWorkRecord1.UserName
 Out2="Evil Laughter Sounds From Above..."
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Out2="   A Bolt of Lightning Strikes..."
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Out3=Rtrim$(Out3)
 Out3=Lcase$(Out3)
 Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
 Out2=Out3+" increased one level!"
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Call Send.Mess(39,TempB!,Room,"Resurrected")
ErrorResume1ax:
 Exit Sub
ErrorTrap1ax:
 Resume ErrorResume1ax
End Sub

' offline user
Sub Damn.User
 On Local Error Goto ErrorTrap1b
 User.Attacked=User.Temp
 Graphics.Off=True
 Strng="Evil Laughter Sounds From Above..."
 Call IO.O
 Strng="   A Bolt of Lightning Strikes..."
 Call IO.O
 Graphics.Off=False
 Out3=Lcase$(Out3)
 Strng=Out3+" was just struck dead!"
 Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
 Call IO.O
 Call User.Died
ErrorResume1b:
 Exit Sub
ErrorTrap1b:
 Resume ErrorResume1b
End Sub

' offline user
Sub Steal.User
 On Local Error Goto ErrorTrap10z
 Graphics.Off=True
 Strng="Evil Laughter Sounds From Above..."
 Call IO.O
 Strng="   A Bolt of Lightning Strikes..."
 Call IO.O
 Graphics.Off=False
 If UserRecord2.WishsLeft=0 Then
    Strng="Nothing happens!"
    Call IO.O
    Exit Sub
 Endif
 If UserRecord.WishsLeft=-1 Then
    Strng="Nothing happens!"
    Call IO.O
    Exit Sub
 Endif
 If UserRecord.WishsLeft=MaxInt Then
    Strng="Nothing happens!"
    Call IO.O
    Exit Sub
 Endif
 UserRecord.WishsLeft=UserRecord.WishsLeft+1
 Out3=Lcase$(Out3)
 Strng=Out3+" was just robbed of a wish!"
 Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
 Call IO.O
 UserRecord2.WishsLeft=UserRecord2.WishsLeft-1
 Call Write.Record(UserFile2,MessWorkRecord4.Index)
ErrorResume10z:
 Exit Sub
ErrorTrap10z:
 Resume ErrorResume10z
End Sub

' offline user
Sub Grant.User
 On Local Error Goto ErrorTrap1bz
 Graphics.Off=True
 Strng="Evil Laughter Sounds From Above..."
 Call IO.O
 Strng="   A Bolt of Lightning Strikes..."
 Call IO.O
 Graphics.Off=False
 If UserRecord2.WishsLeft=True Then
    Strng="Nothing happens!"
    Call IO.O
    Exit Sub
 Endif
 If UserRecord2.WishsLeft=MaxInt Then
    Strng="Nothing happens!"
    Call IO.O
    Exit Sub
 Endif
 Out3=Lcase$(Out3)
 Strng=Out3+" was just granted a wish!"
 Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
 Call IO.O
 UserRecord2.WishsLeft=UserRecord2.WishsLeft+1
 Call Write.Record(UserFile2,MessWorkRecord4.Index)
ErrorResume1bz:
 Exit Sub
ErrorTrap1bz:
 Resume ErrorResume1bz
End Sub

' offline user
Sub Resurrect.User
 On Local Error Goto ErrorTrap1bx
 Graphics.Off=True
 Strng="Evil Laughter Sounds From Above..."
 Call IO.O
 Strng="   A Bolt of Lightning Strikes..."
 Call IO.O
 Graphics.Off=False
 If UserRecord2.Level<MaxInt Then
    UserRecord2.Level=UserRecord2.Level+1
    Call New.Stats2
    Call Write.Record(UserFile2,MessWorkRecord4.Index)
    Strng="User increased 1 level!"
    Call IO.O
 Else
    Strng="Nothing happened!"
    Call IO.O
 Endif
ErrorResume1bx:
 Exit Sub
ErrorTrap1bx:
 Resume ErrorResume1bx
End Sub

Sub Damn.Monster
 On Local Error Goto ErrorTrap1c
 Monster.Attacked=Monster.Temp
 Graphics.Off=True
 Strng="Evil Laughter Sounds From Above..."
 Call IO.O
 Strng="   A Bolt of Lightning Strikes..."
 Call IO.O
 Graphics.Off=False
 Strng="The "+Out3+" was just struck dead!"
 Call IO.O
 Call The.Or.An
 Call Monster.Died
ErrorResume1c:
 Exit Sub
ErrorTrap1c:
 Resume ErrorResume1c
End Sub

Sub Resurrect.Monster
 On Local Error Goto ErrorTrap1cx
 Monster.Attacked=Monster.Temp
 Graphics.Off=True
 Strng="Evil Laughter Sounds From Above..."
 Call IO.O
 Strng="   A Bolt of Lightning Strikes..."
 Call IO.O
 Graphics.Off=False
 If MessWorkRecord3.Monster.Level<MaxInt Then
    MessWorkRecord3.Monster.Level=MessWorkRecord3.Monster.Level+1
    Strng="Monster increased 1 level!"
    Call IO.O
 Else
    Strng="Nothing happened!"
    Call IO.O
 Endif
 Call Write.Record(MessWorkFile3,Monster.Temp)
ErrorResume1cx:
 Exit Sub
ErrorTrap1cx:
 Resume ErrorResume1cx
End Sub

Sub Jail
 On Local Error Goto ErrorTrap2a
 Strng="You were just thrown in jail!"
 Call IO.O
 Next.Room=Int(Val(Room.Array(12))+.5)
 Out2=UserRecord.CodeName
 Out2=Rtrim$(Out2)
 Out2=Lcase$(Out2)
 Out2=Out2+" was just thrown in jail!"
 Call Send.Mess(8,SFalse,Room,Out2)
 Strng="was thrown in jail"
 Call Update.DayFile(Strng,False,3)
 Action.Recurse=0
 Call Enter.Room
ErrorResume2a:
 Exit Sub
ErrorTrap2a:
 Resume ErrorResume2a
End Sub

Sub Get.Last.Monster(VarX)
 On Local Error Goto Err.Trap26a
 VarX=False
 Call Safe.Room
 If TempA=False Then
    For Temp5!=1! To Lof(MessWorkFile3)/MessWorkRecLen3
       Call Read.Record(MessWorkFile3,Temp5!)
       If MessWorkRecord3.Room=Room Then
          If MessWorkRecord3.Monster.Magic>=False Then
             If MessWorkRecord3.Monster.Permanent>=True Then
                TempA=False
                TempB=False
                Out3=MessWorkRecord3.Monster.MonsterName
                Out3=Rtrim$(Out3)
                Out3=Ucase$(Out3)
                TempA=Instr(TempA+1,Out3," ")
                While TempA
                   TempB=TempA
                   TempA=Instr(TempA+1,Out3," ")
                Wend
                VarX=True
                Last.Monster=Mid$(Out3,TempB+1)
                Monster.Temp=Temp5!
                Exit For
             Endif
          Endif
       Endif
    Next
 Endif
Err.Resume26a:
 Exit Sub
Err.Trap26a:
 Resume Err.Resume26a
End Sub

Sub Check.User
 On Local Error Goto ErrorTrp21
 Temp5!=SFalse
 TempC=False
 User.Temp=SFalse
 If Parsed.Command1<>Nul Then
    For Temp5!=1! To Lof(MessWorkFile4)/MessWorkRecLen4
       Call Read.Record(MessWorkFile4,Temp5!)
       If MessWorkRecord4.Room=Room Then
          Call Read.Record(UserFile2,MessWorkRecord4.Index)
          Out3=UserRecord2.CodeName
          Out3=Rtrim$(Out3)
          Out3=Ucase$(Out3)
          Out2=Left$(Out3,Len(Parsed.Command1))
          If Out2=Parsed.Command1 Then
             TempC=TempC+1
             If Parse.Temp=False Or TempC=Parse.Temp Then
                Out3=UserRecord2.CodeName
                Out3=Rtrim$(Out3)
                User.Temp=Temp5!
                Last.Monster=Parsed.Command1
                Exit For
             Endif
          Endif
       Endif
    Next
 Endif
ErrorRsm21:
 Exit Sub
ErrorTrp21:
 Resume ErrorRsm21
End Sub

' online user
Sub Hit.Game.Player
 On Local Error Goto ErrorTrap7
 Var1=TempC
 Strng=Nul
 Select Case Last.Command.Number
 Case Fire, Launch
    Multiplier=Multiplier+2
 Case Else
    Strng=Nul
    Select Case UserRecord.Weapon(7).Plus
    Case False
       Strng="Punch!"
       Multiplier=Config2(43)
    Case Else
       Select Case Rnd
       Case Is>Config1(25)
          Strng="Deathly damage!"
          Multiplier=Config2(40)
       Case Is>Config1(26)
          Strng="Triple damage!"
          Multiplier=Config2(41)
       Case Is>Config1(27)
          Strng="Double damage!"
          Multiplier=Config2(42)
       End Select
    End Select
 End Select
 If Strng<>Nul Then
    Call IO.O
 Endif
 If Config2(63) Then
    Out2=Config3(30)
    Call Equate(Temp#)
 Else
    Temp#=Int((Rnd*UserRecord.Stats(1)+UserRecord.Level/2)+_
    (Multiplier+(UserRecord.Weapons(UserRecord.Proficiency)/100))+_
    Abs(UserRecord.Weapon(7).Plus))
 Endif
 If Temp#>MaxInt Then
    Temp2=MaxInt
 Else
    Temp2=Int(Temp#)
 Endif
 If Temp2<=False Then
    Strng="You missed!"
    Call IO.O
    Exit Sub
 Endif
 Strng="You hit "+Out3+" for "
 Select Case Temp2
 Case 1
    Strng=Strng+"one hit.."
 Case 2 To 10
    Strng=Strng+Rtrim$(Numeral(Temp2))+" hits!"
 Case Else
    Strng=Strng+Form$(Cdbl(Temp2))+" hits!"
 End Select
 Call IO.O
 Out2=Str$(Temp2)
 Call Send.Mess(9,User.Temp,Room,Out2)
 TempC=Var1
 Call Read.Message.Record(MessWorkFile1,TempC+1)
 Var=Temp2
 If Temp2>False Then
    If MessWorkRecord1.Fatigue-Var>=False Then
       MessWorkRecord1.Fatigue=MessWorkRecord1.Fatigue-Var
       Call Write.Message.Record(MessWorkFile1,TempC+1)
       Exit Sub
    Endif
    Temp2=Temp2-MessWorkRecord1.Fatigue
    MessWorkRecord1.Fatigue=False
    Call Write.Message.Record(MessWorkFile1,TempC+1)
 Endif
 Var1=Abs(Temp2)
 If Var1>False Then
    If MessWorkRecord1.Vitality-Var1<=False Then
       MessWorkRecord1.Vitality=False
       Call Write.Message.Record(MessWorkFile1,TempC+1)
       Exit Sub
    Endif
    MessWorkRecord1.Vitality=MessWorkRecord1.Vitality-Var1
    Call Write.Message.Record(MessWorkFile1,TempC+1)
 Endif
ErrorResume7:
 Exit Sub
ErrorTrap7:
 Resume ErrorResume7
End Sub

' offline user
Sub Hit.User
 On Local Error Goto ErrorTrap5a
 Hidden.Player=False
 Call Write.Record(UserFile,User.Index)
 MessWorkRecord4.Align1=1
 MessWorkRecord4.Align2=1
 Call Write.Record(MessWorkFile4,Temp5!)
 If Config2(63) Then
    Out2=Config3(30)
    Call Equate(Temp#)
 Else
    Temp#=Int((Rnd*UserRecord.Stats(1)+UserRecord.Level/2)+_
    (Multiplier+(UserRecord.Weapons(UserRecord.Proficiency)/100))+_
    Abs(UserRecord.Weapon(7).Plus))
 Endif
 If Temp#>MaxInt Then
    Temp2=MaxInt
 Else
    Temp2=Int(Temp#)
 Endif
 If Temp2<=False Then
    Strng="You missed!"
    Call IO.O
    Exit Sub
 Endif
 Strng="You hit "+Out3+" for "
 Select Case Temp2
 Case 1
    Strng=Strng+"one hit.."
 Case 2 To 10
    Strng=Strng+Rtrim$(Numeral(Temp2))+" hits!"
 Case Else
    Strng=Strng+Form$(Cdbl(Temp2))+" hits!"
 End Select
 Call IO.O
 MessWorkRecord4.Hits=MessWorkRecord4.Hits-Temp2
 Call Write.Record(MessWorkFile4,Temp5!)
 If MessWorkRecord4.Hits<=False Then
    Strng="You just killed "+Out3+"!"
    Call IO.O
    Call User.Died
 Endif
ErrorResume5a:
 Exit Sub
ErrorTrap5a:
 Resume ErrorResume5a
End Sub

Sub User.Died
 On Local Error Goto ErrorTrap6
 VarX!=User.Temp
 Graphics.Off=True
 Last.Command.Number=False
 Out3=Lcase$(Out3)
 Strng="killed "+Out3
 Call Update.DayFile(Strng,False,1)
 Strng=UserRecord.CodeName
 Strng=Rtrim$(Strng)
 Strng=Lcase$(Strng)
 Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
 Out2=Strng+" killed you"
 Temp2!=MessWorkRecord4.Index
 Call Read.Record(UserFile2,Temp2!)
 Call Update.LogFile(Out2,Temp2!)
 If Config2(107) Then
    Call Him.Her
    Strng="On "+Prefix1+" you find "
    Carriage.Return=True
    Call IO.O
    Strng2=Nul
    Temp9=False
    Temp3!=UserRecord2.First ' inventory
    If Temp3! Then
       Do
          Call Read.Record(UserInvFile,Temp3!)
          VarQ!=MessWorkRecord6.Next
          Temp5!=MessWorkRecord6.Index
          If Temp5!>SFalse And Temp5!<=Lof(TreasureFile)/TreasureRecLen Then
             Call Read.Record(TreasureFile,Temp5!)
             Var1=TreasureRecord.Charges
             Call Drop.Inventory(Temp5!,Var1)
             Temp9=Temp9+1
             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=True
             Graphics.On=True
             Call IO.O
             Graphics.On=False
             If Len(Strng2) Then
                Carriage.Return=True
                Strng=Strng2
                Call IO.O
             Endif
             Strng=Rtrim$(TreasureRecord.TreasureName)
             Strng=Rtrim$(TreasureRecord.Prefix1)+Strng
             Strng2=", "
          Endif
          If VarQ!=SFalse Then
             Exit Do
          Endif
          Temp3!=VarQ!
       Loop
    Endif
    Temp3!=UserRecord2.First2 ' containers
    If Temp3! Then
       Do
          Call Read.Record(ContainerFile,Temp3!)
          VarQ!=ContainerRecord.Next
          ' drop container
          Call Delete.User.Container2(Temp3!)
          Call Read.Record(ContainerFile,Temp3!)
          ContainerRecord.RoomNumber=Room
          ContainerRecord.UserNumber=SFalse
          ContainerRecord.InvisibleContainer=False
          Call Add.Room.Container(Temp3!)
          ' display container name
          Temp9=Temp9+1
          Call Convert.ANSI(True,VarQ,VarR)
          Carriage.Return=True
          Graphics.On=True
          Call IO.O
          Graphics.On=False
          If Len(Strng2) Then
             Carriage.Return=True
             Strng=Strng2
             Call IO.O
          Endif
          Strng=Rtrim$(ContainerRecord.ContainerName)
          Strng=Rtrim$(ContainerRecord.Prefix1)+Strng
          Strng2=", "
          If VarQ!=SFalse Then
             Exit Do
          Endif
          Temp3!=VarQ!
       Loop
    Endif
    If Temp9=False Then
       Strng="nothing."
    Else
       If Temp9>1 Then
          Strng="and "+Strng
       Endif
    Endif
    Call Convert.ANSI(True,VarQ,VarR)
    Carriage.Return=True
    Graphics.On=True
    Call IO.O
    Graphics.On=False
    If Len(Strng2) Then
       Strng=Left$(Strng2,Len(Strng2)-2)+"."
    Else
       Strng="."
    Endif
    Call IO.O
    For Temp6!=1! To Lof(UserInvFile)/MessWorkRecLen6
       Call Read.Record(UserInvFile,Temp6!)
       If MessWorkRecord6.User=Temp2! Then
          MessWorkRecord6.User=SFalse
          MessWorkRecord6.Room=SFalse
          MessWorkRecord6.Index=SFalse
          MessWorkRecord6.Charges=False
          MessWorkRecord6.Plus=False
          MessWorkRecord6.Prev=SFalse
          MessWorkRecord6.Next=SFalse
          Call Write.Record(UserInvFile,Temp6!)
       Endif
    Next
    UserRecord2.First=SFalse
    UserRecord2.Last=SFalse
 Endif
 UserRecord2.Room=Int(Val(Config3(24))+.5)
 UserRecord2.Level=UserRecord2.Level-1
 UserRecord2.TimesDied=UserRecord2.TimesDied+1#
 Temp3#=UserRecord2.Gold
 UserRecord2.Gold=False
 Aligned=UserRecord2.Align1+UserRecord2.Align2
 Call Write.Record(UserFile2,Temp2!)
 If Aligned<False Then
    If UserRecord.Align1+UserRecord.Align2<False Then
       Strng="Your alignment changed!"
       Call IO.O
       UserRecord.Align2=1
       If UserRecord.Level-UserRecord2.Level<5 Then
          UserRecord.Align1=False
       Else
          UserRecord.Align1=1
       Endif
       Strng="alignment changed to "+_
       Rtrim$(Alignment.Name1(UserRecord.Align1+2))+" "+_
       Rtrim$(Alignment.Name2(UserRecord.Align2+2))
       Call Update.DayFile(Strng,False,2)
    Endif
 Endif
 Players.Killed=Players.Killed+1
 UserRecord.PlayersKilled=UserRecord.PlayersKilled+1
 Call Write.Record(UserFile,User.Index)
 Temp1#=UserRecord2.Level*100
 Call Count.Last(VarZ,False)
 VarZ#=Cdbl(VarZ)
 Temp1#=Int(Temp1#/VarZ#)
 Temp3#=Int(Temp3#/VarZ#)
 Call Add.Experience(Temp1#,Temp3#)
 Call Add.Node.Exp(Temp1#,Temp3#,False)
 User.Temp=VarX!
 Call Remove.User
ErrorResume6:
 Exit Sub
ErrorTrap6:
 Resume ErrorResume6
End Sub

Sub Delete.User.Container2(VarZ!)
 On Local Error Goto ErrorTrp32x
 Call Read.Record(UserFile2,Temp2!)
 If UserRecord2.First2=VarZ! Then
    Call Read.Record(ContainerFile,VarZ!)
    UserRecord2.First2=ContainerRecord.Next
    Call Write.Record(UserFile2,Temp2!)
    If UserRecord2.First2>SFalse Then
       Call Read.Record(ContainerFile,UserRecord2.First2)
       ContainerRecord.Prev=SFalse
       Call Write.Record(ContainerFile,UserRecord2.First2)
    Endif
 Else
    If UserRecord2.Last2=VarZ! Then
       Call Read.Record(ContainerFile,VarZ!)
       UserRecord2.Last2=ContainerRecord.Prev
       Call Write.Record(UserFile2,Temp2!)
       If UserRecord2.Last2>SFalse Then
          Call Read.Record(ContainerFile,UserRecord2.Last2)
          ContainerRecord.Next=SFalse
          Call Write.Record(ContainerFile,UserRecord2.Last2)
       Endif
    Else
       Call Read.Record(ContainerFile,VarZ!)
       Previous.Node!=ContainerRecord.Prev
       Next.Node!=ContainerRecord.Next
       Call Read.Record(ContainerFile,Previous.Node!)
       ContainerRecord.Next=Next.Node!
       Call Write.Record(ContainerFile,Previous.Node!)
       Call Read.Record(ContainerFile,Next.Node!)
       ContainerRecord.Prev=Previous.Node!
       Call Write.Record(ContainerFile,Next.Node!)
    Endif
 Endif
ErrorRsm32x:
 Exit Sub
ErrorTrp32x:
 Resume ErrorRsm32x
End Sub

Sub Update.LogFile(Var$,VarX!)
 On Local Error Goto ErrTrap6
 Close #LogFile
 Open Log.FileName For Random Shared As #LogFile Len=LogRecLen
 Var!=Lof(LogFile)/LogRecLen+1!
 VarX$=Fclock2$
 LogRecord.Clock=VarX$
 LogRecord.Message=Var$
 LogRecord.User=VarX!
 Call Write.Record(LogFile,Var!)
ErrResume6:
 Exit Sub
ErrTrap6:
 Resume ErrResume6
End Sub

Sub Remove.User
 On Local Error Goto ErrorTrap9
 Call Read.Record(MessWorkFile4,User.Temp)
 MessWorkRecord4.Room=Int(Val(Config3(24))+.5)
 Call Write.Record(MessWorkFile4,User.Temp)
 User.Attacked=False
ErrorResume9:
 Exit Sub
ErrorTrap9:
 Resume ErrorResume9
End Sub

Sub Get.Monster
 On Local Error Goto ErrorTrap23
 Gosub Get.Config2
 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
       Call Get.Monster.Stats(VarX)
       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)
       Else
          If Normal.User=False Then
             Strng="You encounter"+Strng+" [inv]!"
             Call IO.O
          Else
             If Len(option1$) Then
                Out2=option1$
                Call Equate(Temp#)
             Else
                Temp#=Rnd>.75
             Endif
             If Temp# Then
                Strng="You sense an encounter!"
                Call IO.O
             Endif
          Endif
       Endif
    Endif
 Endif
 Exit Sub
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$)="[SPELL]" 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 "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 Count.Mess(Var)
 On Local Error Goto ErrorTrap17a
 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
ErrorResume17a:
 Exit Sub
ErrorTrap17a:
 Resume ErrorResume17a
End Sub

Sub Get.Monster.Stats(VarY)
 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
    MessWorkRecord3.Monster.Magic=Int(Rnd*Room.Monster.Rate+1)
    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.Inventory(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.Inventory(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

' absorb poison hits
Sub Get.Ring.Hits3(Var1)
 On Local Error Goto ErrorTrap15x
 If Var1 Then
    Var=UserRecord2.Weapon(4).Charges
 Else
    Var=UserRecord2.Weapon(9).Charges
 Endif
 Var=Var-1
 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 poison spell!"
 Else
    Strng=Out4+"'s right ring absorbs the poison spell!"
 Endif
 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
 Endif
ErrorResume15x:
 Exit Sub
ErrorTrap15x:
 Resume ErrorResume15x
End Sub
