Attribute VB_Name = "modPathfinding" Public Function findPath(a As Integer, x As Integer, y As Integer, tx As Integer, ty As Integer, room As Integer) As String Dim i As Integer Dim walk As String findPath = "NoPath" On Error GoTo anError If x > tx And y > ty Then If botX(room) = x - 1 And botY(room) = y - 1 Then Exit Function For i = 0 To MxHabbo If CX(i) = x - 1 And CY(i) = y - 1 Then Exit Function Next walk = CanWalkP(room, x - 1, y - 1) If IsNumeric(walk) Then If walk > -1 And walk < 10 Then findPath = x - 1 & "," & y - 1 Fa(a) = "7,7" He(a) = walk & ".0" IsSit(a) = False IsLay(a) = False End If Exit Function End If End If If x < tx And y < ty Then If botX(room) = x + 1 And botY(room) = y + 1 Then Exit Function For i = 0 To MxHabbo If CX(i) = x + 1 And CY(i) = y + 1 Then Exit Function Next walk = CanWalkP(room, x + 1, y + 1) If IsNumeric(walk) Then If walk > -1 And walk < 10 Then findPath = x + 1 & "," & y + 1 Fa(a) = "3,3" He(a) = walk & ".0" IsSit(a) = False IsLay(a) = False End If Exit Function End If End If If x > tx And y < ty Then If botX(room) = x - 1 And botY(room) = y + 1 Then Exit Function For i = 0 To MxHabbo If CX(i) = x - 1 And CY(i) = y + 1 Then Exit Function Next walk = CanWalkP(room, x - 1, y + 1) If IsNumeric(walk) Then If walk > -1 And walk < 10 Then findPath = x - 1 & "," & y + 1 Fa(a) = "5,5" He(a) = walk & ".0" IsSit(a) = False IsLay(a) = False End If Exit Function End If End If If x < tx And y > ty Then If botX(room) = x + 1 And botY(room) = y - 1 Then Exit Function For i = 0 To MxHabbo If CX(i) = x + 1 And CY(i) = y - 1 Then Exit Function Next walk = CanWalkP(room, x + 1, y - 1) If IsNumeric(walk) Then If walk > -1 And walk < 10 Then findPath = x + 1 & "," & y - 1 Fa(a) = "1,1" He(a) = walk & ".0" IsSit(a) = False IsLay(a) = False End If Exit Function End If End If If x > tx Then If botX(room) = x - 1 And botY(room) = y Then Exit Function For i = 0 To MxHabbo If CX(i) = x - 1 And CY(i) = y Then Exit Function Next walk = CanWalkP(room, x - 1, y) If IsNumeric(walk) Then If walk > -1 And walk < 10 Then findPath = x - 1 & "," & y Fa(a) = "6,6" He(a) = walk & ".0" IsSit(a) = False IsLay(a) = False End If Exit Function Else If walk = "X" Then Exit Function If tx = x - 1 And ty = y Then findPath = x - 1 & "," & y Fa(a) = "6,6" He(a) = Asc(walk) - 65 & ".0" Sh(a) = "1.0" IsSit(a) = True IsLay(a) = False IsDance(a) = False End If Exit Function End If End If If x < tx Then If botX(room) = x + 1 And botY(room) = y Then Exit Function For i = 0 To MxHabbo If CX(i) = x + 1 And CY(i) = y Then Exit Function Next walk = CanWalkP(room, x + 1, y) If IsNumeric(walk) Then If walk > -1 And walk < 10 Then findPath = x + 1 & "," & y Fa(a) = "2,2" He(a) = walk & ".0" IsSit(a) = False IsLay(a) = False End If Exit Function Else If walk = "X" Then Exit Function If tx = x + 1 And ty = y Then findPath = x + 1 & "," & y Fa(a) = "2,2" He(a) = Asc(walk) - 65 & ".0" Sh(a) = "1.0" IsSit(a) = True IsLay(a) = False IsDance(a) = False End If Exit Function End If End If If y < ty Then If botX(room) = x And botY(room) = y + 1 Then Exit Function For i = 0 To MxHabbo If CX(i) = x And CY(i) = y + 1 Then Exit Function Next walk = CanWalkP(room, x, y + 1) If IsNumeric(walk) Then If walk > -1 And walk < 10 Then findPath = x & "," & y + 1 Fa(a) = "4,4" He(a) = walk & ".0" IsSit(a) = False IsLay(a) = False End If Exit Function Else If walk = "X" Then Exit Function If tx = x And ty = y + 1 Then findPath = x & "," & y + 1 Fa(a) = "4,4" He(a) = Asc(walk) - 65 & ".0" Sh(a) = "1.0" IsSit(a) = True IsLay(a) = False IsDance(a) = False End If Exit Function End If End If If y > ty Then If botX(room) = x And botY(room) = y - 1 Then Exit Function For i = 0 To MxHabbo If CX(i) = x And CY(i) = y - 1 Then Exit Function Next walk = CanWalkP(room, x, y - 1) If IsNumeric(walk) Then If walk > -1 And walk < 10 Then findPath = x & "," & y - 1 Fa(a) = "0,0" He(a) = walk & ".0" IsSit(a) = False IsLay(a) = False End If Exit Function Else If walk = "X" Then Exit Function If tx = x And ty = y - 1 Then findPath = x & "," & y - 1 Fa(a) = "0,0" He(a) = Asc(walk) - 65 & ".0" Sh(a) = "1.0" IsSit(a) = True IsLay(a) = False IsDance(a) = False End If Exit Function End If End If anError: End Function