Mirage Source http://www.miragesource.net/forums/ |
|
Basic Diagonal Movement http://www.miragesource.net/forums/viewtopic.php?f=183&t=4430 |
Page 1 of 50 |
Author: | Tony [ Tue Sep 23, 2008 2:23 am ] |
Post subject: | Basic Diagonal Movement |
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: (click to show)
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 Server Side - Tired yet!? - SPOILER: (click to show)
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) <= 0 Then Exit Function End If ' Check to make sure that they dont have access If GetPlayerAccess(Attacker) > ADMIN_MONITOR Then Call PlayerMsg(Attacker, "You cannot attack any player for thou art an admin!", BrightBlue) Exit Function End If ' Check to make sure the victim isn't an admin If GetPlayerAccess(Victim) > ADMIN_MONITOR Then Call PlayerMsg(Attacker, "You cannot attack " & GetPlayerName(Victim) & "!", BrightRed) Exit Function End If ' Make sure attacker is high enough level If GetPlayerLevel(Attacker) < 10 Then Call PlayerMsg(Attacker, "You are below level 10, you cannot attack another player yet!", BrightRed) Exit Function End If ' Make sure victim is high enough level If GetPlayerLevel(Victim) < 10 Then Call PlayerMsg(Attacker, GetPlayerName(Victim) & " is below level 10, you cannot attack this player yet!", BrightRed) Exit Function End If ' Make sure they are on the same map If Not GetPlayerMap(Attacker) = GetPlayerMap(Victim) Then Exit Function End If ' Make sure we dont attack the player if they are switching maps If TempPlayer(Victim).GettingMap = YES Then Exit Function End If ' Check if map is attackable If Not Map(GetPlayerMap(Attacker)).Moral = MAP_MORAL_NONE Or GetPlayerPK(Victim) = NO Then Call PlayerMsg(Attacker, "This is a safe zone!", BrightRed) Exit Function End If CanAttackPlayer = True End Function Next find Code: Function CanAttackNpc(ByVal Attacker As Long, ByVal MapNpcNum As Long) As Boolean Replace the sub with Code: Function CanAttackNpc(ByVal Attacker As Long, ByVal MapNpcNum As Long) As Boolean Dim MapNum As Long, NpcNum As Long Dim NpcX As Long, NpcY As Long CanAttackNpc = False ' Check for subscript out of range If IsPlaying(Attacker) = False Or MapNpcNum <= 0 Or MapNpcNum > MAX_MAP_NPCS Then Exit Function End If ' Check for subscript out of range If MapNpc(GetPlayerMap(Attacker), MapNpcNum).Num <= 0 Then Exit Function End If MapNum = GetPlayerMap(Attacker) NpcNum = MapNpc(MapNum, MapNpcNum).Num ' Make sure the npc isn't already dead If MapNpc(MapNum, MapNpcNum).Vital(Vitals.HP) <= 0 Then Exit Function End If ' Make sure they are on the same map If IsPlaying(Attacker) Then If NpcNum > 0 And GetTickCount > TempPlayer(Attacker).AttackTimer + 1000 Then ' Check if at same coordinates Select Case GetPlayerDir(Attacker) Case DIR_UP NpcX = MapNpc(MapNum, MapNpcNum).x NpcY = MapNpc(MapNum, MapNpcNum).y + 1 Case DIR_DOWN NpcX = MapNpc(MapNum, MapNpcNum).x NpcY = MapNpc(MapNum, MapNpcNum).y - 1 Case DIR_LEFT NpcX = MapNpc(MapNum, MapNpcNum).x + 1 NpcY = MapNpc(MapNum, MapNpcNum).y Case DIR_RIGHT NpcX = MapNpc(MapNum, MapNpcNum).x - 1 NpcY = MapNpc(MapNum, MapNpcNum).y Case DIR_UP_LEFT NpcX = MapNpc(MapNum, MapNpcNum).x + 1 NpcY = MapNpc(MapNum, MapNpcNum).y + 1 Case DIR_UP_RIGHT NpcX = MapNpc(MapNum, MapNpcNum).x - 1 NpcY = MapNpc(MapNum, MapNpcNum).y + 1 Case DIR_DOWN_LEFT NpcX = MapNpc(MapNum, MapNpcNum).x + 1 NpcY = MapNpc(MapNum, MapNpcNum).y - 1 Case DIR_DOWN_RIGHT NpcX = MapNpc(MapNum, MapNpcNum).x - 1 NpcY = MapNpc(MapNum, MapNpcNum).y - 1 End Select If NpcX = GetPlayerX(Attacker) Then If NpcY = GetPlayerY(Attacker) Then If Npc(NpcNum).Behavior <> NPC_BEHAVIOR_FRIENDLY And Npc(NpcNum).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then CanAttackNpc = True Else Call PlayerMsg(Attacker, "You cannot attack a " & Trim$(Npc(NpcNum).Name) & "!", BrightBlue) End If End If End If End If End If End Function Next find Code: Function CanNpcAttackPlayer(ByVal MapNpcNum As Long, ByVal Index As Long) As Boolean Replace the sub with Code: Function CanNpcAttackPlayer(ByVal MapNpcNum As Long, ByVal Index As Long) As Boolean Dim MapNum As Long, NpcNum As Long CanNpcAttackPlayer = False ' Check for subscript out of range If MapNpcNum <= 0 Or MapNpcNum > MAX_MAP_NPCS Or IsPlaying(Index) = False Then Exit Function End If ' Check for subscript out of range If MapNpc(GetPlayerMap(Index), MapNpcNum).Num <= 0 Then Exit Function End If MapNum = GetPlayerMap(Index) NpcNum = MapNpc(MapNum, MapNpcNum).Num ' Make sure the npc isn't already dead If MapNpc(MapNum, MapNpcNum).Vital(Vitals.HP) <= 0 Then Exit Function End If ' Make sure npcs dont attack more then once a second If GetTickCount < MapNpc(MapNum, MapNpcNum).AttackTimer + 1000 Then Exit Function End If ' Make sure we dont attack the player if they are switching maps If TempPlayer(Index).GettingMap = YES Then Exit Function End If MapNpc(MapNum, MapNpcNum).AttackTimer = GetTickCount ' Make sure they are on the same map If IsPlaying(Index) Then If NpcNum > 0 Then ' Check if at same coordinates If (GetPlayerY(Index) + 1 = MapNpc(MapNum, MapNpcNum).y) And (GetPlayerX(Index) = MapNpc(MapNum, MapNpcNum).x) Then CanNpcAttackPlayer = True Else If (GetPlayerY(Index) - 1 = MapNpc(MapNum, MapNpcNum).y) And (GetPlayerX(Index) = MapNpc(MapNum, MapNpcNum).x) Then CanNpcAttackPlayer = True Else If (GetPlayerY(Index) = MapNpc(MapNum, MapNpcNum).y) And (GetPlayerX(Index) + 1 = MapNpc(MapNum, MapNpcNum).x) Then CanNpcAttackPlayer = True Else If (GetPlayerY(Index) = MapNpc(MapNum, MapNpcNum).y) And (GetPlayerX(Index) - 1 = MapNpc(MapNum, MapNpcNum).x) Then CanNpcAttackPlayer = True Else If (GetPlayerY(Index) + 1 = MapNpc(MapNum, MapNpcNum).y) And (GetPlayerX(Index) + 1 = MapNpc(MapNum, MapNpcNum).x) Then CanNpcAttackPlayer = True Else If (GetPlayerY(Index) + 1 = MapNpc(MapNum, MapNpcNum).y) And (GetPlayerX(Index) - 1 = MapNpc(MapNum, MapNpcNum).x) Then CanNpcAttackPlayer = True Else If (GetPlayerY(Index) = MapNpc(MapNum, MapNpcNum).y) - 1 And (GetPlayerX(Index) + 1 = MapNpc(MapNum, MapNpcNum).x) Then CanNpcAttackPlayer = True Else If (GetPlayerY(Index) = MapNpc(MapNum, MapNpcNum).y) - 1 And (GetPlayerX(Index) - 1 = MapNpc(MapNum, MapNpcNum).x) Then CanNpcAttackPlayer = True End If End If End If End If End If End If End If End If ' Select Case MapNpc(MapNum, MapNpcNum).Dir ' Case DIR_UP ' If (GetPlayerY(Index) + 1 = MapNpc(MapNum, MapNpcNum).y) And (GetPlayerX(Index) = MapNpc(MapNum, MapNpcNum).x) Then ' CanNpcAttackPlayer = True ' End If ' ' Case DIR_DOWN ' If (GetPlayerY(Index) - 1 = MapNpc(MapNum, MapNpcNum).y) And (GetPlayerX(Index) = MapNpc(MapNum, MapNpcNum).x) Then ' CanNpcAttackPlayer = True ' End If ' ' Case DIR_LEFT ' If (GetPlayerY(Index) = MapNpc(MapNum, MapNpcNum).y) And (GetPlayerX(Index) + 1 = MapNpc(MapNum, MapNpcNum).x) Then ' CanNpcAttackPlayer = True ' End If ' ' Case DIR_RIGHT ' If (GetPlayerY(Index) = MapNpc(MapNum, MapNpcNum).y) And (GetPlayerX(Index) - 1 = MapNpc(MapNum, MapNpcNum).x) Then ' CanNpcAttackPlayer = True ' End If ' End Select End If End If End Function Next Find this sub Code: Sub SetPlayerY(ByVal Index As Long, ByVal y As Long) Player(Index).Char(TempPlayer(Index).CharNum).y = y End Sub Below it Add this sub Code: Sub SetPlayerXY(ByVal Index As Long, ByVal x As Long, ByVal y As Long) Player(Index).Char(TempPlayer(Index).CharNum).x = x Player(Index).Char(TempPlayer(Index).CharNum).y = y End Sub Next find Code: Sub PlayerMove(ByVal Index As Long, ByVal Dir As Long, ByVal Movement As Long) Replace the sub with Code: Sub PlayerMove(ByVal Index As Long, ByVal Dir As Long, ByVal Movement As Long) Dim Packet As String Dim MapNum As Long Dim x As Long Dim y As Long Dim Moved As Byte ' Check for subscript out of range If IsPlaying(Index) = False Or Dir < DIR_UP Or Dir > DIR_DOWN_RIGHT Or Movement < 1 Or Movement > 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 <= 0 Or MapNum > MAX_MAPS Or MapNpcNum <= 0 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 <= 0 Or MapNum > MAX_MAPS Or MapNpcNum <= 0 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 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) End Select End Sub Next Find Code: Sub NpcDir(ByVal MapNum As Long, ByVal MapNpcNum As Long, ByVal Dir As Long) Replace sub with Code: Sub NpcDir(ByVal MapNum As Long, ByVal MapNpcNum As Long, ByVal Dir As Long) Dim Packet As String ' Check for subscript out of range If MapNum <= 0 Or MapNum > MAX_MAPS Or MapNpcNum <= 0 Or MapNpcNum > MAX_MAP_NPCS Or Dir < DIR_UP Or Dir > DIR_DOWN_RIGHT Then Exit Sub End If MapNpc(MapNum, MapNpcNum).Dir = Dir Packet = SNpcDir & SEP_CHAR & MapNpcNum & SEP_CHAR & Dir & END_CHAR Call SendDataToMap(MapNum, Packet) End Sub Next Find Code: Sub HandlePlayerMove(ByVal Index As Long, ByRef Parse() As String) Replace sub with Code: Sub HandlePlayerMove(ByVal Index As Long, ByRef Parse() As String) Dim Dir As Long, Movement As Long If TempPlayer(Index).GettingMap = YES Then Exit Sub End If Dir = Val(Parse(1)) Movement = Val(Parse(2)) ' Prevent hacking If Dir < DIR_UP Or Dir > DIR_DOWN_RIGHT Then Call HackingAttempt(Index, "Invalid Direction") Exit Sub End If ' Prevent hacking If Movement < 1 Or Movement > 2 Then Call HackingAttempt(Index, "Invalid Movement") Exit Sub End If ' Prevent player from moving if they have casted a spell If TempPlayer(Index).CastedSpell = YES Then ' Check if they have already casted a spell, and if so we can't let them move If GetTickCount > TempPlayer(Index).AttackTimer + 1000 Then TempPlayer(Index).CastedSpell = NO Else Call SendPlayerXY(Index) Exit Sub End If End If Call PlayerMove(Index, Dir, Movement) End Sub Next Find Code: Sub HandlePlayerDir(ByVal Index As Long, ByRef Parse() As String) Replace sub with Code: Sub HandlePlayerDir(ByVal Index As Long, ByRef Parse() As String) Dim Dir As Long If TempPlayer(Index).GettingMap = YES Then Exit Sub End If Dir = Val(Parse(1)) ' Prevent hacking If Dir < DIR_UP Or Dir > DIR_DOWN_RIGHT Then Call HackingAttempt(Index, "Invalid Direction") Exit Sub End If Call SetPlayerDir(Index, Dir) Call SendDataToMapBut(Index, GetPlayerMap(Index), "playerdir" & SEP_CHAR & Index & SEP_CHAR & GetPlayerDir(Index) & END_CHAR) End Sub In Code: Sub HandleUseItem(ByVal Index As Long, ByRef Parse() As String) Find Code: Case ITEM_TYPE_KEY Select Case GetPlayerDir(Index) Case DIR_UP If GetPlayerY(Index) > 0 Then x = GetPlayerX(Index) y = GetPlayerY(Index) - 1 Else Exit Sub End If Case DIR_DOWN If GetPlayerY(Index) < MAX_MAPY Then x = GetPlayerX(Index) y = GetPlayerY(Index) + 1 Else Exit Sub End If Case DIR_LEFT If GetPlayerX(Index) > 0 Then x = GetPlayerX(Index) - 1 y = GetPlayerY(Index) Else Exit Sub End If Case DIR_RIGHT If GetPlayerX(Index) < MAX_MAPX Then x = GetPlayerX(Index) + 1 y = GetPlayerY(Index) Else Exit Sub End If Replace this bit of code with Code: Case ITEM_TYPE_KEY Select Case GetPlayerDir(Index) Case DIR_UP If GetPlayerY(Index) > 0 Then x = GetPlayerX(Index) y = GetPlayerY(Index) - 1 Else Exit Sub End If Case DIR_DOWN If GetPlayerY(Index) < MAX_MAPY Then x = GetPlayerX(Index) y = GetPlayerY(Index) + 1 Else Exit Sub End If Case DIR_LEFT If GetPlayerX(Index) > 0 Then x = GetPlayerX(Index) - 1 y = GetPlayerY(Index) Else Exit Sub End If Case DIR_RIGHT If GetPlayerX(Index) < MAX_MAPX Then x = GetPlayerX(Index) + 1 y = GetPlayerY(Index) Else Exit Sub End If Case DIR_UP_LEFT If GetPlayerY(Index) > 0 And GetPlayerX(Index) > 0 Then x = GetPlayerX(Index) - 1 y = GetPlayerY(Index) - 1 Else Exit Sub End If Case DIR_UP_RIGHT If GetPlayerY(Index) > 0 And GetPlayerX(Index) < MAX_MAPX Then x = GetPlayerX(Index) + 1 y = GetPlayerY(Index) - 1 Else Exit Sub End If Case DIR_DOWN_LEFT If GetPlayerY(Index) < MAX_MAPY And GetPlayerX(Index) > 0 Then x = GetPlayerX(Index) - 1 y = GetPlayerY(Index) + 1 Else Exit Sub End If Case DIR_DOWN_RIGHT If GetPlayerY(Index) < MAX_MAPY And GetPlayerX(Index) < MAX_MAPX Then x = GetPlayerX(Index) + 1 y = GetPlayerY(Index) + 1 Else Exit Sub End If Next find Code: Sub HandleRequestNewMap Replace this sub with Code: Sub HandleRequestNewMap(ByVal Index As Long, ByRef Parse() As String) Dim Dir As Long Dir = Val(Parse(1)) ' Prevent hacking If Dir < DIR_UP Or Dir > DIR_DOWN_RIGHT Then Call HackingAttempt(Index, "Invalid Direction") Exit Sub End If Call PlayerMove(Index, Dir, 1) End Sub UpdateNPCAi still needs to be done. |
Author: | Tony [ Tue Sep 23, 2008 5:02 am ] |
Post subject: | Re: Basic Diagonal Movement |
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. |
Author: | Nean [ Tue Sep 23, 2008 6:25 am ] |
Post subject: | Re: Basic Diagonal Movement |
I checked this out, and it's loads of fun. I really like it. Great tut. |
Author: | Lea [ Tue Sep 23, 2008 6:38 am ] |
Post subject: | Re: Basic Diagonal Movement |
Do you people never sleep? Can I check the forum every 10 minutes and not have new posts once in a while? jeeze... |
Author: | Doomy [ Tue Sep 23, 2008 7:01 am ] |
Post subject: | Re: Basic Diagonal Movement |
lol nope you cant and thats good that there are always posts |
Author: | William [ Tue Sep 23, 2008 3:08 pm ] |
Post subject: | Re: Basic Diagonal Movement |
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. |
Author: | Tony [ Tue Sep 23, 2008 8:59 pm ] |
Post subject: | Re: Basic Diagonal Movement |
That's odd.. hmm I'll figure out what's wrong when I get home. You downloaded the source right? |
Author: | Mattyw [ Wed Oct 01, 2008 7:30 pm ] |
Post subject: | Re: Basic Diagonal Movement |
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. |
Author: | William [ Wed Oct 01, 2008 8:01 pm ] |
Post subject: | Re: Basic Diagonal Movement |
Dont run the client and server. Run it from the source! And there are a few glitches, but nothing that cant be fixed. |
Author: | Mattyw [ Wed Oct 01, 2008 8:11 pm ] |
Post subject: | Re: Basic Diagonal Movement |
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 |
Author: | William [ Thu Oct 02, 2008 2:32 pm ] |
Post subject: | Re: Basic Diagonal Movement |
If those things are fixed, and movement is slowed down diagonal. I'm pretty sure this will be used by a lot of people. |
Author: | Mattyw [ Thu Oct 02, 2008 2:48 pm ] |
Post subject: | Re: Basic Diagonal Movement |
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. |
Author: | William [ Sat Oct 25, 2008 1:14 pm ] |
Post subject: | Re: Basic Diagonal Movement |
Is this tutorial from es or did you make it yourself? |
Author: | GIAKEN [ Sat Oct 25, 2008 8:41 pm ] |
Post subject: | Re: Basic Diagonal Movement |
Definitely doesn't feel like ES' diag. movement tutorial. |
Author: | Tony [ Tue Oct 28, 2008 7:26 pm ] |
Post subject: | Re: Basic Diagonal Movement |
William wrote: Is this tutorial from es or did you make it yourself? Made completely by me, no reference or used source. |
Author: | wanai [ Tue Dec 28, 2021 8:08 pm ] |
Post subject: | Re: Basic Diagonal Movement |
Econ |
Author: | wanai [ Tue Dec 28, 2021 8:09 pm ] |
Post subject: | Re: Basic Diagonal Movement |
54.8 |
Author: | wanai [ Tue Dec 28, 2021 8:10 pm ] |
Post subject: | Re: Basic Diagonal Movement |
Bett |
Author: | wanai [ Tue Dec 28, 2021 8:12 pm ] |
Post subject: | Re: Basic Diagonal Movement |
Bett |
Author: | wanai [ Tue Dec 28, 2021 8:13 pm ] |
Post subject: | Re: Basic Diagonal Movement |
Comp |
Author: | wanai [ Tue Dec 28, 2021 8:14 pm ] |
Post subject: | Re: Basic Diagonal Movement |
Jewe |
Author: | wanai [ Tue Dec 28, 2021 8:15 pm ] |
Post subject: | Re: Basic Diagonal Movement |
What |
Author: | wanai [ Tue Dec 28, 2021 8:16 pm ] |
Post subject: | Re: Basic Diagonal Movement |
Fris |
Author: | wanai [ Tue Dec 28, 2021 8:17 pm ] |
Post subject: | Re: Basic Diagonal Movement |
Brad |
Page 1 of 50 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |