Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Side Stepping Problemo..
#1
Hey guys, i was bored today so i thought i'd work on adding in sidestepping.. Now this works, but there seems to be an annoying bug and i cant seem to find a fix for it.. Now, there are two bugs..

First one is that it doesnt seem to be able to register what direction the character is facing until you press the sidestep button a second time.. Meaning that when you press the sidestep button, be it left or right, the character jumps diagonally..

Second annoying bug is that after using the sidestep a few times. Approximately 10 times. The character on screen will slide sideways until it hits the end of the map.. Now, i've seen that before, and i cannot remember what causes it.. I was thinking of maybe an overflow error somewhere, but yeah.. It doesnt pop up with any error messages..

Here is the main engine of the whole sidestepping business.. I dont think it has much to do with this, but yeah.. Like i said, i have no idea whats causing this problem.. It would be awesome if someone could give us a bit of help on this.. Cheers..

Code:
Sub PlayerSideStep(ByVal Index As Long, ByVal LeftRight As Long)
Dim i As Long

    ' Check for subscript out of range
    If IsPlaying(Index) = False Then
        Exit Sub
    End If

    ' Move player left or right
    Select Case LeftRight
        Case SIDESTEP_LEFT
            Select Case GetPlayerDir(Index)
                Case DIR_UP
                    ' Check to make sure the player isnt out of bounds
                    If GetPlayerX(Index) > 0 Then
                        ' Check for edge of map
                        If GetPlayerX(Index)  0 Then
                            ' Check for blocks
                            If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) - 1, GetPlayerY(Index)).Type  TILE_TYPE_BLOCKED Then
                                ' Check for key
                                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) - 1, GetPlayerY(Index)).Type  TILE_TYPE_KEY Then
                                    ' Check for players
                                    For i = 1 To MAX_PLAYERS
                                        If IsPlaying(i) Then
                                            If GetPlayerMap(i) = GetPlayerMap(Index) Then
                                                If (GetPlayerX(i) = GetPlayerX(Index) - 1) And (GetPlayerY(i) = GetPlayerY(Index)) Then
                                                    Exit Sub
                                                End If
                                            End If
                                        End If
                                    Next i
                                    ' Check for npcs
                                    For i = 1 To MAX_MAP_NPCS
                                        If MapNpc(GetPlayerMap(Index), i).Num > 0 Then
                                            If (MapNpc(GetPlayerMap(Index), i).x = GetPlayerX(Index) - 1) And (MapNpc(GetPlayerMap(Index), i).y = GetPlayerY(Index)) Then
                                                Exit Sub
                                            End If
                                        End If
                                    Next i
                                    ' Move player
                                    Call SetPlayerX(Index, GetPlayerX(Index) - 1)
                                End If
                            End If
                        End If
                    End If
                    ' Send new X or Y coords and send it to everyone on the map
                    Call SendPlayerXY(Index)
                    Call SendDataToMap(GetPlayerMap(Index), "PLAYERMOVE" & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & 0 & SEP_CHAR & END_CHAR)
                    Exit Sub
                Case DIR_DOWN
                    ' Check to make sure the player isnt out of bounds
                    If GetPlayerX(Index) > 0 Then
                        ' Check for edge of map
                        If GetPlayerX(Index)  MAX_MAPX Then
                            ' Check for blocks
                            If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) + 1, GetPlayerY(Index)).Type  TILE_TYPE_BLOCKED Then
                                ' Check for key and check if its open
                                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) + 1, GetPlayerY(Index)).Type  TILE_TYPE_KEY Then
                                    ' Check for players
                                    For i = 1 To MAX_PLAYERS
                                        If IsPlaying(i) Then
                                            If GetPlayerMap(i) = GetPlayerMap(Index) Then
                                                If (GetPlayerX(i) = GetPlayerX(Index) + 1) And (GetPlayerY(i) = GetPlayerY(Index)) Then
                                                    Exit Sub
                                                End If
                                            End If
                                        End If
                                    Next i
                                    ' Check for npcs
                                    For i = 1 To MAX_MAP_NPCS
                                        If MapNpc(GetPlayerMap(Index), i).Num > 0 Then
                                            If (MapNpc(GetPlayerMap(Index), i).x = GetPlayerX(Index) + 1) And (MapNpc(GetPlayerMap(Index), i).y = GetPlayerY(Index)) Then
                                                Exit Sub
                                            End If
                                        End If
                                    Next i
                                    ' Move player
                                    Call SetPlayerX(Index, GetPlayerX(Index) + 1)
                                End If
                            End If
                        End If
                    End If
                    ' Send new X or Y coords and send it to everyone on the map
                    Call SendPlayerXY(Index)
                    Call SendDataToMap(GetPlayerMap(Index), "PLAYERMOVE" & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & 0 & SEP_CHAR & END_CHAR)
                    Exit Sub
                Case DIR_LEFT
                    ' Check to make sure the player isnt out of bounds
                    If GetPlayerY(Index) > 0 Then
                        ' Check for edge of map
                        If GetPlayerY(Index)  MAX_MAPY Then
                            ' Check for blocks
                            If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) + 1).Type  TILE_TYPE_BLOCKED Then
                                ' Check for key and check if its open
                                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) + 1).Type  TILE_TYPE_KEY Then
                                    ' Check for players
                                    For i = 1 To MAX_PLAYERS
                                        If IsPlaying(i) Then
                                            If GetPlayerMap(i) = GetPlayerMap(Index) Then
                                                If (GetPlayerX(i) = GetPlayerX(Index)) And (GetPlayerY(i) = GetPlayerY(Index) + 1) Then
                                                    Exit Sub
                                                End If
                                            End If
                                        End If
                                    Next i
                                    ' Check for npcs
                                    For i = 1 To MAX_MAP_NPCS
                                        If MapNpc(GetPlayerMap(Index), i).Num > 0 Then
                                            If (MapNpc(GetPlayerMap(Index), i).x = GetPlayerX(Index)) And (MapNpc(GetPlayerMap(Index), i).y = GetPlayerY(Index) + 1) Then
                                                Exit Sub
                                            End If
                                        End If
                                    Next i
                                    ' Move player
                                    Call SetPlayerY(Index, GetPlayerY(Index) + 1)
                                End If
                            End If
                        End If
                    End If
                    ' Send new X or Y coords and send it to everyone on the map
                    Call SendPlayerXY(Index)
                    Call SendDataToMap(GetPlayerMap(Index), "PLAYERMOVE" & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & 0 & SEP_CHAR & END_CHAR)
                    Exit Sub
                Case DIR_RIGHT
                    ' Check to make sure the player isnt out of bounds
                    If GetPlayerY(Index) > 0 Then
                        ' Check for edge of map
                        If GetPlayerY(Index)  0 Then
                            ' Check for blocks
                            If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type  TILE_TYPE_BLOCKED Then
                                ' Check for key and check if its open
                                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type  TILE_TYPE_KEY Then
                                    ' Check for players
                                    For i = 1 To MAX_PLAYERS
                                        If IsPlaying(i) Then
                                            If GetPlayerMap(i) = GetPlayerMap(Index) Then
                                                If (GetPlayerX(i) = GetPlayerX(Index)) And (GetPlayerY(i) = GetPlayerY(Index) - 1) Then
                                                    Exit Sub
                                                End If
                                            End If
                                        End If
                                    Next i
                                    ' Check for npcs
                                    For i = 1 To MAX_MAP_NPCS
                                        If MapNpc(GetPlayerMap(Index), i).Num > 0 Then
                                            If (MapNpc(GetPlayerMap(Index), i).x = GetPlayerX(Index)) And (MapNpc(GetPlayerMap(Index), i).y = GetPlayerY(Index) - 1) Then
                                                Exit Sub
                                            End If
                                        End If
                                    Next i
                                    ' Move player
                                    Call SetPlayerY(Index, GetPlayerY(Index) - 1)
                                End If
                            End If
                        End If
                    End If
                    ' Send new X or Y coords and send it to everyone on the map
                    Call SendPlayerXY(Index)
                    Call SendDataToMap(GetPlayerMap(Index), "PLAYERMOVE" & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & 0 & SEP_CHAR & END_CHAR)
                    Exit Sub
            End Select
        Case SIDESTEP_RIGHT
            Select Case GetPlayerDir(Index)
                Case DIR_UP
                    ' Check to make sure the player isnt out of bounds
                    If GetPlayerX(Index) > 0 Then
                        ' Check for edge of map
                        If GetPlayerY(Index)  MAX_MAPY Then
                            ' Check for blocks
                            If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) + 1, GetPlayerY(Index)).Type  TILE_TYPE_BLOCKED Then
                                ' Check for key and check if its open
                                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) + 1, GetPlayerY(Index)).Type  TILE_TYPE_KEY Then
                                    ' Check for players
                                    For i = 1 To MAX_PLAYERS
                                        If IsPlaying(i) Then
                                            If GetPlayerMap(i) = GetPlayerMap(Index) Then
                                                If (GetPlayerX(i) = GetPlayerX(Index) + 1) And (GetPlayerY(i) = GetPlayerY(Index)) Then
                                                    Exit Sub
                                                End If
                                            End If
                                        End If
                                    Next i
                                    ' Check for npcs
                                    For i = 1 To MAX_MAP_NPCS
                                        If MapNpc(GetPlayerMap(Index), i).Num > 0 Then
                                            If (MapNpc(GetPlayerMap(Index), i).x = GetPlayerX(Index) + 1) And (MapNpc(GetPlayerMap(Index), i).y = GetPlayerY(Index)) Then
                                                Exit Sub
                                            End If
                                        End If
                                    Next i
                                    ' Move player
                                    Call SetPlayerX(Index, GetPlayerX(Index) + 1)
                                End If
                            End If
                        End If
                    End If
                    ' Send new X or Y coords and send it to everyone on the map
                    Call SendPlayerXY(Index)
                    Call SendDataToMap(GetPlayerMap(Index), "PLAYERMOVE" & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & 0 & SEP_CHAR & END_CHAR)
                    Exit Sub
                Case DIR_DOWN
                    ' Check to make sure the player isnt out of bounds
                    If GetPlayerX(Index) > 0 Then
                        ' Check for edge of map
                        If GetPlayerY(Index)  0 Then
                            ' Check for blocks
                            If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) - 1, GetPlayerY(Index)).Type  TILE_TYPE_BLOCKED Then
                                ' Check for key and check if its open
                                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) - 1, GetPlayerY(Index)).Type  TILE_TYPE_KEY Then
                                    ' Check for players
                                    For i = 1 To MAX_PLAYERS
                                        If IsPlaying(i) Then
                                            If GetPlayerMap(i) = GetPlayerMap(Index) Then
                                                If (GetPlayerX(i) = GetPlayerX(Index) - 1) And (GetPlayerY(i) = GetPlayerY(Index)) Then
                                                    Exit Sub
                                                End If
                                            End If
                                        End If
                                    Next i
                                    ' Check for npcs
                                    For i = 1 To MAX_MAP_NPCS
                                        If MapNpc(GetPlayerMap(Index), i).Num > 0 Then
                                            If (MapNpc(GetPlayerMap(Index), i).x = GetPlayerX(Index) - 1) And (MapNpc(GetPlayerMap(Index), i).y = GetPlayerY(Index)) Then
                                                Exit Sub
                                            End If
                                        End If
                                    Next i
                                    ' Move player
                                    Call SetPlayerX(Index, GetPlayerX(Index) - 1)
                                End If
                            End If
                        End If
                    End If
                    ' Send new X or Y coords and send it to everyone on the map
                    Call SendPlayerXY(Index)
                    Call SendDataToMap(GetPlayerMap(Index), "PLAYERMOVE" & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & 0 & SEP_CHAR & END_CHAR)
                    Exit Sub
                Case DIR_LEFT
                    ' Check to make sure the player isnt out of bounds
                    If GetPlayerY(Index) > 0 Then
                        ' Check for edge of map
                        If GetPlayerY(Index)  0 Then
                            ' Check for blocks
                            If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type  TILE_TYPE_BLOCKED Then
                                ' Check for key and check if its open
                                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type  TILE_TYPE_KEY Then
                                    ' Check for players
                                    For i = 1 To MAX_PLAYERS
                                        If IsPlaying(i) Then
                                            If GetPlayerMap(i) = GetPlayerMap(Index) Then
                                                If (GetPlayerX(i) = GetPlayerX(Index)) And (GetPlayerY(i) = GetPlayerY(Index) - 1) Then
                                                    Exit Sub
                                                End If
                                            End If
                                        End If
                                    Next i
                                    ' Check for npcs
                                    For i = 1 To MAX_MAP_NPCS
                                        If MapNpc(GetPlayerMap(Index), i).Num > 0 Then
                                            If (MapNpc(GetPlayerMap(Index), i).x = GetPlayerX(Index)) And (MapNpc(GetPlayerMap(Index), i).y = GetPlayerY(Index) - 1) Then
                                                Exit Sub
                                            End If
                                        End If
                                    Next i
                                    ' Move player
                                    Call SetPlayerY(Index, GetPlayerY(Index) - 1)
                                End If
                            End If
                        End If
                    End If
                    ' Send new X or Y coords and send it to everyone on the map
                    Call SendPlayerXY(Index)
                    Call SendDataToMap(GetPlayerMap(Index), "PLAYERMOVE" & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & 0 & SEP_CHAR & END_CHAR)
                    Exit Sub
                Case DIR_RIGHT
                    ' Check to make sure the player isnt out of bounds
                    If GetPlayerY(Index) > 0 Then
                        ' Check for edge of map
                        If GetPlayerY(Index)  MAX_MAPY Then
                            ' Check for blocks
                            If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) + 1).Type  TILE_TYPE_BLOCKED Then
                                ' Check for key and check if its open
                                If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) + 1).Type  TILE_TYPE_KEY Then
                                    ' Check for players
                                    For i = 1 To MAX_PLAYERS
                                        If IsPlaying(i) Then
                                            If GetPlayerMap(i) = GetPlayerMap(Index) Then
                                                If (GetPlayerX(i) = GetPlayerX(Index)) And (GetPlayerY(i) = GetPlayerY(Index) + 1) Then
                                                    Exit Sub
                                                End If
                                            End If
                                        End If
                                    Next i
                                    ' Check for npcs
                                    For i = 1 To MAX_MAP_NPCS
                                        If MapNpc(GetPlayerMap(Index), i).Num > 0 Then
                                            If (MapNpc(GetPlayerMap(Index), i).x = GetPlayerX(Index)) And (MapNpc(GetPlayerMap(Index), i).y = GetPlayerY(Index) + 1) Then
                                                Exit Sub
                                            End If
                                        End If
                                    Next i
                                    ' Move player
                                    Call SetPlayerY(Index, GetPlayerY(Index) + 1)
                                End If
                            End If
                        End If
                    End If
                    ' Send new X or Y coords and send it to everyone on the map
                    Call SendPlayerXY(Index)
                    Call SendDataToMap(GetPlayerMap(Index), "PLAYERMOVE" & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & 0 & SEP_CHAR & END_CHAR)
                    Exit Sub
            End Select
    End Select
End Sub
Reply
#2
The character on screen will slide sideways until it hits the end of the map.. Now, i've seen that before, and i cannot remember what causes it.. I was thinking of maybe an overflow error somewhere, but yeah.. It doesnt pop up with any error messages


lol pws and 3.03
Reply
#3
Huh?.... pws and 303?.... Sorry im lost.. Sad
Reply
#4
I think he meant, that those are things that happen in PW and MS 3.0.3, though I'm not sure, since, I've never had those problems, cept when I set the walking speed off.

Maybe that's your problem, have you altered the walk/run speed?
Reply
#5
Advocate Wrote:I think he meant, that those are things that happen in PW and MS 3.0.3, though I'm not sure, since, I've never had those problems, cept when I set the walking speed off.

Maybe that's your problem, have you altered the walk/run speed?

If he had, the character would crash even if he wasn't side-stepping.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)