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

Sub Curse.Object
 On Local Error Goto ErrorTrap30
 Gosub Get.Config
 If Lcase$(Parsed.Command1)="self" Then
    Call Curse.Self
    Exit Sub
 Endif
 Call Parse
 If Parser Then
    Call Numeric
 Endif
 Temp4=False
 Call Check.Room.Items
 If Temp7!<SFalse Then
    Strng="You can't curse that!"
    Call IO.O
    Exit Sub
 Endif
 If Temp7!=SFalse Then
    Call Num
    Temp4=UnTrue
    Call Check.User.Items
    If Temp7!<SFalse Then
       Strng="You can't curse that!"
       Call IO.O
       Exit Sub
    Endif
 Endif
 If Temp7!>SFalse Then
    Out3=TreasureRecord.ShortName
    Out3=Rtrim$(Out3)
    Out3=Lcase$(Out3)
    If TreasureRecord.Spell=SFalse Then
       Var=TreasureRecord.TimesCursed
       If option1 Then
          Var2=option1
       Else
          Var2=100
       Endif
       If Var>=Var2 Then
          Strng="You curse the "+Out3+"!"
          Call IO.O
          TreasureRecord.TimesCursed=0
          Var2=TreasureRecord.Charges
          If Var2>0 Then
             TreasureRecord.Charges=Var2-1
             Strng="The "+Out3+" loses 1 charge.."
             Call IO.O
          Else
             Strng="Nothing happens!"
             Call IO.O
          Endif
          Call Write.Record(TreasureFile,Temp7!)
       Else
          If Var<32767 Then
             Var=Var+1
             TreasureRecord.TimesCursed=Var
             Call Write.Record(TreasureFile,Temp7!)
             Strng="You curse the "+Out3+"!"
             Call IO.O
          Else
             Strng="Nothing happens.."
             Call IO.O
          Endif
       Endif
       Exit Sub
    Endif
    Call Read.Record(SpellFile,TreasureRecord.Spell)
    If SpellRecord.SpellType=4 Then
       Strng="You can't curse that!"
       Call IO.O
       Exit Sub
    Endif
    TempZ=False
    Select Case Temp4
    Case 1
       If MessWorkRecord6.Charges>0 Then
          MessWorkRecord6.Charges=MessWorkRecord6.Charges-1
          Call Write.Record(MessWorkFile6,Temp5!)
       Else
          TempZ=True
       Endif
    Case 0
       If MessWorkRecord6.Charges>0 Then
          MessWorkRecord6.Charges=MessWorkRecord6.Charges-1
          Call Write.Record(RoomInvFile,Temp5!)
       Else
          TempZ=True
       Endif
    End Select
    If TempZ Then
       Strng="Nothing happens!"
    Else
       Strng="You curse the "+Out3+"!"
    Endif
    Call IO.O
    Exit Sub
 Endif
 ' online monsters
 TempC=False
 Call Num
 Call Check.Monster
 If Monster.Temp Then
    Out3=MessWorkRecord3.Monster.MonsterName
    Out3=Rtrim$(Out3)
    Out3=Lcase$(Out3)
    Strng="You curse the "+Out3+"!"
    Call IO.O
    If Len(option3$) Then
       Out2=option3$
       Call Equate(Temp#)
       Multiplier=Int(Temp#)
    Else
       Multiplier=Int(UserRecord.Stats(6)/2)
    Endif
    Call Hit.Monster
    Exit Sub
 Endif
 ' online users
 Call Num
 Call Search.Mess(SFalse)
 If Temp!=Room And TempB!<>User.Index Then
    User.Temp=TempB!
    Call Read.Record(UserFile2,User.Temp)
    Out3=MessWorkRecord1.UserName
    Out3=Rtrim$(Out3)
    Out3=Lcase$(Out3)
    Strng="You curse "+Out3+"!"
    Call IO.O
    If Len(option1$) Then
       Out2=option1$
       Call Equate(Temp#)
    Else
       Temp#=Rnd>.8
    Endif
    If Temp# Then
       If UserRecord2.Stats(6)>False Then ' piety
          Out2="curses you!"
          Call Send.Mess(24,TempB!,Room,Out2)
          Exit Sub
       Endif
    Endif
    Strng="Nothing happens!"
    Call IO.O
    Exit Sub
 Endif
 ' offline users
 Call Num
 Call Check.User
 If User.Temp Then
    User.Temp=MessWorkRecord4.Index
    Strng="You curse "+Lcase$(Out3)+"!"
    Call IO.O
    If Len(option2$) Then
       Out2=option2$
       Call Equate(Temp#)
    Else
       Temp#=Rnd>.8
    Endif
    If Temp# Then
       If UserRecord2.Stats(6)>False Then ' piety
          UserRecord2.Stats(6)=UserRecord2.Stats(6)-1
          Call Write.Record(UserFile2,User.Temp)
          Exit Sub
       Endif
    Endif
    Strng="Nothing happens!"
    Call IO.O
    Exit Sub
 Endif
 Strng="You can't curse 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$)="[CMD036]" 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 "curse.times"
                option1=Int(Val(Var3$))
             Case "curse.online.user"
                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 "curse.offline.user"
                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
             Case "curse.multiplier"
                If Left$(Var3$,1)=Chr$(34) Then
                   If Right$(Var3$,1)=Chr$(34) Then
                      option3$=Mid$(Var3$,2)
                      option3$=Left$(option3$,Len(option3$)-1)
                   Endif
                Endif
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrorResume30:
 Exit Sub
ErrorTrap30:
 Resume ErrorResume30
End Sub

Sub Curse.Self
 On Local Error Goto ErrorTrap32
 Gosub Get.Config2
 If Len(option1$) Then
    Out2=option1$
    Call Equate(Temp#)
 Else
    Temp#=Rnd>.8
 Endif
 If Temp# Then
    If UserRecord.Stats(6)>False Then
       UserRecord.Stats(6)=UserRecord.Stats(6)-1
       Call Write.Record(UserFile,User.Index)
       Strng=Rtrim$(Stat(6))
       Strng="lost one "+Strng+" point"
       Call Update.DayFile(Strng,False,2)
       If Node>False Then
          Out2=Lcase$(Rtrim$(UserRecord.CodeName))
          Out2=Out2+" just got cursed!"
          Call Send.Mess(8,SFalse,Room,Out2)
       Endif
       Strng="You feel a darkening about you!"
       Call IO.O
       Strng="Your piety is now "+Form$(Cdbl(UserRecord.Stats(6)))+"!"
       Call IO.O
       Call New.Stats
       Exit Sub
    Endif
 Endif
 Strng="Nothing happens!"
 Call IO.O
 Exit Sub
Get.Config2:
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[CMD035]" 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 "curse.self"
                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
ErrorResume32:
 Exit Sub
ErrorTrap32:
 Resume ErrorResume32
End Sub
