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

Sub Fire.Object
 On Local Error Goto ErrorTrap48
 Gosub Get.Config
 Call Parse
 If Parser Then
    Call Numeric
 Endif
 Call Check.User.Items
 If Temp7!<=SFalse Then
    Strng="You can't fire that!"
    Call IO.O
    Exit Sub
 Endif
 If TreasureRecord.Loadable=False Then
    Strng="You can't fire that!"
    Call IO.O
    Exit Sub
 Endif
 If TreasureRecord.AmmoLoads=SFalse Then
    Strng="It's not loaded with ammunition!"
    Call IO.O
    Exit Sub
 Endif
 Call Read.Record(TreasureFile,TreasureRecord.AmmoLoads)
 If TreasureRecord.Ammunition=False Then
    Strng="It's not loaded with ammunition!"
    Call IO.O
    Exit Sub
 Endif
 Call Read.Record(TreasureFile,Temp7!)
 If MessWorkRecord6.Charges<=False Then
    Strng="It's not loaded!"
    Call IO.O
    Exit Sub
 Endif
 MessWorkRecord6.Charges=MessWorkRecord6.Charges-1
 Call Write.Record(MessWorkFile6,Temp5!)
 Parsed.Command1=Parsed.Command2
 Call Numeric
 If Len(option1$) Then
    Out2=option1$
    Call Equate(Temp#)
 Else
    Temp#=Rnd<Config1(12)
 Endif
 If Temp# Then
    Strng="Bang! The ammunition explodes in your face!"
    Call IO.O
    Prefix2=Nul
    Strng="The device hits you for"
    Out3="loading ammunition"
    Temp2=Int(Rnd*TreasureRecord.Plus+1)
    Call Hit.Player(Temp2)
    Exit Sub
 Endif
 If Len(option2$) Then
    Out2=option2$
    Call Equate(Temp#)
 Else
    Temp#=Rnd<Config1(13)
 Endif
 If Temp# Then
    Strng="The device fires harmlessly!"
    Call IO.O
    Exit Sub
 Endif
 Out5=TreasureRecord.ShortName
 Out5=Rtrim$(Out5)
 Out5=Lcase$(Out5)
 TempC=False
 Call Check.Monster
 If Monster.Temp Then
    Out3=MessWorkRecord3.Monster.MonsterName
    Out3=Rtrim$(Out3)
    Out3=Lcase$(Out3)
    Strng="You fire the "+Out5+" at the "+Out3+"!"
    Call IO.O
    Multiplier=TreasureRecord.Plus
    Call Hit.Monster
    Exit Sub
 Endif
 Call Num
 Call Search.Mess(SFalse)
 If Temp!=Room And TempB!<>User.Index Then
    User.Temp=TempB!
    Out3=MessWorkRecord1.UserName
    Out3=Rtrim$(Out3)
    Out3=Lcase$(Out3)
    Strng="You fire "+Out5+" at "+Out3+"!"
    Call IO.O
    Out2=TreasureRecord.TreasureName
    Out2=Lcase$(Out2)
    Out2=Rtrim$(Out2)
    Call Send.Mess(22,TempB!,Room,Out2)
    Call Hit.Game.Player
    Exit Sub
 Endif
 Strng="The device fires into empty air!"
 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$)="[CMD049]" 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 "device.explodes"
                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 "device.misfires"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option2$=Mid$(Var3$,2)
                      option2$=Left$(option2$,Len(option2$)-1)
                   Endif
                Endif
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrorResume48:
 Exit Sub
ErrorTrap48:
 Resume ErrorResume48
End Sub
