Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic Diagonal Movement
#1
Diagonal Movement
- 8 directional movement - / DOWNLOAD

- Haven't wrote up a tutorial in ages so here you go.
Feel free to improve it.

Diagonal movement is very basic and simple, it's just a lot of copying, pasting,
modifying, and a bit of brain power.

Starting with the client
[spoiler]Let's look at our original DIR_ Constants

Code:
Public Const DIR_UP As Byte = 0
Public Const DIR_DOWN As Byte = 1
Public Const DIR_LEFT As Byte = 2
Public Const DIR_RIGHT As Byte = 3

Since we are adding Diagonal movement theres a top left, top right, bottom left, and bottom right.
I copied that, modified it, and had everything after another.

Code:
Public Const DIR_UP_LEFT As Byte = 0
Public Const DIR_UP_RIGHT As Byte = 1
Public Const DIR_DOWN_LEFT As Byte = 2
Public Const DIR_DOWN_RIGHT As Byte = 3

See anything wrong? You should.
The constants DIR_UP and etc is just a cover for the number so we don't get confused.
Basically the number 0 is the direction up, number 1 is the direction right, etc.

So we cannot have DIR_UP_LEFT to equal 0 because that would be facing up.
so your constants should look like this.

Code:
' Direction constants
Public Const DIR_UP As Byte = 0
Public Const DIR_DOWN As Byte = 1
Public Const DIR_LEFT As Byte = 2
Public Const DIR_RIGHT As Byte = 3
Public Const DIR_UP_LEFT As Byte = 4
Public Const DIR_UP_RIGHT As Byte = 5
Public Const DIR_DOWN_LEFT As Byte = 6
Public Const DIR_DOWN_RIGHT As Byte = 7

Also find
Code:
Public DirUp As Boolean
Public DirDown As Boolean
Public DirLeft As Boolean
Public DirRight As Boolean

and add
Code:
Public DirUpLeft As Boolean
Public DirUpRight As Boolean
Public DirDownLeft As Boolean
Public DirDownRight As Boolean
So now what we want to do is just update everything that includes DIR_UP, DIR_DOWN, etc. and add
our new directions.

Find
Code:
Public Sub BltPlayer(ByVal Index As Long)
Replace the sub with
Code:
Public Sub BltPlayer(ByVal Index As Long)
Dim Anim As Byte
Dim X As Long
Dim Y As Long
Dim rec As DXVBLib.RECT

    ' Check for animation
    Anim = 0
    With rec
        If Player(Index).Attacking = 0 Then
            Select Case GetPlayerDir(Index)
                Case DIR_UP
                    If (Player(Index).YOffset < SIZE_Y / 2) Then Anim = 1
                    .Left = (GetPlayerDir(Index) * 3 + Anim) * SIZE_X
                Case DIR_DOWN
                    If (Player(Index).YOffset < SIZE_Y / 2 * -1) Then Anim = 1
                    .Left = (GetPlayerDir(Index) * 3 + Anim) * SIZE_X
                Case DIR_LEFT
                    If (Player(Index).XOffset < SIZE_Y / 2) Then Anim = 1
                    .Left = (GetPlayerDir(Index) * 3 + Anim) * SIZE_X
                Case DIR_RIGHT
                    If (Player(Index).XOffset < SIZE_Y / 2 * -1) Then Anim = 1
                    .Left = (GetPlayerDir(Index) * 3 + Anim) * SIZE_X
                Case DIR_UP_LEFT
                    If (Player(Index).YOffset < SIZE_Y / 2) And (Player(Index).XOffset < SIZE_Y / 2) Then Anim = 1
                    .Left = ((GetPlayerDir(Index) - GetPlayerDir(Index)) * 3 + Anim) * SIZE_X
                Case DIR_UP_RIGHT
                    If (Player(Index).YOffset < SIZE_Y / 2) And (Player(Index).XOffset < SIZE_Y / 2 * -1) Then Anim = 1
                    .Left = ((GetPlayerDir(Index) - GetPlayerDir(Index)) * 3 + Anim) * SIZE_X
                Case DIR_DOWN_LEFT
                    If (Player(Index).YOffset < SIZE_Y / 2 * -1) And (Player(Index).XOffset < SIZE_Y / 2) Then Anim = 1
                    .Left = ((GetPlayerDir(Index) - GetPlayerDir(Index) + 1) * 3 + Anim) * SIZE_X
                Case DIR_DOWN_RIGHT
                    If (Player(Index).YOffset < SIZE_Y / 2 * -1) And (Player(Index).XOffset < SIZE_Y / 2 * -1) Then Anim = 1
                    .Left = ((GetPlayerDir(Index) - GetPlayerDir(Index) + 1) * 3 + Anim) * SIZE_X
            End Select
        Else
            If Player(Index).AttackTimer + 500 > GetTickCount Then
                Anim = 2
            End If
        End If
    
        .Top = GetPlayerSprite(Index) * SIZE_Y
        .Bottom = .Top + SIZE_Y
        .Right = .Left + SIZE_X
    End With

    
    ' Check to see if we want to stop making him attack
    With Player(Index)
        If .AttackTimer + 1000 < GetTickCount Then
            .Attacking = 0
            .AttackTimer = 0
        End If
    End With
    

        
    
    X = GetPlayerX(Index) * SIZE_X + Player(Index).XOffset
    Y = GetPlayerY(Index) * SIZE_Y + Player(Index).YOffset - 4 ' to raise the sprite by 4 pixels
    
    ' Check if its out of bounds because of the offset
    If Y < 0 Then
        Y = 0
        With rec
            .Top = .Top + (Y * -1)
        End With
    End If
        
    Call DD_MiddleBuffer.BltFast(X, Y, DD_SpriteSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub

Find
Code:
Sub HandlePlayerMove(ByRef Parse() As String)
Below you will see DIR_UP, DIR_DOWN, etc.

What we are gonna do here is simple, just combine directions to make our new direction.

For an example DIR_UP is
Code:
Case DIR_UP
             Player(i).YOffset = PIC_Y

and DIR_LEFT is
Code:
Case DIR_LEFT
             Player(i).XOffset = PIC_X

to make our new direction we just combine them!

our new direction: DIR_UP_LEFT
Code:
Case DIR_UP_LEFT
             Player(i).YOffset = PIC_Y
             Player(i).XOffset = PIC_X

After your done combining everything, it should now look like this
Code:
Case DIR_UP
             Player(i).YOffset = PIC_Y
         Case DIR_DOWN
             Player(i).YOffset = PIC_Y * -1
         Case DIR_LEFT
             Player(i).XOffset = PIC_X
         Case DIR_RIGHT
             Player(i).XOffset = PIC_X * -1
         Case DIR_UP_LEFT
             Player(i).YOffset = PIC_Y
             Player(i).XOffset = PIC_X
         Case DIR_UP_RIGHT
             Player(i).YOffset = PIC_Y
             Player(i).XOffset = PIC_X * -1
         Case DIR_DOWN_LEFT
             Player(i).YOffset = PIC_Y * -1
             Player(i).XOffset = PIC_X
         Case DIR_DOWN_RIGHT
             Player(i).YOffset = PIC_Y * -1
             Player(i).XOffset = PIC_X * -1
I'll be covering everything at once so this includes NPCs.

Find
Code:
Sub HandleNpcMove(ByRef Parse() As String)
Replace the sub with
Code:
Sub HandleNpcMove(ByRef Parse() As String)
Dim i As Long, X As Long, Y As Long, Dir As Long
Dim n As Byte

     i = CLng(Parse(1))
     X = CLng(Parse(2))
     Y = CLng(Parse(3))
     Dir = CLng(Parse(4))
     n = CByte(Parse(5))

     MapNpc(i).X = X
     MapNpc(i).Y = Y
     MapNpc(i).Dir = Dir
     MapNpc(i).XOffset = 0
     MapNpc(i).YOffset = 0
     MapNpc(i).Moving = n
    
     Select Case MapNpc(i).Dir
         Case DIR_UP
             MapNpc(i).YOffset = PIC_Y
         Case DIR_DOWN
             MapNpc(i).YOffset = PIC_Y * -1
         Case DIR_LEFT
             MapNpc(i).XOffset = PIC_X
         Case DIR_RIGHT
             MapNpc(i).XOffset = PIC_X * -1
         Case DIR_UP_LEFT
             MapNpc(i).YOffset = PIC_Y
             MapNpc(i).XOffset = PIC_X
         Case DIR_UP_RIGHT
             MapNpc(i).YOffset = PIC_Y
             MapNpc(i).XOffset = PIC_X * -1
         Case DIR_DOWN_LEFT
             MapNpc(i).YOffset = PIC_Y * -1
             MapNpc(i).XOffset = PIC_X
         Case DIR_DOWN_RIGHT
             MapNpc(i).YOffset = PIC_Y * -1
             MapNpc(i).XOffset = PIC_X * -1
     End Select
End Sub

Next find
Code:
Sub ProcessMovement(ByVal Index As Long)
Replace the sub with
Code:
Sub ProcessMovement(ByVal Index As Long)
Dim MovementSpeed As Long

    ' Check if player is walking, and if so process moving them over
    If Player(Index).Moving = MOVING_WALKING Then
        MovementSpeed = WALK_SPEED
    ElseIf Player(Index).Moving = MOVING_RUNNING Then
        MovementSpeed = RUN_SPEED
    End If
    
    Select Case GetPlayerDir(Index)
        Case DIR_UP
            Player(Index).YOffset = Player(Index).YOffset - MovementSpeed
        Case DIR_DOWN
            Player(Index).YOffset = Player(Index).YOffset + MovementSpeed
        Case DIR_LEFT
            Player(Index).XOffset = Player(Index).XOffset - MovementSpeed
        Case DIR_RIGHT
            Player(Index).XOffset = Player(Index).XOffset + MovementSpeed
        Case DIR_UP_LEFT
            Player(Index).YOffset = Player(Index).YOffset - MovementSpeed
            Player(Index).XOffset = Player(Index).XOffset - MovementSpeed
        Case DIR_UP_RIGHT
            Player(Index).YOffset = Player(Index).YOffset - MovementSpeed
            Player(Index).XOffset = Player(Index).XOffset + MovementSpeed
        Case DIR_DOWN_LEFT
            Player(Index).YOffset = Player(Index).YOffset + MovementSpeed
            Player(Index).XOffset = Player(Index).XOffset - MovementSpeed
        Case DIR_DOWN_RIGHT
            Player(Index).YOffset = Player(Index).YOffset + MovementSpeed
            Player(Index).XOffset = Player(Index).XOffset + MovementSpeed
    End Select

    ' Check if completed walking over to the next tile
    If Player(Index).XOffset = 0 Then
        If Player(Index).YOffset = 0 Then
            Player(Index).Moving = 0
        End If
    End If

End Sub

Next find
Code:
Sub ProcessNpcMovement(ByVal MapNpcNum As Long)
Replace the sub with
Code:
Sub ProcessNpcMovement(ByVal MapNpcNum As Long)
    ' Check if player is walking, and if so process moving them over
    If MapNpc(MapNpcNum).Moving = MOVING_WALKING Then
        Select Case MapNpc(MapNpcNum).Dir
            Case DIR_UP
                MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset - WALK_SPEED
            Case DIR_DOWN
                MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset + WALK_SPEED
            Case DIR_LEFT
                MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset - WALK_SPEED
            Case DIR_RIGHT
                MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset + WALK_SPEED
            Case DIR_UP_LEFT
                MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset - WALK_SPEED
                MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset - WALK_SPEED
            Case DIR_UP_RIGHT
                MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset - WALK_SPEED
                MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset + WALK_SPEED
            Case DIR_DOWN_LEFT
                MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset + WALK_SPEED
                MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset - WALK_SPEED
            Case DIR_DOWN_RIGHT
                MapNpc(MapNpcNum).YOffset = MapNpc(MapNpcNum).YOffset + WALK_SPEED
                MapNpc(MapNpcNum).XOffset = MapNpc(MapNpcNum).XOffset + WALK_SPEED
        End Select
        
        ' Check if completed walking over to the next tile
        If MapNpc(MapNpcNum).XOffset = 0 Then
            If MapNpc(MapNpcNum).YOffset = 0 Then
                MapNpc(MapNpcNum).Moving = 0
            End If
        End If
    End If
End Sub

Next find
Code:
Function CanMove() As Boolean
Replace the sub with
Code:
Function CanMove() As Boolean
Dim d As Long

    CanMove = True
  
    ' Make sure they aren't trying to move when they are already moving
    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
  
    d = GetPlayerDir(MyIndex)
    If DirUp Then
        Call SetPlayerDir(MyIndex, DIR_UP)
      
        ' Check to see if they are trying to go out of bounds
        If GetPlayerY(MyIndex) > 0 Then
            If CheckDirection(DIR_UP) Then
                CanMove = False
              
                ' Set the new direction if they weren't facing that direction
                If d  DIR_UP Then
                    Call SendPlayerDir
                End If
                Exit Function
            End If
        Else
            ' Check if they can warp to a new map
            If Map.Up > 0 Then
                Call MapEditorLeaveMap
                Call SendPlayerRequestNewMap
                GettingMap = True
            End If
            CanMove = False
            Exit Function
        End If
    End If
          
    If DirDown Then
        Call SetPlayerDir(MyIndex, DIR_DOWN)
      
        ' Check to see if they are trying to go out of bounds
        If GetPlayerY(MyIndex) < MAX_MAPY Then
            If CheckDirection(DIR_DOWN) Then
                CanMove = False
              
                ' Set the new direction if they weren't facing that direction
                If d  DIR_DOWN Then
                    Call SendPlayerDir
                End If
                Exit Function
            End If
        Else
            ' Check if they can warp to a new map
            If Map.Down > 0 Then
                Call MapEditorLeaveMap
                Call SendPlayerRequestNewMap
                GettingMap = True
            End If
            CanMove = False
            Exit Function
        End If
    End If
              
    If DirLeft Then
        Call SetPlayerDir(MyIndex, DIR_LEFT)
      
        ' Check to see if they are trying to go out of bounds
        If GetPlayerX(MyIndex) > 0 Then
            If CheckDirection(DIR_LEFT) Then
                CanMove = False
              
                ' Set the new direction if they weren't facing that direction
                If d  DIR_LEFT Then
                    Call SendPlayerDir
                End If
                Exit Function
            End If
        Else
            ' Check if they can warp to a new map
            If Map.Left > 0 Then
                Call MapEditorLeaveMap
                Call SendPlayerRequestNewMap
                GettingMap = True
            End If
            CanMove = False
            Exit Function
        End If
    End If
      
    If DirRight Then
        Call SetPlayerDir(MyIndex, DIR_RIGHT)
      
        ' Check to see if they are trying to go out of bounds
        If GetPlayerX(MyIndex) < MAX_MAPX Then
            If CheckDirection(DIR_RIGHT) Then
                CanMove = False
              
                ' Set the new direction if they weren't facing that direction
                If d  DIR_RIGHT Then
                    Call SendPlayerDir
                End If
                Exit Function
            End If
        Else
            ' Check if they can warp to a new map
            If Map.Right > 0 Then
                Call MapEditorLeaveMap
                Call SendPlayerRequestNewMap
                GettingMap = True
            End If
            CanMove = False
            Exit Function
        End If
    End If
    
    If DirUpLeft Then
        Call SetPlayerDir(MyIndex, DIR_UP_LEFT)
      
        ' Check to see if they are trying to go out of bounds
        If GetPlayerY(MyIndex) > 0 And GetPlayerX(MyIndex) > 0 Then
            If CheckDirection(DIR_UP_LEFT) Then
                CanMove = False
              
                ' Set the new direction if they weren't facing that direction
                If d  DIR_UP_LEFT Then
                    Call SendPlayerDir
                End If
                Exit Function
            End If
        Else
            ' Check if they can warp to a new map
            If Map.Up > 0 Then
                Call MapEditorLeaveMap
                Call SendPlayerRequestNewMap
                GettingMap = True
            End If
            CanMove = False
            Exit Function
        End If
    End If
    
    If DirUpRight Then
        Call SetPlayerDir(MyIndex, DIR_UP_RIGHT)
      
        ' Check to see if they are trying to go out of bounds
        If GetPlayerY(MyIndex) > 0 And GetPlayerX(MyIndex) < Map.MapX Then
            If CheckDirection(DIR_UP_RIGHT) Then
                CanMove = False
              
                ' Set the new direction if they weren't facing that direction
                If d  DIR_UP_RIGHT Then
                    Call SendPlayerDir
                End If
                Exit Function
            End If
        Else
            ' Check if they can warp to a new map
            If Map.Up > 0 Then
                Call MapEditorLeaveMap
                Call SendPlayerRequestNewMap
                GettingMap = True
            End If
            CanMove = False
            Exit Function
        End If
    End If
    
    If DirDownLeft Then
        Call SetPlayerDir(MyIndex, DIR_DOWN_LEFT)
      
        ' Check to see if they are trying to go out of bounds
        If GetPlayerY(MyIndex) < MAX_MAPY And GetPlayerX(MyIndex) > 0 Then
            If CheckDirection(DIR_DOWN_LEFT) Then
                CanMove = False
              
                ' Set the new direction if they weren't facing that direction
                If d  DIR_DOWN_LEFT Then
                    Call SendPlayerDir
                End If
                Exit Function
            End If
        Else
            ' Check if they can warp to a new map
            If Map.Down > 0 Then
                Call MapEditorLeaveMap
                Call SendPlayerRequestNewMap
                GettingMap = True
            End If
            CanMove = False
            Exit Function
        End If
    End If
    
    If DirDownRight Then
        Call SetPlayerDir(MyIndex, DIR_DOWN_RIGHT)
      
        ' Check to see if they are trying to go out of bounds
        If GetPlayerY(MyIndex) < MAX_MAPY And GetPlayerX(MyIndex) < Map.MapX Then
            If CheckDirection(DIR_DOWN_RIGHT) Then
                CanMove = False
              
                ' Set the new direction if they weren't facing that direction
                If d  DIR_DOWN_RIGHT Then
                    Call SendPlayerDir
                End If
                Exit Function
            End If
        Else
            ' Check if they can warp to a new map
            If Map.Down > 0 Then
                Call MapEditorLeaveMap
                Call SendPlayerRequestNewMap
                GettingMap = True
            End If
            CanMove = False
            Exit Function
        End If
    End If
End Function

Next find
Code:
Function CheckDirection(ByVal Direction As Byte) As Boolean

Replace the sub with
Code:
Function CheckDirection(ByVal Direction As Byte) As Boolean
Dim X As Long, Y As Long, i As Long

    CheckDirection = False
  
    Select Case Direction
        Case DIR_UP
            X = GetPlayerX(MyIndex)
            Y = GetPlayerY(MyIndex) - 1
        Case DIR_DOWN
            X = GetPlayerX(MyIndex)
            Y = GetPlayerY(MyIndex) + 1
        Case DIR_LEFT
            X = GetPlayerX(MyIndex) - 1
            Y = GetPlayerY(MyIndex)
        Case DIR_RIGHT
            X = GetPlayerX(MyIndex) + 1
            Y = GetPlayerY(MyIndex)
        Case DIR_UP_LEFT
            X = GetPlayerX(MyIndex) - 1
            Y = GetPlayerY(MyIndex) - 1
        Case DIR_UP_RIGHT
            X = GetPlayerX(MyIndex) + 1
            Y = GetPlayerY(MyIndex) - 1
        Case DIR_DOWN_LEFT
            X = GetPlayerX(MyIndex) - 1
            Y = GetPlayerY(MyIndex) + 1
        Case DIR_DOWN_RIGHT
            X = GetPlayerX(MyIndex) + 1
            Y = GetPlayerY(MyIndex) + 1
    End Select
  
    ' Check to see if the map tile is blocked or not
    If Map.Tile(X, Y).Type = TILE_TYPE_BLOCKED Then
        CheckDirection = True
        Exit Function
    End If
                              
    ' Check to see if the key door is open or not
    If Map.Tile(X, Y).Type = TILE_TYPE_KEY Then
        ' This actually checks if its open or not
        If TempTile(X, Y).DoorOpen = NO Then
            CheckDirection = True
            Exit Function
        End If
    End If
  
    ' Check to see if a player is already on that tile
    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
                        CheckDirection = True
                        Exit Function
                    End If
                End If
            End If
        End If
    Next i

    ' Check to see if a npc is already on that tile
    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
                    CheckDirection = True
                    Exit Function
                End If
            End If
        End If
    Next i
    
End Function
Next find this
Code:
Sub SetPlayerY(ByVal Index As Long, ByVal Y As Long)
    Player(Index).Y = Y
End Sub
Below that whole sub add
Code:
Sub SetPlayerXY(ByVal Index As Long, ByVal X As Long, ByVal Y As Long)
    Player(Index).X = X
    Player(Index).Y = Y
End Sub

Next find
Code:
Sub CheckMovement()
Replace the sub with
Code:
Sub CheckMovement()
    If IsTryingToMove Then
        If CanMove Then
            ' Check if player has the shift key down for running
            If ShiftDown Then
                Player(MyIndex).Moving = MOVING_RUNNING
            Else
                Player(MyIndex).Moving = MOVING_WALKING
            End If
        
            Select Case GetPlayerDir(MyIndex)
                Case DIR_UP
                    Call SendPlayerMove
                    Player(MyIndex).YOffset = PIC_Y
                    Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) - 1)
            
                Case DIR_DOWN
                    Call SendPlayerMove
                    Player(MyIndex).YOffset = PIC_Y * -1
                    Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) + 1)
            
                Case DIR_LEFT
                    Call SendPlayerMove
                    Player(MyIndex).XOffset = PIC_X
                    Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) - 1)
            
                Case DIR_RIGHT
                    Call SendPlayerMove
                    Player(MyIndex).XOffset = PIC_X * -1
                    Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) + 1)
                    
                Case DIR_UP_LEFT
                    Call SendPlayerMove
                    Player(MyIndex).XOffset = PIC_X
                    Player(MyIndex).YOffset = PIC_Y
                    Call SetPlayerXY(MyIndex, GetPlayerX(MyIndex) - 1, GetPlayerY(MyIndex) - 1)
                    
                Case DIR_UP_RIGHT
                    Call SendPlayerMove
                    Player(MyIndex).XOffset = PIC_X * -1
                    Player(MyIndex).YOffset = PIC_Y
                    Call SetPlayerXY(MyIndex, GetPlayerX(MyIndex) + 1, GetPlayerY(MyIndex) - 1)
                    
                Case DIR_DOWN_LEFT
                    Call SendPlayerMove
                    Player(MyIndex).XOffset = PIC_X
                    Player(MyIndex).YOffset = PIC_Y * -1
                    Call SetPlayerXY(MyIndex, GetPlayerX(MyIndex) - 1, GetPlayerY(MyIndex) + 1)
                    
                Case DIR_DOWN_RIGHT
                    Call SendPlayerMove
                    Player(MyIndex).XOffset = PIC_X * -1
                    Player(MyIndex).YOffset = PIC_Y * -1
                    Call SetPlayerXY(MyIndex, GetPlayerX(MyIndex) + 1, GetPlayerY(MyIndex) + 1)
            End Select
        
            ' Gotta check
            If Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Type = TILE_TYPE_WARP Then
                GettingMap = True
            End If
        End If
    End If
End Sub
Next find
Code:
Sub HandlePlayerData(ByRef Parse() As String)
Replace the sub with
Code:
Sub HandlePlayerData(ByRef Parse() As String)
Dim i As Long

     i = CLng(Parse(1))
    
     Call SetPlayerName(i, Parse(2))
     Call SetPlayerSprite(i, CLng(Parse(3)))
     Call SetPlayerMap(i, CLng(Parse(4)))
     Call SetPlayerX(i, CLng(Parse(5)))
     Call SetPlayerY(i, CLng(Parse(6)))
     Call SetPlayerDir(i, CLng(Parse(7)))
     Call SetPlayerAccess(i, CLng(Parse(8)))
     Call SetPlayerPK(i, CLng(Parse(9)))
    
     ' Check if the player is the client player, and if so reset directions
     If i = MyIndex Then
         DirUp = False
         DirDown = False
         DirLeft = False
         DirRight = False
         DirUpLeft = False
         DirUpRight = False
         DirDownLeft = False
         DirDownRight = False
     End If
    
     ' Make sure they aren't walking
     Player(i).Moving = 0
     Player(i).XOffset = 0
     Player(i).YOffset = 0
End Sub
Next find these(in GameLoop)
Code:
' Check to make sure they aren't trying to auto do anything
        If GetAsyncKeyState(VK_UP) >= 0 Then
            If DirUp = True Then
                DirUp = False
            End If
        End If
            
        If GetAsyncKeyState(VK_DOWN) >= 0 Then
            If DirDown = True Then
                DirDown = False
            End If
        End If
        
        If GetAsyncKeyState(VK_LEFT) >= 0 Then
            If DirLeft = True Then
                DirLeft = False
            End If
        End If
        
        If GetAsyncKeyState(VK_RIGHT) >= 0 Then
            If DirRight = True Then
                DirRight = False
            End If
        End If

Below those add
Code:
If GetAsyncKeyState(VK_UP) >= 0 And GetAsyncKeyState(VK_LEFT) >= 0 Then
            If DirUpLeft = True Then
                DirUpLeft = False
            End If
        End If
        
        If GetAsyncKeyState(VK_UP) >= 0 And GetAsyncKeyState(VK_RIGHT) >= 0 Then
            If DirUpRight = True Then
                DirUpRight = False
            End If
        End If
        
        If GetAsyncKeyState(VK_DOWN) >= 0 And GetAsyncKeyState(VK_LEFT) >= 0 Then
            If DirDownLeft = True Then
                DirDownLeft = False
            End If
        End If
        
        If GetAsyncKeyState(VK_DOWN) >= 0 And GetAsyncKeyState(VK_RIGHT) >= 0 Then
            If DirDownRight = True Then
                DirDownRight = False
            End If
        End If
Next find
Code:
Sub CheckInput(ByVal KeyState As Byte, ByVal KeyCode As Integer, ByVal Shift As Integer)
Replace the sub with
Code:
Sub CheckInput(ByVal KeyState As Byte, ByVal KeyCode As Integer, ByVal Shift As Integer)
    If Not GettingMap Then
        If KeyState = 1 Then
            If KeyCode = vbKeyReturn Then
                Call CheckMapGetItem
            End If
            If KeyCode = vbKeyControl Then
                ControlDown = True
            End If
            If KeyCode = vbKeyUp Then
                DirUp = True
                DirDown = False
                DirLeft = False
                DirRight = False
                DirUpLeft = False
                DirUpRight = False
                DirDownLeft = False
                DirDownRight = False
            End If
            If KeyCode = vbKeyDown Then
                DirUp = False
                DirDown = True
                DirLeft = False
                DirRight = False
                DirUpLeft = False
                DirUpRight = False
                DirDownLeft = False
                DirDownRight = False
            End If
            If KeyCode = vbKeyLeft Then
                DirUp = False
                DirDown = False
                DirLeft = True
                DirRight = False
                DirUpLeft = False
                DirUpRight = False
                DirDownLeft = False
                DirDownRight = False
            End If
            If KeyCode = vbKeyRight Then
                DirUp = False
                DirDown = False
                DirLeft = False
                DirRight = True
                DirUpLeft = False
                DirUpRight = False
                DirDownLeft = False
                DirDownRight = False
            End If
            If GetAsyncKeyState(vbKeyUp) And GetAsyncKeyState(vbKeyLeft) Then
                DirUp = False
                DirDown = False
                DirLeft = False
                DirRight = False
                DirUpLeft = True
                DirUpRight = False
                DirDownLeft = False
                DirDownRight = False
            Else
                DirUpLeft = False
            End If
            If GetAsyncKeyState(vbKeyUp) And GetAsyncKeyState(vbKeyRight) Then
                DirUp = False
                DirDown = False
                DirLeft = False
                DirRight = False
                DirUpLeft = False
                DirUpRight = True
                DirDownLeft = False
                DirDownRight = False
            Else
                DirUpRight = False
            End If
            If GetAsyncKeyState(vbKeyDown) And GetAsyncKeyState(vbKeyLeft) Then
                DirUp = False
                DirDown = False
                DirLeft = False
                DirRight = False
                DirUpLeft = False
                DirUpRight = False
                DirDownLeft = True
                DirDownRight = False
            Else
                DirDownLeft = False
            End If
            If GetAsyncKeyState(vbKeyDown) And GetAsyncKeyState(vbKeyRight) Then
                DirUp = False
                DirDown = False
                DirLeft = False
                DirRight = False
                DirUpLeft = False
                DirUpRight = False
                DirDownLeft = False
                DirDownRight = True
            Else
                DirDownRight = False
            End If
            If KeyCode = vbKeyShift Then
                ShiftDown = True
            End If
        Else
            If KeyCode = vbKeyUp Then DirUp = False
            If KeyCode = vbKeyDown Then DirDown = False
            If KeyCode = vbKeyLeft Then DirLeft = False
            If KeyCode = vbKeyRight Then DirRight = False
            'If KeyCode = vbKeyUp And vbKeyLeft Then DirUpLeft = False
            'If KeyCode = vbKeyUp And vbKeyRight Then DirUpRight = False
            'If KeyCode = vbKeyDown And vbKeyLeft Then DirDownLeft = False
            'If KeyCode = vbKeyDown And vbKeyRight Then DirDownRight = False
            If KeyCode = vbKeyShift Then ShiftDown = False
            If KeyCode = vbKeyControl Then ControlDown = False
        End If
    End If
End Sub
Next find
Code:
Function IsTryingToMove() As Boolean
Replace the sub with
Code:
Function IsTryingToMove() As Boolean
    If DirUp Or DirDown Or DirLeft Or DirRight Or DirUpLeft Or DirUpRight Or DirDownLeft Or DirDownRight Then
        IsTryingToMove = True
    Else
        IsTryingToMove = False
    End If
End Function
[/spoiler]

Server Side
- Tired yet!? -

[spoiler]Find
Code:
Public Const DIR_RIGHT As Byte = 3
Below that add
Code:
Public Const DIR_UP_LEFT As Byte = 4
Public Const DIR_UP_RIGHT As Byte = 5
Public Const DIR_DOWN_LEFT As Byte = 6
Public Const DIR_DOWN_RIGHT As Byte = 7
Next find
Code:
Function CanAttackPlayer(ByVal Attacker As Long, ByVal Victim As Long) As Boolean
Replace the sub with
Code:
Function CanAttackPlayer(ByVal Attacker As Long, ByVal Victim As Long) As Boolean
        
    ' Check for subscript out of range
    If Not IsPlaying(Victim) Then
        Exit Function
    End If
            

    ' Check attack timer
    If GetTickCount > TempPlayer(Attacker).AttackTimer + 1000 Then
        Exit Function
    End If
            
    ' Check if at same coordinates
    Select Case GetPlayerDir(Attacker)
        Case DIR_UP
            If (GetPlayerY(Victim) + 1 = GetPlayerY(Attacker)) Then
                If (GetPlayerX(Victim) = GetPlayerX(Attacker)) Then
                    CanAttackPlayer = True
                End If
            End If
        
        Case DIR_DOWN
            If (GetPlayerY(Victim) - 1 = GetPlayerY(Attacker)) Then
                If (GetPlayerX(Victim) = GetPlayerX(Attacker)) Then
                    CanAttackPlayer = True
                End If
            End If

        Case DIR_LEFT
            If (GetPlayerY(Victim) = GetPlayerY(Attacker)) Then
                If (GetPlayerX(Victim) + 1 = GetPlayerX(Attacker)) Then
                    CanAttackPlayer = True
                End If
            End If
        
        Case DIR_RIGHT
            If (GetPlayerY(Victim) = GetPlayerY(Attacker)) Then
                If (GetPlayerX(Victim) - 1 = GetPlayerX(Attacker)) Then
                    CanAttackPlayer = True
                End If
            End If
        
        Case DIR_UP_LEFT
            If (GetPlayerY(Victim) + 1 = GetPlayerY(Attacker)) Then
                If (GetPlayerX(Victim) + 1 = GetPlayerX(Attacker)) Then
                    CanAttackPlayer = True
                End If
            End If
            
        Case DIR_UP_RIGHT
            If (GetPlayerY(Victim) + 1 = GetPlayerY(Attacker)) Then
                If (GetPlayerX(Victim) - 1 = GetPlayerX(Attacker)) Then
                    CanAttackPlayer = True
                End If
            End If
            
        Case DIR_DOWN_LEFT
            If (GetPlayerY(Victim) - 1 = GetPlayerY(Attacker)) Then
                If (GetPlayerX(Victim) + 1 = GetPlayerX(Attacker)) Then
                    CanAttackPlayer = True
                End If
            End If
            
        Case DIR_DOWN_RIGHT
            If (GetPlayerY(Victim) - 1 = GetPlayerY(Attacker)) Then
                If (GetPlayerX(Victim) - 1 = GetPlayerX(Attacker)) Then
                    CanAttackPlayer = True
                End If
            End If
    End Select
    
    If Not CanAttackPlayer Then
        Exit Function
    End If

    ' Make sure they have more then 0 hp
    If GetPlayerVital(Victim, Vitals.HP)  2 Then
        Exit Sub
    End If
    
    Call SetPlayerDir(Index, Dir)
    
    Moved = NO
    
    Select Case Dir
        Case DIR_UP
            ' Check to make sure not outside of boundries
            If GetPlayerY(Index) > 0 Then
                ' Check to make sure that the tile is walkable
                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type  TILE_TYPE_BLOCKED Then
                    ' Check to see if the tile is a key and if it is check if its opened
                    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type  TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index), GetPlayerY(Index) - 1) = YES) Then
                        Call SetPlayerY(Index, GetPlayerY(Index) - 1)
                        
                        Packet = SPlayerMove & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & Movement & END_CHAR
                        Call SendDataToMapBut(Index, GetPlayerMap(Index), Packet)
                        Moved = YES
                    End If
                End If
            Else
                ' Check to see if we can move them to the another map
                If Map(GetPlayerMap(Index)).Up > 0 Then
                    Call PlayerWarp(Index, Map(GetPlayerMap(Index)).Up, GetPlayerX(Index), MAX_MAPY)
                    Moved = YES
                End If
            End If
                    
        Case DIR_DOWN
            ' Check to make sure not outside of boundries
            If GetPlayerY(Index) < MAX_MAPY Then
                ' Check to make sure that the tile is walkable
                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) + 1).Type  TILE_TYPE_BLOCKED Then
                    ' Check to see if the tile is a key and if it is check if its opened
                    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) + 1).Type  TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) + 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index), GetPlayerY(Index) + 1) = YES) Then
                        Call SetPlayerY(Index, GetPlayerY(Index) + 1)
                        
                        Packet = SPlayerMove & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & Movement & END_CHAR
                        Call SendDataToMapBut(Index, GetPlayerMap(Index), Packet)
                        Moved = YES
                    End If
                End If
            Else
                ' Check to see if we can move them to the another map
                If Map(GetPlayerMap(Index)).Down > 0 Then
                    Call PlayerWarp(Index, Map(GetPlayerMap(Index)).Down, GetPlayerX(Index), 0)
                    Moved = YES
                End If
            End If
        
        Case DIR_LEFT
            ' Check to make sure not outside of boundries
            If GetPlayerX(Index) > 0 Then
                ' Check to make sure that the tile is walkable
                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) - 1, GetPlayerY(Index)).Type  TILE_TYPE_BLOCKED Then
                    ' Check to see if the tile is a key and if it is check if its opened
                    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) - 1, GetPlayerY(Index)).Type  TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) - 1, GetPlayerY(Index)).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index) - 1, GetPlayerY(Index)) = YES) Then
                        Call SetPlayerX(Index, GetPlayerX(Index) - 1)
                        
                        Packet = SPlayerMove & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & Movement & END_CHAR
                        Call SendDataToMapBut(Index, GetPlayerMap(Index), Packet)
                        Moved = YES
                    End If
                End If
            Else
                ' Check to see if we can move them to the another map
                If Map(GetPlayerMap(Index)).Left > 0 Then
                    Call PlayerWarp(Index, Map(GetPlayerMap(Index)).Left, MAX_MAPX, GetPlayerY(Index))
                    Moved = YES
                End If
            End If
        
        Case DIR_RIGHT
            ' Check to make sure not outside of boundries
            If GetPlayerX(Index) < MAX_MAPX Then
                ' Check to make sure that the tile is walkable
                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) + 1, GetPlayerY(Index)).Type  TILE_TYPE_BLOCKED Then
                    ' Check to see if the tile is a key and if it is check if its opened
                    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) + 1, GetPlayerY(Index)).Type  TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) + 1, GetPlayerY(Index)).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index) + 1, GetPlayerY(Index)) = YES) Then
                        Call SetPlayerX(Index, GetPlayerX(Index) + 1)
                        
                        Packet = SPlayerMove & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & Movement & END_CHAR
                        Call SendDataToMapBut(Index, GetPlayerMap(Index), Packet)
                        Moved = YES
                    End If
                End If
            Else
                ' Check to see if we can move them to the another map
                If Map(GetPlayerMap(Index)).Right > 0 Then
                    Call PlayerWarp(Index, Map(GetPlayerMap(Index)).Right, 0, GetPlayerY(Index))
                    Moved = YES
                End If
            End If
            
        Case DIR_UP_LEFT
            ' Check to make sure not outside of boundries
            If GetPlayerY(Index) > 0 And GetPlayerX(Index) > 0 Then
                ' Check to make sure that the tile is walkable
                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) - 1, GetPlayerY(Index) - 1).Type  TILE_TYPE_BLOCKED Then
                    ' Check to see if the tile is a key and if it is check if its opened
                    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) - 1, GetPlayerY(Index) - 1).Type  TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) - 1, GetPlayerY(Index) - 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index) - 1, GetPlayerY(Index) - 1) = YES) Then
                        Call SetPlayerXY(Index, GetPlayerX(Index) - 1, GetPlayerY(Index) - 1)
                        
                        Packet = SPlayerMove & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & Movement & END_CHAR
                        Call SendDataToMapBut(Index, GetPlayerMap(Index), Packet)
                        Moved = YES
                    End If
                End If
            Else
                ' Check to see if we can move them to the another map
                If Map(GetPlayerMap(Index)).Up > 0 Then
                    Call PlayerWarp(Index, Map(GetPlayerMap(Index)).Up, GetPlayerX(Index), MAX_MAPY)
                    Moved = YES
                End If
            End If
            
        Case DIR_UP_RIGHT
            ' Check to make sure not outside of boundries
            If GetPlayerY(Index) > 0 And GetPlayerX(Index) < MAX_MAPX Then
                ' Check to make sure that the tile is walkable
                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) + 1, GetPlayerY(Index) - 1).Type  TILE_TYPE_BLOCKED Then
                    ' Check to see if the tile is a key and if it is check if its opened
                    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) + 1, GetPlayerY(Index) - 1).Type  TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) + 1, GetPlayerY(Index) - 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index) + 1, GetPlayerY(Index) - 1) = YES) Then
                        Call SetPlayerXY(Index, GetPlayerX(Index) + 1, GetPlayerY(Index) - 1)
                        
                        Packet = SPlayerMove & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & Movement & END_CHAR
                        Call SendDataToMapBut(Index, GetPlayerMap(Index), Packet)
                        Moved = YES
                    End If
                End If
            Else
                ' Check to see if we can move them to the another map
                If Map(GetPlayerMap(Index)).Up > 0 Then
                    Call PlayerWarp(Index, Map(GetPlayerMap(Index)).Up, GetPlayerX(Index), MAX_MAPY)
                    Moved = YES
                End If
            End If
            
        Case DIR_DOWN_LEFT
            ' Check to make sure not outside of boundries
            If GetPlayerY(Index) < MAX_MAPY And GetPlayerX(Index) > 0 Then
                ' Check to make sure that the tile is walkable
                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) - 1, GetPlayerY(Index) + 1).Type  TILE_TYPE_BLOCKED Then
                    ' Check to see if the tile is a key and if it is check if its opened
                    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) - 1, GetPlayerY(Index) + 1).Type  TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) - 1, GetPlayerY(Index) + 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index) - 1, GetPlayerY(Index) + 1) = YES) Then
                        Call SetPlayerXY(Index, GetPlayerX(Index) - 1, GetPlayerY(Index) + 1)
                        
                        Packet = SPlayerMove & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & Movement & END_CHAR
                        Call SendDataToMapBut(Index, GetPlayerMap(Index), Packet)
                        Moved = YES
                    End If
                End If
            Else
                ' Check to see if we can move them to the another map
                If Map(GetPlayerMap(Index)).Down > 0 Then
                    Call PlayerWarp(Index, Map(GetPlayerMap(Index)).Down, GetPlayerX(Index), 0)
                    Moved = YES
                End If
            End If
            
        Case DIR_DOWN_RIGHT
            ' Check to make sure not outside of boundries
            If GetPlayerY(Index) < MAX_MAPY And GetPlayerX(Index) < MAX_MAPX Then
                ' Check to make sure that the tile is walkable
                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) + 1, GetPlayerY(Index) + 1).Type  TILE_TYPE_BLOCKED Then
                    ' Check to see if the tile is a key and if it is check if its opened
                    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) + 1, GetPlayerY(Index) + 1).Type  TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) + 1, GetPlayerY(Index) + 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index) + 1, GetPlayerY(Index) + 1) = YES) Then
                        Call SetPlayerXY(Index, GetPlayerX(Index) + 1, GetPlayerY(Index) + 1)
                        
                        Packet = SPlayerMove & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & Movement & END_CHAR
                        Call SendDataToMapBut(Index, GetPlayerMap(Index), Packet)
                        Moved = YES
                    End If
                End If
            Else
                ' Check to see if we can move them to the another map
                If Map(GetPlayerMap(Index)).Down > 0 Then
                    Call PlayerWarp(Index, Map(GetPlayerMap(Index)).Down, GetPlayerX(Index), 0)
                    Moved = YES
                End If
            End If
    End Select
        
    ' Check to see if the tile is a warp tile, and if so warp them
    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type = TILE_TYPE_WARP Then
        MapNum = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data1
        x = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data2
        y = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data3
                        
        Call PlayerWarp(Index, MapNum, x, y)
        Moved = YES
    End If
    
    ' Check for key trigger open
    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type = TILE_TYPE_KEYOPEN Then
        x = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data1
        y = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data2
        
        If Map(GetPlayerMap(Index)).Tile(x, y).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(x, y) = NO Then
            TempTile(GetPlayerMap(Index)).DoorOpen(x, y) = YES
            TempTile(GetPlayerMap(Index)).DoorTimer = GetTickCount
                            
            Call SendDataToMap(GetPlayerMap(Index), "mapkey" & SEP_CHAR & x & SEP_CHAR & y & SEP_CHAR & 1 & END_CHAR)
            Call MapMsg(GetPlayerMap(Index), "A door has been unlocked.", White)
        End If
    End If
    
    ' They tried to hack
    If Moved = NO Then
        Call HackingAttempt(Index, "Position Modification")
    End If
End Sub
Next Find
Code:
Function CanNpcMove(ByVal MapNum As Long, ByVal MapNpcNum As Long, ByVal Dir As Byte) As Boolean
Replace the sub with
Code:
Function CanNpcMove(ByVal MapNum As Long, ByVal MapNpcNum As Long, ByVal Dir As Byte) As Boolean
Dim i As Long, n As Long
Dim x As Long, y As Long

    CanNpcMove = False
    
    ' Check for subscript out of range
    If MapNum  MAX_MAPS Or MapNpcNum  MAX_MAP_NPCS Or Dir < DIR_UP Or Dir > DIR_DOWN_RIGHT Then
        Exit Function
    End If
    
    x = MapNpc(MapNum, MapNpcNum).x
    y = MapNpc(MapNum, MapNpcNum).y
    
    CanNpcMove = True
    
    Select Case Dir
        Case DIR_UP
            ' Check to make sure not outside of boundries
            If y > 0 Then
                n = Map(MapNum).Tile(x, y - 1).Type
                
                ' Check to make sure that the tile is walkable
                If n  TILE_TYPE_WALKABLE And n  TILE_TYPE_ITEM Then
                    CanNpcMove = False
                    Exit Function
                End If
                
                ' Check to make sure that there is not a player in the way
                For i = 1 To MAX_PLAYERS
                    If IsPlaying(i) Then
                        If (GetPlayerMap(i) = MapNum) And (GetPlayerX(i) = MapNpc(MapNum, MapNpcNum).x) And (GetPlayerY(i) = MapNpc(MapNum, MapNpcNum).y - 1) Then
                            CanNpcMove = False
                            Exit Function
                        End If
                    End If
                Next i
                
                ' Check to make sure that there is not another npc in the way
                For i = 1 To MAX_MAP_NPCS
                    If (i  MapNpcNum) And (MapNpc(MapNum, i).Num > 0) And (MapNpc(MapNum, i).x = MapNpc(MapNum, MapNpcNum).x) And (MapNpc(MapNum, i).y = MapNpc(MapNum, MapNpcNum).y - 1) Then
                        CanNpcMove = False
                        Exit Function
                    End If
                Next i
            Else
                CanNpcMove = False
            End If
                
        Case DIR_DOWN
            ' Check to make sure not outside of boundries
            If y < MAX_MAPY Then
                n = Map(MapNum).Tile(x, y + 1).Type
                
                ' Check to make sure that the tile is walkable
                If n  TILE_TYPE_WALKABLE And n  TILE_TYPE_ITEM Then
                    CanNpcMove = False
                    Exit Function
                End If
                
                ' Check to make sure that there is not a player in the way
                For i = 1 To MAX_PLAYERS
                    If IsPlaying(i) Then
                        If (GetPlayerMap(i) = MapNum) And (GetPlayerX(i) = MapNpc(MapNum, MapNpcNum).x) And (GetPlayerY(i) = MapNpc(MapNum, MapNpcNum).y + 1) Then
                            CanNpcMove = False
                            Exit Function
                        End If
                    End If
                Next i
                
                ' Check to make sure that there is not another npc in the way
                For i = 1 To MAX_MAP_NPCS
                    If (i  MapNpcNum) And (MapNpc(MapNum, i).Num > 0) And (MapNpc(MapNum, i).x = MapNpc(MapNum, MapNpcNum).x) And (MapNpc(MapNum, i).y = MapNpc(MapNum, MapNpcNum).y + 1) Then
                        CanNpcMove = False
                        Exit Function
                    End If
                Next i
            Else
                CanNpcMove = False
            End If
                
        Case DIR_LEFT
            ' Check to make sure not outside of boundries
            If x > 0 Then
                n = Map(MapNum).Tile(x - 1, y).Type
                
                ' Check to make sure that the tile is walkable
                If n  TILE_TYPE_WALKABLE And n  TILE_TYPE_ITEM Then
                    CanNpcMove = False
                    Exit Function
                End If
                
                ' Check to make sure that there is not a player in the way
                For i = 1 To MAX_PLAYERS
                    If IsPlaying(i) Then
                        If (GetPlayerMap(i) = MapNum) And (GetPlayerX(i) = MapNpc(MapNum, MapNpcNum).x - 1) And (GetPlayerY(i) = MapNpc(MapNum, MapNpcNum).y) Then
                            CanNpcMove = False
                            Exit Function
                        End If
                    End If
                Next i
                
                ' Check to make sure that there is not another npc in the way
                For i = 1 To MAX_MAP_NPCS
                    If (i  MapNpcNum) And (MapNpc(MapNum, i).Num > 0) And (MapNpc(MapNum, i).x = MapNpc(MapNum, MapNpcNum).x - 1) And (MapNpc(MapNum, i).y = MapNpc(MapNum, MapNpcNum).y) Then
                        CanNpcMove = False
                        Exit Function
                    End If
                Next i
            Else
                CanNpcMove = False
            End If
                
        Case DIR_RIGHT
            ' Check to make sure not outside of boundries
            If x < MAX_MAPX Then
                n = Map(MapNum).Tile(x + 1, y).Type
                
                ' Check to make sure that the tile is walkable
                If n  TILE_TYPE_WALKABLE And n  TILE_TYPE_ITEM Then
                    CanNpcMove = False
                    Exit Function
                End If
                
                ' Check to make sure that there is not a player in the way
                For i = 1 To MAX_PLAYERS
                    If IsPlaying(i) Then
                        If (GetPlayerMap(i) = MapNum) And (GetPlayerX(i) = MapNpc(MapNum, MapNpcNum).x + 1) And (GetPlayerY(i) = MapNpc(MapNum, MapNpcNum).y) Then
                            CanNpcMove = False
                            Exit Function
                        End If
                    End If
                Next i
                
                ' Check to make sure that there is not another npc in the way
                For i = 1 To MAX_MAP_NPCS
                    If (i  MapNpcNum) And (MapNpc(MapNum, i).Num > 0) And (MapNpc(MapNum, i).x = MapNpc(MapNum, MapNpcNum).x + 1) And (MapNpc(MapNum, i).y = MapNpc(MapNum, MapNpcNum).y) Then
                        CanNpcMove = False
                        Exit Function
                    End If
                Next i
            Else
                CanNpcMove = False
            End If
            
        Case DIR_UP_LEFT
            ' Check to make sure not outside of boundries
            If y > 0 And x > 0 Then
                n = Map(MapNum).Tile(x - 1, y - 1).Type
                
                ' Check to make sure that the tile is walkable
                If n  TILE_TYPE_WALKABLE And n  TILE_TYPE_ITEM Then
                    CanNpcMove = False
                    Exit Function
                End If
                
                ' Check to make sure that there is not a player in the way
                For i = 1 To MAX_PLAYERS
                    If IsPlaying(i) Then
                        If (GetPlayerMap(i) = MapNum) And (GetPlayerX(i) = MapNpc(MapNum, MapNpcNum).x - 1) And (GetPlayerY(i) = MapNpc(MapNum, MapNpcNum).y - 1) Then
                            CanNpcMove = False
                            Exit Function
                        End If
                    End If
                Next i
                
                ' Check to make sure that there is not another npc in the way
                For i = 1 To MAX_MAP_NPCS
                    If (i  MapNpcNum) And (MapNpc(MapNum, i).Num > 0) And (MapNpc(MapNum, i).x = MapNpc(MapNum, MapNpcNum).x - 1) And (MapNpc(MapNum, i).y = MapNpc(MapNum, MapNpcNum).y - 1) Then
                        CanNpcMove = False
                        Exit Function
                    End If
                Next i
            Else
                CanNpcMove = False
            End If
            
        Case DIR_UP_RIGHT
            ' Check to make sure not outside of boundries
            If y > 0 And x < MAX_MAPX Then
                n = Map(MapNum).Tile(x + 1, y - 1).Type
                
                ' Check to make sure that the tile is walkable
                If n  TILE_TYPE_WALKABLE And n  TILE_TYPE_ITEM Then
                    CanNpcMove = False
                    Exit Function
                End If
                
                ' Check to make sure that there is not a player in the way
                For i = 1 To MAX_PLAYERS
                    If IsPlaying(i) Then
                        If (GetPlayerMap(i) = MapNum) And (GetPlayerX(i) = MapNpc(MapNum, MapNpcNum).x + 1) And (GetPlayerY(i) = MapNpc(MapNum, MapNpcNum).y - 1) Then
                            CanNpcMove = False
                            Exit Function
                        End If
                    End If
                Next i
                
                ' Check to make sure that there is not another npc in the way
                For i = 1 To MAX_MAP_NPCS
                    If (i  MapNpcNum) And (MapNpc(MapNum, i).Num > 0) And (MapNpc(MapNum, i).x = MapNpc(MapNum, MapNpcNum).x + 1) And (MapNpc(MapNum, i).y = MapNpc(MapNum, MapNpcNum).y - 1) Then
                        CanNpcMove = False
                        Exit Function
                    End If
                Next i
            Else
                CanNpcMove = False
            End If
            
        Case DIR_DOWN_LEFT
            ' Check to make sure not outside of boundries
            If y < MAX_MAPY And x > 0 Then
                n = Map(MapNum).Tile(x - 1, y + 1).Type
                
                ' Check to make sure that the tile is walkable
                If n  TILE_TYPE_WALKABLE And n  TILE_TYPE_ITEM Then
                    CanNpcMove = False
                    Exit Function
                End If
                
                ' Check to make sure that there is not a player in the way
                For i = 1 To MAX_PLAYERS
                    If IsPlaying(i) Then
                        If (GetPlayerMap(i) = MapNum) And (GetPlayerX(i) = MapNpc(MapNum, MapNpcNum).x - 1) And (GetPlayerY(i) = MapNpc(MapNum, MapNpcNum).y + 1) Then
                            CanNpcMove = False
                            Exit Function
                        End If
                    End If
                Next i
                
                ' Check to make sure that there is not another npc in the way
                For i = 1 To MAX_MAP_NPCS
                    If (i  MapNpcNum) And (MapNpc(MapNum, i).Num > 0) And (MapNpc(MapNum, i).x = MapNpc(MapNum, MapNpcNum).x - 1) And (MapNpc(MapNum, i).y = MapNpc(MapNum, MapNpcNum).y + 1) Then
                        CanNpcMove = False
                        Exit Function
                    End If
                Next i
            Else
                CanNpcMove = False
            End If
            
        Case DIR_DOWN_RIGHT
            ' Check to make sure not outside of boundries
            If y < MAX_MAPY And x < MAX_MAPX Then
                n = Map(MapNum).Tile(x + 1, y + 1).Type
                
                ' Check to make sure that the tile is walkable
                If n  TILE_TYPE_WALKABLE And n  TILE_TYPE_ITEM Then
                    CanNpcMove = False
                    Exit Function
                End If
                
                ' Check to make sure that there is not a player in the way
                For i = 1 To MAX_PLAYERS
                    If IsPlaying(i) Then
                        If (GetPlayerMap(i) = MapNum) And (GetPlayerX(i) = MapNpc(MapNum, MapNpcNum).x + 1) And (GetPlayerY(i) = MapNpc(MapNum, MapNpcNum).y + 1) Then
                            CanNpcMove = False
                            Exit Function
                        End If
                    End If
                Next i
                
                ' Check to make sure that there is not another npc in the way
                For i = 1 To MAX_MAP_NPCS
                    If (i  MapNpcNum) And (MapNpc(MapNum, i).Num > 0) And (MapNpc(MapNum, i).x = MapNpc(MapNum, MapNpcNum).x + 1) And (MapNpc(MapNum, i).y = MapNpc(MapNum, MapNpcNum).y + 1) Then
                        CanNpcMove = False
                        Exit Function
                    End If
                Next i
            Else
                CanNpcMove = False
            End If
    End Select
End Function
Next Find
Code:
Sub NpcMove(ByVal MapNum As Long, ByVal MapNpcNum As Long, ByVal Dir As Long, ByVal Movement As Long)
Replace sub with[code]Sub NpcMove(ByVal MapNum As Long, ByVal MapNpcNum As Long, ByVal Dir As Long, ByVal Movement As Long)
Dim Packet As String

' Check for subscript out of range
If MapNum MAX_MAPS Or MapNpcNum MAX_MAP_NPCS Or Dir < DIR_UP Or Dir > DIR_DOWN_RIGHT Or Movement < 1 Or Movement > 2 Then
Exit Sub
End If

MapNpc(MapNum, MapNpcNum).Dir = Dir

Select Case Dir
Case DIR_UP
MapNpc(MapNum, MapNpcNum).y = MapNpc(MapNum, MapNpcNum).y - 1
Packet = SNpcMove & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNpc(MapNum, MapNpcNum).x & SEP_CHAR & MapNpc(MapNum, MapNpcNum).y & SEP_CHAR & MapNpc(MapNum, MapNpcNum).Dir & SEP_CHAR & Movement & END_CHAR
Call SendDataToMap(MapNum, Packet)

Case DIR_DOWN
MapNpc(MapNum, MapNpcNum).y = MapNpc(MapNum, MapNpcNum).y + 1
Packet = SNpcMove & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNpc(MapNum, MapNpcNum).x & SEP_CHAR & MapNpc(MapNum, MapNpcNum).y & SEP_CHAR & MapNpc(MapNum, MapNpcNum).Dir & SEP_CHAR & Movement & END_CHAR
Call SendDataToMap(MapNum, Packet)

Case DIR_LEFT
MapNpc(MapNum, MapNpcNum).x = MapNpc(MapNum, MapNpcNum).x - 1
Packet = SNpcMove & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNpc(MapNum, MapNpcNum).x & SEP_CHAR & MapNpc(MapNum, MapNpcNum).y & SEP_CHAR & MapNpc(MapNum, MapNpcNum).Dir & SEP_CHAR & Movement & END_CHAR
Call SendDataToMap(MapNum, Packet)

Case DIR_RIGHT
MapNpc(MapNum, MapNpcNum).x = MapNpc(MapNum, MapNpcNum).x + 1
Packet = SNpcMove & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNpc(MapNum, MapNpcNum).x & SEP_CHAR & MapNpc(MapNum, MapNpcNum).y & SEP_CHAR & MapNpc(MapNum, MapNpcNum).Dir & SEP_CHAR & Movement & END_CHAR
Call SendDataToMap(MapNum, Packet)

Case DIR_UP_LEFT
MapNpc(MapNum, MapNpcNum).x = MapNpc(MapNum, MapNpcNum).x - 1
MapNpc(MapNum, MapNpcNum).y = MapNpc(MapNum, MapNpcNum).y - 1
Packet = SNpcMove & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNpc(MapNum, MapNpcNum).x & SEP_CHAR & MapNpc(MapNum, MapNpcNum).y & SEP_CHAR & MapNpc(MapNum, MapNpcNum).Dir & SEP_CHAR & Movement & END_CHAR
Call SendDataToMap(MapNum, Packet)

Case DIR_UP_RIGHT
MapNpc(MapNum, MapNpcNum).x = MapNpc(MapNum, MapNpcNum).x + 1
MapNpc(MapNum, MapNpcNum).y = MapNpc(MapNum, MapNpcNum).y - 1
Packet = SNpcMove & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNpc(MapNum, MapNpcNum).x & SEP_CHAR & MapNpc(MapNum, MapNpcNum).y & SEP_CHAR & MapNpc(MapNum, MapNpcNum).Dir & SEP_CHAR & Movement & END_CHAR
Call SendDataToMap(MapNum, Packet)

Case DIR_DOWN_LEFT
MapNpc(MapNum, MapNpcNum).x = MapNpc(MapNum, MapNpcNum).x - 1
MapNpc(MapNum, MapNpcNum).y = MapNpc(MapNum, MapNpcNum).y + 1
Packet = SNpcMove & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNpc(MapNum, MapNpcNum).x & SEP_CHAR & MapNpc(MapNum, MapNpcNum).y & SEP_CHAR & MapNpc(MapNum, MapNpcNum).Dir & SEP_CHAR & Movement & END_CHAR
Call SendDataToMap(MapNum, Packet)

Case DIR_DOWN_RIGHT
MapNpc(MapNum, MapNpcNum).x = MapNpc(MapNum, MapNpcNum).x + 1
MapN...
Reply
#2
DFA Wrote:nice, if you don't mind, upload a blank copy of MS with this implemented so we can see it in action
thanks.

It's in the post. Look at the subtitle.
Reply
#3
I checked this out, and it's loads of fun. I really like it. Great tut.
Reply
#4
lol nope you cant

and thats good that there are always posts
Reply
#5
The sprite isnt animated walking south west and north east. And a hint to people who add this is to change the walk speed for diagonal movement.
Reply
#6
That's odd.. hmm I'll figure out what's wrong when I get home.

You downloaded the source right?
Reply
#7
TonyNooblet Wrote:That's odd.. hmm I'll figure out what's wrong when I get home.

You downloaded the source right?

Downloaded source. Doesn't seem to work. Can't move diagonally. :S

Can we have a video? Meh.
Reply
#8
Dont run the client and server. Run it from the source!

And there are a few glitches, but nothing that cant be fixed.
Reply
#9
William Wrote:Dont run the client and server. Run it from the source!

And there are a few glitches, but nothing that cant be fixed.

Oh ye, =-p. Thanks.

I notice quite a few bugs. Like you can go between 2 blocks & get stuck inside block area, diagonal through them. Animation issue. All can be fixed of course. =-p
Reply
#10
If those things are fixed, and movement is slowed down diagonal. I'm pretty sure this will be used by a lot of people.
Reply
#11
William Wrote:If those things are fixed, and movement is slowed down diagonal. I'm pretty sure this will be used by a lot of people.

Yep. I'd definately use it, since I plan to have it.
Reply
#12
Is this tutorial from es or did you make it yourself?
Reply
#13
Definitely doesn't feel like ES' diag. movement tutorial.
Reply
#14
William Wrote:Is this tutorial from es or did you make it yourself?

Made completely by me, no reference or used source.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)