 Rem File: Teleport.bas - for Cmd*.bas modules: (042/044/191)
 Rem $Include: 'dndbbs.inc'

Sub Teleport.Function(VarQ1)
 On Local Error Goto ErrorTrap29a
 VarQ1=False ' returns 0 if successful
 Strng=Rtrim$(Parsed.Command1)
 If Strng="?" Then
    Call Out.File(Data.Path2+"TELEPORT.DOC","")
    Exit Sub
 Endif
 Var$=Nul
 If Right$(Strng,1)=Chr$(34) Then
    For Var=Len(Strng)-1 To 1 Step -1
       If Mid$(Strng,Var,1)=Chr$(34) Then
          Var$=Mid$(Strng,Var)
          Var$=Left$(Var$,Len(Var$)-1)
          Var$=Mid$(Var$,2)
          Var$=Lcase$(Var$)
          Parsed.Command1=Rtrim$(Left$(Strng,Var-1))
          Exit For
       Endif
    Next
    If Len(Var$) Then
       Var1!=SFalse
       Select Case Lcase$(Var$)
       Case "safe room", "sanctuary", "resurrection room"
          Var1!=Csng(Val(Room.Array(11)))
       Case "jail", "jail room"
          Var1!=Csng(Val(Room.Array(12)))
       Case "pawn shop", "pawn shoppe"
          Var1!=Csng(Val(Room.Array(13)))
       Case "smith", "smithy"
          Var1!=Csng(Val(Room.Array(14)))
       Case "smith shop", "smith shoppe"
          Var1!=Csng(Val(Room.Array(14)))
       Case "smithy shop", "smithy shoppe"
          Var1!=Csng(Val(Room.Array(14)))
       Case "weapons shop", "weapons shop"
          Var1!=Csng(Val(Room.Array(14)))
       Case "weapons shoppe", "weapons shoppe"
          Var1!=Csng(Val(Room.Array(14)))
       Case "weapon shop", "weapon shoppe"
          Var1!=Csng(Val(Room.Array(14)))
       Case "weapon shoppe", "weapon shoppe"
          Var1!=Csng(Val(Room.Array(14)))
       Case "weapon master shop", "weapon master shoppe"
          Var1!=Csng(Val(Room.Array(14)))
       Case "weapons master shop", "weapons master shoppe"
          Var1!=Csng(Val(Room.Array(14)))
       Case "bank", "bank shop", "bank shoppe"
          Var1!=Csng(Val(Room.Array(15)))
       Case "alchemist", "alchemist room"
          Var1!=Csng(Val(Room.Array(16)))
       Case "alchemist shop", "alchemist shoppe"
          Var1!=Csng(Val(Room.Array(16)))
       Case "wizard shop", "wizard shoppe"
          Var1!=Csng(Val(Room.Array(16)))
       Case "wizard master shop", "wizard master shoppe"
          Var1!=Csng(Val(Room.Array(16)))
       Case Else
          Var1!=Csng(Int(Val(Var$)+.5))
       End Select
    Endif
 Else
    If Right$(Strng,1)="'" Then
       For Var=Len(Strng)-1 To 1 Step -1
          If Mid$(Strng,Var,1)="'" Then
             Var$=Mid$(Strng,Var)
             Var$=Left$(Var$,Len(Var$)-1)
             Var$=Mid$(Var$,2)
             Var$=Lcase$(Var$)
             Parsed.Command1=Rtrim$(Left$(Strng,Var-1))
             Exit For
          Endif
       Next
       If Len(Var$) Then
          Var1!=SFalse
          For VarQ=1 To 10
             Strng2=Rtrim$(Class.Name(VarQ))
             Strng2=Strng2+" training room"
             Strng2=Lcase$(Strng2)
             If Strng2=Var$ Then
                If Parse.Temp=False Then
                   Parse.Temp=1
                Endif
                VarX$=Rtrim$(Room.Array(VarQ))
                Temp1=False
                Do
                   Temp1=Temp1+1
                   Temp2=Instr(VarX$,",")
                   If Temp2 Then
                      Temp$=Left$(VarX$,Temp2-1)
                      VarX$=Mid$(VarX$,Temp2+1)
                   Else
                      Temp$=VarX$
                      VarX$=Nul
                   Endif
                   If Temp1=Parse.Temp Then
                      Exit Do
                   Endif
                   If VarX$=Nul Then
                      Temp$=Nul
                      Exit Do
                   Endif
                Loop
                Var1!=Csng(Int(Val(Temp$)+.5))
                Exit For
             Endif
          Next
       Endif
    Else
       If Right$(Strng,1)="]" Then
          For Var=Len(Strng)-1 To 1 Step -1
             If Mid$(Strng,Var,1)="[" Then
                Var$=Mid$(Strng,Var)
                Var$=Left$(Var$,Len(Var$)-1)
                Var$=Mid$(Var$,2)
                Var$=Lcase$(Var$)
                Parsed.Command1=Rtrim$(Left$(Strng,Var-1))
                Exit For
             Endif
          Next
          If Len(Var$) Then
             Var1!=SFalse
             Temp2=False
             For Temp!=1 To Lof(RoomFile)/RoomRecLen
                Call Read.Record(RoomFile,Temp!)
                Strng=Rtrim$(RoomRecord.ShortDesc)
                Strng=Lcase$(Strng)
                Call InstrSUB1(VarX,Var$)
                If VarX Then
                   Temp2=Temp2+1
                   If Temp2=Parse.Temp Or Parse.Temp=False Then
                      Var1!=Temp!
                      Exit For
                   Endif
                Endif
             Next
             Call Read.Record(RoomFile,Room)
          Endif
       Else
          If Right$(Strng,1)="}" Then
             For Var=Len(Strng)-1 To 1 Step -1
                If Mid$(Strng,Var,1)="{" Then
                   Var$=Mid$(Strng,Var)
                   Var$=Left$(Var$,Len(Var$)-1)
                   Var$=Mid$(Var$,2)
                   Var$=Lcase$(Var$)
                   Parsed.Command1=Rtrim$(Left$(Strng,Var-1))
                   Exit For
                Endif
             Next
             If Len(Var$) Then
                Var1!=SFalse
                Temp3=False
                For Temp!=1 To Lof(RoomFile)/RoomRecLen
                   Call Read.Record(RoomFile,Temp!)
                   For Temp2=1 To 19
                      TempZ!=RoomRecord.LongDesc(Temp2)
                      If TempZ!>SFalse And TempZ!<=Lof(RoomDescFile)/RoomDescLen Then
                         Call Read.Record(RoomDescFile,TempZ!)
                         Strng=Rtrim$(BufferRecord.Buffer)
                         Strng=Lcase$(Strng)
                         If Len(Strng) Then
                            Call InstrSUB1(VarX,Var$)
                            If VarX Then
                               Temp3=Temp3+1
                               If Temp3=Parse.Temp Or Parse.Temp=False Then
                                  Var1!=Temp!
                                  Exit For
                               Endif
                            Endif
                         Endif
                      Endif
                   Next
                   If Var1! Then
                      Exit For
                   Endif
                Next
                Call Read.Record(RoomFile,Room)
             Endif
          Else
             If Right$(Strng,1)=")" Then
                Var2$=Nul
                For Var=Len(Strng)-1 To 1 Step -1
                   If Mid$(Strng,Var,1)="(" Then
                      Var$=Mid$(Strng,Var)
                      Var$=Left$(Var$,Len(Var$)-1)
                      Var$=Mid$(Var$,2)
                      Var$=Lcase$(Var$)
                      Var2$=Rtrim$(Left$(Strng,Var-1))
                      Parsed.Command1=Var$
                      Exit For
                   Endif
                Next
                ' online user
                If Len(Var$) Then
                   Var1!=SFalse
                   Call Search.Mess(SFalse)
                   If Temp!>SFalse Then
                      Var1!=Temp!
                   Endif
                Endif
                Parsed.Command1=Var2$
                ' offline user
                If Var1!=0! Then
                   Temp3=False
                   If Config2(55) Then
                      For TempX!=1! To Lof(UserFile2)/UserRecLen
                         If TempX!<>User.Index Then
                            Call Read.Record(UserFile2,TempX!)
                            Var2!=UserRecord2.Room
                            If Var2!<>Room Then
                               If UserRecord2.Level>False Then
                                  Call Search.Mess(TempX!)
                                  If Temp!=SFalse Then
                                     Strng=UserRecord2.CodeName
                                     Strng=Rtrim$(Strng)
                                     Strng=Lcase$(Strng)
                                     If Strng<>Deleted$ Then
                                        If Instr(Strng,Var$) Then
                                           If Var2!<>1! Then
                                              Var1$=","+Rtrim$(Room.Array(11))+","
                                              Var2$=","+Mid$(Str$(Var2!),2)+","
                                              If Instr(Var1$,Var2$)=0 Then
                                                 Temp3=Temp3+1
                                                 If Temp3=Parse.Temp Or Parse.Temp=False Then
                                                    Var1!=Var2!
                                                    Exit For
                                                 Endif
                                              Endif
                                           Endif
                                        Endif
                                     Endif
                                  Endif
                               Endif
                            Endif
                         Endif
                      Next
                   Endif
                Endif
             Endif
          Endif
       Endif
    Endif
 Endif
 If Var1!=SFalse Then
    If Len(Parsed.Command1) Then
       If Instr(Parsed.Command1," ")=False Then
          Var1!=Csng(Int(Val(Parsed.Command1)+.5))
          Parsed.Command1=Nul
       Endif
    Endif
 Endif
 If Parsed.Command1=Nul Then
    If Var1!>SFalse And Var1!<=Lof(RoomFile)/RoomRecLen Then
       If Room=Var1! Then
          Strng="You can't teleport to the same room!"
          Call IO.O
          VarQ1=True
          Exit Sub
       Endif
       If Room<>Var1! Then
          Next.Room=Var1!
          Graphics.Off=True
          Strng="A Dark Cloud Passes Overhead..."
          Call IO.O
          Strng="  A Bolt of Lightning Strikes..."
          Call IO.O
          Strng="The Cloud Disappears..."
          Call IO.O
          Graphics.Off=False
          Call Teleport
          Action.Recurse=0
          Call Enter.Room
          Exit Sub
       Endif
    Endif
    VarQ1=True
    Strng="You can't teleport there!"
    Call IO.O
    Exit Sub
 Endif
 If Instr(Parsed.Command1," ") Then
    Call Parse
    If Parser Then
       Call Numeric
       Call Search.Mess(SFalse)
       If Temp!>SFalse Then
          Var1!=Csng(Int(Val(Parsed.Command2)+.5))
       Else
          Var1!=SFalse
       Endif
    Endif
 Else
    Call Numeric
    Call Search.Mess(SFalse)
    If Temp!=SFalse Then
       Var1!=SFalse
    Endif
 Endif
 If TempB!<>User.Index Then
    If Var1!>SFalse And Var1!<=Lof(RoomFile)/RoomRecLen Then
       If MessWorkRecord1.RoomNumber=Var1! Then
          Strng="You can't teleport a user to the same room!"
          Call IO.O
          VarQ1=True
          Exit Sub
       Endif
       If MessWorkRecord1.RoomNumber<>Var1! Then
          Out3=MessWorkRecord1.UserName
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          Strng="You teleport "+Out3+"!"
          Call IO.O
          Out2=Str$(Var1!)
          Call Send.Mess(18,TempB!,SFalse,Out2)
          Exit Sub
       Endif
    Endif
 Endif
 VarQ1=True
 Strng="You can't teleport that!"
 Call IO.O
 Exit SUb
ErrorResume29a:
 Exit Sub
ErrorTrap29a:
 Resume ErrorResume29a
End Sub

Sub Find.Teleport(Var1!)
 On Local Error Goto ErrorTrap1x
 Var1!=SFalse
 If GuestLogin Then
    If GuestRecord.GuestCanTeleport=False Then
       Strng="Sorry, guests cannot teleport!"
       Call IO.O
       Exit Sub
    Endif
 Endif
 Var$=Rtrim$(Out2)
 Var$=Lcase$(Var$)
 Var=False
 Var1=Instr(Var$,"#")
 If Var1 Then
    Var=Int(Val(Mid$(Var$,Var1+1))+.5)
    Var$=Left$(Var$,Var1-1)
 Endif
 Parse.Temp=Var
 Tmp1=False
 ' room number
 Var2!=Int(Val(Var$)+.5)
 If Var2!>SFalse And Var2!<=Lof(RoomFile)/RoomRecLen Then
    If Var2!=Room Then
       Strng="You can't teleport there!"
       Call IO.O
       Exit Sub
    Endif
    Var1!=Var2!
    Exit Sub
 Endif
 If Parse.Temp>0 Then Goto Next.Teleport
 ' shoppe names
 Select Case Var$
 Case "safe room", "sanctuary", "resurrection room"
    Var1!=Csng(Val(Room.Array(11)))
    Exit Sub
 Case "jail", "jail room"
    Var1!=Csng(Val(Room.Array(12)))
    Exit Sub
 Case "pawn shop", "pawn shoppe"
    Var1!=Csng(Val(Room.Array(13)))
    Exit Sub
 Case "smith", "smithy"
    Var1!=Csng(Val(Room.Array(14)))
    Exit Sub
 Case "smith shop", "smith shoppe"
    Var1!=Csng(Val(Room.Array(14)))
    Exit Sub
 Case "smithy shop", "smithy shoppe"
    Var1!=Csng(Val(Room.Array(14)))
    Exit Sub
 Case "weapon shop", "weapon shoppe"
    Var1!=Csng(Val(Room.Array(14)))
    Exit Sub
 Case "weapons shop", "weapons shoppe"
    Var1!=Csng(Val(Room.Array(14)))
    Exit Sub
 Case "weapon master shop", "weapon master shoppe"
    Var1!=Csng(Val(Room.Array(14)))
    Exit Sub
 Case "weapons master shop", "weapons master shoppe"
    Var1!=Csng(Val(Room.Array(14)))
    Exit Sub
 Case "bank", "bank shop", "bank shoppe"
    Var1!=Csng(Val(Room.Array(15)))
    Exit Sub
 Case "alchemist", "alchemist room"
    Var1!=Csng(Val(Room.Array(16)))
    Exit Sub
 Case "alchemist shop", "alchemist shoppe"
    Var1!=Csng(Val(Room.Array(16)))
    Exit Sub
 Case "wizard shop", "wizard shoppe"
    Var1!=Csng(Val(Room.Array(16)))
    Exit Sub
 Case "wizard master shop", "wizard master shoppe"
    Var1!=Csng(Val(Room.Array(16)))
    Exit Sub
 End Select
Next.Teleport:
 ' training rooms
 For VarQ=1 To 10
    Strng2=Rtrim$(Class.Name(VarQ))
    Strng2=Strng2+" training room"
    Strng2=Lcase$(Strng2)
    If Strng2=Var$ Then
       VarX$=Rtrim$(Room.Array(VarQ))
       Do
          Tmp1=Tmp1+1
          Temp2=Instr(VarX$,",")
          If Temp2 Then
             Temp$=Left$(VarX$,Temp2-1)
             VarX$=Mid$(VarX$,Temp2+1)
          Else
             Temp$=VarX$
             VarX$=Nul
          Endif
          If Tmp1=Parse.Temp Or Parse.Temp=False Then
             Exit Do
          Endif
          If VarX$=Nul Then
             Temp$=Nul
             Exit Do
          Endif
       Loop
       If Temp$<>Nul Then
          Var2!=Int(Val(Temp$)+.5)
          If Var2!>SFalse And Var2!<=Lof(RoomFile)/RoomRecLen Then
             If Var2!<>Room Then
                Var1!=Var2!
                Exit Sub
             Endif
          Endif
       Endif
    Endif
 Next
 ' online user
 Parsed.Command1=Var$
 Call Search.Mess(SFalse)
 If Temp!>SFalse Then
    If Temp!<>Room Then
       Tmp1=Tmp1+1
       If Tmp1=Parse.Temp Or Parse.Temp=False Then
          Var1!=Temp!
          Exit Sub
       Endif
    Endif
 Endif
 ' offline user
 If Config2(55) Then
    Call Search.Mess3
    If Temp1!=-1! Then
       Strng="You can't! That user is in a safe haven!"
       Call IO.O
       Exit Sub
    Endif
    If Temp1!>SFalse Then
       Tmp1=Tmp1+1
       If Tmp1=Parse.Temp Or Parse.Temp=False Then
          Var1!=Temp1!
          Exit Sub
       Endif
    Endif
 Endif
 ' short room desc
 For Temp!=1 To Lof(RoomFile)/RoomRecLen
    Call Read.Record(RoomFile,Temp!)
    Strng=Rtrim$(RoomRecord.ShortDesc)
    Strng=Lcase$(Strng)
    Call InstrSUB1(Var,Var$)
    If Var Then
       Tmp1=Tmp1+1
       If Tmp1=Parse.Temp Or Parse.Temp=False Then
          Var1!=Temp!
          Exit Sub
       Endif
    Endif
 Next
 ' long room desc
 For Temp!=1 To Lof(RoomFile)/RoomRecLen
    Call Read.Record(RoomFile,Temp!)
    For Temp2=1 To 19
       TempZ!=RoomRecord.LongDesc(Temp2)
       If TempZ!>SFalse And TempZ!<=Lof(RoomDescFile)/RoomDescLen Then
          Call Read.Record(RoomDescFile,TempZ!)
          Strng=Rtrim$(BufferRecord.Buffer)
          Strng=Lcase$(Strng)
          If Len(Strng) Then
             Call InstrSUB1(Var,Var$)
             If Var Then
                Tmp1=Tmp1+1
                If Tmp1=Parse.Temp Or Parse.Temp=False Then
                   Var1!=Temp!
                   Exit Sub
                Endif
             Endif
          Endif
       Endif
    Next
 Next
 ' online monster
 For Temp5!=1! To Lof(MessWorkFile3)/MessWorkRecLen3
    Call Read.Record(MessWorkFile3,Temp5!)
    Strng=Lcase$(Rtrim$(MessWorkRecord3.Monster.MonsterName))
    Call InstrSUB1(Var,Var$)
    If Var Then
       Tmp1=Tmp1+1
       If Tmp1=Parse.Temp Or Parse.Temp=False Then
          Var1!=MessWorkRecord3.Room
          Exit Sub
       Endif
    Endif
 Next
 ' permanent monster
 For Var2!=1! To Lof(RoomFile)/RoomRecLen
    Call Read.Record(RoomFile,Var2!)
    Var3!=RoomRecord.MonClass
    If Var3!>SFalse And Var3!<=MonClass.Max Then
       If Low.Mem.Use Then
          Call Read.Record(MonClassFile,Var3!)
       Endif
       For Temp1=1 To MaxMonClass
          If Low.Mem.Use=False Then
             Var4!=Monster.Class(Var3!,Temp1)
          Else
             Var4!=MonClassRecord.Monsters(Temp1)
          Endif
          If Var4!>SFalse And Var4!<=Lof(MonsterFile)/MonsterRecLen Then
             Call Read.Record(MonsterFile,Var4!)
             If MonsterRecord.Permanent=True Then
                Strng=Lcase$(Rtrim$(MonsterRecord.MonsterName))
                Call InstrSUB1(Var,Var$)
                If Var Then
                   Temp3=Temp3+1
                   If Temp3=Parse.Temp Or Parse.Temp=False Then
                      Var1!=Var2!
                      Exit Sub
                   Endif
                Endif
             Endif
          Endif
       Next
    Endif
 Next
 ' nonplayer
 For Var2!=1! To NonPlayer.Max
    If Low.Mem.Use=False Then
       Var2$=Rtrim$(Nonplayer.Rooms(Var2!))+","
    Else
       Call Read.Record(NonPlayerFile,Var2!)
       Var2$=Rtrim$(MonsterRecord.PluralName)+","
    Endif
    Call Read.Record(NonPlayerFile,Var2!)
    Strng=Lcase$(Rtrim$(MonsterRecord.MonsterName))
    Call InstrSUB1(Var,Var$)
    If Var Then
       Do
          Var3=Instr(Var2$,",")
          If Var3 Then
             Var3!=Val(Left$(Var2$,Var3-1))
             Var2$=Mid$(Var2$,Var3+1)
             Temp3=Temp3+1
             If Temp3=Parse.Temp Or Parse.Temp=False Then
                Var1!=Var3!
                Exit Sub
             Endif
          Else
             Exit Do
          Endif
       Loop
    Endif
 Next
 ' none
 Call Read.Record(RoomFile,Room)
 Strng="You can't teleport there!"
 Call IO.O
 Exit Sub
ErrorResume1x:
 Exit Sub
ErrorTrap1x:
 Resume ErrorResume1x
End Sub

Sub Drop(Var1)
 On Local Error Goto ErrorTrp47
 Gosub Get.Config2
 WishType=0
 Out2=Lcase$(Out2)
 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
 TempQ=1
 If Right$(Out2,7)=" points" Then
    Out2=Left$(Out2,Len(Out2)-7)
    TempQ=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(TempQ)
       If Stat#+Inc#<32767# Then
          UserRecord.Stats(Temp5)=UserRecord.Stats(Temp5)+TempQ
          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(TempQ)
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          Strng="gained "+Out3+" "+Lcase$(Out2)+" point"
          If TempQ=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 Var1=False Then
    If Normal.User Then
       If UserRecord.WishsLeft=0 Then
          Goto Wish.Denied
       Endif
       If UserRecord.WishsLeft>0 Then
          WishType=-1
          UserRecord.WishsLeft=UserRecord.WishsLeft-1
       Endif
    Endif
 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:
 TempX=True
 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
 VarX$="[CMD"+Right$(Str$(Last.Module.Number+1000),3)+"]"
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)=VarX$ 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 "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
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrorRsm47:
 Exit Sub
ErrorTrp47:
 Resume ErrorRsm47
End Sub

' check user is in safe haven
Sub Search.Mess3
 On Local Error Goto ErrorTrap1z
 Temp1!=SFalse
 Temp3=False
 Var$=Parsed.Command1
 For TempX!=1! To Lof(UserFile2)/UserRecLen
    If TempX!<>User.Index Then
       Call Read.Record(UserFile2,TempX!)
       Var2!=UserRecord2.Room
       If Var2!<>Room Then
          If UserRecord2.Level>False Then
             Call Search.Mess(TempX!)
             If Temp!=SFalse Then
                Strng=UserRecord2.CodeName
                Strng=Rtrim$(Strng)
                Strng=Lcase$(Strng)
                If Strng<>Deleted$ Then
                   If Instr(Strng,Var$) Then
                      Temp3=Temp3+1
                      If Temp3=Parse.Temp Or Parse.Temp=False Then
                         If Var2!=1! Then
                            Temp1!=-1!
                            Exit FOr
                         Endif
                         Var1$=","+Rtrim$(Room.Array(11))+","
                         Var2$=","+Mid$(Str$(Var2!),2)+","
                         If Instr(Var1$,Var2$) Then
                            Temp1!=-1!
                            Exit For
                         Endif
                         Temp1!=Var2!
                         Exit For
                      Endif
                   Endif
                Endif
             Endif
          Endif
       Endif
    Endif
 Next
ErrorResume1z:
 Exit Sub
ErrorTrap1z:
 Resume ErrorResume1z
End Sub

' function to match substring with ?, * characters in substring.
SUB InstrSUB1(Var,Var$)
On Local Error Goto ErrorTrap24x5

' store string match variables
S2$ = Lcase$(Var$)
S3$ = Lcase$(Strng)

' check default instr
IF INSTR(S2$, "*") = 0 THEN
   IF INSTR(S2$, "?") = 0 THEN
      Var = INSTR(S3$, S2$)
      EXIT SUB
   END IF
END IF

Var = -1 ' assume match

' see if S2$ matches in S3$ with substrings
FOR S3 = 1 TO LEN(S3$)
   S1$ = MID$(S3$, S3)
   P1 = 1 ' pointer to S1$
   P2 = 1 ' pointer to S2$
   DO
      ' check match
      IF P2 > LEN(S2$) THEN
         EXIT SUB
      END IF

      ' check character in S2$ at P2
      V$ = MID$(S2$, P2, 1)
      SELECT CASE V$
      CASE "*" ' global character
         ' scan to next char
         IF P2 > LEN(S2$) THEN
            EXIT DO
         END IF
         S4$ = MID$(S2$, P2 + 1, 1)
         SELECT CASE S4$
         CASE "*", "?"
            P2 = P2 + 1
         CASE ELSE
            DO
               IF MID$(S1$, P1, 1) = S4$ THEN
                  EXIT DO
               END IF
               IF P1 >= LEN(S1$) THEN
                  EXIT DO
               END IF
               P1 = P1 + 1
            LOOP
            P2 = P2 + 1
         END SELECT
      CASE "?" ' wildcard character
         P1 = P1 + 1
         P2 = P2 + 1
      CASE ELSE ' ascii character
         IF MID$(S1$, P1, 1) <> V$ THEN ' no match
            EXIT DO
         END IF
         P1 = P1 + 1
         P2 = P2 + 1
      END SELECT
   LOOP
NEXT
Var = 0 ' no match
EXIT SUB

ErrorResume24x5:
 Exit Sub
ErrorTrap24x5:
 Resume ErrorResume24x5
End Sub
