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

' !get/wish/drop()
Sub Drop.Object(Var1)
 On Local Error Goto ErrorTrp47
 Gosub Get.Config2
 If TempX=False Then
    Strng="The Ghods Thunder.."
    Call IO.O
    Strng="   What Do You Wish For? "
    Call IO.I
    Out2=Lcase$(Out2)
    Stored.Parsed.Command2=Out2
    Parsed.Command1=Out2
    Call Numeric
 Endif
 WishType=0
 Do
    If Lost.Carrier Then
       Exit Sub
    Endif
    Out2=Lcase$(Out2)
    If Out2=Nul Then
       Exit Sub
    Endif
    If Out2<>"?" Then
       Exit Do
    Endif
    Call Out.File(Data.Path2+"WISH.DOC","")
    If TempX=False Then
       Strng="The Ghods Thunder.."
       Call IO.O
       Strng="   What Do You Wish For? "
       Call IO.I
       Out2=Lcase$(Out2)
       Stored.Parsed.Command2=Out2
       Parsed.Command1=Out2
       Call Numeric
    Else
       Strng="GET? "
       Call IO.I
       Out2=Lcase$(Out2)
       Stored.Parsed.Command2=Out2
       Parsed.Command1=Out2
       Call Numeric
    Endif
 Loop
 If Out2="level" Then
    VarZ=1
    VarZ2=0
    If (UserRecord.Flags2 And WishLevel)=WishLevel Then
       If Sysop Then
          VarZ2=-1
       Endif
       If OptionX1 Then
          If UserRecord.ClassType=AsstDM Then
             VarZ2=-1
          Endif
       Endif
       If OptionX2 Then
          If UserRecord.ClassType=DM Then
             VarZ2=-1
          Endif
       Endif
       If VarZ2=0 Then
          Strng="You have already wished for a level."
          Call IO.O
          Goto Wish.Denied
       Endif
    Endif
    If Normal.User Then
       If UserRecord.WishsLeft=0 Then
          Strng="You have no wishs left."
          Call IO.O
          Goto Wish.Denied
       Endif
    Endif
    If UserRecord.Level>=MaxInt Then
       Strng="Nothing happens.."
       Call IO.O
       Exit Sub
    Endif
    If option1 Then
       Temp#=(UserRecord.Level>=option1)
    Else
       Temp#=(UserRecord.Level>=10)
    Endif
    If Temp#=0# Then
       Strng="Your level is to low."
       Call IO.O
    Endif
    If Temp# Then
       If Len(option1$) Then
          Out2=option1$
          Call Equate(Temp#)
       Else
          Temp#=(UserRecord.Stats(1)>=5)
       Endif
       If Temp#=0# Then
          Strng="Your strength is to low."
          Call IO.O
       Endif
       If Temp# Then
          If Len(option2$) Then
             Out2=option2$
             Call Equate(Temp#)
          Else
             Temp#=(UserRecord.Stats(2)>=5)
          Endif
          If Temp#=0# Then
             Strng="Your intelligence is to low."
             Call IO.O
          Endif
          If Temp# Then
             Goto Raise.Level
          Endif
       Endif
    Endif
    Goto Wish.Denied
 Endif      
 If Left$(Out2,6)="level=" Then
    VarZ=Int(Val(Mid$(Out2,7))+.5)
    If VarZ>=1 Then
       If Sysop Then
          Goto Raise.Level
       Endif
       If OptionX1 Then ' adm
          If UserRecord.ClassType=AsstDM Then
             Goto Raise.Level
          Endif
       Endif
       If OptionX2 Then ' dm
          If UserRecord.ClassType=DM Then
             Goto Raise.Level
          Endif
       Endif
    Endif
    Goto Wish.Denied
 Endif
 Temp1=1
 If Right$(Out2,7)=" points" Then
    Out2=Left$(Out2,Len(Out2)-7)
    Temp1=2
 Endif
 For Temp5=1 To MaxStats
    Out3=Stat(Temp5)
    Out3=Rtrim$(Out3)
    Out3=Lcase$(Out3)
    If Out2=Out3 Then
       If (UserRecord.Flags And 2^Temp5)=2^Temp5 Then
          If Normal.User Then
             Goto Wish.Denied
          Endif
       Endif
       UserRecord.Flags=(UserRecord.Flags Or 2^Temp5)
       Stat#=Cdbl(UserRecord.Stats(Temp5))
       Inc#=Cdbl(Temp1)
       If Stat#+Inc#<32767# Then
          UserRecord.Stats(Temp5)=UserRecord.Stats(Temp5)+Temp1
          Graphics.Off=True
          Strng="The Ghods Thunder..."
          Call IO.O
          Out2=Stat(Temp5)
          Out2=Rtrim$(Out2)
          Out2=Lcase$(Out2)
          Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
          Strng="   Your "+Out2+" Has Been Raised!"
          Call IO.O
          Out3=Numeral(Temp1)
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          Strng="gained "+Out3+" "+Lcase$(Out2)+" point"
          If Temp1=2 Then
             Strng=Strng+"s"
          Endif
          Call Update.DayFile(Strng,False,2)
          Graphics.Off=False
          Exit Sub
       Endif
       Strng="Stat is maximum."
       Call IO.O
       Goto Wish.Denied
    Endif
 Next
 If Lcase$(Out2)="invisibility" Or Lcase$(Out2)="invisible" Then
    If Len(option9$) Then
       Out2=option9$
       Call Equate(Temp#)
       If Temp# Then
          If Len(option10$) Then
             Out2=option10$
             Call Equate(Temp#)
             Temp2=Cint(Temp#)
             If Temp2>False Then
                Invisible=Temp2
                UserRecord.Invisible=True
                Strng="You are now invisible!"
                Call IO.O
                Exit Sub
             Endif
          Endif
       Endif
       Strng="Didn't work!"
       Call IO.O
       Exit Sub
    Endif
    If Config2(126)=False Then
       VarQ=1
    Else
       Call Count.Mess(VarQ)
    Endif
    Temp3=Room.Health.Rate*VarQ
    Temp2=False
    If Temp3 Then
       Temp2=Int((UserRecord.Level+5)/Temp3)
    Endif
    If Temp2>False Then
       Invisible=Temp2
       UserRecord.Invisible=True
       Strng="You are now invisible!"
    Else
       Strng="Didn't work!"
    Endif
    Call IO.O
    Exit Sub
 Endif
 If Lcase$(Out2)="curepoison" Then
    If UserRecord.Poison Then
       If Len(option11$) Then
          Out2=option11$
          Call Equate(Temp#)
          If Temp# Then
             UserRecord.Poison=False
             Strng="The poison disappeared!"
             Call IO.O
             Exit Sub
          Else
             Strng="Nothing happened!"
             Call IO.O
             Exit Sub
          Endif
       Endif
       If Rnd>.5 Then
          UserRecord.Poison=False
          Strng="The poison disappeared!"
          Call IO.O
          Exit Sub
       Endif
    Endif
    Strng="Nothing happened!"
    Call IO.O
    Exit Sub
 Endif
 If Var1=False Then
    If Normal.User Then
       If UserRecord.WishsLeft=0 Then
          Goto Wish.Denied
       Endif
       If UserRecord.WishsLeft>0 Then
          UserRecord.WishsLeft=UserRecord.WishsLeft-1
          WishType=-1
       Endif
    Endif
 Endif
 If Lcase$(Out2)="teleport" Then
    Do While Lost.Carrier=False
       If GuestLogin Then
          If GuestRecord.GuestCanTeleport=False Then
             Strng="Sorry, guests cannot teleport!"
             Call IO.O
             Exit Sub
          Endif
       Endif
       Strng="Destination(?=help)? "
       Call IO.I
       If Out2="?" Then
          Call Out.File(Data.Path2+"TELEPORT.DOC","")
       Else
          Stored.Parsed.Command2=Out2
          Parsed.Command1=Stored.Parsed.Command2
          Call Numeric
          Out2=Parsed.Command1
          Out2=Lcase$(Out2)
          Call Teleport.Function(VarQ2)
          Exit Sub
       Endif
    Loop
    Exit Sub
 Endif
 UserRecord.Flags=(UserRecord.Flags Or Wished)
 Temp2=False
 Temp6=False
 Temp7!=SFalse
 For Temp5!=1! To Lof(TreasureFile)/TreasureRecLen
    Call Read.Record(TreasureFile,Temp5!)
    Out3=TreasureRecord.TreasureName
    Var4$=Rtrim$(TreasureRecord.Prefix1)
    Var5$=Out3
    Out3=Left$(Out3,Len(Out2))
    If Out2=Out3 Then
       Temp2=Temp2+1
       If Parse.Temp=False Or Temp2=Parse.Temp Then
          Temp7!=Temp5!
          Temp6=TreasureRecord.Charges
          Exit For
       Endif
    Endif
 Next
 If Temp7! Then
    If TreasureRecord.Container Then
       If Normal.User And Var1=False Then
          Goto Wish.Denied
       Endif
       Call Drop.Container.In.Room(Temp7!)
       Gosub Wish.Accepted
       Exit Sub
    Endif
 Endif
 If Temp7!=SFalse Then
    If Normal.User=False Or Var1 Then
       For Temp5!=1! To Lof(ObjectFile)/ObjectRecLen
          Call Read.Record(ObjectFile,Temp5!)
          Out3=ObjectRecord.ObjectName
          Var4$=Rtrim$(ObjectRecord.Prefix1)
          Var5$=Out3
          Out3=Left$(Out3,Len(Out2))
          If Out2=Out3 Then
             Temp2=Temp2+1
             If Parse.Temp=False Or Temp2=Parse.Temp Then
                Temp7!=-Temp5!
                Temp6=False
                Exit For
             Endif
          Endif
       Next
    Endif
 Endif
 If Var1=False Then
    If Normal.User Then
       If Temp7!>SFalse Then
          If TreasureRecord.Vehicle Then
             Temp7!=SFalse
          Endif
          Temp4!=TreasureRecord.Spell
          If Temp4!>SFalse And Temp4!<=Lof(SpellFile)/SpellRecLen Then
             Call Read.Record(SpellFile,Temp4!)
             If SpellRecord.SpellType=Wish Then
                Temp7!=SFalse
             Endif
          Endif
       Endif
    Endif
 Endif
 If Temp7!=SFalse Then
    Goto Wish.Denied
 Endif
 Call Drop.Inventory(Temp7!,Temp6)
 Gosub Wish.Accepted
 Exit Sub

Wish.Denied:
 Graphics.Off=True
 Strng="The Ghods Thunder..."
 Call IO.O
 Strng="   Your Wish Is Denied!"
 Call IO.O
 Graphics.Off=False
 If WishType Then
    UserRecord.WishsLeft=UserRecord.WishsLeft+1
 Endif
 Exit Sub

Wish.Accepted:
 Graphics.Off=True
 Strng="A Dark Cloud Passes Overhead..."
 Call IO.O
 Call Capitalize(Var5$)
 Strng="   "+Var4$+Var5$
 Call Convert.ANSI(True,VarQ,VarR)
 Carriage.Return=True
 Graphics.On=True
 Call IO.O
 Graphics.On=False
 Strng=" Falls From The Sky..."
 Call IO.O
 Strng="The Cloud Disappears..."
 Call IO.O
 Graphics.Off=False
 Return

Raise.Level:
 If VarZ>=1 And VarZ<=OptionX3 Then
    UserRecord.Flags2=(UserRecord.Flags2 Or WishLevel)
    If UserRecord.WishsLeft>0 Then
       UserRecord.WishsLeft=UserRecord.WishsLeft-1
    Endif
    Call Write.Record(UserFile,User.Index)
    Graphics.Off=True
    Strng="A Dark Cloud Passes Overhead..."
    Call IO.O
    Strng="   A Large Lightning Bolt Hits You..."
    Call IO.O
    Strng="The Cloud Disappears..."
    Call IO.O
    Graphics.Off=False
    VarQ2=False
    For VarQ=1 To VarZ
       If UserRecord.Level<MaxInt Then
          VarQ2=True
          UserRecord.Level=UserRecord.Level+1
          Call New.Stats
          UserRecord.Experience=False
          If Config2(93)=False Then
             Call Experience(Temp#)
             UserRecord.Experience=Temp#
          Endif
          Call Write.Record(UserFile,User.Index)
       Endif
    Next
    If VarQ2 Then
       If UserRecord.Level>10 Then
          Var2$=Form$(Cdbl(UserRecord.Level))
       Else
          Var2$=Rtrim$(Numeral(UserRecord.Level))
       Endif
       Strng="wished for level "+Var2$
       Call Update.DayFile(Strng,False,1)
       Strng="You are now level "+Var2$+"."
       Call IO.O
       Exit Sub
    Endif
 Else
    Strng="Raise level must be from 1 to"+Str$(OptionX3)+"."
    Call IO.O
    Exit Sub
 Endif
 Strng="Nothing happens.."
 Call IO.O
 Exit Sub
Get.Config2:
 OptionX1=0
 OptionX2=0
 OptionX3=10
 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$)="[CMD157]" 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+"CMD157.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
          OptionX1=0
          OptionX2=0
          OptionX3=10
          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 "maximum.raise.level"
    If Int(Val(Var3$)+.5)>=1 And Int(Val(Var3$)+.5)<=1024 Then
       OptionX3=Int(Val(Var3$)+.5)
    Endif
 Case "maximum.asstdm.raise.level"
    If Sysop=0 Then
       If UserRecord.ClassType=AsstDM Then
          If Int(Val(Var3$)+.5)>=1 And Int(Val(Var3$)+.5)<=1024 Then
             OptionX3=Int(Val(Var3$)+.5)
          Endif
       Endif
    Endif
 Case "maximum.dm.raise.level"
    If Sysop=0 Then
       If UserRecord.ClassType=DM Then
          If Int(Val(Var3$)+.5)>=1 And Int(Val(Var3$)+.5)<=1024 Then
             OptionX3=Int(Val(Var3$)+.5)
          Endif
       Endif
    Endif
 Case "allow.asstdm.wish.levels"
    Select Case Lcase$(Var3$)
    Case "-1", "true", "on"
       OptionX1=-1
    End Select
 Case "allow.dm.wish.levels"
    Select Case Lcase$(Var3$)
    Case "-1", "true", "on"
       OptionX2=-1
    End Select
 Case "required.level"
    option1=Int(Val(Var3$)+.5)
 Case "strength.required.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
 Case "intelligence.required.equation"
    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 "invisible.equation"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          option9$=Mid$(Var3$,2)
          option9$=Left$(option9$,Len(option9$)-1)
       Endif
    Endif
 Case "invisible.count"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          option10$=Mid$(Var3$,2)
          option10$=Left$(option10$,Len(option10$)-1)
       Endif
    Endif
 Case "curepoison"
    If Left$(Var3$,1)=Chr$(34) Then
       If Right$(Var3$,1)=Chr$(34) Then
          option11$=Mid$(Var3$,2)
          option11$=Left$(option11$,Len(option11$)-1)
       Endif
    Endif
 End Select
 Return
ErrorRsm47:
 Exit Sub
ErrorTrp47:
 Resume ErrorRsm47
End Sub
