 Rem File: Cmd104.bas
 Rem Sub: Drop.Object
 Rem $Include: 'dndbbs.inc'
 On Error Goto Main.Error
 If Chained<>-2 Then
    Color 15,0
    Print "DNDBBS Command 104 -- Drop.Object."
    Color 7,0
    End
 Endif
 Call Drop.Object
Main.Resume:
 Chain DND.Path+"DNDBBS.EXE"
 End
Main.Error:
 Resume Main.Resume

Sub Drop.Object
 On Local Error Goto ErrTrap23
 Gosub Get.Config1
 If Lcase$(Parsed.Command1)="all" Then
    If Config2(137)=False Then
       Strng="Drop all not allowed."
       Call IO.O
       Exit Sub
    Endif
    Call Drop.All.Items
    Exit Sub
 Endif
 VarX#=Int(Val(Parsed.Command1)+.5)
 If VarX#>DFalse Then
    If VarX#<=UserRecord.Gold Then
       If VarX#<=Option1# Or Option1#=-1# Then
          Close #TempFile1
          FileName=DND.Path+"coins.dat"
          Open FileName For Random Shared As #TempFile1 Len=16
          Field #TempFile1, 4 As R$, 8 As G$, 2 As P1$, 2 As P2$
          V! = Lof(TempFile1)/16+1!
          LSET R$ = MKS$(Room)
          LSET G$ = MKD$(VarX#)
          LSET P1$ = MKI$(0%)
          LSET P2$ = MKI$(0%)
          PUT #TempFile1, V!
          UserRecord.Gold=UserRecord.Gold-VarX#
          Call Amount(VarX#,VarQ$)
          Strng="You drop"+VarQ$+" gold!"
          Call IO.O
          Exit Sub
       Else
          Strng="You can't drop that much gold!"
          Call IO.O
          Exit Sub
       Endif
    Else
       Strng="You don't have that much gold!"
       Call IO.O
       Exit Sub
    Endif
 Endif
 Call Parse
 If Parser Then
    Call Numeric
 Endif
 Call Check.User.Items
 If Temp7!<SFalse Then
    Call Drop.Item.In.Room(Temp7!,Temp6)
    MessWorkRecord6.Room=SFalse
    MessWorkRecord6.User=SFalse
    MessWorkRecord6.Index=SFalse
    MessWorkRecord6.Charges=False
    MessWorkRecord6.Plus=False
    MessWorkRecord6.Prev=SFalse
    MessWorkRecord6.Next=SFalse
    Call Write.Record(MessWorkFile6,Temp5!)
    Graphics.Off=False
    Strng2=Rtrim$(ObjectRecord.Prefix1)
    Out3=Lcase$(Out3)
    Strng="You drop "+Strng2+Out3
    Call Convert.ANSI(True,VarQ,VarR)
    Carriage.Return=True
    Graphics.On=True
    Call IO.O
    Strng=Nul
    If ObjectRecord.Invisible Then
       Strng=" [inv]"
    Endif
    Graphics.On=False
    Graphics.Off=True
    Strng=Strng+"!"
    Call IO.O
    Graphics.Off=False
    Exit Sub
 Endif
 If Temp7!>SFalse Then
    If TreasureRecord.Container Then
       Call Drop.Container.In.Room(Temp7!)
       Call Discard(Temp5!,True)
    Else
       Call Discard(Temp5!,False)
    Endif
    Graphics.Off=False
    Strng2=Rtrim$(TreasureRecord.Prefix1)
    Out3=Lcase$(Out3)
    Strng="You drop "+Strng2+Out3
    Call Convert.ANSI(True,VarQ,VarR)
    Carriage.Return=True
    Graphics.On=True
    Call IO.O
    Strng=Nul
    If TreasureRecord.LightType Then
       If MessWorkRecord6.Charges<False Then
          Strng=" [lit]"
       Endif
    Endif
    If TreasureRecord.Invisible Then
       Strng=Strng+" [inv]"
    Endif
    Graphics.On=False
    Graphics.Off=True
    Strng=Strng+"!"
    Call IO.O
    Graphics.Off=False
    Exit Sub
 Endif
 Call Num
 Call Search.User.Containers
 If TempA! Then
    Call Drop.Container
    Exit Sub
 Endif
 Strng="You can't drop that!"
 Call IO.O
 Exit Sub

Get.Config1:
 Option1#=1D100
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Goto Next.Read
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[CMD104]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Goto Next.Read
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Goto Next.Read
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Gosub Parse.Options
          Endif
       Loop
    Endif
 Loop
 Return
Next.Read:
 Close #TempFile1
 Filename$=DND.Path+"CMD104.CFG"
 If Dir$(Filename$)="" Then
    Return
 Endif
 Open Filename$ For Input As #TempFile1
 Do
    If Eof(TempFile1) Then
       Exit Do
    Endif
    Line Input #TempFile1, Var$
    Var$=Ltrim$(Rtrim$(Var$))
    If Left$(Var$,1)<>";" Then
       VarX$=UserRecord.CodeName
       VarX$=Rtrim$(VarX$)
       VarX$=Ucase$(VarX$)
       If Ucase$(Var$)="["+VarX$+"]" Then
          VarZ=0
          Option1#=1D100
          Do
             If Eof(TempFile1) Then
                Exit Do
             Endif
             Line Input #TempFile1, Var$
             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)))
                Gosub Parse.Options
             Endif
          Loop
       Endif
    Endif
 Loop
 Return
Parse.Options:
 Select Case Lcase$(Var2$)
 Case "drop.gold.maximum"
    Option1#=Int(Val(Var3$)+.5)
 End Select
 Return
ErrResume23:
 Exit Sub
ErrTrap23:
 Resume ErrResume23
End Sub
