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

Sub Throw.Object
 On Local Error Goto ErrTrap20
 Gosub Get.Config
 Call ParseX
 If Parser Then
    Call Numeric
 Endif
 Var!=UserRecord.Weapon(7).Index
 Var2=UserRecord.Weapon(7).Charges
 If Var!>SFalse And Var!<=Lof(TreasureFile)/TreasureRecLen Then
    Call Read.Record(TreasureFile,Var!)
    Out3=TreasureRecord.ShortName
    Out3=Left$(Out3,Len(Parsed.Command2))
    If Out3=Parsed.Command2 Then
       Out4=Out3
       ' throw direction
       For TempA=1 To MaxDirections
          Out3=Direction(TempA)
          Out3=Rtrim$(Out3)
          Out3=Ucase$(Out3)
          If Out3=Parsed.Command1 Then
             Next.Room=RoomRecord.Direct(TempA)
             If Next.Room=SFalse Then
                Strng="You can't throw in that direction!"
                Call IO.O
                Exit Sub
             Endif
             Strng="You throw a "+Lcase$(Out4)+" "
             Strng=Strng+Lcase$(Rtrim$(Direction(TempA)))+"!"
             Call IO.O
             ' remove from inventory
             UserRecord.Weapon(7).Index=SFalse
             UserRecord.Weapon(7).Charges=False
             ' drop in room
             Swap Room,Next.Room
             Call Drop.Inventory(Var!,Var2)
             Swap Room,Next.Room
             Exit Sub
          Endif
       Next
       ' custom room direction#1
       Call Read.Record(RoomFile,Room)
       Out3=Rtrim$(RoomRecord.Custom1)
       If Out3=String$(12,Chr$(0)) Then
          Out3=Nul
       Endif
       If Len(Out3) Then
          If Ucase$(Out3)=Parsed.Command1 Then
             TempA=13
             Next.Room=RoomRecord.Direct(TempA)
             If Next.Room=SFalse Then
                Strng="You can't throw in that direction!"
                Call IO.O
                Exit Sub
             Endif
             Strng="You throw a "+Lcase$(Out4)+" "
             Strng=Strng+Lcase$(Rtrim$(Out3))+"!"
             Call IO.O
             ' remove from inventory
             UserRecord.Weapon(7).Index=SFalse
             UserRecord.Weapon(7).Charges=False
             ' drop in room
             Swap Room,Next.Room
             Call Drop.Inventory(Var!,Var2)
             Swap Room,Next.Room
             Exit Sub
          Endif
       Endif
       ' custom room direction#2
       Call Read.Record(RoomFile,Room)
       Out3=Rtrim$(RoomRecord.Custom2)
       If Out3=String$(12,Chr$(0)) Then
          Out3=Nul
       Endif
       If Len(Out3) Then
          If Ucase$(Out3)=Parsed.Command1 Then
             TempA=14
             Next.Room=RoomRecord.Direct(TempA)
             If Next.Room=SFalse Then
                Strng="You can't throw in that direction!"
                Call IO.O
                Exit Sub
             Endif
             Strng="You throw a "+Lcase$(Out4)+" "
             Strng=Strng+Lcase$(Rtrim$(Out3))+"!"
             Call IO.O
             ' remove from inventory
             UserRecord.Weapon(7).Index=SFalse
             UserRecord.Weapon(7).Charges=False
             ' drop in room
             Swap Room,Next.Room
             Call Drop.Inventory(Var!,Var2)
             Swap Room,Next.Room
             Exit Sub
          Endif
       Endif
       ' throw at monster
       Multiplier=UserRecord.Weapon(7).Plus
       Last.Monster=Parsed.Command1
       Strng="You throw a "+Lcase$(Out4)+"!"
       Call IO.O
       If Var2=False Then
          Strng="You missed!"
          Call IO.O
       Else
          If Len(option1$) Then
             Out2=option1$
             Call Equate(Temp#)
          Else
             Temp#=Int(Rnd*5+2)>UserRecord.Stats(4)/2
          Endif
          If Temp# Then
             Strng="You missed!"
             Call IO.O
          Else
             Var2=Var2-1
             Parsed.Command1=Last.Monster
             Last.Command.Number=Killed
             Call Attack.Monster(VarZ)
          Endif
       Endif
       UserRecord.Weapon(7).Index=SFalse
       UserRecord.Weapon(7).Charges=False
       Call Drop.Inventory(Var!,Var2)
       Exit Sub
    Endif
 Endif
 Strng="You can't throw that!"
 Call IO.O
 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$)="[CMD017]" 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 "throw.item.equation"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option1$=Mid$(Var3$,2)
                      option1$=Left$(option1$,Len(option1$)-1)
                   Endif
                Endif
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrResume20:
 Exit Sub
ErrTrap20:
 Resume ErrResume20
End Sub
