 Rem File: Cmd000.bas
 Rem Sub: Attack.Monster
 Rem $Include: 'dndbbs.inc'
 On Error Goto Main.Error
 If Chained<>-2 Then
    Color 15,0
    Print "DNDBBS Command 000 -- Attack.Monster."
    Color 7,0
    End
 Endif
 If TempX=False Then ' kill
    Call Attack.Monster(VarZ)
 Else
    If TempX=True Then ' !kill
       Call Kill.Monster
    Endif
 Endif
Main.Resume:
 Chain DND.Path+"DNDBBS.EXE"
 End
Main.Error:
 Resume Main.Resume

Sub Kill.Monster
 On Local Error Goto ErrorTrap34
 Gosub Get.Config2

 ' !kill self
 If Lcase$(Parsed.Command1)="self" Then
    If Option1 Then
       Call Kill.Self
    Else
       Strng="You can't kill yourself!"
       Call IO.O
    Endif
    Exit Sub
 Endif

 ' !kill all
 If Lcase$(Parsed.Command1)="all" Then
    If Config2(141)=False Then
       Strng="You can't kill that!"
       Call IO.O
       Exit Sub
    Endif
    Graphics.Off=True
    Strng="Evil Laughter Sounds From Above..."
    Call IO.O
    Strng="   A Bolt of Lightning Strikes..."
    Call IO.O
    VarQ=0
    For Var5!=1! To Lof(MessWorkFile3)/MessWorkRecLen3
       Call Read.Record(MessWorkFile3,Var5!)
       If MessWorkRecord3.Room=Room Then
          VarQ=-1
          Out3=MessWorkRecord3.Monster.MonsterName
          Out3=Rtrim$(Out3)
          Temp5!=Var5!
          Choice=MessWorkRecord3.Index
          Monster.Temp=Temp5!
          Last.Monster=Out3

          Strng3=Rtrim$(MessWorkRecord3.Monster.Prefix1)
          Out3=Lcase$(Out3)

          Strng="The "+Strng3+Out3
          Call Convert.ANSI(True,VarQ,VarR)
          Carriage.Return=True
          Graphics.On=True
          Call IO.O
          Graphics.On=False
          Graphics.Off=True
          Strng=" was just struck dead!"
          Call IO.O

          Call The.Or.An
          Call Monster.Died
       Endif
    Next
    If VarQ=0 Then
       Strng="Nothing happens!"
       Call IO.O
    Endif
    Exit Sub
 Endif

 ' online monster
 Monster.Temp=SFalse
 Call Check.Monster
 If Monster.Temp Then
    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

    Strng3=Rtrim$(MessWorkRecord3.Monster.Prefix1)
    Out3=Lcase$(Out3)

    Strng="The "+Strng3+Out3
    Call Convert.ANSI(True,VarQ,VarR)
    Carriage.Return=True
    Graphics.On=True
    Call IO.O
    Graphics.On=False
    Graphics.Off=True
    Strng=" was just struck dead!"
    Call IO.O

    Call The.Or.An
    Call Monster.Died
    Exit Sub
 Endif

 ' offline user
 User.Temp=SFalse
 Call Check.User
 If User.Temp Then
    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

    Strng3=Rtrim$(UserRecord2.Prefix1)
    Out3=Lcase$(Out3)

    Strng="You just killed "+Strng3+Out3
    Call Convert.ANSI(True,VarQ,VarR)
    Carriage.Return=True
    Graphics.On=True
    Call IO.O
    Graphics.On=False
    Graphics.Off=True
    Strng="!"
    Call IO.O

    Call User.Died
    Exit Sub
 Endif

 ' online user
 Call Search.Mess(SFalse)
 If Temp!>SFalse Then
    If TempB!=User.Index Then
       If Option1 Then
          Call Kill.Self
       Else
          Strng="You can't kill yourself!"
          Call IO.O
       Endif
       Exit Sub
    Endif

    Graphics.Off=True
    Strng="Evil Laughter Sounds From Above..."
    Call IO.O
    Strng="   A Bolt of Lightning Strikes..."
    Call IO.O
    Graphics.Off=False

    Call Read.Record(UserFile2,TempB!)
    Strng3=Rtrim$(UserRecord2.Prefix1)

    Strng="You just killed "+Strng3+Out3
    Call Convert.ANSI(True,VarQ,VarR)
    Carriage.Return=True
    Graphics.On=True
    Call IO.O
    Graphics.On=False
    Graphics.Off=True
    Strng="!"
    Call IO.O

    Out2=Out3+" was just struck dead!"
    Call Send.Mess(5,SFalse,SFalse,Out2)
    Call Send.Mess(17,TempB!,Room,"Murdered")
    Exit Sub
 Endif
 Strng="You can't kill that!"
 Call IO.O
 Exit Sub
Get.Config2:
 VarX=0
 Option1=-1
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Goto Next.Read
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[CMD000]" 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+"CMD000.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=-1
          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 Var2$
 Case "kill.self"
    Select Case Lcase$(Var3$)
    Case "0","false","off"
       Option1=0
    End Select
 End Select
Return
ErrorResume34:
 Exit Sub
ErrorTrap34:
 Resume ErrorResume34
End Sub

Sub Kill.Self
 On Local Error Goto ErrorTrap34a
 Gosub Get.Config3
 If UserRecord.Level=0 Then
    Strng="You are already dead!"
    Call IO.O
    Exit Sub
 Endif
 If Option1>0 Then
    If UserRecord.Level<Option1 Then
       Strng="You can't kill yourself until you are level "+Form$(Cdbl(Option1))+"."
       Call IO.O
       Exit Sub
    Endif
 Endif
 If Option2>0 Then
    If UserRecord.Stats(2)<Option2 Then
       Strng="Your intelligence is too low! It must be at least"+Str$(Option2)+"!"
       Call IO.O
       Exit Sub
    Endif
 Endif
 Out2="Evil Laughter Sounds From Above..."
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Strng=Out2
 Call IO.O
 Out2="   A Bolt of Lightning Strikes..."
 Call Send.Mess(5,SFalse,SFalse,Out2)
 Strng=Out2
 Call IO.O
 Out3=Rtrim$(UserRecord.CodeName)
 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)
 Message1="You killed yourself!"
 Call Player.Died
 Exit Sub
Get.Config3:
 VarX=0
 Option1=0
 Option2=8
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Goto Next.Read2
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[CMD000]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Goto Next.Read2
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Goto Next.Read2
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Gosub Parse.Options2
          Endif
       Loop
    Endif
 Loop
 Return
Next.Read2:
 Close #TempFile1
 Filename$=DND.Path+"CMD000.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=0
          Option2=8
          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.Options2
             Endif
          Loop
       Endif
    Endif
 Loop
 Return
Parse.Options2:
 Select Case Lcase$(Var2$)
 Case "kill.self.level"
    If Int(Val(Var3$)+.5)>=0 And Int(Val(Var3$)+.5)<=32767 Then
       Option1=Int(Val(Var3$)+.5)
    Endif
 Case "required.intelligence"
    If Int(Val(Var3$)+.5)>=0 And Int(Val(Var3$)+.5)<=32767 Then
       Option2=Int(Val(Var3$)+.5)
    Endif
 End Select
 Return
ErrorResume34a:
 Exit Sub
ErrorTrap34a:
 Resume ErrorResume34a
End Sub
