Attribute VB_Name = "modPathFind"
Public Function findPath(Index As Integer, ByVal FromX As Integer, ByVal FromY As Integer, ByVal ToX As Integer, ByVal ToY As Integer, ByVal Room As Integer, Walks As String, HeightMap As String) As String
Dim i As Integer
Dim walk As String
findPath = "NoPath"
On Error GoTo anError

If FromX > ToX And FromY > ToY Then
    
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX - 1 And Client(b).PosY = FromY - 1 Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX - 1 And Pet(splitP(b)).PosY = FromY - 1 Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY - 1), FromX, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY - 1 = ToY And FromX - 1 = ToX) Then
           
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX - 1 & "," & FromY - 1, DBP & "privaterooms\" & Client(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY = ToY - 1 And FromX - 1 = ToX)) Then Exit Function
End If
End If
'roller
         
            findPath = FromX - 1 & "," & FromY - 1
            Client(Index).Look = "7,7"
            If walk = "R" Then
            Client(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX, 1)) + 0.4, ",", ".")
            If InStr(Client(Index).He, ".") = 0 Then Client(Index).He = Client(Index).He & ".0"
            Else
            Client(Index).He = Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX, 1) & ".0"
            End If
            Client(Index).Sit = False
            Client(Index).Hadd = 0
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromX < ToX And FromY < ToY Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX + 1 And Client(b).PosY = FromY + 1 Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX + 1 And Pet(splitP(b)).PosY = FromY + 1 Then Exit Function
End If
End If
Next b

    walk = Mid(Split(Walks, Chr(13))(FromY + 1), FromX + 2, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY + 1 = ToY And FromX + 1 = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX + 1 & "," & FromY + 1, DBP & "privaterooms\" & Client(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY = ToY + 1 And FromX + 1 = ToX)) Then Exit Function
End If
End If
'roller
            
            findPath = FromX + 1 & "," & FromY + 1
            Client(Index).Look = "3,3"
            If walk = "R" Then
            Client(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX + 2, 1)) + 0.4, ",", ".")
            If InStr(Client(Index).He, ".") = 0 Then Client(Index).He = Client(Index).He & ".0"
            Else
            Client(Index).He = Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX + 2, 1) & ".0"
            End If
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromX > ToX And FromY < ToY Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX - 1 And Client(b).PosY = FromY + 1 Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX - 1 And Pet(splitP(b)).PosY = FromY + 1 Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY + 1), FromX, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY + 1 = ToY And FromX - 1 = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX - 1 & "," & FromY + 1, DBP & "privaterooms\" & Client(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY = ToY + 1 And FromX - 1 = ToX)) Then Exit Function
End If
End If
'roller
            
            
            findPath = FromX - 1 & "," & FromY + 1
            Client(Index).Look = "5,5"
            If walk = "R" Then
            Client(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX, 1)) + 0.4, ",", ".")
            If InStr(Client(Index).He, ".") = 0 Then Client(Index).He = Client(Index).He & ".0"
            Else
            Client(Index).He = Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX, 1) & ".0"
            End If
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromX < ToX And FromY > ToY Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX + 1 And Client(b).PosY = FromY - 1 Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX + 1 And Pet(splitP(b)).PosY = FromY - 1 Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY - 1), FromX + 2, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY - 1 = ToY And FromX + 1 = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX + 1 & "," & FromY - 1, DBP & "privaterooms\" & Client(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY = ToY - 1 And FromX + 1 = ToX)) Then Exit Function
End If
End If
'roller
            
            
            findPath = FromX + 1 & "," & FromY - 1
            Client(Index).Look = "1,1"
            If walk = "R" Then
            Client(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX + 2, 1)) + 0.4, ",", ".")
            If InStr(Client(Index).He, ".") = 0 Then Client(Index).He = Client(Index).He & ".0"
            Else
            Client(Index).He = Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX + 2, 1) & ".0"
            End If
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromX > ToX Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX - 1 And Client(b).PosY = FromY Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX - 1 And Pet(splitP(b)).PosY = FromY Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY), FromX, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY = ToY And FromX - 1 = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX - 1 & "," & FromY, DBP & "privaterooms\" & Client(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY = ToY And FromX - 1 = ToX)) Then Exit Function
End If
End If
'roller
            
            findPath = FromX - 1 & "," & FromY
            Client(Index).Look = "6,6"
            If walk = "R" Then
            Client(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY), FromX, 1)) + 0.4, ",", ".")
            If InStr(Client(Index).He, ".") = 0 Then Client(Index).He = Client(Index).He & ".0"
            Else
            Client(Index).He = Mid(Split(HeightMap, Chr(13))(FromY), FromX, 1) & ".0"
            End If
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromX < ToX Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX + 1 And Client(b).PosY = FromY Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX + 1 And Pet(splitP(b)).PosY = FromY Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY), FromX + 2, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY = ToY And FromX + 1 = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX + 1 & "," & FromY, DBP & "privaterooms\" & Client(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY = ToY And FromX + 1 = ToX)) Then Exit Function
End If
End If
'roller
            
            findPath = FromX + 1 & "," & FromY
            Client(Index).Look = "2,2"
            If walk = "R" Then
            Client(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY), FromX + 2, 1)) + 0.4, ",", ".")
            If InStr(Client(Index).He, ".") = 0 Then Client(Index).He = Client(Index).He & ".0"
            Else
            Client(Index).He = Mid(Split(HeightMap, Chr(13))(FromY), FromX + 2, 1) & ".0"
            End If
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromY < ToY Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX And Client(b).PosY = FromY + 1 Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX And Pet(splitP(b)).PosY = FromY + 1 Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY + 1), FromX + 1, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY + 1 = ToY And FromX = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX & "," & FromY + 1, DBP & "privaterooms\" & Client(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY + 1 = ToY And FromX = ToX)) Then Exit Function
End If
End If
'roller
            
            findPath = FromX & "," & FromY + 1
            Client(Index).Look = "4,4"
            If walk = "R" Then
            Client(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX + 1, 1)) + 0.4, ",", ".")
            If InStr(Client(Index).He, ".") = 0 Then Client(Index).He = Client(Index).He & ".0"
            Else
            Client(Index).He = Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX + 1, 1) & ".0"
            End If
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromY > ToY Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX And Client(b).PosY = FromY - 1 Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX And Pet(splitP(b)).PosY = FromY - 1 Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY - 1), FromX + 1, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY - 1 = ToY And FromX = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX & "," & FromY - 1, DBP & "privaterooms\" & Client(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY - 1 = ToY And FromX = ToX)) Then Exit Function
End If
End If
'roller
            
            
            findPath = FromX & "," & FromY - 1
            Client(Index).Look = "0,0"
            If walk = "R" Then
            Client(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX + 1, 1)) + 0.4, ",", ".")
            If InStr(Client(Index).He, ".") = 0 Then Client(Index).He = Client(Index).He & ".0"
            Else
            Client(Index).He = Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX + 1, 1) & ".0"
            End If
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If

anError:
End Function

Public Function findPathpet(Index As Integer, ByVal FromX As Integer, ByVal FromY As Integer, ByVal ToX As Integer, ByVal ToY As Integer, ByVal Room As Integer, Walks As String, HeightMap As String) As String
Dim i As Integer
Dim walk As String
findPathpet = "NoPath"
On Error GoTo anError


If FromX > ToX And FromY > ToY Then
    
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX - 1 And Client(b).PosY = FromY - 1 Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX - 1 And Pet(splitP(b)).PosY = FromY - 1 Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY - 1), FromX, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY - 1 = ToY And FromX - 1 = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX - 1 & "," & FromY - 1, DBP & "privaterooms\" & Pet(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY = ToY - 1 And FromX - 1 = ToX)) Then Exit Function
End If
End If
'roller
            
            Pet(Index).Look = "7,7"
            findPathpet = FromX - 1 & "," & FromY - 1
            If walk = "R" Then
            Pet(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX, 1)) + 0.4, ",", ".")
            If InStr(Pet(Index).He, ".") = 0 Then Pet(Index).He = Pet(Index).He & ".0"
            Else
            Pet(Index).He = Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX, 1) & ".0"
            End If
            Pet(Index).Hadd = 0
            Pet(Index).Sit = False
            Pet(Index).Actiontype = ""
            Pet(Index).Lay = False
        Exit Function
    End If
End If

If FromX < ToX And FromY < ToY Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX + 1 And Client(b).PosY = FromY + 1 Then Exit Function
End If
Next b
splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX + 1 And Pet(splitP(b)).PosY = FromY + 1 Then Exit Function
End If
End If
Next b

    walk = Mid(Split(Walks, Chr(13))(FromY + 1), FromX + 2, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY + 1 = ToY And FromX + 1 = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX + 1 & "," & FromY + 1, DBP & "privaterooms\" & Pet(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY = ToY + 1 And FromX + 1 = ToX)) Then Exit Function
End If
End If
'roller
            
            findPathpet = FromX + 1 & "," & FromY + 1
            Pet(Index).Look = "3,3"
            If walk = "R" Then
            Pet(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX + 2, 1)) + 0.4, ",", ".")
            If InStr(Pet(Index).He, ".") = 0 Then Pet(Index).He = Pet(Index).He & ".0"
            Else
            Pet(Index).He = Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX + 2, 1) & ".0"
            End If
            Pet(Index).Hadd = 0
            Pet(Index).Actiontype = ""
            Pet(Index).Sit = False
            Pet(Index).Lay = False
        Exit Function
    End If
End If

If FromX > ToX And FromY < ToY Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX - 1 And Client(b).PosY = FromY + 1 Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX - 1 And Pet(splitP(b)).PosY = FromY + 1 Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY + 1), FromX, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY + 1 = ToY And FromX - 1 = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX - 1 & "," & FromY + 1, DBP & "privaterooms\" & Pet(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY = ToY + 1 And FromX - 1 = ToX)) Then Exit Function
End If
End If
'roller
            
            findPathpet = FromX - 1 & "," & FromY + 1
            Pet(Index).Look = "5,5"
            If walk = "R" Then
            Pet(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX, 1)) + 0.4, ",", ".")
            If InStr(Pet(Index).He, ".") = 0 Then Pet(Index).He = Pet(Index).He & ".0"
            Else
            Pet(Index).He = Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX, 1) & ".0"
            End If
            Pet(Index).Hadd = 0
            Pet(Index).Actiontype = ""
            Pet(Index).Sit = False
            Pet(Index).Lay = False
        Exit Function
    End If
End If

If FromX < ToX And FromY > ToY Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX + 1 And Client(b).PosY = FromY - 1 Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX + 1 And Pet(splitP(b)).PosY = FromY - 1 Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY - 1), FromX + 2, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY - 1 = ToY And FromX + 1 = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX + 1 & "," & FromY - 1, DBP & "privaterooms\" & Pet(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY = ToY - 1 And FromX + 1 = ToX)) Then Exit Function
End If
End If
'roller
            
            findPathpet = FromX + 1 & "," & FromY - 1
            Pet(Index).Look = "1,1"
            If walk = "R" Then
            Pet(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX + 2, 1)) + 0.4, ",", ".")
            If InStr(Pet(Index).He, ".") = 0 Then Pet(Index).He = Pet(Index).He & ".0"
            Else
            Pet(Index).He = Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX + 2, 1) & ".0"
            End If
            Pet(Index).Hadd = 0
            Pet(Index).Actiontype = ""
            Pet(Index).Sit = False
            Pet(Index).Lay = False
        Exit Function
    End If
End If

If FromX > ToX Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX - 1 And Client(b).PosY = FromY Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX - 1 And Pet(splitP(b)).PosY = FromY Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY), FromX, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY = ToY And FromX - 1 = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX - 1 & "," & FromY, DBP & "privaterooms\" & Pet(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY = ToY And FromX - 1 = ToX)) Then Exit Function
End If
End If
'roller
            
            findPathpet = FromX - 1 & "," & FromY
            Pet(Index).Look = "6,6"
            If walk = "R" Then
            Pet(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY), FromX, 1)) + 0.4, ",", ".")
            If InStr(Pet(Index).He, ".") = 0 Then Pet(Index).He = Pet(Index).He & ".0"
            Else
            Pet(Index).He = Mid(Split(HeightMap, Chr(13))(FromY), FromX, 1) & ".0"
            End If
            Pet(Index).Hadd = 0
            Pet(Index).Actiontype = ""
            Pet(Index).Sit = False
            Pet(Index).Lay = False
        Exit Function
    End If
End If

If FromX < ToX Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX + 1 And Client(b).PosY = FromY Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX + 1 And Pet(splitP(b)).PosY = FromY Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY), FromX + 2, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY = ToY And FromX + 1 = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX + 1 & "," & FromY, DBP & "privaterooms\" & Pet(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY = ToY And FromX + 1 = ToX)) Then Exit Function
End If
End If
'roller

            findPathpet = FromX + 1 & "," & FromY
            Pet(Index).Look = "2,2"
            If walk = "R" Then
            Pet(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY), FromX + 2, 1)) + 0.4, ",", ".")
            If InStr(Pet(Index).He, ".") = 0 Then Pet(Index).He = Pet(Index).He & ".0"
            Else
            Pet(Index).He = Mid(Split(HeightMap, Chr(13))(FromY), FromX + 2, 1) & ".0"
            End If
            Pet(Index).Hadd = 0
            Pet(Index).Actiontype = ""
            Pet(Index).Sit = False
            Pet(Index).Lay = False
        Exit Function
    End If
End If

If FromY < ToY Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX And Client(b).PosY = FromY + 1 Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX And Pet(splitP(b)).PosY = FromY + 1 Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY + 1), FromX + 1, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY + 1 = ToY And FromX = ToX) Then
            
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX & "," & FromY + 1, DBP & "privaterooms\" & Pet(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY + 1 = ToY And FromX = ToX)) Then Exit Function
End If
End If
'roller
            
            
            findPathpet = FromX & "," & FromY + 1
            Pet(Index).Look = "4,4"
            If walk = "R" Then
            Pet(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX + 1, 1)) + 0.4, ",", ".")
            If InStr(Pet(Index).He, ".") = 0 Then Pet(Index).He = Pet(Index).He & ".0"
            Else
            Pet(Index).He = Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX + 1, 1) & ".0"
            End If
            Pet(Index).Hadd = 0
            Pet(Index).Actiontype = ""
            Pet(Index).Sit = False
            Pet(Index).Lay = False
        Exit Function
    End If
End If

If FromY > ToY Then
For b = 1 To frmMain.SockI
If Client(b).InRoom = Room Then
If Client(b).PosX = FromX And Client(b).PosY = FromY - 1 Then Exit Function
End If
Next b

splitP = Split(frmMain.Hpets, ";")
For b = 0 To UBound(splitP)
If splitP(b) <> "" Then
If Pet(splitP(b)).InRoom = Room Then
If Pet(splitP(b)).PosX = FromX And Pet(splitP(b)).PosY = FromY - 1 Then Exit Function
End If
End If
Next b
    
    walk = Mid(Split(Walks, Chr(13))(FromY - 1), FromX + 1, 1)
    If walk = "O" Or walk = "D" Or walk = "R" Or ((walk = "S" Or walk = "L") And FromY - 1 = ToY And FromX = ToX) Then
    
'roller
If walk = "R" Then
FurniOP = ReadINI("furnies", FromX & "," & FromY - 1, DBP & "privaterooms\" & Pet(Index).InRoom & "\rotation.txt")
If FurniOP <> "" Then
FurniType = FSO.OpenTextFile(DBP & "furni\" & FurniOP & "\type.txt", ForReading).ReadAll
If (Not FurniType = "rug") And (Not ((FurniType = "sit" Or FurniType = "bed") And FromY - 1 = ToY And FromX = ToX)) Then Exit Function
End If
End If
'roller
    
            findPathpet = FromX & "," & FromY - 1
            Pet(Index).Look = "0,0"
            If walk = "R" Then
            Pet(Index).He = Replace(Val(Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX + 1, 1)) + 0.4, ",", ".")
            If InStr(Pet(Index).He, ".") = 0 Then Pet(Index).He = Pet(Index).He & ".0"
            Else
            Pet(Index).He = Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX + 1, 1) & ".0"
            End If
            Pet(Index).Hadd = 0
            Pet(Index).Actiontype = ""
            Pet(Index).Sit = False
            Pet(Index).Lay = False
        Exit Function
    End If
End If

anError:
End Function

Public Function FindPathP(Index As Integer, ByVal FromX As Integer, ByVal FromY As Integer, ByVal ToX As Integer, ByVal ToY As Integer, ByVal HeightMap As String)
Dim i As Integer
Dim walk As String
FindPathP = "NoPath"
On Error GoTo anError

Botnum = 0
For b = 1 To frmMain.BotI
    If Bot(b).Publicnum = Client(Index).Publicnum Then
        Botnum = b
        Exit For
    End If
Next b

If FromX > ToX And FromY > ToY Then
If Bot(Botnum).PosX = FromX - 1 And Bot(Botnum).PosY = FromY - 1 Then Exit Function
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Client(Index).Publicnum Then
If Client(b).PosX = FromX - 1 And Client(b).PosY = FromY - 1 Then Exit Function
End If
Next b

    walk = Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX, 1)
    furni = PublicWalk(Client(Index).Publicnum, FromX - 1, FromY - 1)
    Checkhe = Val(Split(Client(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "" Or (furni = "S" And FromY - 1 = ToY And FromX - 1 = ToX)) And IsNumeric(walk) = True Then
            FindPathP = FromX - 1 & "," & FromY - 1
            Client(Index).Look = "7,7"
            Client(Index).He = walk & ".0"
            Client(Index).Sit = False
            Client(Index).Hadd = 0
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromX < ToX And FromY < ToY Then
If Bot(Botnum).PosX = FromX + 1 And Bot(Botnum).PosY = FromY + 1 Then Exit Function
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Client(Index).Publicnum Then
If Client(b).PosX = FromX + 1 And Client(b).PosY = FromY + 1 Then Exit Function
End If
Next b

    walk = Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX + 2, 1)
    furni = PublicWalk(Client(Index).Publicnum, FromX + 1, FromY + 1)
    Checkhe = Val(Split(Client(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "" Or (furni = "S" And FromY + 1 = ToY And FromX + 1 = ToX)) And IsNumeric(walk) = True Then
            FindPathP = FromX + 1 & "," & FromY + 1
            Client(Index).Look = "3,3"
            Client(Index).He = walk & ".0"
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromX > ToX And FromY < ToY Then
If Bot(Botnum).PosX = FromX - 1 And Bot(Botnum).PosY = FromY + 1 Then Exit Function
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Client(Index).Publicnum Then
If Client(b).PosX = FromX - 1 And Client(b).PosY = FromY + 1 Then Exit Function
End If
Next b

    walk = Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX, 1)
    furni = PublicWalk(Client(Index).Publicnum, FromX - 1, FromY + 1)
    Checkhe = Val(Split(Client(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "" Or (furni = "S" And FromY + 1 = ToY And FromX - 1 = ToX)) And IsNumeric(walk) = True Then
            FindPathP = FromX - 1 & "," & FromY + 1
            Client(Index).Look = "5,5"
            If IsNumeric(walk) = False Then walk = "1"
            Client(Index).He = walk & ".0"
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromX < ToX And FromY > ToY Then
If Bot(Botnum).PosX = FromX + 1 And Bot(Botnum).PosY = FromY - 1 Then Exit Function
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Client(Index).Publicnum Then
If Client(b).PosX = FromX + 1 And Client(b).PosY = FromY - 1 Then Exit Function
End If
Next b

    walk = Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX + 2, 1)
    furni = PublicWalk(Client(Index).Publicnum, FromX + 1, FromY - 1)
    Checkhe = Val(Split(Client(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "" Or (furni = "S" And FromY - 1 = ToY And FromX + 1 = ToX)) And IsNumeric(walk) = True Then
            FindPathP = FromX + 1 & "," & FromY - 1
            Client(Index).Look = "1,1"
            Client(Index).He = walk & ".0"
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromX > ToX Then
If Bot(Botnum).PosX = FromX - 1 And Bot(Botnum).PosY = FromY Then Exit Function
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Client(Index).Publicnum Then
If Client(b).PosX = FromX - 1 And Client(b).PosY = FromY Then Exit Function
End If
Next b

    walk = Mid(Split(HeightMap, Chr(13))(FromY), FromX, 1)
    furni = PublicWalk(Client(Index).Publicnum, FromX - 1, FromY)
    Checkhe = Val(Split(Client(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "" Or (furni = "S" And FromY = ToY And FromX - 1 = ToX)) And IsNumeric(walk) = True Then
            FindPathP = FromX - 1 & "," & FromY
            Client(Index).Look = "6,6"
            Client(Index).He = walk & ".0"
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromX < ToX Then
If Bot(Botnum).PosX = FromX + 1 And Bot(Botnum).PosY = FromY Then Exit Function
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Client(Index).Publicnum Then
If Client(b).PosX = FromX + 1 And Client(b).PosY = FromY Then Exit Function
End If
Next b

    walk = Mid(Split(HeightMap, Chr(13))(FromY), FromX + 2, 1)
    furni = PublicWalk(Client(Index).Publicnum, FromX + 1, FromY)
    Checkhe = Val(Split(Client(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "" Or (furni = "S" And FromY = ToY And FromX + 1 = ToX)) And IsNumeric(walk) = True Then
            FindPathP = FromX + 1 & "," & FromY
            Client(Index).Look = "2,2"
            Client(Index).He = walk & ".0"
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromY < ToY Then
If Bot(Botnum).PosX = FromX And Bot(Botnum).PosY = FromY + 1 Then Exit Function
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Client(Index).Publicnum Then
If Client(b).PosX = FromX And Client(b).PosY = FromY + 1 Then Exit Function
End If
Next b
    
    walk = Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX + 1, 1)
    furni = PublicWalk(Client(Index).Publicnum, FromX, FromY + 1)
    Checkhe = Val(Split(Client(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "" Or (furni = "S" And FromY + 1 = ToY And FromX = ToX)) And IsNumeric(walk) = True Then
            FindPathP = FromX & "," & FromY + 1
            Client(Index).Look = "4,4"
            Client(Index).He = walk & ".0"
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If

If FromY > ToY Then
If Bot(Botnum).PosX = FromX And Bot(Botnum).PosY = FromY - 1 Then Exit Function
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Client(Index).Publicnum Then
If Client(b).PosX = FromX And Client(b).PosY = FromY - 1 Then Exit Function
End If
Next b
    
    walk = Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX + 1, 1)
    furni = PublicWalk(Client(Index).Publicnum, FromX, FromY - 1)
    Checkhe = Val(Split(Client(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "" Or (furni = "S" And FromY - 1 = ToY And FromX = ToX)) And IsNumeric(walk) = True Then
            FindPathP = FromX & "," & FromY - 1
            Client(Index).Look = "0,0"
            Client(Index).He = walk & ".0"
            Client(Index).Hadd = 0
            Client(Index).Sit = False
            Client(Index).Lay = False
        Exit Function
    End If
End If




Exit Function
anError:
End Function

Public Function FindPathBot(Index As Integer, ByVal FromX As Integer, ByVal FromY As Integer, ByVal ToX As Integer, ByVal ToY As Integer, ByVal HeightMap As String)
Dim i As Integer
Dim walk As String
FindPathBot = "NoPath"
On Error GoTo anError

If FromX > ToX And FromY > ToY Then
    
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Bot(Index).Publicnum Then
If Client(b).PosX = FromX - 1 And Client(b).PosY = FromY - 1 Then Exit Function
End If
Next b

    walk = Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX, 1)
    furni = PublicWalk(Bot(Index).Publicnum, FromX - 1, FromY - 1)
    Checkhe = Val(Split(Bot(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "") And IsNumeric(walk) = True Then
            FindPathBot = FromX - 1 & "," & FromY - 1
            Bot(Index).Look = "7,7"
            Bot(Index).He = walk & ".0"
        Exit Function
    End If
End If

If FromX < ToX And FromY < ToY Then
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Bot(Index).Publicnum Then
If Client(b).PosX = FromX + 1 And Client(b).PosY = FromY + 1 Then Exit Function
End If
Next b

    walk = Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX + 2, 1)
    furni = PublicWalk(Bot(Index).Publicnum, FromX + 1, FromY + 1)
    Checkhe = Val(Split(Bot(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "") And IsNumeric(walk) = True Then
            FindPathBot = FromX + 1 & "," & FromY + 1
            Bot(Index).Look = "3,3"
            Bot(Index).He = walk & ".0"
        Exit Function
    End If
End If

If FromX > ToX And FromY < ToY Then
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Bot(Index).Publicnum Then
If Client(b).PosX = FromX - 1 And Client(b).PosY = FromY + 1 Then Exit Function
End If
Next b

    walk = Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX, 1)
    furni = PublicWalk(Bot(Index).Publicnum, FromX - 1, FromY + 1)
    Checkhe = Val(Split(Bot(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "") And IsNumeric(walk) = True Then
            FindPathBot = FromX - 1 & "," & FromY + 1
            Bot(Index).Look = "5,5"
            If IsNumeric(walk) = False Then walk = "1"
            Bot(Index).He = walk & ".0"
        Exit Function
    End If
End If

If FromX < ToX And FromY > ToY Then
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Bot(Index).Publicnum Then
If Client(b).PosX = FromX + 1 And Client(b).PosY = FromY - 1 Then Exit Function
End If
Next b

    walk = Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX + 2, 1)
    furni = PublicWalk(Bot(Index).Publicnum, FromX + 1, FromY - 1)
    Checkhe = Val(Split(Bot(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "") And IsNumeric(walk) = True Then
            FindPathBot = FromX + 1 & "," & FromY - 1
            Bot(Index).Look = "1,1"
            Bot(Index).He = walk & ".0"
        Exit Function
    End If
End If

If FromX > ToX Then
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Bot(Index).Publicnum Then
If Client(b).PosX = FromX - 1 And Client(b).PosY = FromY Then Exit Function
End If
Next b

    walk = Mid(Split(HeightMap, Chr(13))(FromY), FromX, 1)
    furni = PublicWalk(Bot(Index).Publicnum, FromX - 1, FromY)
    Checkhe = Val(Split(Bot(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "") And IsNumeric(walk) = True Then
            FindPathBot = FromX - 1 & "," & FromY
            Bot(Index).Look = "6,6"
            Bot(Index).He = walk & ".0"
        Exit Function
    End If
End If

If FromX < ToX Then
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Bot(Index).Publicnum Then
If Client(b).PosX = FromX + 1 And Client(b).PosY = FromY Then Exit Function
End If
Next b

    walk = Mid(Split(HeightMap, Chr(13))(FromY), FromX + 2, 1)
    furni = PublicWalk(Bot(Index).Publicnum, FromX + 1, FromY)
    Checkhe = Val(Split(Bot(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "") And IsNumeric(walk) = True Then
            FindPathBot = FromX + 1 & "," & FromY
            Bot(Index).Look = "2,2"
            Bot(Index).He = walk & ".0"
        Exit Function
    End If
End If

If FromY < ToY Then
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Bot(Index).Publicnum Then
If Client(b).PosX = FromX And Client(b).PosY = FromY + 1 Then Exit Function
End If
Next b
    
    walk = Mid(Split(HeightMap, Chr(13))(FromY + 1), FromX + 1, 1)
    furni = PublicWalk(Bot(Index).Publicnum, FromX, FromY + 1)
    Checkhe = Val(Split(Bot(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "") And IsNumeric(walk) = True Then
            FindPathBot = FromX & "," & FromY + 1
            Bot(Index).Look = "4,4"
            Bot(Index).He = walk & ".0"
        Exit Function
    End If
End If

If FromY > ToY Then
For b = 1 To frmMain.SockI
If Client(b).Publicnum = Bot(Index).Publicnum Then
If Client(b).PosX = FromX And Client(b).PosY = FromY - 1 Then Exit Function
End If
Next b
    
    walk = Mid(Split(HeightMap, Chr(13))(FromY - 1), FromX + 1, 1)
    furni = PublicWalk(Bot(Index).Publicnum, FromX, FromY - 1)
    Checkhe = Val(Split(Bot(Index).He, ".")(0)) - Val(walk)
    If Checkhe > 1 Or Checkhe < -1 Then Exit Function
    If (furni = "") And IsNumeric(walk) = True Then
            FindPathBot = FromX & "," & FromY - 1
            Bot(Index).Look = "0,0"
            Bot(Index).He = walk & ".0"
        Exit Function
    End If
End If




Exit Function
anError:
End Function

Public Function CheckPosition(Index As Integer)
If Client(Index).Publicnum = 13 Then 'Rooftop
    If (Client(Index).PosX = 9 And Client(Index).PosY = 4) Or (Client(Index).PosX = 10 And Client(Index).PosY = 4) Or (Client(Index).PosX = 9 And Client(Index).PosY = 3) Then
        Client(Index).Publicnum = 14
        Send Index, "AErooftop_2 42431"
        sendAllP "@]" & Client(Index).Num & Chr(1), 13
        Client(Index).WishX = 0
        Client(Index).WishY = 0
        Exit Function
    End If
End If
If Client(Index).Publicnum = 14 Then 'Rooftop 2
    If (Client(Index).PosY > 9) Then
        Client(Index).Publicnum = 13
        Client(Index).PosX = 9
        Client(Index).PosY = 4
        Client(Index).DestX = 9
        Client(Index).DestY = 4
        Client(Index).He = 4
        Client(Index).Look = "4,4"
        Client(Index).Lockposition = True
        Send Index, "AErooftop 42431"
        sendAllP "@]" & Client(Index).Num & Chr(1), 14
        Client(Index).WishX = 0
        Client(Index).WishY = 0
        Exit Function
    End If
End If
If Client(Index).Publicnum = "11" Then 'Lido 1
    If (Client(Index).PosX = 26 And Client(Index).PosY = 10) Or (Client(Index).PosX = 25 And Client(Index).PosY) = 9 Or (Client(Index).PosX = 24 And Client(Index).PosY = 8) Or (Client(Index).PosX = 23 And Client(Index).PosY = 7) Or (Client(Index).PosX = 22 And Client(Index).PosY = 6) Or (Client(Index).PosX = 21 And Client(Index).PosY = 5) Or (Client(Index).PosX = 20 And Client(Index).PosY = 4) Then
    Client(Index).Publicnum = 12
    Send Index, "AEpool_b 15188"
    sendAllP "@]" & Client(Index).Num & Chr(1), 11
    Client(Index).WishX = 0
    Client(Index).WishY = 0
    Exit Function
  End If
End If
End Function
