Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Question Again.


BugSICK
 Share

Recommended Posts

```
' ::::::::::::::::::::::::::::
    ' :: Player movement packet ::
    ' ::::::::::::::::::::::::::::
    If (casestring = "playermove") Then
        i = Val(parse(1))
        X = Val(parse(2))
        y = Val(parse(3))
        Dir = Val(parse(4))
        n = Val(parse(5))

        If Dir < DIR_UP Or Dir > DIR_RIGHT Then
            Exit Sub
        End If

        Call SetPlayerX(i, X)
        Call SetPlayerY(i, y)
        Call SetPlayerDir(i, Dir)

        Player(i).xOffset = 0
        Player(i).yOffset = 0
        Player(i).Moving = n
```
??  :lipsrsealed:
Link to comment
Share on other sites

sorry for the post again. but i really need this. any could help me shall be credited here [http://www.touchofdeathforums.com/smf/index.php?board=284.0](http://www.touchofdeathforums.com/smf/index.php?board=284.0)

hayz. thanks
Link to comment
Share on other sites

change this:
```
Function CanMove() As Boolean
    Dim i As Long
    Dim X As Long
    Dim y As Long

    CanMove = True

    If Player(MyIndex).Moving <> 0 Then
        CanMove = False
        Exit Function
    End If

    ' Make sure they haven't just casted a spell
    If Player(MyIndex).CastedSpell = YES Then
        If GetTickCount > Player(MyIndex).AttackTimer + 1000 Then
            Player(MyIndex).CastedSpell = NO
        Else
            CanMove = False
            Exit Function
        End If
    End If

    X = GetPlayerX(MyIndex)
    y = GetPlayerY(MyIndex)

    If DirUp Then
        Call SetPlayerDir(MyIndex, DIR_UP)
        y = y - 1
    ElseIf DirDown Then
        Call SetPlayerDir(MyIndex, DIR_DOWN)
        y = y + 1
    ElseIf DirLeft Then
        Call SetPlayerDir(MyIndex, DIR_LEFT)
        X = X - 1
    Else
        Call SetPlayerDir(MyIndex, DIR_RIGHT)
        X = X + 1
    End If

    If y < 0 Then
        If Map(GetPlayerMap(MyIndex)).Up > 0 Then
            Call SendPlayerRequestNewMap(DIR_UP)
            GettingMap = True
        End If
        CanMove = False
        Exit Function
    ElseIf y > MAX_MAPY Then
        If Map(GetPlayerMap(MyIndex)).Down > 0 Then
            Call SendPlayerRequestNewMap(DIR_DOWN)
            GettingMap = True
        End If
        CanMove = False
        Exit Function
    ElseIf X < 0 Then
        If Map(GetPlayerMap(MyIndex)).Left > 0 Then
            Call SendPlayerRequestNewMap(DIR_LEFT)
            GettingMap = True
        End If
        CanMove = False
        Exit Function
    ElseIf X > MAX_MAPX Then
        If Map(GetPlayerMap(MyIndex)).Right > 0 Then
            Call SendPlayerRequestNewMap(DIR_RIGHT)
            GettingMap = True
        End If
        CanMove = False
        Exit Function
    End If

    If Not GetPlayerDir(MyIndex) = LAST_DIR Then
        LAST_DIR = GetPlayerDir(MyIndex)
        Call SendPlayerDir
    End If

    If Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_BLOCKED Or Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_SIGN Or Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_ROOFBLOCK Then
        CanMove = False
        Exit Function
    End If

    If Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_CBLOCK Then
        If Map(GetPlayerMap(MyIndex)).Tile(X, y).Data1 = Player(MyIndex).Class Then
            Exit Function
        End If
        If Map(GetPlayerMap(MyIndex)).Tile(X, y).Data2 = Player(MyIndex).Class Then
            Exit Function
        End If
        If Map(GetPlayerMap(MyIndex)).Tile(X, y).Data3 = Player(MyIndex).Class Then
            Exit Function
        End If
        CanMove = False
    End If

    If Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_GUILDBLOCK And Map(GetPlayerMap(MyIndex)).Tile(X, y).String1 <> GetPlayerGuild(MyIndex) Then
        CanMove = False
    End If

    If Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_KEY Or Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_DOOR Then
        If TempTile(X, y).DoorOpen = NO Then
            CanMove = False
            Exit Function
        End If
    End If

    If Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_WALKTHRU Then
        Exit Function
    Else
        For i = 1 To MAX_PLAYERS
            If IsPlaying(i) Then
                If GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
                    If GetPlayerX(i) = X Then
                        If GetPlayerY(i) = y Then
                            CanMove = False
                            Exit Function
                        End If
                    End If
                End If
            End If
        Next i
    End If

    For i = 1 To MAX_MAP_NPCS
        If MapNpc(i).num > 0 Then
            If MapNpc(i).X = X Then
                If MapNpc(i).y = y Then
                    CanMove = False
                    Exit Function
                End If
            End If
        End If
    Next i
End Function
```
to this:

```
Function CanMove() As Boolean
    Dim i As Long
    Dim X As Long
    Dim y As Long

    CanMove = True

    If Player(MyIndex).Moving <> 0 Then
        CanMove = False
        Exit Function
    End If

    ' Make sure they haven't just casted a spell
    If Player(MyIndex).CastedSpell = YES Then
        If GetTickCount > Player(MyIndex).AttackTimer + 1000 Then
            Player(MyIndex).CastedSpell = NO
        Else
            CanMove = False
            Exit Function
        End If
    End If

    X = GetPlayerX(MyIndex)
    y = GetPlayerY(MyIndex)

    If DirUp Then
        Call SetPlayerDir(MyIndex, DIR_UP)
        y = y - 1
    ElseIf DirDown Then
        Call SetPlayerDir(MyIndex, DIR_DOWN)
        y = y + 1
    ElseIf DirLeft Then
        Call SetPlayerDir(MyIndex, DIR_LEFT)
        X = X - 1
    Else
        Call SetPlayerDir(MyIndex, DIR_RIGHT)
        X = X + 1
    End If

    If y < 0 Then
        If Map(GetPlayerMap(MyIndex)).Up > 0 Then
            Call SendPlayerRequestNewMap(DIR_UP)
            GettingMap = True
        End If
        CanMove = False
        Exit Function
    ElseIf y > MAX_MAPY Then
        If Map(GetPlayerMap(MyIndex)).Down > 0 Then
            Call SendPlayerRequestNewMap(DIR_DOWN)
            GettingMap = True
        End If
        CanMove = False
        Exit Function
    ElseIf X < 0 Then
        If Map(GetPlayerMap(MyIndex)).Left > 0 Then
            Call SendPlayerRequestNewMap(DIR_LEFT)
            GettingMap = True
        End If
        CanMove = False
        Exit Function
    ElseIf X > MAX_MAPX Then
        If Map(GetPlayerMap(MyIndex)).Right > 0 Then
            Call SendPlayerRequestNewMap(DIR_RIGHT)
            GettingMap = True
        End If
        CanMove = False
        Exit Function
    End If

    If Not GetPlayerDir(MyIndex) = LAST_DIR Then
        LAST_DIR = GetPlayerDir(MyIndex)
        Call SendPlayerDir
    End If

    If Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_BLOCKED Or Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_SIGN Or Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_ROOFBLOCK Then
        CanMove = False
        Exit Function
    End If

    If Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_CBLOCK Then
        If Map(GetPlayerMap(MyIndex)).Tile(X, y).Data1 = Player(MyIndex).Class Then
            Exit Function
        End If
        If Map(GetPlayerMap(MyIndex)).Tile(X, y).Data2 = Player(MyIndex).Class Then
            Exit Function
        End If
        If Map(GetPlayerMap(MyIndex)).Tile(X, y).Data3 = Player(MyIndex).Class Then
            Exit Function
        End If
        CanMove = False
    End If

    If Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_GUILDBLOCK And Map(GetPlayerMap(MyIndex)).Tile(X, y).String1 <> GetPlayerGuild(MyIndex) Then
        CanMove = False
    End If

    If Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_KEY Or Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_DOOR Then
        If TempTile(X, y).DoorOpen = NO Then
            CanMove = False
            Exit Function
        End If
    End If

    If Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_WALKTHRU Then
        Exit Function
    Else
        For i = 1 To MAX_PLAYERS
            If IsPlaying(i) Then
                If GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
                    If GetPlayerX(i) = X Then
                        If GetPlayerY(i) = y Then
                            CanMove = False
                            Exit Function
                        End If
                    End If
                End If
            End If
        Next i
    End If

End Function

```
problem should be solved.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...