 Rem File: DndeditF for Dndbbs Version v5.0a Release r2.0 Tweak t5.0a
 Rem Sub: EditNonplayer
 Rem $Include: 'dndedit.inc'

 On Error Goto Main.Error
 Call Stdin(Var)
 If Chained2=0 Then
    Call Init.Arrays
    Call Read.Rows(Var2)
    Max.Row=Var2
    Call Save.Screen(False)
    Call Clear.Screen2
    Call Init.Mouse
    Call Read.Config(False)
    Call Passwrd5(Var,"f")
    Close #TempFile1
    If Var=False Then
       Call Terminate.Program(True)
       End
    Endif
 Endif
Main.Resume:
 Call EditNonplayer
 If Chained2 Then
    Chain DND.Path+"DNDEDIT.EXE"
 Endif
 Call Terminate.Program(True)
 End
Main.Error:
 Resume Main.Resume

Sub EditNonplayer
 On Local Error Goto Error.Trap184
 Nonplayer.Number=1!
 If Lof(NonPlayerFile)=SFalse Then
    Call AddNonplayer
 Endif
 Out3="Sysop Nonplayer Edit"
 Call DisplayEditScreen(8,29,Out3)
 Call NonplayerStatusLine
 Call DisplayNonplayer
 Do While Lost.Carrier=False
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseButton(29)
          If Len(TempX$) Then
             Exit Do
          Endif
       Endif
       If Mouse.Row Or Mouse.Column Then
          Call MouseSelect(29)
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       If TempX=0 Then
          Call Write.Record(NonPlayerFile,NonPlayer.Number)
          Exit Do
       Endif
       Call NonplayerSelect
    Case 1
       TempX=Asc(TempX$)
       Select Case TempX
       Case 65 To 90 ' A to Z
          Call SearchNonplayerPrefix(TempX)
       Case 97 To 122 ' a to z
          Call SearchNonplayerPrefix(TempX)
       Case 1
          Call AddNonplayer
       Case 8
          Call Help(10)
          Out3="Sysop Nonplayer Edit"
          Call DisplayEditScreen(8,29,Out3)
          Call NonplayerStatusLine
          Call DisplayNonplayer
       Case 9
          Call NonplayerSelect
       Case 13
          Call NonplayerEdit
          Call Write.Record(NonPlayerFile,NonPlayer.Number)
          Call NonplayerStatusLine
          TempX=Selection
          Call ShowNonplayer
          Call RedisplayField
       Case 14
          Call NextNonplayer
       Case 15
          Temp0=True
          Call EditMonsterObject
          Call NonplayerStatusLine
       Case 17
          Call PreviousNonplayer
       Case 18
          Call SelectNextNonplayer
          Call NonplayerStatusLine
       Case 20
          Temp0=True
          Call EditMonsterTreasure
          Call NonplayerStatusLine
       Case 23
          Call SearchNonplayer
       Case 27
          Call Write.Record(NonPlayerFile,NonPlayer.Number)
          Exit Sub
       End Select
    End Select
 Loop
Error.Resume184:
 Exit Sub
Error.Trap184:
 Resume Error.Resume184
End Sub

Sub NextNonplayer
 On Local Error Goto Error.Trap185
 If Nonplayer.Number>=Lof(NonPlayerFile)/NonPlayerRecLen Then
    Strng="This is the last nonplayer in the nonplayer file."
    Call ErrorMessage
 Else
    Call Write.Record(NonPlayerFile,NonPlayer.Number)
    Nonplayer.Number=Nonplayer.Number+1!
    Call DisplayNonplayer
 Endif
Error.Resume185:
 Exit Sub
Error.Trap185:
 Resume Error.Resume185
End Sub

Sub PreviousNonplayer
 On Local Error Goto Error.Trap186
 If Nonplayer.Number>1! Then
    Call Write.Record(NonPlayerFile,NonPlayer.Number)
    Nonplayer.Number=Nonplayer.Number-1!
    Call DisplayNonplayer
    Exit Sub
 Endif
 Strng="This is the first nonplayer in the nonplayer file."
 Call ErrorMessage
Error.Resume186:
 Exit Sub
Error.Trap186:
 Resume Error.Resume186
End Sub

Sub SelectNextNonplayer
 On Local Error Goto Error.Trap187
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field "
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Nonplayer: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,19)
 Strng=Space$(6)
 Call Scrn(Strng)
 Call ANSI(4,37,44)
 Call ANSI(2,23,28)
 Strng="(1-"+Mid$(Str$(Lof(NonPlayerFile)/NonPlayerRecLen),2)+")"
 Multiplier=Len(Strng)+28
 Strng=Strng+" (+/-/x)"
 Call Scrn(Strng)
 Restore Data17
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Multiplier=False
 Temp2!=Int(Val(Edit.Data(1))+.5)
 If Temp2!<=SFalse Or Temp2!>Lof(NonPlayerFile)/NonPlayerRecLen Then
    Strng="The nonplayer number is not within the nonplayer file range."
    Call ErrorMessage
    Exit Sub
 Endif
 Call Write.Record(NonPlayerFile,NonPlayer.Number)
 Nonplayer.Number=Temp2!
 Call DisplayNonplayer
Error.Resume187:
 Exit Sub
Error.Trap187:
 Resume Error.Resume187
End Sub

Sub SearchNonplayerPrefix(VarQ)
 On Local Error Goto Error.Trap107x
 Call Write.Record(NonplayerFile,Nonplayer.Number)
 VarQ$=Nul
 If VarQ>=65 And VarQ<=90 Then
    VarQ$=Chr$(VarQ)
 Endif
 If VarQ>=97 And VarQ<=122 Then
    VarQ$=Ucase$(Chr$(VarQ))
 Endif
 If Len(VarQ$) Then
    VarX = 0
    For Var2!=Nonplayer.Number + 1! To Lof(NonplayerFile)/NonplayerRecLen
       Call Read.Record(NonplayerFile,Var2!)
       Strng=Rtrim$(MonsterRecord.MonsterName)
       Strng=Ucase$(Strng)
       If Len(Strng) Then
          If Left$(Strng,1)=VarQ$ Then
             VarX = -1
             Nonplayer.Number=Var2!
             Exit For
          Endif
       Endif
    Next
    If VarX = 0 Then
       For Var2!=1! To Nonplayer.Number
          Call Read.Record(NonplayerFile,Var2!)
          Strng=Rtrim$(MonsterRecord.MonsterName)
          Strng=Ucase$(Strng)
          If Len(Strng) Then
             If Left$(Strng,1)=VarQ$ Then
                VarX = -1
                Nonplayer.Number=Var2!
                Exit For
             Endif
          Endif
       Next
    Endif
 Endif
 Call DisplayNonplayer
Error.Resume107x:
 Exit Sub
Error.Trap107x:
 Resume Error.Resume107x
End Sub

Sub SearchNonplayer
 On Local Error Goto Error.Trap188
 Call Write.Record(NonPlayerFile,NonPlayer.Number)
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field "
 Out2=Out2+"Append # sign and number for duplicate nonplayers"
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Nonplayer Name or Number: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,34)
 Strng=Space$(30)
 Call Scrn(Strng)
 Restore Data18
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Call NonplayerStatusLine
 Temp2!=Int(Val(Edit.Data(1))+.5)
 Temp$=Lcase$(Edit.Data(1))
 If Temp2!>SFalse And Temp2!<=Lof(NonPlayerFile)/NonPlayerRecLen Then
    Nonplayer.Number=Temp2!
    Call DisplayNonplayer
    Exit Sub
 Endif
 Temp.Index=SFalse
 Temp1=Instr(Temp$,"#")
 If Temp1 Then
    Temp.Index=Csng(Int(Val(Mid$(Temp$,Temp1+1))+.5))
    Temp$=Left$(Temp$,Temp1-1)
 Endif
 Temp4=Len(Temp$)
 Temp!=SFalse
 Temp3!=SFalse
 For Temp2!=1! To Lof(NonPlayerFile)/NonPlayerRecLen
    Call Read.Record(NonPlayerFile,Temp2!)
    Out3=Rtrim$(MonsterRecord.MonsterName)
    Out3=Lcase$(Out3)
    Temp$=Lcase$(Temp$)
    'TempX=0
    'If Len(Temp$) Then
    '   If Left$(Out3,Len(Temp$))=Temp$ Then TempX=-1
    'Endif
    Call InstrSUB(TempX,Out3,Temp$)
    If TempX Then
       Temp3!=Temp3!+1!
       If Temp3!=1! Then
          Temp!=Temp2!
       Endif
       If Temp.Index Then
          If Temp3!=Temp.Index Then
             Nonplayer.Number=Temp2!
             Call DisplayNonplayer
             Exit Sub
          Endif
       Endif
    Endif
 Next
 If Temp.Index>SFalse Then
    Strng="The nonplayer name was not found in the nonplayer file."
    Call ErrorMessage
    Call DisplayNonplayer
    Exit Sub
 Endif
 If Temp3!=SFalse Then
    Strng="The nonplayer name was not found in the nonplayer file."
    Call ErrorMessage
    Call DisplayNonplayer
    Exit Sub
 Endif
 If Temp3!=1! Then
    Nonplayer.Number=Temp!
    Call DisplayNonplayer
    Exit Sub
 Endif
 Strng="There was more than one nonplayer found."
 Call ErrorMessage
 Strng="^ Scroll Nonplayer  "+Chr$(60)+Chr$(217)+" Select Nonplayer ("+Ltrim$(Str$(Temp3!))+" found)."
 Out2=Nul
 Call StatusLine
 Nonplayer.Number=Temp!
 Temp2!=Temp!
 Call Read.Record(NonPlayerFile,Nonplayer.Number)
 Call DisplayNonplayer
 Do While Lost.Carrier=False
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseCheck
          Exit Do
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 1
       If TempX$=Chr$(13) Then
          Nonplayer.Number=Temp2!
          Call NonplayerStatusLine
          Call DisplayNonplayer
          Exit Sub
       Endif
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       Select Case TempX
       Case 72, 141, 152
          TempA=False
          For Temp3!=Temp2!-1! To 1! Step -1!
             Call Read.Record(NonPlayerFile,Temp3!)
             Out3=Rtrim$(MonsterRecord.MonsterName)
             Out3=Lcase$(Out3):Temp$=Lcase$(Temp$)
             'TempX=0
             'If Len(Temp$) Then
             '   If Left$(Out3,Len(Temp$))=Temp$ Then TempX=-1
             'Endif
             Call InstrSUB(TempX,Out3,Temp$)
             If TempX Then
                TempA=True
                Temp2!=Temp3!
                Nonplayer.Number=Temp3!
                Call DisplayNonplayer
                Exit For
             Endif
          Next
          If TempA=False Then
             Strng="This is the first nonplayer in the search."
             Call ErrorMessage
          Endif
       Case 80, 145, 160
          TempA=False
          For Temp3!=Temp2!+1! To Lof(NonPlayerFile)/NonPlayerRecLen
             Call Read.Record(NonPlayerFile,Temp3!)
             Out3=Rtrim$(MonsterRecord.MonsterName)
             Out3=Lcase$(Out3):Temp$=Lcase$(Temp$)
             'TempX=0
             'If Len(Temp$) Then
             '   If Left$(Out3,Len(Temp$))=Temp$ Then TempX=-1
             'Endif
             Call InstrSUB(TempX,Out3,Temp$)
             If TempX Then
                TempA=True
                Temp2!=Temp3!
                Nonplayer.Number=Temp3!
                Call DisplayNonplayer
                Exit For
             Endif
          Next
          If TempA=False Then
             Strng="This is the last nonplayer in the search."
             Call ErrorMessage
          Endif
       End Select
    End Select
 Loop
Error.Resume188:
 Exit Sub
Error.Trap188:
 Resume Error.Resume188
End Sub

Sub NonplayerStatusLine
 On Local Error Goto Error.Trap189
 Strng="^ Cursor Select "+Chr$(60)+Chr$(217)
 Strng=Strng+" Enter Choice <esc> Exit and Save ^h Help ^a Add"
 Out2="^n Next ^q Prev ^r Select ^w Search ^o Objects ^t Treasure"
 Call StatusLine
Error.Resume189:
 Exit Sub
Error.Trap189:
 Resume Error.Resume189
End Sub

Sub DisplayNonplayer
 On Local Error Goto Error.Trap183
 If Nonplayer.Number>SFalse And Nonplayer.Number<=Lof(NonPlayerFile)/NonPlayerRecLen Then
    Call Read.Record(NonPlayerFile,Nonplayer.Number)
    For TempX=False To 29
       Call ShowNonplayer
    Next
    Call RedisplayField
 Endif
Error.Resume183:
 Exit Sub
Error.Trap183:
 Resume Error.Resume183
End Sub

Data17:
 Data 23,19,19,6,23,1,1
Data18:
 Data 23,34,34,30,23,1,1

Sub ShowNonplayer
 On Local Error Goto Error.Trap28
 Select Case TempX
 Case 0
    Call ANSI(4,37,44)
    Call ANSI(2,2,12)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(4,33,44)
    Call ANSI(2,2,2)
    Strng="Nonplayer"+Str$(Nonplayer.Number)
    Call Scrn(Strng)
    Room.Treasure=SFalse
    Room.Objects=SFalse
    Var!=MonsterRecord.First
    If Var! Then
       Do While Lost.Carrier=False
          Call Read.Record(MonInvFile,Var!)
          Var2!=MessWorkRecord6.Next
          VarX!=MessWorkRecord6.User
          If VarX!>SFalse Then
             Room.Treasure=Room.Treasure+1!
          Endif
          If VarX!<SFalse Then
             Room.Objects=Room.Objects+1!
          Endif
          If Var2!=SFalse Then
             Exit Do
          Endif
          Var!=Var2!
       Loop
    Endif
    Call ANSI(4,33,44)
    Call ANSI(2,2,21)
    Strng="Treasure"
    Call Scrn(Strng)
    Call ANSI(4,37,40)
    Call ANSI(2,2,30)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(2,2,30)
    Strng=Mid$(Str$(Room.Treasure),2)
    Call Scrn(Strng)
    Call ANSI(4,33,44)
    Call ANSI(2,2,39)
    Strng="Objects"
    Call Scrn(Strng)
    Call ANSI(4,37,40)
    Call ANSI(2,2,47)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(2,2,47)
    Strng=Mid$(Str$(Room.Objects),2)
    Call Scrn(Strng)
 Case Else
    Call ANSI(4,37,40)
    Select Case TempX
    Case 1
       Call ANSI(2,4,2)
       Strng=MonsterRecord.MonsterName
       Call Scrn(Strng)
    Case 2
       Call ANSI(2,7,2)
       Strng=MonsterRecord.PluralName
       Call Scrn(Strng)
    Case 3
       Call ANSI(2,9,8)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,9,8)
       Strng=Mid$(Str$(MonsterRecord.Level),2)
       Call Scrn(Strng)
    Case 4
       Call ANSI(2,11,7)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,11,7)
       Strng=Mid$(Str$(MonsterRecord.Hits),2)
       Call Scrn(Strng)
    Case 5
       Call ANSI(2,13,13)
       Strng=Space$(20)
       Call Scrn(Strng)
       Call ANSI(2,13,13)
       Strng=Mid$(Str$(MonsterRecord.Experience),2)
       Call Scrn(Strng)
    Case 6
       Call ANSI(2,15,7)
       Strng=Space$(20)
       Call Scrn(Strng)
       Call ANSI(2,15,7)
       Strng=Mid$(Str$(MonsterRecord.Gold),2)
       Call Scrn(Strng)
    Case 7
       Call ANSI(2,17,7)
       If MonsterRecord.Jail Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 8
       Call ANSI(2,19,7)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,19,7)
       Strng=Mid$(Str$(MonsterRecord.Rate),2)
       Call Scrn(Strng)
    Case 9
       Call ANSI(2,19,26)
       Strng=Space$(3)
       Call Scrn(Strng)
       Call ANSI(2,19,26)
       Strng=Mid$(Str$(MonsterRecord.RatePercent),2)
       Call Scrn(Strng)
    Case 10
       Call ANSI(2,21,10)
       If MonsterRecord.Psionic Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 11
       If MonsterRecord.Psionic=False Then
          Call ANSI(2,21,22)
          Strng="<none>"
          Call Scrn(Strng)
          Strng=Space$(14)
          Call Scrn(Strng)
       Else
          Call Read.Record(SpellFile,MonsterRecord.PsionicSpell)
          Call ANSI(2,21,22)
          Strng=Left$(SpellRecord.SpellName,20)
          Call Scrn(Strng)
       Endif
    Case 12
       Call ANSI(2,3,58)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,3,58)
       Strng=Mid$(Str$(MonsterRecord.NumberAppearing),2)
       Call Scrn(Strng)
    Case 13
       Call ANSI(2,5,52)
       If MonsterRecord.Poison Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 14
       Call ANSI(2,5,68)
       Strng=Space$(3)
       Call Scrn(Strng)
       Call ANSI(2,5,68)
       Strng=Mid$(Str$(MonsterRecord.PoisonPercent),2)
       Call Scrn(Strng)
    Case 15
       Call ANSI(2,7,57)
       If MonsterRecord.LevelDrain Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 16
       Call ANSI(2,7,68)
       Strng=Space$(3)
       Call Scrn(Strng)
       Call ANSI(2,7,68)
       Strng=Mid$(Str$(MonsterRecord.DrainPercent),2)
       Call Scrn(Strng)
    Case 17
       Call ANSI(2,9,51)
       If MonsterRecord.Block Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 18
       Call ANSI(2,9,68)
       Strng=Space$(3)
       Call Scrn(Strng)
       Call ANSI(2,9,68)
       Strng=Mid$(Str$(MonsterRecord.BlockPercent),2)
       Call Scrn(Strng)
    Case 19
       Call ANSI(2,11,53)
       If MonsterRecord.Prevent Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 20
       Call ANSI(2,11,68)
       Strng=Space$(3)
       Call Scrn(Strng)
       Call ANSI(2,11,68)
       Strng=Mid$(Str$(MonsterRecord.PreventPercent),2)
       Call Scrn(Strng)
    Case 21
       Call ANSI(2,13,52)
       If MonsterRecord.Follow Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 22
       Call ANSI(2,13,68)
       Strng=Space$(3)
       Call Scrn(Strng)
       Call ANSI(2,13,68)
       Strng=Mid$(Str$(MonsterRecord.FollowPercent),2)
       Call Scrn(Strng)
    Case 23
       Call ANSI(2,13,72)
       Strng=Space$(3)
       Call Scrn(Strng)
       Call ANSI(2,13,72)
       Strng=Mid$(Str$(MonsterRecord.TeleportPercent),2)
       Call Scrn(Strng)
    Case 24
       Call ANSI(2,15,56)
       If MonsterRecord.Spell Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 25
       Call ANSI(2,15,68)
       Strng=Space$(3)
       Call Scrn(Strng)
       Call ANSI(2,15,68)
       Strng=Mid$(Str$(MonsterRecord.SpellPercent),2)
       Call Scrn(Strng)
    Case 26
       Call ANSI(2,17,51)
       If MonsterRecord.Spell<=SFalse Or _
       MonsterRecord.Spell>Lof(SpellFile)/SpellRecLen Then
          Strng="<none>"
          Call Scrn(Strng)
          Strng=Space$(14)
          Call Scrn(Strng)
       Else
          Call Read.Record(SpellFile,MonsterRecord.Spell)
          Strng=Left$(SpellRecord.SpellName,20)
          Call Scrn(Strng)
       Endif
    Case 27
       Call ANSI(2,19,53)
       If MonsterRecord.Magic Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 28
       Call ANSI(2,19,65)
       If MonsterRecord.Permanent Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 29
       Call ANSI(2,20,54)
       If MonsterRecord.Equation Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
       Call ANSI(4,37,40)
       Call ANSI(2,21,45)
       Strng=Space$(35)
       Call Scrn(Strng)
       Call ANSI(2,21,45)
       Strng=Rtrim$(MonsterRecord.MonsterEquate)
       Strng=Left$(Strng,35)
       Call Scrn(Strng)
    End Select
 End Select
Error.Resume28:
 Exit Sub
Error.Trap28:
 Resume Error.Resume28
End Sub

Sub AddNonplayer
 On Local Error Goto Error.Trap29
 Nonplayer.Number=Lof(NonPlayerFile)/NonPlayerRecLen+1!
 MonsterRecord.MonsterName=Nul
 MonsterRecord.PluralName=Nul
 MonsterRecord.Experience=False
 MonsterRecord.Gold=False
 MonsterRecord.NumberAppearing=False
 MonsterRecord.Level=False
 MonsterRecord.Hits=False
 MonsterRecord.Poison=False
 MonsterRecord.LevelDrain=False
 MonsterRecord.Spell=SFalse
 MonsterRecord.Block=False
 MonsterRecord.Prevent=False
 MonsterRecord.Follow=False
 MonsterRecord.Magic=True
 MonsterRecord.Jail=False
 MonsterRecord.TeleportPercent=False
 MonsterRecord.FollowPercent=False
 MonsterRecord.BlockPercent=False
 MonsterRecord.PreventPercent=False
 MonsterRecord.SpellPercent=False
 MonsterRecord.PoisonPercent=False
 MonsterRecord.DrainPercent=False
 MonsterRecord.Rate=False
 MonsterRecord.RatePercent=False
 MonsterRecord.Permanent=-2
 MonsterRecord.RemainsInRoom=False
 For Temp6=1 To MaxMonTalk
    MonsterRecord.Talk(Temp6)=False
 Next
 MonsterRecord.Psionic=False
 MonsterRecord.PsionicSpell=SFalse
 MonsterRecord.Equation=False
 MonsterRecord.MonsterEquate=Nul
 MonsterRecord.MonsterSurprise=Nul
 MonsterRecord.MonsterSavingThrow=Nul
 MonsterRecord.Prefix1=Nul
 MonsterRecord.First=SFalse
 MonsterRecord.Last=SFalse
 MonsterRecord.Weapon=SFalse
 MonsterRecord.Shield=SFalse
 MonsterRecord.Armor=SFalse
 MonsterRecord.PerMonster=0
 MonsterRecord.TalkGold=0
 MonsterRecord.TalkGoldTimes=0
 MonsterRecord.TalkGoldPercent=0
 MonsterRecord.TalkItem=0
 MonsterRecord.TalkItemTimes=0
 MonsterRecord.TalkItemPercent=0
 MonsterRecord.TalkMoveDirection=0
 MonsterRecord.Buffer15=0
 MonsterRecord.Buffer16=0
 Call Write.Record(NonPlayerFile,Nonplayer.Number)
 Call DisplayNonplayer
 UserRecord.ObjectsCreated(4)=UserRecord.ObjectsCreated(4)+1#
 If User.Index Then
    Call Write.Record(UserFile,User.Index)
 Endif
Error.Resume29:
 Exit Sub
Error.Trap29:
 Resume Error.Resume29
End Sub

Sub NonplayerEdit
 On Local Error Goto Error.Trap39
 Restore NonplayerEditData
 For TempX=1 To Selection
    Read Xcoor, Ycoor, Column, Line.Length, Max.Lines, Row, Line.Number
 Next
 Static TempE
 TempE=False
 MonsterRecord.Magic=True
 MonsterRecord.Permanent=-2
 Select Case Selection
 Case 1
    Edit.Data(1)=MonsterRecord.MonsterName
 Case 2
    Edit.Data(1)=MonsterRecord.PluralName
 Case 3
    Edit.Data(1)=Mid$(Str$(MonsterRecord.Level),2)
 Case 4
    Edit.Data(1)=Mid$(Str$(MonsterRecord.Hits),2)
 Case 5
    Edit.Data(1)=Mid$(Str$(MonsterRecord.Experience),2)
 Case 6
    Edit.Data(1)=Mid$(Str$(MonsterRecord.Gold),2)
 Case 7
    If MonsterRecord.Jail Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 8
    Edit.Data(1)=Mid$(Str$(MonsterRecord.Rate),2)
 Case 9
    Edit.Data(1)=Mid$(Str$(MonsterRecord.RatePercent),2)
 Case 10
    If MonsterRecord.Psionic Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 11
    If MonsterRecord.Psionic=False Or MonsterRecord.PsionicSpell=SFalse Then
       Edit.Data(1)=Nul
       Call ANSI(4,37,40)
       Call ANSI(2,21,22)
       Strng=Space$(20)
       Call Scrn(Strng)
    Else
       Call Read.Record(SpellFile,MonsterRecord.PsionicSpell)
       Edit.Data(1)=SpellRecord.SpellName
    Endif
 Case 12
    Edit.Data(1)=Mid$(Str$(MonsterRecord.NumberAppearing),2)
 Case 13
    If MonsterRecord.Poison Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 14
    Edit.Data(1)=Mid$(Str$(MonsterRecord.PoisonPercent),2)
 Case 15
    If MonsterRecord.LevelDrain Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 16
    Edit.Data(1)=Mid$(Str$(MonsterRecord.DrainPercent),2)
 Case 17
    If MonsterRecord.Block Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 18
    Edit.Data(1)=Mid$(Str$(MonsterRecord.BlockPercent),2)
 Case 19
    If MonsterRecord.Prevent Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 20
    Edit.Data(1)=Mid$(Str$(MonsterRecord.PreventPercent),2)
 Case 21
    If MonsterRecord.Follow Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 22
    Edit.Data(1)=Mid$(Str$(MonsterRecord.FollowPercent),2)
 Case 23
    Edit.Data(1)=Mid$(Str$(MonsterRecord.TeleportPercent),2)
 Case 24
    If MonsterRecord.Spell Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 25
    Edit.Data(1)=Mid$(Str$(MonsterRecord.SpellPercent),2)
 Case 26
    If MonsterRecord.Spell>SFalse And _
    MonsterRecord.Spell<=Lof(SpellFile)/SpellRecLen Then
       Call Read.Record(SpellFile,MonsterRecord.Spell)
       Edit.Data(1)=Left$(SpellRecord.SpellName,20)
    Else
       Call ANSI(4,37,40)
       Call ANSI(2,17,51)
       Edit.Data(1)=Nul
       Strng=Space$(20)
       Call Scrn(Strng)
    Endif
 Case 27
    If MonsterRecord.Magic Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 28
    If MonsterRecord.Permanent Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 29
    If MonsterRecord.Equation Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 End Select
 Strng="^ Cursor Edit   "
 If Selection=6 Then
    Out2="<esc> Exit Field"
 Else
    Out2=Chr$(60)+Chr$(217)+" Exit Field"
 Endif
 Call StatusLine
 Edit.Data(1)=Rtrim$(Edit.Data(1))
 Call ScreenEdit
 Select Case Selection
 Case 1
    MonsterRecord.MonsterName=Lcase$(Edit.Data(1))
 Case 2
    MonsterRecord.PluralName=Lcase$(Edit.Data(1))
 Case 3
    MonsterRecord.Level=Val(Edit.Data(1))
 Case 4
    MonsterRecord.Hits=Val(Edit.Data(1))
 Case 5
    MonsterRecord.Experience=Val(Edit.Data(1))
 Case 6
    MonsterRecord.Gold=Val(Edit.Data(1))
 Case 7
    If Ucase$(Edit.Data(1))="Y" Then
       MonsterRecord.Jail=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       MonsterRecord.Jail=False
    Endif
 Case 8
    MonsterRecord.Rate=Val(Edit.Data(1))
 Case 9
    MonsterRecord.RatePercent=Val(Edit.Data(1))
 Case 10
    If Ucase$(Edit.Data(1))="Y" Then
       MonsterRecord.Psionic=True
       TempX=Selection
       Call ShowNonplayer
       Next.Field=11
       Call ShowField
       TempE=True
       Call NonplayerEdit
       Exit Sub
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       MonsterRecord.Psionic=False
       MonsterRecord.PsionicSpell=False
       TempX=Selection+1
       Call ShowNonplayer
    Endif
 Case 11
    Edit.Data(1)=Rtrim$(Edit.Data(1))
    Edit.Data(1)=Lcase$(Edit.Data(1))
    If Edit.Data(1)=Nul Then
       MonsterRecord.Psionic=False
       MonsterRecord.PsionicSpell=SFalse
       TempX=Selection-1
       Call ShowNonplayer
    Else
       For Temp2!=1! To Lof(SpellFile)/SpellRecLen
          Call Read.Record(SpellFile,Temp2!)
          If Left$(SpellRecord.SpellName,Len(Edit.Data(1)))=Edit.Data(1) Then
             If SpellRecord.Psionic Then
                MonsterRecord.Psionic=True
                MonsterRecord.PsionicSpell=Temp2!
                If TempE=False Then
                   TempX=Selection-1
                   Call ShowNonplayer
                Endif
                Exit Sub
             Endif
          Endif
       Next
       MonsterRecord.Psionic=False
       MonsterRecord.PsionicSpell=SFalse
       TempX=Selection-1
       Call ShowNonplayer
       Strng="The psi spell was not found in the spell file."
       Call ErrorMessage
    Endif
 Case 12
    MonsterRecord.NumberAppearing=Val(Edit.Data(1))
 Case 13
    MonsterRecord.Poison=False
    MonsterRecord.PoisonPercent=False
    If Ucase$(Edit.Data(1))="Y" Then
       MonsterRecord.Poison=True
       Next.Field=14
       Call ShowField
       TempX=Selection
       Call ShowNonplayer
       Call NonplayerEdit
       Exit Sub
    Endif
 Case 14
    MonsterRecord.PoisonPercent=Int(Val(Edit.Data(1))+.5)
 Case 15
    MonsterRecord.LevelDrain=False
    MonsterRecord.DrainPercent=False
    If Ucase$(Edit.Data(1))="Y" Then
       MonsterRecord.LevelDrain=True
       Next.Field=16
       Call ShowField
       TempX=Selection
       Call ShowNonplayer
       Call NonplayerEdit
       Exit Sub
    Endif
 Case 16
    MonsterRecord.DrainPercent=Int(Val(Edit.Data(1))+.5)
 Case 17
    MonsterRecord.Block=False
    MonsterRecord.BlockPercent=False
    If Ucase$(Edit.Data(1))="Y" Then
       MonsterRecord.Block=True
       Next.Field=18
       Call ShowField
       TempX=Selection
       Call ShowNonplayer
       Call NonplayerEdit
       Exit Sub
    Endif
 Case 18
    MonsterRecord.BlockPercent=Int(Val(Edit.Data(1))+.5)
 Case 19
    MonsterRecord.Prevent=False
    MonsterRecord.PreventPercent=False
    If Ucase$(Edit.Data(1))="Y" Then
       MonsterRecord.Prevent=True
       Next.Field=20
       Call ShowField
       TempX=Selection
       Call ShowNonplayer
       Call NonplayerEdit
       Exit Sub
    Endif
 Case 20
    MonsterRecord.PreventPercent=Int(Val(Edit.Data(1))+.5)
 Case 21
    MonsterRecord.Follow=False
    MonsterRecord.FollowPercent=False
    MonsterRecord.TeleportPercent=False
    If Ucase$(Edit.Data(1))="Y" Then
       MonsterRecord.Follow=True
       Next.Field=22
       Call ShowField
       TempX=Selection
       Call ShowNonplayer
       Call NonplayerEdit
       Exit Sub
    Endif
 Case 22
    MonsterRecord.FollowPercent=Int(Val(Edit.Data(1))+.5)
 Case 23
    MonsterRecord.TeleportPercent=Int(Val(Edit.Data(1))+.5)
 Case 24
    MonsterRecord.Spell=False
    MonsterRecord.SpellPercent=False
    TempX=Selection+1
    Call ShowNonplayer
    If Ucase$(Edit.Data(1))="Y" Then
       MonsterRecord.Spell=True
       TempX=Selection
       Call ShowNonplayer
       Next.Field=25
       Call ShowField
       Call NonplayerEdit
       Exit Sub
    Endif
 Case 25
    MonsterRecord.SpellPercent=Int(Val(Edit.Data(1))+.5)
 Case 26
    Edit.Data(1)=Lcase$(Edit.Data(1))
    Edit.Data(1)=Rtrim$(Edit.Data(1))
    If Edit.Data(1)=Nul Then
       MonsterRecord.Spell=False
       MonsterRecord.SpellPercent=False
    Else
       TempA=False
       For Temp2!=1! To Lof(SpellFile)/SpellRecLen
          Call Read.Record(SpellFile,Temp2!)
          If Left$(SpellRecord.SpellName,Len(Edit.Data(1)))=Edit.Data(1) Then
             TempA=True
             MonsterRecord.Spell=Temp2!
          Endif
       Next
       If TempA=False Then
          MonsterRecord.Spell=SFalse
          MonsterRecord.SpellPercent=False
          Strng="The spell was not found in the spell file."
          Call ErrorMessage
       Endif
    Endif
    TempX=24
    Call ShowNonplayer
    TempX=25
    Call ShowNonplayer
 Case 27
    If Ucase$(Edit.Data(1))="Y" Then
       MonsterRecord.Magic=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       MonsterRecord.Magic=False
    Endif
 Case 28
    If Ucase$(Edit.Data(1))="Y" Then
       MonsterRecord.Permanent=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       MonsterRecord.Permanent=False
    Endif
 Case 29
    If Ucase$(Edit.Data(1))="Y" Then
       Restore NonplayerEditData2
       Read Xcoor, Ycoor, Column, Line.Length, Max.Lines, Row, Line.Number
       Edit.Data(1)=Rtrim$(MonsterRecord.MonsterEquate)
       Strng="^ Cursor Edit   "
       Out2=Chr$(60)+Chr$(217)+" Exit Field"
       Call StatusLine
       Call ScreenEdit
       MonsterRecord.Equation=True
       MonsterRecord.MonsterEquate=Ucase$(Edit.Data$(1))
    Else
       MonsterRecord.Equation=False
       MonsterRecord.MonsterEquate=Nul
    Endif
 End Select
Error.Resume39:
 Exit Sub
Error.Trap39:
 Resume Error.Resume39
End Sub

NonplayerEditData:
 Data 4,2,2,30,1,4,1
 Data 7,2,2,30,1,7,1
 Data 9,8,8,5,1,9,1
 Data 11,7,7,5,1,11,1
 Data 13,13,13,20,1,13,1
 Data 15,7,7,20,1,15,1
 Data 17,7,7,1,1,17,1
 Data 19,7,7,5,1,19,1
 Data 19,26,26,3,1,19,1
 Data 21,10,10,1,1,21,1
 Data 21,22,22,20,1,21,1
 Data 3,58,58,5,1,3,1
 Data 5,52,52,1,1,5,1
 Data 5,68,68,3,1,5,1
 Data 7,57,57,1,1,7,1
 Data 7,68,68,3,1,7,1
 Data 9,51,51,1,1,9,1
 Data 9,68,68,3,1,9,1
 Data 11,53,53,1,1,11,1
 Data 11,68,68,3,1,11,1
 Data 13,52,52,1,1,13,1
 Data 13,68,68,3,1,13,1
 Data 13,72,72,3,1,13,1
 Data 15,56,56,1,1,15,1
 Data 15,68,68,3,1,15,1
 Data 17,51,51,20,1,17,1
 Data 19,53,53,1,1,19,1
 Data 19,65,65,1,1,21,1
 Data 20,54,54,1,1,20,1

NonplayerEditData2:
 Data 21,45,45,35,1,21,1

Sub ClearNonplayerSubstats
 On Local Error Goto Error.Trap62
 If TempD Then
    TempD=False
    Out3="Sysop Nonplayer Edit"
    Call DisplayEditScreen(8,29,Out3)
    Call NonplayerStatusLine
    Call DisplayNonplayer
 Endif
Error.Resume62:
 Exit Sub
Error.Trap62:
 Resume Error.Resume62
End Sub

Sub NonplayerSelect
 On Local Error Goto Error.Trap67
 Next.Field=False
 If TempX$=Chr$(9) Then
    TempX=77
 Endif
 Select Case TempX
 Case 77, 157, 116
    Select Case Selection
    Case 1
       Next.Field=12
    Case 2
       Next.Field=15
    Case 3
       Next.Field=17
    Case 4
       Next.Field=19
    Case 5
       Next.Field=21
    Case 6
       Next.Field=24
    Case 7
       Next.Field=26
    Case 8
       Next.Field=9
    Case 9
       Next.Field=27
    Case 10
       Next.Field=11
    Case 13
       Next.Field=14
    Case 15
       Next.Field=16
    Case 17
       Next.Field=18
    Case 19
       Next.Field=20
    Case 21
       Next.Field=22
    Case 22
       Next.Field=23
    Case 24
       Next.Field=25
    Case 27
       Next.Field=28
    End Select
 Case 15, 75, 155, 115
    Select Case Selection
    Case 9
       Next.Field=8
    Case 11
       Next.Field=10
    Case 12
       Next.Field=1
    Case 13
       Next.Field=2
    Case 14
       Next.Field=13
    Case 15
       Next.Field=2
    Case 16
       Next.Field=15
    Case 17
       Next.Field=3
    Case 18
       Next.Field=17
    Case 19
       Next.Field=4
    Case 20
       Next.Field=19
    Case 21
       Next.Field=5
    Case 22
       Next.Field=21
    Case 23
       Next.Field=22
    Case 24
       Next.Field=6
    Case 25
       Next.Field=24
    Case 26
       Next.Field=7
    Case 27
       Next.Field=9
    Case 28
       Next.Field=27
    Case 29
       Next.Field=11
    End Select
 Case 72, 141, 152
    Select Case Selection
    Case 2 To 8
       Next.Field=Selection-1
    Case 9
       Next.Field=7
    Case 10
       Next.Field=8
    Case 11
       Next.Field=9
    Case 12
       Next.Field=11
    Case 13
       Next.Field=12
    Case 15
       Next.Field=13
    Case 17
       Next.Field=15
    Case 19
       Next.Field=17
    Case 21
       Next.Field=19
    Case 24
       Next.Field=21
    Case 26
       Next.Field=24
    Case 27
       Next.Field=26
    Case 29
       Next.Field=27
    Case 14
       Next.Field=12
    Case 16
       Next.Field=14
    Case 18
       Next.Field=16
    Case 20
       Next.Field=18
    Case 22, 23
       Next.Field=20
    Case 25
       Next.Field=22
    Case 28
       Next.Field=25
    End Select
 Case 80, 145, 160
    Select Case Selection
    Case 1 To 7
       Next.Field=Selection+1
    Case 8
       Next.Field=10
    Case 9
       Next.Field=11
    Case 10, 11
       Next.Field=12
    Case 12
       Next.Field=13
    Case 13
       Next.Field=15
    Case 14
       Next.Field=16
    Case 15
       Next.Field=17
    Case 16
       Next.Field=18
    Case 17
       Next.Field=19
    Case 18
       Next.Field=20
    Case 19
       Next.Field=21
    Case 20
       Next.Field=23
    Case 21
       Next.Field=24
    Case 22
       Next.Field=25
    Case 23
       Next.Field=22
    Case 24
       Next.Field=26
    Case 25
       Next.Field=28
    Case 26
       Next.Field=27
    Case 27
       Next.Field=29
    Case 28
       Next.Field=29
    End Select
 Case 71, 119
    If Selection<>1 Then
       Next.Field=1
    Endif
 Case 79, 117
    If Selection<>29 Then
       Next.Field=29
    Endif
 Case 73, 132
    Select Case Selection
    Case 2 To 11
       Next.Field=1
    Case 13 To 29
       Next.Field=12
    End Select
 Case 81, 118
    Select Case Selection
    Case 1 To 8, 9, 11
       Next.Field=10
    Case 12 To 28
       Next.Field=29
    End Select
 End Select
 Call ShowField
Error.Resume67:
 Exit Sub
Error.Trap67:
 Resume Error.Resume67
End Sub

Sub EditMonsterTreasure
 On Local Error Goto Error.Trap204
 Treasure.Number=1
 Call DisplayMonsterTreasureScreen
 Do While Lost.Carrier=False
    Call MonsterTreasureStatusLine
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseCheck
          Exit Do
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 1
       TempX=Asc(TempX$)
       Select Case TempX
       Case 1
          Call AddMonsterTreasure
       Case 4
          Call DeleteMonsterTreasure
       Case 23
          Call SearchMonsterTreasure
       Case 27
          Call ClearNonplayerSubstats
          Exit Sub
       End Select
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       Select Case TempX
       Case 72, 141, 152
          Call PreviousMonsterTreasure
       Case 80, 145, 160
          Call NextMonsterTreasure
       End Select
    End Select
 Loop
Error.Resume204:
 Exit Sub
Error.Trap204:
 Resume Error.Resume204
End Sub

Sub DisplayMonsterTreasureScreen
 On Local Error Goto Error.Trap205
 If Room.Treasure=SFalse Then
    Treasure.Index=SFalse
    Treasure.Number=SFalse
    Call ShowMonsterTreasure
    Out2="There is no monster treasure to display."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Temp!=SFalse
 Treasure.Index=SFalse
 Room.Index=MonsterRecord.First
 If Room.Index Then
    Do While Lost.Carrier=False
       Call Read.Record(MonInvFile,Room.Index)
       Var2!=MessWorkRecord6.Next
       VarZ=False
       If MessWorkRecord6.User>SFalse Then
          Temp!=Temp!+1!
          If Temp!=Treasure.Number Then
             Treasure.Index=MessWorkRecord6.User
             Exit Do
          Endif
       Endif
       If Var2!=SFalse Then
          Exit Do
       Endif
       Room.Index=Var2!
    Loop
 Endif
 If Treasure.Index<=SFalse Or _
 Treasure.Index>Lof(TreasureFile)/TreasureRecLen Then
    Out2="The treasure number is not within the treasure file range."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Call ShowMonsterTreasure
Error.Resume205:
 Exit Sub
Error.Trap205:
 Resume Error.Resume205
End Sub

Sub MonsterTreasureStatusLine
 On Local Error Goto Error.Trap206
 Strng="^ Cursor Select <esc> Exit Treasure Display"
 Out2="^d Delete Treasure ^a Add Treasure ^w Search Treasure"
 Call StatusLine
Error.Resume206:
 Exit Sub
Error.Trap206:
 Resume Error.Resume206
End Sub

Sub ShowMonsterTreasure
 On Local Error Goto Error.Trap207
 Call MakeBox(6,33,12,79)
 TempD=True

 Title$="Treasure Number"+Str$(Treasure.Number)
 Call TitleBar(Title$)

 Call ANSI(4,37,40)
 Call ANSI(2,2,30)
 Strng=Space$(8)
 Call Scrn(Strng)
 Call ANSI(2,2,30)
 Strng=Mid$(Str$(Room.Treasure),2)
 Call Scrn(Strng)
 If Treasure.Index=SFalse Then
    Exit Sub
 Endif
 Call Read.Record(TreasureFile,Treasure.Index)
 Call ANSI(4,37,44)
 Call ANSI(2,7,34)
 Strng="Name:"
 Call Scrn(Strng)
 Strng=Left$(TreasureRecord.TreasureName,20)
 Call Scrn(Strng)
 Call ANSI(2,8,34)
 Strng="Identifier:"
 Call Scrn(Strng)
 Strng=Left$(TreasureRecord.ShortName,14)
 Strng=Lcase$(Strng)
 Call Scrn(Strng)
 Call ANSI(2,9,34)
 Strng="Weight:"
 Call Scrn(Strng)
 Strng=Mid$(Str$(TreasureRecord.Weight),2)
 Call Scrn(Strng)
 Call ANSI(2,10,34)
 Strng="Value:"
 Call Scrn(Strng)
' Strng=Mid$(Str$(TreasureRecord.Gold),2)
 VarX#=TreasureRecord.Gold
 Call Extend.Amount2(VarX#,Strng)
 Call Scrn(Strng)
 Call ANSI(2,11,34)
 Strng="Hits:"
 Call Scrn(Strng)
 Strng=Mid$(Str$(Abs(TreasureRecord.Plus)),2)
 Call Scrn(Strng)
 Call ANSI(2,7,60)
 Strng="Coins:"
 Call Scrn(Strng)
 If TreasureRecord.Coin Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,8,60)
 Strng="Potion:"
 Call Scrn(Strng)
 If TreasureRecord.Potion Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,9,60)
 Strng="Scroll:"
 Call Scrn(Strng)
 If TreasureRecord.Scroll Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,10,60)
 Strng="Invisible:"
 Call Scrn(Strng)
 If TreasureRecord.Invisible Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,11,60)
 Strng="Key Number:"
 Call Scrn(Strng)
 If TreasureRecord.MasterKey Then
    Strng="<master>"
 Else
    If TreasureRecord.KeyNumber>SFalse Then
       Strng=Right$(Str$(TreasureRecord.KeyNumber+1000000!),6)
    Else
       Strng="0"
    Endif
 Endif
 Call Scrn(Strng)
Error.Resume207:
 Exit Sub
Error.Trap207:
 Resume Error.Resume207
End Sub

Sub PreviousMonsterTreasure
 On Local Error Goto Error.Trap208
 If Treasure.Number=1! Or Room.Treasure=1! Then
    Out2="That is the first or only treasure. Can't cursor up."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Treasure.Number=Treasure.Number-1!
 Call DisplayMonsterTreasureScreen
Error.Resume208:
 Exit Sub
Error.Trap208:
 Resume Error.Resume208
End Sub

Sub NextMonsterTreasure
 On Local Error Goto Error.Trap209
 If Treasure.Number>=Room.Treasure Then
    Out2="That is the last or only treasure. Can't cursor down."
    Call ErrorStatusLine
 Else
    Treasure.Number=Treasure.Number+1!
    Call DisplayMonsterTreasureScreen
 Endif
Error.Resume209:
 Exit Sub
Error.Trap209:
 Resume Error.Resume209
End Sub

Sub DeleteMonsterTreasure
 On Local Error Goto Error.Trap210
 If Room.Treasure>SFalse Then
    Call Read.Record(MonInvFile,Room.Index)
    If MessWorkRecord6.Index=-Nonplayer.Number Then
       If MessWorkRecord6.User>SFalse Then
          Call Delete.List.Node2(Room.Index)
          Call Clear.List.Node
          Call Write.Record(MonInvFile,Room.Index)
          Room.Treasure=Room.Treasure-1!
          Out2="The treasure has been deleted from the inventory."
          Call ErrorStatusLine
          Treasure.Number=1!
          Call DisplayMonsterTreasureScreen
          Exit Sub
       Endif
    Endif
 Endif
 Out2="The treasure has not been deleted from the inventory."
 Call ErrorStatusLine
 Treasure.Number=1!
 Call DisplayMonsterTreasureScreen
Error.Resume210:
 Exit Sub
Error.Trap210:
 Resume Error.Resume210
End Sub

Sub AddMonsterTreasure
 On Local Error Goto Error.Trap211
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field  "
 Out2=Out2+"Append # sign and number for duplicate treasure"
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Treasure Name or Number: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,33)
 Strng=Space$(30)
 Call Scrn(Strng)
 Restore Data15a
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Temp2!=Int(Val(Edit.Data(1))+.5)
 If Temp2!=SFalse Then
    Temp.Index=SFalse
    Var$=Edit.Data(1)
    Var=Instr(Var$,"#")
    If Var Then
       Edit.Data(1)=Left$(Var$,Var-1)
       Var$=Mid$(Var$,Var+1)
       Temp.Index=Int(Val(Var$)+.5)
    Endif
    Edit.Data(1)=Lcase$(Edit.Data(1))
    If Edit.Data(1)<>Nul Then
       Temp3!=SFalse
       For Temp2!=1! To Lof(TreasureFile)/TreasureRecLen
          Call Read.Record(TreasureFile,Temp2!)
          If Left$(TreasureRecord.TreasureName, _
          Len(Edit.Data(1)))=Edit.Data(1) Then
             Temp3!=Temp3!+1!
             If Temp.Index=Temp3! Or Temp.Index=SFalse Then
                Exit For
             Endif
          Endif
       Next
    Endif
 Endif
 If Temp2!<=SFalse Or Temp2!>Lof(TreasureFile)/TreasureRecLen Then
    Out2="The treasure name was not found in the treasure file."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Call Read.Record(TreasureFile,Temp2!)
 Temp3!=Lof(MonInvFile)/MessWorkRecLen6+1!
 MessWorkRecord6.Index=-Nonplayer.Number
 MessWorkRecord6.Room=SFalse
 MessWorkRecord6.User=Temp2!
 MessWorkRecord6.Charges=TreasureRecord.Charges
 MessWorkRecord6.Plus=False
 Call Add.List.Node2(Temp3!)
 Room.Treasure=Room.Treasure+1!
 Treasure.Number=1!
 Call DisplayMonsterTreasureScreen
Error.Resume211:
 Exit Sub
Error.Trap211:
 Resume Error.Resume211
End Sub

Sub SearchMonsterTreasure
 On Local Error Goto Error.Trap212
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field  "
 Out2=Out2+"Append # sign and number for duplicate treasure"
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Treasure Name or Number: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,33)
 Strng=Space$(30)
 Call Scrn(Strng)
 Restore Data16a
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Temp2!=Int(Val(Edit.Data(1))+.5)
 Temp$=Lcase$(Edit.Data(1))
 Temp.Index=SFalse
 Temp1=Instr(Temp$,"#")
 If Temp1 Then
    Temp.Index=Csng(Int(Val(Mid$(Temp$,Temp1+1))+.5))
    Temp$=Left$(Temp$,Temp1-1)
 Endif
 If Temp2!<=SFalse Or Temp2!>Lof(TreasureFile)/TreasureRecLen Then
    Temp2!=SFalse
 Endif
 If Temp2!=SFalse Then
    Temp4=Len(Temp$)
    Temp3!=SFalse
    For Temp5!=1! To Lof(TreasureFile)/TreasureRecLen
       Call Read.Record(TreasureFile,Temp5!)
       Out3=Rtrim$(TreasureRecord.TreasureName)
       Call InstrSUB(TempX,Out3,Temp$)
       If TempX Then
          Temp3!=Temp3!+1!
          If Temp3!=Temp.Index Or Temp.Index=SFalse Then
             Temp2!=Temp5!
             Exit For
          Endif
       Endif
    Next
 Endif
 If Temp2!=SFalse Then
    Out2="The treasure name was not found in the treasure file."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Treasure.Number=Temp2!
 Treasure.Index=Temp2!
 Call ShowMonsterTreasure
 Out2="To exit treasure search display,"
 Call ErrorStatusLine
 Treasure.Number=1!
 Call DisplayMonsterTreasureScreen
Error.Resume212:
 Exit Sub
Error.Trap212:
 Resume Error.Resume212
End Sub

Sub EditMonsterObject
 On Local Error Goto Error.Trap213
 Object.Number=1
 Call DisplayMonsterObjectScreen
 Do While Lost.Carrier=False
    Call MonsterObjectStatusLine
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseCheck
          Exit Do
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 1
       TempX=Asc(TempX$)
       Select Case TempX
       Case 1
          Call AddMonsterObject
       Case 4
          Call DeleteMonsterObject
       Case 23
          Call SearchMonsterObject
       Case 27
          Call ClearNonplayerSubstats
          Exit Sub
       End Select
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       Select Case TempX
       Case 72, 141, 152
          Call PreviousMonsterObject
       Case 80, 145, 160
          Call NextMonsterObject
       End Select
    End Select
 Loop
Error.Resume213:
 Exit Sub
Error.Trap213:
 Resume Error.Resume213
End Sub

Sub DisplayMonsterObjectScreen
 On Local Error Goto Error.Trap214
 If Room.Objects=SFalse Then
    Object.Index=SFalse
    Object.Number=SFalse
    Call ShowMonsterObject
    Out2="There are no monster objects to display."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Temp!=SFalse
 Object.Index=SFalse
 Room.Index=MonsterRecord.First
 If Room.Index Then
    Do While Lost.Carrier=False
       Call Read.Record(MonInvFile,Room.Index)
       Var2!=MessWorkRecord6.Next
       If MessWorkRecord6.User<SFalse Then
          Temp!=Temp!+1!
          If Temp!=Object.Number Then
             Object.Index=Abs(MessWorkRecord6.User)
             Exit Do
          Endif
       Endif
       If Var2!=SFalse Then
          Exit Do
       Endif
       Room.Index=Var2!
    Loop
 Endif
 If Object.Index<=SFalse Or Object.Index>Lof(ObjectFile)/ObjectRecLen Then
    Out2="The object number is not within the object file range."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Call ShowMonsterObject
Error.Resume214:
 Exit Sub
Error.Trap214:
 Resume Error.Resume214
End Sub

Sub MonsterObjectStatusLine
 On Local Error Goto Error.Trap215
 Strng="^ Cursor Select <esc> Exit Object Display"
 Out2="^d Delete Object ^a Add Object ^w Search Objects"
 Call StatusLine
Error.Resume215:
 Exit Sub
Error.Trap215:
 Resume Error.Resume215
End Sub

Sub ShowMonsterObject
 On Local Error Goto Error.Trap216
 Call MakeBox(6,33,12,79)
 TempD=True

 Title$="Object Number"+Str$(Object.Number)
 Call TitleBar(Title$)

 Call ANSI(4,37,40)
 Call ANSI(2,2,47)
 Strng=Space$(8)
 Call Scrn(Strng)
 Call ANSI(2,2,47)
 Strng=Mid$(Str$(Room.Objects),2)
 Call Scrn(Strng)
 If Object.Index=SFalse Then
    Exit Sub
 Endif
 Call Read.Record(ObjectFile,Object.Index)
 Call ANSI(4,37,44)
 Call ANSI(2,7,34)
 Strng="Name:"
 Call Scrn(Strng)
 Strng=Left$(ObjectRecord.ObjectName,20)
 Call Scrn(Strng)
 Call ANSI(2,8,34)
 Strng="Identifier:"
 Call Scrn(Strng)
 Strng=Left$(ObjectRecord.ShortName,14)
 Strng=Lcase$(Strng)
 Call Scrn(Strng)
 Call ANSI(2,9,34)
 Strng="Room Links:"
 Call Scrn(Strng)
 Strng=Mid$(Str$(ObjectRecord.RoomLink1),2)+","
 Call Scrn(Strng)
 Strng=Mid$(Str$(ObjectRecord.RoomLink2),2)
 Call Scrn(Strng)
 Call ANSI(2,10,34)
 Strng="Permanent:"
 Call Scrn(Strng)
 If ObjectRecord.Permanent Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,11,34)
 Strng="Hiding:"
 Call Scrn(Strng)
 Call Scrn("No")
 Call ANSI(2,7,60)
 Strng="Hidden:"
 Call Scrn(Strng)
 If ObjectRecord.Hidden Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,8,60)
 Strng="Invisible:"
 Call Scrn(Strng)
 If ObjectRecord.Invisible Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,9,60)
 Strng="Trapped:"
 Call Scrn(Strng)
 If ObjectRecord.JailTrap Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,10,60)
 Strng="Locked:"
 Call Scrn(Strng)
 If ObjectRecord.DoorLock>1 Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,11,60)
 Strng="Relocks:"
 Call Scrn(Strng)
 If ObjectRecord.Relocks Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
Error.Resume216:
 Exit Sub
Error.Trap216:
 Resume Error.Resume216
End Sub

Sub PreviousMonsterObject
 On Local Error Goto Error.Trap217
 If Object.Number=1! Or Room.Objects=1! Then
    Out2="That is the first or only object. Can't cursor up."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Object.Number=Object.Number-1!
 Call DisplayMonsterObjectScreen
Error.Resume217:
 Exit Sub
Error.Trap217:
 Resume Error.Resume217
End Sub

Sub NextMonsterObject
 On Local Error Goto Error.Trap218
 If Object.Number>=Room.Objects Then
    Out2="That is the last or only object. Can't cursor down."
    Call ErrorStatusLine
 Else
    Object.Number=Object.Number+1!
    Call DisplayMonsterObjectScreen
 Endif
Error.Resume218:
 Exit Sub
Error.Trap218:
 Resume Error.Resume218
End Sub

Sub DeleteMonsterObject
 On Local Error Goto Error.Trap219
 If Room.Objects>SFalse Then
    Call Read.Record(MonInvFile,Room.Index)
    If MessWorkRecord6.Index=-Nonplayer.Number Then
       If MessWorkRecord6.User<SFalse Then
          Call Delete.List.Node2(Room.Index)
          Call Clear.List.Node
          Call Write.Record(MonInvFile,Room.Index)
          Room.Objects=Room.Objects-1!
          Out2="The object has been deleted from the inventory."
          Call ErrorStatusLine
          Object.Number=1!
          Call DisplayMonsterObjectScreen
          Exit Sub
       Endif
    Endif
 Endif
 Out2="The object has not been deleted from the inventory."
 Call ErrorStatusLine
 Object.Number=1!
 Call DisplayMonsterObjectScreen
Error.Resume219:
 Exit Sub
Error.Trap219:
 Resume Error.Resume219
End Sub

Sub AddMonsterObject
 On Local Error Goto Error.Trap220
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field  "
 Out2=Out2+"Append # sign and number for duplicate objects"
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Object Name or Number: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,31)
 Strng=Space$(30)
 Call Scrn(Strng)
 Restore Data13a
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Temp2!=Int(Val(Edit.Data(1))+.5)
 If Temp2!=SFalse Then
    Temp.Index=SFalse
    Var$=Edit.Data(1)
    Var=Instr(Var$,"#")
    If Var Then
       Edit.Data(1)=Left$(Var$,Var-1)
       Var$=Mid$(Var$,Var+1)
       Temp.Index=Int(Val(Var$)+.5)
    Endif
    Edit.Data(1)=Lcase$(Edit.Data(1))
    If Edit.Data(1)<>Nul Then
       Temp3!=SFalse
       For Temp2!=1! To Lof(ObjectFile)/ObjectRecLen
          Call Read.Record(ObjectFile,Temp2!)
          If Left$(ObjectRecord.ObjectName, _
          Len(Edit.Data(1)))=Edit.Data(1) Then
             Temp3!=Temp3!+1!
             If Temp3!=Temp.Index Or Temp.Index=SFalse Then
                Exit For
             Endif
          Endif
       Next
    Endif
 Endif
 If Temp2!<=SFalse Or Temp2!>Lof(ObjectFile)/ObjectRecLen Then
    Out2="The object name was not found in the object file."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Call Read.Record(ObjectFile,Temp2!)
 Temp3!=Lof(MonInvFile)/MessWorkRecLen6+1!
 MessWorkRecord6.Index=-Nonplayer.Number
 MessWorkRecord6.Room=SFalse
 MessWorkRecord6.User=-Temp2!
 MessWorkRecord6.Charges=False
 MessWorkRecord6.Plus=False
 Call Add.List.Node2(Temp3!)
 Room.Objects=Room.Objects+1!
 Object.Number=1!
 Call DisplayMonsterObjectScreen
Error.Resume220:
 Exit Sub
Error.Trap220:
 Resume Error.Resume220
End Sub

Sub SearchMonsterObject
 On Local Error Goto Error.Trap221
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field  "
 Out2=Out2+"Append # sign and number for duplicate objects"
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Object Name or Number: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,31)
 Strng=Space$(30)
 Call Scrn(Strng)
 Restore Data14a
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Temp2!=Int(Val(Edit.Data(1))+.5)
 Temp$=Lcase$(Edit.Data(1))
 Temp.Index=SFalse
 Temp1=Instr(Temp$,"#")
 If Temp1 Then
    Temp.Index=Val(Mid$(Temp$,Temp1+1))
    Temp$=Left$(Temp$,Temp1-1)
 Endif
 If Temp2!<=SFalse Or Temp2!>Lof(ObjectFile)/ObjectRecLen Then
    Temp2!=SFalse
 Endif
 If Temp2!=SFalse Then
    Temp4=Len(Temp$)
    Temp3!=SFalse
    For Temp5!=1! To Lof(ObjectFile)/ObjectRecLen
       Call Read.Record(ObjectFile,Temp5!)
       Out3=Rtrim$(ObjectRecord.ObjectName)
       Call InstrSUB(TempX,Out3,Temp$)
       If TempX Then
          Temp3!=Temp3!+1!
          If Temp3!=Temp.Index Or Temp.Index=SFalse Then
             Temp2!=Temp5!
             Exit For
          Endif
       Endif
    Next
 Endif
 If Temp2!=SFalse Then
    Out2="The object name was not found in the object file."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Object.Number=Temp2!
 Object.Index=Temp2!
 Call ShowMonsterObject
 Out2="To exit object search display,"
 Call ErrorStatusLine
 Object.Number=1!
 Call DisplayMonsterObjectScreen
Error.Resume221:
 Exit Sub
Error.Trap221:
 Resume Error.Resume221
End Sub

Sub Delete.List.Node2(VarZ!)
 On Local Error Goto ErrorTrp32b
 If MonsterRecord.First=VarZ! Then
    Call Read.Record(MonInvFile,VarZ!)
    MonsterRecord.First=MessWorkRecord6.Next
    Call Write.Record(NonplayerFile,Nonplayer.Number)
    If MonsterRecord.First>SFalse Then
       Call Read.Record(MonInvFile,MonsterRecord.First)
       MessWorkRecord6.Prev=SFalse
       Call Write.Record(MonInvFile,MonsterRecord.First)
    Endif
 Else
    If MonsterRecord.Last=VarZ! Then
       Call Read.Record(MonInvFile,VarZ!)
       MonsterRecord.Last=MessWorkRecord6.Prev
       Call Write.Record(NonplayerFile,Nonplayer.Number)
       If MonsterRecord.Last>SFalse Then
          Call Read.Record(MonInvFile,MonsterRecord.Last)
          MessWorkRecord6.Next=SFalse
          Call Write.Record(MonInvFile,MonsterRecord.Last)
       Endif
    Else
       Call Read.Record(MonInvFile,VarZ!)
       Previous.Node!=MessWorkRecord6.Prev
       Next.Node!=MessWorkRecord6.Next
       Call Read.Record(MonInvFile,Previous.Node!)
       MessWorkRecord6.Next=Next.Node!
       Call Write.Record(MonInvFile,Previous.Node!)
       Call Read.Record(MonInvFile,Next.Node!)
       MessWorkRecord6.Prev=Previous.Node!
       Call Write.Record(MonInvFile,Next.Node!)
    Endif
 Endif
ErrorRsm32b:
 Exit Sub
ErrorTrp32b:
 Resume ErrorRsm32b
End Sub

Sub Clear.List.Node
 On Local Error Goto ErrorTrp32c
 MessWorkRecord6.User=SFalse
 MessWorkRecord6.Room=SFalse
 MessWorkRecord6.Index=SFalse
 MessWorkRecord6.Charges=False
 MessWorkRecord6.Plus=False
 MessWorkRecord6.Prev=SFalse
 MessWorkRecord6.Next=SFalse
ErrorRsm32c:
 Exit Sub
ErrorTrp32c:
 Resume ErrorRsm32c
End Sub

Sub Add.List.Node2(VarZ!)
 On Local Error Goto ErrorTrp27b
 If MonsterRecord.First=SFalse Then
    MonsterRecord.First=VarZ!
    MonsterRecord.Last=VarZ!
    Call Write.Record(NonplayerFile,Nonplayer.Number)
    MessWorkRecord6.Prev=SFalse
    MessWorkRecord6.Next=SFalse
    Call Write.Record(MonInvFile,VarZ!)
    Exit Sub
 Endif
 MessWorkRecord6.Prev=MonsterRecord.Last
 MessWorkRecord6.Next=SFalse
 Call Write.Record(MonInvFile,VarZ!)
 Call Read.Record(MonInvFile,MonsterRecord.Last)
 MessWorkRecord6.Next=VarZ!
 Call Write.Record(MonInvFile,MonsterRecord.Last)
 Call Read.Record(MonInvFile,VarZ!)
 MonsterRecord.Last=VarZ!
 Call Write.Record(NonplayerFile,Nonplayer.Number)
ErrorRsm27b:
 Exit Sub
ErrorTrp27b:
 Resume ErrorRsm27b
End Sub

Data13a:
 Data 23,31,31,30,23,1,1
Data14a:
 Data 23,31,31,30,23,1,1
Data15a:
 Data 23,33,33,30,23,1,1
Data16a:
 Data 23,33,33,30,23,1,1

Sub Extend.Amount2(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$=" "+Format$(Var#,"#,##0;;")
 Endif
End Sub

